Browse Source

德飞试验对接

cr 1 tháng trước cách đây
mục cha
commit
2ee3f8622d

+ 11 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialClassificationTreeController.java

@@ -105,8 +105,12 @@ public class TrialClassificationTreeController extends BladeController {
 	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "新增", notes = "传入trialClassificationTree")
 	public R save(@Valid @RequestBody TrialClassificationTreeDTO1 dto) {
+		Boolean flag=false;
 		if(dto.getGroupType()!=null&&dto.getGroupType()==1){
-			trialClassificationTreeService.deleteByGroupType(dto.getGroupType());
+			if(dto.getList().size()>1){
+				trialClassificationTreeService.deleteByGroupType(dto.getGroupType());
+				flag=true;
+			}
 		}
 		// 假设您有一个 List<TrialClassificationTreeDTO> list
 		Map<Long, Long> map = dto.getList().stream()
@@ -125,7 +129,7 @@ public class TrialClassificationTreeController extends BladeController {
 				classificationAncestors.append( ",").append(parentId);
 			}
 			while (parentId!=null&&parentId!=0){
-				parentId = selectAncestors(parentId,map);
+				parentId = selectAncestors(parentId,map,flag);
 				if(parentId!=null&&parentId!=0){
 					classificationAncestors.append(",").append(parentId);
 				}
@@ -137,7 +141,7 @@ public class TrialClassificationTreeController extends BladeController {
 		return R.status(trialClassificationTreeService.saveBatch(insertList));
 	}
 
-	public Long selectAncestors(Long parentId,Map<Long, Long> map) {
+	public Long selectAncestors(Long parentId,Map<Long, Long> map,Boolean flag) {
 		if(parentId==0){
 			return null;
 		}
@@ -145,6 +149,10 @@ public class TrialClassificationTreeController extends BladeController {
 			if(map.get(parentId)!=null){
 				return map.get(parentId);
 			}
+		}else {
+			if(!flag){
+				return trialClassificationTreeService.selectAncestors(parentId);
+			}
 		}
 		return null;
 	}