Przeglądaj źródła

考核指标分类表

chenshudong 1 miesiąc temu
rodzic
commit
9a62c0f7d7

+ 1 - 1
airport-admin/src/main/java/com/sundot/airport/web/controller/system/BasePerformanceIndicatorCategoryController.java

@@ -104,7 +104,7 @@ public class BasePerformanceIndicatorCategoryController extends BaseController {
104 104
     @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:list')")
105 105
     @GetMapping("/listTree")
106 106
     public AjaxResult listTree(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
107
-        List<BasePerformanceIndicatorCategory> list = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategory);
107
+        List<BasePerformanceIndicatorCategory> list = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryListTree(basePerformanceIndicatorCategory);
108 108
         return success(list);
109 109
     }
110 110
 

+ 33 - 5
airport-system/src/main/java/com/sundot/airport/system/service/impl/BasePerformanceIndicatorCategoryServiceImpl.java

@@ -277,13 +277,41 @@ public class BasePerformanceIndicatorCategoryServiceImpl implements IBasePerform
277 277
     private List<BasePerformanceIndicatorCategoryTreeDTO> filterTree(List<BasePerformanceIndicatorCategoryTreeDTO> nodeList, BasePerformanceIndicatorCategoryTreeRequestDTO requestDTO) {
278 278
         List<BasePerformanceIndicatorCategoryTreeDTO> result = new ArrayList<>();
279 279
         for (BasePerformanceIndicatorCategoryTreeDTO node : nodeList) {
280
-            boolean selfMatch = matchesCategory(node, requestDTO);
280
+            // 判断是否为一级分类(parentId = 0 或 null)
281
+            boolean isRoot = node.getParentId() == null || node.getParentId() == 0;
282
+
283
+            // 递归过滤子节点
281 284
             List<BasePerformanceIndicatorCategoryTreeDTO> filteredChildren = filterTree(node.getChildren(), requestDTO);
282 285
 
283
-            // 保留条件:自身匹配 或 子节点有匹配
284
-            if (selfMatch || !filteredChildren.isEmpty()) {
285
-                node.setChildren(filteredChildren);
286
-                result.add(node);
286
+            if (isRoot) {
287
+                // 一级分类:只有当它有有效的二级子节点时才保留
288
+                if (!filteredChildren.isEmpty()) {
289
+                    node.setChildren(filteredChildren);
290
+                    result.add(node);
291
+                }
292
+                // 如果没有有效的二级子节点,直接丢弃一级分类
293
+            } else {
294
+                // 二级分类:必须满足以下条件之一才能保留:
295
+                // 1. 自身匹配(分类名称/编码)
296
+                // 2. 有指标数据(indicatorList不为空)
297
+                boolean selfMatch = matchesCategory(node, requestDTO);
298
+                boolean hasIndicators = node.getIndicatorList() != null && !node.getIndicatorList().isEmpty();
299
+
300
+                // 如果查询条件为空,则只要有指标就显示
301
+                // 如果查询条件不为空,则需要满足查询条件或有指标
302
+                boolean shouldKeep = false;
303
+                if (StrUtil.isBlank(requestDTO.getCategoryCode()) && StrUtil.isBlank(requestDTO.getCategoryName())) {
304
+                    // 没有分类查询条件时,只要有指标就保留
305
+                    shouldKeep = hasIndicators;
306
+                } else {
307
+                    // 有分类查询条件时,需要自身匹配或有指标
308
+                    shouldKeep = selfMatch || hasIndicators;
309
+                }
310
+
311
+                if (shouldKeep) {
312
+                    node.setChildren(filteredChildren);
313
+                    result.add(node);
314
+                }
287 315
             }
288 316
         }
289 317
         return result;