From 95066d1bdaf67f414f01d1686e7ea9c0ebc07e26 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期四, 02 一月 2025 09:37:05 +0800
Subject: [PATCH] 调度模型下发

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java |   47 ++++++++++++-----------------------------------
 1 files changed, 12 insertions(+), 35 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..53bed0b 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,32 +126,23 @@
      * @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);
         switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
             case DATAPOINT:
-                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
-                if (dataPoint == null) {
-                    return null;
-                }
                 dateTime = calendar.getTime();
                 break;
             case NORMALITEM:
             case MERGEITEM:
-                dateTime = calendar.getTime();
+                dateTime = calculateTime(originalTime, false, columnItem.getDataLength(), 60);
                 break;
             case IND:
                 dateTime = calendar.getTime();
                 break;
             case PLAN:
-                ApiPlanItemDTO planItem = planItemApi.getInfoByNo(columnItem.getParamId());
-                if (planItem == null) {
-                    return null;
-                }
-                dateTime = calculateDate(originalTime, false, columnItem.getDataLength(),
-                        TimeGranularityEnum.getEumByCode(planItem.getTimeGranularity()).getValue());
+                dateTime = calendar.getTime();
                 break;
             default:
                 break;
@@ -162,17 +157,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 +174,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:
@@ -212,22 +205,6 @@
         calendar.set(Calendar.MILLISECOND, 0);
         // 数据长度 * 粒度
         calendar.add(Calendar.SECOND, timeLength * granularity);
-        return calendar.getTime();
-    }
-
-    public Date calculateDate(Date originalTime, Boolean backward, int dataLength, int field) {
-        int timeLength;
-        if (backward) {
-            timeLength = (-1) * dataLength;
-        } else {
-            timeLength = dataLength - 1;
-        }
-        Date desTime = originalTime;
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(desTime);
-        calendar.set(Calendar.MILLISECOND, 0);
-        // 数据长度 * 粒度
-        calendar.add(Calendar.SECOND, timeLength);
         return calendar.getTime();
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3