| | |
| | | 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; |
| | |
| | | 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实现 |
| | |
| | | @Autowired |
| | | private YwLinePointMapper ywLinePointMapper; |
| | | |
| | | @Autowired |
| | | private YwPatrolSchemeMapper ywPatrolSchemeMapper; |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public Integer create(YwPatrolLine ywPatrolLine) { |
| | |
| | | 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()) |
| | |
| | | ){ |
| | | 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(); |
| | |
| | | |
| | | @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); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void updateById(YwPatrolLine ywPatrolLine) { |
| | | if(Objects.isNull(ywPatrolLine) |
| | | || StringUtils.isBlank(ywPatrolLine.getName()) |
| | |
| | | .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()) |
| | |
| | | ){ |
| | | 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) { |
| | |
| | | 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) |
| | | ); |
| | |
| | | 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) |