| | |
| | | @Autowired |
| | | private IndItemApi indItemApi; |
| | | |
| | | private final static String process = "备煤工序"; |
| | | |
| | | private final static String reportName = "备煤工序异常溯源"; |
| | | |
| | | private final static String SugObj = "BM"; |
| | | |
| | | private final static String indType = "备煤工序异常溯源"; |
| | | |
| | | private static final HashMap<String, Object> coalColoumMap = new HashMap<String, Object>() {{ |
| | | put("coalColoum0", "一级指标-偏差值"); |
| | | put("coalColoum1", "二级指标-偏差值"); |
| | |
| | | clock = DateUtils.format(startDate).concat("-").concat("B"); |
| | | analyClass = "丙班"; |
| | | } |
| | | Map<String, Object> tMap = new HashMap<>(); |
| | | tMap.put("relId", UUID.randomUUID().toString()); |
| | | tMap.put("process", "备煤工序"); |
| | | tMap.put("reportName", "备煤工序"); |
| | | tMap.put("analyDate", DateUtils.format(startDate)); |
| | | tMap.put("analyClass", analyClass); |
| | | tMap.put("clock", clock); |
| | | tMap.put("analyContent", "备煤耗电异常"); |
| | | tMap.put("startDate", startDate); |
| | | tMap.put("endDate", endDate); |
| | | |
| | | // 调用模型 |
| | | JSONObject jsonObject = JSONObject.parseObject(jsonStr); |
| | | JSONObject result = (JSONObject) JSON.toJSON(jsonObject.get("result")); |
| | | if (!Objects.isNull(result)) { |
| | | saveTraceReport(tMap, result); |
| | | saveTraceSuggest(tMap, result); |
| | | saveTraceDeviation(tMap, result); |
| | | saveAnalyInd(tMap, result); |
| | | saveTraceInd(tMap, result); |
| | | saveTraceChart(tMap, result, startDate, endDate); |
| | | |
| | | if (Objects.isNull(result)) { |
| | | logger.info("模型结果为空"); |
| | | return; |
| | | } |
| | | |
| | | // 保存报告 |
| | | String analyDate = DateUtils.format(startDate); |
| | | String analyContent = result.getString("coalIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | | this.saveAnalyInd(relId, process, analyDate, analyClass, analyContent); |
| | | |
| | | // 保存优化建议 |
| | | this.saveTraceSuggest(relId, process, clock, result); |
| | | |
| | | // 保存偏差值 |
| | | this.saveTraceDeviation(relId, process, clock, result); |
| | | |
| | | // 保存溯源指标 |
| | | this.saveTraceInd(relId, result); |
| | | |
| | | // 保存溯源折线图 |
| | | this.saveTraceChart(relId, clock, startDate, endDate); |
| | | |
| | | } catch (Exception ex) { |
| | | logger.error("RunCokingTraceModelBMTask运行异常"); |
| | | ex.printStackTrace(); |
| | |
| | | logger.info("RunCokingTraceModelBMTask运行完成"); |
| | | } |
| | | |
| | | public void saveTraceReport(Map<String, Object> tMap, JSONObject result) { |
| | | CokingTraceReportEntity reportEntity = new CokingTraceReportEntity(); |
| | | reportEntity.setId(tMap.get("relId").toString()); |
| | | reportEntity.setProcess(tMap.get("process").toString()); |
| | | reportEntity.setReportName(tMap.get("reportName").toString()); |
| | | reportEntity.setAnalyDate(tMap.get("analyDate").toString()); |
| | | reportEntity.setAnalyClass(tMap.get("analyClass").toString()); |
| | | reportEntity.setClock(tMap.get("clock").toString()); |
| | | reportEntity.setAnalyContent(tMap.get("analyContent").toString()); |
| | | reportEntity.setCreateDate(new Date()); |
| | | cokingTraceReportService.save(reportEntity); |
| | | } |
| | | |
| | | public void saveTraceSuggest(Map<String, Object> tMap, JSONObject result) { |
| | | public void saveTraceSuggest(String relId, String process, String clock, JSONObject result) { |
| | | String coalTotal = result.get("coalPrepElecTotal1").toString(); |
| | | if (StringUtils.isNotBlank(coalTotal)) { |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(tMap.get("relId").toString()); |
| | | suggestEntity.setProcess(tMap.get("process").toString()); |
| | | suggestEntity.setSugObj("BM"); |
| | | suggestEntity.setClock(tMap.get("clock").toString()); |
| | | suggestEntity.setContent(coalTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | if (StringUtils.isBlank(coalTotal)) { |
| | | logger.info("coalPrepElecTotal1 is null"); |
| | | } |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(relId); |
| | | suggestEntity.setProcess(process); |
| | | suggestEntity.setSugObj(SugObj); |
| | | suggestEntity.setClock(clock); |
| | | suggestEntity.setContent(coalTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | } |
| | | |
| | | @Transactional |
| | | public void saveTraceDeviation(Map<String, Object> tMap, JSONObject result) { |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.COAL_INDEX_CHARTCODE); |
| | | Map<String, String> steamIndexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamName())); |
| | | for (int i = 0; i <= 2; i++) { |
| | |
| | | for (int j = 0; j < responseArr.size(); j++) { |
| | | JSONArray element = JSON.parseArray(responseArr.get(j).toString()); |
| | | CokingTraceDeviationEntity deviationEntity = new CokingTraceDeviationEntity(); |
| | | deviationEntity.setRelId(tMap.get("relId").toString()); |
| | | deviationEntity.setProcess(tMap.get("process").toString()); |
| | | deviationEntity.setClock(tMap.get("clock").toString()); |
| | | deviationEntity.setSugObj("BM"); |
| | | deviationEntity.setRelId(relId); |
| | | deviationEntity.setProcess(process); |
| | | deviationEntity.setClock(clock); |
| | | deviationEntity.setSugObj(SugObj); |
| | | deviationEntity.setGroupName(coalColoumMap.get("coalColoum" + i).toString()); |
| | | deviationEntity.setIndName(steamIndexMaps.get(element.get(0).toString())); |
| | | deviationEntity.setIndValue(element.get(1).toString()); |
| | |
| | | } |
| | | } |
| | | |
| | | public void saveAnalyInd(Map<String, Object> tMap, JSONObject result) { |
| | | String[] analyContent = tMap.get("analyContent").toString().split(";"); |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |
| | | if (StringUtils.isBlank(analyContent)) { |
| | | logger.info("analyContent is null"); |
| | | } |
| | | String[] analyContentArr = analyContent.split(";"); |
| | | List<CokingAnalyIndEntity> entityList = new ArrayList<>(); |
| | | for (int i = 0; i < analyContent.length; i++) { |
| | | for (int i = 0; i < analyContentArr.length; i++) { |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(tMap.get("relId").toString()); |
| | | analyIndEntity.setAnalyType(tMap.get("process").toString()); |
| | | analyIndEntity.setAnalyDate(tMap.get("analyDate").toString()); |
| | | analyIndEntity.setAnalyClass(tMap.get("analyClass").toString()); |
| | | analyIndEntity.setAnalyContent(analyContent[i]); |
| | | analyIndEntity.setRelId(relId); |
| | | analyIndEntity.setAnalyType(process); |
| | | analyIndEntity.setAnalyDate(analyDate); |
| | | analyIndEntity.setAnalyClass(analyClass); |
| | | analyIndEntity.setAnalyContent(analyContentArr[i]); |
| | | analyIndEntity.setSort(i + 1); |
| | | entityList.add(analyIndEntity); |
| | | } |
| | | cokingAnalyIndService.save(entityList); |
| | | } |
| | | |
| | | public void saveTraceInd(Map<String, Object> tMap, JSONObject result) { |
| | | public void saveTraceInd(String relId, JSONObject result) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("indType", "备煤工序异常溯源"); |
| | | map.put("indType", indType); |
| | | List<CokingTraceConfEntity> list = cokingTraceConfService.list(map); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | logger.info("ConfLis is Empty"); |
| | |
| | | break; |
| | | } |
| | | CokingTraceIndEntity cokingTraceIndEntity = new CokingTraceIndEntity(); |
| | | cokingTraceIndEntity.setRelId(tMap.get("relId").toString()); |
| | | cokingTraceIndEntity.setRelId(relId); |
| | | cokingTraceIndEntity.setTitle(conf.getIndType()); |
| | | cokingTraceIndEntity.setClock(tMap.get("clock").toString()); |
| | | cokingTraceIndEntity.setClock(relId); |
| | | cokingTraceIndEntity.setIndCode(conf.getIndCode()); |
| | | cokingTraceIndEntity.setIndName(conf.getIndName()); |
| | | cokingTraceIndEntity.setIndValue(value); |
| | |
| | | cokingTraceIndService.save(entityList); |
| | | } |
| | | |
| | | public void saveTraceChart(Map<String, Object> tMap, JSONObject result, Date startDate, Date endDate) { |
| | | 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<>(); |
| | | historyPointMap.forEach((key, value) -> { |
| | | list.forEach(value -> { |
| | | CokingTraceChartEntity cokingTraceChartEntity = new CokingTraceChartEntity(); |
| | | cokingTraceChartEntity.setRelId(tMap.get("relId").toString()); |
| | | cokingTraceChartEntity.setRelId(relId); |
| | | cokingTraceChartEntity.setName(value.toString()); |
| | | cokingTraceChartEntity.setClock(tMap.get("clock").toString()); |
| | | cokingTraceChartEntity.setDataNo(key); |
| | | cokingTraceChartEntity.setDataType("DATAPOINT"); |
| | | cokingTraceChartEntity.setClock(clock); |
| | | cokingTraceChartEntity.setDataType(value.getDataType()); |
| | | cokingTraceChartEntity.setDataNo(value.getPointNo()); |
| | | cokingTraceChartEntity.setStartTime(startDate); |
| | | cokingTraceChartEntity.setEndTime(endDate); |
| | | cokingTraceChartEntity.setCreateDate(new Date()); |