|
@@ -1,5 +1,6 @@
|
|
package org.springblade.manager.service.impl;
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.springblade.business.entity.ArchiveFile;
|
|
import org.springblade.business.entity.ArchiveFile;
|
|
import org.springblade.business.entity.InformationQuery;
|
|
import org.springblade.business.entity.InformationQuery;
|
|
@@ -7,6 +8,7 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.manager.entity.ArchiveTreeContract;
|
|
import org.springblade.manager.entity.ArchiveTreeContract;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.ProjectInfo;
|
|
import org.springblade.manager.entity.ProjectInfo;
|
|
|
|
+import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.manager.mapper.ArchiveTreeContractMapper;
|
|
import org.springblade.manager.mapper.ArchiveTreeContractMapper;
|
|
import org.springblade.manager.service.IContractInfoService;
|
|
import org.springblade.manager.service.IContractInfoService;
|
|
import org.springblade.manager.service.IProjectInfoService;
|
|
import org.springblade.manager.service.IProjectInfoService;
|
|
@@ -33,6 +35,7 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
private final IContractInfoService contractInfoService;
|
|
private final IContractInfoService contractInfoService;
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 普通同步
|
|
* 普通同步
|
|
*
|
|
*
|
|
@@ -222,46 +225,110 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
|
|
|
|
public void syncBusinessData(Long projectId,Long contractId) {
|
|
public void syncBusinessData(Long projectId,Long contractId) {
|
|
- //获取某个合同段所有的电签完成的文件题名,取 id wbsid name,eVisaPdfUrl
|
|
|
|
|
|
+ //新增的文件题名
|
|
|
|
+ List<InformationQuery> newInformationQueryList = new ArrayList<>();
|
|
|
|
+ //新增的文件
|
|
|
|
+ List<ArchiveFile> newArchiveFiles = new ArrayList<>();
|
|
|
|
+ //更新的文件
|
|
|
|
+ List<ArchiveFile> updateArchiveFiles = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //项目信息
|
|
|
|
+ ProjectInfo projectInfo = projectInfoService.getOne(projectId);
|
|
|
|
+
|
|
|
|
+ //项目使用的wbs模板
|
|
|
|
+ Long lWbsId = projectInfo.getReferenceWbsTemplateId();
|
|
|
|
+
|
|
|
|
+ //合同信息
|
|
|
|
+ ContractInfo contractIndfo = contractInfoService.getById(contractId);
|
|
|
|
+
|
|
|
|
+ //获取某个合同段所有的电签完成的文件题名
|
|
List<InformationQuery> informationQueryList = getInformationQuerys(contractId);
|
|
List<InformationQuery> informationQueryList = getInformationQuerys(contractId);
|
|
|
|
|
|
|
|
+ //获取某个合同段下所有的质检归档文件
|
|
List<ArchiveFile> archiveFiles = getArchiveFiles(contractId);
|
|
List<ArchiveFile> archiveFiles = getArchiveFiles(contractId);
|
|
|
|
|
|
- Map<Long,ArchiveFile> archiveKeyIdMap = new HashMap<>();
|
|
|
|
|
|
+ //获取该合同段下的wbs节点
|
|
|
|
+ List<ArchiveTreeContract> archiveTreeContracts = getArchiveTreeContractsWbs(contractId);
|
|
|
|
+
|
|
|
|
+ //wbs的keyId到 归档文件的映射
|
|
|
|
+ Map<Long,ArchiveFile> archiveKeyIdMap = new LinkedHashMap<>();
|
|
for (ArchiveFile ar: archiveFiles) {
|
|
for (ArchiveFile ar: archiveFiles) {
|
|
if (ar.getNodeExtId()!= null) {
|
|
if (ar.getNodeExtId()!= null) {
|
|
archiveKeyIdMap.put(ar.getNodeExtId(),ar);
|
|
archiveKeyIdMap.put(ar.getNodeExtId(),ar);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- List<InformationQuery> newInformationQueryList = new ArrayList<>();
|
|
|
|
- List<InformationQuery> updateInformationQueryList = new ArrayList<>();
|
|
|
|
|
|
+ //wbs的keyId到 归档树的映射
|
|
|
|
+ Map<Long,Long> archiveTreeContractIdMap = new LinkedHashMap<>();
|
|
|
|
+ for (ArchiveTreeContract ar :archiveTreeContracts) {
|
|
|
|
+ archiveTreeContractIdMap.put(ar.getExtKeyId(),ar.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //遍历,所有已归档文件
|
|
for (InformationQuery info: informationQueryList) {
|
|
for (InformationQuery info: informationQueryList) {
|
|
- if (info.getWbsId() != null) {
|
|
|
|
|
|
|
|
|
|
+ if (info.getWbsId() != null) {
|
|
ArchiveFile archiveFile = archiveKeyIdMap.get(info.getWbsId());
|
|
ArchiveFile archiveFile = archiveKeyIdMap.get(info.getWbsId());
|
|
|
|
+
|
|
|
|
+ //归档文件里没有则新增
|
|
if ( archiveFile == null) {
|
|
if ( archiveFile == null) {
|
|
newInformationQueryList.add(info);
|
|
newInformationQueryList.add(info);
|
|
- }else if (!archiveFile.getPdfFileUrl().equals(info.getEVisaPdfUrl())) {
|
|
|
|
- updateInformationQueryList.add(info);
|
|
|
|
|
|
+ }//文件不同,则说明重签过,需要更新
|
|
|
|
+ else if (!archiveFile.getPdfFileUrl().equals(info.getEVisaPdfUrl())) {
|
|
|
|
+
|
|
|
|
+ //需要更新的
|
|
|
|
+ //todo 后续需增加判断已组件或者锁定的不要更新?
|
|
|
|
+ archiveFile.setPdfFileUrl(info.getEVisaPdfUrl());
|
|
|
|
+ archiveFile.setEVisaFile(info.getEVisaPdfUrl());
|
|
|
|
+ archiveFile.setFilePage(info.getEVisaPdfPage());
|
|
|
|
+ archiveFile.setFileSize(info.getEVisaPdfSize());
|
|
|
|
+ updateArchiveFiles.add(archiveFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- ProjectInfo projectInfo = projectInfoService.getOne(projectId);
|
|
|
|
-
|
|
|
|
- Long lWbsId = projectInfo.getReferenceWbsTemplateId();
|
|
|
|
|
|
|
|
|
|
+ //获取合同段wbs划分树,用来组织树
|
|
List<WbsTreeContractVO6> wbsTrees = contractInfoService.tree8(lWbsId.toString(), projectId.toString(), contractId.toString());
|
|
List<WbsTreeContractVO6> wbsTrees = contractInfoService.tree8(lWbsId.toString(), projectId.toString(), contractId.toString());
|
|
if (wbsTrees == null || wbsTrees.size() == 0) {
|
|
if (wbsTrees == null || wbsTrees.size() == 0) {
|
|
return ;
|
|
return ;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //将树转换成list
|
|
List<WbsTreeContractVO6> wbsTreeContractVO6s = new ArrayList<>();
|
|
List<WbsTreeContractVO6> wbsTreeContractVO6s = new ArrayList<>();
|
|
ForestNodeMerger.getTreeList(wbsTrees.get(0), wbsTreeContractVO6s);
|
|
ForestNodeMerger.getTreeList(wbsTrees.get(0), wbsTreeContractVO6s);
|
|
|
|
|
|
|
|
+ //id 到 wbs节点的映射
|
|
|
|
+ Map<Long,WbsTreeContractVO6> wbsTreeContractVO6Map = new HashMap<>();
|
|
|
|
+ // keyid 到id的映射
|
|
|
|
+ Map<Long,Long> wbsTreeKeyToIdMap = new HashMap<>();
|
|
|
|
+ for (WbsTreeContractVO6 wbsTreeContractVO6 : wbsTreeContractVO6s) {
|
|
|
|
+ wbsTreeContractVO6Map.put(wbsTreeContractVO6.getId(),wbsTreeContractVO6);
|
|
|
|
+ wbsTreeKeyToIdMap.put(wbsTreeContractVO6.getPKeyId(),wbsTreeContractVO6.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //遍历查找对应的nodeId
|
|
|
|
+ //List<ArchiveTreeContract> associatedNodes = getWbsAssociatedNodes(contractId.toString());
|
|
|
|
+ Long level = 1L;
|
|
|
|
+ for (InformationQuery info: newInformationQueryList) {
|
|
|
|
+
|
|
|
|
+ Long keyId = info.getWbsId();
|
|
|
|
+ //通过keyid 获取id
|
|
|
|
+ Long id = wbsTreeKeyToIdMap.get(keyId);
|
|
|
|
+ if (id == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //向上找到符合条件的level
|
|
|
|
+ Long levelKeyId = findPKeyIdByNodeType(wbsTreeContractVO6Map,id,level);
|
|
|
|
+
|
|
|
|
+ //根据map获取到对应的归档树节点nodeid
|
|
|
|
+ Long nodeId = archiveTreeContractIdMap.get(levelKeyId);
|
|
|
|
+ //生成新增的归档文件
|
|
|
|
+ ArchiveFile archiveFile = getArchiveFile(info,nodeId,info.getWbsId(),contractIndfo.archivesUnit());
|
|
|
|
+ newArchiveFiles.add(archiveFile);
|
|
|
|
+ }
|
|
|
|
|
|
- //对于newInformationQueryList。生成,需提供对应的nodeid
|
|
|
|
|
|
+ //生成map,对于对于newInformationQueryList,递归找nodeId,找到则设置到archiveFileList
|
|
|
|
|
|
//对于updateInformationQueryList,需要找出更新文件和文件大小
|
|
//对于updateInformationQueryList,需要找出更新文件和文件大小
|
|
|
|
|
|
@@ -283,4 +350,53 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
//互殴去
|
|
//互殴去
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public List<ArchiveTreeContract> getArchiveTreeContractsWbs(Long contractId) {
|
|
|
|
+
|
|
|
|
+ List<ArchiveTreeContract> archiveTreeContracts = archiveTreeContractMapper.selectList(Wrappers.<ArchiveTreeContract>query().lambda()
|
|
|
|
+ .eq(ArchiveTreeContract::getContractId, contractId)
|
|
|
|
+ .eq(ArchiveTreeContract::getExtType, 2));
|
|
|
|
+ return archiveTreeContracts;
|
|
|
|
+
|
|
|
|
+ //互殴去
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Long findPKeyIdByNodeType(Map<Long, WbsTreeContractVO6> wbsTreeContractVO6Map, Long id, Long nodeType) {
|
|
|
|
+
|
|
|
|
+ while (true) {
|
|
|
|
+ WbsTreeContractVO6 current = wbsTreeContractVO6Map.get(id);
|
|
|
|
+ if (current == null) {
|
|
|
|
+ return null; // 如果没有找到对应的节点,则返回 null
|
|
|
|
+ }
|
|
|
|
+ if (current.getNodeType().equals(nodeType)) {
|
|
|
|
+ return current.getPKeyId(); // 如果找到了符合要求的节点,则返回其 pKeyId 属性值
|
|
|
|
+ }
|
|
|
|
+ id = current.getParentId(); // 取出当前节点的父节点 ID,准备进行下一轮循环操作
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ArchiveFile getArchiveFile(InformationQuery query,Long nodeId,Long keyId,String unit) {
|
|
|
|
+ ArchiveFile archiveFile = new ArchiveFile();
|
|
|
|
+ archiveFile.setNodeId(nodeId.toString());
|
|
|
|
+ archiveFile.setNodeExtId(keyId);
|
|
|
|
+ archiveFile.setContractId(query.getContractId().toString());
|
|
|
|
+ archiveFile.setStatus(2); // 这里是新增归档文件,所以状态为1(已完成)
|
|
|
|
+ //TODO 文件题名规则,待补充
|
|
|
|
+ archiveFile.setFileName(query.getName());
|
|
|
|
+ archiveFile.setFileTime(query.getBusinessTime());
|
|
|
|
+
|
|
|
|
+ archiveFile.setSourceType(1);
|
|
|
|
+
|
|
|
|
+ //责任人怎么取
|
|
|
|
+ archiveFile.setDutyUser(unit);
|
|
|
|
+
|
|
|
|
+ //文件大小
|
|
|
|
+ archiveFile.setFileSize(query.getEVisaPdfSize());
|
|
|
|
+ archiveFile.setFilePage(query.getEVisaPdfPage());
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ archiveFile.setEVisaFile(query.getEVisaPdfUrl());
|
|
|
|
+ archiveFile.setPdfFileUrl(query.getEVisaPdfUrl());
|
|
|
|
+ return archiveFile;
|
|
|
|
+ }
|
|
}
|
|
}
|