From e0b86ecb9040b56bad93356263805baff76442b4 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期五, 29 十一月 2024 17:24:30 +0800
Subject: [PATCH] Timestamp

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemMergeHandlerImpl.java |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 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 19ae68b..ef85630 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
@@ -4,6 +4,8 @@
 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;
@@ -41,6 +43,12 @@
     @Autowired
     private PredictResultHandler predictResultHandler;
 
+    @Autowired
+    private MmItemResultService mmItemResultService;
+
+    @Autowired
+    private MmItemOutputService mmItemOutputService;
+
     /**
      * MergeItem预测
      *
@@ -60,7 +68,7 @@
             int predictLength = itemEntityFactory.getItemById(itemId).getPredictLength();
             double[][] predictResultMat = new double[predictLength][1];
             Map<String, List<DataValueVO>> predictValueMap = new HashMap<>();
-            String[] mathItem = expression.split("[\\+ \\-]");
+            String[] mathOutPutId = expression.split("[\\+ \\-]");
             ArrayList<Character> operator = new ArrayList<>();
             for (int i = 0; i < expression.length(); i++) {
                 if (expression.charAt(i)=='+' || expression.charAt(i)=='-'){
@@ -69,34 +77,36 @@
             }
             String[] compositionItem = expression.split(String.valueOf("&".toCharArray()));
             //是否为计算预测项
-            if (mathItem.length > 1) {
-                for (String itemNo : mathItem) {
-                    if (itemNo.length() > 4) {
+            if (mathOutPutId.length > 1) {
+                for (String outPutId : mathOutPutId) {
+                    if (outPutId.length() > 4) {
                         Date endTime = predictTime;
-                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
-                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
-                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPutList.get(0).getPointid());
+//                        ItemVO itemEntity = itemEntityFactory.getItemByItemNo(itemNo);
+//                        List<MmItemOutputEntity> outPutList = itemEntityFactory.getOutPutByItemId(itemEntity.getId());
+                        MmItemOutputEntity outPut = mmItemOutputService.getOutPutById(outPutId);
+                        ApiPointDTO pointEntity = dataPointApi.getInfoById(outPut.getPointid());
 
                         Calendar calendar = Calendar.getInstance();
                         calendar.setTime(endTime);
                         calendar.add(Calendar.SECOND, (predictLength - 1) * DataPointFreqEnum.getEumByCode(pointEntity.getMinfreqid()).getValue());
                         endTime = new Timestamp(calendar.getTime().getTime());
-                        List<DataValueVO> predictValueList = predictResultHandler.getPredictValueByItemNo(itemNo, predictTime, endTime);
+//                        List<DataValueVO> predictValueList = predictResultHandler.getPredictValueByItemNo(itemNo, predictTime, endTime);
+                        List<DataValueVO> predictValueList = mmItemResultService.getPredictValue(outPutId, predictTime, endTime);
                         if (predictValueList.size() != predictLength) {
-                            log.debug("merge项融合失败:缺少子项预测数据,对应子项ItemNo=" + itemNo);
+                            log.debug("merge项融合失败:缺少子项预测数据,对应子项outPutId=" + outPutId);
                             return null;
                         }
-                        predictValueMap.put(itemNo, predictValueList);
+                        predictValueMap.put(outPutId, predictValueList);
                     }
                 }
                 for (Integer i = 0; i < predictLength; i++) {
                     double sum =0.0;
-                    sum = predictValueMap.get(mathItem[0]).get(i).getDataValue();
-                    for (int j = 1; j < mathItem.length; j++) {
+                    sum = predictValueMap.get(mathOutPutId[0]).get(i).getDataValue();
+                    for (int j = 1; j < mathOutPutId.length; j++) {
                         if (operator.get(j-1)=='+')
-                        {sum += predictValueMap.get(mathItem[j]).get(i).getDataValue();}
+                        {sum += predictValueMap.get(mathOutPutId[j]).get(i).getDataValue();}
                         if (operator.get(j-1)=='-')
-                        {sum -= predictValueMap.get(mathItem[j]).get(i).getDataValue();}
+                        {sum -= predictValueMap.get(mathOutPutId[j]).get(i).getDataValue();}
                     }
                     predictResultMat[i][0] = sum;
                 }

--
Gitblit v1.9.3