| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.ansteel.coking.entity.*; |
| | | import com.iailab.module.ansteel.coking.entity.CokingAnalyIndEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceSuggestEntity; |
| | | import com.iailab.module.ansteel.coking.service.*; |
| | | import com.iailab.module.ansteel.common.constant.CommonConstant; |
| | | import com.iailab.module.ansteel.common.enums.ProcessConfDataTypeEnum; |
| | | 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.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.ChartParamDTO; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | put("F0000101008", "备煤耗电"); |
| | | }}; |
| | | |
| | | private static final String jsonStr = "{\n" + |
| | | " \"result\": {\n" + |
| | | " \"coalPrepElec\":[1600.8,1613.5], \n" + |
| | | " \"coalPrepElecIndex\":[[0.8,0.73],[723,608],[1782,1782],[752,743],[729,783]],\n" + |
| | | " \"coalPrepElecTotal1\":\"1#粉碎机耗电因粉碎机偏高增加220KW/h,经模型计算,建建议调整单班用煤量,预计可使粉碎机耗电量指标降低170KW/h\",\n" + |
| | | " \"coalPrepElecTotal2\":\"1#粉碎机耗电量数据异常\",\n" + |
| | | " \"coalColoum0\":[[0,450],[0,137],[0,342]],\n" + |
| | | " \"coalColoum1\":[[2,306],[3,134],[1,142]],\n" + |
| | | " \"coalColoum2\":[[4,142],[4,132],[4,349]],\n" + |
| | | private static final String jsonStr = "{\n" + " " + |
| | | "\"result\": {\n" + |
| | | "\"coalPrepElec\":[1600.8,1613.5],\n" + |
| | | "\"coalPrepElecIndex\":[[0.8,0.73],[723,608],[1782,1782],[752,743],[729,783]],\n" + |
| | | "\"coalPrepElecTotal1\":\"1#粉碎机耗电因粉碎机偏高增加220KW/h,经模型计算,建建议调整单班用煤量,预计可使粉碎机耗电量指标降低170KW/h\",\n" + |
| | | "\"coalPrepElecTotal2\":\"1#粉碎机耗电量数据异常\",\n" + |
| | | "\"coalColoum0\":[[0,450],[0,137],[0,342]],\n" + |
| | | "\"coalColoum1\":[[2,306],[3,134],[1,142]],\n" + |
| | | "\"coalColoum2\":[[4,142],[4,132],[4,349]],\n" + |
| | | "\"coalPrepElecHomePage\":[[50,42],[10,10]],\n" + |
| | | "\"coalHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + |
| | | "\"coalIndexInfo\":\"2月18日甲班:备煤耗电异常\",\n" + |
| | | "\"coalErr\":\"2月18日粉碎机耗电数据异常(无数据)\"\n" + |
| | | " }" + |
| | | "}"; |
| | | "\"coalErr\":\"2月18日粉碎机耗电数据异常(无数据)\"\n" + " }" + "}"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | | this.saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | |
| | | // 保存优化建议 |
| | | this.saveTraceSuggest(relId, process, clock, result); |
| | | saveTraceSuggest(relId, process, clock, result); |
| | | |
| | | // 保存偏差值 |
| | | this.saveTraceDeviation(relId, process, clock, result); |
| | | saveTraceDeviation(relId, process, clock, result); |
| | | |
| | | // 保存溯源指标 |
| | | this.saveTraceInd(relId, result); |
| | | cokingTraceIndService.saveTraceInd(relId, indType, clock); |
| | | |
| | | // 保存溯源折线图 |
| | | this.saveTraceChart(relId, clock, startDate, endDate); |
| | | cokingTraceChartService.save(relId, clock, indType, startDate, endDate); |
| | | |
| | | } catch (Exception ex) { |
| | | logger.error("RunCokingTraceModelBMTask运行异常"); |
| | |
| | | String coalTotal = result.get("coalPrepElecTotal1").toString(); |
| | | if (StringUtils.isBlank(coalTotal)) { |
| | | logger.info("coalPrepElecTotal1 is null"); |
| | | return; |
| | | } |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | logger.info("analyContent is null"); |
| | | return; |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | cokingAnalyIndService.save(entityList); |
| | | } |
| | | |
| | | public void saveTraceInd(String relId, JSONObject result) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("indType", indType); |
| | | List<CokingTraceConfEntity> list = cokingTraceConfService.list(map); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | logger.info("ConfLis is Empty"); |
| | | return; |
| | | } |
| | | List<CokingTraceIndEntity> entityList = new ArrayList<>(); |
| | | for (CokingTraceConfEntity conf : list) { |
| | | if (StringUtils.isBlank(conf.getDataType())) { |
| | | logger.info("DataType is Empty"); |
| | | continue; |
| | | } |
| | | if (StringUtils.isBlank(conf.getPointNo())) { |
| | | logger.info("PointNo is Empty"); |
| | | continue; |
| | | } |
| | | String value = ""; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(conf.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | | points.add(conf.getPointNo()); |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | value = pointsRealValue.get(conf.getPointNo()).toString(); |
| | | break; |
| | | case IND: |
| | | List<ApiIndItemValueDTO> indValues = indItemApi.queryIndItemDefaultValue(conf.getPointNo()); |
| | | if (!CollectionUtils.isEmpty(indValues)) { |
| | | value = indValues.get(indValues.size() - 1).getDataValue().toString(); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | CokingTraceIndEntity cokingTraceIndEntity = new CokingTraceIndEntity(); |
| | | cokingTraceIndEntity.setRelId(relId); |
| | | cokingTraceIndEntity.setTitle(conf.getIndType()); |
| | | cokingTraceIndEntity.setClock(relId); |
| | | cokingTraceIndEntity.setIndCode(conf.getIndCode()); |
| | | cokingTraceIndEntity.setIndName(conf.getIndName()); |
| | | cokingTraceIndEntity.setIndValue(value); |
| | | cokingTraceIndEntity.setIndUnit(conf.getIndUnit()); |
| | | entityList.add(cokingTraceIndEntity); |
| | | } |
| | | cokingTraceIndService.save(entityList); |
| | | } |
| | | |
| | | public void saveTraceChart(String relId, String clock, Date startDate, Date endDate) { |
| | | // 查询需要保存chart的配置 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("indType", indType); |
| | | map.put("ext1", "chart"); |
| | | List<CokingTraceConfEntity> list = cokingTraceConfService.list(map); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | logger.info("TraceChartConfLis is Empty"); |
| | | } |
| | | |
| | | List<CokingTraceChartEntity> entityList = new ArrayList<>(); |
| | | list.forEach(value -> { |
| | | CokingTraceChartEntity cokingTraceChartEntity = new CokingTraceChartEntity(); |
| | | cokingTraceChartEntity.setRelId(relId); |
| | | cokingTraceChartEntity.setName(value.toString()); |
| | | cokingTraceChartEntity.setClock(clock); |
| | | cokingTraceChartEntity.setDataType(value.getDataType()); |
| | | cokingTraceChartEntity.setDataNo(value.getPointNo()); |
| | | cokingTraceChartEntity.setStartTime(startDate); |
| | | cokingTraceChartEntity.setEndTime(endDate); |
| | | cokingTraceChartEntity.setCreateDate(new Date()); |
| | | entityList.add(cokingTraceChartEntity); |
| | | }); |
| | | cokingTraceChartService.insert(entityList); |
| | | } |
| | | } |