|
|
@@ -3,11 +3,11 @@ package com.sundot.airport.system.service.impl;
|
|
3
|
3
|
import java.math.BigDecimal;
|
|
4
|
4
|
import java.util.List;
|
|
5
|
5
|
import java.util.Map;
|
|
6
|
|
-import java.util.function.Function;
|
|
7
|
6
|
import java.util.stream.Collectors;
|
|
8
|
7
|
|
|
9
|
8
|
import cn.hutool.core.collection.CollUtil;
|
|
10
|
9
|
import cn.hutool.core.util.ObjUtil;
|
|
|
10
|
+import cn.hutool.core.util.StrUtil;
|
|
11
|
11
|
import com.sundot.airport.common.core.domain.entity.SysDictData;
|
|
12
|
12
|
import com.sundot.airport.common.enums.BasePerformanceIndicatorRewardPunishmentTypeTypeEnum;
|
|
13
|
13
|
import com.sundot.airport.common.exception.ServiceException;
|
|
|
@@ -70,18 +70,24 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
|
|
70
|
70
|
*/
|
|
71
|
71
|
@Override
|
|
72
|
72
|
public int insertBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
|
|
73
|
|
- // 一级分类编码
|
|
|
73
|
+ // 一级分类+二级分类
|
|
74
|
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());
|
|
|
75
|
+ List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryListTree(categoryQueryParam);
|
|
|
76
|
+ if (ObjUtil.isNotNull(basePerformanceIndicator.getCategoryCodeOne())) {
|
|
|
77
|
+ BasePerformanceIndicatorCategory categoryOne = categoryList.stream().filter(category -> StrUtil.equals(category.getCode(), basePerformanceIndicator.getCategoryCodeOne())).findFirst().orElse(null);
|
|
|
78
|
+ if (ObjUtil.isNotNull(categoryOne)) {
|
|
|
79
|
+ basePerformanceIndicator.setCategoryNameOne(categoryOne.getName());
|
|
|
80
|
+ if (ObjUtil.isNotNull(basePerformanceIndicator.getCategoryCode()) && CollUtil.isNotEmpty(categoryOne.getChildren())) {
|
|
|
81
|
+ List<BasePerformanceIndicatorCategory> children = (List<BasePerformanceIndicatorCategory>) categoryOne.getChildren();
|
|
|
82
|
+ BasePerformanceIndicatorCategory categoryTwo = children.stream().filter(category -> StrUtil.equals(category.getCode(), basePerformanceIndicator.getCategoryCode())).findFirst().orElse(null);
|
|
|
83
|
+ if (ObjUtil.isNotNull(categoryTwo)) {
|
|
|
84
|
+ basePerformanceIndicator.setCategoryName(categoryTwo.getCode());
|
|
|
85
|
+ } else {
|
|
|
86
|
+ basePerformanceIndicator.setCategoryName(null);
|
|
|
87
|
+ }
|
|
84
|
88
|
}
|
|
|
89
|
+ } else {
|
|
|
90
|
+ basePerformanceIndicator.setCategoryNameOne(null);
|
|
85
|
91
|
}
|
|
86
|
92
|
}
|
|
87
|
93
|
// 判断奖罚类型
|
|
|
@@ -118,18 +124,24 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
|
|
118
|
124
|
@Override
|
|
119
|
125
|
public int updateBasePerformanceIndicator(BasePerformanceIndicator basePerformanceIndicator) {
|
|
120
|
126
|
basePerformanceIndicator.setUpdateTime(DateUtils.getNowDate());
|
|
121
|
|
- // 一级分类编码
|
|
|
127
|
+ // 一级分类+二级分类
|
|
122
|
128
|
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());
|
|
|
129
|
+ List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryListTree(categoryQueryParam);
|
|
|
130
|
+ if (ObjUtil.isNotNull(basePerformanceIndicator.getCategoryCodeOne())) {
|
|
|
131
|
+ BasePerformanceIndicatorCategory categoryOne = categoryList.stream().filter(category -> StrUtil.equals(category.getCode(), basePerformanceIndicator.getCategoryCodeOne())).findFirst().orElse(null);
|
|
|
132
|
+ if (ObjUtil.isNotNull(categoryOne)) {
|
|
|
133
|
+ basePerformanceIndicator.setCategoryNameOne(categoryOne.getName());
|
|
|
134
|
+ if (ObjUtil.isNotNull(basePerformanceIndicator.getCategoryCode()) && CollUtil.isNotEmpty(categoryOne.getChildren())) {
|
|
|
135
|
+ List<BasePerformanceIndicatorCategory> children = (List<BasePerformanceIndicatorCategory>) categoryOne.getChildren();
|
|
|
136
|
+ BasePerformanceIndicatorCategory categoryTwo = children.stream().filter(category -> StrUtil.equals(category.getCode(), basePerformanceIndicator.getCategoryCode())).findFirst().orElse(null);
|
|
|
137
|
+ if (ObjUtil.isNotNull(categoryTwo)) {
|
|
|
138
|
+ basePerformanceIndicator.setCategoryName(categoryTwo.getCode());
|
|
|
139
|
+ } else {
|
|
|
140
|
+ basePerformanceIndicator.setCategoryName(null);
|
|
|
141
|
+ }
|
|
132
|
142
|
}
|
|
|
143
|
+ } else {
|
|
|
144
|
+ basePerformanceIndicator.setCategoryNameOne(null);
|
|
133
|
145
|
}
|
|
134
|
146
|
}
|
|
135
|
147
|
// 判断奖罚类型
|
|
|
@@ -187,10 +199,7 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
|
|
187
|
199
|
Map<String, String> leaveTypeMap = leaveTypeList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
|
|
188
|
200
|
|
|
189
|
201
|
BasePerformanceIndicatorCategory categoryQueryParam = new BasePerformanceIndicatorCategory();
|
|
190
|
|
- List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryList(categoryQueryParam);
|
|
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));
|
|
|
202
|
+ List<BasePerformanceIndicatorCategory> categoryList = basePerformanceIndicatorCategoryService.selectBasePerformanceIndicatorCategoryListTree(categoryQueryParam);
|
|
194
|
203
|
|
|
195
|
204
|
int successNum = 0;
|
|
196
|
205
|
int failureNum = 0;
|
|
|
@@ -209,9 +218,9 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
|
|
209
|
218
|
data.setRewardPunishmentType(BasePerformanceIndicatorRewardPunishmentTypeTypeEnum.OTHER.getCode());
|
|
210
|
219
|
}
|
|
211
|
220
|
// 根据名称填充ID字段
|
|
212
|
|
- fillIdsByName(data, categoryMap, codeParentIdMap, categoryDataMap, leaveTypeMap);
|
|
|
221
|
+ fillIdsByName(data, categoryList, leaveTypeMap);
|
|
213
|
222
|
try {
|
|
214
|
|
- if (ObjUtil.isNull(data.getCategoryCode()) || ObjUtil.isNull(data.getCategoryName())) {
|
|
|
223
|
+ if (ObjUtil.isNull(data.getCategoryCode()) || ObjUtil.isNull(data.getCategoryName()) || ObjUtil.isNull(data.getCategoryCodeOne()) || ObjUtil.isNull(data.getCategoryNameOne())) {
|
|
215
|
224
|
failureNum++;
|
|
216
|
225
|
failureMsg.append("<br/>" + failureNum + "、所属分类不能为空");
|
|
217
|
226
|
continue;
|
|
|
@@ -263,18 +272,19 @@ public class BasePerformanceIndicatorServiceImpl implements IBasePerformanceIndi
|
|
263
|
272
|
*
|
|
264
|
273
|
* @param data 考核指标数据
|
|
265
|
274
|
*/
|
|
266
|
|
- private void fillIdsByName(BasePerformanceIndicator data, Map<String, String> categoryMap, Map<String, Long> codeParentIdMap, Map<Long, BasePerformanceIndicatorCategory> categoryDataMap, Map<String, String> leaveTypeMap) {
|
|
267
|
|
- // 二级分类编码
|
|
268
|
|
- if (ObjUtil.isNotNull(data.getCategoryName())) {
|
|
269
|
|
- data.setCategoryCode(categoryMap.get(data.getCategoryName()));
|
|
270
|
|
- }
|
|
271
|
|
-
|
|
272
|
|
- // 一级分类编码
|
|
273
|
|
- if (ObjUtil.isNotNull(data.getCategoryCode())) {
|
|
274
|
|
- BasePerformanceIndicatorCategory categoryOne = categoryDataMap.get(codeParentIdMap.get(data.getCategoryCode()));
|
|
|
275
|
+ private void fillIdsByName(BasePerformanceIndicator data, List<BasePerformanceIndicatorCategory> categoryList, Map<String, String> leaveTypeMap) {
|
|
|
276
|
+ // 一级分类+二级分类
|
|
|
277
|
+ if (ObjUtil.isNotNull(data.getCategoryNameOne())) {
|
|
|
278
|
+ BasePerformanceIndicatorCategory categoryOne = categoryList.stream().filter(category -> StrUtil.equals(category.getName(), data.getCategoryNameOne())).findFirst().orElse(null);
|
|
275
|
279
|
if (ObjUtil.isNotNull(categoryOne)) {
|
|
276
|
280
|
data.setCategoryCodeOne(categoryOne.getCode());
|
|
277
|
|
- data.setCategoryNameOne(categoryOne.getName());
|
|
|
281
|
+ if (ObjUtil.isNotNull(data.getCategoryName()) && CollUtil.isNotEmpty(categoryOne.getChildren())) {
|
|
|
282
|
+ List<BasePerformanceIndicatorCategory> children = (List<BasePerformanceIndicatorCategory>) categoryOne.getChildren();
|
|
|
283
|
+ BasePerformanceIndicatorCategory categoryTwo = children.stream().filter(category -> StrUtil.equals(category.getName(), data.getCategoryName())).findFirst().orElse(null);
|
|
|
284
|
+ if (ObjUtil.isNotNull(categoryTwo)) {
|
|
|
285
|
+ data.setCategoryCode(categoryTwo.getCode());
|
|
|
286
|
+ }
|
|
|
287
|
+ }
|
|
278
|
288
|
}
|
|
279
|
289
|
}
|
|
280
|
290
|
|