Commit 19325c466d409fcfd98cc6dd28621002e06b5542
1 parent
94675d99
feature(*): 查看考评详情
查看考评详情
Showing
5 changed files
with
274 additions
and
33 deletions
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/EvalSelectorVO.java
0 → 100644
1 | +package cn.fw.morax.domain.vo; | |
2 | + | |
3 | +import cn.fw.morax.domain.vo.eval.EvalUserGroupRankVO; | |
4 | +import lombok.Builder; | |
5 | +import lombok.Data; | |
6 | +import lombok.EqualsAndHashCode; | |
7 | + | |
8 | +import java.math.BigDecimal; | |
9 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : kurisu | |
13 | + * @version : 1.0 | |
14 | + * @className : SelectorVO | |
15 | + * @description : 绩效\薪酬池选项 | |
16 | + * @date : 2022-05-06 11:23 | |
17 | + */ | |
18 | +@Data | |
19 | +@EqualsAndHashCode | |
20 | +@Builder | |
21 | +public class EvalSelectorVO { | |
22 | + /** | |
23 | + * 岗位id | |
24 | + */ | |
25 | + private Long postId; | |
26 | + /** | |
27 | + * 门店id | |
28 | + */ | |
29 | + private Long shopId; | |
30 | + /** | |
31 | + * 名称 | |
32 | + */ | |
33 | + private String name; | |
34 | + | |
35 | + /** | |
36 | + * 排名 | |
37 | + */ | |
38 | + private List<EvalUserGroupRankVO> ranks; | |
39 | + | |
40 | + public static EvalSelectorVO whit(Long postId, Long shopId, String shopName, String postName) { | |
41 | + String name = shopName + | |
42 | + " (" + | |
43 | + postName + | |
44 | + ") "; | |
45 | + EvalSelectorVO vo = new EvalSelectorVO(); | |
46 | + vo.setShopId(shopId); | |
47 | + vo.setPostId(postId); | |
48 | + vo.setName(name); | |
49 | + return vo; | |
50 | + } | |
51 | + | |
52 | + public EvalSelectorVO() { | |
53 | + } | |
54 | + | |
55 | + public EvalSelectorVO(String name, List<EvalUserGroupRankVO> ranks) { | |
56 | + this.name = name; | |
57 | + this.ranks = ranks; | |
58 | + } | |
59 | +} | ... | ... |
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/eval/EvalUserGroupRankVO.java
0 → 100644
1 | +package cn.fw.morax.domain.vo.eval; | |
2 | + | |
3 | +import cn.fw.morax.common.constant.Constant; | |
4 | +import cn.fw.morax.common.utils.PublicUtil; | |
5 | +import cn.fw.morax.domain.enums.EvalTypeEnum; | |
6 | +import cn.fw.morax.domain.enums.KpiIgnoreCauseEnum; | |
7 | +import lombok.Data; | |
8 | +import lombok.EqualsAndHashCode; | |
9 | + | |
10 | +import java.math.BigDecimal; | |
11 | +import java.time.LocalDate; | |
12 | +import java.time.YearMonth; | |
13 | +import java.util.List; | |
14 | + | |
15 | +/** | |
16 | + * <p> | |
17 | + * 考评池 | |
18 | + * </p> | |
19 | + * | |
20 | + * @author jiangchao | |
21 | + * @since 2022-12-09 | |
22 | + */ | |
23 | +@Data | |
24 | +@EqualsAndHashCode(callSuper = false) | |
25 | +public class EvalUserGroupRankVO { | |
26 | + | |
27 | + private static final long serialVersionUID = 1L; | |
28 | + | |
29 | + /** | |
30 | + * 考评排名组id | |
31 | + */ | |
32 | + private Long id; | |
33 | + | |
34 | + /** | |
35 | + * 考评组编码 | |
36 | + */ | |
37 | + private String evalGroupRankName; | |
38 | + | |
39 | + /** | |
40 | + * 考评组id | |
41 | + */ | |
42 | + private Long evalGroupRankId; | |
43 | + | |
44 | + /** | |
45 | + * 考评得分率 | |
46 | + */ | |
47 | + private BigDecimal scoreRatio; | |
48 | + /** | |
49 | + * 奖惩 | |
50 | + */ | |
51 | + private BigDecimal reward; | |
52 | + | |
53 | + /** | |
54 | + * 考评得分率(格式化) | |
55 | + */ | |
56 | + private String scoreRatioFormat; | |
57 | + | |
58 | + | |
59 | + public void convertScoreRatio() { | |
60 | + if (PublicUtil.isNotEmpty(this.getScoreRatio())) { | |
61 | + this.setScoreRatio(this.getScoreRatio().multiply(Constant.ONE_HUNDRED)); | |
62 | + } | |
63 | + } | |
64 | +} | ... | ... |
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/eval/EvalUserRankStageVO.java
0 → 100644
1 | +package cn.fw.morax.domain.vo.eval; | |
2 | + | |
3 | +import lombok.Data; | |
4 | +import lombok.EqualsAndHashCode; | |
5 | + | |
6 | +import java.time.LocalDate; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * <p> | |
11 | + * 考评组 | |
12 | + * </p> | |
13 | + * | |
14 | + * @author jiangchao | |
15 | + * @since 2022-12-09 | |
16 | + */ | |
17 | +@Data | |
18 | +@EqualsAndHashCode(callSuper = false) | |
19 | +public class EvalUserRankStageVO { | |
20 | + | |
21 | + /** | |
22 | + * 主键id | |
23 | + */ | |
24 | + private Long id; | |
25 | + /** | |
26 | + * 阶段名称 | |
27 | + */ | |
28 | + private String name; | |
29 | + | |
30 | + /** | |
31 | + * 考评排名组id | |
32 | + */ | |
33 | + private Long evalGroupRankId; | |
34 | + | |
35 | + /** | |
36 | + * 生效时间 | |
37 | + */ | |
38 | + private LocalDate beginTime; | |
39 | + | |
40 | + /** | |
41 | + * 结束时间 | |
42 | + */ | |
43 | + private LocalDate overTime; | |
44 | + | |
45 | + /** | |
46 | + * 考评池 | |
47 | + */ | |
48 | + private EvalUserPoolVO pool; | |
49 | + | |
50 | + | |
51 | +} | ... | ... |
fw-morax-server/src/main/java/cn/fw/morax/server/controller/app/EvalPoolController.java
... | ... | @@ -11,7 +11,7 @@ import cn.fw.morax.common.utils.PublicUtil; |
11 | 11 | import cn.fw.morax.domain.dto.eval.EvalGroupIndicatorRankDTO; |
12 | 12 | import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO; |
13 | 13 | import cn.fw.morax.domain.enums.EvalScopeEnum; |
14 | -import cn.fw.morax.domain.vo.SelectorVO; | |
14 | +import cn.fw.morax.domain.vo.EvalSelectorVO; | |
15 | 15 | import cn.fw.morax.domain.vo.eval.*; |
16 | 16 | import cn.fw.morax.domain.vo.kpi.KpiIndicatorRankVO; |
17 | 17 | import cn.fw.morax.service.biz.eval.*; |
... | ... | @@ -29,7 +29,6 @@ import java.time.LocalDate; |
29 | 29 | import java.time.YearMonth; |
30 | 30 | import java.util.List; |
31 | 31 | import java.util.Objects; |
32 | -import java.util.Set; | |
33 | 32 | |
34 | 33 | import static cn.fw.common.businessvalidator.Validator.BV; |
35 | 34 | import static cn.fw.common.web.util.ResultBuilder.success; |
... | ... | @@ -80,7 +79,7 @@ public class EvalPoolController { |
80 | 79 | @GetMapping("/staff-selector") |
81 | 80 | @IgnoreUserToken |
82 | 81 | @ControllerMethod("本月可查看的其他考评池选项") |
83 | - public Message<Set<SelectorVO>> evalPoolSelector(@CurrentUser LoginAuthBean user, Long userId, @RequestParam(required = false) YearMonth monthly) { | |
82 | + public Message<List<EvalSelectorVO>> evalPoolSelector(@CurrentUser LoginAuthBean user, Long userId, @RequestParam(required = false) YearMonth monthly) { | |
84 | 83 | if (Objects.isNull(monthly)) { |
85 | 84 | monthly = YearMonth.now(); |
86 | 85 | } |
... | ... | @@ -100,7 +99,7 @@ public class EvalPoolController { |
100 | 99 | */ |
101 | 100 | @GetMapping("/own-detail") |
102 | 101 | @ControllerMethod("考评详情查询") |
103 | - public Message<EvalUserPoolVO> evalPoolOwnDetail(@CurrentUser Long userId, | |
102 | + public Message<List<EvalUserRankStageVO>> evalPoolOwnDetail(@CurrentUser Long userId, | |
104 | 103 | @RequestParam(required = false) YearMonth monthly) { |
105 | 104 | if (Objects.isNull(monthly)) { |
106 | 105 | monthly = YearMonth.now(); |
... | ... | @@ -118,7 +117,7 @@ public class EvalPoolController { |
118 | 117 | @GetMapping("/staff") |
119 | 118 | @ControllerMethod("考评详情查询") |
120 | 119 | public Message<EvalUserPoolVO> evalPoolDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId) { |
121 | - return success(evalGroupPoolService.queryPoolDetail(evalPoolId)); | |
120 | + return success(evalGroupPoolService.queryRankStagePools(evalPoolId)); | |
122 | 121 | } |
123 | 122 | |
124 | 123 | /** | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalGroupPoolService.java
... | ... | @@ -8,6 +8,7 @@ import cn.fw.morax.domain.db.eval.*; |
8 | 8 | import cn.fw.morax.domain.db.kpi.*; |
9 | 9 | import cn.fw.morax.domain.dto.eval.EvalGroupIndicatorRankDTO; |
10 | 10 | import cn.fw.morax.domain.enums.*; |
11 | +import cn.fw.morax.domain.vo.EvalSelectorVO; | |
11 | 12 | import cn.fw.morax.domain.vo.SelectorVO; |
12 | 13 | import cn.fw.morax.domain.vo.eval.*; |
13 | 14 | import cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO; |
... | ... | @@ -60,6 +61,8 @@ public class EvalGroupPoolService { |
60 | 61 | private final EvalIndicatorValueService evalIndicatorValueService; |
61 | 62 | private final EvalGroupUserService evalGroupUserService; |
62 | 63 | private final EvalGroupRewardService evalGroupRewardService; |
64 | + private final EvalGroupRankStageService evalGroupRankStageService; | |
65 | + private final EvalGroupRankService evalGroupRankService; | |
63 | 66 | private final EvalGroupService evalGroupService; |
64 | 67 | private final EvalUserPoolService evalUserPoolService; |
65 | 68 | private final EvalShopPoolService evalShopPoolService; |
... | ... | @@ -101,32 +104,51 @@ public class EvalGroupPoolService { |
101 | 104 | * |
102 | 105 | * @return |
103 | 106 | */ |
104 | - public EvalUserPoolVO queryPoolDetail(final Long poolId) { | |
107 | + public List<EvalUserRankStageVO> queryRankStagePools(final Long userId, final Long evalGroupRankId) { | |
108 | + | |
109 | + List<EvalUserPool> pools = evalUserPoolService.list(Wrappers.<EvalUserPool>lambdaQuery() | |
110 | + .eq(EvalUserPool::getUserId, userId) | |
111 | + .eq(EvalUserPool::getEvalGroupRankId, evalGroupRankId) | |
112 | + .eq(EvalUserPool::getYn, Boolean.TRUE) | |
113 | + .orderByDesc(EvalUserPool::getScoreRatio) | |
114 | + ); | |
115 | + pools.stream().map(EvalUserPool::getE) | |
116 | + | |
117 | + | |
118 | + List<EvalGroupRankStage> stages = evalGroupRankStageService.list(Wrappers.<EvalGroupRankStage>lambdaQuery() | |
119 | + .in(EvalGroupRankStage::getEvalGroupRankId, evalGroupRankId) | |
120 | + .eq(EvalGroupRankStage::getYn, Boolean.TRUE) | |
121 | + ); | |
122 | + | |
123 | + | |
124 | + | |
105 | 125 | EvalUserPool evalUserPool = evalUserPoolService.getById(poolId); |
106 | 126 | if (PublicUtil.isEmpty(evalUserPool)) { |
107 | -// throw new BusinessException("人员考评数据不存在"); | |
108 | 127 | return null; |
109 | 128 | } |
110 | 129 | return poolDetail(evalUserPool); |
111 | 130 | } |
112 | 131 | |
113 | - /** | |
114 | - * 查询考评详情 | |
115 | - * | |
116 | - * @param userId | |
117 | - * @param yearMonth | |
118 | - * @return | |
119 | - */ | |
120 | - public EvalUserPoolVO queryUserPoolDetail(final Long userId, final YearMonth yearMonth) { | |
121 | - List<EvalUserPool> pools = userEvalPool(userId, yearMonth); | |
122 | - | |
123 | - if (PublicUtil.isEmpty(pools)) { | |
124 | -// throw new BusinessException("人员考评数据不存在"); | |
125 | - return null; | |
126 | - } | |
127 | - EvalUserPool evalUserPool = pools.get(0); | |
128 | - return poolDetail(evalUserPool); | |
129 | - } | |
132 | +// /** | |
133 | +// * 查询考评详情 | |
134 | +// * | |
135 | +// * @param userId | |
136 | +// * @param yearMonth | |
137 | +// * @return | |
138 | +// */ | |
139 | +// public List<EvalUserGroupRankVO> queryUserPoolDetail(final Long userId, final YearMonth yearMonth) { | |
140 | +// List<EvalUserPool> pools = userEvalPool(userId, yearMonth); | |
141 | +// if (PublicUtil.isEmpty(pools)) { | |
142 | +// return new ArrayList<>(); | |
143 | +// } | |
144 | +// EvalUserPool userPool = pools.get(0); | |
145 | +// Long postId = userPool.getPostId(); | |
146 | +// Long shopId = userPool.getShopId(); | |
147 | +// | |
148 | +// pools.stream().filter() | |
149 | +// | |
150 | +// return poolDetail(evalUserPool); | |
151 | +// } | |
130 | 152 | |
131 | 153 | public EvalUserPoolVO poolDetail(EvalUserPool pool) { |
132 | 154 | EvalUserPoolVO evalUserPoolVO = PublicUtil.copy(pool, EvalUserPoolVO.class); |
... | ... | @@ -139,12 +161,6 @@ public class EvalGroupPoolService { |
139 | 161 | this.setIgnore(evalUserPoolVO); |
140 | 162 | evalUserPoolVO.setDataDate(localDate); |
141 | 163 | |
142 | -// Eval eval = evalService.getById(pool.getEvalId()); | |
143 | -// BV.notNull(pool, "考评池不存在"); | |
144 | -// if (PublicUtil.isNotEmpty(eval)) { | |
145 | -// evalUserPoolVO.setEvalType(eval.getType()); | |
146 | -// } | |
147 | - | |
148 | 164 | return evalUserPoolVO; |
149 | 165 | } |
150 | 166 | |
... | ... | @@ -256,14 +272,66 @@ public class EvalGroupPoolService { |
256 | 272 | * @param yearMonth |
257 | 273 | * @return |
258 | 274 | */ |
259 | - public Set<SelectorVO> evalPoolSelector(Long userId, YearMonth yearMonth) { | |
275 | + public List<EvalSelectorVO> evalPoolSelector(Long userId, YearMonth yearMonth) { | |
260 | 276 | List<EvalUserPool> pools = userEvalPool(userId, yearMonth); |
261 | 277 | if (CollectionUtils.isEmpty(pools)) { |
262 | - return new HashSet<>(); | |
278 | + return new ArrayList<>(); | |
279 | + } | |
280 | + List<EvalSelectorVO> selectors = new ArrayList<>(); | |
281 | + Map<Long, String> rankNameMap = this.getRankNameMap(pools); | |
282 | + Map<String, List<EvalUserPool>> shopPostMap = pools.stream().collect(Collectors.groupingBy(pool -> pool.getShopName() + "(" + pool.getPostName() + ")")); | |
283 | + //门店、岗位维度 | |
284 | + for (Map.Entry<String, List<EvalUserPool>> shopPostEntry : shopPostMap.entrySet()) { | |
285 | + | |
286 | + List<EvalUserGroupRankVO> ranks = new ArrayList<>(); | |
287 | + Map<Long, List<EvalUserPool>> rankPools = shopPostEntry.getValue().stream().collect(Collectors.groupingBy(EvalUserPool::getEvalGroupRankId)); | |
288 | + for (Map.Entry<Long, List<EvalUserPool>> rankEntry : rankPools.entrySet()) { | |
289 | + String rankName = rankNameMap.getOrDefault(rankEntry.getKey(), ""); | |
290 | + List<EvalUserPool> userRankPools = rankEntry.getValue(); | |
291 | + double averageKpiScoreRatio = userRankPools.stream() | |
292 | + .mapToDouble(r -> Optional.ofNullable(r.getScoreRatio()).orElse(BigDecimal.ZERO).doubleValue()) | |
293 | + .average() | |
294 | + .orElse(0); | |
295 | + BigDecimal reward = userRankPools.stream().map(EvalUserPool::getReward).reduce(BigDecimal.ZERO, BigDecimal::add); | |
296 | + EvalUserGroupRankVO rank = new EvalUserGroupRankVO(); | |
297 | + rank.setEvalGroupRankName(rankNameMap.getOrDefault(rankEntry.getKey(), "")); | |
298 | + rank.setScoreRatio(new BigDecimal(averageKpiScoreRatio).multiply(Constant.ONE_HUNDRED)); | |
299 | + rank.setReward(reward); | |
300 | + ranks.add(rank); | |
301 | + } | |
302 | + EvalSelectorVO evalSelectorVO = new EvalSelectorVO(shopPostEntry.getKey(), ranks); | |
303 | + selectors.add(evalSelectorVO); | |
304 | + } | |
305 | + return selectors; | |
306 | + } | |
307 | + | |
308 | + public Map<Long, String> getRankNameMap(List<EvalUserPool> pools) { | |
309 | + List<Long> evalGroupRankIds = pools.stream().map(EvalUserPool::getEvalGroupRankId).distinct().collect(Collectors.toList()); | |
310 | + List<EvalGroupRank> evalGroupRanks = evalGroupRankService.list(Wrappers.<EvalGroupRank>lambdaQuery() | |
311 | + .in(EvalGroupRank::getId, evalGroupRankIds) | |
312 | + .eq(EvalGroupRank::getYn, Boolean.TRUE) | |
313 | + ); | |
314 | + if (PublicUtil.isEmpty(evalGroupRanks)) { | |
315 | + return new HashMap<>(); | |
263 | 316 | } |
264 | - return pools.stream().map(r -> SelectorVO.whit(r.getId(), r.getPostName(), r.getShopName() + "")).collect(Collectors.toSet()); | |
317 | + return evalGroupRanks.stream().collect(Collectors.toMap(EvalGroupRank::getId, EvalGroupRank::getName, (v1, v2) -> v1)); | |
265 | 318 | } |
266 | 319 | |
320 | + /** | |
321 | + * 查询用户绩效池 | |
322 | + * | |
323 | + * @param userId | |
324 | + * @param yearMonth | |
325 | + * @return | |
326 | + */ | |
327 | +// public Set<SelectorVO> evalPoolSelector(Long userId, YearMonth yearMonth) { | |
328 | +// List<EvalUserPool> pools = userEvalPool(userId, yearMonth); | |
329 | +// if (CollectionUtils.isEmpty(pools)) { | |
330 | +// return new HashSet<>(); | |
331 | +// } | |
332 | +// return pools.stream().map(r -> SelectorVO.whit(r.getId(), r.getPostName(), r.getShopName() + "")).collect(Collectors.toSet()); | |
333 | +// } | |
334 | + | |
267 | 335 | |
268 | 336 | /** |
269 | 337 | * 查询用户月度绩效池列表 | ... | ... |