Kaynağa Gözat

质检合同段收藏夹节点懒加载

lvy 1 hafta önce
ebeveyn
işleme
96ad8164a0

+ 6 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ContractCollectFolder.java

@@ -42,6 +42,12 @@ public class ContractCollectFolder implements Serializable {
     @ApiModelProperty("节点Id")
     private Long nodeId;
 
+    /**
+     * 节点父Id
+     */
+    @ApiModelProperty("节点父Id")
+    private Long nodeParentId;
+
     /**
      * 节点路径pKeyIds
      */

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

@@ -912,8 +912,8 @@ public class ContractInfoController extends BladeController {
     @GetMapping("/getCollectTreeNode")
     @ApiOperationSupport(order = 26)
     @ApiOperation(value = "获取收藏节点树", notes = "获取收藏节点树")
-    public R<Object> getCollectTreeNode(@RequestParam String queryValue, @RequestParam String contractId, @RequestParam String tableOwner, @RequestParam Long folderId) {
-        R<Object> result = contractInfoService.getCollectTreeNode(contractId, tableOwner,folderId, queryValue);
+    public R<Object> getCollectTreeNode(@RequestParam String queryValue, @RequestParam String contractId, @RequestParam String tableOwner, @RequestParam Long folderId, @RequestParam Long pKeyId) {
+        R<Object> result = contractInfoService.getCollectTreeNode(contractId, tableOwner,folderId, queryValue,pKeyId);
         R<Object> data = doResult(contractId, result);
         if (data != null) return data;
         return R.fail(200, "未查询到信息");

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractCollectFolderMapper.xml

@@ -9,6 +9,7 @@
         <result column="folder_name" property="folderName"/>
         <result column="contract_id" property="contractId"/>
         <result column="node_id" property="nodeId"/>
+        <result column="node_parent_id" property="nodeParentId"/>
         <result column="node_ancestors" property="nodeAncestors"/>
         <result column="type" property="type"/>
         <result column="sort" property="sort"/>

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

@@ -89,5 +89,5 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
 
     R<Object> queryWbsTreeNodeBySaveOrHidden(String contractId, String tableOwner, Integer days, String queryValue, Integer type);
 
-    R<Object> getCollectTreeNode(String contractId, String tableOwner, Long folderId, String queryValue);
+    R<Object> getCollectTreeNode(String contractId, String tableOwner, Long folderId, String queryValue, Long pKeyId);
 }

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

@@ -151,6 +151,7 @@ public class ContractCollectFolderServiceImpl extends ServiceImpl<ContractCollec
                     node1.setCreateUser(AuthUtil.getUserId());
                     node1.setNodeAncestors(contract.getAncestorsPId() + "," + contract.getPKeyId());
                     node1.setParentId(vo.getId());
+                    node1.setNodeParentId(contract.getPId() == null ? 0 : contract.getPId());
                     nodes.add(node1);
                 }
                 return this.saveBatch(nodes);
@@ -193,7 +194,7 @@ public class ContractCollectFolderServiceImpl extends ServiceImpl<ContractCollec
         if (pKeyIds == null || pKeyIds.isEmpty()) {
             return;
         }
-        List<WbsTreeContract> list = wbsTreeContractService.list(Wrappers.<WbsTreeContract>lambdaQuery().select(WbsTreeContract::getPKeyId, WbsTreeContract::getAncestorsPId)
+        List<WbsTreeContract> list = wbsTreeContractService.list(Wrappers.<WbsTreeContract>lambdaQuery().select(WbsTreeContract::getPKeyId, WbsTreeContract::getAncestorsPId, WbsTreeContract::getPId)
                 .in(WbsTreeContract::getPId, pKeyIds).eq(WbsTreeContract::getStatus, 1).eq(WbsTreeContract::getType, 1));
         if (list == null || list.isEmpty()) {
             return;

+ 13 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -1525,7 +1525,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
             if (!collectNodes.isEmpty()) {
                 return collectNodes;
             }
-            List<ContractCollectFolder> query = jdbcTemplate.query(String.format("select * from m_contract_collect_folder where contract_id = %s and type = 1", contractId), new BeanPropertyRowMapper<>(ContractCollectFolder.class));
+            List<ContractCollectFolder> query = jdbcTemplate.query(String.format("select node_id from m_contract_collect_folder where contract_id = %s and type = 1", contractId), new BeanPropertyRowMapper<>(ContractCollectFolder.class));
             for (ContractCollectFolder contractCollectFolder : query) {
                 Long nodeId = contractCollectFolder.getNodeId();
                 collectNodes.put(nodeId, "");
@@ -1591,7 +1591,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         return syncPKeyIds;
     }
     @Override
-    public R<Object> getCollectTreeNode(String contractId, String tableOwner, Long folderId, String queryValue) {
+    public R<Object> getCollectTreeNode(String contractId, String tableOwner, Long folderId, String queryValue, Long pKeyId) {
         if (StringUtils.isEmpty(contractId)) {
             return R.fail(200, "合同段id错误");
         }
@@ -1603,7 +1603,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
             return R.fail(200, "合同段不存在");
         }
         Set<String> syncPKeyIds = getSyncFlagIds(contractId, tableOwner);
-        List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select * from m_contract_collect_folder where type = 1 and parent_id = " + folderId, new BeanPropertyRowMapper<>(ContractCollectFolder.class));
+        List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select node_id from m_contract_collect_folder where type = 1 and parent_id = " + folderId + " and node_parent_id = " + pKeyId, new BeanPropertyRowMapper<>(ContractCollectFolder.class));
         if (!contractCollectNodes.isEmpty()) {
             Set<Long> pKeyIds = new LinkedHashSet<>();
             Map<Long, String> collectMap = new HashMap<>();
@@ -1620,7 +1620,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                 collectMap.put(node.getNodeId(), "");
                 pKeyIds.add(node.getNodeId());
             }
-            List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds));
+            List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds).eq(WbsTreeContract::getPId, pKeyId));
             if (!wbsTreeContractList.isEmpty()) {
                 String pKeyIdStr = wbsTreeContractList.stream().map(item -> item.getPKeyId() + "").collect(Collectors.joining(","));
                 List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, leaf_num, fill_num, approve_num, complete_num,jl_fill_num, jl_approve_num, jl_complete_num from m_wbs_tree_contract_statistics where id in (" + pKeyIdStr + ")",
@@ -1642,9 +1642,15 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                         Integer nums = statistics.calculateSubmitNums(tableOwner);
                                         vo.setSubmitCounts(nums == null ? 0 : nums.longValue());
                                         vo.setColorStatus(statistics.calculateColorStatus(tableOwner));
+                                        if (statistics.getLeafNum() > 0) {
+                                            vo.setHasChildren( true);
+                                        } else {
+                                            vo.setHasChildren(false);
+                                        }
                                     } else {
                                         vo.setSubmitCounts(0L);
                                         vo.setColorStatus(1);
+                                        vo.setHasChildren(false);
                                     }
                                     if(CollectionUtil.isNotEmpty(syncPKeyIds)){
                                         //判断是否展示同步标识
@@ -1658,11 +1664,11 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                 }
                                 return vo;
                             }).collect(Collectors.toList());
-                    List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
+//                    List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
                     if (StringUtil.hasText(queryValue)) {
-                        resultMaps.put(Long.parseLong(cId), this.queryTreeResult(resultList, queryValue));
+                        resultMaps.put(Long.parseLong(cId), this.queryTreeResult(wbsTreeContractTreeAllVOS, queryValue));
                     } else {
-                        resultMaps.put(Long.parseLong(cId), resultList);
+                        resultMaps.put(Long.parseLong(cId), wbsTreeContractTreeAllVOS);
                     }
                 });
                 if (contractInfo.getContractType() != null && contractInfo.getContractType() == 1) {

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

@@ -1160,7 +1160,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             if (!collectNodes.isEmpty()) {
                 return collectNodes;
             }
-            List<ContractCollectFolder> query = jdbcTemplate.query(String.format("select * from m_contract_collect_folder where contract_id = %s and type = 1", contractId), new BeanPropertyRowMapper<>(ContractCollectFolder.class));
+            List<ContractCollectFolder> query = jdbcTemplate.query(String.format("select node_id from m_contract_collect_folder where contract_id = %s and type = 1", contractId), new BeanPropertyRowMapper<>(ContractCollectFolder.class));
             for (ContractCollectFolder contractCollectFolder : query) {
                 Long nodeId = contractCollectFolder.getNodeId();
                 collectNodes.put(nodeId, "");