Browse Source

德飞试验对接

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

+ 8 - 2
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialClassificationTreeDTO.java

@@ -30,14 +30,20 @@ import lombok.EqualsAndHashCode;
 public class TrialClassificationTreeDTO {
 	private static final long serialVersionUID = 1L;
 
-	private Long dfId;
 
-	private Long projectId;
+	private Long id;
+
 	/**
 	 * 父级ID
 	 */
 	private Long parentId;
 
+	/**
+	 * 项目ID
+	 */
+
+	private Long projectId;
+
 	/**
 	 * 分类名称
 	 */

+ 11 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialClassificationTreeDTO1.java

@@ -0,0 +1,11 @@
+package org.springblade.business.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TrialClassificationTreeDTO1 {
+   private List<TrialClassificationTreeDTO> list;
+   private Integer groupType;
+}

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialClassificationTree.java

@@ -39,7 +39,7 @@ public class TrialClassificationTree extends BaseEntity {
 	*/
 	private Long id;
 
-	private Long dfId;
+
 
 	private Long projectId;
 	/**

+ 30 - 16
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialClassificationTreeController.java

@@ -26,6 +26,7 @@ import lombok.AllArgsConstructor;
 import javax.validation.Valid;
 
 import org.springblade.business.dto.TrialClassificationTreeDTO;
+import org.springblade.business.dto.TrialClassificationTreeDTO1;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Condition;
@@ -43,6 +44,9 @@ import org.springblade.core.boot.ctrl.BladeController;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * 德飞试验系统检测分类树 控制器
@@ -100,15 +104,20 @@ public class TrialClassificationTreeController extends BladeController {
 	@PostMapping("/save")
 	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "新增", notes = "传入trialClassificationTree")
-	public R save(@Valid @RequestBody List<TrialClassificationTreeDTO> list,Integer groupType) {
-		if(groupType!=null&&groupType==1){
-			trialClassificationTreeService.update(new UpdateWrapper<TrialClassificationTree>().set("is_deleted", 1).eq("group_type",1));
+	public R save(@Valid @RequestBody TrialClassificationTreeDTO1 dto) {
+		if(dto.getGroupType()!=null&&dto.getGroupType()==1){
+			trialClassificationTreeService.deleteByGroupType(dto.getGroupType());
 		}
+		// 假设您有一个 List<TrialClassificationTreeDTO> list
+		Map<Long, Long> map = dto.getList().stream()
+				.collect(Collectors.toMap(
+						TrialClassificationTreeDTO::getId, // 按 parentId 分组
+						TrialClassificationTreeDTO::getParentId // 收集每个分组的 id 列表
+				));
 		List<TrialClassificationTree>insertList=new ArrayList<>();
-		for (TrialClassificationTreeDTO trialClassificationTreeDTO : list) {
+		for (TrialClassificationTreeDTO trialClassificationTreeDTO : dto.getList()) {
 			TrialClassificationTree trialClassificationTree = new TrialClassificationTree();
 			BeanUtil.copy(trialClassificationTreeDTO, trialClassificationTree);
-			trialClassificationTree.setId(SnowFlakeUtil.getId());
 			Long parentId = trialClassificationTree.getParentId();
 			StringBuilder classificationAncestors = new StringBuilder();
 			classificationAncestors.append(trialClassificationTree.getId());
@@ -116,23 +125,30 @@ public class TrialClassificationTreeController extends BladeController {
 				classificationAncestors.append( ",").append(parentId);
 			}
 			while (parentId!=null&&parentId!=0){
-				parentId = selectAncestors(parentId);
+				parentId = selectAncestors(parentId,map);
 				if(parentId!=null&&parentId!=0){
-					classificationAncestors.append(parentId).append(",");
+					classificationAncestors.append(",").append(parentId);
 				}
 			}
 			trialClassificationTree.setClassificationAncestors(classificationAncestors.toString());
-			trialClassificationTree.setGroupType(groupType);
+			trialClassificationTree.setGroupType(dto.getGroupType());
 			insertList.add(trialClassificationTree);
 		}
-		return R.status(trialClassificationTreeService.saveOrUpdateBatch(insertList));
+		return R.status(trialClassificationTreeService.saveBatch(insertList));
 	}
 
-	public Long selectAncestors(Long parentId) {
+	public Long selectAncestors(Long parentId,Map<Long, Long> map) {
 		if(parentId==0){
 			return null;
 		}
-		return trialClassificationTreeService.selectAncestors(parentId);
+		if(map.containsKey(parentId)){
+			if(map.get(parentId)!=null){
+				return map.get(parentId);
+			}
+		}else {
+			return trialClassificationTreeService.selectAncestors(parentId);
+		}
+		return null;
 	}
 
 	/**
@@ -141,8 +157,8 @@ public class TrialClassificationTreeController extends BladeController {
 	@PostMapping("/update")
 	@ApiOperationSupport(order = 5)
 	@ApiOperation(value = "修改", notes = "传入trialClassificationTree")
-	public R update(Long dfId,String classificationName) {
-		if(dfId==null){
+	public R update(Long id,String classificationName) {
+		if(id==null){
 			return R.fail("请选择要修改的分类");
 		}
 		if(Func.isEmpty(classificationName)){
@@ -150,7 +166,7 @@ public class TrialClassificationTreeController extends BladeController {
 		}
 		TrialClassificationTree trialClassificationTree = new TrialClassificationTree();
 		trialClassificationTree.setClassificationName(classificationName);
-		return R.status(trialClassificationTreeService.update(new UpdateWrapper<TrialClassificationTree>().set("classification_name", classificationName).eq("df_id", dfId)));
+		return R.status(trialClassificationTreeService.update(new UpdateWrapper<TrialClassificationTree>().set("classification_name", classificationName).eq("id", id)));
 	}
 
 //	/**
@@ -182,6 +198,4 @@ public class TrialClassificationTreeController extends BladeController {
 		boolean update = trialClassificationTreeService.update(new UpdateWrapper<TrialClassificationTree>().set("is_deleted", 1).in("classification_ancestors", id));
 		return R.status(update);
 	}
-
-	
 }

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

@@ -155,11 +155,11 @@ public class TrialSystemDockingController extends BladeController {
 	@PostMapping("/remove")
 	@ApiOperationSupport(order = 7)
 	@ApiOperation(value = "逻辑删除", notes = "传入ids")
-	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String dfId) {
-		if (Func.isEmpty(dfId)) {
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		if (Func.isEmpty(ids)) {
 			return R.fail("参数错误");
 		}
-		trialSystemDockingService.updatedelete(Func.toLongList(dfId));
+		trialSystemDockingService.updatedelete(Func.toLongList(ids));
 		return R.status(true);
 	}
 

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialClassificationTreeMapper.java

@@ -45,4 +45,6 @@ public interface TrialClassificationTreeMapper extends BaseMapper<TrialClassific
 	Long selectAncestors(Long parentId);
 
     List<TrialClassificationTreeVO> selectAllNode(@Param("id") Long id, @Param("projectId") Long projectId);
+
+	void deleteByGroupType(@Param("groupType") Integer groupType);
 }

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialClassificationTreeMapper.xml

@@ -12,6 +12,9 @@
     <update id="deleteById1">
         update u_trial_classification_tree set is_deleted = 1 where classification_ancestors  like concat('%',#{id},'%')
     </update>
+    <delete id="deleteByGroupType">
+        delete from u_trial_classification_tree where group_type = #{groupType}
+    </delete>
 
 
     <select id="selectTrialClassificationTreePage" resultMap="trialClassificationTreeResultMap">

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialClassificationTreeService.java

@@ -17,6 +17,7 @@
 package org.springblade.business.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.models.auth.In;
 import org.springblade.business.entity.TrialClassificationTree;
 import org.springblade.business.vo.TrialClassificationTreeVO;
 import org.springblade.core.mp.base.BaseService;
@@ -48,4 +49,6 @@ public interface ITrialClassificationTreeService extends BaseService<TrialClassi
 
 
     List<TrialClassificationTreeVO> selectAllNode(Long id, Long projectId);
+
+	void deleteByGroupType(Integer groupType);
 }

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialClassificationTreeServiceImpl.java

@@ -61,5 +61,10 @@ public class TrialClassificationTreeServiceImpl extends BaseServiceImpl<TrialCla
 		return baseMapper.selectAllNode(id,projectId);
 	}
 
+	@Override
+	public void deleteByGroupType(Integer groupType) {
+		baseMapper.deleteByGroupType(groupType);
+	}
+
 
 }

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSystemDockingServiceImpl.java

@@ -100,7 +100,7 @@ public class TrialSystemDockingServiceImpl extends BaseServiceImpl<TrialSystemDo
 		if (longList != null && !longList.isEmpty()) {
 			this.update(new UpdateWrapper<TrialSystemDocking>()
 					.set("is_deleted", 1)
-					.in("de_id", longList));
+					.in("id", longList));
 		}
 	}