| | |
| | | import com.iailab.module.data.api.ind.IndItemApi; |
| | | import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | 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.setInfoType(conf.getInfoType()); |
| | | processMainEntity.setIndCode(conf.getIndCode()); |
| | | processMainEntity.setIndName(conf.getIndName()); |
| | | processMainEntity.setIndUnit(conf.getIndUnit()); |
| | | processMainEntity.setSort(conf.getSort()); |
| | | // 日实际值 |
| | | Double value = getConfValue(conf.getDataType(),conf.getPointNo()); |
| | | processMainEntity.setRealValue(value == null ? BigDecimal.ZERO : BigDecimal.valueOf(value)); |
| | | processMainEntity.setRealValue(value == null ? BigDecimal.valueOf(-2) : BigDecimal.valueOf(value)); |
| | | |
| | | // 基准值、理论值 来源模型下发结果 |
| | | Double standValue = getConfValue("DATAPOINT",conf.getExt1()); |
| | | processMainEntity.setStandValue(standValue == null ? BigDecimal.ZERO : BigDecimal.valueOf(standValue)); |
| | | processMainEntity.setStandValue(standValue == null ? BigDecimal.valueOf(-2) : BigDecimal.valueOf(standValue)); |
| | | Double theoryValue = getConfValue("DATAPOINT",conf.getExt2()); |
| | | processMainEntity.setTheoryValue(theoryValue == null ? BigDecimal.ZERO : BigDecimal.valueOf(theoryValue)); |
| | | // 历史最优计算方向 |
| | | if (conf.getExt3() != null) { |
| | | directionMap.put(conf.getIndCode(),Double.valueOf(conf.getExt3())); |
| | | } |
| | | 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)); |
| | | } |
| | | // 吨焦耗煤气 |
| | | 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)); |
| | | } |
| | | // 吨焦耗蒸汽 |
| | | if (e.getIndCode().equals("main_djhzq") && resultCodeMap.containsKey("main_zqxh")) { |
| | | // 干熄焦蒸汽产生 |
| | | BigDecimal mainZqxh = resultCodeMap.get("main_zqxh").getRealValue(); |
| | | e.setRealValue(mainZqxh.divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | // 吨焦耗电 |
| | | if (e.getIndCode().equals("main_djhd") && resultCodeMap.containsKey("main_dlxh")) { |
| | | // 干熄焦蒸汽产生 |
| | | BigDecimal mainDlxh = resultCodeMap.get("main_dlxh").getRealValue(); |
| | | e.setRealValue(mainDlxh.divide(jtcl,2,BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 计算 统计值 |
| | | processMainEntities.forEach(processMainEntity -> { |
| | | // 计算 月累计 |
| | | calendar.add(Calendar.DAY_OF_YEAR, -28); |
| | | 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()); |
| | | historyList_30.add(processMainEntity); |
| | |
| | | processMainEntity.setAvgValue(BigDecimal.valueOf(avgValue)); |
| | | // 历史最优 |
| | | double baseValue = 0.0; |
| | | if (!directionMap.containsKey(processMainEntity.getIndCode()) || directionMap.get(processMainEntity.getIndCode()) > 0.0) { |
| | | if (StringUtils.isNotBlank(conf.getExt3()) && 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); |
| | | } |
| | | processMainEntity.setBaseValue(BigDecimal.valueOf(baseValue)); |
| | | }); |
| | | |
| | | |
| | | |
| | | processMainEntities.add(processMainEntity); |
| | | } |
| | | |
| | | cokingProcessMainService.save(processMainEntities); |
| | | } |
| | |
| | | Double value = null; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(dataType)) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | | points.add(pointNo); |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | if (pointsRealValue.containsKey(pointNo)) { |
| | | value = Double.valueOf(pointsRealValue.get(pointNo).toString()); |
| | | ApiPointValueQueryDTO queryDTO = new ApiPointValueQueryDTO(); |
| | | queryDTO.setPointNo(pointNo); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | queryDTO.setEnd(calendar.getTime()); |
| | | calendar.add(Calendar.DAY_OF_YEAR,-1); |
| | | queryDTO.setStart(calendar.getTime()); |
| | | List<ApiPointValueDTO> values = dataPointApi.queryPointHistoryValue(queryDTO); |
| | | if (!CollectionUtils.isEmpty(values)) { |
| | | value = values.get(values.size() - 1).getV(); |
| | | } |
| | | break; |
| | | case IND: |