liuyc 3 年 前
コミット
bb672ae8bf

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

@@ -214,4 +214,10 @@ public class WbsTreeContract extends BaseEntity {
     @ApiModelProperty(value = "是否能预览pdf 1否 2是")
     private Integer isTabPdf;
 
+    /**
+     * type=2,映射私有pKeyId
+     */
+    @ApiModelProperty(value = "type=2,映射私有pKeyId")
+    private Long isTypePrivatePid;
+
 }

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

@@ -23,12 +23,6 @@ public interface WbsTreeContractMapper extends BaseMapper<WbsTreeContract> {
 
     List<WbsTreeContractVO> selectAll();
 
-    Integer insertWbsTreeContract1(@Param("snowId") Long snowId,
-                                   @Param("wbsType") Integer wbsType,
-                                   @Param("contractId") String contractId,
-                                   @Param("wbsTree") WbsTreePrivate wbsTree);
-
-
     void deleteBatch(@Param("ids") List<Long> ids,
                      @Param("wbsId") String wbsId,
                      @Param("projectId") String projectId,
@@ -98,5 +92,6 @@ public interface WbsTreeContractMapper extends BaseMapper<WbsTreeContract> {
 
     List<WbsTreeContract> selectTableListInfo(List<Long> ids, String wbsId, String projectId, String contractId);
 
+    List<WbsTreeContract> selectContractList(String wbsId, String projectId,@Param("ids") List<Long> ids);
 
 }

+ 10 - 22
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeContractMapper.xml

@@ -45,7 +45,7 @@
         <result column="tab_file_type" property="tabFileType"/>
         <result column="is_cope_tab" property="isCopeTab"/>
         <result column="is_tab_pdf" property="isTabPdf"/>
-
+        <result column="is_type_private_pid" property="isTypePrivatePid"/>
     </resultMap>
 
     <resultMap id="resultMap2" type="org.springblade.manager.vo.WbsTreeContractVO">
@@ -73,27 +73,6 @@
         <result column="contractIdRelation" property="contractIdRelation"/>
     </resultMap>
 
-
-    <insert id="insertWbsTreeContract1">
-        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, excel_id)
-        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},
-                #{wbsTree.excelId})
-    </insert>
-
     <insert id="insertByCondition">
         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,
@@ -604,4 +583,13 @@
         ) group by id order by parent_id,`sort`
     </select>
 
+    <select id="selectContractList" resultType="org.springblade.manager.entity.WbsTreeContract">
+        SELECT * FROM m_wbs_tree_contract WHERE id in
+        <foreach item="ids" collection="ids" open="(" close=")" separator=",">
+            #{ids}
+        </foreach>
+        AND project_id = #{projectId}
+        AND wbs_id = #{wbsId}
+    </select>
+
 </mapper>

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

@@ -262,6 +262,9 @@ public class WbsTreeContractServiceImpl
         wbsTreeContract.setExcelId(wbsTree.getExcelId());
         wbsTreeContract.setHtmlUrl(wbsTree.getHtmlUrl());
         wbsTreeContract.setIsBussShow(1);
+        if (wbsTree.getType() == 2) {
+            wbsTreeContract.setIsTypePrivatePid(wbsTree.getPKeyId());
+        }
         return wbsTreeContract;
     }
 

+ 12 - 20
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -1013,24 +1013,20 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 if (pawDTO.getReferenceType().equals("public")) {
                     List<Long> ids1 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
                     //判断是否被合同段引用
-                    List<WbsTreeContract> wbsTreeContract = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
-                            .eq(WbsTreeContract::getWbsId, pawDTO.getWbsId())
-                            .eq(WbsTreeContract::getProjectId, pawDTO.getProjectId())
-                            .eq(WbsTreeContract::getParentId, 0)
-                    );
+                    List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectContractList(pawDTO.getWbsId(),pawDTO.getProjectId(),ids1);
 
-                    if (wbsTreeContract.size() > 0) {
+                    if (wbsTreeContractList.size() > 0) {
                         List<ContractInfo> contractInfoArrayList = new ArrayList<>();
-                        wbsTreeContract.stream().forEach(list -> {
+                        wbsTreeContractList.stream().forEach(list -> {
                             ContractInfo contractInfos = contractInfoMapper.selectOne(Wrappers.<ContractInfo>query().lambda()
                                     .eq(ContractInfo::getId, list.getContractId())
                             );
                             contractInfoArrayList.add(contractInfos);
                         });
-                        List<String> names = contractInfoArrayList.stream().map(ContractInfo::getContractName).collect(Collectors.toList());
-                        if (wbsTreeContract.size() > 0) {
+                        List<String> names = contractInfoArrayList.stream().distinct().map(ContractInfo::getContractName).collect(Collectors.toList());
+                        if (wbsTreeContractList.size() > 0) {
                             String join = StringUtils.join(names, ",");
-                            throw new ServiceException(StringUtil.format("当前项目wbs树已被 {} 引用中,删除失败", join));
+                            throw new ServiceException(StringUtil.format("当前项目wbs树的节点已被 {} 引用中,删除失败", join));
                         }
                     }
 
@@ -1040,24 +1036,20 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 } else if (pawDTO.getReferenceType().equals("private")) {
                     List<Long> ids2 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
                     //判断是否被合同段引用
-                    List<WbsTreeContract> wbsTreeContract = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
-                            .eq(WbsTreeContract::getWbsId, pawDTO.getPrimaryKeyId())
-                            .eq(WbsTreeContract::getProjectId, pawDTO.getProjectId())
-                            .eq(WbsTreeContract::getParentId, 0)
-                    );
+                    List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectContractList(pawDTO.getPrimaryKeyId(), pawDTO.getProjectId(), ids2);
 
-                    if (wbsTreeContract.size() > 0) {
+                    if (wbsTreeContractList.size() > 0) {
                         List<ContractInfo> contractInfoArrayList = new ArrayList<>();
-                        wbsTreeContract.stream().forEach(list -> {
+                        wbsTreeContractList.stream().forEach(list -> {
                             ContractInfo contractInfos = contractInfoMapper.selectOne(Wrappers.<ContractInfo>query().lambda()
                                     .eq(ContractInfo::getId, list.getContractId())
                             );
                             contractInfoArrayList.add(contractInfos);
                         });
-                        List<String> names = contractInfoArrayList.stream().map(ContractInfo::getContractName).collect(Collectors.toList());
-                        if (wbsTreeContract.size() > 0) {
+                        List<String> names = contractInfoArrayList.stream().distinct().map(ContractInfo::getContractName).collect(Collectors.toList());
+                        if (wbsTreeContractList.size() > 0) {
                             String join = StringUtils.join(names, ",");
-                            throw new ServiceException(StringUtil.format("当前项目wbs树已被 {} 引用中,删除失败", join));
+                            throw new ServiceException(StringUtil.format("当前项目wbs树的节点已被 {} 引用中,删除失败", join));
                         }
                     }