소스 검색

考核指标表

chenshudong 1 개월 전
부모
커밋
af00b118a8

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

@@ -25,12 +25,12 @@ public class BasePerformanceIndicator extends BaseEntity {
25 25
     /** 主键 */
26 26
     private Long id;
27 27
 
28
-    /** 所属分类编码 */
29
-    @Excel(name = "所属分类编码", type = Excel.Type.EXPORT)
28
+    /** 所属二级分类编码 */
29
+    @Excel(name = "所属二级分类编码", type = Excel.Type.EXPORT)
30 30
     private String categoryCode;
31 31
 
32
-    /** 所属分类名称 */
33
-    @Excel(name = "所属分类名称")
32
+    /** 所属二级分类名称 */
33
+    @Excel(name = "所属二级分类名称")
34 34
     private String categoryName;
35 35
 
36 36
     /** 编码 */

+ 45 - 30
airport-system/src/main/java/com/sundot/airport/system/service/impl/BasePerformanceIndicatorServiceImpl.java

@@ -48,19 +48,7 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
48 48
      */
49 49
     @Override
50 50
     public BasePerformanceIndicator selectBasePerformanceIndicatorById(Long id) {
51
-        BasePerformanceIndicator result = basePerformanceIndicatorMapper.selectBasePerformanceIndicatorById(id);
52
-        BasePerformanceIndicatorCategory basePerformanceIndicatorCategoryQuery = new BasePerformanceIndicatorCategory();
53
-        basePerformanceIndicatorCategoryQuery.setCode(result.getCategoryCode());
54
-        List<BasePerformanceIndicatorCategory> basePerformanceIndicatorCategoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(basePerformanceIndicatorCategoryQuery);
55
-        if (CollUtil.isNotEmpty(basePerformanceIndicatorCategoryList)) {
56
-            BasePerformanceIndicatorCategory basePerformanceIndicatorCategory = basePerformanceIndicatorCategoryList.get(0);
57
-            BasePerformanceIndicatorCategory basePerformanceIndicatorCategoryOne = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryById(basePerformanceIndicatorCategory.getParentId());
58
-            if (ObjUtil.isNotNull(basePerformanceIndicatorCategoryOne)) {
59
-                result.setCategoryCodeOne(basePerformanceIndicatorCategoryOne.getCode());
60
-                result.setCategoryNameOne(basePerformanceIndicatorCategoryOne.getName());
61
-            }
62
-        }
63
-        return result;
51
+        return basePerformanceIndicatorMapper.selectBasePerformanceIndicatorById(id);
64 52
     }
65 53
 
66 54
     /**
@@ -71,18 +59,7 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
71 59
      */
72 60
     @Override
73 61
     public List<BasePerformanceIndicator> selectBasePerformanceIndicatorList(BasePerformanceIndicator basePerformanceIndicator) {
74
-        List<BasePerformanceIndicator> result = basePerformanceIndicatorMapper.selectBasePerformanceIndicatorList(basePerformanceIndicator);
75
-        List<BasePerformanceIndicatorCategory> basePerformanceIndicatorCategoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(new BasePerformanceIndicatorCategory());
76
-        Map<Long, BasePerformanceIndicatorCategory> dataMap = basePerformanceIndicatorCategoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getId, Function.identity(), (oldValue, newValue) -> newValue));
77
-        Map<String, Long> codeParentIdMap = basePerformanceIndicatorCategoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getCode, BasePerformanceIndicatorCategory::getParentId, (oldValue, newValue) -> newValue));
78
-        result.forEach(item -> {
79
-            BasePerformanceIndicatorCategory basePerformanceIndicatorCategoryOne = dataMap.get(codeParentIdMap.get(item.getCode()));
80
-            if (ObjUtil.isNotNull(basePerformanceIndicatorCategoryOne)) {
81
-                item.setCategoryCodeOne(basePerformanceIndicatorCategoryOne.getCode());
82
-                item.setCategoryNameOne(basePerformanceIndicatorCategoryOne.getName());
83
-            }
84
-        });
85
-        return result;
62
+        return basePerformanceIndicatorMapper.selectBasePerformanceIndicatorList(basePerformanceIndicator);
86 63
     }
87 64
 
88 65
     /**
@@ -93,6 +70,20 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
93 70
      */
94 71
     @Override
95 72
     public int insertBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
73
+        // 一级分类编码
74
+        BasePerformanceIndicatorCategory categoryQueryParam = new BasePerformanceIndicatorCategory();
75
+        List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(categoryQueryParam);
76
+        if (CollUtil.isNotEmpty(categoryList)) {
77
+            Map<String, Long> codeParentIdMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getCode, BasePerformanceIndicatorCategory::getParentId, (oldValue, newValue) -> newValue));
78
+            Map<Long, BasePerformanceIndicatorCategory> categoryDataMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getId, Function.identity(), (oldValue, newValue) -> newValue));
79
+            if (ObjUtil.isNotNull(basePerformanceIndicator.getCategoryCode())) {
80
+                BasePerformanceIndicatorCategory categoryOne = categoryDataMap.get(codeParentIdMap.get(basePerformanceIndicator.getCategoryCode()));
81
+                if (ObjUtil.isNotNull(categoryOne)) {
82
+                    basePerformanceIndicator.setCategoryCodeOne(categoryOne.getCode());
83
+                    basePerformanceIndicator.setCategoryNameOne(categoryOne.getName());
84
+                }
85
+            }
86
+        }
96 87
         // 判断奖罚类型
97 88
         if (ObjUtil.isNull(basePerformanceIndicator.getScore())) {
98 89
             basePerformanceIndicator.setRewardPunishmentType(BasePerformanceIndicatorRewardPunishmentTypeTypeEnum.OTHER.getCode());
@@ -127,6 +118,20 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
127 118
     @Override
128 119
     public int updateBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
129 120
         basePerformanceIndicator.setUpdateTime(DateUtils.getNowDate());
121
+        // 一级分类编码
122
+        BasePerformanceIndicatorCategory categoryQueryParam = new BasePerformanceIndicatorCategory();
123
+        List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(categoryQueryParam);
124
+        if (CollUtil.isNotEmpty(categoryList)) {
125
+            Map<String, Long> codeParentIdMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getCode, BasePerformanceIndicatorCategory::getParentId, (oldValue, newValue) -> newValue));
126
+            Map<Long, BasePerformanceIndicatorCategory> categoryDataMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getId, Function.identity(), (oldValue, newValue) -> newValue));
127
+            if (ObjUtil.isNotNull(basePerformanceIndicator.getCategoryCode())) {
128
+                BasePerformanceIndicatorCategory categoryOne = categoryDataMap.get(codeParentIdMap.get(basePerformanceIndicator.getCategoryCode()));
129
+                if (ObjUtil.isNotNull(categoryOne)) {
130
+                    basePerformanceIndicator.setCategoryCodeOne(categoryOne.getCode());
131
+                    basePerformanceIndicator.setCategoryNameOne(categoryOne.getName());
132
+                }
133
+            }
134
+        }
130 135
         // 判断奖罚类型
131 136
         if (ObjUtil.isNull(basePerformanceIndicator.getScore())) {
132 137
             basePerformanceIndicator.setRewardPunishmentType(BasePerformanceIndicatorRewardPunishmentTypeTypeEnum.OTHER.getCode());
@@ -182,9 +187,10 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
182 187
         Map<String, String> leaveTypeMap = leaveTypeList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
183 188
 
184 189
         BasePerformanceIndicatorCategory categoryQueryParam = new BasePerformanceIndicatorCategory();
185
-        categoryQueryParam.setLevel(2);
186 190
         List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(categoryQueryParam);
187 191
         Map<String, String> categoryMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getName, BasePerformanceIndicatorCategory::getCode, (oldValue, newValue) -> newValue));
192
+        Map<String, Long> codeParentIdMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getCode, BasePerformanceIndicatorCategory::getParentId, (oldValue, newValue) -> newValue));
193
+        Map<Long, BasePerformanceIndicatorCategory> categoryDataMap = categoryList.stream().collect(Collectors.toMap(BasePerformanceIndicatorCategory::getId, Function.identity(), (oldValue, newValue) -> newValue));
188 194
 
189 195
         int successNum = 0;
190 196
         int failureNum = 0;
@@ -203,7 +209,7 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
203 209
                 data.setRewardPunishmentType(BasePerformanceIndicatorRewardPunishmentTypeTypeEnum.OTHER.getCode());
204 210
             }
205 211
             // 根据名称填充ID字段
206
-            fillIdsByName(data, categoryMap, leaveTypeMap);
212
+            fillIdsByName(data, categoryMap, codeParentIdMap, categoryDataMap, leaveTypeMap);
207 213
             try {
208 214
                 if (ObjUtil.isNull(data.getCategoryCode()) || ObjUtil.isNull(data.getCategoryName())) {
209 215
                     failureNum++;
@@ -211,7 +217,7 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
211 217
                     continue;
212 218
                 }
213 219
 
214
-                // 查询是否已存在(根据【日期+当班大队+班次】唯一)
220
+                // 查询是否已存在(根据【所属二级分类编码+指标名称】唯一)
215 221
                 BasePerformanceIndicator queryParam = new BasePerformanceIndicator();
216 222
                 queryParam.setCategoryCode(data.getCategoryCode());
217 223
                 queryParam.setName(data.getName());
@@ -257,12 +263,21 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
257 263
      *
258 264
      * @param data 考核指标数据
259 265
      */
260
-    private void fillIdsByName(BasePerformanceIndicator data, Map<String, String> categoryMap, Map<String, String> leaveTypeMap) {
261
-        // 分类编码
266
+    private void fillIdsByName(BasePerformanceIndicator data, Map<String, String> categoryMap, Map<String, Long> codeParentIdMap, Map<Long, BasePerformanceIndicatorCategory> categoryDataMap, Map<String, String> leaveTypeMap) {
267
+        // 二级分类编码
262 268
         if (ObjUtil.isNotNull(data.getCategoryName())) {
263 269
             data.setCategoryCode(categoryMap.get(data.getCategoryName()));
264 270
         }
265 271
 
272
+        // 一级分类编码
273
+        if (ObjUtil.isNotNull(data.getCategoryCode())) {
274
+            BasePerformanceIndicatorCategory categoryOne = categoryDataMap.get(codeParentIdMap.get(data.getCategoryCode()));
275
+            if (ObjUtil.isNotNull(categoryOne)) {
276
+                data.setCategoryCodeOne(categoryOne.getCode());
277
+                data.setCategoryNameOne(categoryOne.getName());
278
+            }
279
+        }
280
+
266 281
         // 事/病假
267 282
         if (ObjUtil.isNotNull(data.getLeaveTypeDesc())) {
268 283
             data.setLeaveType(leaveTypeMap.get(data.getLeaveTypeDesc()));

+ 16 - 1
airport-system/src/main/resources/mapper/system/BasePerformanceIndicatorMapper.xml

@@ -22,6 +22,8 @@
22 22
         <result property="unit" column="unit"/>
23 23
         <result property="leaveType" column="leave_type"/>
24 24
         <result property="rewardPunishmentType" column="reward_punishment_type"/>
25
+        <result property="categoryCodeOne" column="category_code_one"/>
26
+        <result property="categoryNameOne" column="category_name_one"/>
25 27
     </resultMap>
26 28
 
27 29
     <sql id="selectBasePerformanceIndicatorVo">
@@ -41,7 +43,9 @@
41 43
                score,
42 44
                unit,
43 45
                leave_type,
44
-               reward_punishment_type
46
+               reward_punishment_type,
47
+               category_code_one,
48
+               category_name_one
45 49
         from base_performance_indicator
46 50
     </sql>
47 51
 
@@ -64,6 +68,11 @@
64 68
             <if test="rewardPunishmentType != null  and rewardPunishmentType != ''">and reward_punishment_type =
65 69
                 #{rewardPunishmentType}
66 70
             </if>
71
+            <if test="categoryCodeOne != null  and categoryCodeOne != ''">and category_code_one = #{categoryCodeOne}
72
+            </if>
73
+            <if test="categoryNameOne != null  and categoryNameOne != ''">and category_name_one like
74
+                concat('%', #{categoryNameOne}, '%')
75
+            </if>
67 76
         </where>
68 77
         order by create_time desc
69 78
     </select>
@@ -93,6 +102,8 @@
93 102
             <if test="unit != null">unit,</if>
94 103
             <if test="leaveType != null">leave_type,</if>
95 104
             <if test="rewardPunishmentType != null">reward_punishment_type,</if>
105
+            <if test="categoryCodeOne != null">category_code_one,</if>
106
+            <if test="categoryNameOne != null">category_name_one,</if>
96 107
         </trim>
97 108
         <trim prefix="values (" suffix=")" suffixOverrides=",">
98 109
             <if test="tenantId != null">#{tenantId},</if>
@@ -111,6 +122,8 @@
111 122
             <if test="unit != null">#{unit},</if>
112 123
             <if test="leaveType != null">#{leaveType},</if>
113 124
             <if test="rewardPunishmentType != null">#{rewardPunishmentType},</if>
125
+            <if test="categoryCodeOne != null">#{categoryCodeOne},</if>
126
+            <if test="categoryNameOne != null">#{categoryNameOne},</if>
114 127
         </trim>
115 128
     </insert>
116 129
 
@@ -133,6 +146,8 @@
133 146
             <if test="unit != null">unit = #{unit},</if>
134 147
             <if test="leaveType != null">leave_type = #{leaveType},</if>
135 148
             <if test="rewardPunishmentType != null">reward_punishment_type = #{rewardPunishmentType},</if>
149
+            <if test="categoryCodeOne != null">category_code_one = #{categoryCodeOne},</if>
150
+            <if test="categoryNameOne != null">category_name_one = #{categoryNameOne},</if>
136 151
         </trim>
137 152
         where id = #{id}
138 153
     </update>