From 5b952f77058a9da5af5e143a6c2c7ba195aa736d Mon Sep 17 00:00:00 2001
From: liriming <1343021927@qq.com>
Date: 星期二, 26 十一月 2024 16:08:10 +0800
Subject: [PATCH] 预测消息配置

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 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 409434a..165328f 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
@@ -3,13 +3,16 @@
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
+import com.iailab.framework.common.util.date.DateUtils;
 import com.iailab.module.model.mcs.pre.dao.MmItemResultJsonDao;
 import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity;
 import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -23,7 +26,7 @@
         implements MmItemResultJsonService {
 
     @Override
-    public List<Object[]> getData(String outputId, Date predictTime) {
+    public List<Object[]> getData(String outputId, Date predictTime, String timeFormat) {
         List<Object[]> result = new ArrayList<>();
         QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>();
         wrapper.eq("outputid", outputId)
@@ -32,9 +35,16 @@
         if (data == null || StringUtils.isBlank(data.getJsonvalue())) {
             return result;
         }
-        result = JSONArray.parseArray(data.getJsonvalue(), Object[].class);
-        result.forEach(item -> {
-            item[0] = new Date(Long.parseLong(item[0].toString()));
+        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), value};
+            calendar.add(Calendar.MINUTE, 1);
+            result.add(dv);
         });
         return result;
     }

--
Gitblit v1.9.3