huangtf 2 жил өмнө
parent
commit
89f2e59ece

+ 3 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.java

@@ -86,4 +86,7 @@ public interface ArchivesAutoMapper extends BaseMapper<ArchivesAuto> {
 	List<Map<String,String>> getAllArchiveAgeByContractType(@Param("projectId") Long projectId);
 
 	List<String> getFilingUnitList(@Param("projectId") Long projectId);
+
+
+	Integer splitFiles(@Param("ids") List<Long> ids);
 }

+ 9 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -283,4 +283,13 @@
     </select>
 
 
+    <update id="splitFiles" >
+        update u_archive_file set is_archive = 0 ,archive_id = null where
+        id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+
 </mapper>

+ 10 - 23
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -1087,10 +1087,10 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		//排除锁定的和单文件案卷这种
 		List<ArchivesAuto> archivesAutos = this.listByIds(orgIds);
 		for (ArchivesAuto ar: archivesAutos) {
-			if (ar.getIsLock() == 1) {
+			if (ar.getIsLock()!= null && ar.getIsLock() == 1) {
 				continue;
 			}
-			if (ar.getIsAutoFile() == 1) {
+			if (ar.getIsAutoFile()!= null &&  ar.getIsAutoFile() == 1) {
 				continue;
 			}
 			lIds.add(ar.getId());
@@ -1100,12 +1100,11 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		//更新
 		List<ArchiveFile> files = archiveFileClient.getAllArchiveFileByArchiveIds(strIds);
 		if (files != null && files.size() > 0) {
-			for (ArchiveFile f: files) {
-				f.setIsArchive(0);
-				f.setArchiveId(null);
-				LambdaUpdateWrapper<ArchiveFile> wrappers = Wrappers.lambdaUpdate();
-				this.archiveFileClient.updateWrappers(wrappers.eq(ArchiveFile::getId, f.getId()));
-			}
+
+			List<Long> fids = files.stream()
+					.map(ArchiveFile::getId)
+					.collect(Collectors.toList());
+			baseMapper.splitFiles(fids);
 		}
 
 		//删除案卷
@@ -1113,25 +1112,13 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 	}
 
 	/**
-	 * 拆卷
+	 * 从案卷删除文件
 	 * @param ids
 	 * @return
 	 */
 	public  boolean removeFiles(String ids) {
-
-		List<String> list = Arrays.asList(ids.split(","));
-
-		//更新
-		List<ArchiveFile> files = this.archiveFileClient.listWrappers(Wrappers.<ArchiveFile>lambdaQuery().in(ArchiveFile::getId, list));
-		if (files != null && files.size() > 0) {
-			for (ArchiveFile f: files) {
-				f.setIsArchive(0);
-				f.setArchiveId(null);
-				LambdaUpdateWrapper<ArchiveFile> wrappers = Wrappers.lambdaUpdate();
-				this.archiveFileClient.updateWrappers(wrappers.eq(ArchiveFile::getId, f.getId()));
-			}
-		}
-
+		List<Long> fids = Func.toLongList(ids);
+		baseMapper.splitFiles(fids);
 		return true;
 	}