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/mdk/predict/PredictResultHandler.java |   46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java
index 8bc9517..39729a7 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/PredictResultHandler.java
@@ -1,14 +1,10 @@
 package com.iailab.module.model.mdk.predict;
 
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
-import com.iailab.module.data.api.point.DataPointApi;
-import com.iailab.module.data.api.point.dto.ApiPointDTO;
-import com.iailab.module.data.enums.DataPointFreqEnum;
 import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
 import com.iailab.module.model.mcs.pre.service.MmItemResultService;
 import com.iailab.module.model.mdk.factory.ItemEntityFactory;
 import com.iailab.module.model.mdk.vo.DataValueVO;
-import com.iailab.module.model.mdk.vo.MmItemOutputVO;
 import com.iailab.module.model.mdk.vo.PredictResultVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
@@ -25,9 +21,6 @@
     @Autowired
     private ItemEntityFactory itemEntityFactory;
 
-    @Autowired
-    private DataPointApi dataPointApi;
-
     /**
      * convertToPredictData
      *
@@ -36,17 +29,15 @@
      */
     public Map<String, List<DataValueVO>> convertToPredictData(PredictResultVO predictResult) {
         Map<String, List<DataValueVO>> resultMap = new HashMap<>();
-        List<MmItemOutputVO> itemOutPutList = itemEntityFactory.getOutPutByItemId(predictResult.getPredictId());
+        List<MmItemOutputEntity> itemOutPutList = itemEntityFactory.getOutPutByItemId(predictResult.getPredictId());
 
         if (!CollectionUtils.isEmpty(predictResult.getPredictList())) {
             resultMap.put(itemOutPutList.get(0).getId(), predictResult.getPredictList());
             return resultMap;
         }
-        Map<MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
+        Map<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
         HashMap<String,List<DataValueVO>> predictLists = new HashMap<>();
-        for (Map.Entry<MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
-            ApiPointDTO point = dataPointApi.getInfoById(entry.getKey().getPointid());
-            Integer pointMinfreq = DataPointFreqEnum.getEumByCode(point.getMinfreqid()).getValue();
+        for (Map.Entry<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
             Integer rows = entry.getValue().length;
             List<DataValueVO> predictDataList = new ArrayList<>();
             Calendar calendar = Calendar.getInstance();
@@ -57,12 +48,37 @@
                 predictData.setDataValue(Double.valueOf(entry.getValue()[i]));
                 predictDataList.add(predictData);
 
-                calendar.add(Calendar.SECOND, pointMinfreq);
+                calendar.add(Calendar.SECOND, predictResult.getGranularity());
             }
             resultMap.put(entry.getKey().getId(), predictDataList);
+            predictLists.put(entry.getKey().getResultstr(), predictDataList);
         }
         predictResult.setPredictLists(predictLists);
         return resultMap;
+    }
+
+    public Map<String, List<DataValueVO>> convertToPredictData2(PredictResultVO predictResult) {
+        Map<String, List<DataValueVO>> predictLists = new HashMap<>();
+        if (!CollectionUtils.isEmpty(predictResult.getPredictList())) {
+            return predictLists;
+        }
+        Map<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> predictMatrixs = predictResult.getPredictMatrixs();
+        for (Map.Entry<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity, double[]> entry : predictMatrixs.entrySet()) {
+            Integer rows = entry.getValue().length;
+            List<DataValueVO> predictDataList = new ArrayList<>();
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(predictResult.getPredictTime());
+            for (Integer i = 0; i < rows; i++) {
+                DataValueVO predictData = new DataValueVO();
+                predictData.setDataTime(calendar.getTime());
+                predictData.setDataValue(Double.valueOf(entry.getValue()[i]));
+                predictDataList.add(predictData);
+
+                calendar.add(Calendar.SECOND, predictResult.getGranularity());
+            }
+            predictLists.put(entry.getKey().getResultstr(), predictDataList);
+        }
+        return predictLists;
     }
 
     /**
@@ -79,12 +95,12 @@
 
     public List<DataValueVO> getPredictValueByItemNo(String itemNo, Date start, Date end) {
         String itemId = itemEntityFactory.getItemByItemNo(itemNo).getId();
-        List<MmItemOutputVO> outputList = itemEntityFactory.getOutPutByItemId(itemId);
+        List<MmItemOutputEntity> outputList = itemEntityFactory.getOutPutByItemId(itemId);
         return mmItemResultService.getPredictValue(outputList.get(0).getId(), start, end);
     }
 
     public List<DataValueVO> getPredictValueByItemId(String itemId, Date start, Date end) {
-        List<MmItemOutputVO> outputList = itemEntityFactory.getOutPutByItemId(itemId);
+        List<MmItemOutputEntity> outputList = itemEntityFactory.getOutPutByItemId(itemId);
         return mmItemResultService.getPredictValue(outputList.get(0).getId(), start, end);
     }
 }

--
Gitblit v1.9.3