Răsfoiți Sursa

档案优化需求

chenr 3 luni în urmă
părinte
comite
b86e27c51c

+ 19 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/vo/ArchivesAutoVO4.java

@@ -0,0 +1,19 @@
+package org.springblade.archive.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.springblade.archive.entity.ArchivesAuto;
+
+@Data
+@EqualsAndHashCode
+@NoArgsConstructor
+@AllArgsConstructor
+public class ArchivesAutoVO4{
+    private Long id;
+    private String fileNumber;
+    private Long nodeId;
+    private Long parentId;
+    private String fileNumberPrefix;
+}

+ 2 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/ArchiveFile.java

@@ -328,6 +328,8 @@ public class ArchiveFile extends BaseEntity {
     private String outId;
 
     private String sortNum;
+    @ApiModelProperty("是否锁定 1已锁定")
+    private Integer isLock;
 
     public void fromExternal(ArchiveFileVo vo) {
         if (vo == null) {

+ 2 - 2
blade-service/blade-archive/pom.xml

@@ -173,7 +173,7 @@
                     <target>${java.version}</target>
                     <encoding>${project.build.sourceEncoding}</encoding>
                     <compilerArguments>
-                        <bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar:${java.home}/lib/jsse.jar
+                        <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar;${java.home}/lib/jsse.jar
                         </bootclasspath>
                     </compilerArguments>
                 </configuration>
@@ -181,4 +181,4 @@
         </plugins>
     </build>
 
-</project>
+</project>

+ 30 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java

@@ -63,6 +63,7 @@ import org.springblade.manager.vo.MyInspectTreeVO;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -106,6 +107,8 @@ public class ArchivesAutoController extends BladeController {
 	private ExecutorService executorService;
 	@Autowired
 	private ITraceLogService iTraceLogService;
+
+    private final JdbcTemplate jdbcTemplate;
 	/**
 	 * 详情
 	 */
@@ -152,6 +155,22 @@ public class ArchivesAutoController extends BladeController {
 		return R.data(pages);
 	}
 
+    @GetMapping("/fileNumberFlush")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "档号整理——按档号排序")
+    public R fileNumberFlush(Long projectId,Long contractId,String nodeId,Integer isArchive){
+        List<ArchiveTreeContract> archiveTreeContracts = this.archiveTreeContractClient.queryAllChildByAncestors(nodeId,contractId);
+        List<String> ids = new ArrayList<>();
+        if(archiveTreeContracts != null && archiveTreeContracts.size() > 0){
+            ids=JSONArray.parseArray(JSONObject.toJSONString(archiveTreeContracts.stream().map(ArchiveTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
+        }
+        ids.add(nodeId);
+        archivesAutoService.fileNumberFlush(projectId,contractId,ids,isArchive);
+        return R.success("正在重置题名中,请稍后刷新");
+    }
+
+
+
 
 
 	/**
@@ -391,13 +410,15 @@ public class ArchivesAutoController extends BladeController {
 	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "锁定", notes = "传入ids")
 	public R lock(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
-
 		List<ArchivesAuto> archivesAutos = archivesAutoService.listByIds(Func.toLongList(ids));
 		for (ArchivesAuto ar  :archivesAutos) {
 			ar.setIsLock(1);
+            String sql="update u_archive_file set is_lock=1 where archive_id="+ar.getId()+" and is_deleted=0";
+            jdbcTemplate.update(sql);
 		}
+        archivesAutoService.updateBatchById(archivesAutos);
 
-		return R.status(archivesAutoService.updateBatchById(archivesAutos));
+		return R.status(true);
 	}
 
 	/**
@@ -961,5 +982,12 @@ public class ArchivesAutoController extends BladeController {
 		return R.data(iPage);
 	}
 
+    @GetMapping("/reBuildArchiveFrontPdfs")
+    @ApiOperationSupport(order = 41)
+    @ApiModelProperty(value = "重新生成档案四要素")
+    public R reBuildArchiveFrontPdfs(String archiveIds,Long projectId){
+        return R.status(archivesAutoService.reBuildArchiveFrontPdfs(archiveIds,projectId));
+    }
+
 
 }

+ 4 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.java

@@ -225,5 +225,8 @@ public interface ArchivesAutoMapper extends BaseMapper<ArchivesAuto> {
 	 */
 	Map<String, BigDecimal> getAllArchiveByContractTypeSummary(@Param("projectId") Long projectId,@Param("type") String typ);
 
-	String getArchiveFileByParentId(@Param("nodeId") String nodeId,@Param("contractId") String contractId);
+    List<ArchivesAutoVO4> selectAllArchiveAuto(@Param("projectId")Long projectId, @Param("contractId") Long contractId, @Param("nodeIds") List<String> nodeIds,@Param("isArchive")Integer isArchive);
+
+
+    String getArchiveFileByParentId(@Param("nodeId") String nodeId,@Param("contractId") String contractId);
 }

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

@@ -1418,10 +1418,23 @@
            AND uaa.is_destroy = #{type}
         )a
     </select>
-
+    <select id="selectAllArchiveAuto" resultType="org.springblade.archive.vo.ArchivesAutoVO4">
+        select uaa.id ,uaa.file_number,uaa.node_id,uatc.parent_Id,uatc.file_number_prefix from u_archives_auto uaa left join m_archive_tree_contract uatc on uaa.node_id=uatc.id where uaa.is_deleted = 0 and uaa.project_id=#{projectId}
+        <choose>
+            <when test="isArchive != null and isArchive != ''">
+                and uaa.is_archive = #{isArchive}
+            </when>
+            <otherwise>
+                and (uaa.is_archive is null or uaa.is_archive != 1)
+            </otherwise>
+        </choose>
+        and uaa.node_id in
+        <foreach collection="nodeIds" item="nodeId" open="(" separator="," close=")">
+            #{nodeId}
+        </foreach>
+        ORDER BY uaa.auto_file_sort Asc
+    </select>
     <select id="getArchiveFileByParentId" resultType="java.lang.String">
         SELECT b.id from m_archive_tree a ,m_archive_tree_contract b where a.id=b.from_id and a.id=#{nodeId} and contract_id=#{contractId} and a.is_deleted=0 and b.is_deleted=0
     </select>
-
-
 </mapper>

+ 4 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchivesAutoService.java

@@ -155,5 +155,9 @@ public interface IArchivesAutoService extends BaseService<ArchivesAuto> {
 
     List<JiLinArchiveAutoDto> getArchiveAutoDtoList(Long projId, List<JiLinQueryDto>dtos);
 
+    void fileNumberFlush(Long projectId, Long contractId, List<String> nodeIds,Integer isArchive);
+
+    boolean reBuildArchiveFrontPdfs(String archiveIds, Long projectId);
+
 	R sendFileToEArchives(ArchiveDataVo dataInfo);
 }

+ 66 - 100
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -73,6 +73,7 @@ import org.springblade.system.entity.DictBiz;
 import org.springblade.system.feign.IDictBizClient;
 import org.springblade.system.user.entity.User;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
@@ -376,90 +377,6 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		} else {
 			vo.setPageNumber(0);
 		}
-		String outUrl = vo.getOutUrl();
-		if (StringUtils.isNotBlank(outUrl)) {
-			// 根据 factorType 字符串生成档案号码字符串链表
-			ArchiveProjectConfig config = archiveProjectConfigService.getByProjectIdOrNew(vo.getProjectId());
-			String[] frontUrls = outUrl.split(",");
-			ArchivesAutoVO.ApprovalFile front = new ArchivesAutoVO.ApprovalFile();
-			ArchivesAutoVO.ApprovalFile cataLog = new ArchivesAutoVO.ApprovalFile();
-			ArchivesAutoVO.ApprovalFile spare = new ArchivesAutoVO.ApprovalFile();
-			ArchivesAutoVO.ApprovalFile back = new ArchivesAutoVO.ApprovalFile();
-			for (String frontUrl : frontUrls) {
-				// 封面(原r_Archives_front)增加中文"封面"匹配
-				if ((frontUrl.contains(ArchiveAutoPdfServiceImpl.ARCHIVE_NUMBER[0])
-						|| frontUrl.contains("封面"))
-						&& config.getFactorType().contains("1")) {
-					front.setFileName("封面");
-					if(frontUrl.contains("@@@")){
-						front.setFileUrl(frontUrl.substring(0,frontUrl.indexOf("@@@")));
-					}else {
-						front.setFileUrl(frontUrl);
-					}
-				}
-				// 卷内目录(原r_Archives_catalog)增加中文匹配
-				else if ((frontUrl.contains(ArchiveAutoPdfServiceImpl.ARCHIVE_NUMBER[1])
-						|| frontUrl.contains("卷内目录"))
-						&& config.getFactorType().contains("2")) {
-					cataLog.setFileName("卷内目录");
-					if(frontUrl.contains("@@@")){
-						cataLog.setFileUrl(frontUrl.substring(0,frontUrl.indexOf("@@@")));
-					}else {
-						cataLog.setFileUrl(frontUrl);
-					}
-				}
-				// 备考表(原r_Archives_spare)增加中文匹配
-				else if ((frontUrl.contains(ArchiveAutoPdfServiceImpl.ARCHIVE_NUMBER[2])
-						|| frontUrl.contains("备考表"))
-						&& config.getFactorType().contains("3")) {
-					spare.setFileName("备考表");
-					if(frontUrl.contains("@@@")){
-						spare.setFileUrl(frontUrl.substring(0,frontUrl.indexOf("@@@")));
-					}else {
-						spare.setFileUrl(frontUrl);
-					}
-				}
-				// 背脊(原r_Archives_back)增加中文匹配
-				else if ((frontUrl.contains(ArchiveAutoPdfServiceImpl.ARCHIVE_NUMBER[3])
-						|| frontUrl.contains("背脊"))
-						&& config.getFactorType().contains("4")) {
-					back.setFileName("背脊");
-					if(frontUrl.contains("@@@")){
-						back.setFileUrl(frontUrl.substring(0,frontUrl.indexOf("@@@")));
-					}else {
-						back.setFileUrl(frontUrl);
-					}
-				}
-			}
-			List<ArchivesAutoVO.ApprovalFile> files = vo.getApprovalFileList();
-			if (files != null && !files.isEmpty()) {
-				ArchivesAutoVO.ApprovalFile temp = files.get(0);
-				if (front.getFileUrl() != null) {
-					front.setId(temp.getId() + "_1");
-					front.setPdfFileUrl(front.getFileUrl());
-					files.add(0,front);
-				}
-				if (cataLog.getFileUrl() != null) {
-					cataLog.setId(temp.getId()  + "_2");
-					cataLog.setPdfFileUrl(cataLog.getFileUrl());
-					if (front.getFileUrl() != null) {
-						files.add(1,cataLog);
-					} else {
-						files.add(0,cataLog);
-					}
-				}
-				if (spare.getFileUrl() != null) {
-					spare.setId(temp.getId()  + "_3");
-					spare.setPdfFileUrl(spare.getFileUrl());
-					files.add(spare);
-				}
-				if (back.getFileUrl() != null) {
-					back.setId(temp.getId()  + "_4");
-					back.setPdfFileUrl(back.getFileUrl());
-					files.add(back);
-				}
-			}
-		}
 		return vo;
 	}
 
@@ -1363,23 +1280,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		if (selectList== null || selectList.size() == 0) {
 			return;
 		}
-
-		if (waitArchiveFiles==null || waitArchiveFiles.size()== 0) {
-			return;
-		}
-
-		String strfirstNodeId = waitArchiveFiles.get(0).getNodeId();
-
 		ArchiveTreeContract node = selectList.get(0);
-		if (StringUtils.isNotEmpty(strfirstNodeId)) {
-			Long firstNodeId = Long.parseLong(strfirstNodeId);
-			ArchiveTreeContract firstNode = archiveTreeContractClient.getArchiveTreeContractById(firstNodeId);
-			if (firstNode!= null) {
-				node = firstNode;
-			}
-		}
-
-
 		//获取案卷文件起止时间
 		String archiveStartDateAndEndDate = getArchiveStartDateAndEndDate(waitArchiveFiles);
 		String[] split = archiveStartDateAndEndDate.split(",");
@@ -4104,6 +4005,71 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		return list;
 	}
 
+    @Override
+    @Async
+    public void fileNumberFlush(Long projectId, Long contractId, List<String> nodeIds,Integer isArchive) {
+        ArchiveProjectConfig config = archiveProjectConfigService.getByProjectIdOrNew(projectId);
+        List<ArchivesAutoVO4>list=baseMapper.selectAllArchiveAuto(projectId,contractId,nodeIds,isArchive);
+        if(list!=null && list.size()>0){
+            if(config.getDirType()==null||config.getDirType()==0){
+                List<ArchivesAuto> archivesAutos = setFileNumberByConfig(config, list);
+                this.updateBatchById(archivesAutos);
+            }else {
+                Map<Long, List<ArchivesAutoVO4>> map = list.stream().collect(Collectors.groupingBy(ArchivesAutoVO4::getParentId));
+                for (Map.Entry<Long, List<ArchivesAutoVO4>> entry : map.entrySet()) {
+                    List<ArchivesAutoVO4> value = entry.getValue();
+                    List<ArchivesAuto> archivesAutos = setFileNumberByConfig(config, value);
+                   this.updateBatchById(archivesAutos);
+                }
+            }
+        }
+
+    }
+
+    @Override
+    public boolean reBuildArchiveFrontPdfs(String archiveIds, Long projectId) {
+        if(StringUtils.isEmpty(archiveIds)){
+            return false;
+        }
+        String[] ids = archiveIds.split(",");
+        for (String archiveId : ids) {
+            ArchivesAuto auto = baseMapper.selectById(archiveId);
+            List<ArchiveFile> archiveFiles = archiveFileClient.getArchiveFileByArchiveID(Long.valueOf(archiveId));
+            archiveAutoPdfService.buildArchiveFrontPdfs(projectId,auto,archiveFiles,true);
+            baseMapper.updateById(auto);
+        }
+        return true;
+    }
+
+    public List<ArchivesAuto> setFileNumberByConfig(ArchiveProjectConfig config,List<ArchivesAutoVO4> value){
+        int i=1;
+        List<ArchivesAuto>list=new ArrayList<>();
+        for (ArchivesAutoVO4 v:value) {
+            ArchivesAuto auto = new ArchivesAuto();
+            if(config.getIndexType()==null||config.getIndexType()==0){
+               v.setFileNumber(v.getFileNumberPrefix()+"_"+i);
+           }else {
+               String prefix = v.getFileNumberPrefix();
+               int index = i; // 编号从 1 开始
+               // 获取配置中的编号长度(最多多少位)
+               int numLength = config.getIndexNum();
+               // 默认最多4位,防止过长或无效值
+               if (numLength > 10) { // 限制最大为10位
+                   numLength = 4;
+               }
+               // 使用 %0xd 格式化数字,x 表示总长度
+               String formattedIndex = String.format("%0" + numLength + "d", index);
+               // 设置最终档号
+               v.setFileNumber(prefix + "_" + formattedIndex);
+           }
+            auto.setId(v.getId());
+            auto.setFileNumber(v.getFileNumber());
+            list.add(auto);
+            i++;
+        }
+        return list;
+    }
+
 
 
 

+ 2 - 2
blade-service/blade-e-visa/pom.xml

@@ -334,11 +334,11 @@
                     <target>${java.version}</target>
                     <encoding>${project.build.sourceEncoding}</encoding>
                     <compilerArguments>
-                        <bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar:${java.home}/lib/jsse.jar
+                        <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar;${java.home}/lib/jsse.jar
                         </bootclasspath>
                     </compilerArguments>
                 </configuration>
             </plugin>
         </plugins>
     </build>
-</project>
+</project>

+ 3 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeContractController.java

@@ -101,13 +101,13 @@ public class ArchiveTreeContractController extends BladeController {
         }
         String sql="select * from m_contract_info where id="+contractId1;
         ContractInfo info = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(ContractInfo.class));
-        if(detail.getRollor()==null&&info!=null&&info.getFiler()!=null){
+        if(StringUtils.isEmpty(detail.getRollor())&&info!=null&&info.getFiler()!=null){
             detail.setRollor(info.getFiler());
         }
-        if(detail.getReviewer()==null&&info!=null&&info.getReviewer()!=null){
+        if(StringUtils.isEmpty(detail.getReviewer())&&info!=null&&info.getReviewer()!=null){
             detail.setReviewer(info.getReviewer());
         }
-        if(detail.getFileNumberPrefix()==null&&info!=null&&info.getPrefix()!=null){
+        if(StringUtils.isEmpty(detail.getFileNumberPrefix())&&info!=null&&info.getPrefix()!=null){
             detail.setFileNumberPrefix(info.getPrefix());
         }
         return R.data(detail);