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/PredictSampleDataConstructor.java |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
index 9cb12d7..093156e 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleDataConstructor.java
@@ -1,6 +1,7 @@
 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.data.api.point.dto.ApiPointValueDTO;
@@ -62,6 +63,7 @@
     public List<SampleData>  prepareSampleData(SampleInfo sampleInfo) throws Exception {
         List<SampleData> sampleDataList = new ArrayList<>();
         Map<String, ApiPointDTO> pointMap = sampleInfo.getPointMap();
+        Map<String, ApiPlanItemDTO> planMap = sampleInfo.getPlanMap();
         //对每个爪分别进行计算
         for (ColumnItemPort entry : sampleInfo.getColumnInfo()) {
             //先依据爪内数据项的modelParamOrder进行排序——重写comparator匿名函数
@@ -83,11 +85,11 @@
             //对每一项依次进行数据查询,然后将查询出的值赋给matrix对应的位置
             for (int i = 0; i < entry.getColumnItemList().size(); i++) {
                 try {
-                    List<DataValueVO> dataEntityList = getData(entry.getColumnItemList().get(i),pointMap);
+                    List<DataValueVO> dataEntityList = getData(entry.getColumnItemList().get(i),pointMap,planMap);
                     //补全数据
                     ColumnItem columnItem = entry.getColumnItemList().get(i);
                     dataEntityList = super.completionData(matrix.length, dataEntityList, columnItem.startTime, columnItem.endTime,
-                            columnItem.paramId, columnItem.getParamType());
+                            columnItem.paramId, columnItem.getParamType(),pointMap,planMap);
 
                     /** 如果数据取不满,把缺失的数据点放在后面 */
                     if (dataEntityList != null && dataEntityList.size() != 0) {
@@ -113,10 +115,11 @@
      *
      * @param columnItem
      * @param pointMap
+     * @param planMap
      * @return
      * @throws Exception
      */
-    private List<DataValueVO> getData(ColumnItem columnItem, Map<String, ApiPointDTO> pointMap) throws Exception {
+    private List<DataValueVO> getData(ColumnItem columnItem, Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) throws Exception {
         List<DataValueVO> dataList = new ArrayList<>();
         String paramType = columnItem.getParamType();
         switch (ModelParamType.getEumByCode(paramType)) {
@@ -147,7 +150,7 @@
                 break;
             case PLAN:
                 ApiDataQueryDTO queryPlanItemDto = new ApiDataQueryDTO();
-                queryPlanItemDto.setItemNo(columnItem.getParamId());
+                queryPlanItemDto.setItemNo(planMap.get(columnItem.getParamId()).getItemNo());
                 queryPlanItemDto.setStart(columnItem.getStartTime());
                 queryPlanItemDto.setEnd(columnItem.getEndTime());
                 List<ApiDataValueDTO> planValueList = planItemApi.queryPlanItemHistoryValue(queryPlanItemDto);

--
Gitblit v1.9.3