Просмотр исходного кода

质检-保存表单,
1、递归查询子节点改为根据ancestors_p_id查询
2、从循环体中抽出来
3、sql先按合同id查询

LHB 1 месяц назад
Родитель
Сommit
e27f0e522f

+ 12 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -402,6 +402,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             });
                         });
                         AtomicBoolean update = new AtomicBoolean(false);
+                        List<Long> ids = getNodeType46(tec).stream().map(CurrentNode::getPkId).collect(Collectors.toList());
                         itemsMap.values().stream().filter(Measurement::isMatching).forEach(t -> {
                             ElementBlock g = null;
                             FormData vfd = t.getValue();
@@ -423,7 +424,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             if (g != null) {
                                 /*手写部分的数据加载*/
                                 if (t.getPoint().contains("混凝土强度") && false) {
-                                    List<Long> ids = getNodeType46(tec).stream().map(CurrentNode::getPkId).collect(Collectors.toList());
+//                                    List<Long> ids = getNodeType46(tec).stream().map(CurrentNode::getPkId).collect(Collectors.toList());
                                     /*质检附表m_20230316104657_1636197331206406144*/
                                     List<Map<String, Object>> listMaps = this.jdbcTemplate.queryForList("select a.p_key_id,b.key_10 name,b.key_6 design,b.key_5 data from m_wbs_tree_contract a join m_20230316104657_1636197331206406144 b on a.p_key_id=b.p_key_id where  a.is_deleted=0 and a.parent_id =" + tec.getCurrentNode().getId());
                                     if (listMaps.size() > 0) {
@@ -463,7 +464,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 
                                 List<ItemBlock> itemBlockList = g.getList();
                                 int originSize = itemBlockList.size();
-                                List<Long> ids = getNodeType46(tec).stream().map(CurrentNode::getPkId).collect(Collectors.toList());
+
                                 /*清除那些已经不存在的工序*/
                                 itemBlockList.removeIf(ik -> !ids.contains(ik.getPkeyId()));
                                 if (itemBlockList.size() > 0) {
@@ -575,6 +576,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             });
                         });
                         AtomicBoolean update = new AtomicBoolean(false);
+                        List<Long> ids = getNodeType46(tec).stream().map(CurrentNode::getPkId).collect(Collectors.toList());
                         itemsMap.values().stream().filter(Measurement::isMatching).forEach(t -> {
                             ElementBlock g = null;
                             FormData vfd = t.getValue();
@@ -596,7 +598,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             if (g != null) {
                                 List<ItemBlock> itemBlockList = g.getList();
                                 int originSize = itemBlockList.size();
-                                List<Long> ids = getNodeType46(tec).stream().map(CurrentNode::getPkId).collect(Collectors.toList());
+
                                 /*清除那些已经不存在的工序*/
                                 itemBlockList.removeIf(ik -> !ids.contains(ik.getPkeyId()));
                                 if (itemBlockList.size() > 0) {
@@ -631,16 +633,17 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         }
     }
 
-    public void descendantType46(Object id, List<Map<String, Object>> listMaps) {
-        String sql = "select p_Key_id pkId,id,node_type nodeType,table_type tableType  from m_wbs_tree_contract where parent_id =? and is_deleted=0";
-        List<Map<String, Object>> tmp = this.jdbcTemplate.queryForList(sql, id);
+    public void descendantType46(Long id, Long contractId, List<Map<String, Object>> listMaps) {
+        String sql = "select p_Key_id pkId,id,node_type nodeType,table_type tableType  from m_wbs_tree_contract where  contract_id =  " + contractId + " and find_in_set( " + id + ",ancestors_p_id) and is_deleted=0";
+        List<Map<String, Object>> tmp = this.jdbcTemplate.queryForList(sql);
         if (tmp.size() > 0) {
             for (Map<String, Object> map : tmp) {
                 if (StringUtils.isEquals(map.get("nodeType"), 6)) {
                     listMaps.add(map);
-                } else {
-                    descendantType46(map.get("id"), listMaps);
                 }
+//                else {
+//                    descendantType46(map.get("id"), listMaps);
+//                }
             }
         }
     }
@@ -649,7 +652,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         if (tec.getCurrentNode().getDivisional().size() == 0) {
             // List<Map<String,Object>> listMaps=this.jdbcTemplate.queryForList("select b.p_Key_id pkId,b.id from m_wbs_tree_contract a join m_wbs_tree_contract b on (a.contract_id=b.contract_id and b.ancestors like CONCAT(a.ancestors,'%')) where a.p_key_id="+tec.getCurrentNode().getPkId()+" and b.is_deleted=0 and b.node_type=6 ORDER BY b.sort");
             List<Map<String, Object>> listMaps = new ArrayList<>();
-            descendantType46(tec.getCurrentNode().getParentId(), listMaps);
+            descendantType46(tec.getCurrentNode().getPkId(),tec.getCurrentNode().getContractId(), listMaps);
             if (listMaps.size() > 0) {
                 tec.getCurrentNode().getDivisional().addAll(listMaps.stream().map(m -> BeanUtil.toBean(m, CurrentNode.class)).collect(Collectors.toList()));
             }