|
@@ -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){
|