| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | logger.info("runCokingMainTask,参数为:{}", processTypes); |
| | | try { |
| | | |
| | | String[] split = processTypes.split(","); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | 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); |
| | | |
| | | // 清理旧数据 |
| | | cokingProcessMainService.deleteByClock(clock); |
| | | |
| | | String[] split = processTypes.split(","); |
| | | for (String processType : split) { |
| | | CokingProcessConfEntity queryParams = new CokingProcessConfEntity(); |
| | | queryParams.setIndType(processType); |
| | |
| | | continue; |
| | | } |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | 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); |
| | | |
| | | // 清理旧数据 |
| | | cokingProcessMainService.deleteByClock(clock); |
| | | |
| | | // 主工序指标 筛选info_type = 0 |
| | | List<CokingProcessConfEntity> indList = list.stream().filter(e -> e.getInfoType().equals("0")).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(indList)) { |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | continue; |
| | | } |
| | | List<CokingProcessMainEntity> processMainEntities = new ArrayList<>(indList.size()); |
| | | for (CokingProcessConfEntity conf : indList) { |
| | | List<CokingProcessMainEntity> processMainEntities = new ArrayList<>(list.size()); |
| | | for (CokingProcessConfEntity conf : list) { |
| | | if (StringUtils.isBlank(conf.getDataType())) { |
| | | logger.info("DataType is Empty"); |
| | | continue; |
| | |
| | | |
| | | processMainEntities.add(processMainEntity); |
| | | } |
| | | // 计算吨焦产煤气,吨焦产蒸汽,吨焦耗煤气 |
| | | Map<String, CokingProcessMainEntity> resultCodeMap = processMainEntities.stream().collect(Collectors.toMap(CokingProcessMainEntity::getIndCode, Function.identity(), (e1, e2) -> e1)); |
| | | // 有焦炭产量 |
| | | if (resultCodeMap.containsKey("main_jcmq")) { |
| | | // 焦炭产量 |
| | | BigDecimal jtcl = resultCodeMap.get("main_jcmq").getRealValue(); |
| | | if (jtcl != null && !jtcl.equals(BigDecimal.ZERO)) { |
| | | processMainEntities.forEach(e -> { |
| | | // 吨焦产煤气 |
| | | if (e.getIndCode().equals("main_jcmq") && resultCodeMap.containsKey("main_jlmqfs")) { |
| | | // 焦炉煤气发生 |
| | | BigDecimal mainJlmqfs = resultCodeMap.get("main_jlmqfs").getRealValue(); |
| | | e.setRealValue(mainJlmqfs.divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | // 吨焦产蒸汽 |
| | | if (e.getIndCode().equals("main_djczq") && resultCodeMap.containsKey("main_gxjzqcs")) { |
| | | // 干熄焦蒸汽产生 |
| | | 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")) { |
| | | // 高炉煤气消耗 |
| | | BigDecimal mainGlmqxh = resultCodeMap.get("main_glmqxh").getRealValue(); |
| | | // 焦炉煤气消耗 |
| | | BigDecimal mainJlmqxh = resultCodeMap.get("main_jlmqxh").getRealValue(); |
| | | e.setRealValue(mainGlmqxh.add(mainJlmqxh).divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | cokingProcessMainService.save(processMainEntities); |
| | | } |
| | | } catch (Exception ex) { |