| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.ansteel.coking.entity.CokingOverviewEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingProcessConfEntity; |
| | | import com.iailab.module.ansteel.coking.entity.CokingTraceReportEntity; |
| | | import com.iailab.module.ansteel.coking.service.CokingOverviewService; |
| | | import com.iailab.module.ansteel.coking.service.CokingProcessConfService; |
| | | import com.iailab.module.ansteel.coking.service.CokingTraceReportService; |
| | | import com.iailab.module.ansteel.coking.entity.*; |
| | | import com.iailab.module.ansteel.coking.service.*; |
| | | import com.iailab.module.ansteel.common.enums.ProcessConfDataTypeEnum; |
| | | import com.iailab.module.ansteel.common.enums.ProcessTypeEnum; |
| | | import com.iailab.module.data.api.ind.IndItemApi; |
| | | import com.iailab.module.data.api.ind.dto.ApiIndItemQueryDTO; |
| | | import com.iailab.module.data.api.ind.dto.ApiIndItemValueDTO; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | private IndItemApi indItemApi; |
| | | @Resource |
| | | private CokingTraceReportService cokingTraceReportService; |
| | | @Resource |
| | | private CokingTraceChartService cokingTraceChartService; |
| | | @Resource |
| | | private CokingTraceSuggestService cokingTraceSuggestService; |
| | | @Resource |
| | | private CokingTraceDataService cokingTraceDataService; |
| | | |
| | | @Override |
| | | public void run(String processTypes) { |
| | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | String clock = DateUtils.format(calendar.getTime(), DateUtils.FORMAT_YEAR_MONTH_DAY); |
| | | // 插入溯源报告 |
| | | // 溯源报告 |
| | | CokingTraceReportEntity reportEntity = new CokingTraceReportEntity(); |
| | | String relId = UUID.randomUUID().toString(); |
| | | reportEntity.setId(relId); |
| | |
| | | reportEntity.setReportName(ProcessTypeEnum.getEumByCode(processType).getReportName()); |
| | | reportEntity.setAnalyDate(clock); |
| | | reportEntity.setClock(clock); |
| | | reportEntity.setCreateDate(new Date()); |
| | | cokingTraceReportService.save(reportEntity); |
| | | |
| | | // 按照子工序类型分组 |
| | | Map<String, List<CokingProcessConfEntity>> processTypeMap = list.stream().collect(Collectors.groupingBy(CokingProcessConfEntity::getExt2)); |
| | | // 整体情况 |
| | | // 筛选info_type = 2,按照子工序类型分组 |
| | | Map<String, List<CokingProcessConfEntity>> processTypeMap = list.stream().filter(e -> e.getInfoType().equals("2")).collect(Collectors.groupingBy(CokingProcessConfEntity::getExt2)); |
| | | // 结果 <子工序类型,<数据key,数据value>> |
| | | List<CokingOverviewEntity> result = new ArrayList<>(processTypeMap.size()); |
| | | List<CokingTraceDataEntity> exDatalist = new ArrayList<>(); |
| | | |
| | | for (Map.Entry<String, List<CokingProcessConfEntity>> entry : processTypeMap.entrySet()) { |
| | | Map<String,Double> values = new HashMap<>(entry.getValue().size()); |
| | |
| | | logger.info("PointNo is Empty"); |
| | | continue; |
| | | } |
| | | Double value = 0.0; |
| | | Double value = null; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(conf.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | |
| | | |
| | | } |
| | | values.put(conf.getExt1(),value); |
| | | |
| | | // 异常数据处理 |
| | | String content = null; |
| | | if (value != null) { |
| | | if (value.equals(0.0)) { |
| | | content = clock + " " + conf.getIndName() + "数据异常(数据为0)"; |
| | | }else if (value.compareTo(Double.valueOf(conf.getExt3())) > 0) { |
| | | content = clock + " " + conf.getIndName() + "数据异常(超上限)"; |
| | | }else if (value.compareTo(Double.valueOf(conf.getExt4())) < 0) { |
| | | content = clock + " " + conf.getIndName() + "数据异常(超下限)"; |
| | | } |
| | | }else { |
| | | content = clock + " " + conf.getIndName() + "数据异常(无数据)"; |
| | | } |
| | | if (StringUtils.isNotBlank(content)) { |
| | | CokingTraceDataEntity ctd = new CokingTraceDataEntity(); |
| | | ctd.setId(UUID.randomUUID().toString()); |
| | | ctd.setRelId(relId); |
| | | ctd.setProcess(ProcessTypeEnum.getEumByCode(conf.getIndType()).getReportName()); |
| | | ctd.setClock(clock); |
| | | ctd.setExObj(conf.getIndType()+"_AD"); |
| | | ctd.setExTime(calendar.getTime()); |
| | | ctd.setExType(content); |
| | | exDatalist.add(ctd); |
| | | } |
| | | |
| | | } |
| | | CokingOverviewEntity overviewEntity = new CokingOverviewEntity(); |
| | | BeanUtil.fillBeanWithMap(values,overviewEntity,true); |
| | |
| | | overviewEntity.setSubProcessType(entry.getKey()); |
| | | overviewEntity.setClock(clock); |
| | | result.add(overviewEntity); |
| | | |
| | | // 清理旧数据 |
| | | cokingOverviewService.deleteByProcessType(processType, clock); |
| | | cokingTraceDataService.deleteByExObj(processType, clock); |
| | | } |
| | | cokingOverviewService.insert(result); |
| | | cokingTraceDataService.insertList(exDatalist); |
| | | } |
| | | } catch (Exception ex) { |
| | | logger.error("runCokingOverviewTask运行异常"); |
| | | ex.printStackTrace(); |
| | | logger.error("runCokingOverviewTask运行异常",ex); |
| | | } |
| | | logger.info("runCokingOverviewTask运行完成"); |
| | | |
| | | } |
| | | } |