From a440ec3bfaa1363f5841100b8948d852971a2eb1 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 10 十二月 2024 13:19:58 +0800 Subject: [PATCH] MmPredictAlarmConfigService --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictModelServiceImpl.java | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 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..4738817 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,17 +2,15 @@ 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.ObjectUtils; import java.math.BigDecimal; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -29,6 +27,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 +57,7 @@ @Override public void clearCache() { modelEntityMap.clear(); + activeModelMap.clear(); } @Override @@ -67,11 +68,11 @@ @Override public BigDecimal getSampleLength(String id) { BigDecimal result = BigDecimal.ZERO; - List<MmPredictModelEntity> list = mmPredictModelDao.getSampleLength(id); - if (CollectionUtils.isEmpty(list)) { + MmPredictModelEntity entity = mmPredictModelDao.getSampleLength(id); + if (ObjectUtils.isEmpty(entity)) { return result; } - result = list.get(0).getPredictsamplength(); + result = entity.getPredictsamplength(); return result; } @@ -99,7 +100,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