From 5bf42aa9950058f391805e6fb8d7376f4378924b Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 23 十二月 2024 16:16:55 +0800 Subject: [PATCH] cumulateHandle.getCurrent --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java | 35 ++++++++++++++++++++++++++++------- 1 files changed, 28 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 a7e7c44..0e3bdc7 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 @@ -6,8 +6,10 @@ import com.iailab.module.model.mcs.pre.dto.MmItemOutputDTO; import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; import com.iailab.module.model.mcs.pre.service.MmItemOutputService; +import org.apache.commons.lang3.StringUtils; 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,19 +26,24 @@ 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) { @@ -44,21 +51,35 @@ 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 - public MmItemOutputEntity getByItemid(String itemid, String resultstr) { + public MmItemOutputEntity getByItemid(String itemid, String resultstr, String resultIndex) { QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("itemid", itemid).eq("resultstr", resultstr); + queryWrapper.eq("itemid", itemid) + .eq("resultstr", resultstr) + .eq(StringUtils.isNotBlank(resultIndex), "result_index", resultIndex); return mmItemOutputDao.selectOne(queryWrapper); } -- Gitblit v1.9.3