|
@@ -1,15 +1,12 @@
|
|
|
package com.bosshand.virgo.api.service;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.bosshand.virgo.api.dao.ProjectCityWeatherDao;
|
|
|
-import com.bosshand.virgo.api.dao.WeeklyDao;
|
|
|
-import com.bosshand.virgo.api.dao.WeeklySetDao;
|
|
|
-import com.bosshand.virgo.api.dao.WeeklyTypeDao;
|
|
|
-import com.bosshand.virgo.api.model.ProjectCityWeather;
|
|
|
-import com.bosshand.virgo.api.model.Weekly;
|
|
|
-import com.bosshand.virgo.api.model.WeeklySet;
|
|
|
-import com.bosshand.virgo.api.model.WeeklyType;
|
|
|
+import com.bosshand.virgo.api.dao.*;
|
|
|
+import com.bosshand.virgo.api.model.*;
|
|
|
+import com.bosshand.virgo.api.operate.dao.OperateDeviceDao;
|
|
|
+import com.bosshand.virgo.api.operate.model.OperateDevice;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -31,6 +28,24 @@ public class WeeklyService {
|
|
|
@Autowired
|
|
|
ProjectCityWeatherDao projectCityWeatherDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ContractDao contractDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaymentDao paymentDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PaymentOrdinaryDao paymentOrdinaryDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OperateDeviceDao operateDeviceDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProjectItemTargetRoomDao projectItemTargetRoomDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ManagerClient managerClient;
|
|
|
+
|
|
|
public List<Weekly> getByProjectId(long projectId){
|
|
|
return weeklyDao.getByProjectId(projectId);
|
|
|
}
|
|
@@ -87,8 +102,60 @@ public class WeeklyService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public WeeklyType getWeeklyType (long id){
|
|
|
- return weeklyTypeDao.getWeeklyType(id);
|
|
|
+ public WeeklyType getWeeklyType(long id) {
|
|
|
+ WeeklyType weeklyType = weeklyTypeDao.getWeeklyType(id);
|
|
|
+ Weekly weekly = weeklyDao.get(weeklyType.getWeeklyId());
|
|
|
+ String startDate = weekly.getStartDate();
|
|
|
+ String endDate = weekly.getEndDate();
|
|
|
+ long projectId = weekly.getProjectId();
|
|
|
+ switch (weeklyType.getType()) {
|
|
|
+ //客户管理
|
|
|
+ case 1:
|
|
|
+ if (weeklyType.getData() == null) {
|
|
|
+ String data = managerClient.listByDate(startDate, endDate, projectId);
|
|
|
+ weeklyType.setData(data);
|
|
|
+ weeklyTypeDao.update(weeklyType);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //合同管理
|
|
|
+ case 2:
|
|
|
+ if (weeklyType.getData() == null) {
|
|
|
+ List<Contract> data = contractDao.getProjectId(startDate, endDate, projectId);
|
|
|
+ weeklyType.setData(JSON.toJSONString(data));
|
|
|
+ weeklyTypeDao.update(weeklyType);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //费用管理
|
|
|
+ case 3:
|
|
|
+ if (weeklyType.getData() == null) {
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+ List<Payment> paymentList = paymentDao.getProjectId(startDate, endDate, projectId);
|
|
|
+ js.put("payment", paymentList);
|
|
|
+ List<PaymentOrdinary> paymentOrdinaryList = paymentOrdinaryDao.getProjectId(startDate, endDate, projectId);
|
|
|
+ js.put("paymentOrdinary", paymentOrdinaryList);
|
|
|
+ weeklyType.setData(js.toJSONString());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //设备管理
|
|
|
+ case 4:
|
|
|
+ if (weeklyType.getData() == null) {
|
|
|
+ List<OperateDevice> data = operateDeviceDao.getProjectId(startDate, endDate, projectId);
|
|
|
+ weeklyType.setData(JSON.toJSONString(data));
|
|
|
+ weeklyTypeDao.update(weeklyType);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //房源管理
|
|
|
+ case 5:
|
|
|
+ if (weeklyType.getData() == null) {
|
|
|
+ List<ProjectItemTargetRoom> data = projectItemTargetRoomDao.listByDate(startDate, endDate, projectId);
|
|
|
+ weeklyType.setData(JSON.toJSONString(data));
|
|
|
+ weeklyTypeDao.update(weeklyType);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new IllegalStateException("Unexpected value: " + weeklyType.getType());
|
|
|
+ }
|
|
|
+ return weeklyType;
|
|
|
}
|
|
|
|
|
|
public WeeklySet saveWeeklySet(WeeklySet weeklySet) {
|