| | |
| | | package com.iailab.module.data.point.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| | | 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.google.common.annotations.VisibleForTesting; |
| | | import com.iailab.framework.common.exception.ServiceException; |
| | | 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.framework.datapermission.core.util.DataPermissionUtils; |
| | | import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | 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.point.common.IncreaseCodeEnum; |
| | | 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.DaMeasurePointDTO; |
| | |
| | | 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.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | import com.iailab.module.data.enums.ErrorCodeConstants; |
| | | 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 |
| | |
| | | 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 |
| | |
| | | |
| | | @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 |
| | |
| | | daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); |
| | | daPointEntity.setCreateTime(new Date()); |
| | | daPointDao.insert(daPointEntity); |
| | | |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | default: |
| | | break; |
| | | } |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | daPointDao.deleteBatchIds(Arrays.asList(id)); |
| | | daMeasurePointService.deleteByPoint(id); |
| | | daMathPointService.deleteByPoint(id); |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @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 |
| | |
| | | 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); |
| | | }); |
| | | } |
| | |
| | | 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); |
| | | }); |
| | | } |