| | |
| | | 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.entity.CokingTraceReportEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceSuggestEntity; |
| | | import com.iailab.module.ansteel.coking.service.CokingAnalyIndService; |
| | | 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.ansteel.coking.entity.*; |
| | | 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.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 干熄焦工序-异常溯源 |
| | |
| | | private CokingAnalyIndService cokingAnalyIndService; |
| | | |
| | | @Autowired |
| | | private CokingTraceIndService cokingTraceIndService; |
| | | |
| | | @Autowired |
| | | private CokingTraceConfService cokingTraceConfService; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private IndItemApi indItemApi; |
| | | |
| | | private static final HashMap<String, Object> steamFirstColoumMap = new HashMap<String, Object>() {{ |
| | | put("steamFirstColoum0", "一级指标-偏差值"); |
| | |
| | | logger.info("RunCokingTraceModelTask,参数为:{}", params); |
| | | try { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | // 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 = ""; |
| | | int hour = 8; |
| | | if (hour == 0) { |
| | | clock = yesterday.concat("-").concat("A"); |
| | | analyClass = "甲班"; |
| | |
| | | saveTraceReport(tMap,result); |
| | | saveTraceSuggest(tMap,result); |
| | | saveTraceDeviation(tMap,result); |
| | | saveTraceAnalyInd(tMap,result); |
| | | saveAnalyInd(tMap,result); |
| | | saveTraceInd(tMap,result); |
| | | } |
| | | } catch (Exception ex) { |
| | | logger.error("RunCokingTraceModelTask运行异常"); |
| | |
| | | } |
| | | |
| | | 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())); |
| | | List<ChartParamDTO> list = mcsApi.getChartParamList(CommonConstant.STEAM_INDEX_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)){ |
| | |
| | | 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.setIndName(steamIndexMaps.get(element.get(0).toString())); |
| | | deviationEntity.setIndValue(element.get(1).toString()); |
| | | deviationEntity.setCreateDate(new Date()); |
| | | cokingTraceDeviationService.save(deviationEntity); |
| | |
| | | |
| | | } |
| | | |
| | | 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()); |
| | | analyIndEntity.setAnalyDate(tMap.get("analyDate").toString()); |
| | | analyIndEntity.setAnalyClass(tMap.get("analyClass").toString()); |
| | | analyIndEntity.setAnalyContent(tMap.get("analyContent").toString()); |
| | | cokingAnalyIndService.save(analyIndEntity); |
| | | private void saveAnalyInd(Map<String, Object> tMap,JSONObject result) { |
| | | String[] analyContent = tMap.get("analyContent").toString().split(";"); |
| | | for(int i=0;i<analyContent.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.setSort(i+1); |
| | | cokingAnalyIndService.save(analyIndEntity); |
| | | } |
| | | } |
| | | |
| | | private void saveTraceInd(Map<String, Object> tMap,JSONObject result) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("indType","干熄焦工序异常溯源"); |
| | | List<CokingTraceConfEntity> list = cokingTraceConfService.list(map); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | logger.info("ConfLis is Empty"); |
| | | return; |
| | | } |
| | | 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(tMap.get("relId").toString()); |
| | | cokingTraceIndEntity.setTitle(conf.getIndType()); |
| | | cokingTraceIndEntity.setClock(tMap.get("clock").toString()); |
| | | cokingTraceIndEntity.setIndName(conf.getIndName()); |
| | | cokingTraceIndEntity.setIndValue(value); |
| | | cokingTraceIndEntity.setIndUnit(conf.getIndUnit()); |
| | | cokingTraceIndService.save(cokingTraceIndEntity); |
| | | |
| | | } |
| | | } |
| | | } |