|
@@ -1,35 +1,48 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
+import com.alibaba.nacos.common.utils.DateFormatUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.protobuf.ServiceException;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.archive.entity.ArchiveProjectConfig;
|
|
|
import org.springblade.archive.feign.ArchiveAutoClient;
|
|
|
+import org.springblade.business.dto.ImageClassificationFileDTO;
|
|
|
import org.springblade.business.entity.ArchiveFile;
|
|
|
import org.springblade.business.entity.InformationQuery;
|
|
|
import org.springblade.business.feign.ArchiveFileClient;
|
|
|
+import org.springblade.business.feign.ImageClassificationFileClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
+import org.springblade.business.vo.TreeVoTwo;
|
|
|
+import org.springblade.common.utils.ForestNodeMergerEx;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.manager.entity.ArchiveTreeContract;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
import org.springblade.manager.entity.ContractRelationJlyz;
|
|
|
import org.springblade.manager.entity.ProjectInfo;
|
|
|
-import org.springblade.manager.feign.ContractClient;
|
|
|
+import org.springblade.manager.enums.StorageTypeEnum;
|
|
|
+import org.springblade.manager.enums.TreeStructureEnum;
|
|
|
import org.springblade.manager.mapper.ArchiveTreeContractMapper;
|
|
|
import org.springblade.manager.service.IContractInfoService;
|
|
|
import org.springblade.manager.service.IProjectInfoService;
|
|
|
-import org.springblade.common.utils.ForestNodeMergerEx;
|
|
|
-import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.utils.ForestNodeMerger;
|
|
|
+import org.springblade.manager.utils.YearTreeUtils;
|
|
|
+import org.springblade.manager.vo.ArchiveTreeContractVO;
|
|
|
import org.springblade.manager.vo.ArchiveTreeContractVO2;
|
|
|
import org.springblade.manager.vo.ArchiveTreeVO2;
|
|
|
import org.springblade.manager.vo.WbsTreeContractVO6;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -55,6 +68,7 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
private final ArchiveAutoClient archiveAutoClient;
|
|
|
|
|
|
+ private final ImageClassificationFileClient imageClassificationFileClient;
|
|
|
|
|
|
/**
|
|
|
* 普通同步
|
|
@@ -620,10 +634,10 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
public List<ArchiveTreeContract> getArchiveTreeContractsWbs(Long contractId,Long attachId,Integer classify) {
|
|
|
|
|
|
- List<ArchiveTreeContract> archiveTreeContracts = archiveTreeContractMapper.selectList(Wrappers.<ArchiveTreeContract>query().lambda()
|
|
|
+ List<ArchiveTreeContract> archiveTreeContracts = archiveTreeContractMapper.selectList(Wrappers.<ArchiveTreeContract>query().lambda()
|
|
|
.eq(ArchiveTreeContract::getContractId, contractId)
|
|
|
.eq(ArchiveTreeContract::getExtAttachId, attachId)
|
|
|
- .eq(ArchiveTreeContract::getClassify, classify)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(classify), ArchiveTreeContract::getClassify, classify)
|
|
|
.eq(ArchiveTreeContract::getExtType, 1));
|
|
|
return archiveTreeContracts;
|
|
|
|
|
@@ -738,5 +752,692 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
return groupedFiles;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 同步合同段声像文件
|
|
|
+ */
|
|
|
+ public void syncSoundImageData(Long projectId, Long contractId, Long nodeId) throws ServiceException {
|
|
|
+ // 合同信息
|
|
|
+ ContractInfo contractInfo = contractInfoService.getById(contractId);
|
|
|
+ // 判断是否正在同步
|
|
|
+ Integer isArchivesAuto = contractInfo.getIsArchivesAuto();
|
|
|
+ if(ObjectUtil.isNotEmpty(isArchivesAuto) && isArchivesAuto != 0) {
|
|
|
+ throw new ServiceException("当前合同段已经在同步中,请耐心等待");
|
|
|
+ }
|
|
|
+ // 判断节点存储类型是否为声像
|
|
|
+ ArchiveTreeContract archiveTreeContract = archiveTreeContractMapper.selectById(nodeId);
|
|
|
+ if(archiveTreeContract != null) {
|
|
|
+ if(!archiveTreeContract.getStorageType().equals(StorageTypeEnum.SOUND_IMAGE.getCode())){
|
|
|
+ throw new ServiceException("当前节点存储类型不是声像,无法同步声像文件");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new ServiceException("当前节点不存在,同步失败");
|
|
|
+ }
|
|
|
+ log.info("开始自动组卷...." + contractId);
|
|
|
+ //设置自动组卷中
|
|
|
+ contractInfoService.updateIsArchivesAutoById(contractId,1);
|
|
|
+ try {
|
|
|
+ // 同步文件
|
|
|
+ syncSoundImageData(projectId,contractInfo,archiveTreeContract);
|
|
|
+ //完成自动组卷
|
|
|
+ contractInfoService.updateIsArchivesAutoById(contractId, 0);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ //设置自动组卷结束
|
|
|
+ contractInfoService.updateIsArchivesAutoById(contractId, 0);
|
|
|
+ log.error("同步声像文件报错,projectId:"+projectId+"、contractId:"+contractId+"nodeId:"+nodeId+",原因:"+e.getMessage());
|
|
|
+ throw new ServiceException("同步声像文件报错");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步某个合同段的声像资料到归档
|
|
|
+ */
|
|
|
+ public void syncSoundImageData(Long projectId, ContractInfo contractInfo, ArchiveTreeContract archiveTreeContract) {
|
|
|
+ Long contractId = contractInfo.getId();
|
|
|
+
|
|
|
+ log.info("同步声像文件,projectId:"+projectId+",contractId:"+contractId+",nodeId:"+archiveTreeContract.getId());
|
|
|
+
|
|
|
+ //项目信息
|
|
|
+ ProjectInfo projectInfo = projectInfoService.getOne(projectId);
|
|
|
+
|
|
|
+ //项目使用的wbs模板
|
|
|
+ Long lWbsId = projectInfo.getReferenceWbsTemplateId();
|
|
|
+
|
|
|
+ //获取合同段wbs划分树,用来组织树
|
|
|
+ List<WbsTreeContractVO6> wbsTrees = contractInfoService.tree8(lWbsId.toString(), projectId.toString(), contractId.toString());
|
|
|
+ if (CollectionUtil.isEmpty(wbsTrees)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // wbs转换archive树形集合
|
|
|
+ List<ArchiveTreeContract> wbsCovertArchiveTreeContractList = new ArrayList<>();
|
|
|
+
|
|
|
+ // wbs转换archive,并初始化值
|
|
|
+ getTreeList(AuthUtil.getTenantId(), wbsTrees.get(0), wbsCovertArchiveTreeContractList, archiveTreeContract, archiveTreeContract.getId());
|
|
|
+
|
|
|
+ log.info("同步声像文件树 imageClassificationFileList :"+wbsCovertArchiveTreeContractList.size());
|
|
|
+
|
|
|
+ //同步质检关联节点
|
|
|
+ syncNodes(wbsCovertArchiveTreeContractList, contractInfo, archiveTreeContract);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将树形节点对象转换为普通的list集合
|
|
|
+ */
|
|
|
+ public void getTreeList(String tenantId, WbsTreeContractVO6 tree, List<ArchiveTreeContract> wbsCovertArchiveTreeContractList, ArchiveTreeContract archiveTreeContract, Long archiveTreeContractId) {
|
|
|
+ if (ObjectUtil.isEmpty(tree)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // wbs树转archive树
|
|
|
+ ArchiveTreeContract archiveTreeContractTemp = wbsTreeContractCovertArchiveTreeContract(tenantId, tree, archiveTreeContract, archiveTreeContractId);
|
|
|
+ wbsCovertArchiveTreeContractList.add(archiveTreeContractTemp);
|
|
|
+
|
|
|
+ // 循环遍历,转换树对象
|
|
|
+ List<WbsTreeContractVO6> childrenList = tree.getChildren();
|
|
|
+ if (childrenList != null) {
|
|
|
+ for (WbsTreeContractVO6 child : childrenList) {
|
|
|
+ getTreeList(tenantId, child, wbsCovertArchiveTreeContractList, archiveTreeContractTemp, archiveTreeContractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将wbs树初始化为归档树
|
|
|
+ */
|
|
|
+ public ArchiveTreeContract wbsTreeContractCovertArchiveTreeContract(String tenantId, WbsTreeContractVO6 tree, ArchiveTreeContract archiveTreeContract, Long archiveTreeContractId) {
|
|
|
+ ArchiveTreeContract archiveTreeContractTemp = new ArchiveTreeContract();
|
|
|
+ //设置基本信息
|
|
|
+ archiveTreeContractTemp.setId(SnowFlakeUtil.getId());
|
|
|
+ archiveTreeContractTemp.setTenantId(tenantId);
|
|
|
+ archiveTreeContractTemp.setProjectId(archiveTreeContract.getProjectId());
|
|
|
+ archiveTreeContractTemp.setContractId(archiveTreeContract.getContractId());
|
|
|
+ archiveTreeContractTemp.setParentId(archiveTreeContract.getId());
|
|
|
+ archiveTreeContractTemp.setAncestors(archiveTreeContract.getAncestors()+","+archiveTreeContract.getId());
|
|
|
+ archiveTreeContractTemp.setNodeName(tree.getNodeName());
|
|
|
+ archiveTreeContractTemp.setNodeType(1);
|
|
|
+ archiveTreeContractTemp.setFullName(tree.getFullName());
|
|
|
+ archiveTreeContractTemp.setTreeCode(archiveTreeContract.getContractId().toString());
|
|
|
+ //设置关联
|
|
|
+ archiveTreeContractTemp.setExtType(1);
|
|
|
+ archiveTreeContractTemp.setExtId(tree.getId());
|
|
|
+ archiveTreeContractTemp.setExtKeyId(tree.getPKeyId());
|
|
|
+ archiveTreeContractTemp.setExtAttachId(archiveTreeContractId);
|
|
|
+ archiveTreeContractTemp.setSort(tree.getSort());
|
|
|
+ archiveTreeContractTemp.setStatus(1);
|
|
|
+ archiveTreeContractTemp.setIsDeleted(0);
|
|
|
+ archiveTreeContractTemp.setFromId(tree.getId());
|
|
|
+ if (StringUtils.isNotEmpty(tree.getOldId())) {
|
|
|
+ archiveTreeContractTemp.setFromId(Long.parseLong(tree.getOldId()));
|
|
|
+ }
|
|
|
+ archiveTreeContractTemp.setIsStorageNode(1);
|
|
|
+ //wbs_tree_contract与archive_tree_contract字段等存在差异,不清楚的字段值,我沿用同步节点的字段值进行初始化
|
|
|
+ archiveTreeContractTemp.setPostType(archiveTreeContract.getPostType());
|
|
|
+ archiveTreeContractTemp.setMajorDataType(archiveTreeContract.getMajorDataType());
|
|
|
+ archiveTreeContractTemp.setProjectType(archiveTreeContract.getProjectType());
|
|
|
+ archiveTreeContractTemp.setStorageType(archiveTreeContract.getStorageType());
|
|
|
+ archiveTreeContractTemp.setCreateUser(tree.getCreateUser());
|
|
|
+ archiveTreeContractTemp.setCreateDept(tree.getCreateDept());
|
|
|
+ archiveTreeContractTemp.setCreateTime(tree.getCreateTime());
|
|
|
+ archiveTreeContractTemp.setTreeStructure(TreeStructureEnum.ORDINARY_TREE.getCode());
|
|
|
+ return archiveTreeContractTemp;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void syncNodes(List<ArchiveTreeContract> wbsCovertArchiveTreeContractList,
|
|
|
+ ContractInfo contractInfo, ArchiveTreeContract archiveTreeContract) {
|
|
|
+ Long contractId = contractInfo.getId();
|
|
|
+
|
|
|
+ // 获取关联节点
|
|
|
+ List<ArchiveTreeContract> associatedNodes = Arrays.asList(archiveTreeContract);
|
|
|
+
|
|
|
+ log.info("同步声像文件树节点 syncNodes:"+associatedNodes.size());
|
|
|
+
|
|
|
+ // 新增的归档树聚合
|
|
|
+ List<ArchiveTreeContract> saveArchiveTreeContractList = new ArrayList<>();
|
|
|
+ // 新增的归档文件集合
|
|
|
+ List<ArchiveFile> saveArchiveFileList = new ArrayList<>();
|
|
|
+ // 修改的归档树聚合
|
|
|
+ List<Map> updateArchiveTreeContractList = new ArrayList<>();
|
|
|
+ // 修改的归档文件集合
|
|
|
+ List<ArchiveFile> updateArchiveFileList = new ArrayList<>();
|
|
|
+ // 删除的归档树聚合
|
|
|
+ List<ArchiveTreeContract> deleteArchiveTreeContractList = new ArrayList<>();
|
|
|
+ // 删除的归档文件集合
|
|
|
+ List<ArchiveFile> deleteArchiveFileList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (ArchiveTreeContract node : associatedNodes) {
|
|
|
+ log.info("同步声像文件树节点 syncNode:" + node.getId() + "-" + node.getNodeName());
|
|
|
+
|
|
|
+ /***同步树-开始*/
|
|
|
+ // 获取该合同段下的wbs节点
|
|
|
+ List<ArchiveTreeContract> originalArchiveTreeContractList = getArchiveTreeContractsWbs(contractId, node.getId(),null);
|
|
|
+
|
|
|
+ // 树形map
|
|
|
+ Map<Long, ArchiveTreeContract> originalArchiveTreeContractMap = buildNodeMap(originalArchiveTreeContractList);
|
|
|
+
|
|
|
+ // 转换类型
|
|
|
+ List<ArchiveTreeContractVO> archiveTreeContractVOList = wbsCovertArchiveTreeContractList.stream().map(tree -> {
|
|
|
+ ArchiveTreeContractVO vo = new ArchiveTreeContractVO();
|
|
|
+ BeanUtils.copyProperties(tree, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // list转换为树形
|
|
|
+ List<ArchiveTreeContractVO> mergeList = org.springblade.core.tool.node.ForestNodeMerger.merge(archiveTreeContractVOList);
|
|
|
+
|
|
|
+ // 与已有数据做合并(目的是将已有的树信息复制到对应的树)
|
|
|
+ archiveAndOldTreeMergeData(mergeList, originalArchiveTreeContractMap, TreeStructureEnum.ORDINARY_TREE);
|
|
|
+
|
|
|
+ // 重新刷新整个树结构(刷新整个树的父子节点id)
|
|
|
+ for (ArchiveTreeContractVO archiveTreeContractVO : mergeList) {
|
|
|
+ refreshTreeStructure(archiveTreeContractVO, node.getId(), node.getAncestors());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将树转换为list
|
|
|
+ List<ArchiveTreeContractVO> archiveTreeContractVOTempList = new ArrayList<>();
|
|
|
+ ForestNodeMerger.getTreeList(mergeList.get(0), archiveTreeContractVOTempList);
|
|
|
+
|
|
|
+ List<ArchiveTreeContract> newArchiveTreeContractList = archiveTreeContractVOTempList.stream().map(vo -> {
|
|
|
+ ArchiveTreeContract archiveTreeContractTemp = new ArchiveTreeContract();
|
|
|
+ BeanUtils.copyProperties(vo, archiveTreeContractTemp);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 树形map
|
|
|
+ Map<Long, ArchiveTreeContract> newArchiveTreeContractMap = buildNodeMap(newArchiveTreeContractList);
|
|
|
+
|
|
|
+ // 取两个树形集合中的差异,并输出新增、修改、删除三个集合
|
|
|
+ diffTrees(originalArchiveTreeContractList, newArchiveTreeContractList, originalArchiveTreeContractMap,
|
|
|
+ newArchiveTreeContractMap, saveArchiveTreeContractList, deleteArchiveTreeContractList, updateArchiveTreeContractList);
|
|
|
+ /***同步树-结束*/
|
|
|
+
|
|
|
+ /***同步树型文件数据准备-开始*/
|
|
|
+ // 根据合同段id查询声像文件
|
|
|
+ List<ImageClassificationFileDTO> imageClassificationFileList = getImageClassificationFileListByContractId(contractId);
|
|
|
+
|
|
|
+ // 声像文件转换
|
|
|
+ List<ArchiveFile> newArchiveFileList = imageClassificationFileList.stream().map(file -> {
|
|
|
+ ArchiveFile archiveFile = imageClassificationFileCovertArchiveFile(file, node, newArchiveTreeContractMap);
|
|
|
+ return archiveFile;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查询合同段下的声像文件
|
|
|
+ List<ArchiveFile> originalArchiveFileList = archiveFileClient.getListByContractIdAndArchiveFileStorageType(contractId, StorageTypeEnum.SOUND_IMAGE.getCode());
|
|
|
+
|
|
|
+ // 构件原始文件TreeMap
|
|
|
+ Map<Long, ArchiveFile> originalArchiveFileMap = buildArchiveFileMap(originalArchiveFileList);
|
|
|
+
|
|
|
+ // 与已有数据做合并(目的是将已有的树信息复制到对应的树)
|
|
|
+ originalAndNewArchiveFileMergeData(newArchiveFileList, originalArchiveFileMap);
|
|
|
+
|
|
|
+ // 构件新文件TreeMap
|
|
|
+ Map<Long, ArchiveFile> newArchiveFileMap = buildArchiveFileMap(newArchiveFileList);
|
|
|
+
|
|
|
+ // 将声像文件集合遍历,分为时间储存和树形储存两个集合
|
|
|
+ List<ArchiveFile> newArchiveFileTreeList = new ArrayList<>();
|
|
|
+ List<ArchiveFile> newArchiveFileDateList = new ArrayList<>();
|
|
|
+ for (ArchiveFile archiveFile : newArchiveFileList) {
|
|
|
+ if(archiveFile.getNodeTreeStructure() == 1) {
|
|
|
+ newArchiveFileTreeList.add(archiveFile);
|
|
|
+ }else if(archiveFile.getNodeTreeStructure() == 2) {
|
|
|
+ newArchiveFileDateList.add(archiveFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将声像文件集合遍历,分为时间储存和树形储存两个集合
|
|
|
+ List<ArchiveFile> originalArchiveFileTreeList = new ArrayList<>();
|
|
|
+ List<ArchiveFile> originalArchiveFileDateList = new ArrayList<>();
|
|
|
+ for (ArchiveFile archiveFile : originalArchiveFileList) {
|
|
|
+ if(archiveFile.getNodeTreeStructure() == 1) {
|
|
|
+ originalArchiveFileTreeList.add(archiveFile);
|
|
|
+ }else if(archiveFile.getNodeTreeStructure() == 2) {
|
|
|
+ originalArchiveFileDateList.add(archiveFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /***同步树型文件数据准备-结束*/
|
|
|
+
|
|
|
+ /**同步树形文件-开始**/
|
|
|
+ // 取两个树形集合中的差异,并输出新增、修改、删除三个集合
|
|
|
+ diffFiles(originalArchiveFileTreeList, newArchiveFileTreeList, originalArchiveFileMap, newArchiveFileMap,
|
|
|
+ saveArchiveFileList, deleteArchiveFileList, updateArchiveFileList, newArchiveTreeContractMap, TreeStructureEnum.ORDINARY_TREE);
|
|
|
+ /**同步树形文件-结束**/
|
|
|
+
|
|
|
+ /**同步时间树-开始**/
|
|
|
+ // 获取该合同段下的时间型节点
|
|
|
+ List<ArchiveTreeContract> originalDateArchiveTreeContractList = getArchiveTreeContractsByTreeStructure(contractId, node.getId(), TreeStructureEnum.DATE_TREE);
|
|
|
+
|
|
|
+ // 树形map
|
|
|
+ Map<Long, ArchiveTreeContract> originalDateArchiveTreeContractMap = buildDateMap(originalDateArchiveTreeContractList);
|
|
|
+
|
|
|
+ // 将最新文件的时间取出,创建时间树
|
|
|
+ List<String> dateList = newArchiveFileDateList.stream().map(archiveFile -> {
|
|
|
+ String format = DateFormatUtils.format(archiveFile.getCreateTime(), "yyyy-MM-dd");
|
|
|
+ return format;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 转时间树
|
|
|
+ List<TreeVoTwo> dateTreeList = YearTreeUtils.yearMonthDayTree(dateList, "DESC");
|
|
|
+
|
|
|
+ // date转换archive树形集合
|
|
|
+ List<ArchiveTreeContractVO> dateCovertArchiveTreeContractVoList = new ArrayList<>();
|
|
|
+
|
|
|
+ // date转换archive,并初始化值
|
|
|
+ getTreeList(AuthUtil.getTenantId(), dateTreeList, dateCovertArchiveTreeContractVoList, archiveTreeContract, archiveTreeContract.getId());
|
|
|
+
|
|
|
+ // list转换为树形
|
|
|
+ List<ArchiveTreeContractVO> mergeDateList = org.springblade.core.tool.node.ForestNodeMerger.merge(dateCovertArchiveTreeContractVoList);
|
|
|
+
|
|
|
+ // 与已有数据做合并(目的是将已有的树信息复制到对应的树)
|
|
|
+ archiveAndOldTreeMergeData(mergeDateList, originalDateArchiveTreeContractMap, TreeStructureEnum.DATE_TREE);
|
|
|
+
|
|
|
+ // 重新刷新整个树结构(刷新整个树的父子节点id)
|
|
|
+ for (ArchiveTreeContractVO dateArchiveTreeContractVO : mergeDateList) {
|
|
|
+ refreshTreeStructure(dateArchiveTreeContractVO, node.getId(), node.getAncestors());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将树转换为list
|
|
|
+ List<ArchiveTreeContractVO> dateArchiveTreeContractVOTempList = new ArrayList<>();
|
|
|
+ for (ArchiveTreeContractVO archiveTreeContractVO : mergeDateList) {
|
|
|
+ ForestNodeMerger.getTreeList(archiveTreeContractVO, dateArchiveTreeContractVOTempList);
|
|
|
+ }
|
|
|
+ // 转实体类
|
|
|
+ List<ArchiveTreeContract> newDateArchiveTreeContractList = dateArchiveTreeContractVOTempList.stream().map(vo -> {
|
|
|
+ ArchiveTreeContract archiveTreeContractTemp = new ArchiveTreeContract();
|
|
|
+ BeanUtils.copyProperties(vo, archiveTreeContractTemp);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 树形map
|
|
|
+ Map<Long, ArchiveTreeContract> newDateArchiveTreeContractMap = buildDateMap(newDateArchiveTreeContractList);
|
|
|
+
|
|
|
+ // 取两个树形集合中的差异,并输出新增、修改、删除三个集合
|
|
|
+ diffDateTrees(originalDateArchiveTreeContractList, newDateArchiveTreeContractList, originalDateArchiveTreeContractMap,
|
|
|
+ newDateArchiveTreeContractMap, saveArchiveTreeContractList, deleteArchiveTreeContractList, updateArchiveTreeContractList);
|
|
|
+ /**同步时间树-结束**/
|
|
|
+
|
|
|
+ /**同步时间树形文件-开始**/
|
|
|
+ // 取两个树形集合中的差异,并输出新增、修改、删除三个集合
|
|
|
+ diffFiles(originalArchiveFileDateList, newArchiveFileDateList, originalArchiveFileMap, newArchiveFileMap,
|
|
|
+ saveArchiveFileList, deleteArchiveFileList, updateArchiveFileList, newDateArchiveTreeContractMap, TreeStructureEnum.DATE_TREE);
|
|
|
+ /**同步时间树形文件-结束**/
|
|
|
+
|
|
|
+ /**统一刷新树与文件**/
|
|
|
+ // 刷新树
|
|
|
+ refreshArchiveTreeContract(saveArchiveTreeContractList, updateArchiveTreeContractList, deleteArchiveTreeContractList);
|
|
|
+
|
|
|
+ // 刷新文件
|
|
|
+ refreshArchiveFile(saveArchiveFileList, updateArchiveFileList, deleteArchiveFileList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 时间树中的差异
|
|
|
+ * 遍历循环,获取差异,并输出三个集合(归档树的fullName = 老树中的fullName)
|
|
|
+ */
|
|
|
+ private static void diffDateTrees(List<ArchiveTreeContract> originalDateArchiveTreeContractList, List<ArchiveTreeContract> newDateArchiveTreeContractList, Map<Long, ArchiveTreeContract> originalDateArchiveTreeContractMap,
|
|
|
+ Map<Long, ArchiveTreeContract> newDateArchiveTreeContractMap, List<ArchiveTreeContract> insertions,
|
|
|
+ List<ArchiveTreeContract> deletions, List<Map> modifications) {
|
|
|
+ for (ArchiveTreeContract originalDateArchiveTreeContract : originalDateArchiveTreeContractList) {
|
|
|
+ if (!newDateArchiveTreeContractMap.containsKey(originalDateArchiveTreeContract.getFullName())) {
|
|
|
+ deletions.add(originalDateArchiveTreeContract);
|
|
|
+ } else {
|
|
|
+ ArchiveTreeContract node2 = newDateArchiveTreeContractMap.get(originalDateArchiveTreeContract.getFullName());
|
|
|
+ if (originalDateArchiveTreeContract.getFullName().equals(node2.getFullName())) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("id", originalDateArchiveTreeContract.getId());
|
|
|
+ map.put("parentId", node2.getParentId());
|
|
|
+ map.put("ancestors", node2.getAncestors());
|
|
|
+ map.put("nodeName", node2.getNodeName());
|
|
|
+ map.put("nodeType", node2.getNodeType());
|
|
|
+ map.put("fullName", node2.getFullName());
|
|
|
+ map.put("treeStructure", node2.getTreeStructure());
|
|
|
+ modifications.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ArchiveTreeContract newArchiveTreeContract : newDateArchiveTreeContractList) {
|
|
|
+ if (!originalDateArchiveTreeContractMap.containsKey(newArchiveTreeContract.getFullName())) {
|
|
|
+ insertions.add(newArchiveTreeContract);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据tree结构获取归档树
|
|
|
+ */
|
|
|
+ public List<ArchiveTreeContract> getArchiveTreeContractsByTreeStructure(Long contractId,Long attachId, TreeStructureEnum treeStructure) {
|
|
|
+ List<ArchiveTreeContract> archiveTreeContracts = archiveTreeContractMapper.selectList(Wrappers.<ArchiveTreeContract>query().lambda()
|
|
|
+ .eq(ArchiveTreeContract::getContractId, contractId)
|
|
|
+ .eq(ArchiveTreeContract::getExtAttachId, attachId)
|
|
|
+ .eq(ArchiveTreeContract::getTreeStructure, treeStructure.getCode()));
|
|
|
+ return archiveTreeContracts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将时间树形节点对象转换为普通的list集合
|
|
|
+ */
|
|
|
+ public void getTreeList(String tenantId, List<TreeVoTwo> dateTreeList, List<ArchiveTreeContractVO> dateCovertArchiveTreeContractList, ArchiveTreeContract archiveTreeContract, Long archiveTreeContractId) {
|
|
|
+ if (CollectionUtil.isEmpty(dateTreeList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (TreeVoTwo tree : dateTreeList) {
|
|
|
+ // wbs树转archive树
|
|
|
+ ArchiveTreeContractVO archiveTreeContractVoTemp = dateTreeCovertArchiveTreeContract(tenantId, tree, archiveTreeContract, archiveTreeContractId);
|
|
|
+ dateCovertArchiveTreeContractList.add(archiveTreeContractVoTemp);
|
|
|
+
|
|
|
+ // 循环遍历,转换树对象
|
|
|
+ List<TreeVoTwo> childrenList = tree.getChildren();
|
|
|
+ if (childrenList != null) {
|
|
|
+ getTreeList(tenantId, childrenList, dateCovertArchiveTreeContractList, archiveTreeContractVoTemp, archiveTreeContractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将时间树初始化为归档树
|
|
|
+ */
|
|
|
+ public ArchiveTreeContractVO dateTreeCovertArchiveTreeContract(String tenantId, TreeVoTwo tree, ArchiveTreeContract archiveTreeContract, Long archiveTreeContractId) {
|
|
|
+ ArchiveTreeContractVO archiveTreeContractVoTemp = new ArchiveTreeContractVO();
|
|
|
+ //设置基本信息
|
|
|
+ archiveTreeContractVoTemp.setId(SnowFlakeUtil.getId());
|
|
|
+ archiveTreeContractVoTemp.setTenantId(tenantId);
|
|
|
+ archiveTreeContractVoTemp.setProjectId(archiveTreeContract.getProjectId());
|
|
|
+ archiveTreeContractVoTemp.setContractId(archiveTreeContract.getContractId());
|
|
|
+ archiveTreeContractVoTemp.setParentId(archiveTreeContract.getId());
|
|
|
+ archiveTreeContractVoTemp.setAncestors(archiveTreeContract.getAncestors()+","+archiveTreeContract.getId());
|
|
|
+ archiveTreeContractVoTemp.setNodeName(tree.getName());
|
|
|
+ archiveTreeContractVoTemp.setNodeType(1);
|
|
|
+ archiveTreeContractVoTemp.setFullName(tree.getHierarchy());
|
|
|
+ archiveTreeContractVoTemp.setTreeCode(archiveTreeContract.getContractId().toString());
|
|
|
+ //设置关联
|
|
|
+ archiveTreeContractVoTemp.setExtAttachId(archiveTreeContractId);
|
|
|
+ archiveTreeContractVoTemp.setSort(archiveTreeContract.getSort());
|
|
|
+ archiveTreeContractVoTemp.setStatus(1);
|
|
|
+ archiveTreeContractVoTemp.setIsDeleted(0);
|
|
|
+ archiveTreeContractVoTemp.setIsStorageNode(1);
|
|
|
+ //时间树不同于wbs树,不清楚的字段值,我沿用同步节点的字段值进行初始化
|
|
|
+ archiveTreeContractVoTemp.setPostType(archiveTreeContract.getPostType());
|
|
|
+ archiveTreeContractVoTemp.setMajorDataType(archiveTreeContract.getMajorDataType());
|
|
|
+ archiveTreeContractVoTemp.setProjectType(archiveTreeContract.getProjectType());
|
|
|
+ archiveTreeContractVoTemp.setStorageType(archiveTreeContract.getStorageType());
|
|
|
+ archiveTreeContractVoTemp.setCreateUser(archiveTreeContract.getCreateUser());
|
|
|
+ archiveTreeContractVoTemp.setCreateDept(archiveTreeContract.getCreateDept());
|
|
|
+ archiveTreeContractVoTemp.setCreateTime(archiveTreeContract.getCreateTime());
|
|
|
+ archiveTreeContractVoTemp.setTreeStructure(TreeStructureEnum.DATE_TREE.getCode());
|
|
|
+ return archiveTreeContractVoTemp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 刷新归档文件
|
|
|
+ */
|
|
|
+ void refreshArchiveFile(List<ArchiveFile> saveArchiveFileList, List<ArchiveFile> updateArchiveFileList,
|
|
|
+ List<ArchiveFile> deleteArchiveFileList) {
|
|
|
+ if (CollectionUtil.isNotEmpty(saveArchiveFileList)) {
|
|
|
+ archiveFileClient.addArchiveFile(saveArchiveFileList);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(updateArchiveFileList)) {
|
|
|
+ archiveFileClient.updateArchiveFile(updateArchiveFileList);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(deleteArchiveFileList)) {
|
|
|
+ List<Long> idList = deleteArchiveFileList.stream().map(ArchiveFile::getId).collect(Collectors.toList());
|
|
|
+ archiveFileClient.removeFile(idList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 现有的树与wbs的树做合并
|
|
|
+ */
|
|
|
+ public void originalAndNewArchiveFileMergeData(List<ArchiveFile> mergeList, Map<Long, ArchiveFile> archiveFileMap) {
|
|
|
+ if (CollectionUtil.isEmpty(mergeList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 循环遍历,将已有的赋值
|
|
|
+ for (ArchiveFile archiveFile : mergeList) {
|
|
|
+ ArchiveFile archiveFileTemp = archiveFileMap.get(archiveFile.getUImageClassificationFileId());
|
|
|
+ if(ObjectUtil.isNotEmpty(archiveFileTemp)){
|
|
|
+ archiveFile.setId(archiveFileTemp.getId());
|
|
|
+ archiveFile.setNodeId(archiveFileTemp.getNodeId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 遍历循环,获取差异,并输出三个集合(archiveFile表的uImageClassificationFileId = ImageClassificationFile 的 id)
|
|
|
+ */
|
|
|
+ private static void diffFiles(List<ArchiveFile> originalArchiveFileList, List<ArchiveFile> newArchiveFileList, Map<Long, ArchiveFile> originalArchiveFileTreeMap,
|
|
|
+ Map<Long, ArchiveFile> newArchiveFileTreeMap, List<ArchiveFile> insertions, List<ArchiveFile> deletions, List<ArchiveFile> modifications,
|
|
|
+ Map<Long, ArchiveTreeContract> newArchiveTreeContractMap, TreeStructureEnum treeStructureEnum) {
|
|
|
+ for (ArchiveFile originalArchiveFile : originalArchiveFileList) {
|
|
|
+ if (!newArchiveFileTreeMap.containsKey(originalArchiveFile.getUImageClassificationFileId())) {
|
|
|
+ deletions.add(originalArchiveFile);
|
|
|
+ } else {
|
|
|
+ ArchiveFile node2 = newArchiveFileTreeMap.get(originalArchiveFile.getUImageClassificationFileId());
|
|
|
+ if (originalArchiveFile.getUImageClassificationFileId().equals(node2.getUImageClassificationFileId())) {
|
|
|
+ modifications.add(node2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ArchiveFile newArchiveFile : newArchiveFileList) {
|
|
|
+ if (!originalArchiveFileTreeMap.containsKey(newArchiveFile.getUImageClassificationFileId())) {
|
|
|
+ ArchiveTreeContract archiveTreeContract = null;
|
|
|
+ if(treeStructureEnum.getCode() == TreeStructureEnum.ORDINARY_TREE.getCode()){
|
|
|
+ archiveTreeContract = newArchiveTreeContractMap.get(newArchiveFile.getMWbsTreeContractPKeyId());
|
|
|
+ } else if(treeStructureEnum.getCode() == TreeStructureEnum.DATE_TREE.getCode()) {
|
|
|
+ archiveTreeContract = newArchiveTreeContractMap.get(Long.valueOf(newArchiveFile.getDateName()));
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(archiveTreeContract)){
|
|
|
+ newArchiveFile.setNodeId(String.valueOf(archiveTreeContract.getId()));
|
|
|
+ }
|
|
|
+ insertions.add(newArchiveFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建节点map
|
|
|
+ */
|
|
|
+ private static Map<Long, ArchiveFile> buildArchiveFileMap(List<ArchiveFile> archiveFileList) {
|
|
|
+ Map<Long, ArchiveFile> map = new HashMap<>();
|
|
|
+ for (ArchiveFile archiveFile : archiveFileList) {
|
|
|
+ map.put(archiveFile.getUImageClassificationFileId(), archiveFile);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * imageClassificationFile 转换为 archiveFile
|
|
|
+ */
|
|
|
+ private ArchiveFile imageClassificationFileCovertArchiveFile(ImageClassificationFileDTO file,
|
|
|
+ ArchiveTreeContract node,
|
|
|
+ Map<Long, ArchiveTreeContract> wbsCovertArchiveTreeContractMap)
|
|
|
+ {
|
|
|
+ ArchiveFile archiveFile = new ArchiveFile();
|
|
|
+ archiveFile.setId(SnowFlakeUtil.getId());
|
|
|
+ archiveFile.setProjectId(String.valueOf(node.getProjectId()));
|
|
|
+ archiveFile.setContractId(String.valueOf(node.getContractId()));
|
|
|
+ ArchiveTreeContract archiveTreeContractTemp = wbsCovertArchiveTreeContractMap.get(Long.valueOf(file.getWbsId()));
|
|
|
+ if(archiveTreeContractTemp != null){
|
|
|
+ archiveFile.setNodeId(String.valueOf(archiveTreeContractTemp.getId()));
|
|
|
+ }
|
|
|
+ archiveFile.setFileNumber(String.valueOf(file.getId()));
|
|
|
+ archiveFile.setFileName(file.getTitle());
|
|
|
+ archiveFile.setFileTime(file.getUploadTime());
|
|
|
+ archiveFile.setFileUrl(file.getImageUrl());
|
|
|
+ archiveFile.setPdfFileUrl(file.getPdfUrl());
|
|
|
+ archiveFile.setFilePage(1);
|
|
|
+ archiveFile.setIsApproval(0);
|
|
|
+ archiveFile.setIsCertification(1);
|
|
|
+ archiveFile.setIsNeedCertification(0);
|
|
|
+ archiveFile.setDutyUser(file.getShootingUser());
|
|
|
+ archiveFile.setCreateUser(file.getCreateUser());
|
|
|
+ archiveFile.setCreateDept(file.getCreateDept());
|
|
|
+ archiveFile.setCreateTime(file.getCreateTime());
|
|
|
+ archiveFile.setUpdateUser(file.getUpdateUser());
|
|
|
+ archiveFile.setUpdateTime(file.getUpdateTime());
|
|
|
+ archiveFile.setStatus(0);
|
|
|
+ archiveFile.setIsDeleted(0);
|
|
|
+ archiveFile.setFileType(Long.valueOf(file.getType()));
|
|
|
+ archiveFile.setFilmingTime(file.getShootingTime());
|
|
|
+ archiveFile.setFilmingorTime(file.getShootingTime());
|
|
|
+ archiveFile.setPicCode(file.getPhotoCode());
|
|
|
+ archiveFile.setFilmCode(file.getFilmCode());
|
|
|
+ archiveFile.setReferCode(file.getSeeAlsoCode());
|
|
|
+ archiveFile.setWidth(file.getFileWidth());
|
|
|
+ archiveFile.setHeight(file.getFileHeight());
|
|
|
+ // 创建 LocalDateTime 时间爱你
|
|
|
+ LocalDateTime localDateTime = new Date().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
+ archiveFile.setFtime(localDateTime);
|
|
|
+ archiveFile.setUtime(localDateTime);
|
|
|
+ archiveFile.setSort(0);
|
|
|
+ archiveFile.setPageNum("1");
|
|
|
+ archiveFile.setFileSize(convertSizeToBytes(file.getFileSize()));
|
|
|
+ archiveFile.setSourceType(1);
|
|
|
+ archiveFile.setIsElement(0);
|
|
|
+ archiveFile.setRectification(0);
|
|
|
+ archiveFile.setMWbsTreeContractPKeyId(file.getWbsId());
|
|
|
+ archiveFile.setUImageClassificationFileId(file.getId());
|
|
|
+ archiveFile.setArchiveFileStorageType(StorageTypeEnum.SOUND_IMAGE.getCode());
|
|
|
+ archiveFile.setNodeTreeStructure(file.getStorageDirectoryFormat());
|
|
|
+ archiveFile.setDateName(DateFormatUtils.format(file.getCreateTime(), "yyyyMMdd"));
|
|
|
+ return archiveFile;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * imageClassificationFile里面的fileSize,是已经转换过的(230.6MB),是字符串
|
|
|
+ * 而archiveFile里面的fileSize是纯数字大小,现在要转换回来
|
|
|
+ */
|
|
|
+ private static Long convertSizeToBytes(String size) {
|
|
|
+ Long value = Double.valueOf(size.replaceAll("[^\\d.]", "")).longValue();
|
|
|
+ String unit = size.replaceAll("[\\d.]", "").trim();
|
|
|
+ switch (unit) {
|
|
|
+ case "B":
|
|
|
+ return value;
|
|
|
+ case "KB":
|
|
|
+ return value * 1024;
|
|
|
+ case "MB":
|
|
|
+ return value * 1024 * 1024;
|
|
|
+ case "GB":
|
|
|
+ return value * 1024 * 1024 * 1024;
|
|
|
+ default:
|
|
|
+ throw new IllegalArgumentException("Invalid size unit: " + unit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新刷新整个树结构
|
|
|
+ */
|
|
|
+ public void refreshTreeStructure(ArchiveTreeContractVO archiveTreeContractVO, Long id, String ancestors) {
|
|
|
+ archiveTreeContractVO.setParentId(id);
|
|
|
+ archiveTreeContractVO.setAncestors(ancestors+","+id);
|
|
|
+ List<ArchiveTreeContractVO> children = archiveTreeContractVO.getChildren();
|
|
|
+ if (CollectionUtil.isNotEmpty(children)) {
|
|
|
+ for (ArchiveTreeContractVO child : children) {
|
|
|
+ refreshTreeStructure(child, archiveTreeContractVO.getId(), archiveTreeContractVO.getAncestors());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 现有的树与老的树做合并
|
|
|
+ */
|
|
|
+ public void archiveAndOldTreeMergeData(List<ArchiveTreeContractVO> mergeList, Map<Long, ArchiveTreeContract> archiveTreeContractMap, TreeStructureEnum treeStructureEnum) {
|
|
|
+ if (CollectionUtil.isEmpty(mergeList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 循环遍历,将已有的赋值,随后再次将整个树的上下节点,重新刷新
|
|
|
+ for (ArchiveTreeContractVO archiveTreeContractVO : mergeList) {
|
|
|
+ ArchiveTreeContract archiveTreeContract = null;
|
|
|
+ if(treeStructureEnum.getCode() == TreeStructureEnum.ORDINARY_TREE.getCode()){
|
|
|
+ archiveTreeContract = archiveTreeContractMap.get(archiveTreeContractVO.getExtKeyId());
|
|
|
+ } else if(treeStructureEnum.getCode() == TreeStructureEnum.DATE_TREE.getCode()) {
|
|
|
+ archiveTreeContract = archiveTreeContractMap.get(archiveTreeContractVO.getFullName());
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(archiveTreeContract)){
|
|
|
+ archiveTreeContractVO.setId(archiveTreeContract.getId());
|
|
|
+ archiveTreeContractVO.setParentId(archiveTreeContract.getParentId());
|
|
|
+ archiveTreeContractVO.setAncestors(archiveTreeContract.getAncestors());
|
|
|
+ }
|
|
|
+ archiveAndOldTreeMergeData(archiveTreeContractVO.getChildren(), archiveTreeContractMap, treeStructureEnum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 刷新归档树
|
|
|
+ */
|
|
|
+ void refreshArchiveTreeContract(List<ArchiveTreeContract> saveArchiveTreeContractList, List<Map> updateArchiveTreeContractList,
|
|
|
+ List<ArchiveTreeContract> deleteArchiveTreeContractList) {
|
|
|
+ if (CollectionUtil.isNotEmpty(saveArchiveTreeContractList)) {
|
|
|
+ archiveTreeContractMapper.batchInsertArchiveTreeContract(saveArchiveTreeContractList);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(updateArchiveTreeContractList)) {
|
|
|
+ archiveTreeContractMapper.batchUpdateArchiveTreeContract(updateArchiveTreeContractList);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(deleteArchiveTreeContractList)) {
|
|
|
+ List<Long> idList = deleteArchiveTreeContractList.stream().map(ArchiveTreeContract::getId).collect(Collectors.toList());
|
|
|
+ archiveTreeContractMapper.batchDeleteArchiveTreeContractByIdList(idList, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据合同段id查询声像文件
|
|
|
+ */
|
|
|
+ public List<ImageClassificationFileDTO> getImageClassificationFileListByContractId(Long contractId) {
|
|
|
+ return imageClassificationFileClient.getImageClassificationFileListByContractId(contractId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 遍历循环,获取差异,并输出三个集合(归档树的ExtKeyId = Wbs树的pKeyId)
|
|
|
+ */
|
|
|
+ private static void diffTrees(List<ArchiveTreeContract> originalArchiveTreeContractList, List<ArchiveTreeContract> newArchiveTreeContractList, Map<Long, ArchiveTreeContract> originalArchiveTreeContractMap,
|
|
|
+ Map<Long, ArchiveTreeContract> newArchiveTreeContractMap, List<ArchiveTreeContract> insertions,
|
|
|
+ List<ArchiveTreeContract> deletions, List<Map> modifications) {
|
|
|
+ for (ArchiveTreeContract originalArchiveTreeContract : originalArchiveTreeContractList) {
|
|
|
+ if (!newArchiveTreeContractMap.containsKey(originalArchiveTreeContract.getExtKeyId())) {
|
|
|
+ deletions.add(originalArchiveTreeContract);
|
|
|
+ } else {
|
|
|
+ ArchiveTreeContract node2 = newArchiveTreeContractMap.get(originalArchiveTreeContract.getExtKeyId());
|
|
|
+ if (originalArchiveTreeContract.getExtKeyId().equals(node2.getExtKeyId())) {
|
|
|
+ // 更新修改数据
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("id", originalArchiveTreeContract.getId());
|
|
|
+ map.put("parentId", node2.getParentId());
|
|
|
+ map.put("ancestors", node2.getAncestors());
|
|
|
+ map.put("nodeName", node2.getNodeName());
|
|
|
+ map.put("nodeType", node2.getNodeType());
|
|
|
+ map.put("fullName", node2.getFullName());
|
|
|
+ map.put("treeStructure", node2.getTreeStructure());
|
|
|
+ modifications.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ArchiveTreeContract newArchiveTreeContract : newArchiveTreeContractList) {
|
|
|
+ if (!originalArchiveTreeContractMap.containsKey(newArchiveTreeContract.getExtKeyId())) {
|
|
|
+ insertions.add(newArchiveTreeContract);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建节点map
|
|
|
+ */
|
|
|
+ private static Map<Long, ArchiveTreeContract> buildNodeMap(List<ArchiveTreeContract> tree) {
|
|
|
+ Map<Long, ArchiveTreeContract> map = new HashMap<>();
|
|
|
+ for (ArchiveTreeContract node : tree) {
|
|
|
+ map.put(node.getExtKeyId(), node);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建时间map
|
|
|
+ */
|
|
|
+ private static Map<Long, ArchiveTreeContract> buildDateMap(List<ArchiveTreeContract> tree) {
|
|
|
+ Map<Long, ArchiveTreeContract> map = new HashMap<>();
|
|
|
+ for (ArchiveTreeContract node : tree) {
|
|
|
+ // 时间树中,fullName表示该节点的详细时间,如20240109,唯一性
|
|
|
+ map.put(Long.valueOf(node.getFullName()), node);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
|
|
|
}
|