Browse Source

自定义新增节点相关

Signed-off-by: liuyc <56808083@qq.com>
liuyc 1 year ago
parent
commit
2827398e2c

+ 23 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/CustomAddContractNodeDTO.java

@@ -0,0 +1,23 @@
+package org.springblade.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class CustomAddContractNodeDTO implements Serializable {
+
+    @ApiModelProperty(required = true, value = "当前选择新增节点的primaryKeyId")
+    private String primaryKeyId;
+
+    @ApiModelProperty(required = true, value = "节点名称")
+    private String nodeName;
+
+    @ApiModelProperty(required = true, value = "节点类型")
+    private Integer nodeType;
+
+    @ApiModelProperty(value = "划分编号")
+    private String partitionCode;
+
+}

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/WbsTreeContract.java

@@ -276,4 +276,7 @@ public class WbsTreeContract extends BaseEntity {
     @ApiModelProperty(value = "查询索引")
     @ApiModelProperty(value = "查询索引")
     private String treeCode;
     private String treeCode;
 
 
+    @ApiModelProperty(value = "是否为自定义新增节点 1=是")
+    private Integer isCustom;
+
 }
 }

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

@@ -81,6 +81,9 @@ public class WbsTreeContractLazyVO implements Serializable {
     @ApiModelProperty(value = "子级集合(在构造树形结构时使用)")
     @ApiModelProperty(value = "子级集合(在构造树形结构时使用)")
     private List<WbsTreeContractLazyVO> children;
     private List<WbsTreeContractLazyVO> children;
 
 
+    @ApiModelProperty(value = "是否为自定义新增节点 1=是")
+    private Integer isCustom;
+
     private Integer sort;
     private Integer sort;
 
 
     private String fullName;
     private String fullName;

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

@@ -15,6 +15,7 @@ import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.NotNull;
+import org.springblade.business.dto.CustomAddContractNodeDTO;
 import org.springblade.business.entity.*;
 import org.springblade.business.entity.*;
 import org.springblade.business.feign.MessageWarningClient;
 import org.springblade.business.feign.MessageWarningClient;
 import org.springblade.business.feign.OperationLogClient;
 import org.springblade.business.feign.OperationLogClient;
@@ -3900,4 +3901,60 @@ public class InformationWriteQueryController extends BladeController {
         return R.data("操作成功");
         return R.data("操作成功");
     }
     }
 
 
+    /**
+     * 自定义新增合同段节点
+     */
+    @PostMapping("/customAddContractNode")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "自定义新增合同段节点", notes = "传入CustomAddContractNodeDTO")
+    public R<Object> customAddContractNode(@RequestBody CustomAddContractNodeDTO dto) {
+        if (ObjectUtil.isEmpty(dto.getNodeName()) || ObjectUtil.isEmpty(dto.getNodeType())) {
+            throw new ServiceException("节点名称、节点类型不能为空");
+        }
+        WbsTreeContract parentNode = wbsTreeContractClient.getContractNodeByPrimaryKeyId(dto.getPrimaryKeyId());
+        if (parentNode != null) {
+            if (parentNode.getNodeType() < parentNode.getNodeType()) {
+                throw new ServiceException("当前新增选择的节点类型不能大于父级节点类型");
+            }
+
+            WbsTreeContract obj = new WbsTreeContract();
+            obj.setPKeyId(SnowFlakeUtil.getId());
+            obj.setId(SnowFlakeUtil.getId());
+            obj.setProjectId(parentNode.getProjectId());
+            obj.setContractId(parentNode.getContractId());
+            obj.setContractType(ObjectUtil.isNotEmpty(parentNode.getContractType()) ? parentNode.getContractType() : null);
+            obj.setWbsType(parentNode.getWbsType());
+            obj.setWbsId(parentNode.getWbsId());
+            obj.setNodeName(dto.getNodeName());
+            obj.setFullName(dto.getNodeName());
+            obj.setNodeType(dto.getNodeType());
+            obj.setPartitionCode(dto.getPartitionCode());
+            obj.setParentId(parentNode.getId());
+            obj.setAncestors(parentNode.getAncestors() + "," + parentNode.getId());
+            obj.setType(1);
+            obj.setStatus(1);
+            obj.setIsDeleted(0);
+            obj.setIsCustom(1);
+
+            if (ObjectUtil.isNotEmpty(SecureUtil.getUser())) {
+                obj.setCreateUser(SecureUtil.getUserId());
+                obj.setUpdateUser(SecureUtil.getUserId());
+                String deptIds = SecureUtil.getDeptId();
+                obj.setCreateTime(new Date());
+                obj.setUpdateTime(new Date());
+                List<String> strings = Func.toStrList(deptIds);
+                if (strings.size() > 0) {
+                    obj.setCreateDept(Long.parseLong(strings.get(0)));
+                }
+                obj.setTenantId(SecureUtil.getTenantId());
+            }
+
+            if (wbsTreeContractClient.saveBatch(Collections.singletonList(obj))) {
+                informationQueryService.delAsyncWbsTree(parentNode.getContractId());
+                return R.success("操作成功");
+            }
+        }
+        return R.fail("未获取到当前选择节点信息");
+    }
+
 }
 }

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

@@ -717,7 +717,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             if (contractInfo != null) {
             if (contractInfo != null) {
                 /* =========================== 施工合同段 =========================== */
                 /* =========================== 施工合同段 =========================== */
                 if (new Integer(1).equals(contractInfo.getContractType())) {
                 if (new Integer(1).equals(contractInfo.getContractType())) {
-                    String sql = "select p_key_id,contract_id,(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,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (org.apache.commons.lang.StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId + " ORDER BY a.sort,title,a.create_time";
+                    String sql = "select is_custom,p_key_id,contract_id,(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,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (org.apache.commons.lang.StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId + " ORDER BY a.sort,title,a.create_time";
                     List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                     List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                     if (lazyNodes.size() > 0) {
                     if (lazyNodes.size() > 0) {
                         /*获取当前合同段节点本地缓存信息*/
                         /*获取当前合同段节点本地缓存信息*/
@@ -827,7 +827,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                     for (String sgContractId : contractIds) {
                     for (String sgContractId : contractIds) {
                         ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
                         ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
                         if (sgContractInfo != null) {
                         if (sgContractInfo != null) {
-                            List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (org.apache.commons.lang.StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+                            List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select is_custom,p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (org.apache.commons.lang.StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                             if (lazyNodes.size() > 0) {
                             if (lazyNodes.size() > 0) {
                                 List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
                                 List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
                                 List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
                                 List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
@@ -998,7 +998,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                     List<WbsTreeContractLazyVO> collect = firstNodes.stream().filter(f -> f.getParentId().equals(Long.parseLong(parentId))).collect(Collectors.toList());
                     List<WbsTreeContractLazyVO> collect = firstNodes.stream().filter(f -> f.getParentId().equals(Long.parseLong(parentId))).collect(Collectors.toList());
                     List<Long> pKeyIds = collect.stream().map(WbsTreeContractLazyVO::getPKeyId).collect(Collectors.toList());
                     List<Long> pKeyIds = collect.stream().map(WbsTreeContractLazyVO::getPKeyId).collect(Collectors.toList());
                     if (pKeyIds.size() > 0) {
                     if (pKeyIds.size() > 0) {
-                        List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where p_key_id IN (" + StringUtils.join(pKeyIds, ",") + ") ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+                        List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select is_custom,p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where p_key_id IN (" + StringUtils.join(pKeyIds, ",") + ") ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                         if (lazyNodes.size() > 0) {
                         if (lazyNodes.size() > 0) {
                             for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
                             for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
                                 lazyNodeVO.setType(lazyNodeVO.getNodeType());
                                 lazyNodeVO.setType(lazyNodeVO.getNodeType());
@@ -1036,7 +1036,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                 List<WbsTreeContractLazyVO> collect = firstNodes.stream().filter(f -> f.getParentId().equals(Long.parseLong(parentId))).collect(Collectors.toList());
                                 List<WbsTreeContractLazyVO> collect = firstNodes.stream().filter(f -> f.getParentId().equals(Long.parseLong(parentId))).collect(Collectors.toList());
                                 List<Long> pKeyIds = collect.stream().map(WbsTreeContractLazyVO::getPKeyId).collect(Collectors.toList());
                                 List<Long> pKeyIds = collect.stream().map(WbsTreeContractLazyVO::getPKeyId).collect(Collectors.toList());
                                 if (pKeyIds.size() > 0) {
                                 if (pKeyIds.size() > 0) {
-                                    List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where p_key_id IN (" + StringUtils.join(pKeyIds, ",") + ") ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+                                    List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select is_custom,p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where p_key_id IN (" + StringUtils.join(pKeyIds, ",") + ") ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                                     if (lazyNodes.size() > 0) {
                                     if (lazyNodes.size() > 0) {
                                         for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
                                         for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
                                             lazyNodeVO.setType(lazyNodeVO.getNodeType());
                                             lazyNodeVO.setType(lazyNodeVO.getNodeType());
@@ -1049,7 +1049,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                                 }
                                 }
                             }
                             }
                         } else {
                         } else {
-                            List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where parent_id = 0 AND contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+                            List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select is_custom,p_key_id,contract_id,(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,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,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 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where parent_id = 0 AND contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                             for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
                             for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
                                 lazyNode.setTitle(sgContractInfo.getContractName());
                                 lazyNode.setTitle(sgContractInfo.getContractName());
                                 lazyNode.setType(lazyNode.getNodeType());
                                 lazyNode.setType(lazyNode.getNodeType());