From 9ce28811e94fa042adb7cabe6581b0393c6d576d Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 09 十二月 2024 18:17:11 +0800
Subject: [PATCH] ll
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 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 51e298f..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())
@@ -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);
}
@@ -95,6 +106,7 @@
}
@Override
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
public void updateById(YwPatrolLine ywPatrolLine) {
if(Objects.isNull(ywPatrolLine)
|| StringUtils.isBlank(ywPatrolLine.getName())
@@ -111,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())
@@ -128,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