|
|
|
@ -1485,24 +1485,36 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
private List<ActivePowerVo> getLoadsByDay(EminfoAndEmParamVo device) { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
// 结束日期
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
Date end = calendar.getTime(); |
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
|
// 开始日期
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":00:00"; |
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); |
|
|
|
|
if (CollectionUtil.isEmpty(records)) { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
Date start = calendar.getTime(); |
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(end,DateUtil.PATTERN_DATETIME), 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); |
|
|
|
|
List<ActivePowerVo> activePowers = new ArrayList<>(); |
|
|
|
|
while (start.compareTo(end) < 0){ |
|
|
|
|
String time = DateUtil.format(start,"yyyy-MM-dd HH"); |
|
|
|
|
ActivePowerVo active = new ActivePowerVo(); |
|
|
|
|
active.setStrHour(time); |
|
|
|
|
active.setHour(start.getHours()); |
|
|
|
|
if(CollectionUtil.isNotEmpty(records)){ |
|
|
|
|
Optional<AnalyseDataTaosVO> analyseData = records.stream().filter(o->o.getTs().contains(time)).findFirst(); |
|
|
|
|
if(analyseData.isPresent()){ |
|
|
|
|
if(StringUtil.isNotBlank(analyseData.get().getVal())){ |
|
|
|
|
active.setActivePower(analyseData.get().getVal()); |
|
|
|
|
}else{ |
|
|
|
|
active.setActivePower("0.0"); |
|
|
|
|
} |
|
|
|
|
return records.stream().map(record -> { |
|
|
|
|
ActivePowerVo load = new ActivePowerVo(); |
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
load.setStrHour(DateUtil.format(time,"yyyy-MM-dd HH")); |
|
|
|
|
load.setHour(time.getHours()); |
|
|
|
|
if(StringUtil.isNotBlank(record.getVal())){ |
|
|
|
|
load.setActivePower(record.getVal()); |
|
|
|
|
}else{ |
|
|
|
|
active.setActivePower("0.0"); |
|
|
|
|
} |
|
|
|
|
return load; |
|
|
|
|
}).sorted(Comparator.comparing(ActivePowerVo::getStrHour)).collect(Collectors.toList()); |
|
|
|
|
}else{ |
|
|
|
|
active.setActivePower("0.0"); |
|
|
|
|
} |
|
|
|
|
activePowers.add(active); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
} |
|
|
|
|
return activePowers.stream().sorted(Comparator.comparing(ActivePowerVo::getStrHour)).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|