| | |
| | | package com.iailab.module.ansteel.job.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.CokingAnalyIndEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceDeviationEntity; |
| | |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceDeviationService; |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceReportService; |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceSuggestService; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private CokingAnalyIndService cokingAnalyIndService; |
| | | |
| | | private static final HashMap<String, Object> sugObjMap = new HashMap<String, Object>() {{ |
| | | put("1#", "1#干熄焦主蒸汽温度因装焦量、装焦温度偏低而降低13℃。经模型计算,建议调整XX,预计可使XX指标升高/降低XX"); |
| | | put("2#", "2#干熄焦蒸汽发生量因空气导入量偏高、锅炉入口温度偏低而减少13t。经模型计算,建议调整XX,预计可使XX指标升高/降低XX\n"); |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | private static final HashMap<String, Object> steamFirstColoumMap = new HashMap<String, Object>() {{ |
| | | put("steamFirstColoum0", "一级指标-偏差值"); |
| | | put("steamFirstColoum1", "二级指标-偏差值"); |
| | | put("steamFirstColoum2", "影响因素1-偏差值"); |
| | | put("steamFirstColoum3", "影响因素2-偏差值"); |
| | | put("steamFirstColoum4", "影响因素3-偏差值"); |
| | | put("steamFirstColoum5", "影响因素n-偏差值"); |
| | | }}; |
| | | |
| | | private static final HashMap<String, List<String>> deviationMap = new HashMap<String, List<String>>() {{ |
| | | put("1", Arrays.asList("1#", "一级指标-偏差值", "主蒸汽温度", "13", "℃")); |
| | | put("2", Arrays.asList("1#", "二级指标-偏差值", "装焦温度", "50", "℃")); |
| | | put("3", Arrays.asList("1#", "影响因素1-偏差值", "CO含量", "5", "%")); |
| | | put("4", Arrays.asList("1#", "影响因素2-偏差值", "H2含量", "4", "%")); |
| | | put("5", Arrays.asList("2#", "一级指标-偏差值", "蒸汽产量", "15", "t")); |
| | | put("6", Arrays.asList("2#", "二级指标-偏差值", "空气导入量", "350", "")); |
| | | put("7", Arrays.asList("2#", "影响因素1-偏差值", "干熄炉入口温度", "30", "℃")); |
| | | put("8", Arrays.asList("2#", "影响因素2-偏差值", "H2含量", "4", "%")); |
| | | private static final HashMap<String, Object> steamSecondColoumMap = new HashMap<String, Object>() {{ |
| | | put("steamSecondColoum0", "一级指标-偏差值"); |
| | | put("steamSecondColoum1", "二级指标-偏差值"); |
| | | put("steamSecondColoum2", "影响因素1-偏差值"); |
| | | put("steamSecondColoum3", "影响因素2-偏差值"); |
| | | put("steamSecondColoum4", "影响因素3-偏差值"); |
| | | put("steamSecondColoum5", "影响因素n-偏差值"); |
| | | }}; |
| | | |
| | | private static final String jsonStr="{\"result\":{" + |
| | | " \"steamTotal1\":\"2#干熄焦蒸汽发生量因空气导入量偏高、锅炉入口温度偏低而减少13t,经模型计算,建议调整空气导入量,预计可使主蒸汽流量指标升高20m3/h\",\n" + |
| | | " \"steamTotal2\":\"2#干熄焦蒸汽发生量因空气导入量偏高、锅炉入口温度偏低而减少13m3/h,经模型计算,建议调整循环风机转速,预计可使主蒸汽流量指标升高32m3/h\",\n" + |
| | | " \"steamFirstColoum0\":[[14,20],[14,30],[14,35]],\n" + |
| | | " \"steamFirstColoum1\":[[10,5],[11,15],[21,20]],\n" + |
| | | " \"steamFirstColoum2\":[[74,8],[36,18],[35,34]],\n" + |
| | | " \"steamFirstColoum3\":[[24,67],[6,12],[19,21]],\n" + |
| | | " \"steamFirstColoum4\":[[21,19],[22,31],[8,42]],\n" + |
| | | " \"steamFirstColoum5\":[[11,45],[9,62],[18,34]],\n" + |
| | | " \"steamSecondColoum0\":[[14,20],[14,50],[14,13]],\n" + |
| | | " \"steamSecondColoum1\":[[11,27],[10,35],[22,16]],\n" + |
| | | " \"steamSecondColoum2\":[[36,90],[35,34],[74,55]],\n" + |
| | | " \"steamSecondColoum3\":[[6,66],[19,73],[21,31]],\n" + |
| | | " \"steamSecondColoum4\":[[22,65],[8,22],[21,67]],\n" + |
| | | " \"steamSecondColoum5\":[[9,29],[11,56],[18,61]],\n" + |
| | | " \"steamHomePage\":[[663,617],[66.5,68.9]],\n" + |
| | | " \"steamHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + |
| | | " \"steamHomeIndexInfo\":\"2月18日甲班:干熄焦产蒸汽量异常\",\n" + |
| | | " \"steamHomeErr\":\"2月18日循环风机转速数据异常(无数据)\"}}"; |
| | | |
| | | @Override |
| | | public void run(String params) { |
| | |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | String yesterday = DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.FORMAT_YEAR_MONTH_DAY); |
| | | String clock = ""; |
| | | String analyClass = ""; |
| | | if (hour == 0) { |
| | | clock = yesterday.concat("-").concat("A"); |
| | | analyClass = "甲班"; |
| | | } else if (hour == 8) { |
| | | clock = yesterday.concat("-").concat("B"); |
| | | analyClass = "乙班"; |
| | | } else if (hour == 16) { |
| | | clock = yesterday.concat("-").concat("C"); |
| | | analyClass = "丙班"; |
| | | } |
| | | Map<String, Object> tMap = new HashMap<>(); |
| | | tMap.put("relId", UUID.randomUUID().toString()); |
| | | tMap.put("process", "干熄焦工序"); |
| | | tMap.put("reportName", "锅炉蒸汽产量"); |
| | | tMap.put("analyDate", yesterday); |
| | | tMap.put("analyClass", "甲班"); |
| | | tMap.put("analyClass", analyClass); |
| | | tMap.put("clock", clock); |
| | | tMap.put("analyContent", "锅炉蒸汽产量异常"); |
| | | tMap.put("analyContent", "干熄焦产蒸汽量异常"); |
| | | |
| | | saveTraceReport(tMap); |
| | | saveTraceSuggest(tMap); |
| | | saveTraceDeviation(tMap); |
| | | saveTraceAnalyInd(tMap); |
| | | |
| | | 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); |
| | | saveTraceAnalyInd(tMap,result); |
| | | } |
| | | } catch (Exception ex) { |
| | | logger.error("RunCokingTraceModelTask运行异常"); |
| | | ex.printStackTrace(); |
| | |
| | | |
| | | } |
| | | |
| | | private void saveTraceReport(Map<String, Object> tMap) { |
| | | private void saveTraceReport(Map<String, Object> tMap,JSONObject result) { |
| | | CokingTraceReportEntity reportEntity = new CokingTraceReportEntity(); |
| | | reportEntity.setId(tMap.get("relId").toString()); |
| | | reportEntity.setProcess(tMap.get("process").toString()); |
| | |
| | | cokingTraceReportService.save(reportEntity); |
| | | } |
| | | |
| | | private void saveTraceSuggest(Map<String, Object> tMap) { |
| | | for (Map.Entry<String, Object> entry : sugObjMap.entrySet()) { |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(tMap.get("relId").toString()); |
| | | suggestEntity.setProcess(tMap.get("process").toString()); |
| | | suggestEntity.setSugObj(entry.getKey()); |
| | | suggestEntity.setClock(tMap.get("clock").toString()); |
| | | suggestEntity.setContent(entry.getValue().toString()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | private void saveTraceSuggest(Map<String, Object> tMap,JSONObject result) { |
| | | for(int i=1;i<=2;i++){ |
| | | String steamTotal = result.get("steamTotal"+i).toString(); |
| | | if(StringUtils.isNotBlank(steamTotal)){ |
| | | CokingTraceSuggestEntity suggestEntity = new CokingTraceSuggestEntity(); |
| | | suggestEntity.setRelId(tMap.get("relId").toString()); |
| | | suggestEntity.setProcess(tMap.get("process").toString()); |
| | | suggestEntity.setSugObj(i+"#"); |
| | | suggestEntity.setClock(tMap.get("clock").toString()); |
| | | suggestEntity.setContent(steamTotal); |
| | | suggestEntity.setCreateDate(new Date()); |
| | | cokingTraceSuggestService.save(suggestEntity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void saveTraceDeviation(Map<String, Object> tMap) { |
| | | for (Map.Entry<String, List<String>> entry : deviationMap.entrySet()) { |
| | | CokingTraceDeviationEntity deviationEntity = new CokingTraceDeviationEntity(); |
| | | deviationEntity.setRelId(tMap.get("relId").toString()); |
| | | deviationEntity.setProcess(tMap.get("process").toString()); |
| | | deviationEntity.setSugObj(entry.getValue().get(0)); |
| | | deviationEntity.setClock(tMap.get("clock").toString()); |
| | | deviationEntity.setGroupName(entry.getValue().get(1)); |
| | | deviationEntity.setIndName(entry.getValue().get(2)); |
| | | deviationEntity.setIndValue(entry.getValue().get(3)); |
| | | deviationEntity.setIndUnit(entry.getValue().get(4)); |
| | | deviationEntity.setCreateDate(new Date()); |
| | | |
| | | cokingTraceDeviationService.save(deviationEntity); |
| | | private void saveTraceDeviation(Map<String, Object> tMap,JSONObject result) { |
| | | // String chartCode = "STEAM_INDEX"; |
| | | // List<ChartParamDTO> list = mcsApi.getChartParamList(chartCode); |
| | | // Map<String, String> steamIndexMaps = list.stream().collect(Collectors.toMap(ChartParamDTO::getParamCode, e -> e.getParamValue())); |
| | | for(int i=0;i<=5;i++){ |
| | | String steamFirstColoum = result.get("steamFirstColoum"+i).toString(); |
| | | if(StringUtils.isNotBlank(steamFirstColoum)){ |
| | | JSONArray responseArr = JSON.parseArray(steamFirstColoum); |
| | | 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("1#"); |
| | | deviationEntity.setGroupName(steamFirstColoumMap.get("steamFirstColoum"+i).toString()); |
| | | // deviationEntity.setIndName(steamIndexMaps.get(element.get(0).toString())); |
| | | deviationEntity.setIndName(element.get(0).toString()); |
| | | deviationEntity.setIndValue(element.get(1).toString()); |
| | | deviationEntity.setCreateDate(new Date()); |
| | | cokingTraceDeviationService.save(deviationEntity); |
| | | } |
| | | } |
| | | } |
| | | for(int i=0;i<=5;i++){ |
| | | String steamSecondColoum = result.get("steamSecondColoum"+i).toString(); |
| | | if(StringUtils.isNotBlank(steamSecondColoum)){ |
| | | JSONArray responseArr = JSON.parseArray(steamSecondColoum); |
| | | |
| | | 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("2#"); |
| | | deviationEntity.setGroupName(steamSecondColoumMap.get("steamSecondColoum" + i).toString()); |
| | | deviationEntity.setIndName(element.get(0).toString()); |
| | | deviationEntity.setIndValue(element.get(1).toString()); |
| | | deviationEntity.setCreateDate(new Date()); |
| | | cokingTraceDeviationService.save(deviationEntity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void saveTraceAnalyInd(Map<String, Object> tMap) { |
| | | private void saveTraceAnalyInd(Map<String, Object> tMap,JSONObject result) { |
| | | CokingAnalyIndEntity analyIndEntity = new CokingAnalyIndEntity(); |
| | | analyIndEntity.setRelId(tMap.get("relId").toString()); |
| | | analyIndEntity.setAnalyType(tMap.get("process").toString()); |