Selaa lähdekoodia

质检-删除节点对子节点是否上报审批的校验,因为父id和祖级节点数据错误,现在使用递归查询后的数据

qianxb 11 kuukautta sitten
vanhempi
commit
c177553828

+ 11 - 4
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -2767,10 +2767,10 @@ public class InformationWriteQueryController extends BladeController {
         this.currentNodeAllParent(parentNodeName, removeNode);
 
         //判断是否子节点有上报或审批过的资料
-        List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeNode);
-        if (list != null && list.size() >= 1) {
-            return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
-        }
+//        List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeNode);
+//        if (list != null && list.size() >= 1) {
+//            return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
+//        }
 
         //查询所有子节点 TODO(不能用ancestors字段获取,ancestors字段有问题,目前用递归获取)2023年9月19日
         //List<WbsTreeContract> removeNodeList = jdbcTemplate.query("select p_key_id,type from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + removeNode.getContractId() + " and ancestors like '%" + removeNode.getId() + "%'", new BeanPropertyRowMapper<>(WbsTreeContract.class));
@@ -2779,6 +2779,13 @@ public class InformationWriteQueryController extends BladeController {
 
         //获取pKeyId
         List<Long> removeList = removeNodeList.stream().map(WbsTreeContract::getPKeyId).distinct().collect(Collectors.toList());
+
+        /** 判断是否子节点有上报或审批过的资料,因为父id和祖级节点错误,直接使用上面的值去查询上报情况*/
+        List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeList);
+        if (list != null && list.size() >= 1) {
+            return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
+        }
+
         //拼接
         ids = ids + "," + String.join(",", JSONArray.parseArray(JSONObject.toJSONString(removeList), String.class));
         //删除掉表格 TODO(不清楚为什么要剔除表格,按理说删除节点后,节点下的表也应该一起删除的,猜测或许是为了方便恢复节点的时候表数据还存在)2023年9月19日

+ 2 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.java

@@ -137,7 +137,8 @@ public interface InformationQueryMapper extends BaseMapper<InformationQuery> {
     // 查询当前节点下,表单的有值的字段数据,根据表名
     List<QueryProcessDataVO> getNodeChildTabColsWithValueByTabName(String tabName, String pKeyId);
 
-    List<InformationQuery> selectChildrenNodeInfo(@Param("node") WbsTreeContract node);
+//    List<InformationQuery> selectChildrenNodeInfo(@Param("node") WbsTreeContract node);
+    List<InformationQuery> selectChildrenNodeInfo(@Param("ids") List<Long> removeList);
 
     List<InformationQuery> getInformationByContractId(@Param("contractId") Long contractId, @Param("classify")Integer classify);
 

+ 15 - 5
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml

@@ -941,14 +941,24 @@
     </select>
 
 
+<!--    <select id="selectChildrenNodeInfo" resultType="org.springblade.business.entity.InformationQuery">-->
+<!--        SELECT *-->
+<!--        FROM u_information_query-->
+<!--        WHERE wbs_id in (SELECT p_key_id-->
+<!--                         FROM m_wbs_tree_contract-->
+<!--                         WHERE ancestors LIKE concat('%', #{node.id}, '%') AND contract_id = #{node.contractId} AND-->
+<!--                               is_deleted = 0-->
+<!--                            or p_key_id = #{node.pKeyId})-->
+<!--          AND status IN (1, 2)-->
+<!--    </select>-->
+
     <select id="selectChildrenNodeInfo" resultType="org.springblade.business.entity.InformationQuery">
         SELECT *
         FROM u_information_query
-        WHERE wbs_id in (SELECT p_key_id
-                         FROM m_wbs_tree_contract
-                         WHERE ancestors LIKE concat('%', #{node.id}, '%') AND contract_id = #{node.contractId} AND
-                               is_deleted = 0
-                            or p_key_id = #{node.pKeyId})
+        WHERE wbs_id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
           AND status IN (1, 2)
     </select>
 

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/IInformationQueryService.java

@@ -150,7 +150,7 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
     //根据节点获取首件数据
     InformationQuery getFirstInfoByWbsId(String wbsId);
 
-    List<InformationQuery> selectChildrenNodeInfo(WbsTreeContract node);
+    List<InformationQuery> selectChildrenNodeInfo(List<Long> removeList);
 
     List<QueryProcessDataVO> getNodeChildTabColsWithValueByTabName(String initTabName, String pKeyId);
 

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java

@@ -1032,8 +1032,8 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
     }
 
     @Override
-    public List<InformationQuery> selectChildrenNodeInfo(WbsTreeContract node) {
-        return this.baseMapper.selectChildrenNodeInfo(node);
+    public List<InformationQuery> selectChildrenNodeInfo(List<Long> removeList) {
+        return this.baseMapper.selectChildrenNodeInfo(removeList);
     }
 
     @Override