鞍钢鲅鱼圈能源管控系统后端代码
dongyukun
7 天以前 54a2a28953b310ba421f0765a55bd2d650645443
ansteel-biz/src/main/java/com/iailab/module/ansteel/job/task/RunPeakValleyFlatTask.java
@@ -46,13 +46,9 @@
                    .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();
@@ -60,7 +56,20 @@
                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();
@@ -71,15 +80,9 @@
                //下发昨日峰/谷累积量
                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();
@@ -87,7 +90,6 @@
                double percentMonth = totalValueMonth == 0 ? 0 : valueMonth / totalValueMonth * 100;
                monthDto.setValue(percentMonth);
                dataPointApi.writePointRealValue(monthDto);
            });
        } catch (Exception ex) {
            logger.error("runPeakValleyFlatTask运行异常", ex);
@@ -102,6 +104,7 @@
        }
        //根据配置获取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);
@@ -171,9 +174,13 @@
            dto.setStart(startTime);
            dto.setEnd(endTime);
            logger.info("开始查询,测点:" + entity.getPowerNo() + "startTime:" + startTime + "endTime:" + endTime);
            List<ApiPointValueDTO> valueList;
            //查找数据
            List<ApiPointValueDTO> valueList = dataPointApi.queryPointHistoryValue(dto);
            try {
                valueList = dataPointApi.queryPointHistoryValue(dto);
            } catch (Exception e) {
                throw new RuntimeException("查询测点异常");
            }
            //补全数据
            valueList = fillMissingData(valueList, startTime, endTime);
            //累加