|
@@ -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;
|
|
|
}
|