From 7f0bcd00c556889ba890e5e68c681f1b5d4267e1 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期四, 19 十二月 2024 18:07:20 +0800 Subject: [PATCH] 预测项状态添加模型结果异常 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java | 133 +++++++++++++++++++++++++++++++++---------- 1 files changed, 101 insertions(+), 32 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 3310495..b9742f0 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 @@ -9,24 +9,25 @@ import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.api.point.dto.ApiPointDTO; import com.iailab.module.data.channel.common.service.ChannelSourceService; import com.iailab.module.data.common.enums.CommonConstant; import com.iailab.module.data.common.enums.IsEnableEnum; import com.iailab.module.data.common.enums.IncreaseCodeEnum; import com.iailab.module.data.point.common.PointTypeEnum; import com.iailab.module.data.point.dao.DaPointDao; +import com.iailab.module.data.point.dto.DaCumulatePointDTO; +import com.iailab.module.data.point.dto.DaMathPointDTO; import com.iailab.module.data.point.dto.DaMeasurePointDTO; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.entity.DaMeasurePointEntity; import com.iailab.module.data.point.entity.DaPointEntity; -import com.iailab.module.data.point.service.DaMathPointService; -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.service.*; 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.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -46,13 +47,16 @@ @Service public class DaPointServiceImpl extends ServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { - @Resource + @Autowired private DaMeasurePointService daMeasurePointService; - @Resource + @Autowired private DaMathPointService daMathPointService; - @Resource + @Autowired + private DaCumulatePointService daCumulatePointService; + + @Autowired private DaSequenceNumService daSequenceNumService; @Resource @@ -61,41 +65,70 @@ @Resource private ChannelSourceService channelSourceService; + @Resource + private DaPointCollectStatusService daPointCollectStatusService; + + private static Map<String, ApiPointDTO> 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 public DaPointDTO info(String id) { DaPointEntity entity = daPointDao.selectById(id); DaPointDTO result = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); - if (PointTypeEnum.MEASURE_POINT.getCode().equals(result.getPointType())) { - DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id); - result.setMeasurePoint(measurePoint); - List<String> sourceOption = new ArrayList<>(); - sourceOption.add(measurePoint.getSourceType()); - sourceOption.add(measurePoint.getSourceId()); - sourceOption.add(measurePoint.getTagNo()); - result.setSourceOption(sourceOption); - } else if (PointTypeEnum.CALCULATE_POINT.getCode().equals(result.getPointType())) { - result.setMathPoint(daMathPointService.getByPoint(id)); + result.setMeasurePoint(new DaMeasurePointDTO()); + result.setMathPoint(new DaMathPointDTO()); + result.setCumulatePoint(new DaCumulatePointDTO()); + switch (PointTypeEnum.getEumByCode(result.getPointType())) { + case MEASURE_POINT: + DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id); + result.setMeasurePoint(measurePoint); + List<String> sourceOption = new ArrayList<>(); + sourceOption.add(measurePoint.getSourceType()); + sourceOption.add(measurePoint.getSourceId()); + sourceOption.add(measurePoint.getTagNo()); + result.setSourceOption(sourceOption); + break; + case CALCULATE_POINT: + result.setMathPoint(daMathPointService.getByPoint(id)); + break; + case CUMULATE: + result.setCumulatePoint(daCumulatePointService.getByPoint(id)); + break; + default: + break; } return result; } @Override - public DaPointDTO getSimpleInfoById(String id) { - return ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); + public ApiPointDTO getSimpleInfoById(String id) { + if (pointIdMap.containsKey(id)) { + return pointIdMap.get(id); + } + ApiPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), ApiPointDTO.class); + if (dto == null) { + return null; + } + pointIdMap.put(id, dto); + return dto; } @Override public DaPointDTO getSimpleInfoByNo(String no) { - QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper(); - queryWrapper.eq("pointNo", no); + QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("point_no", no); return ConvertUtils.sourceToTarget(daPointDao.selectOne(queryWrapper), DaPointDTO.class); } @@ -142,6 +175,10 @@ case CONSTANT: daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name())); break; + case CUMULATE: + daCumulatePointService.add(dataPoint.getCumulatePoint(), daPointEntity.getId()); + daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name())); + break; default: break; } @@ -149,8 +186,9 @@ daPointEntity.setCreateTime(new Date()); daPointDao.insert(daPointEntity); + daPointCollectStatusService.add(daPointEntity.getPointNo()); // 清空缓存 - pointNoMap.clear(); + clearCache(); } @Override @@ -170,21 +208,25 @@ case CALCULATE_POINT: daMathPointService.update(dataPoint.getMathPoint()); break; + case CUMULATE: + daCumulatePointService.update(dataPoint.getCumulatePoint()); + break; default: break; } // 清空缓存 - pointNoMap.clear(); + clearCache(); } @Override @DSTransactional(rollbackFor = Exception.class) - public void delete(String[] id) { - daPointDao.deleteBatchIds(Arrays.asList(id)); - daMeasurePointService.deleteByPoint(id); - daMathPointService.deleteByPoint(id); + public void delete(String[] ids) { + daPointDao.deleteBatchIds(Arrays.asList(ids)); + daMeasurePointService.deleteByPoint(ids); + daMathPointService.deleteByPoint(ids); + daCumulatePointService.deleteByPoint(ids); // 清空缓存 - pointNoMap.clear(); + clearCache(); } @Override @@ -282,6 +324,24 @@ } @Override + public List<DaPointDTO> getCumulatePoint(String freq) { + Map<String, Object> params = new HashMap<>(3); + params.put("pointType", PointTypeEnum.CUMULATE.getCode()); + params.put("isEnable", CommonConstant.IS_ENABLE); + params.put("minfreqid", freq); + return daPointDao.getCumulatePoint(params); + } + + @Override + public List<DaPointDTO> getCumulatePoint(DaPointPageReqVO reqVO) { + Map<String, Object> params = new HashMap<>(3); + params.put("pointType", PointTypeEnum.CUMULATE.getCode()); + params.put("pointNo", reqVO.getPointNo()); + params.put("pointName", reqVO.getPointName()); + return daPointDao.getCumulatePoint(params); + } + + @Override public DaPointDTO getByNo(String pointNo) { if (pointNoMap.containsKey(pointNo)) { return pointNoMap.get(pointNo); @@ -350,11 +410,19 @@ case CONSTANT: daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name())); break; + case CUMULATE: + DaCumulatePointDTO cumulatePoint = new DaCumulatePointDTO(); + cumulatePoint.setMomentPoint(importPoint.getMomentPoint()); + cumulatePoint.setLength(importPoint.getLength()); + cumulatePoint.setDivisor(importPoint.getDivisor()); + daCumulatePointService.add(cumulatePoint, daPointEntity.getId()); + daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name())); default: break; } daPointDao.insert(daPointEntity); + daPointCollectStatusService.add(daPointEntity.getPointNo()); respVO.getCreatePointnames().add(importPoint.getPointName()); return; } @@ -373,9 +441,6 @@ measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName())); measurePoint.setTagNo(importPoint.getTagNo()); daMeasurePointService.update(measurePoint, new QueryWrapper<DaMeasurePointEntity>().eq("point_id",updatePoint.getId())); - - - respVO.getUpdatePointnames().add(importPoint.getPointName()); }); return respVO; @@ -387,6 +452,7 @@ } @Override + @DSTransactional(rollbackFor = Exception.class) public void enableByIds(String[] ids) { if (CollectionUtils.isEmpty(Arrays.asList(ids))) { return; @@ -395,11 +461,13 @@ DaPointEntity entity = new DaPointEntity(); entity.setId(item); entity.setIsEnable(IsEnableEnum.ENABLE.getCode()); + entity.setUpdateTime(new Date()); daPointDao.updateById(entity); }); } @Override + @DSTransactional(rollbackFor = Exception.class) public void disableByIds(String[] ids) { if (CollectionUtils.isEmpty(Arrays.asList(ids))) { return; @@ -408,6 +476,7 @@ DaPointEntity entity = new DaPointEntity(); entity.setId(item); entity.setIsEnable(IsEnableEnum.DISABLE.getCode()); + entity.setUpdateTime(new Date()); daPointDao.updateById(entity); }); } -- Gitblit v1.9.3