Selaa lähdekoodia

获取归档模板

huangtf 8 kuukautta sitten
vanhempi
commit
b211249bb6

+ 5 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClient.java

@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.servlet.http.HttpServletRequest;
 
+import java.util.List;
+
 import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX;
 
 @FeignClient(value = APPLICATION_NAME_PREFIX + "manager", fallback = ExcelTabClientFallBack.class)
@@ -56,4 +58,7 @@ public interface ExcelTabClient {
                  @RequestParam String projectId,
                  @RequestHeader("Blade-Auth") String header) throws Exception;
 
+    @PostMapping(API_PREFIX + "/getArchiveTabList")
+    List<ExcelTab> getArchiveTabList();
+
 }

+ 6 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClientFallBack.java

@@ -10,6 +10,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 @Component
 public class ExcelTabClientFallBack implements ExcelTabClient {
@@ -46,4 +47,9 @@ public class ExcelTabClientFallBack implements ExcelTabClient {
         return null;
     }
 
+    @Override
+    public List<ExcelTab> getArchiveTabList(){
+        return null;
+    }
+
 }

+ 2 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchiveAutoPdfService.java

@@ -35,4 +35,6 @@ public interface IArchiveAutoPdfService {
 
     String upFile(InputStream inputStream, Long projectId);
 
+    public void assignArchiveTableUrl();
+
 }

+ 33 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -29,6 +29,8 @@ import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.manager.entity.ExcelTab;
+import org.springblade.manager.feign.ExcelTabClient;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.stereotype.Service;
@@ -43,6 +45,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -57,6 +60,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     private ArchiveFileClient archiveFileClient;
 
+    private final ExcelTabClient excelTabClient;
+
     public static final String[] ARCHIVE_NUMBER = new String[]{"r_Archives_front", "r_Archives_catalog", "r_Archives_spare", "r_Archives_back"};
 
     public static final Map<String, String> URL_MAP = new HashMap<>();
@@ -138,6 +143,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         Long projectId = 1578599210897772545L;
 
+        List<ExcelTab> excelTabList = excelTabClient.getArchiveTabList();
+
         ArchivesAuto archivesAuto = new ArchivesAuto();
         archivesAuto.setId(SnowFlakeUtil.getId());
         archivesAuto.setProjectId(projectId);
@@ -965,5 +972,31 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         return url;
     }
 
+    public void assignFileUrlsToUrlMap(List<ExcelTab> excelTabList) {
+
+        Map<String, String> invertedNameMap = NAME_MAP.entrySet()
+                .stream()
+                .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
+
+        for (ExcelTab tab : excelTabList) {
+            // Find the corresponding key in the inverted map by the tab's name
+            String key = invertedNameMap.get(tab.getName());
+            if (key != null) {
+                if (StringUtils.isNotEmpty(tab.getFileUrl())) {
+                    URL_MAP.put(key, tab.getFileUrl());
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 从数据库读取最新的清表
+     */
+    public void assignArchiveTableUrl() {
+        List<ExcelTab> excelTabList = excelTabClient.getArchiveTabList();
+        assignFileUrlsToUrlMap(excelTabList);
+    }
+
 
 }

+ 9 - 3
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -964,7 +964,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		//获取立卷单位
 		String unit = "";
 		String treeCode = node.getTreeCode();
-		if (StringUtils.isEmpty(treeCode)) {
+		if (StringUtils.isEmpty(treeCode) || treeCode.equals("null")) {
 			//treeCode为null的是业主的节点
 			List<ContractInfo> contractInfos = contractClient.getContractListByProjectId(node.getProjectId());
 			for (ContractInfo contract : contractInfos) {
@@ -978,7 +978,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 			unit = contract.archivesUnit();
 		}
 		//获取档号
-		if (StringUtils.isEmpty(treeCode)) {
+		if (StringUtils.isEmpty(treeCode) || treeCode.equals("null")) {
 			treeCode = "owner";
 		}
 		//String fileNumberPrefix=node.getFileNumberPrefix(); //档号前缀在节点设置
@@ -2395,7 +2395,9 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 				//业主合同段时treeCode为空串
 				if (StringUtils.isNotEmpty(nodeId)) {
 					//如果还选择了节点
-					if (StringUtils.isNotEmpty(contract.getAncestors()) && contract.getAncestors().contains(nodeId)) {
+					if ((StringUtils.isNotEmpty(contract.getAncestors()) && contract.getAncestors().contains(nodeId))
+						|| contract.getId().toString().equals(nodeId))
+					{
 						result.add(contract);
 					}
 				} else {
@@ -2457,6 +2459,8 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 				//log.info(startAutoArchiveMsg);
 				iTraceLogService.saveLog(traceId, startAutoArchiveMsg);
 
+				archiveAutoPdfService.assignArchiveTableUrl();
+
 				archiveAutoMethod(projectId, contractId, nodeId, traceId);
 				// 设置完成度80%
 				contractClient.updateIsArchivesAutoById(contractId, 80);
@@ -2504,6 +2508,8 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 				// 设置完成度10%
 				contractClient.updateIsArchivesAutoById(contractId, 10);
 
+				archiveAutoPdfService.assignArchiveTableUrl();
+
 				// 项目自动组卷入口
 				this.refreshFileNumberNoSlipt(projectId, contractId, null, false, traceId);
 

+ 4 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -130,6 +130,10 @@ public class ExcelTabClientImpl implements ExcelTabClient {
     public R synPDFInfo(String contractId, String nodeIds, String classify, String projectId, String authorization) throws Exception {
         return excelTabController.synPDFInfo(contractId, nodeIds, classify, projectId);
     }
+    @Override
+    public List<ExcelTab> getArchiveTabList(){
+        return excelTabService.getListByParentName("档案");
+    }
 
 
 }

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IExcelTabService.java

@@ -186,4 +186,6 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
 
 
     String createFileTitle(WbsTreeContract wbsTreeContract);
+
+    List<ExcelTab> getListByParentName(String parentName);
 }

+ 23 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -3651,4 +3651,27 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         IoUtil.closeQuietly(exceInp);
     }
 
+    /**
+     *
+     * @param parentName
+     * @return
+     */
+    @Override
+    public List<ExcelTab> getListByParentName(String parentName) {
+        List<ExcelTab> excelTabs = new ArrayList<>();
+
+
+        //获取name为parentName的ExcelTab,并且is_deleted字段为0
+        excelTabs = this.list(new QueryWrapper<ExcelTab>().eq("name", parentName).eq("file_type", 1).eq("is_deleted", 0));
+
+        //如果不为空,则取第一个作为父节点,查询出parent_id为该父节点id的的 ExcelTab
+        if (!excelTabs.isEmpty()) {
+            ExcelTab excelTab = excelTabs.get(0);
+            excelTabs = this.list(new QueryWrapper<ExcelTab>().eq("parent_id", excelTab.getId()).eq("is_deleted", 0));
+        }
+
+        return excelTabs;
+    }
+
+
 }