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/MmPredictModelServiceImpl.java |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java
index 892bae3..12221fc 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.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.MmPredictMergeItemDao;
 import com.iailab.module.model.mcs.pre.dao.MmPredictModelDao;
 import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity;
 import com.iailab.module.model.mcs.pre.service.MmPredictModelService;
@@ -12,7 +10,6 @@
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -29,6 +26,8 @@
     private MmPredictModelDao mmPredictModelDao;
 
     private static Map<String, MmPredictModelEntity> modelEntityMap = new ConcurrentHashMap<>();
+
+    private static Map<String, MmPredictModelEntity> activeModelMap = new ConcurrentHashMap<>();
 
     @Override
     public void savePredictModel(MmPredictModelEntity predictModel) {
@@ -57,6 +56,7 @@
     @Override
     public void clearCache() {
         modelEntityMap.clear();
+        activeModelMap.clear();
     }
 
     @Override
@@ -99,7 +99,15 @@
     }
 
     @Override
-    public List<MmPredictModelEntity> getActiveModelByItemId(String itemId) {
-        return mmPredictModelDao.getActiveModelByItemId(itemId);
+    public MmPredictModelEntity getActiveModelByItemId(String itemId) {
+        if (activeModelMap.containsKey(itemId)) {
+            return activeModelMap.get(itemId);
+        }
+        List<MmPredictModelEntity> list = mmPredictModelDao.getActiveModelByItemId(itemId);
+        if (CollectionUtils.isEmpty(list)) {
+            return null;
+        }
+        activeModelMap.put(itemId, list.get(0));
+        return activeModelMap.get(itemId);
     }
 }

--
Gitblit v1.9.3