|
@@ -10,10 +10,13 @@ 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.entity.TrialDetectionData;
|
|
|
+import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
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.business.vo.TrialSelfInspectionRecordFileVO;
|
|
|
import org.springblade.common.utils.ForestNodeMergerEx;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -28,10 +31,14 @@ import org.springblade.manager.mapper.ArchiveTreeContractMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.utils.ForestNodeMerger;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
+import org.springblade.resource.entity.Attach;
|
|
|
import org.springblade.system.entity.DictBiz;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
@@ -70,6 +77,8 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -769,6 +778,9 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
* 同步合同段数据时,统一校验通道,3声像资料,6日志资料,2试验资料
|
|
|
*/
|
|
|
public void syncDataCheck(Long projectId, Long contractId, Long nodeId,Integer associationType) {
|
|
|
+ if (ObjectUtil.isEmpty(contractId)){
|
|
|
+ throw new ServiceException("未获取到当前同步节点的合同段信息,请查看是否当前节点在合同段节点下");
|
|
|
+ }
|
|
|
// 合同信息
|
|
|
ContractInfo contractInfo = contractInfoService.getById(contractId);
|
|
|
// 判断是否正在同步
|
|
@@ -869,10 +881,140 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
/**
|
|
|
* 同步某个合同段的试验资料到归档
|
|
|
+ * 因为试验系统没有做完,所以目前某些类型的同步会同步所有数据,并且也缺失一些文件的基础信息,
|
|
|
+ * 如大小,页码等,等做完之后,再完善。目前整体功能没有问题
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void syncContractTrialData(Long projectId, ContractInfo contractInfo, ArchiveTreeContract archiveTreeContract) {
|
|
|
+ //获取勾选的试验类型
|
|
|
+ String contractTrialType = archiveTreeContract.getContractTrialType();
|
|
|
+ if (StringUtils.isBlank(contractTrialType)){
|
|
|
+ throw new ServiceException("当前节点未配置同步试验资料类型");
|
|
|
+ }
|
|
|
+ List<Integer> TrialType = Arrays.stream(contractTrialType.split(","))
|
|
|
+ .map(Integer::parseInt) // 将每个字符串转换为Integer
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Long contractId = contractInfo.getId();
|
|
|
+ String tenantId = AuthUtil.getTenantId();
|
|
|
+ log.info("同步试验文件,projectId:"+projectId+",contractId:"+contractId+",nodeId:"+archiveTreeContract.getId());
|
|
|
+ //先删除试验资料节点下的所有节点与文件
|
|
|
+ archiveTreeContractMapper.removeImageNodeFile(archiveTreeContract.getContractId(),archiveTreeContract.getId());
|
|
|
+ archiveTreeContractMapper.removeImageNodeChild(archiveTreeContract.getContractId(),archiveTreeContract.getId());
|
|
|
+
|
|
|
+ //查出所有试验节点,节点是共用项目级的
|
|
|
+ List<ArchiveSyncTrialVO> trials = archiveTreeContractMapper.getAllTrialNode(projectId);
|
|
|
+ //试验节点按照类型分组
|
|
|
+ Map<Integer, List<ArchiveSyncTrialVO>> trialsMap = trials.stream().collect(Collectors.groupingBy(ArchiveSyncTrialVO::getNodeType));
|
|
|
+ //查出所有的试验报告,报告是合同段独立的
|
|
|
+ List<TrialSelfInspectionRecord> records = archiveTreeContractMapper.getAllTrialRecord(contractId);
|
|
|
+ //试验报告按照节点分组
|
|
|
+ Map<Long, List<TrialSelfInspectionRecord>> recordsMap = records.stream().collect(Collectors.groupingBy(TrialSelfInspectionRecord::getNodeId));
|
|
|
+ List<ArchiveTreeContract> addNode = new ArrayList<>();
|
|
|
+ List<ArchiveFile> addFile = new ArrayList<>();
|
|
|
+ /**循环指定试验类型 */
|
|
|
+ for (Integer type : TrialType) {
|
|
|
+ //根据类型获取试验节点
|
|
|
+ List<ArchiveSyncTrialVO> trialVOS = trialsMap.get(type);
|
|
|
+ if (CollectionUtil.isEmpty(trialVOS)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //循环试验节点
|
|
|
+ for (ArchiveSyncTrialVO vo : trialVOS) {
|
|
|
+ //把节点转换为档案节点,挂载到同步节点下
|
|
|
+ ArchiveTreeContract trialNode = createTypeNode(vo.getNodeName(), archiveTreeContract);
|
|
|
+ addNode.add(trialNode);
|
|
|
+ //获取出节点下面的报告,并转换为档案文件
|
|
|
+ List<TrialSelfInspectionRecord> files = recordsMap.get(vo.getPKeyId());
|
|
|
+ if (CollectionUtil.isEmpty(files)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //挂载到子节点下
|
|
|
+ List<ArchiveFile> newArchiveFileList = files.stream().map(file -> {
|
|
|
+ ArchiveFile archiveFile = trialFileCovertArchiveFile(file, trialNode);
|
|
|
+ return archiveFile;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ addFile.addAll(newArchiveFileList);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ /**单独处理外委和第三方报告 */
|
|
|
+ if (contractTrialType.contains("98")){
|
|
|
+ //获取所有的外委和第三方节点
|
|
|
+ List<TrialClassificationConfiguration> threeTestNodes = archiveTreeContractMapper.getAllThreeTestNode();
|
|
|
+ //获取出合同段所有的检测报告
|
|
|
+ List<TrialDetectionData> dataList = archiveTreeContractMapper.getAllTrialTestRecord(contractId);
|
|
|
+ //检测报告,按照节点分组
|
|
|
+ Map<Long, List<TrialDetectionData>> dataMap = dataList.stream().collect(Collectors.groupingBy(l -> l.getNodeId()));
|
|
|
+ //循环所有节点
|
|
|
+ for (TrialClassificationConfiguration vo : threeTestNodes) {
|
|
|
+ //把节点转换为档案节点,挂载到同步节点下
|
|
|
+ ArchiveTreeContract trialNode = createTypeNode(vo.getNodeName(), archiveTreeContract);
|
|
|
+ addNode.add(trialNode);
|
|
|
+ //获取出节点下面的报告,并转换为档案文件
|
|
|
+ List<TrialDetectionData> files = dataMap.get(vo.getId());
|
|
|
+ if (CollectionUtil.isEmpty(files)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //挂载到子节点下
|
|
|
+ List<ArchiveFile> newArchiveFileList = files.stream().map(file -> {
|
|
|
+ ArchiveFile archiveFile = trialTestFileCovertArchiveFile(file, trialNode);
|
|
|
+ return archiveFile;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ addFile.addAll(newArchiveFileList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**单独处理原材料资质证书 */
|
|
|
+ if (contractTrialType.contains("99")){
|
|
|
+ //获取所有的原材节点
|
|
|
+ List<ArchiveSyncTrialVO> trialVOS = trialsMap.get(52);
|
|
|
+ if (CollectionUtil.isNotEmpty(trialVOS)){
|
|
|
+ //查询出整个系统的附件,设计问题
|
|
|
+ Map<String, Attach> maps = jdbcTemplate.query("select link,original_name from blade_attach", new BeanPropertyRowMapper<>(Attach.class)).stream().collect(Collectors.toMap(Attach::getLink, Attach -> Attach, (obj1, obj2) -> obj1));
|
|
|
+ //获取出所有节点id
|
|
|
+ List<Long> nodeIds = trialVOS.stream().map(l -> l.getPKeyId()).collect(Collectors.toList());
|
|
|
+ //根据节点id,查询出所有的报告id
|
|
|
+ List<Long> recordIds = records.stream().filter(l -> nodeIds.contains(l.getNodeId())).map(l -> l.getId()).collect(Collectors.toList());
|
|
|
+ //根据报告id,查询出所有的报告附件
|
|
|
+ List<TrialSelfInspectionRecordFileVO> fileVOS = archiveTreeContractMapper.getAllTrialRecordFile(recordIds);
|
|
|
+ //报告附件按照节点id分组
|
|
|
+ Map<Long, List<TrialSelfInspectionRecordFileVO>> fileMap = fileVOS.stream().collect(Collectors.groupingBy(l -> l.getNodeId()));
|
|
|
+ //循环原材节点
|
|
|
+ for (ArchiveSyncTrialVO vo : trialVOS) {
|
|
|
+ //把节点转换为档案节点,挂载到同步节点下
|
|
|
+ ArchiveTreeContract trialNode = createTypeNode(vo.getNodeName(), archiveTreeContract);
|
|
|
+ addNode.add(trialNode);
|
|
|
+ //获取出节点下面的报告下面的附件,并转换为档案文件
|
|
|
+ List<TrialSelfInspectionRecordFileVO> files = fileMap.get(vo.getPKeyId());
|
|
|
+ if (CollectionUtil.isEmpty(files)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //上个开发太懒,敷衍了事,重新设置附件相关值
|
|
|
+ for (TrialSelfInspectionRecordFileVO file : files) {
|
|
|
+ Attach attach = maps.get(file.getUrl());
|
|
|
+ if (attach != null){
|
|
|
+ file.setFileName(attach.getOriginalName());
|
|
|
+ file.setCreateTime(attach.getCreateTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //挂载到子节点下
|
|
|
+ List<ArchiveFile> newArchiveFileList = files.stream().map(file -> {
|
|
|
+ ArchiveFile archiveFile = trialFileCovertArchiveFile2(file, trialNode);
|
|
|
+ return archiveFile;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ addFile.addAll(newArchiveFileList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (addNode.size() > 0){
|
|
|
+ addNode.stream().forEach(l->l.setTenantId(tenantId));
|
|
|
+ archiveTreeContractMapper.batchInsertArchiveTreeContract(addNode);
|
|
|
+ }
|
|
|
+ if (addFile.size() > 0){
|
|
|
+ archiveFileClient.addArchiveFile(addFile);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -883,7 +1025,7 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
//获取勾选的日志类型
|
|
|
String contractLogType = archiveTreeContract.getContractLogType();
|
|
|
if (StringUtils.isBlank(contractLogType)){
|
|
|
- throw new ServiceException("当前节点未配置同步日志类型");
|
|
|
+ throw new ServiceException("当前节点未配置同步日志资料类型");
|
|
|
}
|
|
|
List<Integer> logType = Arrays.stream(contractLogType.split(","))
|
|
|
.map(Integer::parseInt) // 将每个字符串转换为Integer
|
|
@@ -904,14 +1046,18 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
List<ArchiveFile> addFile = new ArrayList<>();
|
|
|
//获取合同段所有的日志,并且附带类型
|
|
|
List<ArchiveSyncLogVO> logs = wbsTreePrivateService.getContractAllLog(contractId);
|
|
|
+ if (CollectionUtil.isEmpty(logs)){
|
|
|
+ throw new ServiceException("当前合同段下没有日志资料");
|
|
|
+ }
|
|
|
//日志按照类型分组
|
|
|
Map<Integer, List<ArchiveSyncLogVO>> logMap = logs.stream().collect(Collectors.groupingBy(ArchiveSyncLogVO::getLogType));
|
|
|
- //循环选择的日志类型,生成子节点
|
|
|
+ //循环选择的日志类型
|
|
|
for (Integer type : logType) {
|
|
|
String typeName = dictMap.get(type);
|
|
|
if (StringUtils.isBlank(typeName)){
|
|
|
throw new ServiceException("日志存在字典中未配置的类型,请检查后再同步");
|
|
|
}
|
|
|
+ //生成子节点
|
|
|
ArchiveTreeContract logNode = createTypeNode(typeName, archiveTreeContract);
|
|
|
/** 如果到时候修改需求,只显示有日志的,则下面文件存在再add*/
|
|
|
addNode.add(logNode);
|
|
@@ -969,6 +1115,9 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
|
|
|
//获取合同下声像资料所有文件
|
|
|
List<ImageClassificationFileDTO> imageClassificationFileList = imageClassificationFileClient.getImageClassificationFileListByContractId(contractId);
|
|
|
+ if (CollectionUtil.isEmpty(imageClassificationFileList)){
|
|
|
+ throw new ServiceException("当前合同段下没有声像资料");
|
|
|
+ }
|
|
|
Map<Long, List<ImageClassificationFileDTO>> imageMap = imageClassificationFileList.stream().collect(Collectors.groupingBy(l -> l.getClassifyId()));
|
|
|
|
|
|
//获取声像资料分类,生成声像资料下级节点
|
|
@@ -1124,6 +1273,129 @@ public class ArchiveTreeContractSyncImpl {
|
|
|
return archiveFile;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 质检试验资料附件 转换为 档案文件
|
|
|
+ */
|
|
|
+ private ArchiveFile trialFileCovertArchiveFile2(TrialSelfInspectionRecordFileVO vo,ArchiveTreeContract parentNode)
|
|
|
+ {
|
|
|
+ ArchiveFile archiveFile = new ArchiveFile();
|
|
|
+ archiveFile.setId(SnowFlakeUtil.getId());
|
|
|
+ archiveFile.setProjectId(String.valueOf(parentNode.getProjectId()));
|
|
|
+ archiveFile.setContractId(String.valueOf(parentNode.getContractId()));
|
|
|
+ archiveFile.setNodeId(parentNode.getId()+"");
|
|
|
+// archiveFile.setFileNumber(vo.getReportNo());
|
|
|
+ archiveFile.setFileName(vo.getFileName());
|
|
|
+ if (vo.getCreateTime() != null) {
|
|
|
+ archiveFile.setFileTime(new SimpleDateFormat("yyyy-MM-dd").format(vo.getCreateTime()));
|
|
|
+ }
|
|
|
+ archiveFile.setFileUrl(vo.getUrl());
|
|
|
+ archiveFile.setPdfFileUrl(vo.getUrl());
|
|
|
+ archiveFile.setFilePage(1);
|
|
|
+ archiveFile.setIsApproval(0);
|
|
|
+ archiveFile.setIsCertification(1);
|
|
|
+ archiveFile.setIsNeedCertification(0);
|
|
|
+// archiveFile.setDutyUser(vo.getTrialUserName());
|
|
|
+// archiveFile.setCreateUser(vo.getCreateUser());
|
|
|
+ archiveFile.setStatus(0);
|
|
|
+ archiveFile.setIsDeleted(0);
|
|
|
+ archiveFile.setFileType(2L);
|
|
|
+ // 创建 LocalDateTime
|
|
|
+ LocalDateTime localDateTime = new Date().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
+ archiveFile.setFtime(localDateTime);
|
|
|
+ archiveFile.setUtime(localDateTime);
|
|
|
+ archiveFile.setSort(0);
|
|
|
+ archiveFile.setPageNum("1");
|
|
|
+ archiveFile.setSourceType(1);
|
|
|
+ archiveFile.setIsElement(0);
|
|
|
+ archiveFile.setRectification(0);
|
|
|
+ archiveFile.setArchiveFileStorageType(StorageTypeEnum.SOUND_IMAGE.getCode());
|
|
|
+ return archiveFile;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 质检试验检测资料 转换为 档案文件
|
|
|
+ */
|
|
|
+ private ArchiveFile trialTestFileCovertArchiveFile(TrialDetectionData vo,ArchiveTreeContract parentNode)
|
|
|
+ {
|
|
|
+ ArchiveFile archiveFile = new ArchiveFile();
|
|
|
+ archiveFile.setId(SnowFlakeUtil.getId());
|
|
|
+ archiveFile.setProjectId(String.valueOf(parentNode.getProjectId()));
|
|
|
+ archiveFile.setContractId(String.valueOf(parentNode.getContractId()));
|
|
|
+ archiveFile.setNodeId(parentNode.getId()+"");
|
|
|
+ archiveFile.setFileNumber(vo.getReportNo());
|
|
|
+ archiveFile.setFileName(vo.getMaterialName()+vo.getSpecificationModel());
|
|
|
+ if (vo.getReportDate() != null) {
|
|
|
+ archiveFile.setFileTime(new SimpleDateFormat("yyyy-MM-dd").format(vo.getReportDate()));
|
|
|
+ }
|
|
|
+ archiveFile.setFileUrl(vo.getReportAttachmentUrl());
|
|
|
+ archiveFile.setPdfFileUrl(vo.getReportAttachmentUrl());
|
|
|
+ archiveFile.setFilePage(1);
|
|
|
+ archiveFile.setIsApproval(0);
|
|
|
+ archiveFile.setIsCertification(1);
|
|
|
+ archiveFile.setIsNeedCertification(0);
|
|
|
+ archiveFile.setDutyUser(vo.getUserName());
|
|
|
+ archiveFile.setCreateUser(vo.getCreateUser());
|
|
|
+ archiveFile.setStatus(0);
|
|
|
+ archiveFile.setIsDeleted(0);
|
|
|
+ archiveFile.setFileType(2L);
|
|
|
+ // 创建 LocalDateTime
|
|
|
+ LocalDateTime localDateTime = new Date().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
+ archiveFile.setFtime(localDateTime);
|
|
|
+ archiveFile.setUtime(localDateTime);
|
|
|
+ archiveFile.setSort(0);
|
|
|
+ archiveFile.setPageNum("1");
|
|
|
+ archiveFile.setSourceType(1);
|
|
|
+ archiveFile.setIsElement(0);
|
|
|
+ archiveFile.setRectification(0);
|
|
|
+ archiveFile.setArchiveFileStorageType(StorageTypeEnum.SOUND_IMAGE.getCode());
|
|
|
+ return archiveFile;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 质检试验资料 转换为 档案文件
|
|
|
+ */
|
|
|
+ private ArchiveFile trialFileCovertArchiveFile(TrialSelfInspectionRecord vo,ArchiveTreeContract parentNode)
|
|
|
+ {
|
|
|
+ ArchiveFile archiveFile = new ArchiveFile();
|
|
|
+ archiveFile.setId(SnowFlakeUtil.getId());
|
|
|
+ archiveFile.setProjectId(String.valueOf(parentNode.getProjectId()));
|
|
|
+ archiveFile.setContractId(String.valueOf(parentNode.getContractId()));
|
|
|
+ archiveFile.setNodeId(parentNode.getId()+"");
|
|
|
+ archiveFile.setFileNumber(vo.getReportNo());
|
|
|
+ archiveFile.setFileName(StringUtils.isNotBlank(vo.getSpecificationModel())?vo.getSpecificationModel():vo.getTrialProjectName());
|
|
|
+ if (vo.getReportDate() != null) {
|
|
|
+ archiveFile.setFileTime(new SimpleDateFormat("yyyy-MM-dd").format(vo.getReportDate()));
|
|
|
+ }
|
|
|
+ archiveFile.setFileUrl(vo.getPdfUrl());
|
|
|
+ archiveFile.setPdfFileUrl(vo.getPdfUrl());
|
|
|
+ archiveFile.setFilePage(1);
|
|
|
+ archiveFile.setIsApproval(0);
|
|
|
+ archiveFile.setIsCertification(1);
|
|
|
+ archiveFile.setIsNeedCertification(0);
|
|
|
+ archiveFile.setDutyUser(vo.getTrialUserName());
|
|
|
+ archiveFile.setCreateUser(vo.getCreateUser());
|
|
|
+ archiveFile.setStatus(0);
|
|
|
+ archiveFile.setIsDeleted(0);
|
|
|
+ archiveFile.setFileType(2L);
|
|
|
+ // 创建 LocalDateTime
|
|
|
+ LocalDateTime localDateTime = new Date().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
+ archiveFile.setFtime(localDateTime);
|
|
|
+ archiveFile.setUtime(localDateTime);
|
|
|
+ archiveFile.setSort(0);
|
|
|
+ archiveFile.setPageNum("1");
|
|
|
+ archiveFile.setSourceType(1);
|
|
|
+ archiveFile.setIsElement(0);
|
|
|
+ archiveFile.setRectification(0);
|
|
|
+ archiveFile.setArchiveFileStorageType(StorageTypeEnum.SOUND_IMAGE.getCode());
|
|
|
+ return archiveFile;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 质检日志资料 转换为 档案文件
|
|
|
*/
|