renkang
2024-12-03 b81c72d58016bb15d2d47331da258e621245cfb5
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())
@@ -77,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);
    }
@@ -111,6 +122,11 @@
                .eq(YwLinePoint::getLineId,ywPatrolLine.getId()));
        //循环处理 子集数据
        List<YwLinePoint> ywLinePointList = ywPatrolLine.getLinePointList();
        //是否存在相同数据
        Set<Integer> setIds = new HashSet<Integer>(ywLinePointList.stream().map(i->i.getLineId()).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())
@@ -128,6 +144,15 @@
    }
    @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) {
        if (CollectionUtils.isEmpty(ywPatrolLines)) {
            return;