ソースを参照

档案插卷修改文件节点

lvy 1 日 前
コミット
50f4dc41d4

+ 24 - 5
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java

@@ -1263,20 +1263,39 @@ public class ArchivesAutoController extends BladeController {
 		targetArchiveFileList.addAll(sourceArchiveFileList);
 		Map<Long, ArchiveFile> targetMap = targetArchiveFileList.stream().collect(Collectors.toMap(ArchiveFile::getId, item -> item, (k1, k2) -> k1));
 		Map<Long, ArchiveFile> map = sourceArchiveFileList.stream().collect(Collectors.toMap(ArchiveFile::getId, item -> item));
-		for (String s : split1) {
-			if (StringUtils.isNumeric(s)) {
-				ArchiveFile tempFile = targetMap.get(Long.parseLong(s));
+		for (int i = 0; i < split1.length; i++) {
+			if (StringUtils.isNumeric(split1[i])) {
+				ArchiveFile tempFile = targetMap.get(Long.parseLong(split1[i]));
 				if (tempFile != null) {
 					ArchiveFileVO file = new ArchiveFileVO();
 					file.setId(tempFile.getId());
 					file.setSort(tempFile.getSort());
 					file.setArchiveSort(tempFile.getArchiveSort());
-					file.setNodeId(tempFile.getNodeId());
 					updateArchiveFileList.add(file);
 					if (map.containsKey(file.getId())) {
 						file.setPageNum("");
 						file.setArchiveId(target.getId());
-						file.setNodeId(target.getNodeId() + "");
+						for (int j = i + 1; j < split1.length; j++) {
+							if (StringUtils.isNumeric(split1[j])) {
+								ArchiveFile tempFile1 = targetMap.get(Long.parseLong(split1[j]));
+								if (tempFile1 != null && !map.containsKey(tempFile1.getId())) {
+									file.setNodeId(tempFile1.getNodeId());
+								}
+							}
+						}
+						if (file.getNodeId() == null) {
+							for (int j = i - 1; j >= 0; j--) {
+								if (StringUtils.isNumeric(split1[j])) {
+									ArchiveFile tempFile1 = targetMap.get(Long.parseLong(split1[j]));
+									if (tempFile1 != null && !map.containsKey(tempFile1.getId())) {
+										file.setNodeId(tempFile1.getNodeId());
+									}
+								}
+							}
+						}
+						if (file.getNodeId() == null) {
+							file.setNodeId(target.getNodeId() + "");
+						}
 					}
 				}
 			}