| | |
| | | |
| | | 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.CokingTraceChartEntity; |
| | | 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.CokingTraceChartService; |
| | | 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; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * 备煤工序-概况 |
| | |
| | | private CokingTraceReportService cokingTraceReportService; |
| | | @Resource |
| | | private CokingTraceChartService cokingTraceChartService; |
| | | @Resource |
| | | private CokingTraceSuggestService cokingTraceSuggestService; |
| | | @Resource |
| | | private CokingTraceDataService cokingTraceDataService; |
| | | |
| | | @Override |
| | | public void run(String processTypes) { |
| | |
| | | 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().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); |
| | | |
| | | // 指标运行趋势 |
| | | List<CokingProcessConfEntity> indRunTrend = list.stream().filter(e -> e.getInfoType().equals("1")).collect(Collectors.toList()); |
| | | List<CokingTraceChartEntity> cokingTraceChartEntityList = new ArrayList<>(indRunTrend.size()); |
| | | indRunTrend.forEach(e -> { |
| | | CokingTraceChartEntity cokingTraceChartEntity = new CokingTraceChartEntity(); |
| | | cokingTraceChartEntity.setRelId(relId); |
| | | cokingTraceChartEntity.setName(e.getIndName()); |
| | | cokingTraceChartEntity.setClock(clock); |
| | | cokingTraceChartEntity.setDataNo(e.getPointNo()); |
| | | cokingTraceChartEntity.setDataType(e.getDataType()); |
| | | |
| | | cokingTraceChartEntity.setEndTime(calendar.getTime()); |
| | | if (e.getExt2().equals("month")) { |
| | | calendar.add(Calendar.MONTH,-1 * Integer.parseInt(e.getExt1())); |
| | | } else if (e.getExt2().equals("day")) { |
| | | calendar.add(Calendar.DAY_OF_YEAR,-1 * Integer.parseInt(e.getExt1())); |
| | | } |
| | | cokingTraceChartEntity.setStartTime(calendar.getTime()); |
| | | cokingTraceChartEntity.setCreateDate(new Date()); |
| | | cokingTraceChartEntityList.add(cokingTraceChartEntity); |
| | | }); |
| | | cokingTraceChartService.insert(cokingTraceChartEntityList); |
| | | |
| | | cokingTraceDataService.insertList(exDatalist); |
| | | } |
| | | } catch (Exception ex) { |
| | | logger.error("runCokingOverviewTask运行异常"); |
| | | ex.printStackTrace(); |
| | | logger.error("runCokingOverviewTask运行异常",ex); |
| | | } |
| | | logger.info("runCokingOverviewTask运行完成"); |
| | | |
| | | } |
| | | } |