57fffce6
姜超
[jiangchao] 绩效组查询接口
|
1
|
package cn.fw.morax.service.biz.kpi;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
2
|
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
3
|
import cn.fw.morax.common.constant.Constant;
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
4
|
import cn.fw.morax.common.utils.DateUtil;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
5
|
import cn.fw.morax.common.utils.PublicUtil;
|
982d9d1b
姜超
feature(*): 修改薪酬计...
|
6
|
import cn.fw.morax.domain.db.kpi.*;
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
7
8
|
import cn.fw.morax.domain.dto.kpi.KpiGroupIndicatorRankDTO;
import cn.fw.morax.domain.enums.*;
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
9
|
import cn.fw.morax.domain.vo.kpi.*;
|
3d4edc47
姜超
feature(*): 薪酬项目下钻
|
10
|
import cn.fw.morax.service.biz.CommonService;
|
982d9d1b
姜超
feature(*): 修改薪酬计...
|
11
|
import cn.fw.morax.service.data.kpi.*;
|
967ed70a
姜超
feature(*): 绩效详情接口
|
12
|
import com.alibaba.fastjson.JSON;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
13
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
14
|
import com.google.common.collect.Lists;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
15
16
|
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
17
|
import org.springframework.stereotype.Service;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
18
|
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
19
|
import java.math.BigDecimal;
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
20
|
import java.time.LocalDate;
|
967ed70a
姜超
feature(*): 绩效详情接口
|
21
|
import java.time.YearMonth;
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
22
23
|
import java.util.*;
import java.util.function.Function;
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
24
|
import java.util.stream.Collectors;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
25
26
27
28
29
30
31
32
33
34
|
import static cn.fw.common.businessvalidator.Validator.BV;
@RequiredArgsConstructor
@Service
@Slf4j
public class KpiGroupIndicatorBizService {
private final KpiGroupIndicatorLaddersService kpiGroupIndicatorLaddersService;
private final KpiGroupIndicatorService kpiGroupIndicatorService;
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
35
|
private final KpiGroupIndicatorHitLogService kpiGroupIndicatorHitLogService;
|
982d9d1b
姜超
feature(*): 修改薪酬计...
|
36
37
|
private final KpiGroupIndicatorParamService kpiGroupIndicatorParamService;
private final KpiGroupIndicatorPreconditionService kpiGroupIndicatorPreconditionService;
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
38
39
|
private final KpiGroupIndicatorTargetHitLogService kpiGroupIndicatorTargetHitLogService;
private final KpiGroupIndicatorPreconditionLaddersService kpiGroupIndicatorPreconditionLaddersService;
|
99471c63
姜超
feature(*): 指标排名
|
40
|
private final KpiPoolIndicatorValueService kpiPoolIndicatorValueService;
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
41
|
private final IndicatorUserValueService indicatorUserValueService;
|
99471c63
姜超
feature(*): 指标排名
|
42
43
|
private final KpiGroupUserService kpiGroupUserService;
private final IndicatorsService indicatorsService;
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
44
|
private final KpiGroupService kpiGroupService;
|
3d4edc47
姜超
feature(*): 薪酬项目下钻
|
45
|
private final CommonService commonService;
|
967ed70a
姜超
feature(*): 绩效详情接口
|
46
|
private final KpiPoolService kpiPoolService;
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
47
48
49
|
/**
* 绩效组指标详情
|
b8b6eb02
姜超
feature(*): 接口注释修改
|
50
|
*
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
51
52
53
|
* @param kpiIndicatorId
* @return
*/
|
83fc9174
姜超
feature(*): 薪酬项查询...
|
54
|
public KpiGroupIndicatorVO kpiGroupIndicatorDetail(Long kpiIndicatorId) {
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
55
|
KpiGroupIndicator kpiGroupIndicator = kpiGroupIndicatorService.getById(kpiIndicatorId);
|
a38c5a05
姜超
feature(*): 薪酬报表
|
56
|
BV.notNull(kpiGroupIndicator, "绩效指标配置不存在,请重试");
|
83fc9174
姜超
feature(*): 薪酬项查询...
|
57
|
KpiGroupIndicatorVO kpiGroupIndicatorVo = PublicUtil.copy(kpiGroupIndicator, KpiGroupIndicatorVO.class);
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
58
59
60
|
List<KpiGroupIndicatorLadders> kpiGroupIndicatorLadders = kpiGroupIndicatorLaddersService.list(Wrappers.<KpiGroupIndicatorLadders>lambdaQuery()
.eq(KpiGroupIndicatorLadders::getKpiGroupIndicatorId, kpiIndicatorId)
|
98f0b2aa
姜超
feature(*): 添加yn判断
|
61
|
.eq(KpiGroupIndicatorLadders::getYn, Boolean.TRUE)
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
62
63
|
);
if (PublicUtil.isNotEmpty(kpiGroupIndicatorLadders)) {
|
83fc9174
姜超
feature(*): 薪酬项查询...
|
64
|
List<KpiGroupIndicatorLaddersVO> indicatorLaddersVos = PublicUtil.copyList(kpiGroupIndicatorLadders, KpiGroupIndicatorLaddersVO.class);
|
59d58c08
姜超
feature(*): excel...
|
65
|
kpiGroupIndicatorVo.setIndicatorLadders(indicatorLaddersVos);
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
66
67
68
|
}
return kpiGroupIndicatorVo;
}
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
69
70
71
|
/**
* 获取正在使用指标的绩效组
|
b8b6eb02
姜超
feature(*): 接口注释修改
|
72
|
*
|
9dd1f916
姜超
feature(*): 指标启用禁用
|
73
|
* @param indicatorCode
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
74
75
|
* @return
*/
|
9dd1f916
姜超
feature(*): 指标启用禁用
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
public List<KpiGroup> getKpiGroupByIndicatorCode(String indicatorCode) {
List<KpiGroupIndicatorParam> kpiGroupIndicatorParams = kpiGroupIndicatorParamService.list(Wrappers.<KpiGroupIndicatorParam>lambdaQuery()
.eq(KpiGroupIndicatorParam::getIndicatorCode, indicatorCode)
.eq(KpiGroupIndicatorParam::getYn, Boolean.TRUE)
);
List<KpiGroupIndicatorPrecondition> preconditions = kpiGroupIndicatorPreconditionService.list(Wrappers.<KpiGroupIndicatorPrecondition>lambdaQuery()
.eq(KpiGroupIndicatorPrecondition::getIndicatorCode, indicatorCode)
.eq(KpiGroupIndicatorPrecondition::getYn, Boolean.TRUE)
);
Set<Long> kpiGroupIds = new HashSet<>();
if (PublicUtil.isNotEmpty(kpiGroupIndicatorParams)) {
kpiGroupIds.addAll(kpiGroupIndicatorParams.stream().map(KpiGroupIndicatorParam::getKpiGroupId).collect(Collectors.toSet()));
}
if (PublicUtil.isNotEmpty(preconditions)) {
kpiGroupIds.addAll(preconditions.stream().map(KpiGroupIndicatorPrecondition::getKpiGroupId).collect(Collectors.toSet()));
}
if (PublicUtil.isEmpty(kpiGroupIds)) {
return new ArrayList<>();
}
|
99471c63
姜超
feature(*): 指标排名
|
96
|
List<SettingStatusEnum> status = new ArrayList<SettingStatusEnum>() {{
|
982d9d1b
姜超
feature(*): 修改薪酬计...
|
97
98
|
add(SettingStatusEnum.APPROVING);
add(SettingStatusEnum.BE_EFFECTIVE);
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
99
100
|
add(SettingStatusEnum.EFFECTIVE);
}};
|
982d9d1b
姜超
feature(*): 修改薪酬计...
|
101
|
List<KpiGroup> kpiGroups = kpiGroupService.list(Wrappers.<KpiGroup>lambdaQuery()
|
9dd1f916
姜超
feature(*): 指标启用禁用
|
102
|
.in(KpiGroup::getId, kpiGroupIds)
|
982d9d1b
姜超
feature(*): 修改薪酬计...
|
103
104
105
|
.in(KpiGroup::getStatus, status)
.eq(KpiGroup::getYn, Boolean.TRUE)
);
|
9dd1f916
姜超
feature(*): 指标启用禁用
|
106
|
return kpiGroups;
|
bbb00e01
姜超
feature(*): 启用禁用指标
|
107
108
|
}
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
109
|
/**
|
967ed70a
姜超
feature(*): 绩效详情接口
|
110
111
112
113
114
115
116
117
118
119
|
* 绩效项目阶梯详情
*
* @param kpiPoolId
* @param kpiGroupIndicatorId
* @param yearMonth
* @return
*/
public KpiGroupIndicatorDetailVO getHitIndicatorLadder(Long kpiPoolId, Long kpiGroupIndicatorId, YearMonth yearMonth) {
KpiPool kpiPool = kpiPoolService.getById(kpiPoolId);
|
9f47fb88
姜超
feature(*): 薪酬组人员日期
|
120
121
122
123
|
if (PublicUtil.isEmpty(kpiPool)) {
return null;
}
// BV.notNull(kpiPool, "绩效池不存在");
|
967ed70a
姜超
feature(*): 绩效详情接口
|
124
125
126
127
128
129
130
131
132
|
LocalDate localDate = this.getPoolLastData(kpiPool);
Long userId = kpiPool.getUserId();
KpiGroupIndicator kpiGroupIndicator = kpiGroupIndicatorService.getById(kpiGroupIndicatorId);
BV.notNull(kpiGroupIndicator, "指标不存在");
KpiGroup kpiGroup = kpiGroupService.getAllDataById(kpiGroupIndicator.getKpiGroupId());
BV.notNull(kpiGroup, "绩效组不存在");
KpiGroupIndicatorDetailVO detailVO = new KpiGroupIndicatorDetailVO();
|
967ed70a
姜超
feature(*): 绩效详情接口
|
133
|
this.setIndicatorsVo(kpiGroupIndicatorId, userId, localDate, detailVO);
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
134
|
detailVO.setKpiGroupId(kpiGroup.getId());
|
967ed70a
姜超
feature(*): 绩效详情接口
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
detailVO.setKpiTime(localDate.atTime(23, 59, 59));
detailVO.setPostId(kpiGroup.getPostId());
detailVO.setPostName(kpiGroup.getPostName());
detailVO.setKpiGroupShopIds(kpiGroup.getShopIds());
detailVO.setKpiGroupShopNames(kpiGroup.getShopNames());
return detailVO;
}
/**
* 获取绩效池详情最近日期
*
* @param kpiPool
* @return
*/
public LocalDate getPoolLastData(KpiPool kpiPool) {
|
a92022b7
姜超
feature(*): 绩效不再使...
|
151
|
KpiGroupUser kpiGroupUser = kpiGroupUserService.getMonthLastData(kpiPool.getKpiGroupId(), kpiPool.getUserId(), kpiPool.getMonthly());
|
967ed70a
姜超
feature(*): 绩效详情接口
|
152
153
154
155
156
157
158
159
|
if (PublicUtil.isEmpty(kpiGroupUser)) {
log.error("员工绩效池:{},不存在绩效组人员", JSON.toJSONString(kpiPool));
return PublicUtil.getYesterdayOrEndOfMonthDay(kpiPool.getMonthly());
}
return kpiGroupUser.getDataDate();
}
/**
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
160
161
162
163
|
* 设置指标
*
* @param
*/
|
967ed70a
姜超
feature(*): 绩效详情接口
|
164
|
public void setIndicatorsVo(Long kpiGroupIndicatorId, Long userId, LocalDate localDate, KpiGroupIndicatorDetailVO detailVO) {
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
165
166
|
KpiGroupIndicator kpiGroupIndicator = kpiGroupIndicatorService.getById(kpiGroupIndicatorId);
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
167
|
BV.notNull(kpiGroupIndicator, "绩效组指标不存在");
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
168
169
170
|
detailVO.setScoreWay(kpiGroupIndicator.getScoreWay());
detailVO.setBaseScore(kpiGroupIndicator.getBaseScore());
detailVO.setParamAlias(kpiGroupIndicator.getParamAlias());
|
a45344cf
姜超
feature(bug): 修改目...
|
171
172
173
|
if (PublicUtil.isNotEmpty(kpiGroupIndicator.getLaddersType())) {
detailVO.setLaddersType(kpiGroupIndicator.getLaddersType());
}
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
174
|
|
0ac3000c
姜超
feature(*): 绩效详情查看
|
175
|
//命中记录
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
176
177
178
179
180
181
|
KpiGroupIndicatorHitLog kpiGroupIndicatorHitLog = kpiGroupIndicatorHitLogService.getOne(Wrappers.<KpiGroupIndicatorHitLog>lambdaQuery()
.eq(KpiGroupIndicatorHitLog::getKpiGroupIndicatorId, kpiGroupIndicatorId)
.eq(KpiGroupIndicatorHitLog::getDataDate, localDate)
.eq(KpiGroupIndicatorHitLog::getUserId, userId)
.eq(KpiGroupIndicatorHitLog::getYn, Boolean.TRUE)
);
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
182
183
184
|
if (ScoreWayEnum.LADDER.equals(kpiGroupIndicator.getScoreWay())) {
Long hitKpiIndicatorLaddersId = kpiGroupIndicatorHitLog.getKpiGroupIndicatorLaddersId();
|
278ef9ef
姜超
feature(bug): 修改目...
|
185
186
|
List<KpiGroupIndicatorLaddersVO> ladderVos = kpiGroupIndicatorLaddersService.getVos(kpiGroupIndicatorId, kpiGroupIndicator.getLaddersType());
for (KpiGroupIndicatorLaddersVO laddersVO : ladderVos) {
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
187
|
if (PublicUtil.isNotEmpty(hitKpiIndicatorLaddersId)) {
|
278ef9ef
姜超
feature(bug): 修改目...
|
188
|
laddersVO.setHit((hitKpiIndicatorLaddersId.equals(laddersVO.getId()) ? Boolean.TRUE : Boolean.FALSE));
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
189
|
}
|
278ef9ef
姜超
feature(bug): 修改目...
|
190
191
|
}
detailVO.setLadders(ladderVos);
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
192
193
|
}
|
278ef9ef
姜超
feature(bug): 修改目...
|
194
|
if (PublicUtil.isNotEmpty(kpiGroupIndicatorHitLog) && DataTypeEnum.RATIO.equals(kpiGroupIndicator.getLaddersType())) {
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
195
196
|
detailVO.setParamsValue(kpiGroupIndicatorHitLog.getKpiValue().multiply(Constant.ONE_HUNDRED));
}
|
0ac3000c
姜超
feature(*): 绩效详情查看
|
197
|
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
198
199
|
//参数
Map<ParamTypeEnum, List<KpiGroupIndicatorParamVO>> paramMap = this.getKpiGroupIndicatorParamMap(kpiGroupIndicatorId, userId, localDate);
|
967ed70a
姜超
feature(*): 绩效详情接口
|
200
201
|
detailVO.setLadderParams(paramMap.getOrDefault(ParamTypeEnum.LADDER, new ArrayList<>()));
detailVO.setCommissionParams(paramMap.getOrDefault(ParamTypeEnum.COMMISSION, new ArrayList<>()));
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
202
203
204
|
//条件
List<KpiGroupIndicatorPreconditionVO> preconditionVOS = kpiGroupIndicatorPreconditionService.getHitVos(kpiGroupIndicatorId, userId, localDate);
|
967ed70a
姜超
feature(*): 绩效详情接口
|
205
|
detailVO.setConds(preconditionVOS);
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
206
207
|
for (KpiGroupIndicatorPreconditionVO preconditionVO : preconditionVOS) {
//条件目标记录
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
208
|
if (! TargetTypeEnum.NO.equals(preconditionVO.getTargetType())) {
|
99471c63
姜超
feature(*): 指标排名
|
209
|
KpiGroupIndicatorTargetHitLog kpiGroupIndicatorTargetHitLog = kpiGroupIndicatorTargetHitLogService.getOne(Wrappers.<KpiGroupIndicatorTargetHitLog>lambdaQuery()
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
210
|
.eq(KpiGroupIndicatorTargetHitLog::getReferId, preconditionVO.getId())
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
211
|
.eq(KpiGroupIndicatorTargetHitLog::getTargetType, IndicatorTypeEnum.PRE)
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
212
213
214
215
|
.eq(KpiGroupIndicatorTargetHitLog::getDataDate, localDate)
.eq(KpiGroupIndicatorTargetHitLog::getUserId, userId)
.eq(KpiGroupIndicatorTargetHitLog::getYn, Boolean.TRUE)
);
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
216
217
218
219
|
preconditionVO.processTargetPercent(kpiGroupIndicatorTargetHitLog);
} else {
//无条件目标记录
preconditionVO.processNoTargetPercent();
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
220
221
222
|
}
//条件阶梯
|
278ef9ef
姜超
feature(bug): 修改目...
|
223
224
|
List<KpiGroupIndicatorPreconditionLaddersVO> preconditionLaddersVOS = kpiGroupIndicatorPreconditionLaddersService.getVOS(
preconditionVO.getId(), preconditionVO.getTargetType(), preconditionVO.getDataType());
|
3d4edc47
姜超
feature(*): 薪酬项目下钻
|
225
226
227
|
for (KpiGroupIndicatorPreconditionLaddersVO preconditionLaddersVO : preconditionLaddersVOS) {
if (PublicUtil.isNotEmpty(preconditionVO.getHitLaddersId()) && preconditionLaddersVO.getId().equals(preconditionVO.getHitLaddersId())) {
preconditionLaddersVO.setHit(Boolean.TRUE);
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
228
|
}
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
229
230
231
232
|
}
preconditionVO.setCondLadders(preconditionLaddersVOS);
}
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
233
234
|
}
|
278ef9ef
姜超
feature(bug): 修改目...
|
235
236
237
|
|
0ac3000c
姜超
feature(*): 绩效详情查看
|
238
239
240
241
242
243
244
245
|
/**
* 获取绩效参数
*
* @param kpiGroupIndicatorId
* @param userId
* @param localDate
* @return
*/
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
246
247
|
public Map<ParamTypeEnum, List<KpiGroupIndicatorParamVO>> getKpiGroupIndicatorParamMap(Long kpiGroupIndicatorId, Long userId, LocalDate localDate) {
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
248
|
List<KpiGroupIndicatorParamVO> paramVos = kpiGroupIndicatorParamService.getKpiGroupIndicatorParamVos(kpiGroupIndicatorId);
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
249
|
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
250
|
List<String> indicatorCodes = paramVos.stream()
|
3d4edc47
姜超
feature(*): 薪酬项目下钻
|
251
|
.filter(param -> TargetTypeEnum.NO.equals(param.getTargetType()))
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
252
|
.map(KpiGroupIndicatorParamVO::getIndicatorCode).collect(Collectors.toList());
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
253
|
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
254
255
256
257
258
259
260
261
262
263
264
|
Map<String, IndicatorUserValue> indicatorCodeValueMap = new HashMap<>();
if (PublicUtil.isNotEmpty(indicatorCodes)) {
List<IndicatorUserValue> indicatorUserValues = indicatorUserValueService.list(Wrappers.<IndicatorUserValue>lambdaQuery()
.in(IndicatorUserValue::getIndicatorCode, indicatorCodes)
.eq(IndicatorUserValue::getDataDate, localDate)
.eq(IndicatorUserValue::getUserId, userId)
.eq(IndicatorUserValue::getYn, Boolean.TRUE)
);
indicatorCodeValueMap = indicatorUserValues.stream()
.collect(Collectors.toMap(IndicatorUserValue::getIndicatorCode, Function.identity(), (v1, v2) -> v1));
}
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
265
|
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
266
|
List<Long> paramIds = paramVos.stream()
|
99471c63
姜超
feature(*): 指标排名
|
267
|
.filter(param -> !TargetTypeEnum.NO.equals(param.getTargetType()))
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
268
|
.map(KpiGroupIndicatorParamVO::getId).collect(Collectors.toList());
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
269
|
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
270
271
|
Map<Long, KpiGroupIndicatorTargetHitLog> paramTargetHitLogMap = new HashMap<>();
if (PublicUtil.isNotEmpty(paramIds)) {
|
99471c63
姜超
feature(*): 指标排名
|
272
|
List<KpiGroupIndicatorTargetHitLog> targetHitLogs = kpiGroupIndicatorTargetHitLogService.list(Wrappers.<KpiGroupIndicatorTargetHitLog>lambdaQuery()
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
273
274
275
276
277
|
.in(KpiGroupIndicatorTargetHitLog::getReferId, paramIds)
.eq(KpiGroupIndicatorTargetHitLog::getDataDate, localDate)
.eq(KpiGroupIndicatorTargetHitLog::getUserId, userId)
.eq(KpiGroupIndicatorTargetHitLog::getYn, Boolean.TRUE)
);
|
99471c63
姜超
feature(*): 指标排名
|
278
|
paramTargetHitLogMap = targetHitLogs.stream()
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
279
280
|
.collect(Collectors.toMap(KpiGroupIndicatorTargetHitLog::getReferId, Function.identity(), (v1, v2) -> v1));
}
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
281
|
for (KpiGroupIndicatorParamVO paramVO : paramVos) {
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
282
|
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
283
|
//有目标
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
284
285
|
if (paramTargetHitLogMap.containsKey(paramVO.getId())) {
KpiGroupIndicatorTargetHitLog targetHitLog = paramTargetHitLogMap.get(paramVO.getId());
|
5d90b0dc
姜超
feature(*): 绩效数据展示修改
|
286
287
|
if (DataTypeEnum.RATIO.equals(paramVO.getDataType())) {
paramVO.setIndicatorValue(targetHitLog.getValue().multiply(Constant.ONE_HUNDRED));
|
150794c9
姜超
feature(*): 展示修改
|
288
289
|
} else {
paramVO.setIndicatorValue(targetHitLog.getValue());
|
5d90b0dc
姜超
feature(*): 绩效数据展示修改
|
290
|
}
|
0ac3000c
姜超
feature(*): 绩效详情查看
|
291
|
paramVO.setReachValue(targetHitLog.getReachValue().multiply(Constant.ONE_HUNDRED));
|
f4b9a6ec
姜超
feature(*): 修改绩效组保存
|
292
293
294
295
296
|
continue;
}
//无目标
if (indicatorCodeValueMap.containsKey(paramVO.getIndicatorCode())) {
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
297
|
IndicatorUserValue indicatorUserValue = indicatorCodeValueMap.get(paramVO.getIndicatorCode());
|
3d4edc47
姜超
feature(*): 薪酬项目下钻
|
298
|
BigDecimal indicatorOriginValue = commonService.queryIndicatorValue(paramVO.getIndicatorCode(), indicatorUserValue);
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
299
300
301
|
switch (indicatorUserValue.getValueType()) {
case WORK_AGE:
case QUANTITY: {
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
302
|
paramVO.setIndicatorValue(indicatorOriginValue);
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
303
304
305
|
break;
}
case RATIO: {
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
306
|
paramVO.setIndicatorValue(indicatorOriginValue.multiply(Constant.ONE_HUNDRED));
|
f77829b1
姜超
feature(*): 绩效薪酬详情
|
307
308
309
|
break;
}
}
|
0ac3000c
姜超
feature(*): 绩效详情查看
|
310
|
}
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
311
312
|
}
|
58aa0677
姜超
feature(*): 绩效得分详情修改
|
313
|
Map<ParamTypeEnum, List<KpiGroupIndicatorParamVO>> indicatorParamMap = paramVos.stream()
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
314
315
316
317
|
.collect(Collectors.groupingBy(KpiGroupIndicatorParamVO::getParamType));
return indicatorParamMap;
}
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
318
|
|
99471c63
姜超
feature(*): 指标排名
|
319
320
321
322
323
324
|
/**
* 查询指标排名
*
* @param dto
* @return
*/
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
325
326
|
public KpiIndicatorRankVO queryKpiIndicatorRank(KpiGroupIndicatorRankDTO dto) {
|
99471c63
姜超
feature(*): 指标排名
|
327
328
329
330
|
LocalDate localDate = PublicUtil.getYesterdayOrEndOfMonthDay(dto.getMonthly());
List<KpiPool> pools = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
.eq(KpiPool::getKpiGroupId, dto.getKpiGroupId())
.eq(KpiPool::getMonthly, YearMonth.from(localDate))
|
16ee250d
姜超
feature(*): 排名修改
|
331
|
// .eq(KpiPool::getInclusion, Boolean.TRUE)
|
99471c63
姜超
feature(*): 指标排名
|
332
333
|
.eq(KpiPool::getYn, Boolean.TRUE)
);
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
334
|
|
99471c63
姜超
feature(*): 指标排名
|
335
|
Long referId = null;
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
336
337
338
339
|
BigDecimal targetValue = null;
String indicatorCode = null;
TargetTypeEnum targetType = null;
TargetCalcTypeEnum targetCalcType = null;
|
99471c63
姜超
feature(*): 指标排名
|
340
|
IndicatorTypeEnum indicatorTypeEnum = null;
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
341
|
if (PublicUtil.isNotEmpty(dto.getKpiGroupIndicatorParamId())) {
|
99471c63
姜超
feature(*): 指标排名
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
referId = dto.getKpiGroupIndicatorParamId();
indicatorTypeEnum = IndicatorTypeEnum.EXAMINE;
KpiGroupIndicatorParam param = kpiGroupIndicatorParamService.getById(dto.getKpiGroupIndicatorParamId());
BV.isTrue(PublicUtil.isNotEmpty(param), "绩效组指标参数不存在");
indicatorCode = param.getIndicatorCode();
targetType = param.getTargetType();
targetValue = param.getTargetValue();
targetCalcType = param.getTargetCalcType();
} else {
referId = dto.getKpiGroupIndicatorPreconditionId();
indicatorTypeEnum = IndicatorTypeEnum.PRE;
KpiGroupIndicatorPrecondition precondition = kpiGroupIndicatorPreconditionService.getById(dto.getKpiGroupIndicatorPreconditionId());
BV.isTrue(PublicUtil.isNotEmpty(precondition), "绩效组指标条件不存在");
indicatorCode = precondition.getIndicatorCode();
targetType = precondition.getTargetType();
targetValue = precondition.getTargetValue();
targetCalcType = precondition.getTargetCalcType();
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
360
361
|
}
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
362
|
|
99471c63
姜超
feature(*): 指标排名
|
363
364
365
366
|
Indicators indicators = indicatorsService.queryByCode(indicatorCode, Boolean.FALSE);
BV.isTrue(PublicUtil.isNotEmpty(indicators), "指标不存在");
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
367
|
KpiIndicatorRankVO kpiIndicatorRankVO = KpiIndicatorRankVO.builder()
|
99471c63
姜超
feature(*): 指标排名
|
368
369
370
|
.indicatorName(indicators.getIndicatorName())
.indicatorCode(indicators.getIndicatorCode())
.dataType(indicators.getDataType())
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
371
|
.targetType(targetType)
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
372
373
|
.deadlineDate(DateUtil.localDate2Date(localDate))
.build();
|
99471c63
姜超
feature(*): 指标排名
|
374
|
if (PublicUtil.isEmpty(pools)) {
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
375
|
log.error("绩效指标查无数据,指标:[{}] [{}] [{}]", indicatorCode, dto.getKpiGroupId(), localDate);
|
99471c63
姜超
feature(*): 指标排名
|
376
377
|
return kpiIndicatorRankVO;
}
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
378
|
|
99471c63
姜超
feature(*): 指标排名
|
379
|
//无目标指标排名
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
380
|
if (TargetTypeEnum.NO.equals(targetType)) {
|
99471c63
姜超
feature(*): 指标排名
|
381
|
kpiIndicatorRankVO.setStaffs(getNoTargetIndicatorRanks(indicatorCode, localDate, pools));
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
382
383
384
|
return kpiIndicatorRankVO;
}
|
99471c63
姜超
feature(*): 指标排名
|
385
|
//有目标指标排名
|
278ef9ef
姜超
feature(bug): 修改目...
|
386
|
kpiIndicatorRankVO.setStaffs(getTargetIndicatorRanks(referId, localDate, pools, indicatorTypeEnum, indicators));
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
387
|
kpiIndicatorRankVO.setTargetValue((TargetTypeEnum.RATIO.equals(targetType) ? targetValue.multiply(Constant.ONE_HUNDRED) : targetValue));
|
99471c63
姜超
feature(*): 指标排名
|
388
389
390
|
kpiIndicatorRankVO.setTargetCalcType(targetCalcType);
return kpiIndicatorRankVO;
}
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
391
|
|
99471c63
姜超
feature(*): 指标排名
|
392
393
394
395
396
397
398
399
400
401
|
/**
* 无目标指标排名
*
* @param indicatorCode
* @param localDate
* @param pools
* @return
*/
public List<KpiIndicatorRankStaffVO> getNoTargetIndicatorRanks(String indicatorCode, LocalDate localDate, List<KpiPool> pools) {
Set<Long> userIds = pools.stream().map(KpiPool::getUserId).collect(Collectors.toSet());
|
e1778851
姜超
feature(*): 计算考评调整
|
402
|
List<IndicatorUserValueVO> indicatorUserValues = indicatorUserValueService.getStaffReportData(indicatorCode, YearMonth.from(localDate), userIds);
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
403
|
|
99471c63
姜超
feature(*): 指标排名
|
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
Map<Long, IndicatorUserValueVO> indicatorUserValueMap = indicatorUserValues.stream()
.collect(Collectors.toMap(IndicatorUserValueVO::getUserId, Function.identity(), (v1, v2) -> v1));
List<KpiIndicatorRankStaffVO> staffRanks = Lists.newArrayListWithCapacity(indicatorUserValues.size());
for (KpiPool kpiPool : pools) {
KpiIndicatorRankStaffVO rankStaffVO = new KpiIndicatorRankStaffVO();
rankStaffVO.setUserId(kpiPool.getUserId());
rankStaffVO.setUserName(kpiPool.getUserName());
rankStaffVO.setPostId(kpiPool.getPostId());
rankStaffVO.setPostName(kpiPool.getPostName());
rankStaffVO.setShopId(kpiPool.getShopId());
rankStaffVO.setShopName(kpiPool.getShopName());
rankStaffVO.setInclusion(kpiPool.getInclusion());
if (indicatorUserValueMap.containsKey(kpiPool.getUserId())) {
IndicatorUserValueVO indicatorUserValueVO = indicatorUserValueMap.get(kpiPool.getUserId());
rankStaffVO.setOriginValue(commonService.queryIndicatorValueVO(indicatorCode, indicatorUserValueVO));
}
staffRanks.add(rankStaffVO);
}
Collections.sort(staffRanks);
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
427
|
calcRank(staffRanks);
|
99471c63
姜超
feature(*): 指标排名
|
428
|
return staffRanks;
|
7de20f3f
姜超
feature(*): 绩效薪酬查看
|
429
|
}
|
99471c63
姜超
feature(*): 指标排名
|
430
431
432
433
434
435
436
437
438
439
440
441
442
443
|
/**
* 有目标指标排名
*
* @param referId
* @param localDate
* @param pools
* @param indicatorTypeEnum
* @return
*/
public List<KpiIndicatorRankStaffVO> getTargetIndicatorRanks(Long referId,
LocalDate localDate,
List<KpiPool> pools,
IndicatorTypeEnum indicatorTypeEnum,
|
278ef9ef
姜超
feature(bug): 修改目...
|
444
|
Indicators indicators) {
|
99471c63
姜超
feature(*): 指标排名
|
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
Set<Long> userIds = pools.stream().map(KpiPool::getUserId).collect(Collectors.toSet());
List<KpiGroupIndicatorTargetHitLogVO> indicatorTargetHitLogs = kpiGroupIndicatorTargetHitLogService.getIndicatorData(referId,
YearMonth.from(localDate), indicatorTypeEnum, userIds);
Map<Long, KpiGroupIndicatorTargetHitLogVO> indicatorTargetMap = indicatorTargetHitLogs.stream()
.collect(Collectors.toMap(KpiGroupIndicatorTargetHitLogVO::getUserId, Function.identity(), (v1, v2) -> v1));
List<KpiIndicatorRankStaffVO> staffRanks = Lists.newArrayListWithCapacity(indicatorTargetMap.size());
for (KpiPool kpiPool : pools) {
KpiIndicatorRankStaffVO rankStaffVO = new KpiIndicatorRankStaffVO();
rankStaffVO.setUserId(kpiPool.getUserId());
rankStaffVO.setUserName(kpiPool.getUserName());
rankStaffVO.setPostId(kpiPool.getPostId());
rankStaffVO.setPostName(kpiPool.getPostName());
rankStaffVO.setShopId(kpiPool.getShopId());
rankStaffVO.setShopName(kpiPool.getShopName());
rankStaffVO.setInclusion(kpiPool.getInclusion());
if (indicatorTargetMap.containsKey(kpiPool.getUserId())) {
KpiGroupIndicatorTargetHitLogVO targetHitLogVO = indicatorTargetMap.get(kpiPool.getUserId());
|
278ef9ef
姜超
feature(bug): 修改目...
|
466
467
|
rankStaffVO.setOriginValue(targetHitLogVO.getValue());
rankStaffVO.setReachValue(targetHitLogVO.getReachValue());
|
69f59d7a
姜超
feature(bug): 修改目...
|
468
|
rankStaffVO.convertReportValueToPercent(indicators.getDataType());
|
99471c63
姜超
feature(*): 指标排名
|
469
470
471
472
473
|
}
staffRanks.add(rankStaffVO);
}
Collections.sort(staffRanks);
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
474
|
calcRank(staffRanks);
|
99471c63
姜超
feature(*): 指标排名
|
475
476
477
|
return staffRanks;
}
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
478
479
480
481
482
483
|
/**
* 设置排名序号
*
* @return
*/
public void calcRank(List<KpiIndicatorRankStaffVO> staffs) {
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
484
|
int rank = 1;
|
3a3defbe
姜超
feature(bug): 排名名次修改
|
485
486
487
488
489
490
491
|
Optional<BigDecimal> lastIndicatorValueOp = staffs.stream()
.filter(staff -> Boolean.TRUE.equals(staff.getInclusion()))
.findFirst().map(KpiIndicatorRankStaffVO::getOriginValue);
if (Boolean.FALSE.equals(lastIndicatorValueOp.isPresent())) {
return;
}
BigDecimal lastIndicatorValue = lastIndicatorValueOp.get();
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
492
|
for (KpiIndicatorRankStaffVO staff : staffs) {
|
16ee250d
姜超
feature(*): 排名修改
|
493
494
495
|
if (! staff.getInclusion()) {
continue;
}
|
3a3defbe
姜超
feature(bug): 排名名次修改
|
496
497
|
//原始值为空,无排名
if (PublicUtil.isEmpty(staff.getOriginValue())) {
|
dad803db
姜超
feature(*): 修改展示查询
|
498
499
500
|
continue;
}
if (lastIndicatorValue.compareTo(staff.getOriginValue()) != 0) {
|
96ab8564
姜超
feature(*): 薪酬组绩效...
|
501
502
503
504
505
506
507
508
|
rank++;
}
staff.setIndicatorRank(rank);
lastIndicatorValue = staff.getOriginValue();
}
}
|
9e73b4bb
姜超
[jiangchao] 绩效指标相关接口
|
509
|
}
|
9fe049d0
姜超
feature(*): 修改薪酬计...
|
|
|