From f853b02cb7b265379eceb2f0e3c38f9d63bb1b21 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 06 一月 2025 17:55:25 +0800
Subject: [PATCH] 执行调度模型 默认时间

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/ScheduleSampleInfoConstructor.java |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 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 f8547d6..b3c73a9 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,21 +1,20 @@
 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;
 import com.iailab.module.model.mdk.sample.dto.ColumnItem;
 import com.iailab.module.model.mdk.sample.dto.ColumnItemPort;
+import com.iailab.module.model.mdk.sample.dto.SampleInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -28,13 +27,17 @@
     @Autowired
     private DataPointApi dataPointApi;
 
+    @Autowired
+    private PlanItemApi planItemApi;
+
     @Override
     protected Integer getSampleColumn(String modelId) {
         return null;
     }
 
     @Override
-    protected List<ColumnItemPort> getColumnInfo(String modelId, Date predictTime) {
+    protected SampleInfo getColumnInfo(String modelId, Date predictTime, Map<Integer, Integer> dynamicDataLength) {
+        SampleInfo sampleInfo = new SampleInfo();
         List<ColumnItemPort> resultList = new ArrayList<>();
         List<ColumnItem> columnItemList = new ArrayList<>();
         ColumnItem columnInfo = new ColumnItem();
@@ -46,24 +49,28 @@
         //设置当前端口号,初始值为最小端口(查询结果按端口号从小到达排列)
         int curPortOrder = modelInputParamEntityList.get(0).getModelparamportorder();
         //设置当前查询数据长度,初始值为最小端口数据长度
-        int curDataLength = modelInputParamEntityList.get(0).getDatalength();
+        int curDataLength = super.getDataLength(dynamicDataLength, curPortOrder, modelInputParamEntityList.get(0).getDatalength());
         // 统一获取测点的信息
-        List<String> pointIds = modelInputParamEntityList.stream().filter(e -> ModelParamType.getEumByCode(e.getModelparamtype()).equals(ModelParamType.DATAPOINT)).map(StScheduleModelParamEntity::getModelparamid).collect(Collectors.toList());
+        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());
             columnInfo.setParamId(entry.getModelparamid());
-            columnInfo.setDataLength(entry.getDatalength());
+            columnInfo.setDataLength(super.getDataLength(dynamicDataLength, entry.getModelparamportorder(), 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()){
+            if (curPortOrder != entry.getModelparamportorder()) {
                 //当数据项端口号不为当前端口号时,封装上一个端口类,操作下一个端口类
                 curPort.setColumnItemList(columnItemList);
                 curPort.setDataLength(curDataLength);
@@ -72,7 +79,7 @@
                 curPort = new ColumnItemPort(); //对象重新初始化,防止引用拷贝导致数据覆盖
                 //封装上一个端口类后更新当前的各个参数
                 columnItemList = new ArrayList<>();
-                curDataLength = entry.getDatalength();
+                curDataLength = super.getDataLength(dynamicDataLength, entry.getModelparamportorder(), entry.getDatalength());
                 curPortOrder = entry.getModelparamportorder();
             }
             columnItemList.add(columnInfo);
@@ -83,7 +90,10 @@
         curPort.setDataLength(curDataLength);
         curPort.setPortOrder(curPortOrder);
         resultList.add(curPort);
-        return resultList;
+        sampleInfo.setColumnInfo(resultList);
+        sampleInfo.setPointMap(pointMap);
+        sampleInfo.setPlanMap(planMap);
+        return sampleInfo;
     }
 
     @Override
@@ -91,4 +101,5 @@
         return null;
     }
 
+
 }

--
Gitblit v1.9.3