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/SampleInfoConstructor.java | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java index 1ed6feb..3f8f72b 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java @@ -86,7 +86,7 @@ * @return * @throws Exception */ - protected Date getStartTime(ColumnItem columnItem, Date originalTime, Map<String, ApiPointDTO> pointMap) { + protected Date getStartTime(ColumnItem columnItem, Date originalTime, Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) { Date dateTime = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(originalTime); @@ -106,7 +106,11 @@ dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60); break; case PLAN: - dateTime = calendar.getTime(); + ApiPlanItemDTO apiPlanItemDTO = planMap.get(columnItem.getParamId()); + if (apiPlanItemDTO == null) { + return null; + } + dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue()); break; default: break; @@ -122,7 +126,7 @@ * @return * @throws Exception */ - protected Date getEndTime(ColumnItem columnItem, Date originalTime,Map<String, ApiPointDTO> pointMap) { + protected Date getEndTime(ColumnItem columnItem, Date originalTime,Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) { Date dateTime = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(originalTime); @@ -142,12 +146,11 @@ dateTime = calendar.getTime(); break; case PLAN: - ApiPlanItemDTO planItem = planItemApi.getInfoByNo(columnItem.getParamId()); - if (planItem == null) { + ApiPlanItemDTO apiPlanItemDTO = planMap.get(columnItem.getParamId()); + if (apiPlanItemDTO == null) { return null; } - dateTime = calculateDate(originalTime, false, columnItem.getDataLength(), - TimeGranularityEnum.getEumByCode(planItem.getTimeGranularity()).getValue()); + dateTime = calculateDate(originalTime, false, columnItem.getDataLength(), TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue()); break; default: break; @@ -162,17 +165,15 @@ * @return * @throws Exception */ - protected Integer getGranularity(ColumnItem columnItem) { + protected Integer getGranularity(ColumnItem columnItem,Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) { // 默认60s Integer granularity = 60; switch (ModelParamType.getEumByCode(columnItem.getParamType())) { case DATAPOINT: - ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId()); + ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId()); granularity = DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue(); break; case NORMALITEM: - granularity = mmPredictItemService.getItemByOutPutId(columnItem.getParamId()).getGranularity(); - break; case MERGEITEM: granularity = mmPredictItemService.getItemByOutPutId(columnItem.getParamId()).getGranularity(); break; @@ -181,7 +182,7 @@ granularity = TimeGranularitySecEnum.getEumByCode(indItemDTO.getTimeGranularity()).getValue();; break; case PLAN: - ApiPlanItemDTO apiPlanItemDTO = planItemApi.getInfoById(columnItem.getParamId()); + ApiPlanItemDTO apiPlanItemDTO = planMap.get(columnItem.getParamId()); granularity = TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue(); break; default: -- Gitblit v1.9.3