dcs 3 bulan lalu
induk
melakukan
15654e6d94

+ 1 - 14
virgo.api/src/main/java/com/bosshand/virgo/api/job/JobProjectWeeklyQuartz.java

@@ -8,7 +8,6 @@ import com.bosshand.virgo.api.dao.ProjectDao;
 import com.bosshand.virgo.api.dao.WeeklyDao;
 import com.bosshand.virgo.api.dao.WeeklyTypeDao;
 import com.bosshand.virgo.api.model.Project;
-import com.bosshand.virgo.api.model.ProjectCityWeather;
 import com.bosshand.virgo.api.model.Weekly;
 import com.bosshand.virgo.api.model.WeeklyType;
 import org.quartz.JobDataMap;
@@ -85,19 +84,7 @@ public class JobProjectWeeklyQuartz extends QuartzJobBean {
             switch (i) {
                 //天气情况
                 case 0:
-                    String start = DateUtil.formatDate(DateUtil.parseDate(startDate));
-                    String end = DateUtil.formatDate(DateUtil.parseDate(endDate));
-                    List<ProjectCityWeather> weatherList = projectCityWeatherDao.getProjectId(start, end, projectId);
-                    if (weatherList.size() > 0) {
-                        List<JSONObject> ls = new ArrayList<>();
-                        for (ProjectCityWeather weather : weatherList) {
-                            JSONObject json = new JSONObject();
-                            json.put("date", DateUtil.formatDate(weather.getDate()));
-                            json.put("weather", weather.getWeatherData());
-                            ls.add(json);
-                        }
-                        wt.setData(ls.toString());
-                    }
+                    wt.setData(null);
                     break;
                 //进度情况
                 case 1:

+ 35 - 2
virgo.api/src/main/java/com/bosshand/virgo/api/service/WeeklyService.java

@@ -1,14 +1,19 @@
 package com.bosshand.virgo.api.service;
 
+import cn.hutool.core.date.DateUtil;
+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 org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @Service
@@ -23,6 +28,9 @@ public class WeeklyService {
     @Autowired
     WeeklySetDao weeklySetDao;
 
+    @Autowired
+    ProjectCityWeatherDao projectCityWeatherDao;
+
     public List<Weekly> getByProjectId(long projectId){
        return weeklyDao.getByProjectId(projectId);
     }
@@ -50,8 +58,33 @@ public class WeeklyService {
         return weeklyType;
     }
 
-    public List<WeeklyType> getByWeeklyId (long weeklyId){
-        return weeklyTypeDao.getByWeeklyId(weeklyId);
+    public List<WeeklyType> getByWeeklyId(long weeklyId) {
+        Weekly weekly = weeklyDao.get(weeklyId);
+        long projectId = weekly.getProjectId();
+        String startDate = weekly.getStartDate();
+        String endDate = weekly.getEndDate();
+        String start = DateUtil.formatDate(DateUtil.parseDate(startDate));
+        String end = DateUtil.formatDate(DateUtil.parseDate(endDate));
+        List<ProjectCityWeather> weatherList = projectCityWeatherDao.getProjectId(start, end, projectId);
+        List<JSONObject> ls = new ArrayList<>();
+        if (weatherList.size() > 0) {
+            for (ProjectCityWeather weather : weatherList) {
+                JSONObject json = new JSONObject();
+                json.put("date", DateUtil.formatDate(weather.getDate()));
+                json.put("weather", weather.getWeatherData());
+                ls.add(json);
+            }
+        }
+        List<WeeklyType> list = weeklyTypeDao.getByWeeklyId(weeklyId);
+        for (WeeklyType type : list) {
+            if (type.getType() == 0) {
+                if (type.getData() == null) {
+                    type.setData(ls.toString());
+                    weeklyTypeDao.update(type);
+                }
+            }
+        }
+        return list;
     }
 
     public WeeklyType getWeeklyType (long id){