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/MmModelArithSettingsServiceImpl.java |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java
index f26796c..8059a9f 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmModelArithSettingsServiceImpl.java
@@ -2,8 +2,6 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.iailab.framework.common.service.impl.BaseServiceImpl;
-import com.iailab.module.model.mcs.pre.dao.MmItemTypeDao;
 import com.iailab.module.model.mcs.pre.dao.MmModelArithSettingsDao;
 import com.iailab.module.model.mcs.pre.entity.MmModelArithSettingsEntity;
 import com.iailab.module.model.mcs.pre.service.MmModelArithSettingsService;
@@ -12,6 +10,7 @@
 import org.springframework.util.CollectionUtils;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * @author PanZhibao
@@ -23,7 +22,9 @@
 
     @Autowired
     private MmModelArithSettingsDao mmModelArithSettingsDao;
-    
+
+    private static Map<String, List<MmModelArithSettingsEntity>> modelIdMap = new ConcurrentHashMap<>();
+
     @Override
     public void saveList(List<MmModelArithSettingsEntity> list) {
         QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
@@ -33,23 +34,23 @@
             item.setId(UUID.randomUUID().toString());
         });
         mmModelArithSettingsDao.insertList(list);
-    }
 
-    public List<MmModelArithSettingsEntity> getByModelid(String modelid) {
-        Map<String, Object> params = new HashMap<>(1);
-        params.put("modelid", modelid);
-        List<MmModelArithSettingsEntity> list = mmModelArithSettingsDao.getMmModelArithSettings(params);
-
-        if (CollectionUtils.isEmpty(list)) {
-            return new ArrayList<>();
-        }
-        return list;
+        // 清空缓存
+        modelIdMap.clear();
     }
 
     @Override
     public List<MmModelArithSettingsEntity> getByModelId(String modelId) {
-        QueryWrapper<MmModelArithSettingsEntity> queryWrapper = new QueryWrapper();
-        queryWrapper.eq("modelid", modelId);
-        return mmModelArithSettingsDao.selectList(queryWrapper);
+        if (modelIdMap.containsKey(modelId)) {
+            return modelIdMap.get(modelId);
+        }
+        Map<String, Object> params = new HashMap<>(1);
+        params.put("modelid", modelId);
+        List<MmModelArithSettingsEntity> list =  mmModelArithSettingsDao.getMmModelArithSettings(params);
+        if (CollectionUtils.isEmpty(list)) {
+            list = new ArrayList<>();
+        }
+        modelIdMap.put(modelId, list);
+        return list;
     }
 }

--
Gitblit v1.9.3