From 4be7d863a161b64f8592a789d699e807545e7dc6 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期五, 15 十一月 2024 16:46:12 +0800 Subject: [PATCH] 计划数据 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java | 49 +++++++++++++++++++++++++++++++++++++------------ 1 files changed, 37 insertions(+), 12 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java index a761e3b..58ac5ec 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java @@ -23,18 +23,20 @@ import com.iailab.module.data.point.service.DaMeasurePointService; import com.iailab.module.data.point.service.DaPointService; import com.iailab.module.data.point.service.DaSequenceNumService; -import com.iailab.module.data.point.vo.*; -import com.iailab.module.infra.api.config.ConfigApi; +import com.iailab.module.data.point.vo.DaPointPageReqVO; +import com.iailab.module.data.point.vo.PointImportExcelVO; +import com.iailab.module.data.point.vo.PointImportRespVO; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; - import javax.annotation.Resource; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.iailab.module.data.enums.ErrorCodeConstants.*; +import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_EXISTS; +import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_IMPORT_LIST_IS_EMPTY; /** * @author lirm @@ -57,15 +59,21 @@ private DaPointDao daPointDao; @Resource - private ConfigApi configApi; - - @Resource private ChannelSourceService channelSourceService; + + private static Map<String, DaPointDTO> pointIdMap = new ConcurrentHashMap<>(); + + private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>(); @Override public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) { IPage<DaPointDTO> page = daPointDao.selectPageList(reqVO); - return new PageResult<DaPointDTO>(page.getRecords(), page.getTotal()); + return new PageResult<>(page.getRecords(), page.getTotal()); + } + + private void clearCache() { + pointIdMap.clear(); + pointNoMap.clear(); } @Override @@ -88,7 +96,12 @@ @Override public DaPointDTO getSimpleInfoById(String id) { - return ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); + if (pointIdMap.containsKey(id)) { + return pointIdMap.get(id); + } + DaPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); + pointIdMap.put(id, dto); + return dto; } @Override @@ -147,6 +160,9 @@ daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); daPointEntity.setCreateTime(new Date()); daPointDao.insert(daPointEntity); + + // 清空缓存 + clearCache(); } @Override @@ -169,6 +185,8 @@ default: break; } + // 清空缓存 + clearCache(); } @Override @@ -177,6 +195,8 @@ daPointDao.deleteBatchIds(Arrays.asList(id)); daMeasurePointService.deleteByPoint(id); daMathPointService.deleteByPoint(id); + // 清空缓存 + clearCache(); } @Override @@ -275,10 +295,15 @@ @Override public DaPointDTO getByNo(String pointNo) { + if (pointNoMap.containsKey(pointNo)) { + return pointNoMap.get(pointNo); + } QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); wrapper.eq("point_no", pointNo); DaPointEntity entity = daPointDao.selectOne(wrapper); - return ConvertUtils.sourceToTarget(entity, DaPointDTO.class); + DaPointDTO dto = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); + pointNoMap.put(pointNo, dto); + return dto; } @Override @@ -381,7 +406,7 @@ Arrays.asList(ids).forEach(item -> { DaPointEntity entity = new DaPointEntity(); entity.setId(item); - entity.setIsEnable(IsEnableEnum.ENABLE.value()); + entity.setIsEnable(IsEnableEnum.ENABLE.getCode()); daPointDao.updateById(entity); }); } @@ -394,7 +419,7 @@ Arrays.asList(ids).forEach(item -> { DaPointEntity entity = new DaPointEntity(); entity.setId(item); - entity.setIsEnable(IsEnableEnum.DISABLE.value()); + entity.setIsEnable(IsEnableEnum.DISABLE.getCode()); daPointDao.updateById(entity); }); } -- Gitblit v1.9.3