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/MmItemOutputServiceImpl.java | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java index 0c69a6b..3ab68e9 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java @@ -8,6 +8,7 @@ import com.iailab.module.model.mcs.pre.service.MmItemOutputService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Map; @@ -24,35 +25,52 @@ private MmItemOutputDao mmItemOutputDao; private static Map<String, MmItemOutputEntity> outputMap = new ConcurrentHashMap<>(); + + private static Map<String, List<MmItemOutputEntity>> itemMap = new ConcurrentHashMap<>(); @Override public void saveMmItemOutput(List<MmItemOutputEntity> mmItemOutput) { + mmItemOutput.forEach(e -> { + e.setId(e.getId().replace("+","").replace("-","")); + }); mmItemOutputDao.insert(mmItemOutput); // 清空缓存 - outputMap.clear(); + clearCache(); } @Override public void update(MmItemOutputEntity mmItemOutput) { mmItemOutputDao.updateById(mmItemOutput); // 清空缓存 - outputMap.clear(); + clearCache(); } public void deleteBatch(String[] itemIds) { - QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); + QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.in("itemid", itemIds); mmItemOutputDao.delete(queryWrapper); // 清空缓存 + clearCache(); + } + + private void clearCache() { outputMap.clear(); + itemMap.clear(); } @Override - public List<MmItemOutputEntity> getByItemid(String itemid) { + public List<MmItemOutputEntity> getByItemid(String itemId) { + if (itemMap.containsKey(itemId)) { + return itemMap.get(itemId); + } QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("itemid", itemid).orderByAsc("outputorder"); + queryWrapper.eq("itemid", itemId).orderByAsc("outputorder"); List<MmItemOutputEntity> list = mmItemOutputDao.selectList(queryWrapper); - return list; + if (CollectionUtils.isEmpty(list)) { + return null; + } + itemMap.put(itemId, list); + return itemMap.get(itemId); } @Override @@ -64,7 +82,7 @@ @Override public void deleteByItemId(String itemId) { - QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); + QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("itemid", itemId); mmItemOutputDao.delete(queryWrapper); } -- Gitblit v1.9.3