From a2299a6d4a6f99e9c11132138f5d3e9ec68f03ea Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期五, 06 六月 2025 19:19:34 +0800 Subject: [PATCH] 开发更新 --- server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java index 54dea5a..a40d68f 100644 --- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java +++ b/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; /** * 杩愮淮宸℃璺嚎淇℃伅琛⊿ervice瀹炵幇 @@ -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,6 +71,7 @@ ){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"宸℃鐐归厤缃敊璇�"); } + ywLinePoint.setId(null); ywLinePoint.setCreateDate(new Date()); ywLinePoint.setCreator(loginUserInfo.getId()); ywLinePoint.setIsdeleted(Constants.ZERO); @@ -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,6 +135,7 @@ ){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"宸℃鐐归厤缃敊璇�"); } + ywLinePoint.setId(null); ywLinePoint.setLineId(ywPatrolLine.getId()); ywLinePoint.setCreateDate(new Date()); ywLinePoint.setCreator(loginUserInfo.getId()); @@ -126,6 +145,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; -- Gitblit v1.9.3