Browse Source

Merge branch 'dev' into test

lvy 2 months ago
parent
commit
dfadd1e3bf

+ 12 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ProjectInfo.java

@@ -198,5 +198,17 @@ public class ProjectInfo extends BaseEntity {
     @ApiModelProperty(value = "模板引用 1.模版节点 2.底层节点")
     private Integer templateType;
 
+    /**
+     * 施工后缀
+     */
+    @ApiModelProperty(value = "施工后缀")
+    private String sgSuffix;
+
+    /**
+     * 监理前缀
+     */
+    @ApiModelProperty(value = "监理后缀")
+    private String jlSuffix;
+
 
 }

+ 6 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractLazyVO.java

@@ -127,4 +127,10 @@ public class WbsTreeContractLazyVO implements Serializable {
     @ApiModelProperty(value = "WbsId")
     private Long WbsId;
 
+    @ApiModelProperty(value = "系统模板,后管项目级位置")
+    private String privateTemplate;
+
+    @ApiModelProperty(value = "关联后管节点ID")
+    private Long isTypePrivatePid;
+
 }

+ 1 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/ArchiveFileController.java

@@ -421,6 +421,7 @@ public class ArchiveFileController extends BladeController {
     @ApiOperationSupport(order = 3)
     @ApiOperation("按文件日期排序")
     public R<Boolean> sortByFileTime(@RequestParam Long nodeId){
+
         return R.status(this.archiveFileService.sortByFileTime(nodeId));
     }
 

+ 44 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.google.common.collect.Lists;
 import io.swagger.annotations.*;
@@ -188,6 +189,49 @@ public class InformationWriteQueryController extends BladeController {
         return R.data(300, null, "未找到文件题名");
     }
 
+    @PostMapping("/flushQueryName")
+    @ApiModelProperty(value = "刷新文件题名")
+    @ApiOperationSupport(order = 28)
+    public R<Boolean> flushQueryName(@RequestParam String ids){
+        if(ids==null){
+            throw new ServiceException("请选择要刷新的文件");
+        }
+        List<Long> idList = Arrays.stream(ids.split(","))
+            .map(Long::valueOf)
+            .collect(Collectors.toList());
+        List<InformationQuery> queryList = this.informationQueryService.list(Wrappers.<InformationQuery>lambdaQuery()
+            .select(InformationQuery::getId, InformationQuery::getName,InformationQuery::getProjectId,InformationQuery::getClassify,InformationQuery::getStatus).in(InformationQuery::getId, idList));
+        String sgSuffix="";
+        String jlSuffix="";
+        if(queryList.size()>0){
+            String sql1="Select sg_suffix,jl_suffix from m_project_info where id="+queryList.get(0).getProjectId()+" and is_deleted=0";
+            List<ProjectInfo> projectInfos = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
+            if(projectInfos.size()>0){
+                sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
+                jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
+            }
+            for (InformationQuery query : queryList) {
+                if(query.getClassify()!=null&&query.getClassify()==1&&StringUtils.isNotEmpty(sgSuffix)){
+                   if(!query.getName().endsWith(sgSuffix)){
+                       query.setName(query.getName()+sgSuffix);
+                   }
+                }else if(query.getClassify()!=null&&query.getClassify()==2&&StringUtils.isNotEmpty(jlSuffix)){
+                    if(!query.getName().endsWith(jlSuffix)){
+                        query.setName(query.getName()+jlSuffix);
+                    }
+                }
+            }
+        }
+        List<InformationQuery> taskList = queryList.stream().filter(o -> o.getStatus() == 1 || o.getStatus() == 2).collect(Collectors.toList());
+        if(taskList.size()>0){
+            for (InformationQuery query : taskList) {
+                String update="update u_task set task_name='"+query.getName()+"' where form_data_id='"+query.getId()+"' and is_deleted=0";
+                jdbcTemplate.update(update);
+            }
+        }
+        return R.status(this.informationQueryService.updateBatchById(queryList));
+    }
+
     /**
      * 初始化合同段导图树
      */

+ 33 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeController.java

@@ -12,6 +12,7 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
 import org.springblade.manager.dto.ArchiveTreeDTO;
@@ -19,6 +20,8 @@ import org.springblade.manager.dto.ArchiveTreeSortDTO;
 import org.springblade.manager.service.IArchiveTreeContractService;
 import org.springblade.manager.vo.ArchiveTreeVO2;
 import org.springblade.manager.vo.ArchiveTreeVO3;
+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 org.springblade.manager.entity.ArchiveTree;
@@ -41,6 +44,8 @@ public class ArchiveTreeController extends BladeController {
 
     private final IArchiveTreeContractService archiveTreeContractService;
 
+    private final JdbcTemplate jdbcTemplate;
+
     /**
      * 初始化归档树根节点
      */
@@ -93,10 +98,36 @@ public class ArchiveTreeController extends BladeController {
     @ApiOperation(value = "修改", notes = "传入ArchiveTree")
     public R update(@Valid @RequestBody ArchiveTree archiveTree) {
         archiveTree.setFullName(archiveTree.getNodeName());
-        if (archiveTree.getProjectId() != null && archiveTree.getProjectId() > 0) {
+        if(archiveTree.getProjectId()==null||archiveTree.getProjectId()==0){
+            //先查出所有引用了该系统级的项目级节点
+            String sql="select * from m_archive_tree where from_id="+archiveTree.getId()+" and is_deleted=0";
+            List<ArchiveTree> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ArchiveTree.class));
+            if(query.size()>0){
+                for (ArchiveTree tree : query) {
+                    tree.setNodeType(archiveTree.getNodeType());
+                    tree.setPostType(archiveTree.getPostType());
+                    tree.setAssociationType(archiveTree.getAssociationType());
+                    tree.setMajorDataType(archiveTree.getMajorDataType());
+                    tree.setDisplayHierarchy(archiveTree.getDisplayHierarchy());
+                    tree.setIsStorageNode(archiveTree.getIsStorageNode());
+                    tree.setIsBuiltDrawing(archiveTree.getIsBuiltDrawing());
+                    tree.setIsInterfaceNode(archiveTree.getIsInterfaceNode());
+                    tree.setProjectType(archiveTree.getProjectType());
+                    tree.setStorageType(archiveTree.getStorageType());
+                    tree.setExpDataType(archiveTree.getExpDataType());
+                    tree.setArchiveAutoType(archiveTree.getArchiveAutoType());
+                    tree.setArchiveAutoNodeId(archiveTree.getArchiveAutoNodeId());
+                    tree.setArchiveAutoGroupId(archiveTree.getArchiveAutoGroupId());
+                    tree.setArchiveAutoGroupSelect(archiveTree.getArchiveAutoGroupSelect());
+                    tree.setIsUploadFileDisplayConfigurationTree(archiveTree.getIsUploadFileDisplayConfigurationTree());
+                    tree.setStorageTime(archiveTree.getStorageTime());
+                    archiveTreeService.updateById(tree);
+                    archiveTreeContractService.UpdateByArchiveTree(tree);
+                }
+            }
+        }else if (archiveTree.getProjectId() != null && archiveTree.getProjectId() > 0) {
             archiveTreeContractService.UpdateByArchiveTree(archiveTree);
         }
-
         return R.status(archiveTreeService.updateById(archiveTree));
     }
 

+ 6 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.xml

@@ -231,9 +231,13 @@
         d.contract_id,
         (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree_contract WHERE parent_id = d.id and is_deleted = 0 and project_id = #{projectId})
         AS "has_children",
-        (SELECT  count(1)  FROM m_archive_tree_contract WHERE  is_deleted = 0 and project_id = #{projectId} and ancestors like CONCAT('%',d.id,'%')
+        (SELECT  count(1)  FROM m_archive_tree_contract a
+                        inner join u_archive_file b on b.node_id = a.id and b.is_deleted = a.is_deleted and b.project_id = a.project_id and (b.is_auto_file is null or b.is_auto_file != 1)
+                           WHERE  a.is_deleted = 0
+                             and a.project_id = #{projectId}
+                             and a.ancestors like CONCAT('%',d.id,'%')
         <if test="code!=null and code!=''">
-            AND (tree_code = #{code} or tree_code = #{contractId} or parent_id = 0)
+            AND (a.tree_code = #{code} or a.tree_code = #{contractId} or a.parent_id = 0)
         </if>
         ) as tree_number
         FROM

+ 157 - 8
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeServiceImpl.java

@@ -14,20 +14,18 @@ import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
+import org.springblade.manager.dto.ArchiveTreeContractDTO;
 import org.springblade.manager.dto.ArchiveTreeDTO;
 import org.springblade.manager.dto.ArchiveTreeSortDTO;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
 import org.springblade.manager.mapper.ArchiveTreeContractMapper;
-import org.springblade.manager.service.IProjectInfoService;
-import org.springblade.manager.service.IWbsTreePrivateService;
-import org.springblade.manager.service.IWbsTreeService;
+import org.springblade.manager.service.*;
 import org.springblade.manager.utils.DiffListUtil;
 import org.springblade.manager.utils.ForestNodeMerger;
 import org.springblade.common.utils.ForestNodeMergerEx;
 import org.springblade.manager.vo.*;
 import org.springblade.manager.mapper.ArchiveTreeMapper;
-import org.springblade.manager.service.IArchiveTreeService;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -43,14 +41,13 @@ import java.util.stream.Collectors;
 public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, ArchiveTree> implements IArchiveTreeService {
 
     private final ArchiveTreeMapper archiveTreeMapper;
-    private final ArTreeContractInitServiceImpl archiveTreeContractInitService;
     private final IWbsTreeService wbsTreeService;
     private final IWbsTreePrivateService wbsTreePrivateService;
     private final IProjectInfoService projectInfoService;
-
     private final ArchiveAutoRuleWbsMapper archiveAutoRuleWbsMapper;
-
+    private final ArchiveTreeContractMapper archiveTreeContractMapper;
     private final ArchiveAutoRuleSyncImpl archiveAutoRuleSync;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public boolean initArchiveTree(Long projectId) {
@@ -403,6 +400,7 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
             archiveTreeDTO.setIsStorageNode(1);
         }
         if (archiveTreeDTO.getId() == null) {
+            archiveTreeDTO.setId(SnowFlakeUtil.getId());
             List<ArchiveTree> trees = baseMapper.selectList(Wrappers.<ArchiveTree>query().lambda()
                     .eq(ArchiveTree::getParentId, archiveTreeDTO.getParentId())
             );
@@ -420,10 +418,161 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
             }
             archiveTreeDTO.setSort(sort + 1);
         }
-
+        //这一段是系统级新增,项目级,合同段级自动新增
+//        //如果是修改的系统级的,需要更新项目级+合同段级
+//        if(archiveTreeDTO.getProjectId()==null||archiveTreeDTO.getProjectId()==0){
+//            //查出引用了该系统节点的父节点的项目级节点
+//            String sql="select * from m_archive_tree where from_id="+archiveTreeDTO.getParentId()+" and is_deleted=0";
+//            List<ArchiveTreeDTO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ArchiveTreeDTO.class));
+//            if(query.size()>0){
+//                for (ArchiveTreeDTO dto : query) {
+//                    ArchiveTreeDTO treeDTO = new ArchiveTreeDTO();
+//                    BeanUtil.copy(archiveTreeDTO,treeDTO);
+//                    treeDTO.setId(null);
+//                    treeDTO.setProjectId(dto.getProjectId());
+//                    treeDTO.setParentId(dto.getId());
+//                    treeDTO.setAncestors(dto.getAncestors()+StringPool.COMMA+dto.getId());
+//                    treeDTO.setFromId(archiveTreeDTO.getId());
+//                    Long l = sumbit1(treeDTO);
+//                    //在新增合同段级的
+//                    String sql1="select * from m_archive_tree_contract where from_id="+treeDTO.getParentId()+" and is_deleted=0";
+//                    List<ArchiveTreeContractDTO> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ArchiveTreeContractDTO.class));
+//                    if(query1.size()>0){
+//                        for (ArchiveTreeContractDTO dto1 : query1) {
+//                            ArchiveTreeContractDTO contractDTO=new ArchiveTreeContractDTO();
+//                            BeanUtil.copy(treeDTO,contractDTO);
+//                            contractDTO.setId(null);
+//                            contractDTO.setParentId(dto1.getId());
+//                            contractDTO.setAncestors(dto1.getAncestors()+StringPool.COMMA+dto1.getId());
+//                            contractDTO.setFromId(l);
+//                            submit2(contractDTO);
+//                        }
+//                    }
+//                }
+//            }
+//        }else {
+//            //如果修改的是项目级就新增合同段级的
+//            String sql1="select * from m_archive_tree_contract where from_id="+archiveTreeDTO.getParentId()+" and is_deleted=0";
+//            List<ArchiveTreeContractDTO> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ArchiveTreeContractDTO.class));
+//            if(query1.size()>0){
+//                for (ArchiveTreeContractDTO dto1 : query1) {
+//                    ArchiveTreeContractDTO contractDTO=new ArchiveTreeContractDTO();
+//                    BeanUtil.copy(archiveTreeDTO,contractDTO);
+//                    contractDTO.setId(null);
+//                    contractDTO.setParentId(dto1.getId());
+//                    contractDTO.setAncestors(dto1.getAncestors()+StringPool.COMMA+dto1.getId());
+//                    contractDTO.setFromId(archiveTreeDTO.getId());
+//                    submit2(contractDTO);
+//                }
+//            }
+//        }
         return save(archiveTreeDTO);
     }
 
+    public int submit2(ArchiveTreeContractDTO archiveTreeContractDTO) {
+        if (Func.isEmpty(archiveTreeContractDTO.getParentId())) {
+            archiveTreeContractDTO.setTenantId(AuthUtil.getTenantId());
+            archiveTreeContractDTO.setParentId(BladeConstant.TOP_PARENT_ID);
+            archiveTreeContractDTO.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
+        }
+        if (archiveTreeContractDTO.getParentId() > 0) {
+            ArchiveTreeContract parent = archiveTreeContractMapper.selectById(archiveTreeContractDTO.getParentId());
+            if (Func.toLong(archiveTreeContractDTO.getParentId()) == Func.toLong(archiveTreeContractDTO.getId())) {
+                throw new ServiceException("父节点不可选择自身!");
+            }
+            archiveTreeContractDTO.setTenantId(parent.getTenantId());
+            String ancestors = parent.getAncestors() + StringPool.COMMA + archiveTreeContractDTO.getParentId();
+            archiveTreeContractDTO.setAncestors(ancestors);
+            archiveTreeContractDTO.setTreeSort(parent.getTreeSort());
+            archiveTreeContractDTO.setContractId(parent.getContractId());
+            archiveTreeContractDTO.setTreeCode(parent.getTreeCode());
+
+            archiveTreeContractDTO.setArchiveAutoNodeId(parent.getArchiveAutoNodeId());
+            archiveTreeContractDTO.setArchiveAutoType(parent.getArchiveAutoType());
+            archiveTreeContractDTO.setArchiveAutoGroupId(parent.getArchiveAutoGroupId());
+            archiveTreeContractDTO.setArchiveAutoGroupSelect(0);
+        }
+
+        archiveTreeContractDTO.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+        archiveTreeContractDTO.setFullName(archiveTreeContractDTO.getNodeName());
+        if (archiveTreeContractDTO.getNodeType() == 1) {
+            archiveTreeContractDTO.setIsStorageNode(1);
+        }
+        if (archiveTreeContractDTO.getId() == null) {
+            List<ArchiveTreeContract> trees = archiveTreeContractMapper.selectList(Wrappers.<ArchiveTreeContract>query().lambda()
+                .eq(ArchiveTreeContract::getParentId, archiveTreeContractDTO.getParentId())
+            );
+            List<ArchiveTreeContract> collect = trees.stream().filter(f -> {
+                if (f.getSort() == null) {
+                    f.setSort(0);
+                }
+                return true;
+            }).collect(Collectors.toList());
+            Optional<ArchiveTreeContract> max = collect.stream().max(Comparator.comparingInt(ArchiveTreeContract::getSort));
+            Integer sort = 0;
+            if (max.isPresent()) {
+                sort = max.get().getSort();
+            }
+            archiveTreeContractDTO.setSort(sort + 1);
+            String treeSort = archiveTreeContractDTO.getTreeSort();
+            if (com.mixsmart.utils.StringUtils.isNotEmpty(treeSort)) {
+                treeSort = treeSort + (100 + archiveTreeContractDTO.getSort());
+                archiveTreeContractDTO.setTreeSort(treeSort);
+            }
+        }
+
+        return archiveTreeContractMapper.insert(archiveTreeContractDTO);
+    }
+
+    public Long sumbit1(ArchiveTreeDTO archiveTreeDTO){
+        if (Func.isEmpty(archiveTreeDTO.getParentId())) {
+            archiveTreeDTO.setTenantId(AuthUtil.getTenantId());
+            archiveTreeDTO.setParentId(BladeConstant.TOP_PARENT_ID);
+            archiveTreeDTO.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
+        }
+        if (archiveTreeDTO.getParentId() > 0) {
+            ArchiveTree parent = getById(archiveTreeDTO.getParentId());
+            if (Func.toLong(archiveTreeDTO.getParentId()) == Func.toLong(archiveTreeDTO.getId())) {
+                throw new ServiceException("父节点不可选择自身!");
+            }
+            archiveTreeDTO.setTenantId(parent.getTenantId());
+            String ancestors = parent.getAncestors() + StringPool.COMMA + archiveTreeDTO.getParentId();
+            archiveTreeDTO.setAncestors(ancestors);
+
+            archiveTreeDTO.setArchiveAutoType(parent.getArchiveAutoType());
+            archiveTreeDTO.setArchiveAutoNodeId(parent.getArchiveAutoNodeId());
+            archiveTreeDTO.setArchiveAutoGroupId(parent.getArchiveAutoGroupId());
+            archiveTreeDTO.setArchiveAutoGroupSelect(0);
+        }
+
+        archiveTreeDTO.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+        archiveTreeDTO.setFullName(archiveTreeDTO.getNodeName());
+        if (archiveTreeDTO.getNodeType() == 1) {
+            archiveTreeDTO.setIsStorageNode(1);
+        }
+        if (archiveTreeDTO.getId() == null) {
+            archiveTreeDTO.setId(SnowFlakeUtil.getId());
+            List<ArchiveTree> trees = baseMapper.selectList(Wrappers.<ArchiveTree>query().lambda()
+                .eq(ArchiveTree::getParentId, archiveTreeDTO.getParentId())
+            );
+
+            List<ArchiveTree> collect = trees.stream().filter(f -> {
+                if (f.getSort() == null) {
+                    f.setSort(0);
+                }
+                return true;
+            }).collect(Collectors.toList());
+            Optional<ArchiveTree> max = collect.stream().max(Comparator.comparingInt(ArchiveTree::getSort));
+            Integer sort = 0;
+            if (max.isPresent()) {
+                sort = max.get().getSort();
+            }
+            archiveTreeDTO.setSort(sort + 1);
+        }
+        save(archiveTreeDTO);
+        return archiveTreeDTO.getId();
+    }
+
     @Override
     public List<ArchiveTree> treeList(String tenantId, Long projectId, Integer disPlayTree, Integer nodeType) {
         return baseMapper.selectList(Wrappers.<ArchiveTree>query().lambda()

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

@@ -1246,22 +1246,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     if (wbsTreeContractByP != null) {
                         //处理文件提名
                         String fileName = this.wbsParamService.createFileTitle(wbsTreeContractByP);
-                        String sql="select template_type from m_contract_info where id="+wbsTreeContractByP.getContractId();
-                        Integer type = jdbcTemplate.query(sql, rs -> {
-                            if (rs.next()) {
-                                return rs.getObject(1, Integer.class);
-                            } else {
-                                return 0; // 默认值
-                            }
-                        });
-                        if(type==2){
-                            if(wbsTreeContractByP.getMajorDataType()!=null&&wbsTreeContractByP.getMajorDataType()==4){
-                                if(tableInfo.getClassify()!=null&&tableInfo.getClassify().equals("1")){
-                                    //查询是否是底层节点
-                                    fileName=fileName+"检验申请批复单及附件";
-                                }else {
-                                    fileName=fileName+"抽检记录";
-                                }
+                        String sql1="Select sg_suffix,jl_suffix from m_project_info where id="+wbsTreeContractByP.getProjectId()+" and is_deleted=0";
+                        List<ProjectInfo> query = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
+                        if(query.size()>0){
+                            if(tableInfo.getClassify()!=null&&tableInfo.getClassify().equals("1")){
+                                fileName=fileName+(query.get(0).getSgSuffix()==null?"":query.get(0).getSgSuffix());
+                            }else {
+                                fileName=fileName+(query.get(0).getJlSuffix()==null?"":query.get(0).getJlSuffix());
                             }
                         }
                         //huangjn 保存成功后调用生成资料查询列表数据
@@ -1300,22 +1291,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         .eq(WbsTreeContract::getId, wbsTreeContract.getParentId()).eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId()));
                 //处理文件提名
                 fileName1= this.wbsParamService.createFileTitle(wbsTreeContractByP);
-                String sql="select template_type from m_contract_info where id="+wbsTreeContractByP.getContractId();
-                Integer type = jdbcTemplate.query(sql, rs -> {
-                    if (rs.next()) {
-                        return rs.getObject(1, Integer.class);
-                    } else {
-                        return 0; // 默认值
-                    }
-                });
-                if(type==2){
-                    if(wbsTreeContractByP.getMajorDataType()!=null&&wbsTreeContractByP.getMajorDataType()==4){
-                        if(tableInfoList.get(0).getClassify()!=null&&tableInfoList.get(0).getClassify().equals("1")){
-                            //查询是否是底层节点
-                            fileName1=fileName1+"检验申请批复单及附件";
-                        }else {
-                            fileName1=fileName1+"抽检记录";
-                        }
+                String sql1="Select sg_suffix,jl_suffix from m_project_info where id="+wbsTreeContractByP.getProjectId()+" and is_deleted=0";
+                List<ProjectInfo> query = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
+                if(query.size()>0){
+                    if(tableInfoList.get(0).getClassify()!=null&&tableInfoList.get(0).getClassify().equals("1")){
+                        fileName1=fileName1+(query.get(0).getSgSuffix()==null?"":query.get(0).getSgSuffix());
+                    }else {
+                        fileName1=fileName1+(query.get(0).getJlSuffix()==null?"":query.get(0).getJlSuffix());
                     }
                 }
                 //huangjn 保存成功后调用生成资料查询列表数据

+ 3 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsFormElementServiceImpl.java

@@ -59,7 +59,7 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
     //元素字符串、数值、时间类型默认长度
     public static final Integer DEFAULT_ELEMENT_LENGTH_VARCHAR = 200;
     public static final Integer DEFAULT_ELEMENT_LENGTH_NUMBER = 50;
-    public static final Integer DEFAULT_ELEMENT_LENGTH_DATE = 50;
+    public static final Integer DEFAULT_ELEMENT_LENGTH_DATE = 100;
     //实体表字段默认长度
     private static final String ELEMENT_LENGTH_ENTITY = "200";
 
@@ -236,8 +236,8 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
                     return wbsFormElement;
                 }
             } else if ("datetime".equals(fieldType)) {
-                if (wbsFormElement.getELength() > 50 || wbsFormElement.getELength() < 0) {
-                    throw new ServiceException("请输入正确的长度,范围为0-50");
+                if (wbsFormElement.getELength() > 100 || wbsFormElement.getELength() < 0) {
+                    throw new ServiceException("请输入正确的长度,范围为0-100");
                 } else {
                     //新增
                     baseMapper.insert(wbsFormElement);

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

@@ -143,7 +143,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             //如果className,unitName不为空,则要判断该节点是否是最小节点
             if (ObjectUtil.isNotEmpty(wbsTreePrivate.getClassName()) && ObjectUtil.isNotEmpty(wbsTreePrivate.getUnitName())) {
                 QueryWrapper<WbsTreePrivate> wrapper = new QueryWrapper<>();
-                wrapper.eq("parent_id", wbsTreePrivate.getId()).eq("is_deleted", 0);
+                wrapper.eq("parent_id", wbsTreePrivate.getId()).eq("project_id",  wbsTreePrivate.getProjectId());
                 //查出当前节点所有子节点。如果子节点中没有节点,说明是最小节点
                 List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectList(wrapper);
                 if (wbsTreePrivates.size() > 0) {

+ 57 - 4
blade-service/blade-user/src/main/java/org/springblade/system/user/bean/NodeVO.java

@@ -3,10 +3,7 @@ package org.springblade.system.user.bean;
 import cn.hutool.core.util.ObjectUtil;
 import lombok.Data;
 
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -154,6 +151,62 @@ public class NodeVO {
         node.setStatus(2);
     }
 
+    public static void calculateStatusToDFS1(List<NodeVO> nodeList, Map<Long, Integer> nodeColorStatusMap) {
+        NodeVO rootNode = findRootNode(nodeList);
+        if (rootNode != null) {
+            calculateNodeStatusToDFS1(rootNode, nodeColorStatusMap);
+            nodeColorStatusMap.put(rootNode.getPKeyId(), rootNode.getStatus());
+        }
+    }
+    public static void calculateNodeStatusToDFS1(NodeVO node, Map<Long, Integer> nodeColorStatusMap) {
+        //最底层节点直接返回
+        if (ObjectUtil.isEmpty(node.getChildren())) {
+            return;
+        }
+        //递归处理子节点
+        for (NodeVO child : node.getChildren()) {
+            calculateNodeStatusToDFS1(child, nodeColorStatusMap);
+            nodeColorStatusMap.put(child.getPKeyId(), child.getStatus());
+        }
+        //判断子级
+        Set<Integer> childStatusList = node.getChildren().stream().map(NodeVO::getStatus).collect(Collectors.toSet());
+        //如果子节点都是相同的状态,则父节点状态也为该状态
+        if (childStatusList.size() == 1) {
+            node.setStatus(childStatusList.iterator().next());
+            return;
+        }
+        //判断是否存在同时只存在1、3的情况
+        if (childStatusList.contains(1) && childStatusList.contains(3) && !childStatusList.contains(2)) {
+            node.setStatus(2);
+            return;
+        }
+        //判断是否存在同时只存在3、4的情况
+        if (childStatusList.contains(3) && childStatusList.contains(4) && !childStatusList.contains(1) && !childStatusList.contains(2)) {
+            node.setStatus(3);
+            return;
+        }
+        //判断是否存在只有1但不全是1的情况
+        if (childStatusList.contains(1) && !childStatusList.contains(2) && !childStatusList.contains(3) && !childStatusList.contains(4)) {
+            node.setStatus(2);
+            return;
+        }
+
+        //判断是否存在只有2但不全是2的情况
+        if (childStatusList.contains(2) && !childStatusList.contains(1) && !childStatusList.contains(3) && !childStatusList.contains(4)) {
+            node.setStatus(2);
+            return;
+        }
+
+        //判断是否存在只有3但不全是3的情况
+        if (childStatusList.contains(3) && !childStatusList.contains(1) && !childStatusList.contains(2) && !childStatusList.contains(4)) {
+            node.setStatus(3);
+            return;
+        }
+
+        //其他情况,父节点状态默认为2
+        node.setStatus(2);
+    }
+
     /**
      * BFS
      *

+ 100 - 17
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@@ -72,6 +72,7 @@ import org.springframework.dao.DataAccessException;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -83,6 +84,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.Function;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 @Service
 @AllArgsConstructor
@@ -726,7 +728,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                     String sql = "SELECT is_custom,p_key_id,contract_id," +
                             "(SELECT is_reference_number FROM m_contract_info WHERE id="+contractId+") AS isReferenceNumber,"+
                             "(SELECT id FROM u_contract_tree_drawings WHERE process_id = p_key_id AND is_deleted = 0 limit 1) AS drawingsId," +
-                            "id,parent_id,node_type,type,wbs_type,is_buss_show as isBussShow,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time," +
+                            "id,parent_id,node_type,type,wbs_type,is_buss_show as isBussShow,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time,is_type_private_pid," +
                             "CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) " +
                             "WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title," +
                             "(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1" +
@@ -788,12 +790,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
 
                         /* ================ 处理颜色 ================ */
                         long startTime = System.currentTimeMillis();
-                        List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
-                        Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
+//                        List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
+//                        Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
                         List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
-                        NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
-                        List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
-                        Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
+//                        NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
+                        Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
+                        NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
+//                        buildNodeTreeByStream(distinctNodesAll, lowestNodesMap, nodeColorStatusMap);
+                        // 将树形结构展开成列表
+//                        List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
+//                        Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
                         long endTime = System.currentTimeMillis();
                         long executionTime = endTime - startTime;
                         _logger.info("合同段 " + contractId + " 处理颜色 执行时间:" + executionTime + " ms");
@@ -810,6 +816,25 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                 }
                             }
                             for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
+                                if(lazyNodeVO.getIsCustom()!=null&&lazyNodeVO.getIsCustom()==1){
+                                    lazyNodeVO.setPrivateTemplate("当前节点为自定义节点,无法定位后管位置");
+                                }else {
+                                    try {
+                                        if(lazyNodeVO.getIsTypePrivatePid()!=null){
+                                            String privateSql="select p_key_id, ancestors_p_id from m_wbs_tree_private where p_key_id="+lazyNodeVO.getIsTypePrivatePid()+" and is_deleted=0";
+                                            WbsTreePrivate ancestor = jdbcTemplate.queryForObject(privateSql,new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+                                            String ancestorsPId=ancestor.getAncestorsPId()+","+ancestor.getPKeyId();
+                                            String privateNodeNameSql="select node_name from m_wbs_tree_private where p_key_id in ("+ancestorsPId+")";
+                                            List<String> wbsTreePrivates = jdbcTemplate.query(privateNodeNameSql,new SingleColumnRowMapper<>(String.class));
+                                            if(wbsTreePrivates.size()>0){
+                                                String result = wbsTreePrivates.stream().collect(Collectors.joining("/"));
+                                                lazyNodeVO.setPrivateTemplate(result);
+                                            }
+                                        }
+                                    } catch (Exception e) {
+                                        lazyNodeVO.setPrivateTemplate("");
+                                    }
+                                }
                                 lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
                                 lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
                                 if (lazyNodeVO.getParentId() == 0L) {
@@ -834,6 +859,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                         lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
                                     }
                                 }
+
                             }
                         }
                         return lazyNodes;
@@ -864,7 +890,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                             String sql = "SELECT is_custom,p_key_id,contract_id," +
                                     "(SELECT is_reference_number FROM m_contract_info WHERE id="+contractId+") AS isReferenceNumber,"+
                                     "(SELECT id FROM u_contract_tree_drawings WHERE process_id = p_key_id AND is_deleted = 0 limit 1) AS drawingsId," +
-                                    "id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time," +
+                                    "id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time,is_type_private_pid," +
                                     "CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) " +
                                     "WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title," +
                                     "(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1" +
@@ -907,13 +933,15 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                             }
                                         }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
 
-                                List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
-                                Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
+//                                List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
+//                                Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
                                 List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
-                                NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
-                                List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
-                                Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
-
+//                                NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
+//                                List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
+//                                Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
+                                Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
+                                NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
+//                                buildNodeTreeByStream(distinctNodesAll, lowestNodesMap, nodeColorStatusMap);
                                 if (lazyNodes.size() > 0) {
                                     Map<Long, Integer> countMap = new HashMap<>();
                                     for (WbsTreeContractLazyVO node : resultParentNodesTB) {
@@ -926,6 +954,25 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                     }
 
                                     for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
+                                        if(lazyNodeVO.getIsCustom()!=null&&lazyNodeVO.getIsCustom()==1){
+                                            lazyNodeVO.setPrivateTemplate("当前节点为自定义节点,无法定位后管位置");
+                                        }else {
+                                            try {
+                                                if(lazyNodeVO.getIsTypePrivatePid()!=null){
+                                                    String privateSql="select p_key_id, ancestors_p_id from m_wbs_tree_private where p_key_id="+lazyNodeVO.getIsTypePrivatePid()+" and is_deleted=0";
+                                                    WbsTreePrivate ancestor = jdbcTemplate.queryForObject(privateSql,new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+                                                    String ancestorsPId=ancestor.getAncestorsPId()+","+ancestor.getPKeyId();
+                                                    String privateNodeNameSql="select node_name from m_wbs_tree_private where p_key_id in ("+ancestorsPId+")";
+                                                    List<String> wbsTreePrivates = jdbcTemplate.query(privateNodeNameSql,new SingleColumnRowMapper<>(String.class));
+                                                    if(wbsTreePrivates.size()>0){
+                                                        String result = wbsTreePrivates.stream().collect(Collectors.joining("/"));
+                                                        lazyNodeVO.setPrivateTemplate(result);
+                                                    }
+                                                }
+                                            } catch (Exception e) {
+                                                lazyNodeVO.setPrivateTemplate("");
+                                            }
+                                        }
                                         lazyNodeVO.setType(lazyNodeVO.getNodeType());
                                         lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
                                         lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
@@ -951,6 +998,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                                 lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
                                             }
                                         }
+
                                     }
                                 }
                                 lazyNodesAll.addAll(lazyNodes);
@@ -1384,8 +1432,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             long startTime = System.currentTimeMillis();
 
             /*重新计算,进行递归获取父节点计数统计*/
-            this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
-
+//            this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
+            Map<Long, List<WbsTreeContractLazyVO>> map = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getId));
+            recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, map);
             long endTime = System.currentTimeMillis();
             long executionTime = endTime - startTime;
             _logger.info("合同段 " + contractId + " wbs节点树 数量计算 执行时间:" + executionTime + " ms");
@@ -1441,6 +1490,40 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         }
     }
 
+    public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, Map<Long, List<WbsTreeContractLazyVO>> nodeMap) {
+        if (lowestNodeParentIds == null || lowestNodeParentIds.isEmpty()) {
+            return;
+        }
+        Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
+                .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
+
+        List<WbsTreeContractLazyVO> collectedNodes = parentIdGroup.entrySet().stream()
+                .flatMap(entry -> {
+                    List<WbsTreeContractLazyVO> nodes = nodeMap.get(entry.getKey());
+                    if (nodes == null || nodes.isEmpty()) {
+                        return Stream.empty();
+                    }
+                    if (entry.getValue() > 1L) {
+                        nodes = nodes.stream().limit(1)
+                                .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream())
+                                .collect(Collectors.toList());
+                    }
+                    return nodes.stream();
+                })
+                .collect(Collectors.toList());
+        if (collectedNodes.isEmpty()) {
+            return;
+        }
+        List<Long> collect = collectedNodes.stream()
+                .map(WbsTreeContractLazyVO::getParentId).filter(Objects::nonNull).distinct()
+                .collect(Collectors.toList());
+        if (!collect.isEmpty()) {
+            result.addAll(collectedNodes);
+            this.recursiveGetParentNodes(result, collect, nodeMap);
+        }
+    }
+
+
     /**
      * 转换VO
      *
@@ -1452,7 +1535,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         nodeVO.setId(wbsTreeContractLazyVO.getId());
         nodeVO.setParentId(wbsTreeContractLazyVO.getParentId());
         nodeVO.setPKeyId(wbsTreeContractLazyVO.getPKeyId());
-        nodeVO.setStatus(cn.hutool.core.util.ObjectUtil.isNotEmpty(wbsTreeContractLazyVO.getColorStatus()) ? wbsTreeContractLazyVO.getColorStatus() : 1);
+        nodeVO.setStatus(wbsTreeContractLazyVO.getColorStatus() != null ? wbsTreeContractLazyVO.getColorStatus() : 1);
         return nodeVO;
     }
 
@@ -1476,7 +1559,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         for (WbsTreeContractLazyVO vo : list) {
             if (vo.getHasChildren().equals(0)) {
                 WbsTreeContractLazyVO lowestNodeVO = lowestNodesMap.getOrDefault(vo.getPKeyId(), null);
-                if (lowestNodeVO != null && cn.hutool.core.util.ObjectUtil.isNotEmpty(lowestNodeVO.getColorStatus())) {
+                if (lowestNodeVO != null && lowestNodeVO.getColorStatus() != null) {
                     //最底层颜色初始化
                     vo.setColorStatus(lowestNodeVO.getColorStatus());
                 }