|
@@ -1,5 +1,7 @@
|
|
package org.springblade.manager.feign;
|
|
package org.springblade.manager.feign;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.springblade.archive.dto.JiLinQueryDto;
|
|
import org.springblade.archive.dto.JiLinQueryDto;
|
|
@@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.function.Function;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
@@ -166,10 +170,54 @@ public class ArchiveTreeContractImpl implements ArchiveTreeContractClient {
|
|
return archiveTreeContractMapper.getOutNodesByOutIds(projectId,outIds);
|
|
return archiveTreeContractMapper.getOutNodesByOutIds(projectId,outIds);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// @Override
|
|
|
|
+// public void updateArchiveTreeContract(List<ArchiveTreeContract> archiveTreeContracts) {
|
|
|
|
+// archiveTreeContractService.updateBatchById(archiveTreeContracts);
|
|
|
|
+// }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void updateArchiveTreeContract(List<ArchiveTreeContract> archiveTreeContracts) {
|
|
public void updateArchiveTreeContract(List<ArchiveTreeContract> archiveTreeContracts) {
|
|
- archiveTreeContractService.updateBatchById(archiveTreeContracts);
|
|
|
|
|
|
+ // 1. 提取传入合同列表中的所有ID(过滤空值)
|
|
|
|
+ List<Long> ids = archiveTreeContracts.stream()
|
|
|
|
+ .map(ArchiveTreeContract::getId)
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (ids.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 2. 根据ID批量查询现有记录
|
|
|
|
+ LambdaQueryWrapper<ArchiveTreeContract> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ wrapper.in(ArchiveTreeContract::getId, ids);
|
|
|
|
+ List<ArchiveTreeContract> existContracts = archiveTreeContractService.list(wrapper);
|
|
|
|
+
|
|
|
|
+ // 3. 将传入合同列表转换为Map<ID, 合同对象>便于查找
|
|
|
|
+ Map<Long, ArchiveTreeContract> externalContractMap = archiveTreeContracts.stream()
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
+ ArchiveTreeContract::getId,
|
|
|
|
+ Function.identity(),
|
|
|
|
+ (existing, replacement) -> existing // 处理重复ID,保留第一个
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ // 4. 准备更新列表 - 只更新ext_node_type字段
|
|
|
|
+ List<ArchiveTreeContract> updateList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (ArchiveTreeContract local : existContracts) {
|
|
|
|
+ ArchiveTreeContract external = externalContractMap.get(local.getId());
|
|
|
|
+ if (external != null) {
|
|
|
|
+ // 只更新ext_node_type字段
|
|
|
|
+ local.setExtNodeType(external.getExtNodeType());
|
|
|
|
+ updateList.add(local);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 5. 批量更新(建议分批处理,如每500条一次)
|
|
|
|
+ if (!updateList.isEmpty()) {
|
|
|
|
+ archiveTreeContractService.updateBatchById(updateList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void addArchiveTreeContract(@RequestBody List<ArchiveTreeContract> archiveTreeContracts, @RequestParam Long rootId){
|
|
public void addArchiveTreeContract(@RequestBody List<ArchiveTreeContract> archiveTreeContracts, @RequestParam Long rootId){
|
|
// archiveTreeContractService.saveBatch(archiveTreeContracts);
|
|
// archiveTreeContractService.saveBatch(archiveTreeContracts);
|