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/MmPredictItemServiceImpl.java | 75 ++++++++++++++++++++++++++++--------- 1 files changed, 57 insertions(+), 18 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java index 828c7fd..7f4dfec 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java @@ -17,6 +17,7 @@ import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mdk.vo.ItemVO; import com.iailab.module.model.mdk.vo.MergeItemVO; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -58,6 +59,8 @@ @Autowired private MmPredictItemDao mmPredictItemDao; + private static HashMap<String, ItemVO> itemVOHashMap = new HashMap<>(); + @Override public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) { IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO); @@ -73,12 +76,6 @@ @Override public MmPredictItemEntity getById(String id) { return mmPredictItemDao.selectById(id); - } - - @Override - public List<Object[]> getHisData(String itemId, Date startTime, Date endTime) { - List<Object[]> result = new ArrayList<>(); - return result; } @DSTransactional(rollbackFor = Exception.class) @@ -127,9 +124,15 @@ dmModuleItem.setItemid(predictItem.getId()); dmModuleItemService.saveModuleItem(dmModuleItem); - MmItemOutputEntity mmItemOutput = mmPredictItemDto.getMmItemOutput(); - mmItemOutput.setItemid(predictItem.getId()); + List<MmItemOutputEntity> mmItemOutput = mmPredictItemDto.getMmItemOutputList(); + mmItemOutput.forEach(e -> { + e.setId(UUID.randomUUID().toString()); + e.setItemid(predictItem.getId()); + }); mmItemOutputService.saveMmItemOutput(mmItemOutput); + + // 清空缓存 + clearCatch(); } @DSTransactional(rollbackFor = Exception.class) @@ -162,10 +165,22 @@ if (!"".equals(dmModuleItem.getId()) && dmModuleItem.getId() != null) { dmModuleItemService.update(dmModuleItem); } - MmItemOutputEntity mmItemOutput = mmPredictItemDto.getMmItemOutput(); - if (!"".equals(mmItemOutput.getId()) && dmModuleItem.getId() != null) { - mmItemOutputService.update(mmItemOutput); + mmItemOutputService.deleteByItemId(predictItem.getId()); + List<MmItemOutputEntity> mmItemOutput = mmPredictItemDto.getMmItemOutputList(); + if (!CollectionUtils.isEmpty(mmItemOutput)) { + mmItemOutput.forEach(e -> { + // 尽量保存原有id + if (StringUtils.isBlank(e.getId())) { + e.setId(UUID.randomUUID().toString()); + } + e.setItemid(predictItem.getId()); + }); + mmItemOutputService.saveMmItemOutput(mmItemOutput); } + + + // 清空缓存 + clearCatch(); } @DSTransactional(rollbackFor = Exception.class) @@ -175,6 +190,9 @@ mmPredictMergeItemService.deleteBatch(itemIds); mmPredictModelService.deleteBatch(itemIds); mmItemOutputService.deleteBatch(itemIds); + + // 清空缓存 + clearCatch(); } @Override @@ -183,12 +201,12 @@ MmPredictItemDTO mmPredictItemDto = BeanUtils.toBean(predictItem, MmPredictItemDTO.class); mmPredictItemDto.setMmPredictItem(predictItem); mmPredictItemDto.setDmModuleItem(dmModuleItemService.getByItemid(id)); - mmPredictItemDto.setMmItemOutput(mmItemOutputService.getByItemid(id)); + mmPredictItemDto.setMmItemOutputList(mmItemOutputService.getByItemid(id)); MmItemTypeEntity itemType = mmItemTypeImpl.getById(predictItem.getItemtypeid()); if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { MmPredictModelEntity mmPredictModel = mmPredictModelService.getByItemid(id); mmPredictItemDto.setMmPredictModel(mmPredictModel); - mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelid(mmPredictModel.getId())); + mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelId(mmPredictModel.getId())); mmPredictItemDto.setMmModelParamList(mmModelParamService.getByModelid(mmPredictModel.getId())); mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity()); } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { @@ -235,17 +253,38 @@ } @Override + public void clearCatch() { + itemVOHashMap.clear(); + } + + @Override public ItemVO getItemById(String itemId) { if (StringUtils.isBlank(itemId)) { return null; } - Map<String, Object> params = new HashMap(1); - params.put("ITEMID", itemId); - List<ItemVO> list = mmPredictItemDao.getItem(params); - if (CollectionUtils.isEmpty(list)) { + if (!itemVOHashMap.containsKey(itemId)) { + Map<String, Object> params = new HashMap<>(1); + params.put("ITEMID", itemId); + List<ItemVO> list = mmPredictItemDao.getItem(params); + if (CollectionUtils.isEmpty(list)) { + return null; + } + itemVOHashMap.put(itemId, list.get(0)); + } + return itemVOHashMap.get(itemId); + } + + @Override + public ItemVO getItemByOutPutId(String outPutId) { + if (StringUtils.isBlank(outPutId)) { return null; } - return list.get(0); + MmItemOutputEntity outPutById = mmItemOutputService.getOutPutById(outPutId); + if (ObjectUtils.isEmpty(outPutById)) { + return null; + } + String itemId = outPutById.getItemid(); + return getItemById(itemId); } @Override -- Gitblit v1.9.3