|
@@ -99,18 +99,13 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
|
|
|
@Override
|
|
|
@Cacheable("windspeedforecastcontrast")
|
|
|
- public JSONObject getContrast(String stationid, String starttime, String endtime, int timescale) {
|
|
|
- if(stationid.isEmpty()||starttime.isEmpty()||endtime.isEmpty()){
|
|
|
- return JsonResult.error(ResultCode.PARAM_IS_BLANK);
|
|
|
- }
|
|
|
- Date dateStart = DateUtil.str2DateTime(starttime);
|
|
|
- Date dateEnd = DateUtil.str2DateTime(endtime);
|
|
|
- Date dateStartQntq = DateUtil.str2QntqDateTime(starttime);
|
|
|
- Date dateEndQntq = DateUtil.str2QntqDateTime(endtime);
|
|
|
+ public JSONObject getContrast(String stationid, Date starttime, Date endtime, int timescale) {
|
|
|
+ Date dateStartQntq = DateUtil.dateTimeAddYear(starttime,-1);
|
|
|
+ Date dateEndQntq = DateUtil.dateTimeAddYear(endtime,-1);
|
|
|
|
|
|
//list1短期 list2超短期 list3去年同期短期 list4去年同期超短期
|
|
|
- List<Windspeedforecastshortterm> list1 = getShortterm(stationid,dateStart,dateEnd);
|
|
|
- List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid,dateStart,dateEnd,timescale);
|
|
|
+ List<Windspeedforecastshortterm> list1 = getShortterm(stationid,starttime,endtime);
|
|
|
+ List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid,starttime,endtime,timescale);
|
|
|
List<Windspeedforecastshortterm> list3 = getShortterm(stationid,dateStartQntq,dateEndQntq);
|
|
|
List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid,dateStartQntq,dateEndQntq,timescale);
|
|
|
List<WindspeedforecastContrast> windspeedforecastContrasts = new ArrayList<>();
|
|
@@ -124,10 +119,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
windspeedforecastContrasts.add(wsfcc);
|
|
|
});
|
|
|
Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity()));
|
|
|
- /*Map<Date, WindspeedforecastContrast> contrastMap = new HashMap<>();
|
|
|
- for (WindspeedforecastContrast wsfcc : windspeedforecastContrasts) {
|
|
|
- contrastMap.put(wsfcc.getCalctime(), wsfcc);
|
|
|
- }*/
|
|
|
+
|
|
|
list2.forEach(l-> {
|
|
|
WindspeedforecastContrast wsfcc = contrastMap.get(l.getCalctime());
|
|
|
wsfcc.setForecastpowersp(l.getForecastpower());
|
|
@@ -135,14 +127,14 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
});
|
|
|
//给年份加一年,然后匹配
|
|
|
list3.forEach(l-> {
|
|
|
- WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime()));
|
|
|
+ WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
|
|
|
wsfcc.setActualpowertq(l.getActualpower());
|
|
|
wsfcc.setForecastpowertq(l.getForecastpower());
|
|
|
wsfcc.setActualwindspeedtq(l.getActualwindspeed());
|
|
|
wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
|
|
|
});
|
|
|
list4.forEach(l-> {
|
|
|
- WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime()));
|
|
|
+ WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
|
|
|
wsfcc.setForecastpowersptq(l.getForecastpower());
|
|
|
wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
|
|
|
});
|