| | |
| | | double value = getSumValue(entry.getValue(), 1, calendar); |
| | | |
| | | //计算昨日总电耗 |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | Calendar cal = (Calendar) calendar.clone(); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | Date endTime = calendar.getTime(); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startTime = calendar.getTime(); |
| | | cal.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date startTime = cal.getTime(); |
| | | double totalValue = getSumValueTotal(entry.getValue().get(0).getPowerNo(), startTime,endTime); |
| | | |
| | | //下发昨日占比 |
| | | ApiPointValueWriteDTO dto = new ApiPointValueWriteDTO(); |
| | | dto.setPointNo(entry.getValue().get(0).getPointNo()); |
| | | dto.setValue(value/totalValue*100); |
| | | double percent = totalValue==0?0:value/totalValue*100; |
| | | dto.setValue(percent); |
| | | dataPointApi.writePointRealValue(dto); |
| | | |
| | | if(entry.getValue().get(0).getPointNoMonth()!=null){ |
| | |
| | | } |
| | | |
| | | //计算前三十日总电耗 |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -30); |
| | | Date startTimeMonth = calendar.getTime(); |
| | | Calendar monthCal = (Calendar) calendar.clone(); |
| | | monthCal.set(Calendar.MILLISECOND, 0); |
| | | monthCal.set(Calendar.MINUTE, 0); |
| | | monthCal.set(Calendar.HOUR_OF_DAY, 0); |
| | | monthCal.add(Calendar.DAY_OF_YEAR, -30); |
| | | Date startTimeMonth = monthCal.getTime(); |
| | | double totalValueMonth = getSumValueTotal(entry.getValue().get(0).getPowerNo(), startTimeMonth,endTime); |
| | | |
| | | //下发前三十日占比 |
| | | ApiPointValueWriteDTO monthDto = new ApiPointValueWriteDTO(); |
| | | monthDto.setPointNo(entry.getValue().get(0).getPointNoMonth()); |
| | | monthDto.setValue(value30/totalValueMonth*100); |
| | | double percentMonth = totalValueMonth==0?0:value30/totalValueMonth*100; |
| | | monthDto.setValue(percentMonth); |
| | | dataPointApi.writePointRealValue(monthDto); |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | | logger.error("runPeakValleyFlatTask运行异常"); |
| | | ex.printStackTrace(); |
| | | logger.error("runPeakValleyFlatTask运行异常", ex); |
| | | } |
| | | } |
| | | |
| | | private Date getTime(String timeStr, int ago, Calendar calendar) { |
| | | Calendar cal = (Calendar) calendar.clone(); |
| | | String[] timeSplit = timeStr.split(":"); |
| | | if (timeSplit.length != 2) { |
| | | throw new IllegalArgumentException("时间配置格式不合法"); |
| | | } |
| | | //根据配置获取startTime、endTime |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeSplit[0])); |
| | | calendar.set(Calendar.MINUTE, Integer.parseInt(timeSplit[1])); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -ago); |
| | | return calendar.getTime(); |
| | | cal.set(Calendar.MILLISECOND, 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); |
| | | return cal.getTime(); |
| | | } |
| | | |
| | | private List<ApiPointValueDTO> fillMissingData(List<ApiPointValueDTO> valueList, |
| | |
| | | dto.setPointNo(entity.getPowerNo()); |
| | | dto.setStart(startTime); |
| | | dto.setEnd(endTime); |
| | | logger.info("开始查询,测点:"+entity.getPowerNo()+"startTime:"+startTime+"endTime:"+endTime); |
| | | |
| | | //查找数据 |
| | | List<ApiPointValueDTO> valueList = dataPointApi.queryPointHistoryValue(dto); |