Ver Fonte

档案分卷

cr há 1 dia atrás
pai
commit
a0f3e3aaf1

+ 14 - 6
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -5698,10 +5698,12 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		for (Long archiveId : archiveIds) {
 			ArchivesAuto archivesAuto = this.getById(archiveId);
 			List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(archiveId+"", "");
-			archivesAuto.setFileN(files.size());
-			archivesAuto.setPageN(files.stream().mapToInt(ArchiveFile::getFilePage).sum());
-			archivesAuto.setColourStatus(2);
-			baseMapper.updateById(archivesAuto);
+			if(!files.isEmpty()){
+				archivesAuto.setFileN(files.size());
+				archivesAuto.setPageN(files.stream().mapToInt(ArchiveFile::getFilePage).sum());
+				archivesAuto.setColourStatus(2);
+				baseMapper.updateById(archivesAuto);
+			}
 		}
 		return true;
 	}
@@ -5771,12 +5773,18 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 				}else {
 					auto.setVolumeIds(auto.getVolumeIds().replace(volumeId+",",""));
 				}
-				String update = "UPDATE u_archive_file SET archive_id = ?, old_archive_id = '', is_volume = 0 WHERE archive_id = ?";
+				if(auto.getVolumeIds().startsWith(",")){
+					auto.setVolumeIds(auto.getVolumeIds().substring(1));
+				}
+				if(auto.getVolumeIds().endsWith(",")){
+					auto.setVolumeIds(auto.getVolumeIds().substring(0,auto.getVolumeIds().length()-1));
+				}
+				String update = "UPDATE u_archive_file SET archive_id = ?, old_archive_id = null, is_volume = 0 WHERE archive_id = ?";
 				jdbcTemplate.update(update, archiveId, volumeId);
 			}
 			baseMapper.updateById(auto);
 			this.deleteLogic(Arrays.asList(volumeId));
-			this.updateArchivePage(Arrays.asList(archiveId));
+			this.updateArchivePage(Arrays.asList(archiveId,volumeId));
 		}
 		return true;
 	}