| | |
| | | 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.data.api.ind.IndItemApi; |
| | | 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.apache.commons.lang3.StringUtils; |
| | |
| | | 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; |
| | |
| | | private CokingTraceIndService cokingTraceIndService; |
| | | |
| | | @Autowired |
| | | private CokingTraceConfService cokingTraceConfService; |
| | | |
| | | @Autowired |
| | | private CokingTraceChartService cokingTraceChartService; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private IndItemApi indItemApi; |
| | | |
| | | private final static String process = "炼焦工序"; |
| | | |
| | |
| | | private final static String SugObj = "LJ"; |
| | | |
| | | private final static String indType = "炼焦工序异常溯源"; |
| | | |
| | | private final static String cokeRow = "cokeRow"; |
| | | |
| | | private static final HashMap<String, Object> cokeColoumMap = new HashMap<String, Object>() {{ |
| | | put("cokeColoum0", "一级指标-偏差值"); |
| | |
| | | "\"cokeHeat\":[3.7,3.8],\n" + " " + |
| | | "\"cokeIndex\":[[0.8,0.7],[608,608],[1440,1460],[1346,1293],[0.8,0.7],[1372,1293]],\n" + " " + |
| | | "\"cokeTotal\":\"炼焦吨焦耗热量因煤气流量偏高、煤气水分偏低而增加23,经模型计算,延建议调整煤气流量,预计可使吨焦耗热量指标降低17\",\n" + " " + |
| | | "\"cokeColoum0\":[[0,13],[0,42],[0,34]],\n" + " " + |
| | | "\"cokeColoum1\":[[13,12],[12,34],[24,42]],\n" + " " + |
| | | "\"cokeColoum2\":[[27,45],[58,42],[70,31]],\n" + " " + |
| | | "\"cokeColoum3\":[[108,56],[110,89],[185,21]],\n" + " " + |
| | | "\"cokeColoum4\":[[199,13],[200,51],[197,34]],\n" + " " + |
| | | "\"cokeColoum5\":[[147,33],[131,12],[122,13]],\n" + " " + |
| | | "\"cokeRow0\":[[0,13],[0,42],[0,34]],\n" + " " + |
| | | "\"cokeRow1\":[[13,12],[12,34],[24,42]],\n" + " " + |
| | | "\"cokeRow2\":[[27,45],[58,42],[70,31]],\n" + " " + |
| | | "\"cokeRow3\":[[108,56],[110,89],[185,21]],\n" + " " + |
| | | "\"cokeRow4\":[[199,13],[200,51],[197,34]],\n" + " " + |
| | | "\"cokeRow5\":[[147,33],[131,12],[122,13]],\n" + " " + |
| | | "\"cokeHomePage\":[[202,42],[203,13],[204,45],[205,34],[206,17]],\n" + " " + |
| | | "\"cokeHomeIndex\":[[90.4,90.2],[80.3,78],[103,100],[280,270]],\n" + " " + |
| | | "\"cokeHomeIndexInfo\":\"2月18日甲班:吨焦耗热量异常\",\n" + " " + |
| | |
| | | |
| | | // 保存报告 |
| | | String analyDate = DateUtils.format(startDate); |
| | | String analyContent = result.getString("coalIndexInfo"); |
| | | String analyContent = result.getString("cokeHomeIndexInfo"); |
| | | String relId = cokingTraceReportService.save(process, reportName, analyDate, analyClass, clock, analyContent); |
| | | |
| | | // 保存一级分析指标 |
| | |
| | | |
| | | @Transactional |
| | | public void saveTraceDeviation(String relId, String process, String clock, JSONObject result) { |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.COKE_INDEX_CHARTCODE); |
| | | 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 <= 5; i++) { |
| | | String cokeColoum = result.get("cokeColoum" + i).toString(); |
| | | if (StringUtils.isNotBlank(cokeColoum)) { |
| | | JSONArray responseArr = JSON.parseArray(cokeColoum); |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (int j = 0; j < responseArr.size(); j++) { |
| | | JSONArray element = JSON.parseArray(responseArr.get(j).toString()); |
| | | CokingTraceDeviationEntity deviationEntity = new CokingTraceDeviationEntity(); |
| | | deviationEntity.setRelId(relId); |
| | | deviationEntity.setProcess(process); |
| | | deviationEntity.setClock(clock); |
| | | deviationEntity.setSugObj(SugObj); |
| | | deviationEntity.setGroupName(cokeColoumMap.get("cokeColoum" + i).toString()); |
| | | deviationEntity.setIndName(steamIndexMaps.get(element.get(0).toString())); |
| | | deviationEntity.setIndValue(element.get(1).toString()); |
| | | deviationEntity.setCreateDate(new Date()); |
| | | entityList.add(deviationEntity); |
| | | } |
| | | cokingTraceDeviationService.save(entityList); |
| | | |
| | | List<String> coalRowKeys = new ArrayList<>(); |
| | | result.forEach((key, value) -> { |
| | | if (StringUtils.isBlank(key) && key.contains(cokeRow)) { |
| | | coalRowKeys.add(key); |
| | | } |
| | | |
| | | }); |
| | | |
| | | List<CokingTraceDeviationEntity> entityList = new ArrayList<>(); |
| | | for (String key : coalRowKeys) { |
| | | JSONArray rowArr = JSON.parseArray(result.get(key).toString()); |
| | | if (CollectionUtils.isEmpty(rowArr)) { |
| | | continue; |
| | | } |
| | | CokingTraceDeviationEntity entity = new CokingTraceDeviationEntity(); |
| | | entity.setRelId(relId); |
| | | entity.setProcess(process); |
| | | entity.setClock(clock); |
| | | entity.setSugObj(SugObj); |
| | | |
| | | entity.setInd1Name(steamIndexMaps.get(rowArr.getJSONArray(0).get(0).toString())); |
| | | entity.setInd1Value(rowArr.getJSONArray(0).get(1).toString()); |
| | | entity.setInd1Unit(""); |
| | | |
| | | entity.setInd2Name(steamIndexMaps.get(rowArr.getJSONArray(1).get(0).toString())); |
| | | entity.setInd2Value(rowArr.getJSONArray(1).get(1).toString()); |
| | | entity.setInd2Unit(""); |
| | | |
| | | if (rowArr.size() > 2) { |
| | | entity.setFac1Name(steamIndexMaps.get(rowArr.getJSONArray(2).get(0).toString())); |
| | | entity.setFac1Value(rowArr.getJSONArray(2).get(1).toString()); |
| | | entity.setFac1Unit(""); |
| | | } |
| | | if (rowArr.size() > 3) { |
| | | entity.setFac2Name(steamIndexMaps.get(rowArr.getJSONArray(3).get(0).toString())); |
| | | entity.setFac2Value(rowArr.getJSONArray(3).get(1).toString()); |
| | | entity.setFac2Unit(""); |
| | | } |
| | | if (rowArr.size() > 4) { |
| | | entity.setFac3Name(steamIndexMaps.get(rowArr.getJSONArray(4).get(0).toString())); |
| | | entity.setFac3Value(rowArr.getJSONArray(4).get(1).toString()); |
| | | entity.setFac3Unit(""); |
| | | } |
| | | if (rowArr.size() > 5) { |
| | | entity.setFac4Name(steamIndexMaps.get(rowArr.getJSONArray(5).get(0).toString())); |
| | | entity.setFac4Value(rowArr.getJSONArray(5).get(1).toString()); |
| | | entity.setFac4Unit(""); |
| | | } |
| | | if (rowArr.size() > 6) { |
| | | entity.setFac5Name(steamIndexMaps.get(rowArr.getJSONArray(6).get(0).toString())); |
| | | entity.setFac5Value(rowArr.getJSONArray(6).get(1).toString()); |
| | | entity.setFac5Unit(""); |
| | | } |
| | | entityList.add(entity); |
| | | } |
| | | |
| | | cokingTraceDeviationService.save(entityList); |
| | | } |
| | | |
| | | public void saveAnalyInd(String relId, String process, String analyDate, String analyClass, String analyContent) { |