Explorar o código

Merge remote-tracking branch 'origin/feature/dev' into feature/dev

wangxx hai 5 días
pai
achega
6bad613ace

+ 108 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/system/BasePerformanceIndicatorController.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.BasePerformanceIndicator;
21
+import com.sundot.airport.system.service.IBasePerformanceIndicatorService;
22
+import com.sundot.airport.common.utils.poi.ExcelUtil;
23
+
24
+/**
25
+ * 考核指标Controller
26
+ *
27
+ * @author ruoyi
28
+ * @date 2026-04-20
29
+ */
30
+@RestController
31
+@RequestMapping("/system/indicator")
32
+public class BasePerformanceIndicatorController extends BaseController {
33
+    @Autowired
34
+    private IBasePerformanceIndicatorService basePerformanceIndicatorService;
35
+
36
+    /**
37
+     * 查询考核指标列表
38
+     */
39
+    @PreAuthorize("@ss.hasPermi('system:indicator:list')")
40
+    @GetMapping("/list")
41
+    public AjaxResult list(BasePerformanceIndicator basePerformanceIndicator) {
42
+        List<BasePerformanceIndicator> list = basePerformanceIndicatorService.selectBasePerformanceIndicatorList(basePerformanceIndicator);
43
+        return success(list);
44
+    }
45
+
46
+    /**
47
+     * 导出考核指标列表
48
+     */
49
+    @PreAuthorize("@ss.hasPermi('system:indicator:export')")
50
+    @Log(title = "考核指标", businessType = BusinessType.EXPORT)
51
+    @PostMapping("/export")
52
+    public void export(HttpServletResponse response, BasePerformanceIndicator basePerformanceIndicator) {
53
+        List<BasePerformanceIndicator> list = basePerformanceIndicatorService.selectBasePerformanceIndicatorList(basePerformanceIndicator);
54
+        ExcelUtil<BasePerformanceIndicator> util = new ExcelUtil<BasePerformanceIndicator>(BasePerformanceIndicator.class);
55
+        util.exportExcel(response, list, "考核指标数据");
56
+    }
57
+
58
+    /**
59
+     * 获取考核指标详细信息
60
+     */
61
+    @PreAuthorize("@ss.hasPermi('system:indicator:query')")
62
+    @GetMapping(value = "/{id}")
63
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
64
+        return success(basePerformanceIndicatorService.selectBasePerformanceIndicatorById(id));
65
+    }
66
+
67
+    /**
68
+     * 新增考核指标
69
+     */
70
+    @PreAuthorize("@ss.hasPermi('system:indicator:add')")
71
+    @Log(title = "考核指标", businessType = BusinessType.INSERT)
72
+    @PostMapping
73
+    public AjaxResult add(@RequestBody BasePerformanceIndicator basePerformanceIndicator) {
74
+        basePerformanceIndicator.setCreateBy(getUsername());
75
+        return toAjax(basePerformanceIndicatorService.insertBasePerformanceIndicator(basePerformanceIndicator));
76
+    }
77
+
78
+    /**
79
+     * 修改考核指标
80
+     */
81
+    @PreAuthorize("@ss.hasPermi('system:indicator:edit')")
82
+    @Log(title = "考核指标", businessType = BusinessType.UPDATE)
83
+    @PutMapping
84
+    public AjaxResult edit(@RequestBody BasePerformanceIndicator basePerformanceIndicator) {
85
+        basePerformanceIndicator.setUpdateBy(getUsername());
86
+        return toAjax(basePerformanceIndicatorService.updateBasePerformanceIndicator(basePerformanceIndicator));
87
+    }
88
+
89
+    /**
90
+     * 删除考核指标
91
+     */
92
+    @PreAuthorize("@ss.hasPermi('system:indicator:remove')")
93
+    @Log(title = "考核指标", businessType = BusinessType.DELETE)
94
+    @DeleteMapping("/{ids}")
95
+    public AjaxResult remove(@PathVariable Long[] ids) {
96
+        return toAjax(basePerformanceIndicatorService.deleteBasePerformanceIndicatorByIds(ids));
97
+    }
98
+
99
+    /**
100
+     * 查询考核指标列表树形结构
101
+     */
102
+    @PreAuthorize("@ss.hasPermi('system:indicator:list')")
103
+    @GetMapping("/listTree")
104
+    public AjaxResult listTree(BasePerformanceIndicator basePerformanceIndicator) {
105
+        List<BasePerformanceIndicator> list = basePerformanceIndicatorService.selectBasePerformanceIndicatorListTree(basePerformanceIndicator);
106
+        return success(list);
107
+    }
108
+}

+ 28 - 0
airport-common/src/main/java/com/sundot/airport/common/enums/BasePerformanceIndicatorTypeEnum.java

@@ -0,0 +1,28 @@
1
+package com.sundot.airport.common.enums;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Getter;
5
+
6
+/**
7
+ * 考核指标表类型枚举
8
+ */
9
+@Getter
10
+@AllArgsConstructor
11
+public enum BasePerformanceIndicatorTypeEnum {
12
+
13
+    CATEGORY("CATEGORY", "类别"),
14
+    BUSINESS("BUSINESS", "业务");
15
+
16
+    private final String code;
17
+    private final String desc;
18
+
19
+    public static BasePerformanceIndicatorTypeEnum getByCode(String code) {
20
+        for (BasePerformanceIndicatorTypeEnum itemEnum : values()) {
21
+            if (itemEnum.getCode().equals(code)) {
22
+                return itemEnum;
23
+            }
24
+        }
25
+        return null;
26
+    }
27
+
28
+}

+ 146 - 0
airport-system/src/main/java/com/sundot/airport/system/domain/BasePerformanceIndicator.java

@@ -0,0 +1,146 @@
1
+package com.sundot.airport.system.domain;
2
+
3
+import java.math.BigDecimal;
4
+
5
+import org.apache.commons.lang3.builder.ToStringBuilder;
6
+import org.apache.commons.lang3.builder.ToStringStyle;
7
+import com.sundot.airport.common.annotation.Excel;
8
+import com.sundot.airport.common.core.domain.TreeEntity;
9
+
10
+/**
11
+ * 考核指标对象 base_performance_indicator
12
+ *
13
+ * @author ruoyi
14
+ * @date 2026-04-20
15
+ */
16
+public class BasePerformanceIndicator extends TreeEntity {
17
+    private static final long serialVersionUID = 1L;
18
+
19
+    /** 租户号 */
20
+    private String tenantId;
21
+
22
+    /** 乐观锁 */
23
+    private Integer revision;
24
+
25
+    /** 主键 */
26
+    private Long id;
27
+
28
+    /** 类型 */
29
+    @Excel(name = "类型", readConverterExp = "CATEGORY=类别,BUSINESS=业务", combo = "类别,业务")
30
+    private String type;
31
+
32
+    /** 序号 */
33
+    @Excel(name = "序号")
34
+    private String code;
35
+
36
+    /** 指标名称 */
37
+    @Excel(name = "指标名称")
38
+    private String name;
39
+
40
+    /** 层级 */
41
+    @Excel(name = "层级")
42
+    private Integer level;
43
+
44
+    /** 分值 */
45
+    @Excel(name = "分值")
46
+    private BigDecimal score;
47
+
48
+    /** 单位 */
49
+    @Excel(name = "单位")
50
+    private String unit;
51
+
52
+    public void setTenantId(String tenantId) {
53
+        this.tenantId = tenantId;
54
+    }
55
+
56
+    public String getTenantId() {
57
+        return tenantId;
58
+    }
59
+
60
+    public void setRevision(Integer revision) {
61
+        this.revision = revision;
62
+    }
63
+
64
+    public Integer getRevision() {
65
+        return revision;
66
+    }
67
+
68
+    public void setId(Long id) {
69
+        this.id = id;
70
+    }
71
+
72
+    public Long getId() {
73
+        return id;
74
+    }
75
+
76
+    public void setType(String type) {
77
+        this.type = type;
78
+    }
79
+
80
+    public String getType() {
81
+        return type;
82
+    }
83
+
84
+    public void setCode(String code) {
85
+        this.code = code;
86
+    }
87
+
88
+    public String getCode() {
89
+        return code;
90
+    }
91
+
92
+    public void setName(String name) {
93
+        this.name = name;
94
+    }
95
+
96
+    public String getName() {
97
+        return name;
98
+    }
99
+
100
+    public void setLevel(Integer level) {
101
+        this.level = level;
102
+    }
103
+
104
+    public Integer getLevel() {
105
+        return level;
106
+    }
107
+
108
+    public void setScore(BigDecimal score) {
109
+        this.score = score;
110
+    }
111
+
112
+    public BigDecimal getScore() {
113
+        return score;
114
+    }
115
+
116
+    public void setUnit(String unit) {
117
+        this.unit = unit;
118
+    }
119
+
120
+    public String getUnit() {
121
+        return unit;
122
+    }
123
+
124
+    @Override
125
+    public String toString() {
126
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
127
+                .append("tenantId", getTenantId())
128
+                .append("revision", getRevision())
129
+                .append("createBy", getCreateBy())
130
+                .append("createTime", getCreateTime())
131
+                .append("updateBy", getUpdateBy())
132
+                .append("updateTime", getUpdateTime())
133
+                .append("remark", getRemark())
134
+                .append("id", getId())
135
+                .append("type", getType())
136
+                .append("code", getCode())
137
+                .append("name", getName())
138
+                .append("parentId", getParentId())
139
+                .append("ancestors", getAncestors())
140
+                .append("level", getLevel())
141
+                .append("orderNum", getOrderNum())
142
+                .append("score", getScore())
143
+                .append("unit", getUnit())
144
+                .toString();
145
+    }
146
+}

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

+ 77 - 0
airport-system/src/main/java/com/sundot/airport/system/service/IBasePerformanceIndicatorService.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.BasePerformanceIndicator;
6
+
7
+/**
8
+ * 考核指标Service接口
9
+ *
10
+ * @author ruoyi
11
+ * @date 2026-04-20
12
+ */
13
+public interface IBasePerformanceIndicatorService {
14
+    /**
15
+     * 查询考核指标
16
+     *
17
+     * @param id 考核指标主键
18
+     * @return 考核指标
19
+     */
20
+    public BasePerformanceIndicator selectBasePerformanceIndicatorById(Long id);
21
+
22
+    /**
23
+     * 查询考核指标列表
24
+     *
25
+     * @param basePerformanceIndicator 考核指标
26
+     * @return 考核指标集合
27
+     */
28
+    public List<BasePerformanceIndicator> selectBasePerformanceIndicatorList(BasePerformanceIndicator basePerformanceIndicator);
29
+
30
+    /**
31
+     * 新增考核指标
32
+     *
33
+     * @param basePerformanceIndicator 考核指标
34
+     * @return 结果
35
+     */
36
+    public int insertBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator);
37
+
38
+    /**
39
+     * 修改考核指标
40
+     *
41
+     * @param basePerformanceIndicator 考核指标
42
+     * @return 结果
43
+     */
44
+    public int updateBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator);
45
+
46
+    /**
47
+     * 批量删除考核指标
48
+     *
49
+     * @param ids 需要删除的考核指标主键集合
50
+     * @return 结果
51
+     */
52
+    public int deleteBasePerformanceIndicatorByIds(Long[] ids);
53
+
54
+    /**
55
+     * 删除考核指标信息
56
+     *
57
+     * @param id 考核指标主键
58
+     * @return 结果
59
+     */
60
+    public int deleteBasePerformanceIndicatorById(Long id);
61
+
62
+    /**
63
+     * 查询考核指标列表树形结构
64
+     *
65
+     * @param basePerformanceIndicator 考核指标
66
+     * @return 考核指标集合
67
+     */
68
+    public List<BasePerformanceIndicator> selectBasePerformanceIndicatorListTree(BasePerformanceIndicator basePerformanceIndicator);
69
+
70
+    /**
71
+     * 构建前端所需要树结构
72
+     *
73
+     * @param list 列表
74
+     * @return 树结构列表
75
+     */
76
+    public List<BasePerformanceIndicator> buildTree(List<BasePerformanceIndicator> list);
77
+}

+ 192 - 0
airport-system/src/main/java/com/sundot/airport/system/service/impl/BasePerformanceIndicatorServiceImpl.java

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

+ 171 - 0
airport-system/src/main/resources/mapper/system/BasePerformanceIndicatorMapper.xml

@@ -0,0 +1,171 @@
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.BasePerformanceIndicatorMapper">
6
+
7
+    <resultMap type="BasePerformanceIndicator" id="BasePerformanceIndicatorResult">
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="type" column="type"/>
17
+        <result property="code" column="code"/>
18
+        <result property="name" column="name"/>
19
+        <result property="parentId" column="parent_id"/>
20
+        <result property="ancestors" column="ancestors"/>
21
+        <result property="level" column="level"/>
22
+        <result property="orderNum" column="order_num"/>
23
+        <result property="score" column="score"/>
24
+        <result property="unit" column="unit"/>
25
+    </resultMap>
26
+
27
+    <sql id="selectBasePerformanceIndicatorVo">
28
+        select tenant_id,
29
+               revision,
30
+               create_by,
31
+               create_time,
32
+               update_by,
33
+               update_time,
34
+               remark,
35
+               id,
36
+               type,
37
+               code,
38
+               name,
39
+               parent_id,
40
+               ancestors,
41
+               level,
42
+               order_num,
43
+               score,
44
+               unit
45
+        from base_performance_indicator
46
+    </sql>
47
+
48
+    <select id="selectBasePerformanceIndicatorList" parameterType="BasePerformanceIndicator"
49
+            resultMap="BasePerformanceIndicatorResult">
50
+        <include refid="selectBasePerformanceIndicatorVo"/>
51
+        <where>
52
+            <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
53
+            <if test="revision != null ">and revision = #{revision}</if>
54
+            <if test="type != null  and type != ''">and type = #{type}</if>
55
+            <if test="code != null  and code != ''">and code = #{code}</if>
56
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
57
+            <if test="parentId != null ">and parent_id = #{parentId}</if>
58
+            <if test="ancestors != null  and ancestors != ''">and ancestors = #{ancestors}</if>
59
+            <if test="level != null ">and level = #{level}</if>
60
+            <if test="orderNum != null ">and order_num = #{orderNum}</if>
61
+            <if test="score != null ">and score = #{score}</if>
62
+            <if test="unit != null  and unit != ''">and unit = #{unit}</if>
63
+        </where>
64
+    </select>
65
+
66
+    <select id="selectBasePerformanceIndicatorById" parameterType="Long" resultMap="BasePerformanceIndicatorResult">
67
+        <include refid="selectBasePerformanceIndicatorVo"/>
68
+        where id = #{id}
69
+    </select>
70
+
71
+    <insert id="insertBasePerformanceIndicator" parameterType="BasePerformanceIndicator" useGeneratedKeys="true"
72
+            keyProperty="id">
73
+        insert into base_performance_indicator
74
+        <trim prefix="(" suffix=")" suffixOverrides=",">
75
+            <if test="tenantId != null">tenant_id,</if>
76
+            <if test="revision != null">revision,</if>
77
+            <if test="createBy != null">create_by,</if>
78
+            <if test="createTime != null">create_time,</if>
79
+            <if test="updateBy != null">update_by,</if>
80
+            <if test="updateTime != null">update_time,</if>
81
+            <if test="remark != null">remark,</if>
82
+            <if test="type != null and type != ''">type,</if>
83
+            <if test="code != null">code,</if>
84
+            <if test="name != null and name != ''">name,</if>
85
+            <if test="parentId != null">parent_id,</if>
86
+            <if test="ancestors != null and ancestors != ''">ancestors,</if>
87
+            <if test="level != null">level,</if>
88
+            <if test="orderNum != null">order_num,</if>
89
+            <if test="score != null">score,</if>
90
+            <if test="unit != null">unit,</if>
91
+        </trim>
92
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
93
+            <if test="tenantId != null">#{tenantId},</if>
94
+            <if test="revision != null">#{revision},</if>
95
+            <if test="createBy != null">#{createBy},</if>
96
+            <if test="createTime != null">#{createTime},</if>
97
+            <if test="updateBy != null">#{updateBy},</if>
98
+            <if test="updateTime != null">#{updateTime},</if>
99
+            <if test="remark != null">#{remark},</if>
100
+            <if test="type != null and type != ''">#{type},</if>
101
+            <if test="code != null">#{code},</if>
102
+            <if test="name != null and name != ''">#{name},</if>
103
+            <if test="parentId != null">#{parentId},</if>
104
+            <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
105
+            <if test="level != null">#{level},</if>
106
+            <if test="orderNum != null">#{orderNum},</if>
107
+            <if test="score != null">#{score},</if>
108
+            <if test="unit != null">#{unit},</if>
109
+        </trim>
110
+    </insert>
111
+
112
+    <update id="updateBasePerformanceIndicator" parameterType="BasePerformanceIndicator">
113
+        update base_performance_indicator
114
+        <trim prefix="SET" suffixOverrides=",">
115
+            <if test="tenantId != null">tenant_id = #{tenantId},</if>
116
+            <if test="revision != null">revision = #{revision},</if>
117
+            <if test="createBy != null">create_by = #{createBy},</if>
118
+            <if test="createTime != null">create_time = #{createTime},</if>
119
+            <if test="updateBy != null">update_by = #{updateBy},</if>
120
+            <if test="updateTime != null">update_time = #{updateTime},</if>
121
+            <if test="remark != null">remark = #{remark},</if>
122
+            <if test="type != null and type != ''">type = #{type},</if>
123
+            <if test="code != null">code = #{code},</if>
124
+            <if test="name != null and name != ''">name = #{name},</if>
125
+            <if test="parentId != null">parent_id = #{parentId},</if>
126
+            <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
127
+            <if test="level != null">level = #{level},</if>
128
+            <if test="orderNum != null">order_num = #{orderNum},</if>
129
+            <if test="score != null">score = #{score},</if>
130
+            <if test="unit != null">unit = #{unit},</if>
131
+        </trim>
132
+        where id = #{id}
133
+    </update>
134
+
135
+    <delete id="deleteBasePerformanceIndicatorById" parameterType="Long">
136
+        delete
137
+        from base_performance_indicator
138
+        where id = #{id}
139
+    </delete>
140
+
141
+    <delete id="deleteBasePerformanceIndicatorByIds" parameterType="String">
142
+        delete from base_performance_indicator where id in
143
+        <foreach item="id" collection="array" open="(" separator="," close=")">
144
+            #{id}
145
+        </foreach>
146
+    </delete>
147
+
148
+    <select id="selectChildrenById" parameterType="Long" resultMap="BasePerformanceIndicatorResult">
149
+        select *
150
+        from base_performance_indicator
151
+        where find_in_set(#{id}, ancestors)
152
+    </select>
153
+
154
+    <update id="updateChildren" parameterType="java.util.List">
155
+        update base_performance_indicator set ancestors =
156
+        <foreach collection="list" item="item" index="index"
157
+                 separator=" " open="case id" close="end">
158
+            when #{item.id} then #{item.ancestors}
159
+        </foreach>,
160
+        level =
161
+        <foreach collection="list" item="item" index="index"
162
+                 separator=" " open="case id" close="end">
163
+            when #{item.id} then #{item.level}
164
+        </foreach>
165
+        where id in
166
+        <foreach collection="list" item="item" index="index"
167
+                 separator="," open="(" close=")">
168
+            #{item.id}
169
+        </foreach>
170
+    </update>
171
+</mapper>