鞍钢鲅鱼圈能源管控系统后端代码
dongyukun
昨天 3c2259265505c213f04b9615633a465d394dcce2
ansteel-biz/src/main/java/com/iailab/module/ansteel/job/task/RunCokingMainTask.java
@@ -57,6 +57,15 @@
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.add(Calendar.DAY_OF_YEAR, -1);
            String clock = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY);
            // 当月一号到当前的天数
            int days = calendar.get(Calendar.DAY_OF_MONTH);
            Calendar clone = (Calendar) calendar.clone();
            clone.set(Calendar.DAY_OF_MONTH,1);
            // 当月一号
            String clock_month_1 = DateUtils.format(clone.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY);
            calendar.add(Calendar.DAY_OF_YEAR, -88);
            // 前90天
            String clock_90 = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY);
            // 清理旧数据
            cokingProcessMainService.deleteByClock(clock);
@@ -102,19 +111,18 @@
                    processMainEntity.setStandValue(standValue == null ? BigDecimal.valueOf(-2) : BigDecimal.valueOf(standValue));
                    Double theoryValue = getConfValue("DATAPOINT",conf.getExt2());
                    processMainEntity.setTheoryValue(theoryValue == null ? BigDecimal.valueOf(-2) : BigDecimal.valueOf(theoryValue));
                    // 计算 月累计 当前自然月
                    calendar.set(Calendar.DAY_OF_MONTH,1);
                    String clock_30 = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY);
                    List<CokingProcessMainEntity> historyList_30 = cokingProcessMainService.historyList(clock_30, clock, "day",processMainEntity.getIndCode());
                    // 计算 当月累计 当前自然月
                    List<CokingProcessMainEntity> historyList_30 = cokingProcessMainService.historyList(clock_month_1, clock, "day",processMainEntity.getIndCode());
                    historyList_30.add(processMainEntity);
                    double monthValue = historyList_30.stream().mapToDouble(e -> e.getRealValue().doubleValue()).average().orElse(0.0) * 30;
                    // 过滤-2,平均值*一号到当天总天数
                    double monthValue = historyList_30.stream().filter(e -> e.getRealValue().compareTo(BigDecimal.valueOf(-2)) != 0).mapToDouble(e -> e.getRealValue().doubleValue()).average().orElse(0.0) * days;
                    processMainEntity.setMonthValue(BigDecimal.valueOf(monthValue));
                    // 计算 历史平均
                    calendar.add(Calendar.DAY_OF_YEAR, -60);
                    String clock_90 = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY);
                    List<CokingProcessMainEntity> historyList_90 = cokingProcessMainService.historyList(clock_90, clock, "day",processMainEntity.getIndCode());
                    historyList_90.add(processMainEntity);
                    // 过滤-2
                    historyList_90 = historyList_90.stream().filter(e -> e.getRealValue().compareTo(BigDecimal.valueOf(-2)) != 0).collect(Collectors.toList());
                    double avgValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).average().orElse(0.0);
                    processMainEntity.setAvgValue(BigDecimal.valueOf(avgValue));
                    // 历史最优