Browse Source

考核指标分类表

chenshudong 1 month ago
parent
commit
00e8214698

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

@@ -0,0 +1,108 @@
1
+package com.sundot.airport.web.controller.system;
2
+
3
+import java.util.List;
4
+import javax.servlet.http.HttpServletResponse;
5
+
6
+import org.springframework.security.access.prepost.PreAuthorize;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.PutMapping;
11
+import org.springframework.web.bind.annotation.DeleteMapping;
12
+import org.springframework.web.bind.annotation.PathVariable;
13
+import org.springframework.web.bind.annotation.RequestBody;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RestController;
16
+import com.sundot.airport.common.annotation.Log;
17
+import com.sundot.airport.common.core.controller.BaseController;
18
+import com.sundot.airport.common.core.domain.AjaxResult;
19
+import com.sundot.airport.common.enums.BusinessType;
20
+import com.sundot.airport.system.domain.BasePerformanceIndicatorCategory;
21
+import com.sundot.airport.system.service.IBasePerformanceIndicatorCategoryService;
22
+import com.sundot.airport.common.utils.poi.ExcelUtil;
23
+
24
+/**
25
+ * 考核指标分类Controller
26
+ *
27
+ * @author ruoyi
28
+ * @date 2026-04-28
29
+ */
30
+@RestController
31
+@RequestMapping("/system/performanceIndicatorCategory")
32
+public class BasePerformanceIndicatorCategoryController extends BaseController {
33
+    @Autowired
34
+    private IBasePerformanceIndicatorCategoryService basePerformanceIndicatorCategoryService;
35
+
36
+    /**
37
+     * 查询考核指标分类列表
38
+     */
39
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:list')")
40
+    @GetMapping("/list")
41
+    public AjaxResult list(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
42
+        List<BasePerformanceIndicatorCategory> list = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategory);
43
+        return success(list);
44
+    }
45
+
46
+    /**
47
+     * 导出考核指标分类列表
48
+     */
49
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:export')")
50
+    @Log(title = "考核指标分类", businessType = BusinessType.EXPORT)
51
+    @PostMapping("/export")
52
+    public void export(HttpServletResponse response, BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
53
+        List<BasePerformanceIndicatorCategory> list = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategory);
54
+        ExcelUtil<BasePerformanceIndicatorCategory> util = new ExcelUtil<BasePerformanceIndicatorCategory>(BasePerformanceIndicatorCategory.class);
55
+        util.exportExcel(response, list, "考核指标分类数据");
56
+    }
57
+
58
+    /**
59
+     * 获取考核指标分类详细信息
60
+     */
61
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:query')")
62
+    @GetMapping(value = "/{id}")
63
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
64
+        return success(basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryById(id));
65
+    }
66
+
67
+    /**
68
+     * 新增考核指标分类
69
+     */
70
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:add')")
71
+    @Log(title = "考核指标分类", businessType = BusinessType.INSERT)
72
+    @PostMapping
73
+    public AjaxResult add(@RequestBody BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
74
+        basePerformanceIndicatorCategory.setCreateBy(getUsername());
75
+        return toAjax(basePerformanceIndicatorCategoryService.insertBasePerformanceIndicatorCategory(basePerformanceIndicatorCategory));
76
+    }
77
+
78
+    /**
79
+     * 修改考核指标分类
80
+     */
81
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:edit')")
82
+    @Log(title = "考核指标分类", businessType = BusinessType.UPDATE)
83
+    @PutMapping
84
+    public AjaxResult edit(@RequestBody BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
85
+        basePerformanceIndicatorCategory.setUpdateBy(getUsername());
86
+        return toAjax(basePerformanceIndicatorCategoryService.updateBasePerformanceIndicatorCategory(basePerformanceIndicatorCategory));
87
+    }
88
+
89
+    /**
90
+     * 删除考核指标分类
91
+     */
92
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:remove')")
93
+    @Log(title = "考核指标分类", businessType = BusinessType.DELETE)
94
+    @DeleteMapping("/{ids}")
95
+    public AjaxResult remove(@PathVariable Long[] ids) {
96
+        return toAjax(basePerformanceIndicatorCategoryService.deleteBasePerformanceIndicatorCategoryByIds(ids));
97
+    }
98
+
99
+    /**
100
+     * 查询考核指标分类列表树形结构
101
+     */
102
+    @PreAuthorize("@ss.hasPermi('system:performanceIndicatorCategory:list')")
103
+    @GetMapping("/listTree")
104
+    public AjaxResult listTree(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
105
+        List<BasePerformanceIndicatorCategory> list = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategory);
106
+        return success(list);
107
+    }
108
+}

+ 2 - 1
airport-admin/src/main/resources/level-config.yml

@@ -13,4 +13,5 @@ level:
13 13
     2: "BRIGADE"
14 14
     3: "MANAGER"
15 15
     4: "TEAMS"
16
-  sysPostLevel: 2
16
+  sysPostLevel: 2
17
+  performanceIndicatorCategoryLevel: 2

+ 11 - 0
airport-common/src/main/java/com/sundot/airport/common/config/LevelConfig.java

@@ -41,6 +41,10 @@ public class LevelConfig {
41 41
      * 岗位信息表
42 42
      */
43 43
     private int sysPostLevel;
44
+    /**
45
+     * 考核指标分类表
46
+     */
47
+    private int performanceIndicatorCategoryLevel;
44 48
 
45 49
     public int getPositionLevel() {
46 50
         return positionLevel;
@@ -106,4 +110,11 @@ public class LevelConfig {
106 110
         this.sysPostLevel = sysPostLevel;
107 111
     }
108 112
 
113
+    public int getPerformanceIndicatorCategoryLevel() {
114
+        return performanceIndicatorCategoryLevel;
115
+    }
116
+
117
+    public void setPerformanceIndicatorCategoryLevel(int performanceIndicatorCategoryLevel) {
118
+        this.performanceIndicatorCategoryLevel = performanceIndicatorCategoryLevel;
119
+    }
109 120
 }

+ 105 - 0
airport-system/src/main/java/com/sundot/airport/system/domain/BasePerformanceIndicatorCategory.java

@@ -0,0 +1,105 @@
1
+package com.sundot.airport.system.domain;
2
+
3
+import org.apache.commons.lang3.builder.ToStringBuilder;
4
+import org.apache.commons.lang3.builder.ToStringStyle;
5
+import com.sundot.airport.common.annotation.Excel;
6
+import com.sundot.airport.common.core.domain.TreeEntity;
7
+
8
+/**
9
+ * 考核指标分类对象 base_performance_indicator_category
10
+ *
11
+ * @author ruoyi
12
+ * @date 2026-04-28
13
+ */
14
+public class BasePerformanceIndicatorCategory extends TreeEntity {
15
+    private static final long serialVersionUID = 1L;
16
+
17
+    /** 租户号 */
18
+    private String tenantId;
19
+
20
+    /** 乐观锁 */
21
+    private Integer revision;
22
+
23
+    /** 主键 */
24
+    private Long id;
25
+
26
+    /** 编码 */
27
+    @Excel(name = "编码")
28
+    private String code;
29
+
30
+    /** 分类名称 */
31
+    @Excel(name = "分类名称")
32
+    private String name;
33
+
34
+    /** 层级 */
35
+    @Excel(name = "层级")
36
+    private Integer level;
37
+
38
+    public void setTenantId(String tenantId) {
39
+        this.tenantId = tenantId;
40
+    }
41
+
42
+    public String getTenantId() {
43
+        return tenantId;
44
+    }
45
+
46
+    public void setRevision(Integer revision) {
47
+        this.revision = revision;
48
+    }
49
+
50
+    public Integer getRevision() {
51
+        return revision;
52
+    }
53
+
54
+    public void setId(Long id) {
55
+        this.id = id;
56
+    }
57
+
58
+    public Long getId() {
59
+        return id;
60
+    }
61
+
62
+    public void setCode(String code) {
63
+        this.code = code;
64
+    }
65
+
66
+    public String getCode() {
67
+        return code;
68
+    }
69
+
70
+    public void setName(String name) {
71
+        this.name = name;
72
+    }
73
+
74
+    public String getName() {
75
+        return name;
76
+    }
77
+
78
+    public void setLevel(Integer level) {
79
+        this.level = level;
80
+    }
81
+
82
+    public Integer getLevel() {
83
+        return level;
84
+    }
85
+
86
+    @Override
87
+    public String toString() {
88
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
89
+                .append("tenantId", getTenantId())
90
+                .append("revision", getRevision())
91
+                .append("createBy", getCreateBy())
92
+                .append("createTime", getCreateTime())
93
+                .append("updateBy", getUpdateBy())
94
+                .append("updateTime", getUpdateTime())
95
+                .append("remark", getRemark())
96
+                .append("id", getId())
97
+                .append("code", getCode())
98
+                .append("name", getName())
99
+                .append("parentId", getParentId())
100
+                .append("ancestors", getAncestors())
101
+                .append("level", getLevel())
102
+                .append("orderNum", getOrderNum())
103
+                .toString();
104
+    }
105
+}

+ 78 - 0
airport-system/src/main/java/com/sundot/airport/system/mapper/BasePerformanceIndicatorCategoryMapper.java

@@ -0,0 +1,78 @@
1
+package com.sundot.airport.system.mapper;
2
+
3
+import java.util.List;
4
+
5
+import com.sundot.airport.system.domain.BasePerformanceIndicatorCategory;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+/**
9
+ * 考核指标分类Mapper接口
10
+ *
11
+ * @author ruoyi
12
+ * @date 2026-04-28
13
+ */
14
+public interface BasePerformanceIndicatorCategoryMapper {
15
+    /**
16
+     * 查询考核指标分类
17
+     *
18
+     * @param id 考核指标分类主键
19
+     * @return 考核指标分类
20
+     */
21
+    public BasePerformanceIndicatorCategory selectBasePerformanceIndicatorCategoryById(Long id);
22
+
23
+    /**
24
+     * 查询考核指标分类列表
25
+     *
26
+     * @param basePerformanceIndicatorCategory 考核指标分类
27
+     * @return 考核指标分类集合
28
+     */
29
+    public List<BasePerformanceIndicatorCategory> selectBasePerformanceIndicatorCategoryList(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
30
+
31
+    /**
32
+     * 新增考核指标分类
33
+     *
34
+     * @param basePerformanceIndicatorCategory 考核指标分类
35
+     * @return 结果
36
+     */
37
+    public int insertBasePerformanceIndicatorCategory(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
38
+
39
+    /**
40
+     * 修改考核指标分类
41
+     *
42
+     * @param basePerformanceIndicatorCategory 考核指标分类
43
+     * @return 结果
44
+     */
45
+    public int updateBasePerformanceIndicatorCategory(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
46
+
47
+    /**
48
+     * 删除考核指标分类
49
+     *
50
+     * @param id 考核指标分类主键
51
+     * @return 结果
52
+     */
53
+    public int deleteBasePerformanceIndicatorCategoryById(Long id);
54
+
55
+    /**
56
+     * 批量删除考核指标分类
57
+     *
58
+     * @param ids 需要删除的数据主键集合
59
+     * @return 结果
60
+     */
61
+    public int deleteBasePerformanceIndicatorCategoryByIds(Long[] ids);
62
+
63
+    /**
64
+     * 根据ID查询所有子元素
65
+     *
66
+     * @param id ID
67
+     * @return 列表
68
+     */
69
+    public List<BasePerformanceIndicatorCategory> selectChildrenById(Long id);
70
+
71
+    /**
72
+     * 修改子元素关系
73
+     *
74
+     * @param list 子元素
75
+     * @return 结果
76
+     */
77
+    public int updateChildren(@Param("list") List<BasePerformanceIndicatorCategory> list);
78
+}

+ 77 - 0
airport-system/src/main/java/com/sundot/airport/system/service/IBasePerformanceIndicatorCategoryService.java

@@ -0,0 +1,77 @@
1
+package com.sundot.airport.system.service;
2
+
3
+import java.util.List;
4
+
5
+import com.sundot.airport.system.domain.BasePerformanceIndicatorCategory;
6
+
7
+/**
8
+ * 考核指标分类Service接口
9
+ *
10
+ * @author ruoyi
11
+ * @date 2026-04-28
12
+ */
13
+public interface IBasePerformanceIndicatorCategoryService {
14
+    /**
15
+     * 查询考核指标分类
16
+     *
17
+     * @param id 考核指标分类主键
18
+     * @return 考核指标分类
19
+     */
20
+    public BasePerformanceIndicatorCategory selectBasePerformanceIndicatorCategoryById(Long id);
21
+
22
+    /**
23
+     * 查询考核指标分类列表
24
+     *
25
+     * @param basePerformanceIndicatorCategory 考核指标分类
26
+     * @return 考核指标分类集合
27
+     */
28
+    public List<BasePerformanceIndicatorCategory> selectBasePerformanceIndicatorCategoryList(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
29
+
30
+    /**
31
+     * 新增考核指标分类
32
+     *
33
+     * @param basePerformanceIndicatorCategory 考核指标分类
34
+     * @return 结果
35
+     */
36
+    public int insertBasePerformanceIndicatorCategory(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
37
+
38
+    /**
39
+     * 修改考核指标分类
40
+     *
41
+     * @param basePerformanceIndicatorCategory 考核指标分类
42
+     * @return 结果
43
+     */
44
+    public int updateBasePerformanceIndicatorCategory(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
45
+
46
+    /**
47
+     * 批量删除考核指标分类
48
+     *
49
+     * @param ids 需要删除的考核指标分类主键集合
50
+     * @return 结果
51
+     */
52
+    public int deleteBasePerformanceIndicatorCategoryByIds(Long[] ids);
53
+
54
+    /**
55
+     * 删除考核指标分类信息
56
+     *
57
+     * @param id 考核指标分类主键
58
+     * @return 结果
59
+     */
60
+    public int deleteBasePerformanceIndicatorCategoryById(Long id);
61
+
62
+    /**
63
+     * 查询考核指标分类对象树形结构
64
+     *
65
+     * @param basePerformanceIndicatorCategory 考核指标分类对象
66
+     * @return 树结构列表
67
+     */
68
+    public List<BasePerformanceIndicatorCategory> selectBasePerformanceIndicatorCategoryListTree(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory);
69
+
70
+    /**
71
+     * 构建前端所需要树结构
72
+     *
73
+     * @param list 列表
74
+     * @return 树结构列表
75
+     */
76
+    public List<BasePerformanceIndicatorCategory> buildTree(List<BasePerformanceIndicatorCategory> list);
77
+}

+ 211 - 0
airport-system/src/main/java/com/sundot/airport/system/service/impl/BasePerformanceIndicatorCategoryServiceImpl.java

@@ -0,0 +1,211 @@
1
+package com.sundot.airport.system.service.impl;
2
+
3
+import java.util.ArrayList;
4
+import java.util.HashMap;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import cn.hutool.core.util.ObjectUtil;
9
+import com.sundot.airport.common.config.LevelConfig;
10
+import com.sundot.airport.common.exception.ServiceException;
11
+import com.sundot.airport.common.utils.DateUtils;
12
+import com.sundot.airport.system.utils.CodeGeneratorUtil;
13
+import org.apache.commons.lang3.ObjectUtils;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Service;
16
+import com.sundot.airport.system.mapper.BasePerformanceIndicatorCategoryMapper;
17
+import com.sundot.airport.system.domain.BasePerformanceIndicatorCategory;
18
+import com.sundot.airport.system.service.IBasePerformanceIndicatorCategoryService;
19
+import org.springframework.transaction.annotation.Transactional;
20
+import org.springframework.util.CollectionUtils;
21
+
22
+/**
23
+ * 考核指标分类Service业务层处理
24
+ *
25
+ * @author ruoyi
26
+ * @date 2026-04-28
27
+ */
28
+@Service
29
+public class BasePerformanceIndicatorCategoryServiceImpl implements IBasePerformanceIndicatorCategoryService {
30
+    @Autowired
31
+    private BasePerformanceIndicatorCategoryMapper basePerformanceIndicatorCategoryMapper;
32
+    @Autowired
33
+    private LevelConfig levelConfig;
34
+    @Autowired
35
+    private CodeGeneratorUtil codeGeneratorUtil;
36
+
37
+    /**
38
+     * 查询考核指标分类
39
+     *
40
+     * @param id 考核指标分类主键
41
+     * @return 考核指标分类
42
+     */
43
+    @Override
44
+    public BasePerformanceIndicatorCategory selectBasePerformanceIndicatorCategoryById(Long id) {
45
+        return basePerformanceIndicatorCategoryMapper.selectBasePerformanceIndicatorCategoryById(id);
46
+    }
47
+
48
+    /**
49
+     * 查询考核指标分类列表
50
+     *
51
+     * @param basePerformanceIndicatorCategory 考核指标分类
52
+     * @return 考核指标分类
53
+     */
54
+    @Override
55
+    public List<BasePerformanceIndicatorCategory> selectBasePerformanceIndicatorCategoryList(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
56
+        return basePerformanceIndicatorCategoryMapper.selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategory);
57
+    }
58
+
59
+    /**
60
+     * 新增考核指标分类
61
+     *
62
+     * @param basePerformanceIndicatorCategory 考核指标分类
63
+     * @return 结果
64
+     */
65
+    @Override
66
+    public int insertBasePerformanceIndicatorCategory(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
67
+        basePerformanceIndicatorCategory.setCreateTime(DateUtils.getNowDate());
68
+        if (ObjectUtil.isEmpty(basePerformanceIndicatorCategory.getParentId()) || basePerformanceIndicatorCategory.getParentId().equals(0L)) {
69
+            basePerformanceIndicatorCategory.setAncestors("0");
70
+            basePerformanceIndicatorCategory.setLevel(1);
71
+        } else {
72
+            BasePerformanceIndicatorCategory info = basePerformanceIndicatorCategoryMapper.selectBasePerformanceIndicatorCategoryById(basePerformanceIndicatorCategory.getParentId());
73
+            if (ObjectUtil.isEmpty(info)) {
74
+                throw new ServiceException("父分类不存在,不允许新增");
75
+            }
76
+            basePerformanceIndicatorCategory.setAncestors(info.getAncestors() + "," + basePerformanceIndicatorCategory.getParentId());
77
+            basePerformanceIndicatorCategory.setLevel(basePerformanceIndicatorCategory.getAncestors().split(",").length);
78
+        }
79
+        verifyData(basePerformanceIndicatorCategory);
80
+        basePerformanceIndicatorCategory.setCode(codeGeneratorUtil.getNextCodeGenerator());
81
+        return basePerformanceIndicatorCategoryMapper.insertBasePerformanceIndicatorCategory(basePerformanceIndicatorCategory);
82
+    }
83
+
84
+    /**
85
+     * 修改考核指标分类
86
+     *
87
+     * @param basePerformanceIndicatorCategory 考核指标分类
88
+     * @return 结果
89
+     */
90
+    @Transactional(rollbackFor = Exception.class)
91
+    @Override
92
+    public int updateBasePerformanceIndicatorCategory(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
93
+        basePerformanceIndicatorCategory.setUpdateTime(DateUtils.getNowDate());
94
+        BasePerformanceIndicatorCategory newParent = basePerformanceIndicatorCategoryMapper.selectBasePerformanceIndicatorCategoryById(basePerformanceIndicatorCategory.getParentId());
95
+        BasePerformanceIndicatorCategory old = basePerformanceIndicatorCategoryMapper.selectBasePerformanceIndicatorCategoryById(basePerformanceIndicatorCategory.getId());
96
+        if (ObjectUtils.isNotEmpty(newParent) && ObjectUtils.isNotEmpty(old)) {
97
+            String newAncestors = newParent.getAncestors() + "," + newParent.getId();
98
+            String oldAncestors = old.getAncestors();
99
+            basePerformanceIndicatorCategory.setAncestors(newAncestors);
100
+            basePerformanceIndicatorCategory.setLevel(basePerformanceIndicatorCategory.getAncestors().split(",").length);
101
+            updateChildren(basePerformanceIndicatorCategory.getId(), newAncestors, oldAncestors);
102
+        }
103
+        verifyData(basePerformanceIndicatorCategory);
104
+        return basePerformanceIndicatorCategoryMapper.updateBasePerformanceIndicatorCategory(basePerformanceIndicatorCategory);
105
+    }
106
+
107
+    /**
108
+     * 修改子元素关系
109
+     *
110
+     * @param id           被修改的元素ID
111
+     * @param newAncestors 新的父ID集合
112
+     * @param oldAncestors 旧的父ID集合
113
+     */
114
+    private void updateChildren(Long id, String newAncestors, String oldAncestors) {
115
+        List<BasePerformanceIndicatorCategory> children = basePerformanceIndicatorCategoryMapper.selectChildrenById(id);
116
+        for (BasePerformanceIndicatorCategory child : children) {
117
+            child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
118
+            child.setLevel(child.getAncestors().split(",").length);
119
+            verifyData(child);
120
+        }
121
+        if (!CollectionUtils.isEmpty(children)) {
122
+            basePerformanceIndicatorCategoryMapper.updateChildren(children);
123
+        }
124
+    }
125
+
126
+    /**
127
+     * 批量删除考核指标分类
128
+     *
129
+     * @param ids 需要删除的考核指标分类主键
130
+     * @return 结果
131
+     */
132
+    @Override
133
+    public int deleteBasePerformanceIndicatorCategoryByIds(Long[] ids) {
134
+        return basePerformanceIndicatorCategoryMapper.deleteBasePerformanceIndicatorCategoryByIds(ids);
135
+    }
136
+
137
+    /**
138
+     * 删除考核指标分类信息
139
+     *
140
+     * @param id 考核指标分类主键
141
+     * @return 结果
142
+     */
143
+    @Override
144
+    public int deleteBasePerformanceIndicatorCategoryById(Long id) {
145
+        return basePerformanceIndicatorCategoryMapper.deleteBasePerformanceIndicatorCategoryById(id);
146
+    }
147
+
148
+    /**
149
+     * 查询考核指标分类对象树形结构
150
+     *
151
+     * @param basePerformanceIndicatorCategory 考核指标分类对象
152
+     * @return 树结构列表
153
+     */
154
+    @Override
155
+    public List<BasePerformanceIndicatorCategory> selectBasePerformanceIndicatorCategoryListTree(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
156
+        List<BasePerformanceIndicatorCategory> list = selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategory);
157
+        return buildTree(list);
158
+    }
159
+
160
+    /**
161
+     * 构建前端所需要树结构
162
+     *
163
+     * @param list 列表
164
+     * @return 树结构列表
165
+     */
166
+    @Override
167
+    public List<BasePerformanceIndicatorCategory> buildTree(List<BasePerformanceIndicatorCategory> list) {
168
+        // 结果列表
169
+        List<BasePerformanceIndicatorCategory> result = new ArrayList<>();
170
+
171
+        // 临时Map,用于快速查找节点
172
+        Map<Long, BasePerformanceIndicatorCategory> nodeMap = new HashMap<>();
173
+
174
+        // 第一次遍历:将所有节点存入Map
175
+        for (BasePerformanceIndicatorCategory node : list) {
176
+            nodeMap.put(node.getId(), node);
177
+        }
178
+
179
+        // 第二次遍历:建立父子关系
180
+        for (BasePerformanceIndicatorCategory node : list) {
181
+            Long parentId = node.getParentId();
182
+            if (parentId == null || parentId == 0L) {
183
+                // 父ID为null或0,说明是根节点
184
+                result.add(node);
185
+            } else {
186
+                // 查找父节点
187
+                BasePerformanceIndicatorCategory parent = nodeMap.get(parentId);
188
+                if (parent != null) {
189
+                    // 初始化子节点列表
190
+                    if (parent.getChildren() == null) {
191
+                        parent.setChildren(new ArrayList<>());
192
+                    }
193
+                    // 将当前节点添加到父节点的子列表中
194
+                    List<BasePerformanceIndicatorCategory> children = (List<BasePerformanceIndicatorCategory>) parent.getChildren();
195
+                    children.add(node);
196
+                }
197
+            }
198
+        }
199
+
200
+        return result;
201
+    }
202
+
203
+    /**
204
+     * 验证数据
205
+     */
206
+    private void verifyData(BasePerformanceIndicatorCategory basePerformanceIndicatorCategory) {
207
+        if (basePerformanceIndicatorCategory.getLevel() > levelConfig.getPerformanceIndicatorCategoryLevel()) {
208
+            throw new ServiceException("操作失败,层级超过限制" + levelConfig.getPerformanceIndicatorCategoryLevel() + "级");
209
+        }
210
+    }
211
+}

+ 154 - 0
airport-system/src/main/resources/mapper/system/BasePerformanceIndicatorCategoryMapper.xml

@@ -0,0 +1,154 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.sundot.airport.system.mapper.BasePerformanceIndicatorCategoryMapper">
6
+
7
+    <resultMap type="BasePerformanceIndicatorCategory" id="BasePerformanceIndicatorCategoryResult">
8
+        <result property="tenantId" column="tenant_id"/>
9
+        <result property="revision" column="revision"/>
10
+        <result property="createBy" column="create_by"/>
11
+        <result property="createTime" column="create_time"/>
12
+        <result property="updateBy" column="update_by"/>
13
+        <result property="updateTime" column="update_time"/>
14
+        <result property="remark" column="remark"/>
15
+        <result property="id" column="id"/>
16
+        <result property="code" column="code"/>
17
+        <result property="name" column="name"/>
18
+        <result property="parentId" column="parent_id"/>
19
+        <result property="ancestors" column="ancestors"/>
20
+        <result property="level" column="level"/>
21
+        <result property="orderNum" column="order_num"/>
22
+    </resultMap>
23
+
24
+    <sql id="selectBasePerformanceIndicatorCategoryVo">
25
+        select tenant_id,
26
+               revision,
27
+               create_by,
28
+               create_time,
29
+               update_by,
30
+               update_time,
31
+               remark,
32
+               id,
33
+               code,
34
+               name,
35
+               parent_id,
36
+               ancestors,
37
+               level,
38
+               order_num
39
+        from base_performance_indicator_category
40
+    </sql>
41
+
42
+    <select id="selectBasePerformanceIndicatorCategoryList" parameterType="BasePerformanceIndicatorCategory"
43
+            resultMap="BasePerformanceIndicatorCategoryResult">
44
+        <include refid="selectBasePerformanceIndicatorCategoryVo"/>
45
+        <where>
46
+            <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
47
+            <if test="revision != null ">and revision = #{revision}</if>
48
+            <if test="code != null  and code != ''">and code = #{code}</if>
49
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
50
+            <if test="parentId != null ">and parent_id = #{parentId}</if>
51
+            <if test="ancestors != null  and ancestors != ''">and ancestors = #{ancestors}</if>
52
+            <if test="level != null ">and level = #{level}</if>
53
+            <if test="orderNum != null ">and order_num = #{orderNum}</if>
54
+        </where>
55
+    </select>
56
+
57
+    <select id="selectBasePerformanceIndicatorCategoryById" parameterType="Long"
58
+            resultMap="BasePerformanceIndicatorCategoryResult">
59
+        <include refid="selectBasePerformanceIndicatorCategoryVo"/>
60
+        where id = #{id}
61
+    </select>
62
+
63
+    <insert id="insertBasePerformanceIndicatorCategory" parameterType="BasePerformanceIndicatorCategory"
64
+            useGeneratedKeys="true" keyProperty="id">
65
+        insert into base_performance_indicator_category
66
+        <trim prefix="(" suffix=")" suffixOverrides=",">
67
+            <if test="tenantId != null">tenant_id,</if>
68
+            <if test="revision != null">revision,</if>
69
+            <if test="createBy != null">create_by,</if>
70
+            <if test="createTime != null">create_time,</if>
71
+            <if test="updateBy != null">update_by,</if>
72
+            <if test="updateTime != null">update_time,</if>
73
+            <if test="remark != null">remark,</if>
74
+            <if test="code != null and code != ''">code,</if>
75
+            <if test="name != null and name != ''">name,</if>
76
+            <if test="parentId != null">parent_id,</if>
77
+            <if test="ancestors != null and ancestors != ''">ancestors,</if>
78
+            <if test="level != null">level,</if>
79
+            <if test="orderNum != null">order_num,</if>
80
+        </trim>
81
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
82
+            <if test="tenantId != null">#{tenantId},</if>
83
+            <if test="revision != null">#{revision},</if>
84
+            <if test="createBy != null">#{createBy},</if>
85
+            <if test="createTime != null">#{createTime},</if>
86
+            <if test="updateBy != null">#{updateBy},</if>
87
+            <if test="updateTime != null">#{updateTime},</if>
88
+            <if test="remark != null">#{remark},</if>
89
+            <if test="code != null and code != ''">#{code},</if>
90
+            <if test="name != null and name != ''">#{name},</if>
91
+            <if test="parentId != null">#{parentId},</if>
92
+            <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
93
+            <if test="level != null">#{level},</if>
94
+            <if test="orderNum != null">#{orderNum},</if>
95
+        </trim>
96
+    </insert>
97
+
98
+    <update id="updateBasePerformanceIndicatorCategory" parameterType="BasePerformanceIndicatorCategory">
99
+        update base_performance_indicator_category
100
+        <trim prefix="SET" suffixOverrides=",">
101
+            <if test="tenantId != null">tenant_id = #{tenantId},</if>
102
+            <if test="revision != null">revision = #{revision},</if>
103
+            <if test="createBy != null">create_by = #{createBy},</if>
104
+            <if test="createTime != null">create_time = #{createTime},</if>
105
+            <if test="updateBy != null">update_by = #{updateBy},</if>
106
+            <if test="updateTime != null">update_time = #{updateTime},</if>
107
+            <if test="remark != null">remark = #{remark},</if>
108
+            <if test="code != null and code != ''">code = #{code},</if>
109
+            <if test="name != null and name != ''">name = #{name},</if>
110
+            <if test="parentId != null">parent_id = #{parentId},</if>
111
+            <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
112
+            <if test="level != null">level = #{level},</if>
113
+            <if test="orderNum != null">order_num = #{orderNum},</if>
114
+        </trim>
115
+        where id = #{id}
116
+    </update>
117
+
118
+    <delete id="deleteBasePerformanceIndicatorCategoryById" parameterType="Long">
119
+        delete
120
+        from base_performance_indicator_category
121
+        where id = #{id}
122
+    </delete>
123
+
124
+    <delete id="deleteBasePerformanceIndicatorCategoryByIds" parameterType="String">
125
+        delete from base_performance_indicator_category where id in
126
+        <foreach item="id" collection="array" open="(" separator="," close=")">
127
+            #{id}
128
+        </foreach>
129
+    </delete>
130
+
131
+    <select id="selectChildrenById" parameterType="Long" resultMap="BasePerformanceIndicatorCategoryResult">
132
+        select *
133
+        from base_performance_indicator_category
134
+        where find_in_set(#{id}, ancestors)
135
+    </select>
136
+
137
+    <update id="updateChildren" parameterType="java.util.List">
138
+        update base_performance_indicator_category set ancestors =
139
+        <foreach collection="list" item="item" index="index"
140
+                 separator=" " open="case id" close="end">
141
+            when #{item.id} then #{item.ancestors}
142
+        </foreach>,
143
+        level =
144
+        <foreach collection="list" item="item" index="index"
145
+                 separator=" " open="case id" close="end">
146
+            when #{item.id} then #{item.level}
147
+        </foreach>
148
+        where id in
149
+        <foreach collection="list" item="item" index="index"
150
+                 separator="," open="(" close=")">
151
+            #{item.id}
152
+        </foreach>
153
+    </update>
154
+</mapper>