jiangping
2025-06-06 a2299a6d4a6f99e9c11132138f5d3e9ec68f03ea
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java
@@ -9,6 +9,7 @@
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.YwLinePointMapper;
import com.doumee.dao.business.YwPatrolLineMapper;
import com.doumee.dao.business.YwPatrolSchemeMapper;
import com.doumee.dao.business.model.*;
import com.doumee.service.business.YwPatrolLineService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -22,9 +23,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 运维巡检路线信息表Service实现
@@ -40,6 +40,8 @@
    @Autowired
    private YwLinePointMapper ywLinePointMapper;
    @Autowired
    private YwPatrolSchemeMapper ywPatrolSchemeMapper;
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer create(YwPatrolLine ywPatrolLine) {
@@ -56,8 +58,12 @@
        ywPatrolLine.setStatus(Constants.ZERO);
        ywPatrolLineMapper.insert(ywPatrolLine);
        //循环处理 子集数据
        List<YwLinePoint> ywLinePointList = ywPatrolLine.getLinePointList();
        //是否存在相同数据
        Set<Integer> setIds = new HashSet<Integer>(ywLinePointList.stream().map(i->i.getPointId()).collect(Collectors.toList()));
        if(setIds.size()!=ywLinePointList.size()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在相同巡检点!");
        }
        for (YwLinePoint ywLinePoint:ywLinePointList) {
            if(Objects.isNull(ywLinePoint)
            || Objects.isNull(ywLinePoint.getPointId())
@@ -65,10 +71,11 @@
            ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"巡检点配置错误");
            }
            ywLinePoint.setId(null);
            ywLinePoint.setCreateDate(new Date());
            ywLinePoint.setCreator(loginUserInfo.getId());
            ywLinePoint.setIsdeleted(Constants.ZERO);
            ywLinePoint.setLineId(ywLinePoint.getId());
            ywLinePoint.setLineId(ywPatrolLine.getId());
        }
        ywLinePointMapper.insert(ywLinePointList);
        return ywPatrolLine.getId();
@@ -76,6 +83,11 @@
    @Override
    public void deleteById(Integer id, LoginUserInfo user) {
        //查询是否存在巡检计划
        if(ywPatrolSchemeMapper.selectCount(new QueryWrapper<YwPatrolScheme>().lambda().eq(YwPatrolScheme::getIsdeleted, Constants.ZERO)
                .eq(YwPatrolScheme::getLineId,id))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前巡检线路已被使用,无法删除");
        };
        ywPatrolLineMapper.deleteById(id);
    }
@@ -94,6 +106,7 @@
    }
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public void updateById(YwPatrolLine ywPatrolLine) {
        if(Objects.isNull(ywPatrolLine)
                || StringUtils.isBlank(ywPatrolLine.getName())
@@ -110,6 +123,11 @@
                .eq(YwLinePoint::getLineId,ywPatrolLine.getId()));
        //循环处理 子集数据
        List<YwLinePoint> ywLinePointList = ywPatrolLine.getLinePointList();
        //是否存在相同数据
        Set<Integer> setIds = new HashSet<Integer>(ywLinePointList.stream().map(i->i.getPointId()).collect(Collectors.toList()));
        if(setIds.size()!=ywLinePointList.size()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在相同巡检点!");
        }
        for (YwLinePoint ywLinePoint:ywLinePointList) {
            if(Objects.isNull(ywLinePoint)
                    || Objects.isNull(ywLinePoint.getPointId())
@@ -117,13 +135,23 @@
            ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"巡检点配置错误");
            }
            ywLinePoint.setLineId(ywLinePoint.getId());
            ywLinePoint.setId(null);
            ywLinePoint.setLineId(ywPatrolLine.getId());
            ywLinePoint.setCreateDate(new Date());
            ywLinePoint.setCreator(loginUserInfo.getId());
            ywLinePoint.setIsdeleted(Constants.ZERO);
        }
        ywLinePointMapper.insert(ywLinePointList);
    }
    @Override
    public void updateStatusById(YwPatrolLine ywPatrolLine) {
        YwPatrolLine model = new YwPatrolLine();
        model.setId(ywPatrolLine.getId());
        model.setStatus(ywPatrolLine.getStatus());
        ywPatrolLineMapper.updateById(model);
    }
    @Override
    public void updateByIdInBatch(List<YwPatrolLine> ywPatrolLines) {
@@ -148,7 +176,8 @@
        List<YwLinePoint> ywLinePointList = ywLinePointMapper.selectJoinList(YwLinePoint.class,new MPJLambdaWrapper<YwLinePoint>()
                .selectAll(YwLinePoint.class)
                .selectAs(YwPatrolPoint::getName,YwLinePoint::getPointName)
                .leftJoin(YwPatrolLine.class,YwPatrolLine::getId,YwLinePoint::getPointId)
                .selectAs(YwPatrolPoint::getCode,YwLinePoint::getCode)
                .leftJoin(YwPatrolPoint.class,YwPatrolPoint::getId,YwLinePoint::getPointId)
                .eq(YwLinePoint::getLineId,id)
                .orderByAsc(YwLinePoint::getSortnum)
        );
@@ -178,7 +207,7 @@
        Utils.MP.blankToNull(pageWrap.getModel());
        YwPatrolLine model = pageWrap.getModel();
        queryWrapper.selectAll(YwPatrolLine.class)
                .select(" ( select count(1) from  yw_line_point y where y.LINE_ID = yw_patrol_line.id ) as lineAmount ")
                .select(" ( select count(1) from  yw_line_point y where y.LINE_ID = t.id ) as lineAmount ")
                .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getName()),YwPatrolLine::getName,model.getName())
                .eq(YwPatrolLine::getIsdeleted,Constants.ZERO)
                .orderByDesc(YwPatrolLine::getCreateDate)