From c9dd12a0042b50af36edf2ae710d33430542385d Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期二, 24 十二月 2024 10:15:43 +0800
Subject: [PATCH] 预测值 开始时间计算bug,数据补全bug

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java
index dba4323..e3c6e3e 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java
@@ -6,6 +6,7 @@
 import com.iailab.module.data.api.point.dto.ApiPointDTO;
 import com.iailab.module.data.enums.DataPointFreqEnum;
 import com.iailab.module.data.enums.TimeGranularitySecEnum;
+import com.iailab.module.model.mcs.pre.enums.PredGranularityEnum;
 import com.iailab.module.model.mdk.common.enums.ModelParamType;
 import com.iailab.module.model.mdk.sample.dto.SampleData;
 import com.iailab.module.model.mdk.sample.dto.SampleInfo;
@@ -15,7 +16,6 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 
-import java.sql.Timestamp;
 import java.util.*;
 
 abstract class SampleDataConstructor {
@@ -42,10 +42,11 @@
      * @param dataEntityList
      * @param startTime
      * @param endTime
+     * @param planMap
      * @return
      */
     public List<DataValueVO> completionData(int length, List<DataValueVO> dataEntityList, Date startTime, Date endTime,
-                                            String paramId, String paramType) {
+                                            String paramId, String paramType, Map<String, ApiPointDTO> pointMap, Map<String, ApiPlanItemDTO> planMap) {
         if (CollectionUtils.isEmpty(dataEntityList) || length == dataEntityList.size()) {
             return dataEntityList;
         } else if (length < dataEntityList.size()) {
@@ -63,28 +64,14 @@
             case NORMALITEM:
             case MERGEITEM:
                 // 预测值
-                Calendar calendar = Calendar.getInstance();
-                calendar.setTime(startTime);
-                calendar.set(Calendar.HOUR_OF_DAY, 0);
-                calendar.set(Calendar.MINUTE, 0);
-                calendar.set(Calendar.SECOND, 0);
-                calendar.add(Calendar.DAY_OF_YEAR, 1);
-                startTime = calendar.getTime();
-                start = startTime.getTime();
-
-                calendar.setTime(endTime);
-                calendar.set(Calendar.HOUR_OF_DAY, 0);
-                calendar.set(Calendar.MINUTE, 0);
-                calendar.set(Calendar.SECOND, 0);
-                endTime = calendar.getTime();
-                end = endTime.getTime();
-
-                oneMin = 60 * 1000L;
+                oneMin = PredGranularityEnum.MIN1.getCode() * 1000L;
+                start = start - (start % oneMin) + oneMin;
+                end = end - (end % oneMin) + oneMin;
                 mins = ((end - start) / oneMin);
                 break;
             case DATAPOINT:
                 // 测点值
-                ApiPointDTO dataPoint = dataPointApi.getInfoById(paramId);
+                ApiPointDTO dataPoint = pointMap.get(paramId);
                 oneMin = 1000L * DataPointFreqEnum.getEumByCode(dataPoint.getMinfreqid()).getValue();
                 // 设置时间偏移量
                 start = start - (start % oneMin) + oneMin;
@@ -110,7 +97,7 @@
                 break;
             case PLAN:
                 // 计划数据
-                ApiPlanItemDTO planItem = planItemApi.getInfoById(paramId);
+                ApiPlanItemDTO planItem = planMap.get(paramId);
                 oneMin = 1000L * TimeGranularitySecEnum.getEumByCode(planItem.getTimeGranularity()).getValue();
                 // 设置时间偏移量
                 start = start - (start % oneMin) + oneMin;

--
Gitblit v1.9.3