Browse Source

合同段监理、业主类型接口调整

liuyc 2 years ago
parent
commit
9da652c8eb
14 changed files with 462 additions and 92 deletions
  1. 13 2
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/WbsTreeContract.java
  2. 16 9
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ContractInfoVO.java
  3. 61 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractVO2.java
  4. 28 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractVO3.java
  5. 21 5
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java
  6. 2 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java
  7. 8 12
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java
  8. 2 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml
  9. 6 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.java
  10. 120 42
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml
  11. 6 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IContractInfoService.java
  12. 177 11
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java
  13. 1 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java
  14. 1 1
      doc/nacos/blade-dev.yaml

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

@@ -40,7 +40,7 @@ public class WbsTreeContract extends BaseEntity {
     /**
      * wbsType
      */
-    @ApiModelProperty(name = "wbsType", value = "wbsType", required = false)
+    @ApiModelProperty(name = "wbsType", value = "wbsType")
     private Integer wbsType;
 
     /**
@@ -57,6 +57,18 @@ public class WbsTreeContract extends BaseEntity {
     @ApiModelProperty(name = "contractId", value = "合同Id", required = true)
     private String contractId;
 
+    /**
+     * 合同段类型
+     */
+    @ApiModelProperty(name = "contractType", value = "合同段类型")
+    private Integer contractType;
+
+    /**
+     * 合同段关联id(监理、业主合同关联施工合同id)
+     */
+    @ApiModelProperty(name = "contractIdRelation", value = "合同段关联id(监理、业主合同关联施工合同id)")
+    private String contractIdRelation;
+
     /**
      * 租户id
      */
@@ -166,5 +178,4 @@ public class WbsTreeContract extends BaseEntity {
     private Integer isLinkTable;
 
 
-
 }

+ 16 - 9
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ContractInfoVO.java

@@ -20,6 +20,8 @@ import org.springblade.manager.entity.ContractInfo;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
+
 /**
  * 合同段信息表视图实体类
  *
@@ -29,16 +31,21 @@ import lombok.EqualsAndHashCode;
 @Data
 @EqualsAndHashCode(callSuper = true)
 public class ContractInfoVO extends ContractInfo {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 项目名称
+     */
+    private String projectName;
 
-	/**
-	 * 项目名称
-	 */
-	private String projectName;
+    /**
+     * 合同段名称,用于同一返回格式
+     */
+    private String name;
 
-	/**
-	 * 合同段名称,用于同一返回格式
-	 */
-	private String name;
+    /**
+     * 监理、业主分配当前项目下的施工Wbs树根节点idList
+     */
+    private List<WbsTreeContractVO3> idList;
 
 }

+ 61 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractVO2.java

@@ -0,0 +1,61 @@
+package org.springblade.manager.vo;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * wbs合同段树关系实体类
+ *
+ * @author liuyc
+ * @since 2022-05-23
+ */
+@Data
+public class WbsTreeContractVO2 implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private Long pKeyId;
+    /**
+     * 主键id
+     */
+    private Long id;
+    /**
+     * wbsId
+     */
+    private String wbsId;
+    /**
+     * wbsType
+     */
+    private Integer wbsType;
+    /**
+     * 项目id
+     */
+    private String projectId;
+    /**
+     * 项目名称
+     */
+    private String projectName;
+    /**
+     * 合同id
+     */
+    private String contractId;
+    /**
+     * 合同类型
+     */
+    private Integer contractType;
+    /**
+     * 节点名
+     */
+    private String deptName;
+    /**
+     * 节点全称
+     */
+    private String fullName;
+
+
+}

+ 28 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractVO3.java

@@ -0,0 +1,28 @@
+package org.springblade.manager.vo;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class WbsTreeContractVO3 implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private String pkeyId;
+
+    /**
+     * 当前节点id
+     */
+    private Long id;
+
+    /**
+     * 合同id
+     */
+    private String contractId;
+
+
+}

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

@@ -44,9 +44,7 @@ import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.mapper.SaveUserInfoByProjectMapper;
 import org.springblade.manager.service.IWbsTreeContractService;
 import org.springblade.manager.service.SaveUserInfoByProjectService;
-import org.springblade.manager.vo.CRolePostVO;
-import org.springblade.manager.vo.WbsTreeContractTreeVO;
-import org.springblade.manager.vo.WbsTreeVO;
+import org.springblade.manager.vo.*;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 import org.springblade.system.user.vo.UserVO2;
@@ -56,7 +54,6 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import org.springblade.manager.entity.ContractInfo;
-import org.springblade.manager.vo.ContractInfoVO;
 import org.springblade.manager.wrapper.ContractInfoWrapper;
 import org.springblade.manager.service.IContractInfoService;
 import org.springblade.core.boot.ctrl.BladeController;
@@ -401,7 +398,7 @@ public class ContractInfoController extends BladeController {
             @ApiImplicitParam(name = "项目id", value = "projectId", required = true),
             @ApiImplicitParam(name = "合同段id", value = "contractId", required = true)
     })
-    public R saveWbsTreeInContract(String wbsId, String projectId, String contractId) {
+    public R tree(String wbsId, String projectId, String contractId) {
         List<WbsTreeContractTreeVO> tree = contractInfoService.tree(wbsId, projectId, contractId);
         if (tree != null && tree.size() > 0) {
             return R.data(tree);
@@ -410,4 +407,23 @@ public class ContractInfoController extends BladeController {
     }
 
 
+    /**
+     * 查询所有施工合同wbs树根节点(新建监理或业主合同段时,加载当前项目下的施工WBS树,分配时使用)
+     */
+    @GetMapping("/treeAllConstruction")
+    @ApiOperationSupport(order = 18)
+    @ApiOperation(value = "查询所有施工合同wbs树根节点", notes = "传入wbsId,项目id")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "wbsId", value = "wbsId", required = true),
+            @ApiImplicitParam(name = "项目id", value = "projectId", required = true),
+    })
+    public R treeAllConstruction(String wbsId, String projectId) {
+        List<WbsTreeContractVO2> tree = contractInfoService.treeTwo(wbsId, projectId);
+        if (tree != null && tree.size() > 0) {
+            return R.data(tree);
+        }
+        return R.fail(200, "未查询到信息");
+    }
+    
+
 }

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

@@ -299,9 +299,8 @@ public class WbsTreeController extends BladeController {
     @RequestMapping(value = "/import-wbsTree", method = RequestMethod.POST)
     public R importWbsTree(@RequestPart("excelFile") MultipartFile excelFile,
                            @RequestPart("wbsTreeFu") WbsTree wbsTreeFu) throws IOException {
-        Long parentId = wbsTreeFu.getParentId();
-        WbsTree wbsTree1 = wbsTreeService.getById(parentId);
-        if (wbsTree1.getProjectNodeId().equals(parentId)) {
+        WbsTree wbsTree1 = wbsTreeService.getById(wbsTreeFu.getParentId());
+        if (wbsTree1.getProjectNodeId().equals(wbsTreeFu.getParentId())) {
             wbsTreeService.deleteBatchByProjectNodeId(wbsTree1.getProjectNodeId());
             boolean result = wbsTreeService.importWbsTree(excelFile, wbsTreeFu, wbsTree1);
             if (result) {

+ 8 - 12
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java

@@ -38,14 +38,8 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<ContractInfo> selectContractByProjectIds(@Param("ids") List<Long> ids);
 
-    /**
-     * 自定义分页
-     *
-     * @param page
-     * @param contractInfo
-     * @return
-     */
-    List<ContractInfoVO> selectContractInfoPage(IPage page, ContractInfoVO contractInfo);
+    List<ContractInfoVO> selectContractInfoPage(IPage page,
+                                                ContractInfoVO contractInfo);
 
     List<ContractlnfoCountVO> selectContractInfoCount();
 
@@ -53,9 +47,11 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<CRolePostVO> findJobByRoleId(@Param("id") String id);
 
-    List<UserVO2> findAllUserByCondition(IPage page, @Param("Values") FindAllUserByConditionDTO values);
+    List<UserVO2> findAllUserByCondition(IPage page,
+                                         @Param("Values") FindAllUserByConditionDTO values);
 
-    List<User> findUserListByCondition(IPage page, @Param("Values") FindAllUserByConditionDTO values);
+    List<User> findUserListByCondition(IPage page,
+                                       @Param("Values") FindAllUserByConditionDTO values);
 
     List<User> findUserInfoByCondition(@Param("rId") String rId,
                                        @Param("pId") String pId,
@@ -63,7 +59,8 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<User> findUserByName(@Param("name") String name);
 
-    Integer updatePasswordByUserId(@Param("userId") String userId, @Param("password") String password);
+    Integer updatePasswordByUserId(@Param("userId") String userId,
+                                   @Param("password") String password);
 
     Boolean deleteFile(@Param("url") String url);
 
@@ -73,6 +70,5 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
                                      @Param("wbsType") Integer wbsType,
                                      @Param("parentId") String parentId);
 
-//    String selectStartFileId(@Param("id") String id);
 
 }

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

@@ -58,6 +58,7 @@
         <result column="wbsType" property="wbsType"/>
     </resultMap>
 
+
     <select id="selectContractByProjectIds" resultMap="contractInfoResultMap">
         select id, p_id, contract_name, contract_number from m_contract_info where is_deleted = 0 and p_id in
         <foreach collection="ids" item="pId" open="(" separator="," close=")">
@@ -185,4 +186,5 @@
     </select>
 
 
+
 </mapper>

+ 6 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.java

@@ -6,6 +6,7 @@ import org.springblade.manager.entity.WbsTree;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.vo.WbsTreeContractVO;
+import org.springblade.manager.vo.WbsTreeContractVO2;
 
 import java.util.List;
 
@@ -56,4 +57,9 @@ public interface WbsTreeContractMapper extends BaseMapper<WbsTreeContract> {
                            @Param("pKeyId") Long pKeyId,
                            @Param("wbsType") Integer wbsType);
 
+    List<WbsTreeContractVO2> selectListByCondition(String wbsId, String projectId);
+
+    void updateByCondition2(Long contractId, String contractIdRelation);
+
+    WbsTreeContract selectCondition(Long getContractId, Long id, String getContractIdRelation, Integer contractType);
 }

+ 120 - 42
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml

@@ -9,6 +9,8 @@
         <result column="wbs_id" property="wbsId"/>
         <result column="project_id" property="projectId"/>
         <result column="contract_id" property="contractId"/>
+        <result column="contract_type" property="contractType"/>
+        <result column="contract_id_relation" property="contractIdRelation"/>
         <result column="is_deleted" property="isDeleted"/>
         <result column="status" property="status"/>
         <result column="create_time" property="createTime"/>
@@ -46,47 +48,47 @@
     </resultMap>
 
     <insert id="insertWbsTreeContract1">
-            INSERT INTO m_wbs_tree_contract(
-            p_key_id,id,wbs_id,wbs_type,project_id,contract_id,tenant_id,parent_id,ancestors,dept_category,dept_name,full_name,sort,remark,`type`,
-            table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
-            unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
-            VALUES(
-            #{snowId},#{wbsTree.id},#{wbsTree.wbsId},#{wbsType},#{wbsTree.projectId},#{contractId},#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
-            #{wbsTree.deptCategory},#{wbsTree.deptName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
-            #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
-            #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
-            #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
+        INSERT INTO m_wbs_tree_contract(
+        p_key_id,id,wbs_id,wbs_type,project_id,contract_id,contract_type,tenant_id,parent_id,ancestors,dept_category,dept_name,full_name,sort,remark,`type`,
+        table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
+        unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
+        VALUES(
+        #{snowId},#{wbsTree.id},#{wbsTree.wbsId},#{wbsType},#{wbsTree.projectId},#{contractId},1,#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
+        #{wbsTree.deptCategory},#{wbsTree.deptName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
+        #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
+        #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
+        #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
     </insert>
 
     <insert id="insertByCondition">
-            INSERT INTO m_wbs_tree_contract(
-            p_key_id,id,wbs_id,wbs_type,project_id,contract_id,tenant_id,parent_id,ancestors,dept_category,dept_name,full_name,sort,remark,`type`,
-            table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
-            unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
-            VALUES(
-            #{pKeyId},#{wbsTree.id},#{wbsTree.wbsId},#{wbsType},#{wbsTree.projectId},#{contractId},#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
-            #{wbsTree.deptCategory},#{wbsTree.deptName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
-            #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
-            #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
-            #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
+        INSERT INTO m_wbs_tree_contract(
+        p_key_id,id,wbs_id,wbs_type,project_id,contract_id,contract_type,tenant_id,parent_id,ancestors,dept_category,dept_name,full_name,sort,remark,`type`,
+        table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
+        unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
+        VALUES(
+        #{pKeyId},#{wbsTree.id},#{wbsTree.wbsId},#{wbsType},#{wbsTree.projectId},#{contractId},1,#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
+        #{wbsTree.deptCategory},#{wbsTree.deptName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
+        #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
+        #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
+        #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
     </insert>
 
     <update id="deleteByCondition">
-            UPDATE m_wbs_tree_contract
-            SET is_deleted = 1
-            WHERE  id = #{id}
-            AND wbs_id = #{wbsId}
-            AND project_id = #{projectId}
-            AND contract_id = #{contractId}
+        UPDATE m_wbs_tree_contract
+        SET is_deleted = 1
+        WHERE  id = #{id}
+        AND wbs_id = #{wbsId}
+        AND project_id = #{projectId}
+        AND contract_id = #{contractId}
     </update>
 
     <update id="updateByCondition">
-            UPDATE m_wbs_tree_contract
-            SET is_deleted = 0
-            WHERE id = #{id}
-            AND wbs_id = #{wbsId}
-            AND project_id =#{projectId}
-            AND contract_id = #{contractId}
+        UPDATE m_wbs_tree_contract
+        SET is_deleted = 0
+        WHERE id = #{id}
+        AND wbs_id = #{wbsId}
+        AND project_id =#{projectId}
+        AND contract_id = #{contractId}
     </update>
 
     <update id="updateByCondition1">
@@ -102,6 +104,14 @@
         AND wbs_id = #{wbsTP.wbsId}
     </update>
 
+    <update id="updateByCondition2">
+        UPDATE m_wbs_tree_contract
+        SET is_deleted = 0
+        WHERE contract_id = #{contractId}
+        AND contract_id_relation = #{contractIdRelation}
+        AND status = 1
+    </update>
+
 
     <select id="selectAll" resultMap="resultMap2">
         SELECT
@@ -126,11 +136,11 @@
             m_wbs_tree_contract
         WHERE
             id = #{id}
-            AND project_id = #{projectId}
-            AND contract_id = #{contractId}
-            AND wbs_id = #{wbsId}
-            AND STATUS = 1
-            AND is_deleted = 0
+        AND project_id = #{projectId}
+        AND contract_id = #{contractId}
+        AND wbs_id = #{wbsId}
+        AND STATUS = 1
+        AND is_deleted = 0
     </select>
 
     <select id="selectByCondition2" resultType="org.springblade.manager.entity.WbsTreeContract">
@@ -140,10 +150,10 @@
             m_wbs_tree_contract
         WHERE
             id = #{id}
-            AND project_id = #{projectId}
-            AND contract_id = #{contractId}
-            AND wbs_id = #{wbsId}
-            AND STATUS = 1
+        AND project_id = #{projectId}
+        AND contract_id = #{contractId}
+        AND wbs_id = #{wbsId}
+        AND STATUS = 1
     </select>
 
     <select id="findAllNodeList2" resultType="org.springblade.manager.entity.WbsTreeContract">
@@ -161,7 +171,7 @@
     <select id="selectParent" resultType="org.springblade.manager.entity.WbsTreePrivate">
         SELECT dept_name FROM m_wbs_tree_private
         WHERE
-        project_id = #{projectId}
+            project_id = #{projectId}
         AND wbs_id = #{wbsId}
         AND id = #{parentId}
     </select>
@@ -181,4 +191,72 @@
         and contract_id = #{contractId}
     </select>
 
+    <select id="selectListByCondition" resultType="org.springblade.manager.vo.WbsTreeContractVO2">
+        SELECT
+            p_key_id AS "pKeyId",
+            id,
+            dept_name AS "deptName",
+            full_name AS "fullName",
+            project_id AS "projectId",
+            (select project_name from m_project_info where id =#{projectId}) AS "projectName",
+            contract_id AS "contractId",
+            contract_type AS "contractType",
+            wbs_type AS "wbsType",
+            wbs_id AS "wbsId"
+        FROM
+            m_wbs_tree_contract
+        WHERE project_id = #{projectId}
+        AND wbs_id = #{wbsId}
+        AND contract_type = 1
+        AND parent_id = 0
+        AND is_deleted = 0
+        AND status = 1
+    </select>
+
+    <select id="selectCondition" resultType="org.springblade.manager.entity.WbsTreeContract">
+        SELECT
+            id,
+            p_key_id,
+            wbs_id,
+            wbs_type,
+            project_id,
+            contract_id,
+            contract_type,
+            contract_id_relation,
+            tenant_id,
+            parent_id,
+            dept_category,
+            type,
+            dept_name,
+            full_name,
+            table_type,
+            sort,
+            ancestors,
+            remark,
+            unique_code,
+            partition_code,
+            is_expernode,
+            is_concrete,
+            table_owner,
+            major_data_type,
+            init_table_name,
+            is_link_table,
+            create_user,
+            create_dept,
+            create_time,
+            update_user,
+            update_time,
+            STATUS,
+            is_deleted
+        FROM
+            m_wbs_tree_contract
+        WHERE
+            is_deleted = 1
+        AND parent_id = 0
+        AND contract_id = #{getContractId}
+        AND id = #{id}
+        AND contract_id_relation = #{getContractIdRelation}
+        AND contract_type = #{contractType}
+    </select>
+
 </mapper>

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

@@ -19,11 +19,9 @@ package org.springblade.manager.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
 import org.springblade.manager.entity.ContractInfo;
-import org.springblade.manager.vo.CRolePostVO;
-import org.springblade.manager.vo.ContractInfoVO;
+import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.vo.*;
 import org.springblade.core.mp.base.BaseService;
-import org.springblade.manager.vo.WbsTreeContractTreeVO;
-import org.springblade.manager.vo.WbsTreeVO;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.vo.UserVO2;
 
@@ -62,6 +60,8 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
 
     List<WbsTreeContractTreeVO> tree(String wbsId, String projectId, String contractId);
 
+    List<WbsTreeContractVO2> treeTwo(String wbsId, String projectId);
+
     List<WbsTreeContractTreeVO> queryContractWbsTreeByContractIdAndType(String contractId, Integer wbsType, String parentId);
 
     List<WbsTreeContractTreeVO> queryContractWbsTreeAll(String contractId, Integer wbsType, String parentId);
@@ -69,4 +69,6 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
     boolean saveAndUpdateContract(ContractInfoVO contractInfo);
 
     List<ContractInfo> findContractInProject(String ids);
+
+
 }

+ 177 - 11
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -22,20 +22,21 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import org.apache.ibatis.annotations.Param;
 import org.springblade.common.utils.BaiduApiUtil;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
 import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.ProjectContractArea;
+import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.mapper.ProjectContractAreaMapper;
 import org.springblade.manager.mapper.SaveUserInfoByProjectMapper;
-import org.springblade.manager.vo.CRolePostVO;
-import org.springblade.manager.vo.ContractInfoVO;
+import org.springblade.manager.mapper.WbsTreeContractMapper;
+import org.springblade.manager.vo.*;
 import org.springblade.manager.mapper.ContractInfoMapper;
 import org.springblade.manager.service.IContractInfoService;
 import org.springblade.core.mp.base.BaseServiceImpl;
-import org.springblade.manager.vo.WbsTreeContractTreeVO;
-import org.springblade.manager.vo.WbsTreeVO;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.vo.UserVO2;
 import org.springframework.stereotype.Service;
@@ -44,6 +45,8 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -62,6 +65,8 @@ public class ContractInfoServiceImpl
     private final ContractInfoMapper contractInfoMapper;
     private final ProjectContractAreaMapper projectContractAreaMapper;
     private final SaveUserInfoByProjectMapper saveUserInfoByProjectMapper;
+    private final WbsTreeContractMapper wbsTreeContractMapper;
+    private final WbsTreeContractServiceImpl wbsTreeContractService;
 
     @Override
     public List<ContractInfo> selectContractByProjectIds(List<Long> ids) {
@@ -136,6 +141,13 @@ public class ContractInfoServiceImpl
         return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, contractId, null, null));
     }
 
+    @Override
+    public List<WbsTreeContractVO2> treeTwo(String wbsId, String projectId) {
+        //查询当前项目下所有施工合同树根节点
+        List<WbsTreeContractVO2> list = wbsTreeContractMapper.selectListByCondition(wbsId, projectId);
+        return list;
+    }
+
     /**
      * 对客户端接口
      *
@@ -154,10 +166,139 @@ public class ContractInfoServiceImpl
         return this.baseMapper.tree(null, null, contractId, wbsType, parentId);
     }
 
+
+    /**
+     * 新增合同段保存(施工-监理引用施工合同wbs私有树)
+     *
+     * @param contractInfo
+     * @return
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean saveAndUpdateContract(ContractInfoVO contractInfo) {
-        boolean row = saveOrUpdate(contractInfo);
+        //新增
+        if (contractInfo.getId() == null) {
+            List<ContractInfo> contractInfos = baseMapper.selectList(Wrappers.<ContractInfo>query().lambda()
+                    .eq(ContractInfo::getContractName, contractInfo.getContractName())
+                    .eq(ContractInfo::getPId, contractInfo.getPId())
+            );
+            if (contractInfos.size() > 0) {
+                throw new ServiceException("合同段名称已存在当前项目下,请重新输入");
+            }
+            if (StringUtils.isEmpty(String.valueOf(contractInfo.getContractType()))) {
+                throw new ServiceException("合同类型不能为空");
+            }
+            //新增
+            boolean row = saveOrUpdate(contractInfo);
+            //新增contract_type=2监理或=3指挥部(业主)类型Wbs树
+            if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
+                List<WbsTreeContractVO3> infos = contractInfo.getIdList();
+                infos.forEach(info -> {
+                    List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
+                            .eq(WbsTreeContract::getContractId, info.getContractId())
+                    );
+                    //初始化
+                    wbsTreeContracts.forEach(i -> {
+                        Long id = SnowFlakeUtil.getId();
+                        i.setPKeyId(id);
+                        i.setContractIdRelation(i.getContractId());
+                        i.setContractId(String.valueOf(contractInfo.getId()));
+                        i.setContractType(contractInfo.getContractType());
+                    });
+                    //新增
+                    wbsTreeContractService.saveBatch(wbsTreeContracts);
+                });
+            }
+            return submitContractRelevantInfo(row, contractInfo);
+
+        } else {  //编辑修改
+            List<ContractInfo> contractInfos = baseMapper.selectList(Wrappers.<ContractInfo>query().lambda()
+                    .eq(ContractInfo::getContractName, contractInfo.getContractName())
+                    .eq(ContractInfo::getPId, contractInfo.getPId())
+                    .ne(ContractInfo::getId, contractInfo.getId())
+            );
+            if (contractInfos.size() > 0) {
+                throw new ServiceException("合同段名称已存在当前项目下,请重新输入");
+            }
+            if (StringUtils.isEmpty(String.valueOf(contractInfo.getContractType()))) {
+                throw new ServiceException("合同类型不能为空");
+            }
+            boolean row = saveOrUpdate(contractInfo);
+            if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
+                List<String> idList1 = new ArrayList<>();  //当前所有入参施工合同根节点合同id
+                List<String> idList2 = new ArrayList<>();  //当前所有已引用监理或业主根节点合同引用id
+                List<WbsTreeContractVO3> list = contractInfo.getIdList();
+                if (list.size() > 0) {
+                    list.forEach(cId -> {
+                        //获取入参根节点id
+                        String contractId = cId.getContractId();
+                        idList1.add(contractId);
+                    });
+                }
+                //查询当前所有已引用监理或业主根节点合同引用id
+                List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
+                        .eq(WbsTreeContract::getContractId, contractInfo.getId())
+                        .eq(WbsTreeContract::getContractType, contractInfo.getContractType())
+                        .eq(WbsTreeContract::getStatus, 1)
+                        .eq(WbsTreeContract::getParentId, 0)
+                );
+                wbsTreeContracts.forEach(id -> {
+                    String contractIdRelation = id.getContractIdRelation();
+                    idList2.add(String.valueOf(contractIdRelation));
+                });
+                List<String> result = getDiffrent(idList1, idList2);
+                System.out.println("list1:" + idList1);
+                System.out.println("list2:" + idList2);
+                System.out.println("result:" + result);
+
+                if (idList1.size() > idList2.size()) {
+                    //新增
+                    result.forEach(id -> {
+                        //查询当前需要引用的施工合同wbs树根节点信息
+                        WbsTreeContract wbsTreeContract = wbsTreeContractMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
+                                .eq(WbsTreeContract::getContractId, id)
+                                .eq(WbsTreeContract::getParentId, 0)
+                                .eq(WbsTreeContract::getContractType, 1)
+                        );
+                        WbsTreeContract wbsTreeContractsIsDeleted = wbsTreeContractMapper.selectCondition(contractInfo.getId(), wbsTreeContract.getId(), id, contractInfo.getContractType());
+                        if (wbsTreeContractsIsDeleted != null) {
+                            //修改 通过当前合同id = contractInfo.getId(),监理或业主关联的合同段id = contractIdRelation
+                            wbsTreeContractMapper.updateByCondition2(contractInfo.getId(), wbsTreeContractsIsDeleted.getContractIdRelation());
+                        } else {
+                            //新增 根据施工合同根节点查询当前根节点下的施工合同wbs树
+                            List<WbsTreeContract> wbsTreeContractsList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
+                                    .eq(WbsTreeContract::getContractId, id)
+                                    .eq(WbsTreeContract::getContractType, 1)
+                            );
+                            //初始化
+                            wbsTreeContractsList.forEach(i -> {
+                                Long id1 = SnowFlakeUtil.getId();
+                                i.setPKeyId(id1);
+                                i.setContractIdRelation(i.getContractId());
+                                i.setContractId(String.valueOf(contractInfo.getId()));
+                                i.setContractType(contractInfo.getContractType());
+                            });
+                            wbsTreeContractService.saveBatch(wbsTreeContractsList);
+                        }
+                    });
+                } else {
+                    //删除wbs树
+                    result.forEach(id -> {
+                        //根据关联项目id = getContractIdRelation , 删除监理或业主合同的wbs树
+                        wbsTreeContractMapper.delete(Wrappers.<WbsTreeContract>update().lambda()
+                                .set(WbsTreeContract::getIsDeleted, 1)
+                                .eq(WbsTreeContract::getContractIdRelation, id)
+                                .eq(WbsTreeContract::getProjectId, contractInfo.getPId())
+                                .eq(WbsTreeContract::getContractId, contractInfo.getId())
+                        );
+                    });
+                }
+            }
+            return submitContractRelevantInfo(row, contractInfo);
+        }
+    }
+
+    private boolean submitContractRelevantInfo(boolean row, ContractInfoVO contractInfo) {
         if (row) {
             //绑定用户角色信息
             List<SaveUserInfoByProjectDTO> list = saveUserInfoByProjectMapper.selectList(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
@@ -185,7 +326,6 @@ public class ContractInfoServiceImpl
                 projectContractArea.setProjectId(contractInfo.getPId());
                 projectContractArea.setIsDeleted(0);
                 projectContractArea.setContractId(String.valueOf(contractInfo.getId()));
-
                 QueryWrapper<ProjectContractArea> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("project_id", contractInfo.getPId());
                 queryWrapper.eq("contract_id", contractInfo.getId());
@@ -196,19 +336,45 @@ public class ContractInfoServiceImpl
                 queryWrapper.eq("is_deleted", contractInfo.getIsDeleted());
                 ProjectContractArea projectContractArea1 = projectContractAreaMapper.selectOne(queryWrapper);
                 if (projectContractArea1 == null) {
-                    int insert = projectContractAreaMapper.insert(projectContractArea);
-                    if (insert > 0) {
-                        return true;
-                    }
+                    int res = projectContractAreaMapper.insert(projectContractArea);
+                    return res > 0;
                 }
+                return true;
             } catch (IOException e) {
                 e.printStackTrace();
             }
-            return true;
         }
         return false;
     }
 
+    private static List<String> getDiffrent(List<String> list1, List<String> list2) {
+        List<String> diff = new ArrayList<String>();
+        List<String> maxList = list1;
+        List<String> minList = list2;
+        if (list2.size() > list1.size()) {
+            maxList = list2;
+            minList = list1;
+        }
+        Map<String, Integer> map = new HashMap<String, Integer>(maxList.size());
+        for (String string : maxList) {
+            map.put(string, 1);
+        }
+        for (String string : minList) {
+            if (map.get(string) != null) {
+                map.put(string, 2);
+                continue;
+            }
+            diff.add(string);
+        }
+        for (Map.Entry<String, Integer> entry : map.entrySet()) {
+            if (entry.getValue() == 1) {
+                diff.add(entry.getKey());
+            }
+        }
+        return diff;
+    }
+
+
     @Override
     public List<ContractInfo> findContractInProject(String ids) {
         return baseMapper.selectList(Wrappers.<ContractInfo>query().lambda().eq(ContractInfo::getPId, ids));

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

@@ -200,7 +200,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 if (b) {
                     //新增实体表
                     initTable(initTableName);
-
+                    //返参
                     WbsTreeBatchImportDTO wbsTreeBatchImportDTO = new WbsTreeBatchImportDTO();
                     wbsTreeBatchImportDTO.setId(id);
                     wbsTreeBatchImportDTO.setTableName(deptName);
@@ -345,7 +345,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         }
     }
 
-
     @Override
     public List<WbsNodeTableVO> selectByNodeTable(String id) {
         //查询节点下的所有表单
@@ -452,7 +451,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         return i > 0;
     }
 
-
     private WbsTree importTree(WbsTree wbsTreeZi) {
         //查重
         QueryWrapper<WbsTree> queryWrapper = new QueryWrapper<>();

+ 1 - 1
doc/nacos/blade-dev.yaml

@@ -42,7 +42,7 @@ blade:
   datasource:
     dev:
       # MySql
-      url: jdbc:mysql://192.168.3.19:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
+      url: jdbc:mysql://192.168.4.20:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
       username: bladex
       password: 68LzdwJ6p7RAGijK
       # PostgreSQL