From 35ed9cd31d7b675082425361a9f08bec40aa1292 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 03 十二月 2024 18:23:01 +0800
Subject: [PATCH] ll
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java | 42 +++++++++++++++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 7 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 f5b6603..217d7c4 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,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);
}
@@ -110,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())
@@ -117,13 +134,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 +175,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)
);
--
Gitblit v1.9.3