瀏覽代碼

Merge remote-tracking branch 'origin/master'

chenr 2 月之前
父節點
當前提交
d9c16d0baf
共有 18 個文件被更改,包括 655 次插入259 次删除
  1. 2 2
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveTree.java
  2. 34 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveSyncWbsVO.java
  3. 8 11
      blade-service/blade-business/src/main/java/org/springblade/business/controller/FixedFlowController.java
  4. 2 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java
  5. 3 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.java
  6. 13 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.xml
  7. 2 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ImageClassificationConfigMapper.java
  8. 9 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ImageClassificationConfigMapper.xml
  9. 2 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml
  10. 3 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IImageClassificationConfigService.java
  11. 538 232
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractSyncImpl.java
  12. 1 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java
  13. 1 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  14. 18 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ImageClassificationConfigServiceImpl.java
  15. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java
  16. 7 6
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml
  17. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.java
  18. 10 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.xml

+ 2 - 2
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveTree.java

@@ -66,7 +66,7 @@ public class ArchiveTree extends BaseEntity {
     /**
      * 关联类型
      */
-    @ApiModelProperty(value = "关联类型")
+    @ApiModelProperty(value = "关联类型,对应业务字典的关联类型")
     private Integer associationType;
 
     /**
@@ -130,7 +130,7 @@ public class ArchiveTree extends BaseEntity {
     /**
      * 存储类型
      */
-    @ApiModelProperty(value = "存储类型")
+    @ApiModelProperty(value = "存储类型,对应业务字典里面的存储类型")
     private Integer storageType;
     /**
      * 扩展类型

+ 34 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveSyncWbsVO.java

@@ -1,7 +1,15 @@
 package org.springblade.manager.vo;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springblade.core.tool.node.INode;
+import org.springblade.meter.vo.WbsNodeVO;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @Param   档案同步质检影像资料VO
@@ -9,12 +17,37 @@ import lombok.Data;
  * @Date 2024/9/12 16:02
  **/
 @Data
-public class ArchiveSyncWbsVO {
+public class ArchiveSyncWbsVO implements INode<ArchiveSyncWbsVO> {
+
+    /**
+     * 子孙节点
+     */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private List<ArchiveSyncWbsVO> children;
+
+    /**
+     * 是否有子孙节点
+     */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private Boolean hasChildren;
+
+    @Override
+    public List<ArchiveSyncWbsVO> getChildren() {
+        if (this.children == null) {
+            this.children = new ArrayList<>();
+        }
+        return this.children;
+    }
 
     @ApiModelProperty(value = "主键id")
     private Long pKeyId;
 
+    @ApiModelProperty(value = "主键id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
     @ApiModelProperty(value = "父主键id")
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long parentId;
 
     @ApiModelProperty(value = "节点名称")

+ 8 - 11
blade-service/blade-business/src/main/java/org/springblade/business/controller/FixedFlowController.java

@@ -1,19 +1,21 @@
 package org.springblade.business.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
-
-import javax.validation.Valid;
-
 import org.apache.commons.lang.StringUtils;
+import org.springblade.business.entity.FixedFlow;
 import org.springblade.business.entity.FixedFlowLink;
 import org.springblade.business.entity.Task;
 import org.springblade.business.service.IFixedFlowLinkService;
+import org.springblade.business.service.IFixedFlowService;
+import org.springblade.business.vo.FixedFlowVO;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
@@ -29,13 +31,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 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;
-import org.springblade.business.entity.FixedFlow;
-import org.springblade.business.vo.FixedFlowVO;
-import org.springblade.business.service.IFixedFlowService;
-import org.springblade.core.boot.ctrl.BladeController;
 
+import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -74,7 +71,7 @@ public class FixedFlowController extends BladeController {
         //获取当前系统配置的角色划分
         List<RoleVO> roleVOS = this.sysClient.search().getData();
         //获取项目人员
-        List<SaveUserInfoByProjectDTO> contractUserList = this.projectAssignmentUserClient.queryContractDownAllUser(contractId, 1);
+        List<SaveUserInfoByProjectDTO> contractUserList = this.projectAssignmentUserClient.queryContractDownAllUser(contractId, 2);
 
         //先处理管理员
         for (RoleVO vos : roleVOS) {

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -1195,11 +1195,11 @@ public class ExecutorMeter extends FormulaExecutor {
                      }
                      payItemZj.add(startPay);
                      payItemZj.add(new InterimPaymentCertificate("扣回动员预付款"));
-                     InterimPaymentCertificate clsbdfk=new InterimPaymentCertificate("材料设备垫付款");
+                     InterimPaymentCertificate clsbdfk=new InterimPaymentCertificate("材料付款");
                      /*材料预付款关联*/
                      clsbdfk.setCurrentPeriodPay(materialSum);
                      payItemZj.add(clsbdfk);
-                     payItemZj.add(new InterimPaymentCertificate("扣回材料设备垫付款"));
+                     payItemZj.add(new InterimPaymentCertificate("扣回材料付款"));
                       blj=new InterimPaymentCertificate("保留金",MINUS_ONE);
                      payItemZj.add(blj);
                      InterimPaymentCertificate thblj=new InterimPaymentCertificate("返回保留金");

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.java

@@ -154,4 +154,7 @@ public interface ArchiveTreeContractMapper extends BaseMapper<ArchiveTreeContrac
     List<ArchiveTreeContractDTO> getArchiveTreeContractDto(@Param("dtos")List<JiLinQueryDto>dtos,@Param("projectId")Long projectId);
 
 
+    void removeImageNodeChild(@Param("contractId") Long contractId,@Param("id") Long id);
+
+    void removeImageNodeFile(@Param("contractId") Long contractId,@Param("id") Long id);
 }

+ 13 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.xml

@@ -50,6 +50,19 @@
         <result column="archive_name_suffix" property="archiveNameSuffix"/>
         <result column="ext_key_id" property="extKeyId"/>
     </resultMap>
+    <delete id="removeImageNodeChild">
+        delete from m_archive_tree_contract
+        where  contract_id = #{contractId} and is_deleted = 0 and FIND_IN_SET(#{id},ancestors) > 0
+    </delete>
+    <delete id="removeImageNodeFile">
+        delete from u_archive_file
+        where  contract_id = #{contractId}
+          and node_id in
+        (
+            select id from m_archive_tree_contract
+            where  contract_id = #{contractId} and is_deleted = 0 and FIND_IN_SET(#{id},ancestors) > 0
+            )
+    </delete>
 
 
     <select id="selectArchiveTreeContractPage" resultMap="archiveTreeContractResultMap">

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

@@ -2,6 +2,7 @@ package org.springblade.manager.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
 import org.springblade.manager.entity.ImageClassificationConfig;
 import org.springblade.manager.vo.ImageClassificationConfigVO;
 
@@ -11,4 +12,5 @@ public interface ImageClassificationConfigMapper extends BaseMapper<ImageClassif
 
     List<ImageClassificationConfigVO> selectImageClassificationConfigPage(IPage page, ImageClassificationConfigVO imageClassificationConfig);
 
+    List<ImageClassificationConfig> selectByContractType(@Param("contractId") Long contractId,@Param("contractType") Integer contractType);
 }

+ 9 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ImageClassificationConfigMapper.xml

@@ -23,5 +23,14 @@
     <select id="selectImageClassificationConfigPage" resultMap="imageClassificationConfigResultMap">
         select * from m_image_classification_config where is_deleted = 0
     </select>
+    <select id="selectByContractType" resultType="org.springblade.manager.entity.ImageClassificationConfig">
+        select *
+        from m_image_classification_config
+        WHERE affiliated_party =#{contractType} and is_deleted = 0 and id not in (
+            select classify_id from u_image_classification_show
+            WHERE contract_id = #{contractId} and is_show = 0 and is_deleted = 0
+        )
+
+    </select>
 
 </mapper>

+ 2 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml

@@ -864,7 +864,8 @@
         ORDER BY a.type,a.sort
     </select>
     <select id="getContractAllNode" resultType="org.springblade.manager.vo.ArchiveSyncWbsVO">
-        select p_key_id,id,parent_id,ancestors,node_name,full_name,sort
+        select p_key_id,id,parent_id,node_name,full_name,sort
         from m_wbs_tree_contract where contract_id = #{contractId} and type = 1 and is_deleted = 0
+        ORDER BY sort,create_time
     </select>
 </mapper>

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IImageClassificationConfigService.java

@@ -12,4 +12,7 @@ public interface IImageClassificationConfigService extends BaseService<ImageClas
     IPage<ImageClassificationConfigVO> selectImageClassificationConfigPage(IPage<ImageClassificationConfigVO> page, ImageClassificationConfigVO imageClassificationConfig);
 
     List<ImageClassificationConfig> selectByType(String type);
+
+    //根据合同段id和合同段类型,获取当前合同影像资料分类
+    List<ImageClassificationConfig> selectByContractType(Long contractId,Integer contractType);
 }

+ 538 - 232
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractSyncImpl.java

@@ -20,23 +20,18 @@ 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.entity.*;
 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.IImageClassificationConfigService;
 import org.springblade.manager.service.IProjectInfoService;
+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.BeanUtils;
+import org.springblade.manager.vo.*;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -70,6 +65,12 @@ public class ArchiveTreeContractSyncImpl {
 
     private final ImageClassificationFileClient imageClassificationFileClient;
 
+    private final IImageClassificationConfigService imageClassificationConfigService;
+
+    private final IWbsTreeContractService wbsTreeContractService;
+
+
+
     /**
      * 普通同步
      *
@@ -800,58 +801,275 @@ public class ArchiveTreeContractSyncImpl {
         }
     }
 
+//    /**
+//     * 同步某个合同段的声像资料到归档
+//     */
+//    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);
+//    }
+
+    private void buildWbsContractTree(List<ArchiveSyncWbsVO> parentNode, Long parentId,String ancestors,Map<Long, List<ArchiveSyncWbsVO>> childMap,List<ArchiveSyncWbsVO> wbsRealList) {
+        if (parentNode != null && parentNode.size() > 0){
+            for (ArchiveSyncWbsVO parent : parentNode) {
+                List<ArchiveSyncWbsVO> childList = childMap.get(parent.getId());
+                parent.setId(parent.getPKeyId());
+                parent.setParentId(parentId);
+                parent.setAncestors(ancestors);
+                wbsRealList.add(parent);
+                if (childList != null && childList.size() > 0){
+                    parent.setChildren(childList);
+                    buildWbsContractTree(childList,parent.getPKeyId(),ancestors+","+parent.getPKeyId(),childMap,wbsRealList);
+                }
+            }
+        }
+    }
+
+
     /**
      * 同步某个合同段的声像资料到归档
      */
+    @Transactional
     public void syncSoundImageData(Long projectId, ContractInfo contractInfo, ArchiveTreeContract archiveTreeContract) {
         Long contractId = contractInfo.getId();
-
+        String tenantId = AuthUtil.getTenantId();
         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;
+        //先删除声像资料节点下的所有节点与文件
+        archiveTreeContractMapper.removeImageNodeFile(archiveTreeContract.getContractId(),archiveTreeContract.getId());
+        archiveTreeContractMapper.removeImageNodeChild(archiveTreeContract.getContractId(),archiveTreeContract.getId());
+
+        //获取合同段下所有WBS节点
+        List<ArchiveSyncWbsVO> wbsAllList = wbsTreeContractService.getContractAllNode(contractId);
+        //按照父id分组
+        Map<Long, List<ArchiveSyncWbsVO>> childMap = wbsAllList.stream().collect(Collectors.groupingBy(ArchiveSyncWbsVO::getParentId));
+        List<ArchiveSyncWbsVO> rootNode = childMap.get(0L);
+        //合同段重置后实际的数据
+        List<ArchiveSyncWbsVO> wbsRealList = new ArrayList<>();
+        //递归生成树,生成树的同时,重置父节点和祖级节点
+        long start1 = System.currentTimeMillis();
+        buildWbsContractTree(rootNode,0L,"0",childMap,wbsRealList);
+        long start2 = System.currentTimeMillis();
+        System.out.println("递归时间"+(start2 - start1));
+        Map<Long,ArchiveSyncWbsVO> keyMap = new HashMap<>();
+        for (ArchiveSyncWbsVO vo : wbsRealList) {
+            keyMap.put(vo.getPKeyId(),vo);
         }
 
-        // wbs转换archive树形集合
-        List<ArchiveTreeContract> wbsCovertArchiveTreeContractList = new ArrayList<>();
-
-        // wbs转换archive,并初始化值
-        getTreeList(AuthUtil.getTenantId(), wbsTrees.get(0), wbsCovertArchiveTreeContractList, archiveTreeContract, archiveTreeContract.getId());
+        //获取合同下声像资料所有文件
+        List<ImageClassificationFileDTO> imageClassificationFileList = imageClassificationFileClient.getImageClassificationFileListByContractId(contractId);
+        Map<Long, List<ImageClassificationFileDTO>> imageMap = imageClassificationFileList.stream().collect(Collectors.groupingBy(l -> l.getClassifyId()));
+
+        //获取声像资料分类,生成声像资料下级节点
+        List<ImageClassificationConfig> imageTypes = imageClassificationConfigService.selectByContractType(contractId,contractInfo.getContractType());
+
+        List<ArchiveTreeContract> addNode = new ArrayList<>();
+        List<ArchiveFile> addFile = new ArrayList<>();
+        //循环下级节点
+        for (ImageClassificationConfig imageType : imageTypes) {
+            //把分类生成为影像资料的下级节点
+            ArchiveTreeContract imageNode = createImageTypeNode(imageType,archiveTreeContract);
+            addNode.add(imageNode);
+            //如果当前分类下存在文件,则根据类型生成树,还是日期
+            List<ImageClassificationFileDTO> files = imageMap.get(imageType.getId());
+            if (CollectionUtil.isEmpty(files)){
+                continue;
+            }
+            if (imageType.getStorageDirectoryFormat() == 1){
+                /**部位存储,获取分类下面的文件,只生成必要的树,没有则跳过 */
+                //获取出文件对应的WBS节点,查询出所有节点
+                List<Long> wbsPIds = files.stream().filter(l-> l.getWbsId() != null).map(l -> l.getWbsId()).distinct().collect(Collectors.toList());
+                Set<Long> wbsIds = new HashSet<>();
+                for (Long wbsId : wbsPIds) {
+                    ArchiveSyncWbsVO vo = keyMap.get(wbsId);
+                    if (vo != null){
+                        wbsIds.add(vo.getId());
+                        String[] ids = vo.getAncestors().split(",");
+                        for (String id : ids) {
+                            wbsIds.add(Long.valueOf(id));
+                        }
+                    }
+                }
+                List<ArchiveSyncWbsVO> currentNodes = new ArrayList<>();
+                for (Long wbsId : wbsIds) {
+                    ArchiveSyncWbsVO vo = keyMap.get(wbsId);
+                    if (vo != null) {
+                        vo.setChildren(null);
+                        currentNodes.add(vo);
+                    }
+                }
+                ArchiveSyncWbsVO root = ForestNodeMerger.merge(currentNodes).stream()
+                        .filter(f -> f.getParentId() == 0L).collect(Collectors.toList()).get(0);
+                //从根节点递归,递归过程中,同步生成档案树, 并且生成档案树id和wbsPid的映射,后面单独为文件设置
+                List<ArchiveTreeContract> currentTypeAdd = new ArrayList<>();
+                recursionCreateArchiveTree(root,currentTypeAdd,imageNode);
+                //转换影像文件为档案文件,并挂到档案树下面
+                Map<Long, Long> wbsPidMapArchiveId = currentTypeAdd.stream().collect(Collectors.toMap(l -> l.getExtKeyId(), l -> l.getId()));
+                addNode.addAll(currentTypeAdd);
+                List<ArchiveFile> newArchiveFileList = files.stream().map(file -> {
+                    ArchiveFile archiveFile = imageFileCovertArchiveFile(file, wbsPidMapArchiveId);
+                    return archiveFile;
+                }).collect(Collectors.toList());
+                addFile.addAll(newArchiveFileList);
+                log.info("同步声像文件树-"+imageType.getClassfName()+": 节点"+currentNodes.size()+"个,节点下文件"+files.size()+"个");
+
+            }else if (imageType.getStorageDirectoryFormat() == 2){
+                /**日期存储,获取分类下面的文件,获取出所有的年,生成年节点,文件归到年节点下 */
+                //文件按照年份分组
+                Map<Integer, List<ImageClassificationFileDTO>> yearMap = files.stream().collect(Collectors.groupingBy(l -> l.getShootingTime().getYear()));
+                List<Integer> years = yearMap.keySet().stream().sorted().collect(Collectors.toList());
+                for (Integer year : years) {
+                    //生成年份节点,并添加进集合
+                    ArchiveTreeContract dateNode = createImageDateNode(imageNode, year);
+                    addNode.add(dateNode);
+                    //把文件设置进指定年份下
+                    List<ImageClassificationFileDTO> fileDTOS = yearMap.get(year);
+                    Map<Long, Long> wbsPidMapArchiveId = new HashMap<>();
+                    for (ImageClassificationFileDTO fileDTO : fileDTOS) {
+                        wbsPidMapArchiveId.put(fileDTO.getWbsId(),dateNode.getId());
+                    }
+                    List<ArchiveFile> newArchiveFileList = fileDTOS.stream().map(file -> {
+                        ArchiveFile archiveFile = imageFileCovertArchiveFile(file, wbsPidMapArchiveId);
+                        return archiveFile;
+                    }).collect(Collectors.toList());
+                    addFile.addAll(newArchiveFileList);
 
-        log.info("同步声像文件树  imageClassificationFileList :"+wbsCovertArchiveTreeContractList.size());
+                }
+            }else {
+                log.error("同步声像文件:影像资料存储类型不在范围中");
+                continue;
+            }
 
-        //同步质检关联节点
-        syncNodes(wbsCovertArchiveTreeContractList, contractInfo, archiveTreeContract);
+        }
+        if (addNode.size() > 0){
+            addNode.stream().forEach(l->l.setTenantId(tenantId));
+            archiveTreeContractMapper.batchInsertArchiveTreeContract(addNode);
+        }
+        if (addFile.size() > 0){
+            archiveFileClient.addArchiveFile(addFile);
+        }
+//        if (1==1){
+//            throw new org.springblade.core.log.exception.ServiceException("111");
+//        }
     }
 
+
     /**
-     * 将树形节点对象转换为普通的list集合
+     * 质检影像资料 转换为 档案文件
      */
-    public void getTreeList(String tenantId, WbsTreeContractVO6 tree, List<ArchiveTreeContract> wbsCovertArchiveTreeContractList, ArchiveTreeContract archiveTreeContract, Long archiveTreeContractId) {
-        if (ObjectUtil.isEmpty(tree)) {
-            return;
+    private ArchiveFile imageFileCovertArchiveFile(ImageClassificationFileDTO file,Map<Long, Long> wbsPidMapArchiveId)
+    {
+        ArchiveFile archiveFile = new ArchiveFile();
+        archiveFile.setId(SnowFlakeUtil.getId());
+        archiveFile.setProjectId(String.valueOf(file.getProjectId()));
+        archiveFile.setContractId(String.valueOf(file.getContractId()));
+        archiveFile.setNodeId(String.valueOf(wbsPidMapArchiveId.get(file.getWbsId())));
+        archiveFile.setFileName(file.getTitle());
+        archiveFile.setFileTime(file.getUploadTime());
+        archiveFile.setFileUrl(file.getImageUrl());
+        // 根据type判断,设置pdfUrl, 1=视频格式,取原本的视频地址就好,2=图片格式,就取合并后的pdfUrl
+        if(file.getType() == 1){
+            archiveFile.setPdfFileUrl(file.getImageUrl());
+        }else{
+            archiveFile.setPdfFileUrl(StringUtils.isNotEmpty(file.getMargePdfUrl()) ? file.getMargePdfUrl() : file.getPdfUrl());
+        }
+        archiveFile.setFilePage(file.getFilePage());
+        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(String.valueOf(file.getFilePage()));
+        if (StringUtils.isNotBlank(file.getFileSize())) {
+            archiveFile.setFileSize(convertSizeToBytes(file.getFileSize()));
         }
-        // wbs树转archive树
-        ArchiveTreeContract archiveTreeContractTemp = wbsTreeContractCovertArchiveTreeContract(tenantId, tree, archiveTreeContract, archiveTreeContractId);
-        wbsCovertArchiveTreeContractList.add(archiveTreeContractTemp);
+        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;
+    }
 
+    private void recursionCreateArchiveTree(ArchiveSyncWbsVO rootNode, List<ArchiveTreeContract> addNode, ArchiveTreeContract archiveTreeContract) {
+        ArchiveTreeContract node = createImageWbsNode(rootNode, archiveTreeContract);
+        addNode.add(node);
         // 循环遍历,转换树对象
-        List<WbsTreeContractVO6> childrenList = tree.getChildren();
+        List<ArchiveSyncWbsVO> childrenList = rootNode.getChildren();
         if (childrenList != null) {
-            for (WbsTreeContractVO6 child : childrenList) {
-                getTreeList(tenantId, child, wbsCovertArchiveTreeContractList, archiveTreeContractTemp, archiveTreeContractId);
+            for (ArchiveSyncWbsVO child : childrenList) {
+                recursionCreateArchiveTree(child, addNode, node);
             }
         }
     }
 
+//    /**
+//     * 将树形节点对象转换为普通的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树初始化为归档树
      */
@@ -893,192 +1111,280 @@ public class ArchiveTreeContractSyncImpl {
         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());
+    /**
+     * 档案同步质检影像资料时,为影像资料节点下级分类节点,创建日期节点
+     * 传入年份名称
+     */
+    public ArchiveTreeContract createImageDateNode(ArchiveTreeContract archiveTreeContract,Integer year){
+        ArchiveTreeContract archiveTreeContractTemp = new ArchiveTreeContract();
+        //设置基本信息
+        archiveTreeContractTemp.setId(SnowFlakeUtil.getId());
+        archiveTreeContractTemp.setTenantId(AuthUtil.getTenantId());
+        archiveTreeContractTemp.setProjectId(archiveTreeContract.getProjectId());
+        archiveTreeContractTemp.setContractId(archiveTreeContract.getContractId());
+        archiveTreeContractTemp.setParentId(archiveTreeContract.getId());
+        archiveTreeContractTemp.setAncestors(archiveTreeContract.getAncestors()+","+archiveTreeContract.getId());
+        archiveTreeContractTemp.setNodeName(year+"");
+        archiveTreeContractTemp.setNodeType(1);
+        archiveTreeContractTemp.setFullName(year+"");
+        archiveTreeContractTemp.setStatus(1);
+        archiveTreeContractTemp.setIsDeleted(0);
+        //设置关联
+        archiveTreeContractTemp.setExtType(1);
+        archiveTreeContractTemp.setIsStorageNode(0);
+        archiveTreeContractTemp.setPostType(archiveTreeContract.getPostType());
+        archiveTreeContractTemp.setProjectType(archiveTreeContract.getProjectType());
+        archiveTreeContractTemp.setStorageType(archiveTreeContract.getStorageType());
+        archiveTreeContractTemp.setTreeStructure(TreeStructureEnum.ORDINARY_TREE.getCode());
+        return archiveTreeContractTemp;
+    }
 
-            // 转时间树
-            List<TreeVoTwo> dateTreeList = YearTreeUtils.yearMonthDayTree(dateList, "DESC");
+    /**
+     * 档案同步质检影像资料时,为影像资料节点下级创建分类节点
+     * 传入分类名称
+     */
+    public ArchiveTreeContract createImageTypeNode(ImageClassificationConfig imageType,ArchiveTreeContract archiveTreeContract){
+        ArchiveTreeContract archiveTreeContractTemp = new ArchiveTreeContract();
+        //设置基本信息
+        archiveTreeContractTemp.setId(SnowFlakeUtil.getId());
+        archiveTreeContractTemp.setTenantId(AuthUtil.getTenantId());
+        archiveTreeContractTemp.setProjectId(archiveTreeContract.getProjectId());
+        archiveTreeContractTemp.setContractId(archiveTreeContract.getContractId());
+        archiveTreeContractTemp.setParentId(archiveTreeContract.getId());
+        archiveTreeContractTemp.setAncestors(archiveTreeContract.getAncestors()+","+archiveTreeContract.getId());
+        archiveTreeContractTemp.setNodeName(imageType.getClassfName());
+        archiveTreeContractTemp.setNodeType(1);
+        archiveTreeContractTemp.setFullName(imageType.getClassfName());
+        archiveTreeContractTemp.setStatus(1);
+        archiveTreeContractTemp.setIsDeleted(0);
+        //设置关联
+        archiveTreeContractTemp.setExtType(1);
+        archiveTreeContractTemp.setIsStorageNode(0);
+        archiveTreeContractTemp.setPostType(archiveTreeContract.getPostType());
+        archiveTreeContractTemp.setProjectType(archiveTreeContract.getProjectType());
+        archiveTreeContractTemp.setStorageType(archiveTreeContract.getStorageType());
+        archiveTreeContractTemp.setTreeStructure(TreeStructureEnum.ORDINARY_TREE.getCode());
+        return archiveTreeContractTemp;
+    }
 
-            // date转换archive树形集合
-            List<ArchiveTreeContractVO> dateCovertArchiveTreeContractVoList = new ArrayList<>();
+    /**
+     * 档案同步质检影像资料时,为影像资料节点下分类节点创建WBS树
+     */
+    public ArchiveTreeContract createImageWbsNode(ArchiveSyncWbsVO rootNode,ArchiveTreeContract archiveTreeContract){
+        ArchiveTreeContract archiveTreeContractTemp = new ArchiveTreeContract();
+        //设置基本信息
+        archiveTreeContractTemp.setId(SnowFlakeUtil.getId());
+        archiveTreeContractTemp.setTenantId(AuthUtil.getTenantId());
+        archiveTreeContractTemp.setProjectId(archiveTreeContract.getProjectId());
+        archiveTreeContractTemp.setContractId(archiveTreeContract.getContractId());
+        archiveTreeContractTemp.setParentId(archiveTreeContract.getId());
+        archiveTreeContractTemp.setAncestors(archiveTreeContract.getAncestors()+","+archiveTreeContract.getId());
+        archiveTreeContractTemp.setNodeName(rootNode.getNodeName());
+        archiveTreeContractTemp.setNodeType(1);
+        archiveTreeContractTemp.setFullName(rootNode.getFullName());
+        archiveTreeContractTemp.setStatus(1);
+        archiveTreeContractTemp.setIsDeleted(0);
+        //设置关联
+        archiveTreeContractTemp.setExtType(1);
+        archiveTreeContractTemp.setExtKeyId(rootNode.getPKeyId());
+        archiveTreeContractTemp.setSort(rootNode.getSort());
+        archiveTreeContractTemp.setPostType(archiveTreeContract.getPostType());
+        archiveTreeContractTemp.setProjectType(archiveTreeContract.getProjectType());
+        archiveTreeContractTemp.setStorageType(archiveTreeContract.getStorageType());
+        archiveTreeContractTemp.setTreeStructure(TreeStructureEnum.ORDINARY_TREE.getCode());
+        return archiveTreeContractTemp;
+    }
 
-            // 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);
-        }
-    }
+//    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)
@@ -1380,19 +1686,19 @@ public class ArchiveTreeContractSyncImpl {
     /**
      * 刷新归档树
      */
-    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);
-        }
-    }
+//    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查询声像文件

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -999,6 +999,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                 projectContractArea.setProjectId(contractInfo.getPId());
                 projectContractArea.setIsDeleted(0);
                 projectContractArea.setContractId(String.valueOf(contractInfo.getId()));
+                projectContractArea.setProjectId(contractInfo.getPId());
 //                QueryWrapper<ProjectContractArea> queryWrapper = new QueryWrapper<>();
 //                queryWrapper.eq("project_id", contractInfo.getPId());
 //                queryWrapper.eq("contract_id", contractInfo.getId());

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

@@ -4553,7 +4553,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         String representativeCount = sampleInfo.getRepresentativeCount();
         String calculationUnit = sampleInfo.getCalculationUnit();
         Date mobilizationDate = sampleInfo.getMobilizationDate();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         String format = simpleDateFormat.format(mobilizationDate);
         setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
         setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);

+ 18 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ImageClassificationConfigServiceImpl.java

@@ -29,4 +29,22 @@ public class ImageClassificationConfigServiceImpl extends BaseServiceImpl<ImageC
         return list;
     }
 
+    @Override
+    public List<ImageClassificationConfig> selectByContractType(Long contractId, Integer contractType) {
+        switch (contractType) {
+            case 1:
+                contractType = 3;
+                break;
+            case 2:
+                contractType = 2;
+                break;
+            case 3:
+                contractType = 1;
+                break;
+            default:
+                break;
+        }
+        return baseMapper.selectByContractType(contractId,contractType);
+    }
+
 }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -1350,7 +1350,7 @@ public class TaskController extends BladeController {
                 //实时查询上报总金额
                 if (task.getMeterTaskType() == 1) {
                     //中间计量
-                    reportAllMoney = middleMeterApplyTaskMapper.selectAllMoney(task.getId());
+                    reportAllMoney = middleMeterApplyTaskMapper.selectAllMoney(Long.valueOf(task.getContractId()),Long.valueOf(task.getFormDataId()));
                 } else if (task.getMeterTaskType() == 2) {
                     //材料计量
                     reportAllMoney = materialMeterFormTaskMapper.selectAllMoney(task.getId());

+ 7 - 6
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -222,12 +222,12 @@
 <!--    </select>-->
 
     <select id="getCurrentMeterMoney" resultType="java.math.BigDecimal">
-        select ifnull(sum(current_period_pay),0)
-        from s_interim_pay_certificate_item where  chapter_seq='小计' and is_deleted = 0
-                and certificate_id =
-                (select id from s_interim_pay_certificate
-                    WHERE contract_id = #{contractId} and contract_period_id = #{contractPeriodId} and is_deleted = 0
-                )
+        select current_period_pay
+        from s_interim_pay_certificate_item where  chapter_seq='实际支付' and is_deleted = 0
+                                              and certificate_id =
+                                                  (select id from s_interim_pay_certificate
+                                                   WHERE contract_id = #{contractId} and contract_period_id = #{contractPeriodId} and is_deleted = 0
+                                                  )
     </select>
 
 
@@ -462,4 +462,5 @@
     </select>
 
 
+
 </mapper>

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.java

@@ -8,5 +8,5 @@ import java.math.BigDecimal;
 
 public interface MiddleMeterApplyTaskMapper extends BaseMapper<MiddleMeterApplyTask> {
 
-    BigDecimal selectAllMoney(@Param("taskId") Long id);
+    BigDecimal selectAllMoney(@Param("contractId") Long contractId,@Param("contractPeriodId") Long contractPeriodId);
 }

+ 10 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.xml

@@ -2,7 +2,16 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.springblade.meter.mapper.MiddleMeterApplyTaskMapper">
 
+<!--    <select id="selectAllMoney" resultType="java.math.BigDecimal">-->
+<!--        select sum(meter_money) from s_middle_meter_apply_task where is_deleted = 0 and task_id = #{taskId}-->
+<!--    </select>-->
+
     <select id="selectAllMoney" resultType="java.math.BigDecimal">
-        select sum(meter_money) from s_middle_meter_apply_task where is_deleted = 0 and task_id = #{taskId}
+        select current_period_pay
+        from s_interim_pay_certificate_item where  chapter_seq='实际支付' and is_deleted = 0
+                                              and certificate_id =
+                                                  (select id from s_interim_pay_certificate
+                                                   WHERE contract_id = #{contractId} and contract_period_id = #{contractPeriodId} and is_deleted = 0
+                                                  )
     </select>
 </mapper>