From c630b9bc245aef6b95923fbd774084edb7726a72 Mon Sep 17 00:00:00 2001
From: Jay <csj123456>
Date: 星期一, 24 三月 2025 11:44:20 +0800
Subject: [PATCH] 增加累计预测值最后一个值的获取

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleDataConstructor.java |   54 +++++++++++++++++++-----------------------------------
 1 files changed, 19 insertions(+), 35 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 6915322..9478194 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
@@ -52,8 +52,7 @@
         }
 
         List<DataValueVO> completionDataEntityList = new ArrayList<>();
-        long oneMin = 0L;
-
+        long oneMin = granularity * 1000L;;
         long start = startTime.getTime();
         long end = endTime.getTime();
         long mins = 0L;
@@ -61,47 +60,18 @@
         switch (ModelParamType.getEumByCode(paramType)) {
             case NORMALITEM:
             case MERGEITEM:
-                // 预测值
-                oneMin = granularity * 1000L;
                 // 设置时间偏移量
-                if (granularity >= 24*60*60) {
-                    // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00
-                    start = start - ((start+8*60*60*1000) % oneMin);
-                    end = end - ((end+8*60*60*1000) % oneMin);
-                } else {
-                    start = start - (start % oneMin);
-                    end = end - (end % oneMin);
-                }
-                mins = ((end - start) / oneMin);
+                mins = calMins(start, end, granularity);
                 break;
             case DATAPOINT:
             case PLAN:
-                // 测点值
-                oneMin = 1000L * granularity;
                 // 设置时间偏移量
-                if (granularity >= 24*60*60) {
-                    // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00
-                    start = start - ((start+8*60*60*1000) % oneMin);
-                    end = end - ((end+8*60*60*1000) % oneMin);
-                } else {
-                    start = start - (start % oneMin);
-                    end = end - (end % oneMin);
-                }
-                mins = ((end - start) / oneMin);
+                mins = calMins(start, end, granularity) + 1;
                 break;
             case IND:
-                // 测点值
-                oneMin = 1000L * granularity;
+            case IND_ASCII:
                 // 设置时间偏移量
-                if (granularity >= 24*60*60) {
-                    // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00
-                    start = start - ((start+8*60*60*1000) % oneMin);
-                    end = end - ((end+8*60*60*1000) % oneMin);
-                } else {
-                    start = start - (start % oneMin);
-                    end = end - (end % oneMin);
-                }
-                mins = ((end - start) / oneMin) + 1;
+                mins = calMins(start, end, granularity) + 1;
                 break;
             default:
                 break;
@@ -141,6 +111,20 @@
         return completionDataEntityList;
     }
 
+    private long calMins(long start, long end, Integer granularity) {
+        long oneMin = granularity * 1000L;
+        // 设置时间偏移量
+        if (granularity >= 24 * 60 * 60) {
+            // 如果时间粒度大于等于一天,因为时区问题,特殊处理,否则时间为8:00,而非0:00
+            start = start - ((start + 8 * 60 * 60 * 1000) % oneMin);
+            end = end - ((end + 8 * 60 * 60 * 1000) % oneMin);
+        } else {
+            start = start - (start % oneMin);
+            end = end - (end % oneMin);
+        }
+        return ((end - start) / oneMin);
+    }
+
     /**
      * getFirstValue
      *

--
Gitblit v1.9.3