From b82ba2a29aa9ee181c707677157d8057fff68450 Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期一, 16 十二月 2024 13:50:33 +0800
Subject: [PATCH] 预测项数据图表查询bug,不能从缓存中查item,要最新的运行时间

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java      |   16 ++++++++--------
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java          |    2 +-
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java       |    2 +-
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java              |    2 +-
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java |   15 +++++++++++++--
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java |    2 +-
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java                                |    4 ++--
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java                 |    2 +-
 8 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
index fa66d48..965a3cd 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java
@@ -134,7 +134,7 @@
         Date predictTime = reqVO.getPredictTime();
         if (predictTime == null) {
             MmItemOutputEntity output = mmItemOutputService.getOutPutById(reqVO.getOutIds().get(0));
-            ItemVO predictItem = mmPredictItemService.getItemById(output.getItemid());
+            ItemVO predictItem = mmPredictItemService.getItemByIdFromCache(output.getItemid());
             if (predictItem.getLastTime() != null) {
                 predictTime = predictItem.getLastTime();
             } else {
@@ -235,7 +235,7 @@
     @Override
     public PreDataItemChartRespVO getPreDataItemChart(PreDataItemChartReqVO reqVO) {
         PreDataItemChartRespVO result = new PreDataItemChartRespVO();
-        ItemVO predictItem = mmPredictItemService.getItemById(reqVO.getItemId());
+        ItemVO predictItem = mmPredictItemService.getItemByIdFromCache(reqVO.getItemId());
         if (predictItem == null) {
             return result;
         }
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
index e837bf0..72dc043 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java
@@ -8,7 +8,6 @@
 import com.iailab.module.model.mdk.vo.ItemVO;
 import com.iailab.module.model.mdk.vo.MergeItemVO;
 
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -28,6 +27,7 @@
 
     ItemVO getItemByItemNo(String itemNo);
 
+    ItemVO getItemByIdFromCache(String itemId);
     ItemVO getItemById(String itemId);
 
     ItemVO getItemByOutPutId(String outPutId);
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
index 7f4dfec..d058b4c 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -258,7 +258,7 @@
     }
 
     @Override
-    public ItemVO getItemById(String itemId) {
+    public ItemVO getItemByIdFromCache(String itemId) {
         if (StringUtils.isBlank(itemId)) {
             return null;
         }
@@ -275,6 +275,17 @@
     }
 
     @Override
+    public ItemVO getItemById(String itemId) {
+        Map<String, Object> params = new HashMap<>(1);
+        params.put("ITEMID", itemId);
+        List<ItemVO> list = mmPredictItemDao.getItem(params);
+        if (CollectionUtils.isEmpty(list)) {
+            return null;
+        }
+        return list.get(0);
+    }
+
+    @Override
     public ItemVO getItemByOutPutId(String outPutId) {
         if (StringUtils.isBlank(outPutId)) {
             return null;
@@ -284,7 +295,7 @@
             return null;
         }
         String itemId = outPutById.getItemid();
-        return getItemById(itemId);
+        return getItemByIdFromCache(itemId);
     }
 
     @Override
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java
index 52924f1..82634b2 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/factory/ItemEntityFactory.java
@@ -77,7 +77,7 @@
      * @return
      */
     public ItemVO getItemById(String itemId) {
-        ItemVO ItemVO = mmPredictItemService.getItemById(itemId);
+        ItemVO ItemVO = mmPredictItemService.getItemByIdFromCache(itemId);
         if (!ItemVOHashMap.containsKey(itemId)) {
             if (ItemVO != null) {
                 ItemVOHashMap.put(itemId, ItemVO);
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java
index 855794b..2d8ea79 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java
@@ -40,7 +40,6 @@
     public PredictResultVO predict(Date predictTime, ItemVO predictItemDto) throws ItemInvokeException {
         PredictResultVO predictResult = new PredictResultVO();
         String itemId = predictItemDto.getId();
-        predictResult.setPredictId(itemId);
         try {
             MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId);
             if (predictModel == null) {
@@ -48,6 +47,7 @@
                         ModelInvokeException.errorGetModelEntity, itemId));
             }
             predictResult = predictModelHandler.predictByModel(predictTime, predictModel);
+            predictResult.setPredictId(itemId);
         } catch (Exception ex) {
             throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}",
                     ItemInvokeException.errorItemFailed, itemId));
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
index e8a9142..88cefdd 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
@@ -86,13 +86,13 @@
             param2Values[portLength] = newModelBean.getDataMap().get("models");
             param2Values[portLength + 1] = settings;
 
-            log.info("#######################预测模型 " + predictModel.getItemid() + " ##########################");
-            JSONObject jsonObjNewModelBean = new JSONObject();
-            jsonObjNewModelBean.put("newModelBean", newModelBean);
-            log.info(String.valueOf(jsonObjNewModelBean));
-            JSONObject jsonObjParam2Values = new JSONObject();
-            jsonObjParam2Values.put("param2Values", param2Values);
-            log.info(String.valueOf(jsonObjParam2Values));
+            log.info("####################### 预测模型 "+ "【itemId:" + predictModel.getItemid() + ",modelName" + predictModel.getMethodname() + "】 ##########################");
+//            JSONObject jsonObjNewModelBean = new JSONObject();
+//            jsonObjNewModelBean.put("newModelBean", newModelBean);
+//            log.info(String.valueOf(jsonObjNewModelBean));
+//            JSONObject jsonObjParam2Values = new JSONObject();
+//            jsonObjParam2Values.put("param2Values", param2Values);
+//            log.info(String.valueOf(jsonObjParam2Values));
 
             //IAILMDK.run
             HashMap<String, Object> modelResult = DllUtils.run(newModelBean, param2Values, predictModel.getMpkprojectid());
@@ -102,7 +102,7 @@
             }
             modelResult = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT);
             //打印结果
-            log.info("预测模型计算完成:modelId=" + modelId + modelResult);
+            log.info("预测模型计算完成:modelId=" + modelId + ",modelName" + predictModel.getMethodname());
             JSONObject jsonObjResult = new JSONObject();
             jsonObjResult.put("result", modelResult);
             log.info(String.valueOf(jsonObjResult));
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
index 3a8e085..582a1b9 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/PredictSampleInfoConstructor.java
@@ -105,7 +105,7 @@
      */
     @Override
     protected Integer getSampleCycle(String modelId) {
-        return mmPredictItemService.getItemById(mmPredictModelService.getInfoFromCatch(modelId).getItemid()).getGranularity();
+        return mmPredictItemService.getItemByIdFromCache(mmPredictModelService.getInfoFromCatch(modelId).getItemid()).getGranularity();
     }
 
 
diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
index 3d53588..54dea55 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -179,7 +179,7 @@
                 granularity = mmPredictItemService.getItemByOutPutId(columnItem.getParamId()).getGranularity();
                 break;
             case MERGEITEM:
-                granularity = mmPredictItemService.getItemById(columnItem.getParamId()).getGranularity();
+                granularity = mmPredictItemService.getItemByIdFromCache(columnItem.getParamId()).getGranularity();
                 break;
             case IND:
                 ApiIndItemDTO indItemDTO = indItemApi.getInfoById(columnItem.getParamId());

--
Gitblit v1.9.3