From 5bf42aa9950058f391805e6fb8d7376f4378924b Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 23 十二月 2024 16:16:55 +0800
Subject: [PATCH] cumulateHandle.getCurrent

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java |   42 +++++++++++++++++++-----------------------
 1 files changed, 19 insertions(+), 23 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 3d53588..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
@@ -19,6 +19,7 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author PanZhibao
@@ -47,14 +48,8 @@
      * @return
      */
     protected SampleInfo prepareSampleInfo(String modelId, Date predictTime) {
-        SampleInfo sampleInfo = new SampleInfo();
-        //调用样本列数的方法
-//        sampleInfo.setSampleColumn(getSampleColumn(modelId));
         //样本的列信息
-        sampleInfo.setColumnInfo(getColumnInfo(modelId, predictTime));
-        //样本的采样周期
-//        sampleInfo.setSampleCycle(getSampleCycle(modelId));
-        return sampleInfo;
+        return getColumnInfo(modelId, predictTime);
     }
 
     /**
@@ -73,7 +68,7 @@
      * @param predictTime
      * @return
      */
-    protected abstract List<ColumnItemPort> getColumnInfo(String modelId, Date predictTime);
+    protected abstract SampleInfo getColumnInfo(String modelId, Date predictTime);
 
     /**
      * 样本的采样周期
@@ -91,13 +86,13 @@
      * @return
      * @throws Exception
      */
-    protected Date getStartTime(ColumnItem columnItem, Date originalTime) {
+    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);
         switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
             case DATAPOINT:
-                ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId());
+                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
                 if (dataPoint == null) {
                     return null;
                 }
@@ -111,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;
@@ -127,13 +126,13 @@
      * @return
      * @throws Exception
      */
-    protected Date getEndTime(ColumnItem columnItem, Date originalTime) {
+    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);
         switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
             case DATAPOINT:
-                ApiPointDTO dataPoint = dataPointApi.getInfoById(columnItem.getParamId());
+                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
                 if (dataPoint == null) {
                     return null;
                 }
@@ -147,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;
@@ -167,26 +165,24 @@
      * @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.getItemById(columnItem.getParamId()).getGranularity();
+                granularity = mmPredictItemService.getItemByOutPutId(columnItem.getParamId()).getGranularity();
                 break;
             case IND:
                 ApiIndItemDTO indItemDTO = indItemApi.getInfoById(columnItem.getParamId());
                 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