| | |
| | | continue; |
| | | } |
| | | List<CokingProcessMainEntity> processMainEntities = new ArrayList<>(list.size()); |
| | | // 历史最优计算方向,正数取最大值,负数取最小值 |
| | | Map<String,Double> directionMap = new HashMap<>(list.size()); |
| | | for (CokingProcessConfEntity conf : list) { |
| | | if (StringUtils.isBlank(conf.getDataType())) { |
| | | logger.info("DataType is Empty"); |
| | |
| | | processMainEntity.setStandValue(standValue == null ? BigDecimal.ZERO : BigDecimal.valueOf(standValue)); |
| | | Double theoryValue = getConfValue("DATAPOINT",conf.getExt2()); |
| | | processMainEntity.setTheoryValue(theoryValue == null ? BigDecimal.ZERO : BigDecimal.valueOf(theoryValue)); |
| | | |
| | | // 计算 月累计 |
| | | calendar.add(Calendar.DAY_OF_YEAR, -29); |
| | | String clock_30 = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY); |
| | | List<CokingProcessMainEntity> historyList_30 = cokingProcessMainService.historyList(clock_30, clock, "day",conf.getIndCode()); |
| | | historyList_30.add(processMainEntity); |
| | | double monthValue = historyList_30.stream().mapToDouble(e -> e.getRealValue().doubleValue()).sum(); |
| | | 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",conf.getIndCode()); |
| | | historyList_90.add(processMainEntity); |
| | | double avgValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).average().orElse(0.0); |
| | | processMainEntity.setAvgValue(BigDecimal.valueOf(avgValue)); |
| | | // 历史最优 |
| | | double baseValue = 0.0; |
| | | if (Double.valueOf(conf.getExt3()) > 0.0) { |
| | | baseValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).max().orElse(0.0); |
| | | }else { |
| | | baseValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).min().orElse(0.0); |
| | | // 历史最优计算方向 |
| | | if (conf.getExt3() != null) { |
| | | directionMap.put(conf.getIndCode(),Double.valueOf(conf.getExt3())); |
| | | } |
| | | processMainEntity.setBaseValue(BigDecimal.valueOf(baseValue)); |
| | | |
| | | |
| | | processMainEntities.add(processMainEntity); |
| | | } |
| | | // 计算吨焦产煤气,吨焦产蒸汽,吨焦耗煤气 |
| | |
| | | // 干熄焦蒸汽产生 |
| | | BigDecimal mainGxjzqcs = resultCodeMap.get("main_gxjzqcs").getRealValue(); |
| | | e.setRealValue(mainGxjzqcs.divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | |
| | | |
| | | e.setRealValue(e.getAvgValue()); |
| | | e.setAvgValue(e.getAvgValue().divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | // 吨焦耗煤气 |
| | | if (e.getIndCode().equals("main_djhmq") && resultCodeMap.containsKey("main_glmqxh") && resultCodeMap.containsKey("main_jlmqxh")) { |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 计算 统计值 |
| | | processMainEntities.forEach(processMainEntity -> { |
| | | // 计算 月累计 |
| | | calendar.add(Calendar.DAY_OF_YEAR, -29); |
| | | String clock_30 = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY); |
| | | List<CokingProcessMainEntity> historyList_30 = cokingProcessMainService.historyList(clock_30, clock, "day",processMainEntity.getIndCode()); |
| | | historyList_30.add(processMainEntity); |
| | | double monthValue = historyList_30.stream().mapToDouble(e -> e.getRealValue().doubleValue()).sum(); |
| | | 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); |
| | | double avgValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).average().orElse(0.0); |
| | | processMainEntity.setAvgValue(BigDecimal.valueOf(avgValue)); |
| | | // 历史最优 |
| | | double baseValue = 0.0; |
| | | if (!directionMap.containsKey(processMainEntity.getIndCode()) || directionMap.get(processMainEntity.getIndCode()) > 0.0) { |
| | | baseValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).max().orElse(0.0); |
| | | }else { |
| | | baseValue = historyList_90.stream().mapToDouble(e -> e.getRealValue().doubleValue()).min().orElse(0.0); |
| | | } |
| | | processMainEntity.setBaseValue(BigDecimal.valueOf(baseValue)); |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | cokingProcessMainService.save(processMainEntities); |
| | | } |
| | | } catch (Exception ex) { |