潘志宝
2024-09-03 f7e880deb0612ba5efe96e6ce229abd8c19bc6e7
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
@@ -2,38 +2,37 @@
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.iailab.framework.common.constant.Constant;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.common.enums.CommonConstant;
import com.iailab.module.data.common.enums.IsEnableEnum;
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.data.point.common.IncreaseCodeEnum;
import com.iailab.module.data.point.dao.DaPointDao;
import com.iailab.module.data.point.service.DaMeasurePointService;
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.dto.DaPointDTO;
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.vo.DaPointPageReqVO;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
/**
 * @author PanZhibao
 * @author lirm
 * @Description
 * @createTime 2024年05月12日
 * @createTime 2024年09月2日
 */
@Service
public class DaPointServiceImpl extends BaseServiceImpl<DaPointDao, DaPointEntity> implements DaPointService {
public class DaPointServiceImpl extends ServiceImpl<DaPointDao, DaPointEntity> implements DaPointService {
    @Resource
    private DaMeasurePointService daMeasurePointService;
@@ -43,19 +42,19 @@
    @Resource
    private DaSequenceNumService daSequenceNumService;
    @Resource
    private DaPointDao daPointDao;
    @Override
    public PageData<DaPointDTO> page(Map<String, Object> params) {
        IPage<DaPointDTO> page = baseDao.getPageList(
                getPage(params, Constant.CREATE_TIME, false),
                params
        );
        return getPageData(page, DaPointDTO.class);
    public PageResult<DaPointEntity> queryPage(DaPointPageReqVO reqVO) {
        return daPointDao.selectPage(reqVO);
    }
    @Override
    public DaPointDTO get(String id) {
        DaPointEntity entity = baseDao.selectById(id);
    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);
@@ -86,7 +85,7 @@
        .in(!CollectionUtils.isEmpty(pointNos),"point_no", pointNos)
        .like(StringUtils.isNotBlank(pointNoLike), "point_no", pointNoLike)
                .last("limit 1, 10");
        List<DaPointEntity> list = baseDao.selectList(queryWrapper);
        List<DaPointEntity> list = daPointDao.selectList(queryWrapper);
        return ConvertUtils.sourceToTarget(list, DaPointDTO.class);
    }
@@ -110,7 +109,7 @@
        }
        daPointEntity.setIsEnable(CommonConstant.IS_ENABLE);
        daPointEntity.setCreateTime(new Date());
        baseDao.insert(daPointEntity);
        daPointDao.insert(daPointEntity);
    }
    @Override
@@ -118,7 +117,7 @@
    public void update(DaPointDTO dataPoint) {
        DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class);
        daPointEntity.setUpdateTime(new Date());
        baseDao.updateById(daPointEntity);
        daPointDao.updateById(daPointEntity);
        if (PointTypeEnum.MEASURE_POINT.getName().equals(dataPoint.getPointType())) {
            DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint();
            measurePoint.setSourceType(dataPoint.getSourceOption().get(0));
@@ -133,7 +132,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(String[] ids) {
        baseDao.deleteBatchIds(Arrays.asList(ids));
        daPointDao.deleteBatchIds(Arrays.asList(ids));
        daMeasurePointService.deleteByPoint(ids);
        daMathPointService.deleteByPoint(ids);
    }
@@ -144,7 +143,7 @@
        params.put("pointType", PointTypeEnum.CONSTANT.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("minfreqid", freq);
        return baseDao.getConstantPoint(params);
        return daPointDao.getConstantPoint(params);
    }
    @Override
@@ -153,7 +152,7 @@
        params.put("pointType", PointTypeEnum.CONSTANT.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("pointNos", pointNos);
        return baseDao.getConstantPoint(params);
        return daPointDao.getConstantPoint(params);
    }
    @Override
@@ -162,7 +161,7 @@
        params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("minfreqid", freq);
        return baseDao.getMeasurePoint(params);
        return daPointDao.getMeasurePoint(params);
    }
    @Override
@@ -171,7 +170,7 @@
        params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("pointNos", pointNos);
        return baseDao.getMeasurePoint(params);
        return daPointDao.getMeasurePoint(params);
    }
    @Override
@@ -179,7 +178,7 @@
        Map<String, Object> params = new HashMap<>();
        params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode());
        params.put("pointNo", pointNo);
        List<DaPointDTO> list = baseDao.getMeasurePoint(params);
        List<DaPointDTO> list = daPointDao.getMeasurePoint(params);
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
@@ -192,7 +191,7 @@
        params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("minfreqid", freq);
        return baseDao.getMathPoint(params);
        return daPointDao.getMathPoint(params);
    }
    @Override
@@ -201,14 +200,14 @@
        params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode());
        params.put("isEnable", CommonConstant.IS_ENABLE);
        params.put("pointNos", pointNos);
        return baseDao.getMathPoint(params);
        return daPointDao.getMathPoint(params);
    }
    @Override
    public DaPointDTO getByNo(String pointNo) {
        QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("point_no", pointNo);
        DaPointEntity entity = baseDao.selectOne(wrapper);
        DaPointEntity entity = daPointDao.selectOne(wrapper);
        return ConvertUtils.sourceToTarget(entity, DaPointDTO.class);
    }
@@ -216,7 +215,7 @@
    public List<DaPointDTO> getByNos(List<String> pointNos) {
        QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>();
        wrapper.in("point_no", pointNos);
        List<DaPointEntity> list = baseDao.selectList(wrapper);
        List<DaPointEntity> list = daPointDao.selectList(wrapper);
        return ConvertUtils.sourceToTarget(list, DaPointDTO.class);
    }
@@ -226,7 +225,7 @@
        wrapper.eq("point_no", dto.getPointNo());
        DaPointEntity entity = new DaPointEntity();
        entity.setDefaultValue(dto.getDefaultValue());
        baseDao.update(entity, wrapper);
        daPointDao.update(entity, wrapper);
    }
    @Override
@@ -238,7 +237,7 @@
            DaPointEntity entity = new DaPointEntity();
            entity.setId(item);
            entity.setIsEnable(IsEnableEnum.ENABLE.value());
            baseDao.updateById(entity);
            daPointDao.updateById(entity);
        });
    }
@@ -251,7 +250,7 @@
            DaPointEntity entity = new DaPointEntity();
            entity.setId(item);
            entity.setIsEnable(IsEnableEnum.DISABLE.value());
            baseDao.updateById(entity);
            daPointDao.updateById(entity);
        });
    }
}