From 9b445c66fcc4b5870476a591c006d665f08ba915 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 24 十二月 2024 11:59:06 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java
index e9385d7..31d481e 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java
@@ -1,27 +1,23 @@
 package com.iailab.module.model.mdk.predict.impl;
 
+import com.alibaba.fastjson.JSON;
 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.MmItemOutputService;
 import com.iailab.module.model.mcs.pre.service.MmItemResultService;
-import com.iailab.module.model.mdk.common.enums.ItemPredictStatus;
 import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException;
 import com.iailab.module.model.mdk.factory.ItemEntityFactory;
 import com.iailab.module.model.mdk.factory.PredictItemFactory;
 import com.iailab.module.model.mdk.predict.PredictItemHandler;
 import com.iailab.module.model.mdk.predict.PredictResultHandler;
-import com.iailab.module.model.mdk.vo.DataValueVO;
 import com.iailab.module.model.mdk.vo.ItemVO;
 import com.iailab.module.model.mdk.vo.PredictResultVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
-import java.sql.Timestamp;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @author PanZhibao
@@ -59,15 +55,14 @@
      * @throws ItemInvokeException
      */
     @Override
-    public PredictResultVO predict(Date predictTime, ItemVO predictItemDto,Map<String, double[]> predictValueMap)
+    public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap)
             throws ItemInvokeException {
         PredictResultVO predictResult = new PredictResultVO();
-        ItemPredictStatus itemStatus = ItemPredictStatus.PREDICTING;
         String itemId = predictItemDto.getId();
         try {
             String expression = itemEntityFactory.getMergeItem(itemId).getExpression();
             int predictLength = itemEntityFactory.getItemById(itemId).getPredictLength();
-            double[][] predictResultMat = new double[predictLength][1];
+            double[] predictResultMat = new double[predictLength];
             String[] mathOutPutId = expression.split("[\\+ \\-]");
             ArrayList<Character> operator = new ArrayList<>();
             for (int i = 0; i < expression.length(); i++) {
@@ -110,7 +105,7 @@
                         if (operator.get(j-1)=='-')
                         {sum -= predictValueMap.get(mathOutPutId[j])[i];}
                     }
-                    predictResultMat[i][0] = sum;
+                    predictResultMat[i] = sum;
                 }
             }
             //是否为组合预测项
@@ -135,17 +130,19 @@
 //                predictResult.setPredictMatrix(matrix);
 //            }
             predictResult.setPredictId(itemId);
-            predictResult.setPredictMatrix(predictResultMat);
+            List<MmItemOutputEntity> outputServiceByItemid = mmItemOutputService.getByItemid(itemId);
+            if (!CollectionUtils.isEmpty(outputServiceByItemid)) {
+                Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>();
+                predictMatrixs.put(outputServiceByItemid.get(0),predictResultMat);
+                predictResult.setPredictMatrixs(predictMatrixs);
+            }
             predictResult.setPredictTime(predictTime);
-            //预测项预测成功的状态
-            itemStatus = ItemPredictStatus.SUCCESS;
         } catch (Exception e) {
-            //预测项预测失败的状态
-            itemStatus = ItemPredictStatus.FAILED;
-            log.debug("merge项预测失败,itemId:" + itemId);
+            log.error("merge项预测失败,itemId:" + itemId);
+            e.printStackTrace();
             throw e;
         }
-        log.debug("预测完成,itemId:" + itemId + ",itemStatus:" + itemStatus.getValue());
+        log.info("merge项预测完成,itemId:" + itemId + ",结果:" + JSON.toJSONString(predictResult));
         return predictResult;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3