Przeglądaj źródła

考核指标表

chenshudong 1 miesiąc temu
rodzic
commit
198ce6a626

+ 29 - 13
airport-admin/src/main/java/com/sundot/airport/web/controller/system/BasePerformanceIndicatorController.java

@@ -3,6 +3,7 @@ package com.sundot.airport.web.controller.system;
3
 import java.util.List;
3
 import java.util.List;
4
 import javax.servlet.http.HttpServletResponse;
4
 import javax.servlet.http.HttpServletResponse;
5
 
5
 
6
+import com.sundot.airport.blocked.domain.BlockedRate;
6
 import org.springframework.security.access.prepost.PreAuthorize;
7
 import org.springframework.security.access.prepost.PreAuthorize;
7
 import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.web.bind.annotation.GetMapping;
9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -20,12 +21,14 @@ import com.sundot.airport.common.enums.BusinessType;
20
 import com.sundot.airport.system.domain.BasePerformanceIndicator;
21
 import com.sundot.airport.system.domain.BasePerformanceIndicator;
21
 import com.sundot.airport.system.service.IBasePerformanceIndicatorService;
22
 import com.sundot.airport.system.service.IBasePerformanceIndicatorService;
22
 import com.sundot.airport.common.utils.poi.ExcelUtil;
23
 import com.sundot.airport.common.utils.poi.ExcelUtil;
24
+import com.sundot.airport.common.core.page.TableDataInfo;
25
+import org.springframework.web.multipart.MultipartFile;
23
 
26
 
24
 /**
27
 /**
25
  * 考核指标Controller
28
  * 考核指标Controller
26
  *
29
  *
27
  * @author ruoyi
30
  * @author ruoyi
28
- * @date 2026-04-20
31
+ * @date 2026-04-28
29
  */
32
  */
30
 @RestController
33
 @RestController
31
 @RequestMapping("/system/indicator")
34
 @RequestMapping("/system/indicator")
@@ -38,9 +41,10 @@ public class BasePerformanceIndicatorController extends BaseController {
38
      */
41
      */
39
     @PreAuthorize("@ss.hasPermi('system:indicator:list')")
42
     @PreAuthorize("@ss.hasPermi('system:indicator:list')")
40
     @GetMapping("/list")
43
     @GetMapping("/list")
41
-    public AjaxResult list(BasePerformanceIndicator basePerformanceIndicator) {
44
+    public TableDataInfo list(BasePerformanceIndicator basePerformanceIndicator) {
45
+        startPage();
42
         List<BasePerformanceIndicator> list = basePerformanceIndicatorService.selectBasePerformanceIndicatorList(basePerformanceIndicator);
46
         List<BasePerformanceIndicator> list = basePerformanceIndicatorService.selectBasePerformanceIndicatorList(basePerformanceIndicator);
43
-        return success(list);
47
+        return getDataTable(list);
44
     }
48
     }
45
 
49
 
46
     /**
50
     /**
@@ -56,6 +60,28 @@ public class BasePerformanceIndicatorController extends BaseController {
56
     }
60
     }
57
 
61
 
58
     /**
62
     /**
63
+     * 导入考核指标列表
64
+     */
65
+    @PreAuthorize("@ss.hasPermi('system:indicator:import')")
66
+    @Log(title = "导入考核指标列表", businessType = BusinessType.IMPORT)
67
+    @PostMapping("/importData")
68
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
69
+        ExcelUtil<BasePerformanceIndicator> util = new ExcelUtil<>(BasePerformanceIndicator.class);
70
+        List<BasePerformanceIndicator> list = util.importExcel(file.getInputStream());
71
+        String message = basePerformanceIndicatorService.importData(list, updateSupport);
72
+        return success(message);
73
+    }
74
+
75
+    /**
76
+     * 获取导入模板
77
+     */
78
+    @PostMapping("/importTemplate")
79
+    public void importTemplate(HttpServletResponse response) {
80
+        ExcelUtil<BlockedRate> util = new ExcelUtil<>(BlockedRate.class);
81
+        util.importTemplateExcel(response, "考核指标数据导入模板");
82
+    }
83
+
84
+    /**
59
      * 获取考核指标详细信息
85
      * 获取考核指标详细信息
60
      */
86
      */
61
     @PreAuthorize("@ss.hasPermi('system:indicator:query')")
87
     @PreAuthorize("@ss.hasPermi('system:indicator:query')")
@@ -95,14 +121,4 @@ public class BasePerformanceIndicatorController extends BaseController {
95
     public AjaxResult remove(@PathVariable Long[] ids) {
121
     public AjaxResult remove(@PathVariable Long[] ids) {
96
         return toAjax(basePerformanceIndicatorService.deleteBasePerformanceIndicatorByIds(ids));
122
         return toAjax(basePerformanceIndicatorService.deleteBasePerformanceIndicatorByIds(ids));
97
     }
123
     }
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
 }
124
 }

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

@@ -4,20 +4,20 @@ import lombok.AllArgsConstructor;
4
 import lombok.Getter;
4
 import lombok.Getter;
5
 
5
 
6
 /**
6
 /**
7
- * 考核指标表类型枚举
7
+ * 考核指标表事/病假类型枚举
8
  */
8
  */
9
 @Getter
9
 @Getter
10
 @AllArgsConstructor
10
 @AllArgsConstructor
11
-public enum BasePerformanceIndicatorTypeEnum {
11
+public enum BasePerformanceIndicatorLeaveTypeEnum {
12
 
12
 
13
-    CATEGORY("CATEGORY", "类别"),
14
-    BUSINESS("BUSINESS", "业务");
13
+    PERSONAL_LEAVE("PERSONAL_LEAVE", "事假"),
14
+    SICK_LEAVE("SICK_LEAVE", "病假");
15
 
15
 
16
     private final String code;
16
     private final String code;
17
     private final String desc;
17
     private final String desc;
18
 
18
 
19
-    public static BasePerformanceIndicatorTypeEnum getByCode(String code) {
20
-        for (BasePerformanceIndicatorTypeEnum itemEnum : values()) {
19
+    public static BasePerformanceIndicatorLeaveTypeEnum getByCode(String code) {
20
+        for (BasePerformanceIndicatorLeaveTypeEnum itemEnum : values()) {
21
             if (itemEnum.getCode().equals(code)) {
21
             if (itemEnum.getCode().equals(code)) {
22
                 return itemEnum;
22
                 return itemEnum;
23
             }
23
             }

+ 67 - 28
airport-system/src/main/java/com/sundot/airport/system/domain/BasePerformanceIndicator.java

@@ -5,15 +5,15 @@ import java.math.BigDecimal;
5
 import org.apache.commons.lang3.builder.ToStringBuilder;
5
 import org.apache.commons.lang3.builder.ToStringBuilder;
6
 import org.apache.commons.lang3.builder.ToStringStyle;
6
 import org.apache.commons.lang3.builder.ToStringStyle;
7
 import com.sundot.airport.common.annotation.Excel;
7
 import com.sundot.airport.common.annotation.Excel;
8
-import com.sundot.airport.common.core.domain.TreeEntity;
8
+import com.sundot.airport.common.core.domain.BaseEntity;
9
 
9
 
10
 /**
10
 /**
11
  * 考核指标对象 base_performance_indicator
11
  * 考核指标对象 base_performance_indicator
12
  *
12
  *
13
  * @author ruoyi
13
  * @author ruoyi
14
- * @date 2026-04-20
14
+ * @date 2026-04-28
15
  */
15
  */
16
-public class BasePerformanceIndicator extends TreeEntity {
16
+public class BasePerformanceIndicator extends BaseEntity {
17
     private static final long serialVersionUID = 1L;
17
     private static final long serialVersionUID = 1L;
18
 
18
 
19
     /** 租户号 */
19
     /** 租户号 */
@@ -25,22 +25,26 @@ public class BasePerformanceIndicator extends TreeEntity {
25
     /** 主键 */
25
     /** 主键 */
26
     private Long id;
26
     private Long id;
27
 
27
 
28
-    /** 类型 */
29
-    @Excel(name = "类型", readConverterExp = "CATEGORY=类别,BUSINESS=业务", combo = "类别,业务")
30
-    private String type;
28
+    /** 所属分类编码 */
29
+    @Excel(name = "所属分类编码", type = Excel.Type.EXPORT)
30
+    private String categoryCode;
31
+
32
+    /** 所属分类名称 */
33
+    @Excel(name = "所属分类名称")
34
+    private String categoryName;
35
+
36
+    /** 编码 */
37
+    @Excel(name = "编码", type = Excel.Type.EXPORT)
38
+    private String code;
31
 
39
 
32
     /** 序号 */
40
     /** 序号 */
33
     @Excel(name = "序号")
41
     @Excel(name = "序号")
34
-    private String code;
42
+    private String serialNumber;
35
 
43
 
36
     /** 指标名称 */
44
     /** 指标名称 */
37
     @Excel(name = "指标名称")
45
     @Excel(name = "指标名称")
38
     private String name;
46
     private String name;
39
 
47
 
40
-    /** 层级 */
41
-    @Excel(name = "层级")
42
-    private Integer level;
43
-
44
     /** 分值 */
48
     /** 分值 */
45
     @Excel(name = "分值")
49
     @Excel(name = "分值")
46
     private BigDecimal score;
50
     private BigDecimal score;
@@ -49,6 +53,18 @@ public class BasePerformanceIndicator extends TreeEntity {
49
     @Excel(name = "单位")
53
     @Excel(name = "单位")
50
     private String unit;
54
     private String unit;
51
 
55
 
56
+    /** 事/病假 */
57
+    @Excel(name = "事/病假",
58
+            readConverterExp = "PERSONAL_LEAVE=事假," +
59
+                    "SICK_LEAVE=病假,",
60
+            combo = "事假,病假",
61
+            type = Excel.Type.EXPORT)
62
+    private String leaveType;
63
+
64
+    /** 事/病假描述  */
65
+    @Excel(name = "事/病假", type = Excel.Type.IMPORT)
66
+    private String leaveTypeDesc;
67
+
52
     public void setTenantId(String tenantId) {
68
     public void setTenantId(String tenantId) {
53
         this.tenantId = tenantId;
69
         this.tenantId = tenantId;
54
     }
70
     }
@@ -73,12 +89,20 @@ public class BasePerformanceIndicator extends TreeEntity {
73
         return id;
89
         return id;
74
     }
90
     }
75
 
91
 
76
-    public void setType(String type) {
77
-        this.type = type;
92
+    public void setCategoryCode(String categoryCode) {
93
+        this.categoryCode = categoryCode;
78
     }
94
     }
79
 
95
 
80
-    public String getType() {
81
-        return type;
96
+    public String getCategoryCode() {
97
+        return categoryCode;
98
+    }
99
+
100
+    public void setCategoryName(String categoryName) {
101
+        this.categoryName = categoryName;
102
+    }
103
+
104
+    public String getCategoryName() {
105
+        return categoryName;
82
     }
106
     }
83
 
107
 
84
     public void setCode(String code) {
108
     public void setCode(String code) {
@@ -89,20 +113,20 @@ public class BasePerformanceIndicator extends TreeEntity {
89
         return code;
113
         return code;
90
     }
114
     }
91
 
115
 
92
-    public void setName(String name) {
93
-        this.name = name;
116
+    public void setSerialNumber(String serialNumber) {
117
+        this.serialNumber = serialNumber;
94
     }
118
     }
95
 
119
 
96
-    public String getName() {
97
-        return name;
120
+    public String getSerialNumber() {
121
+        return serialNumber;
98
     }
122
     }
99
 
123
 
100
-    public void setLevel(Integer level) {
101
-        this.level = level;
124
+    public void setName(String name) {
125
+        this.name = name;
102
     }
126
     }
103
 
127
 
104
-    public Integer getLevel() {
105
-        return level;
128
+    public String getName() {
129
+        return name;
106
     }
130
     }
107
 
131
 
108
     public void setScore(BigDecimal score) {
132
     public void setScore(BigDecimal score) {
@@ -121,6 +145,22 @@ public class BasePerformanceIndicator extends TreeEntity {
121
         return unit;
145
         return unit;
122
     }
146
     }
123
 
147
 
148
+    public void setLeaveType(String leaveType) {
149
+        this.leaveType = leaveType;
150
+    }
151
+
152
+    public String getLeaveType() {
153
+        return leaveType;
154
+    }
155
+
156
+    public String getLeaveTypeDesc() {
157
+        return leaveTypeDesc;
158
+    }
159
+
160
+    public void setLeaveTypeDesc(String leaveTypeDesc) {
161
+        this.leaveTypeDesc = leaveTypeDesc;
162
+    }
163
+
124
     @Override
164
     @Override
125
     public String toString() {
165
     public String toString() {
126
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
166
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -132,15 +172,14 @@ public class BasePerformanceIndicator extends TreeEntity {
132
                 .append("updateTime", getUpdateTime())
172
                 .append("updateTime", getUpdateTime())
133
                 .append("remark", getRemark())
173
                 .append("remark", getRemark())
134
                 .append("id", getId())
174
                 .append("id", getId())
135
-                .append("type", getType())
175
+                .append("categoryCode", getCategoryCode())
176
+                .append("categoryName", getCategoryName())
136
                 .append("code", getCode())
177
                 .append("code", getCode())
178
+                .append("serialNumber", getSerialNumber())
137
                 .append("name", getName())
179
                 .append("name", getName())
138
-                .append("parentId", getParentId())
139
-                .append("ancestors", getAncestors())
140
-                .append("level", getLevel())
141
-                .append("orderNum", getOrderNum())
142
                 .append("score", getScore())
180
                 .append("score", getScore())
143
                 .append("unit", getUnit())
181
                 .append("unit", getUnit())
182
+                .append("leaveType", getLeaveType())
144
                 .toString();
183
                 .toString();
145
     }
184
     }
146
 }
185
 }

+ 1 - 18
airport-system/src/main/java/com/sundot/airport/system/mapper/BasePerformanceIndicatorMapper.java

@@ -3,13 +3,12 @@ package com.sundot.airport.system.mapper;
3
 import java.util.List;
3
 import java.util.List;
4
 
4
 
5
 import com.sundot.airport.system.domain.BasePerformanceIndicator;
5
 import com.sundot.airport.system.domain.BasePerformanceIndicator;
6
-import org.apache.ibatis.annotations.Param;
7
 
6
 
8
 /**
7
 /**
9
  * 考核指标Mapper接口
8
  * 考核指标Mapper接口
10
  *
9
  *
11
  * @author ruoyi
10
  * @author ruoyi
12
- * @date 2026-04-20
11
+ * @date 2026-04-28
13
  */
12
  */
14
 public interface BasePerformanceIndicatorMapper {
13
 public interface BasePerformanceIndicatorMapper {
15
     /**
14
     /**
@@ -59,20 +58,4 @@ public interface BasePerformanceIndicatorMapper {
59
      * @return 结果
58
      * @return 结果
60
      */
59
      */
61
     public int deleteBasePerformanceIndicatorByIds(Long[] ids);
60
     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
 }
61
 }

+ 6 - 13
airport-system/src/main/java/com/sundot/airport/system/service/IBasePerformanceIndicatorService.java

@@ -8,7 +8,7 @@ import com.sundot.airport.system.domain.BasePerformanceIndicator;
8
  * 考核指标Service接口
8
  * 考核指标Service接口
9
  *
9
  *
10
  * @author ruoyi
10
  * @author ruoyi
11
- * @date 2026-04-20
11
+ * @date 2026-04-28
12
  */
12
  */
13
 public interface IBasePerformanceIndicatorService {
13
 public interface IBasePerformanceIndicatorService {
14
     /**
14
     /**
@@ -60,18 +60,11 @@ public interface IBasePerformanceIndicatorService {
60
     public int deleteBasePerformanceIndicatorById(Long id);
60
     public int deleteBasePerformanceIndicatorById(Long id);
61
 
61
 
62
     /**
62
     /**
63
-     * 查询考核指标列表树形结构
63
+     * 导入考核指标列表
64
      *
64
      *
65
-     * @param basePerformanceIndicator 考核指标
66
-     * @return 考核指标集合
67
-     */
68
-    public List<BasePerformanceIndicator> selectBasePerformanceIndicatorListTree(BasePerformanceIndicator basePerformanceIndicator);
69
-
70
-    /**
71
-     * 构建前端所需要树结构
72
-     *
73
-     * @param list 列表
74
-     * @return 树结构列表
65
+     * @param list          数据列表
66
+     * @param updateSupport 是否更新支持
67
+     * @return 导入结果信息
75
      */
68
      */
76
-    public List<BasePerformanceIndicator> buildTree(List<BasePerformanceIndicator> list);
69
+    public String importData(List<BasePerformanceIndicator> list, boolean updateSupport);
77
 }
70
 }

+ 109 - 86
airport-system/src/main/java/com/sundot/airport/system/service/impl/BasePerformanceIndicatorServiceImpl.java

@@ -1,32 +1,41 @@
1
 package com.sundot.airport.system.service.impl;
1
 package com.sundot.airport.system.service.impl;
2
 
2
 
3
-import java.util.ArrayList;
4
-import java.util.HashMap;
5
 import java.util.List;
3
 import java.util.List;
6
 import java.util.Map;
4
 import java.util.Map;
5
+import java.util.stream.Collectors;
7
 
6
 
8
-import cn.hutool.core.util.ObjectUtil;
7
+import cn.hutool.core.collection.CollUtil;
8
+import cn.hutool.core.util.ObjUtil;
9
+import com.sundot.airport.common.core.domain.entity.SysDictData;
9
 import com.sundot.airport.common.exception.ServiceException;
10
 import com.sundot.airport.common.exception.ServiceException;
10
 import com.sundot.airport.common.utils.DateUtils;
11
 import com.sundot.airport.common.utils.DateUtils;
11
-import org.apache.commons.lang3.ObjectUtils;
12
+import com.sundot.airport.system.domain.BasePerformanceIndicatorCategory;
13
+import com.sundot.airport.system.service.IBasePerformanceIndicatorCategoryService;
14
+import com.sundot.airport.system.service.ISysDictDataService;
15
+import com.sundot.airport.system.utils.CodeGeneratorUtil;
12
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
14
 import com.sundot.airport.system.mapper.BasePerformanceIndicatorMapper;
18
 import com.sundot.airport.system.mapper.BasePerformanceIndicatorMapper;
15
 import com.sundot.airport.system.domain.BasePerformanceIndicator;
19
 import com.sundot.airport.system.domain.BasePerformanceIndicator;
16
 import com.sundot.airport.system.service.IBasePerformanceIndicatorService;
20
 import com.sundot.airport.system.service.IBasePerformanceIndicatorService;
17
 import org.springframework.transaction.annotation.Transactional;
21
 import org.springframework.transaction.annotation.Transactional;
18
-import org.springframework.util.CollectionUtils;
19
 
22
 
20
 /**
23
 /**
21
  * 考核指标Service业务层处理
24
  * 考核指标Service业务层处理
22
  *
25
  *
23
  * @author ruoyi
26
  * @author ruoyi
24
- * @date 2026-04-20
27
+ * @date 2026-04-28
25
  */
28
  */
26
 @Service
29
 @Service
27
 public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndicatorService {
30
 public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndicatorService {
28
     @Autowired
31
     @Autowired
29
     private BasePerformanceIndicatorMapper basePerformanceIndicatorMapper;
32
     private BasePerformanceIndicatorMapper basePerformanceIndicatorMapper;
33
+    @Autowired
34
+    private IBasePerformanceIndicatorCategoryService basePerformanceIndicatorCategoryService;
35
+    @Autowired
36
+    private ISysDictDataService sysDictDataService;
37
+    @Autowired
38
+    private CodeGeneratorUtil codeGeneratorUtil;
30
 
39
 
31
     /**
40
     /**
32
      * 查询考核指标
41
      * 查询考核指标
@@ -58,19 +67,19 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
58
      */
67
      */
59
     @Override
68
     @Override
60
     public int insertBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
69
     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);
70
+        BasePerformanceIndicator query = new BasePerformanceIndicator();
71
+        query.setCategoryCode(basePerformanceIndicator.getCategoryCode());
72
+        query.setName(basePerformanceIndicator.getName());
73
+        List<BasePerformanceIndicator> existingList = basePerformanceIndicatorMapper.selectBasePerformanceIndicatorList(query);
74
+        if (CollUtil.isNotEmpty(existingList)) {
75
+            basePerformanceIndicator.setUpdateTime(DateUtils.getNowDate());
76
+            basePerformanceIndicator.setId(existingList.get(0).getId());
77
+            return basePerformanceIndicatorMapper.updateBasePerformanceIndicator(basePerformanceIndicator);
65
         } else {
78
         } 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);
79
+            basePerformanceIndicator.setCreateTime(DateUtils.getNowDate());
80
+            basePerformanceIndicator.setCode(codeGeneratorUtil.getNextCodeGenerator());
81
+            return basePerformanceIndicatorMapper.insertBasePerformanceIndicator(basePerformanceIndicator);
72
         }
82
         }
73
-        return basePerformanceIndicatorMapper.insertBasePerformanceIndicator(basePerformanceIndicator);
74
     }
83
     }
75
 
84
 
76
     /**
85
     /**
@@ -79,41 +88,13 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
79
      * @param basePerformanceIndicator 考核指标
88
      * @param basePerformanceIndicator 考核指标
80
      * @return 结果
89
      * @return 结果
81
      */
90
      */
82
-    @Transactional(rollbackFor = Exception.class)
83
     @Override
91
     @Override
84
     public int updateBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
92
     public int updateBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
85
         basePerformanceIndicator.setUpdateTime(DateUtils.getNowDate());
93
         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);
94
         return basePerformanceIndicatorMapper.updateBasePerformanceIndicator(basePerformanceIndicator);
96
     }
95
     }
97
 
96
 
98
     /**
97
     /**
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
      * 批量删除考核指标
98
      * 批量删除考核指标
118
      *
99
      *
119
      * @param ids 需要删除的考核指标主键
100
      * @param ids 需要删除的考核指标主键
@@ -136,57 +117,99 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
136
     }
117
     }
137
 
118
 
138
     /**
119
     /**
139
-     * 查询考核指标列表树形结构
120
+     * 导入考核指标列表
140
      *
121
      *
141
-     * @param basePerformanceIndicator 考核指标
142
-     * @return 考核指标集合
122
+     * @param list            数据列表
123
+     * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
124
+     * @return 结果
143
      */
125
      */
126
+    @Transactional(rollbackFor = Exception.class)
144
     @Override
127
     @Override
145
-    public List<BasePerformanceIndicator> selectBasePerformanceIndicatorListTree(BasePerformanceIndicator basePerformanceIndicator) {
146
-        List<BasePerformanceIndicator> list = selectBasePerformanceIndicatorList(basePerformanceIndicator);
147
-        return buildTree(list);
128
+    public String importData(List<BasePerformanceIndicator> list, boolean isUpdateSupport) {
129
+        if (CollUtil.isEmpty(list)) {
130
+            throw new ServiceException("导入速率数据不能为空!");
131
+        }
132
+
133
+        SysDictData leaveTypeQueryParam = new SysDictData();
134
+        leaveTypeQueryParam.setDictType("base_performance_indicator_leave_type");
135
+        List<SysDictData> leaveTypeList = sysDictDataService.selectDictDataList(leaveTypeQueryParam);
136
+        Map<String, String> leaveTypeMap = leaveTypeList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
137
+
138
+        BasePerformanceIndicatorCategory categoryQueryParam = new BasePerformanceIndicatorCategory();
139
+        categoryQueryParam.setLevel(2);
140
+        List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(categoryQueryParam);
141
+        Map<String, String> categoryMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getName, BasePerformanceIndicatorCategory::getCode, (oldValue, newValue) -> newValue));
142
+
143
+        int successNum = 0;
144
+        int failureNum = 0;
145
+        StringBuilder successMsg = new StringBuilder();
146
+        StringBuilder failureMsg = new StringBuilder();
147
+
148
+        for (BasePerformanceIndicator data : list) {
149
+            // 根据名称填充ID字段
150
+            fillIdsByName(data, categoryMap, leaveTypeMap);
151
+            try {
152
+                if (ObjUtil.isNull(data.getCategoryCode()) || ObjUtil.isNull(data.getCategoryName())) {
153
+                    failureNum++;
154
+                    failureMsg.append("<br/>" + failureNum + "、所属分类不能为空");
155
+                    continue;
156
+                }
157
+
158
+                // 查询是否已存在(根据【日期+当班大队+班次】唯一)
159
+                BasePerformanceIndicator queryParam = new BasePerformanceIndicator();
160
+                queryParam.setCategoryCode(data.getCategoryCode());
161
+                queryParam.setName(data.getName());
162
+                List<BasePerformanceIndicator> existingList = basePerformanceIndicatorMapper.selectBasePerformanceIndicatorList(queryParam);
163
+
164
+                if (CollUtil.isEmpty(existingList)) {
165
+                    // 新增
166
+                    data.setCode(codeGeneratorUtil.getNextCodeGenerator());
167
+                    data.setCreateTime(DateUtils.getNowDate());
168
+                    basePerformanceIndicatorMapper.insertBasePerformanceIndicator(data);
169
+                    successNum++;
170
+                    successMsg.append("<br/>" + successNum + "、所属分类名称【" + data.getCategoryName() + "】、指标名称【" + data.getName() + "】导入成功");
171
+                } else if (isUpdateSupport) {
172
+                    // 更新
173
+                    BasePerformanceIndicator old = existingList.get(0);
174
+                    data.setId(old.getId());
175
+                    data.setUpdateTime(DateUtils.getNowDate());
176
+                    basePerformanceIndicatorMapper.updateBasePerformanceIndicator(data);
177
+                    successNum++;
178
+                    successMsg.append("<br/>" + successNum + "、所属分类名称【" + data.getCategoryName() + "】、指标名称【" + data.getName() + "】更新成功");
179
+                } else {
180
+                    failureNum++;
181
+                    failureMsg.append("<br/>" + failureNum + "、所属分类名称【" + data.getCategoryName() + "】、指标名称【" + data.getName() + "】已存在");
182
+                }
183
+            } catch (Exception e) {
184
+                failureNum++;
185
+                String msg = "<br/>" + failureNum + "、所属分类名称【" + data.getCategoryName() + "】、指标名称【" + data.getName() + "】导入失败:";
186
+                failureMsg.append(msg + e.getMessage());
187
+            }
188
+        }
189
+
190
+        if (failureNum > 0) {
191
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
192
+            throw new ServiceException(failureMsg.toString());
193
+        } else {
194
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
195
+        }
196
+        return successMsg.toString();
148
     }
197
     }
149
 
198
 
150
     /**
199
     /**
151
-     * 构建前端所需要树结构
200
+     * 根据名称填充ID字段
152
      *
201
      *
153
-     * @param list 列表
154
-     * @return 树结构列表
202
+     * @param data 速率数据
155
      */
203
      */
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);
204
+    private void fillIdsByName(BasePerformanceIndicator data, Map<String, String> categoryMap, Map<String, String> leaveTypeMap) {
205
+        // 分类编码
206
+        if (ObjUtil.isNotNull(data.getCategoryName())) {
207
+            data.setCategoryCode(categoryMap.get(data.getCategoryName()));
167
         }
208
         }
168
 
209
 
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
-            }
210
+        // 事/病假
211
+        if (ObjUtil.isNotNull(data.getLeaveTypeDesc())) {
212
+            data.setLeaveType(leaveTypeMap.get(data.getLeaveTypeDesc()));
188
         }
213
         }
189
-
190
-        return result;
191
     }
214
     }
192
 }
215
 }

+ 27 - 55
airport-system/src/main/resources/mapper/system/BasePerformanceIndicatorMapper.xml

@@ -13,15 +13,14 @@
13
         <result property="updateTime" column="update_time"/>
13
         <result property="updateTime" column="update_time"/>
14
         <result property="remark" column="remark"/>
14
         <result property="remark" column="remark"/>
15
         <result property="id" column="id"/>
15
         <result property="id" column="id"/>
16
-        <result property="type" column="type"/>
16
+        <result property="categoryCode" column="category_code"/>
17
+        <result property="categoryName" column="category_name"/>
17
         <result property="code" column="code"/>
18
         <result property="code" column="code"/>
19
+        <result property="serialNumber" column="serial_number"/>
18
         <result property="name" column="name"/>
20
         <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"/>
21
         <result property="score" column="score"/>
24
         <result property="unit" column="unit"/>
22
         <result property="unit" column="unit"/>
23
+        <result property="leaveType" column="leave_type"/>
25
     </resultMap>
24
     </resultMap>
26
 
25
 
27
     <sql id="selectBasePerformanceIndicatorVo">
26
     <sql id="selectBasePerformanceIndicatorVo">
@@ -33,15 +32,14 @@
33
                update_time,
32
                update_time,
34
                remark,
33
                remark,
35
                id,
34
                id,
36
-               type,
35
+               category_code,
36
+               category_name,
37
                code,
37
                code,
38
+               serial_number,
38
                name,
39
                name,
39
-               parent_id,
40
-               ancestors,
41
-               level,
42
-               order_num,
43
                score,
40
                score,
44
-               unit
41
+               unit,
42
+               leave_type
45
         from base_performance_indicator
43
         from base_performance_indicator
46
     </sql>
44
     </sql>
47
 
45
 
@@ -51,15 +49,16 @@
51
         <where>
49
         <where>
52
             <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
50
             <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
53
             <if test="revision != null ">and revision = #{revision}</if>
51
             <if test="revision != null ">and revision = #{revision}</if>
54
-            <if test="type != null  and type != ''">and type = #{type}</if>
52
+            <if test="categoryCode != null  and categoryCode != ''">and category_code = #{categoryCode}</if>
53
+            <if test="categoryName != null  and categoryName != ''">and category_name like concat('%', #{categoryName},
54
+                '%')
55
+            </if>
55
             <if test="code != null  and code != ''">and code = #{code}</if>
56
             <if test="code != null  and code != ''">and code = #{code}</if>
57
+            <if test="serialNumber != null  and serialNumber != ''">and serial_number = #{serialNumber}</if>
56
             <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
58
             <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>
59
             <if test="score != null ">and score = #{score}</if>
62
             <if test="unit != null  and unit != ''">and unit = #{unit}</if>
60
             <if test="unit != null  and unit != ''">and unit = #{unit}</if>
61
+            <if test="leaveType != null  and leaveType != ''">and leave_type = #{leaveType}</if>
63
         </where>
62
         </where>
64
     </select>
63
     </select>
65
 
64
 
@@ -79,15 +78,14 @@
79
             <if test="updateBy != null">update_by,</if>
78
             <if test="updateBy != null">update_by,</if>
80
             <if test="updateTime != null">update_time,</if>
79
             <if test="updateTime != null">update_time,</if>
81
             <if test="remark != null">remark,</if>
80
             <if test="remark != null">remark,</if>
82
-            <if test="type != null and type != ''">type,</if>
81
+            <if test="categoryCode != null and categoryCode != ''">category_code,</if>
82
+            <if test="categoryName != null and categoryName != ''">category_name,</if>
83
             <if test="code != null">code,</if>
83
             <if test="code != null">code,</if>
84
+            <if test="serialNumber != null">serial_number,</if>
84
             <if test="name != null and name != ''">name,</if>
85
             <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>
86
             <if test="score != null">score,</if>
90
             <if test="unit != null">unit,</if>
87
             <if test="unit != null">unit,</if>
88
+            <if test="leaveType != null">leave_type,</if>
91
         </trim>
89
         </trim>
92
         <trim prefix="values (" suffix=")" suffixOverrides=",">
90
         <trim prefix="values (" suffix=")" suffixOverrides=",">
93
             <if test="tenantId != null">#{tenantId},</if>
91
             <if test="tenantId != null">#{tenantId},</if>
@@ -97,15 +95,14 @@
97
             <if test="updateBy != null">#{updateBy},</if>
95
             <if test="updateBy != null">#{updateBy},</if>
98
             <if test="updateTime != null">#{updateTime},</if>
96
             <if test="updateTime != null">#{updateTime},</if>
99
             <if test="remark != null">#{remark},</if>
97
             <if test="remark != null">#{remark},</if>
100
-            <if test="type != null and type != ''">#{type},</if>
98
+            <if test="categoryCode != null and categoryCode != ''">#{categoryCode},</if>
99
+            <if test="categoryName != null and categoryName != ''">#{categoryName},</if>
101
             <if test="code != null">#{code},</if>
100
             <if test="code != null">#{code},</if>
101
+            <if test="serialNumber != null">#{serialNumber},</if>
102
             <if test="name != null and name != ''">#{name},</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>
103
             <if test="score != null">#{score},</if>
108
             <if test="unit != null">#{unit},</if>
104
             <if test="unit != null">#{unit},</if>
105
+            <if test="leaveType != null">#{leaveType},</if>
109
         </trim>
106
         </trim>
110
     </insert>
107
     </insert>
111
 
108
 
@@ -119,15 +116,14 @@
119
             <if test="updateBy != null">update_by = #{updateBy},</if>
116
             <if test="updateBy != null">update_by = #{updateBy},</if>
120
             <if test="updateTime != null">update_time = #{updateTime},</if>
117
             <if test="updateTime != null">update_time = #{updateTime},</if>
121
             <if test="remark != null">remark = #{remark},</if>
118
             <if test="remark != null">remark = #{remark},</if>
122
-            <if test="type != null and type != ''">type = #{type},</if>
119
+            <if test="categoryCode != null and categoryCode != ''">category_code = #{categoryCode},</if>
120
+            <if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
123
             <if test="code != null">code = #{code},</if>
121
             <if test="code != null">code = #{code},</if>
122
+            <if test="serialNumber != null">serial_number = #{serialNumber},</if>
124
             <if test="name != null and name != ''">name = #{name},</if>
123
             <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>
124
             <if test="score != null">score = #{score},</if>
130
             <if test="unit != null">unit = #{unit},</if>
125
             <if test="unit != null">unit = #{unit},</if>
126
+            <if test="leaveType != null">leave_type = #{leaveType},</if>
131
         </trim>
127
         </trim>
132
         where id = #{id}
128
         where id = #{id}
133
     </update>
129
     </update>
@@ -144,28 +140,4 @@
144
             #{id}
140
             #{id}
145
         </foreach>
141
         </foreach>
146
     </delete>
142
     </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>
143
 </mapper>