| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Resource |
| | | private CokingOverviewService cokingOverviewService; |
| | | @Resource |
| | | private CokingOverviewIndService cokingOverviewIndService; |
| | | @Resource |
| | | private DataPointApi dataPointApi; |
| | | @Resource |
| | | private IndItemApi indItemApi; |
| | | @Resource |
| | | private CokingTraceReportService cokingTraceReportService; |
| | | @Resource |
| | | private CokingTraceChartService cokingTraceChartService; |
| | | @Resource |
| | | private CokingTraceSuggestService cokingTraceSuggestService; |
| | | @Resource |
| | | private CokingTraceDataService cokingTraceDataService; |
| | | |
| | |
| | | queryParams.setIndType(processType); |
| | | List<CokingProcessConfEntity> list = cokingProcessConfService.list(queryParams); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | logger.info("ConfLis is Empty"); |
| | | return; |
| | | logger.info("ConfList is Empty"); |
| | | continue; |
| | | } |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | reportEntity.setCreateDate(new Date()); |
| | | cokingTraceReportService.save(reportEntity); |
| | | |
| | | // 清理旧数据 |
| | | cokingOverviewService.deleteByProcessType(processType, clock); |
| | | cokingTraceDataService.deleteByExObj(processType+"_AD", clock); |
| | | cokingOverviewIndService.deleteByProcessType(processType, clock); |
| | | |
| | | // 整体情况 |
| | | // 筛选info_type = 2,按照子工序类型分组 |
| | | Map<String, List<CokingProcessConfEntity>> processTypeMap = list.stream().filter(e -> e.getInfoType().equals("2")).collect(Collectors.groupingBy(CokingProcessConfEntity::getExt2)); |
| | |
| | | logger.info("PointNo is Empty"); |
| | | continue; |
| | | } |
| | | Double value = null; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(conf.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | | points.add(conf.getPointNo()); |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | value = Double.valueOf(pointsRealValue.get(conf.getPointNo()).toString()); |
| | | break; |
| | | case IND: |
| | | List<ApiIndItemValueDTO> indValues = indItemApi.queryIndItemDefaultValue(conf.getPointNo()); |
| | | if (!CollectionUtils.isEmpty(indValues)) { |
| | | value = Double.valueOf(indValues.get(indValues.size() - 1).getDataValue().toString()); |
| | | } |
| | | break; |
| | | case MODEL: |
| | | break; |
| | | default: |
| | | break; |
| | | |
| | | } |
| | | Double value = getConfValue(conf); |
| | | |
| | | values.put(conf.getExt1(),value); |
| | | |
| | | // 异常数据处理 |
| | |
| | | ctd.setRelId(relId); |
| | | ctd.setProcess(ProcessTypeEnum.getEumByCode(conf.getIndType()).getReportName()); |
| | | ctd.setClock(clock); |
| | | ctd.setExObj(conf.getIndType()+"_AD"); |
| | | ctd.setExObj(processType+"_AD"); |
| | | ctd.setExTime(calendar.getTime()); |
| | | ctd.setExType(content); |
| | | ctd.setCreateDate(new Date()); |
| | | exDatalist.add(ctd); |
| | | } |
| | | |
| | |
| | | overviewEntity.setSubProcessType(entry.getKey()); |
| | | overviewEntity.setClock(clock); |
| | | result.add(overviewEntity); |
| | | |
| | | // 清理旧数据 |
| | | cokingOverviewService.deleteByProcessType(processType, clock); |
| | | cokingTraceDataService.deleteByExObj(processType, clock); |
| | | } |
| | | cokingOverviewService.insert(result); |
| | | cokingTraceDataService.insertList(exDatalist); |
| | | |
| | | // 能流图指标数据 |
| | | // 筛选info_type = 1 |
| | | List<CokingProcessConfEntity> indList = list.stream().filter(e -> e.getInfoType().equals("1")).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(indList)) { |
| | | return; |
| | | } |
| | | List<CokingOverviewIndEntity> overviewIndEntities = new ArrayList<>(indList.size()); |
| | | for (CokingProcessConfEntity conf : indList) { |
| | | if (StringUtils.isBlank(conf.getDataType())) { |
| | | logger.info("DataType is Empty"); |
| | | continue; |
| | | } |
| | | if (StringUtils.isBlank(conf.getPointNo())) { |
| | | logger.info("PointNo is Empty"); |
| | | continue; |
| | | } |
| | | Double value = getConfValue(conf); |
| | | CokingOverviewIndEntity entity = new CokingOverviewIndEntity(); |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | entity.setRelId(relId); |
| | | entity.setProcessType(processType); |
| | | entity.setClock(clock); |
| | | entity.setIndCode(conf.getIndCode()); |
| | | entity.setIndName(conf.getIndName()); |
| | | entity.setIndUnit(conf.getIndUnit()); |
| | | if (value != null) { |
| | | entity.setIndValue(BigDecimal.valueOf(value)); |
| | | } |
| | | entity.setCreateDate(new Date()); |
| | | overviewIndEntities.add(entity); |
| | | } |
| | | cokingOverviewIndService.save(overviewIndEntities); |
| | | } |
| | | } catch (Exception ex) { |
| | | logger.error("runCokingOverviewTask运行异常",ex); |
| | | } |
| | | logger.info("runCokingOverviewTask运行完成"); |
| | | } |
| | | |
| | | private Double getConfValue(CokingProcessConfEntity conf) { |
| | | Double value = null; |
| | | switch (ProcessConfDataTypeEnum.getEumByCode(conf.getDataType())) { |
| | | case DATAPOINT: |
| | | List<String> points = new ArrayList<>(); |
| | | points.add(conf.getPointNo()); |
| | | Map<String, Object> pointsRealValue = dataPointApi.queryPointsRealValue(points); |
| | | value = Double.valueOf(pointsRealValue.get(conf.getPointNo()).toString()); |
| | | break; |
| | | case IND: |
| | | List<ApiIndItemValueDTO> indValues = indItemApi.queryIndItemDefaultValue(conf.getPointNo()); |
| | | if (!CollectionUtils.isEmpty(indValues)) { |
| | | value = Double.valueOf(indValues.get(indValues.size() - 1).getDataValue().toString()); |
| | | } |
| | | break; |
| | | case MODEL: |
| | | break; |
| | | default: |
| | | break; |
| | | |
| | | } |
| | | return value; |
| | | } |
| | | } |