| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | 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; |
| | |
| | | * @createTime 2024年09月2日 |
| | | */ |
| | | @Service |
| | | public class DaPointServiceImpl extends ServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { |
| | | public class DaPointServiceImpl extends BaseServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { |
| | | |
| | | @Autowired |
| | | private DaMeasurePointService daMeasurePointService; |
| | |
| | | @Resource |
| | | private ChannelSourceService channelSourceService; |
| | | |
| | | private static Map<String, DaPointDTO> pointIdMap = new ConcurrentHashMap<>(); |
| | | @Resource |
| | | private DaPointCollectStatusService daPointCollectStatusService; |
| | | |
| | | private static Map<String, ApiPointDTO> pointIdMap = new ConcurrentHashMap<>(); |
| | | |
| | | private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DaPointDTO getSimpleInfoById(String id) { |
| | | public ApiPointDTO getSimpleInfoById(String id) { |
| | | if (pointIdMap.containsKey(id)) { |
| | | return pointIdMap.get(id); |
| | | } |
| | | DaPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); |
| | | ApiPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), ApiPointDTO.class); |
| | | if (dto == null) { |
| | | return null; |
| | | } |
| | | pointIdMap.put(id, dto); |
| | | return pointIdMap.get(id); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | public DaPointDTO getSimpleInfoByNo(String no) { |
| | | QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper(); |
| | | QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("point_no", no); |
| | | return ConvertUtils.sourceToTarget(daPointDao.selectOne(queryWrapper), DaPointDTO.class); |
| | | } |
| | |
| | | daPointEntity.setCreateTime(new Date()); |
| | | daPointDao.insert(daPointEntity); |
| | | |
| | | daPointCollectStatusService.add(daPointEntity.getPointNo()); |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<ApiPointDTO> getPointPage(HashMap map) { |
| | | IPage<ApiPointDTO> page = daPointDao.getPointPage(getPage(map, Constant.CREATE_TIME, false),map); |
| | | return new PageResult<>(page.getRecords(), page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DaPointDTO> getMathPoint(String freq) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); |
| | |
| | | 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(List<String> pointNos) { |
| | | Map<String, Object> params = new HashMap<>(3); |
| | | params.put("pointType", PointTypeEnum.CUMULATE.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("pointNos", pointNos); |
| | | return daPointDao.getCumulatePoint(params); |
| | | } |
| | | |
| | |
| | | importPoints.forEach(importPoint -> { |
| | | |
| | | // 判断如果不存在,再进行插入 |
| | | DaPointEntity existPoint = baseMapper.selectByPointName(importPoint.getPointName()); |
| | | DaPointEntity existPoint = baseDao.selectByPointName(importPoint.getPointName()); |
| | | if (existPoint == null) { |
| | | DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(importPoint, DaPointEntity.class); |
| | | daPointEntity.setId(UUID.randomUUID().toString()); |
| | |
| | | } |
| | | |
| | | daPointDao.insert(daPointEntity); |
| | | daPointCollectStatusService.add(daPointEntity.getPointNo()); |
| | | respVO.getCreatePointnames().add(importPoint.getPointName()); |
| | | return; |
| | | } |
| | |
| | | |
| | | DaPointEntity updatePoint = BeanUtils.toBean(importPoint, DaPointEntity.class); |
| | | updatePoint.setId(existPoint.getId()); |
| | | baseMapper.updateById(updatePoint); |
| | | baseDao.updateById(updatePoint); |
| | | DaMeasurePointEntity measurePoint = new DaMeasurePointEntity(); |
| | | measurePoint.setSourceType(importPoint.getSourceType()); |
| | | measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName())); |