| | |
| | | .collect(Collectors.groupingBy(PeakValleyFlatEntity::getPointNo)); |
| | | |
| | | groupedByPointNo.entrySet().stream().forEach(entry -> { |
| | | |
| | | //计算昨日的峰/谷累积量 |
| | | double value = getSumValue(entry.getValue(), 1, calendar); |
| | | |
| | | //计算昨日总电耗 |
| | | Calendar cal = (Calendar) calendar.clone(); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endTime = calendar.getTime(); |
| | |
| | | Date startTime = cal.getTime(); |
| | | cal.add(Calendar.DAY_OF_YEAR, -29); |
| | | Date monthStartTime = cal.getTime(); |
| | | |
| | | //计算昨日的峰/谷累积量 |
| | | double value = getSumValue(entry.getValue(), 1, calendar); |
| | | |
| | | //计算昨日总电耗 |
| | | double totalValue = getSumValueTotal(entry.getValue().get(0).getPowerNo(), startTime, endTime); |
| | | |
| | | //计算前三十日峰/谷累积量 |
| | | double valueMonth = getSumValueTotal(entry.getValue().get(0).getPointNoTotal(), monthStartTime, startTime)+value; |
| | | |
| | | //计算前三十日总电耗 |
| | | double totalValueMonth = getSumValueTotal(entry.getValue().get(0).getPowerNo(), monthStartTime, endTime); |
| | | |
| | | logger.info("name:"+entry.getValue().get(0).getName()+";value:"+value+";totalValue:"+totalValue+";valueMonth:"+valueMonth+";totalValueMonth:"+totalValueMonth); |
| | | |
| | | //下发昨日占比 |
| | | ApiPointValueWriteDTO percentDto = new ApiPointValueWriteDTO(); |
| | |
| | | |
| | | //下发昨日峰/谷累积量 |
| | | ApiPointValueWriteDTO totalDto = new ApiPointValueWriteDTO(); |
| | | percentDto.setPointNo(entry.getValue().get(0).getPointNoTotal()); |
| | | percentDto.setValue(value); |
| | | totalDto.setPointNo(entry.getValue().get(0).getPointNoTotal()); |
| | | totalDto.setValue(totalValue); |
| | | dataPointApi.writePointRealValue(totalDto); |
| | | |
| | | //计算前三十日峰/谷累积量 |
| | | double valueMonth = getSumValueTotal(entry.getValue().get(0).getPointNoTotal(), monthStartTime, endTime); |
| | | |
| | | //计算前三十日总电耗 |
| | | double totalValueMonth = getSumValueTotal(entry.getValue().get(0).getPowerNo(), monthStartTime, endTime); |
| | | |
| | | //下发前三十日占比 |
| | | ApiPointValueWriteDTO monthDto = new ApiPointValueWriteDTO(); |
| | |
| | | double percentMonth = totalValueMonth == 0 ? 0 : valueMonth / totalValueMonth * 100; |
| | | monthDto.setValue(percentMonth); |
| | | dataPointApi.writePointRealValue(monthDto); |
| | | |
| | | }); |
| | | } catch (Exception ex) { |
| | | logger.error("runPeakValleyFlatTask运行异常", ex); |
| | |
| | | } |
| | | //根据配置获取startTime、endTime |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeSplit[0])); |
| | | cal.set(Calendar.MINUTE, Integer.parseInt(timeSplit[1])); |
| | | cal.add(Calendar.DAY_OF_YEAR, -ago); |