From 8bf5531fcc2566bd932216e1a8dafab2a59f4f78 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期一, 23 十二月 2024 15:58:46 +0800 Subject: [PATCH] sampleInfo.setPlanMap 统一获取计划数据的信息,避免重复查询 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java index 3dc2e7e..bc58d7b 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java @@ -1,8 +1,9 @@ package com.iailab.module.model.mdk.sample; +import com.iailab.module.data.api.plan.PlanItemApi; +import com.iailab.module.data.api.plan.dto.ApiPlanItemDTO; import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.data.api.point.dto.ApiPointDTO; -import com.iailab.module.model.mcs.pre.entity.MmModelParamEntity; import com.iailab.module.model.mcs.sche.entity.StScheduleModelParamEntity; import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService; import com.iailab.module.model.mdk.common.enums.ModelParamType; @@ -25,6 +26,9 @@ @Autowired private DataPointApi dataPointApi; + + @Autowired + private PlanItemApi planItemApi; @Override protected Integer getSampleColumn(String modelId) { @@ -50,6 +54,10 @@ Set<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toSet()); List<ApiPointDTO> points = dataPointApi.getInfoByIds(pointIds); Map<String, ApiPointDTO> pointMap = points.stream().collect(Collectors.toMap(ApiPointDTO::getId, Function.identity())); + // 统一获取计划数据的信息 + Set<String> planIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.PLAN)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toSet()); + List<ApiPlanItemDTO> plans = planItemApi.getInfoByIds(planIds); + Map<String, ApiPlanItemDTO> planMap = plans.stream().collect(Collectors.toMap(ApiPlanItemDTO::getId, Function.identity(), (e1,e2) -> e1)); for (StScheduleModelParamEntity entry : modelInputParamEntityList) { columnInfo.setParamType(entry.getModelparamtype()); @@ -57,9 +65,9 @@ columnInfo.setDataLength(entry.getDatalength()); columnInfo.setModelParamOrder(entry.getModelparamorder()); columnInfo.setModelParamPortOrder(entry.getModelparamportorder()); - columnInfo.setStartTime(getStartTime(columnInfo, predictTime,pointMap)); - columnInfo.setEndTime(getEndTime(columnInfo, predictTime,pointMap)); - columnInfo.setGranularity(super.getGranularity(columnInfo)); + columnInfo.setStartTime(getStartTime(columnInfo, predictTime,pointMap,planMap)); + columnInfo.setEndTime(getEndTime(columnInfo, predictTime,pointMap,planMap)); + columnInfo.setGranularity(super.getGranularity(columnInfo,pointMap,planMap)); //对每一个爪进行数据项归并 if (curPortOrder != entry.getModelparamportorder()){ @@ -84,6 +92,7 @@ resultList.add(curPort); sampleInfo.setColumnInfo(resultList); sampleInfo.setPointMap(pointMap); + sampleInfo.setPlanMap(planMap); return sampleInfo; } -- Gitblit v1.9.3