From 46f62230c2a12e51e60b10c9ee91664dde870165 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 17 三月 2025 16:33:15 +0800
Subject: [PATCH] 当前时间+1

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
index d2d988f..f7b9545 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java
@@ -11,6 +11,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -39,7 +40,31 @@
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(predictTime);
         valueList.forEach(value -> {
+            calendar.add(Calendar.MINUTE, 1);
             Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), value};
+            result.add(dv);
+        });
+        return result;
+    }
+
+    @Override
+    public List<Object[]> getData(String outputId, Date predictTime, String timeFormat, int scale) {
+        List<Object[]> result = new ArrayList<>();
+        QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq("outputid", outputId)
+                .eq("predicttime", DateUtils.format(predictTime,timeFormat));
+        MmItemResultJsonEntity data = baseDao.selectOne(wrapper);
+        if (data == null || StringUtils.isBlank(data.getJsonvalue())) {
+            return result;
+        }
+        List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class);
+        if (CollectionUtils.isEmpty(valueList)) {
+            return result;
+        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(predictTime);
+        valueList.forEach(value -> {
+            Object[] dv = {DateUtils.format(calendar.getTime(), timeFormat), new BigDecimal(value).setScale(scale, BigDecimal.ROUND_HALF_UP)};
             calendar.add(Calendar.MINUTE, 1);
             result.add(dv);
         });
@@ -47,6 +72,26 @@
     }
 
     @Override
+    public double[] getSimpleData(String outputId, Date predictTime, int predictLength) {
+        double[] result = new double[predictLength];
+        QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq("outputid", outputId)
+                .eq("predicttime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
+        MmItemResultJsonEntity data = baseDao.selectOne(wrapper);
+        if (data == null || StringUtils.isBlank(data.getJsonvalue())) {
+            return null;
+        }
+        List<Double> valueList = JSONArray.parseArray(data.getJsonvalue(), Double.class);
+        if (CollectionUtils.isEmpty(valueList)) {
+            return result;
+        }
+        for (int i = 0; i < predictLength; i++) {
+            result[i] = valueList.get(i);
+        }
+        return result;
+    }
+
+    @Override
     public void insert(List<MmItemResultJsonEntity> resultJsonList) {
         baseDao.insertBatch(resultJsonList);
     }

--
Gitblit v1.9.3