|
@@ -129,6 +129,9 @@ public class ExternalDataArchiveTreeService {
|
|
|
// 获取本地存储的合同数据
|
|
|
List<ArchiveTreeContract> localContracts = getLocalContracts(projectId,outIds);
|
|
|
|
|
|
+ //把本地的也加进去,一般用不到作为冗余手段
|
|
|
+ updateExternalDataMapping(externalDataInfo,localContracts);
|
|
|
+
|
|
|
// 比对差异获取需新增/更新的合同
|
|
|
getAddAndUpdateContracts(
|
|
|
externalDataInfo,
|
|
@@ -159,7 +162,10 @@ public class ExternalDataArchiveTreeService {
|
|
|
*/
|
|
|
private List<ArchiveTreeContract> getLocalContracts(Long projectId, List<String> outIds) {
|
|
|
|
|
|
- List<ArchiveTreeContract> localContracts = autoMapper.getOutNodesByOutIds(projectId,outIds);
|
|
|
+ List<ArchiveTreeContract> localContracts = new ArrayList<>();
|
|
|
+ if (outIds!=null && outIds.size() > 0) {
|
|
|
+ localContracts = autoMapper.getOutNodesByOutIds(projectId,outIds);
|
|
|
+ }
|
|
|
//List<ArchiveTreeContract> localContracts = archiveTreeContractClient.getOutNodesByOutIds(projectId,outIds);
|
|
|
return localContracts;
|
|
|
}
|
|
@@ -224,6 +230,31 @@ public class ExternalDataArchiveTreeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void updateExternalDataMapping(ExternalDataInfo externalDataInfo, List<ArchiveTreeContract> localContracts) {
|
|
|
+ if (localContracts == null || localContracts.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Long> idMapping = externalDataInfo.getArchiveTreeNodeIdMapping();
|
|
|
+
|
|
|
+ for (ArchiveTreeContract contract : localContracts) {
|
|
|
+ String outId = contract.getOutId();
|
|
|
+ Long localId = contract.getId();
|
|
|
+
|
|
|
+ // 空值防御
|
|
|
+ if (outId == null || localId == null) {
|
|
|
+ continue; // 可改为日志输出或抛自定义异常
|
|
|
+ }
|
|
|
+
|
|
|
+ // 线程安全操作(如果存在并发场景)
|
|
|
+ synchronized (idMapping) {
|
|
|
+ if (!idMapping.containsKey(outId)) {
|
|
|
+ idMapping.put(outId, localId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|