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/MmPredictItemServiceImpl.java |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)

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 a1bf58c..3a38f00 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
@@ -58,6 +58,8 @@
     @Autowired
     private MmPredictItemDao mmPredictItemDao;
 
+    private static HashMap<String, ItemVO> itemVOHashMap = new HashMap<>();
+
     @Override
     public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) {
         IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO);
@@ -73,12 +75,6 @@
     @Override
     public MmPredictItemEntity getById(String id) {
         return  mmPredictItemDao.selectById(id);
-    }
-
-    @Override
-    public List<Object[]> getHisData(String itemId, Date startTime, Date endTime) {
-        List<Object[]> result = new ArrayList<>();
-        return result;
     }
 
     @DSTransactional(rollbackFor = Exception.class)
@@ -133,6 +129,9 @@
             e.setItemid(predictItem.getId());
         });
         mmItemOutputService.saveMmItemOutput(mmItemOutput);
+
+        // 清空缓存
+        clearCatch();
     }
 
     @DSTransactional(rollbackFor = Exception.class)
@@ -172,6 +171,9 @@
             e.setItemid(predictItem.getId());
         });
         mmItemOutputService.saveMmItemOutput(mmItemOutput);
+
+        // 清空缓存
+        clearCatch();
     }
 
     @DSTransactional(rollbackFor = Exception.class)
@@ -181,6 +183,9 @@
         mmPredictMergeItemService.deleteBatch(itemIds);
         mmPredictModelService.deleteBatch(itemIds);
         mmItemOutputService.deleteBatch(itemIds);
+
+        // 清空缓存
+        clearCatch();
     }
 
     @Override
@@ -194,7 +199,7 @@
         if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) {
             MmPredictModelEntity mmPredictModel = mmPredictModelService.getByItemid(id);
             mmPredictItemDto.setMmPredictModel(mmPredictModel);
-            mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelid(mmPredictModel.getId()));
+            mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelId(mmPredictModel.getId()));
             mmPredictItemDto.setMmModelParamList(mmModelParamService.getByModelid(mmPredictModel.getId()));
             mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity());
         } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) {
@@ -241,17 +246,25 @@
     }
 
     @Override
+    public void clearCatch() {
+        itemVOHashMap.clear();
+    }
+
+    @Override
     public ItemVO getItemById(String itemId) {
         if (StringUtils.isBlank(itemId)) {
             return null;
         }
-        Map<String, Object> params = new HashMap(1);
-        params.put("ITEMID", itemId);
-        List<ItemVO> list = mmPredictItemDao.getItem(params);
-        if (CollectionUtils.isEmpty(list)) {
-            return null;
+        if (!itemVOHashMap.containsKey(itemId)) {
+            Map<String, Object> params = new HashMap<>(1);
+            params.put("ITEMID", itemId);
+            List<ItemVO> list = mmPredictItemDao.getItem(params);
+            if (CollectionUtils.isEmpty(list)) {
+                return null;
+            }
+            itemVOHashMap.put(itemId, list.get(0));
         }
-        return list.get(0);
+        return itemVOHashMap.get(itemId);
     }
 
     @Override

--
Gitblit v1.9.3