Commit e177885122a1e61dd5a2aed1920afc3c281d5a50
1 parent
bf4d326c
feature(*): 计算考评调整
计算考评调整
Showing
21 changed files
with
406 additions
and
86 deletions
fw-morax-dao/src/main/java/cn/fw/morax/dao/kpi/IndicatorUserValueDao.java
... | ... | @@ -32,7 +32,9 @@ public interface IndicatorUserValueDao extends BaseMapper<IndicatorUserValue> { |
32 | 32 | * @param userIds |
33 | 33 | * @return |
34 | 34 | */ |
35 | - List<IndicatorUserValueVO> getIndicatorReportData(@Param("indicatorCode") String indicatorCode, | |
36 | - @Param("monthly") YearMonth monthly, | |
37 | - @Param("userIds") Set<Long> userIds); | |
35 | + List<IndicatorUserValueVO> getReportData(@Param("indicatorCode") String indicatorCode, | |
36 | + @Param("monthly") YearMonth monthly, | |
37 | + @Param("userIds") Set<Long> userIds, | |
38 | + @Param("shopIds") Set<Long> shopIds); | |
39 | + | |
38 | 40 | } | ... | ... |
fw-morax-dao/src/main/resources/mapper/eval/EvalShopPoolDao.xml
fw-morax-dao/src/main/resources/mapper/eval/EvalUserPoolDao.xml
fw-morax-dao/src/main/resources/mapper/kpi/IndicatorUserValueMapper.xml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 | <mapper namespace="cn.fw.morax.dao.kpi.IndicatorUserValueDao"> |
4 | 4 | |
5 | - <select id="getIndicatorReportData" resultType="cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO"> | |
5 | + <select id="getReportData" resultType="cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO"> | |
6 | 6 | SELECT |
7 | 7 | t1.id, |
8 | 8 | t1.user_id, |
... | ... | @@ -21,10 +21,18 @@ |
21 | 21 | indicator_user_value |
22 | 22 | WHERE |
23 | 23 | DATE_FORMAT( data_date, '%Y-%m' ) = #{monthly} |
24 | - AND user_id IN | |
25 | - <foreach collection="userIds" item="userId" separator=" , " open="(" close=")"> | |
26 | - #{userId} | |
27 | - </foreach> | |
24 | + <if test="userIds != null and userIds.size > 0 "> | |
25 | + AND user_id IN | |
26 | + <foreach collection="userIds" item="userId" separator=" , " open="(" close=")"> | |
27 | + #{userId} | |
28 | + </foreach> | |
29 | + </if> | |
30 | + <if test="shopIds != null and shopIds.size > 0 "> | |
31 | + AND shop_id IN | |
32 | + <foreach collection="shopIds" item="shopId" separator=" , " open="(" close=")"> | |
33 | + #{shopId} | |
34 | + </foreach> | |
35 | + </if> | |
28 | 36 | AND indicator_code = #{indicatorCode} |
29 | 37 | AND yn = 1 |
30 | 38 | GROUP BY | ... | ... |
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/eval/EvalIndicatorImportDetail.java
... | ... | @@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode; |
10 | 10 | import lombok.experimental.Accessors; |
11 | 11 | |
12 | 12 | import java.io.Serializable; |
13 | +import java.math.BigDecimal; | |
13 | 14 | import java.time.LocalDate; |
14 | 15 | import java.time.LocalDateTime; |
15 | 16 | |
... | ... | @@ -72,7 +73,7 @@ public class EvalIndicatorImportDetail extends BaseAuditableTimeEntity<EvalIndic |
72 | 73 | /** |
73 | 74 | * 指标业务值 |
74 | 75 | */ |
75 | - private String indicatorValue; | |
76 | + private BigDecimal indicatorValue; | |
76 | 77 | |
77 | 78 | /** |
78 | 79 | * 类型:1: 百分比 2:数量 3:条件值 4:金额 | ... | ... |
fw-morax-domain/src/main/java/cn/fw/morax/domain/db/eval/EvalIndicatorValue.java
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/eval/EvalIndicatorRankShopVO.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.DataTypeEnum; | |
6 | +import lombok.Data; | |
7 | + | |
8 | +import java.math.BigDecimal; | |
9 | +import java.util.Optional; | |
10 | + | |
11 | +/** | |
12 | + * @author : kurisu | |
13 | + * @date : 2022-4-6 | |
14 | + * @desc : 绩效池 | |
15 | + */ | |
16 | +@Data | |
17 | +public class EvalIndicatorRankShopVO implements Comparable<EvalIndicatorRankShopVO>{ | |
18 | + /** | |
19 | + * 门店id | |
20 | + */ | |
21 | + private Long shopId; | |
22 | + /** | |
23 | + * 门店名称 | |
24 | + */ | |
25 | + private String shopName; | |
26 | + /** | |
27 | + * 指标排名序号 | |
28 | + */ | |
29 | + private Integer indicatorRank; | |
30 | + | |
31 | + /** | |
32 | + * 原始值 | |
33 | + */ | |
34 | + private BigDecimal originValue; | |
35 | + | |
36 | + /** | |
37 | + * 达成值 | |
38 | + */ | |
39 | + private BigDecimal reachValue; | |
40 | + | |
41 | + /** | |
42 | + * 转换为百分数展示 | |
43 | + */ | |
44 | + public void convertReportValueToPercent(DataTypeEnum dataType){ | |
45 | + if (PublicUtil.isNotEmpty(dataType) && DataTypeEnum.RATIO.equals(dataType)) { | |
46 | + this.setReachValue(this.getReachValue().multiply(Constant.ONE_HUNDRED)); | |
47 | + this.setOriginValue(this.getOriginValue().multiply(Constant.ONE_HUNDRED)); | |
48 | + } | |
49 | + } | |
50 | + | |
51 | + /** | |
52 | + * 转换为百分数展示 | |
53 | + */ | |
54 | + public void convertValueForTarget(DataTypeEnum dataType){ | |
55 | + if (PublicUtil.isNotEmpty(dataType) && DataTypeEnum.RATIO.equals(dataType)) { | |
56 | + this.setOriginValue(this.getOriginValue().multiply(Constant.ONE_HUNDRED)); | |
57 | + } | |
58 | + this.setReachValue(this.getReachValue().multiply(Constant.ONE_HUNDRED)); | |
59 | + } | |
60 | + | |
61 | + @Override | |
62 | + public int compareTo(EvalIndicatorRankShopVO other) { | |
63 | + return Optional.ofNullable(other.originValue).orElse(BigDecimal.ZERO) | |
64 | + .compareTo(Optional.ofNullable(this.originValue).orElse(BigDecimal.ZERO)); | |
65 | + } | |
66 | +} | |
0 | 67 | \ No newline at end of file | ... | ... |
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/kpi/IndicatorUserValueVO.java
1 | 1 | package cn.fw.morax.domain.vo.kpi; |
2 | 2 | |
3 | 3 | import cn.fw.common.data.entity.BaseAuditableTimeEntity; |
4 | +import cn.fw.morax.domain.enums.DimensionTypeEnum; | |
4 | 5 | import cn.fw.morax.domain.enums.IndicatorValueTypeEnum; |
5 | 6 | import lombok.Data; |
6 | 7 | import lombok.EqualsAndHashCode; |
... | ... | @@ -34,6 +35,11 @@ public class IndicatorUserValueVO { |
34 | 35 | * 指标名称 |
35 | 36 | */ |
36 | 37 | private String indicatorName; |
38 | + | |
39 | + /** | |
40 | + * 维度类型 1:人员 2:门店 | |
41 | + */ | |
42 | + private DimensionTypeEnum dimensionType; | |
37 | 43 | /** |
38 | 44 | * 类型;1: 百分比 2:数量 3:条件值 4:金额 5:工龄 |
39 | 45 | */ | ... | ... |
fw-morax-domain/src/main/java/cn/fw/morax/domain/vo/kpi/KpiIndicatorRankVO.java
1 | 1 | package cn.fw.morax.domain.vo.kpi; |
2 | 2 | |
3 | -import cn.fw.morax.domain.enums.DataTypeEnum; | |
4 | -import cn.fw.morax.domain.enums.StarLevelEnum; | |
5 | -import cn.fw.morax.domain.enums.TargetCalcTypeEnum; | |
6 | -import cn.fw.morax.domain.enums.TargetTypeEnum; | |
3 | +import cn.fw.morax.domain.enums.*; | |
4 | +import cn.fw.morax.domain.vo.eval.EvalIndicatorRankShopVO; | |
7 | 5 | import lombok.AllArgsConstructor; |
8 | 6 | import lombok.Builder; |
9 | 7 | import lombok.Data; |
... | ... | @@ -69,5 +67,10 @@ public class KpiIndicatorRankVO { |
69 | 67 | */ |
70 | 68 | private List<KpiIndicatorRankStaffVO> staffs; |
71 | 69 | |
70 | + /** | |
71 | + * 排名门店 | |
72 | + */ | |
73 | + private List<EvalIndicatorRankShopVO> shops; | |
74 | + | |
72 | 75 | |
73 | 76 | } |
74 | 77 | \ No newline at end of file | ... | ... |
fw-morax-server/src/main/java/cn/fw/morax/server/controller/app/EvalPoolController.java
... | ... | @@ -8,10 +8,9 @@ import cn.fw.common.web.auth.LoginAuthBean; |
8 | 8 | import cn.fw.common.web.auth.annotation.CurrentUser; |
9 | 9 | import cn.fw.data.base.domain.common.Message; |
10 | 10 | import cn.fw.morax.common.utils.PublicUtil; |
11 | -import cn.fw.morax.domain.dto.eval.EvalDTO; | |
12 | 11 | import cn.fw.morax.domain.dto.eval.EvalGroupIndicatorRankDTO; |
13 | -import cn.fw.morax.domain.dto.eval.EvalRewardDistDTO; | |
14 | 12 | import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO; |
13 | +import cn.fw.morax.domain.enums.EvalScopeEnum; | |
15 | 14 | import cn.fw.morax.domain.vo.SelectorVO; |
16 | 15 | import cn.fw.morax.domain.vo.eval.*; |
17 | 16 | import cn.fw.morax.domain.vo.kpi.KpiIndicatorRankVO; |
... | ... | @@ -167,19 +166,35 @@ public class EvalPoolController { |
167 | 166 | @GetMapping("/staff-indicator-rank") |
168 | 167 | @ControllerMethod("人员考评指标排名") |
169 | 168 | public Message<KpiIndicatorRankVO> queryKpiIndicatorRank(@Validated EvalGroupIndicatorRankDTO dto) { |
170 | - if (dto.getIsEvalGroupIndicator()) { | |
171 | - if (PublicUtil.isEmpty(dto.getEvalGroupIndicatorParamId()) && PublicUtil.isEmpty(dto.getEvalGroupIndicatorPreconditionId())) { | |
169 | + if (dto.getIsEvalGroupIndicator() && PublicUtil.isEmpty(dto.getEvalGroupIndicatorParamId()) && | |
170 | + PublicUtil.isEmpty(dto.getEvalGroupIndicatorPreconditionId())) { | |
172 | 171 | throw new BusinessException("参数错误"); |
173 | - } | |
174 | - } else { | |
175 | - if (PublicUtil.isEmpty(dto.getEvalGroupRewardParamId()) && PublicUtil.isEmpty(dto.getEvalGroupRewardPreconditionId())) { | |
172 | + } else if (PublicUtil.isEmpty(dto.getEvalGroupRewardParamId()) && PublicUtil.isEmpty(dto.getEvalGroupRewardPreconditionId())) { | |
176 | 173 | throw new BusinessException("参数错误"); |
177 | - } | |
178 | 174 | } |
179 | - return success(evalGroupPoolService.queryEvalIndicatorRank(dto)); | |
175 | + return success(evalGroupPoolService.queryIndicatorRank(dto, EvalScopeEnum.STAFF)); | |
180 | 176 | } |
181 | 177 | |
182 | 178 | /** |
179 | + * 门店考评指标排名 | |
180 | + * | |
181 | + * @param dto | |
182 | + * @return | |
183 | + */ | |
184 | + @GetMapping("/shop-indicator-rank") | |
185 | + @ControllerMethod("门店考评指标排名") | |
186 | + public Message<KpiIndicatorRankVO> queryShopIndicatorRank(@Validated EvalGroupIndicatorRankDTO dto) { | |
187 | + if (dto.getIsEvalGroupIndicator() && PublicUtil.isEmpty(dto.getEvalGroupIndicatorParamId()) && | |
188 | + PublicUtil.isEmpty(dto.getEvalGroupIndicatorPreconditionId())) { | |
189 | + throw new BusinessException("参数错误"); | |
190 | + } else if (PublicUtil.isEmpty(dto.getEvalGroupRewardParamId()) && PublicUtil.isEmpty(dto.getEvalGroupRewardPreconditionId())) { | |
191 | + throw new BusinessException("参数错误"); | |
192 | + } | |
193 | + return success(evalGroupPoolService.queryIndicatorRank(dto, EvalScopeEnum.SHOP)); | |
194 | + } | |
195 | + | |
196 | + | |
197 | + /** | |
183 | 198 | * 门店考评池列表 |
184 | 199 | * |
185 | 200 | * @param dto | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/calculator/eval/kpi/EvalKpiBaseCalculator.java
1 | 1 | package cn.fw.morax.service.biz.calculator.eval.kpi; |
2 | 2 | |
3 | +import cn.fw.morax.common.utils.PublicUtil; | |
3 | 4 | import cn.fw.morax.domain.bo.eval.EvalGroupUserShop; |
4 | 5 | import cn.fw.morax.domain.db.eval.*; |
5 | 6 | import cn.fw.morax.domain.db.kpi.*; |
... | ... | @@ -72,11 +73,11 @@ public abstract class EvalKpiBaseCalculator implements Calculator<EvalGroupUserS |
72 | 73 | for (int i = 0; i < preconditions.size(); i++) { |
73 | 74 | EvalGroupIndicatorPrecondition precondition = preconditions.get(i); |
74 | 75 | TargetTypeEnum targetType = precondition.getTargetType(); |
75 | - Optional<String> valueOptional = queryValue(obj, precondition.getCodeType(), precondition.getCode()); | |
76 | + Optional<BigDecimal> valueOptional = queryValue(obj, precondition.getCodeType(), precondition.getCode()); | |
76 | 77 | if (! valueOptional.isPresent()) { |
77 | 78 | return BigDecimal.ZERO; |
78 | 79 | } |
79 | - final BigDecimal originValue = queryIndicatorValue(precondition.getCode(), valueOptional.get()); | |
80 | + final BigDecimal originValue = valueOptional.get();//queryIndicatorValue(precondition.getCode(), valueOptional.get()); | |
80 | 81 | BigDecimal indicatorValue = originValue; |
81 | 82 | if (!TargetTypeEnum.NO.equals(targetType)) { |
82 | 83 | BigDecimal targetValue = precondition.getTargetValue(); |
... | ... | @@ -141,13 +142,13 @@ public abstract class EvalKpiBaseCalculator implements Calculator<EvalGroupUserS |
141 | 142 | return rate; |
142 | 143 | } |
143 | 144 | for (EvalGroupIndicatorParam param : params) { |
144 | - Optional<String> valueOptional = queryValue(userShop, param.getCodeType(), param.getCode()); | |
145 | + Optional<BigDecimal> valueOptional = queryValue(userShop, param.getCodeType(), param.getCode()); | |
145 | 146 | if (! valueOptional.isPresent()) { |
146 | 147 | log.info("[{}] [{}]指标[{}]值不存在", userShop.getScopeType().getName(), userShop.getReferId(), evalGroupIndicatorId); |
147 | 148 | continue; |
148 | 149 | } |
149 | 150 | TargetTypeEnum targetType = param.getTargetType(); |
150 | - final BigDecimal originValue = queryIndicatorValue(param.getCode(), valueOptional.get()); | |
151 | + final BigDecimal originValue = valueOptional.get(); | |
151 | 152 | BigDecimal indicatorValue = originValue; |
152 | 153 | if (!TargetTypeEnum.NO.equals(targetType)) { |
153 | 154 | BigDecimal targetValue = param.getTargetValue(); |
... | ... | @@ -185,7 +186,7 @@ public abstract class EvalKpiBaseCalculator implements Calculator<EvalGroupUserS |
185 | 186 | * @param indicatorCode |
186 | 187 | * @return |
187 | 188 | */ |
188 | - protected Optional<String> queryValue(EvalGroupUserShop obj, IndicatorCodeTypeEnum codeType, String indicatorCode) { | |
189 | + protected Optional<BigDecimal> queryValue(EvalGroupUserShop obj, IndicatorCodeTypeEnum codeType, String indicatorCode) { | |
189 | 190 | DimensionTypeEnum dimensionType = EvalScopeEnum.STAFF.equals(obj.getScopeType()) ? DimensionTypeEnum.STAFF : DimensionTypeEnum.SHOP; |
190 | 191 | if (IndicatorCodeTypeEnum.INDICATOR.equals(codeType)) { |
191 | 192 | LambdaQueryWrapper<IndicatorUserValue> queryWrapper = Wrappers.<IndicatorUserValue>lambdaQuery() |
... | ... | @@ -200,13 +201,11 @@ public abstract class EvalKpiBaseCalculator implements Calculator<EvalGroupUserS |
200 | 201 | queryWrapper.eq(IndicatorUserValue::getShopId, obj.getReferId()); |
201 | 202 | } |
202 | 203 | IndicatorUserValue indicatorUserValue = indicatorUserValueService.getOne(queryWrapper, Boolean.FALSE); |
203 | - return Optional.ofNullable(indicatorUserValue).map(IndicatorUserValue::getIndicatorValue); | |
204 | + return queryKpiIndicatorValue(indicatorUserValue); | |
204 | 205 | } |
205 | 206 | |
206 | - | |
207 | 207 | EvalIndicatorValue evalIndicatorValue = evalIndicatorValueService.queryLastValue(obj.getReferId(), |
208 | 208 | dimensionType, indicatorCode, obj.getDataDate()); |
209 | - | |
210 | 209 | return Optional.ofNullable(evalIndicatorValue).map(EvalIndicatorValue::getIndicatorValue); |
211 | 210 | } |
212 | 211 | |
... | ... | @@ -242,6 +241,26 @@ public abstract class EvalKpiBaseCalculator implements Calculator<EvalGroupUserS |
242 | 241 | /** |
243 | 242 | * 查询具体指标值 |
244 | 243 | * |
244 | + * @param indicatorUserValue | |
245 | + * @return | |
246 | + */ | |
247 | + protected Optional<BigDecimal> queryKpiIndicatorValue(IndicatorUserValue indicatorUserValue) { | |
248 | + if (PublicUtil.isEmpty(indicatorUserValue) || PublicUtil.isEmpty(indicatorUserValue.getIndicatorValue())) { | |
249 | + return Optional.empty(); | |
250 | + } | |
251 | + BigDecimal value = BigDecimal.ZERO; | |
252 | + try { | |
253 | + JSONObject jsonObject = JSONObject.parseObject(indicatorUserValue.getIndicatorValue()); | |
254 | + value = Optional.ofNullable(jsonObject.getBigDecimal(indicatorUserValue.getIndicatorCode())).orElse(BigDecimal.ZERO); | |
255 | + } catch (Exception e) { | |
256 | + log.error("[{}]指标值转化失败", indicatorUserValue, e); | |
257 | + } | |
258 | + return Optional.of(value); | |
259 | + } | |
260 | + | |
261 | + /** | |
262 | + * 查询具体指标值 | |
263 | + * | |
245 | 264 | * @param indicatorCode |
246 | 265 | * @param originalValue |
247 | 266 | * @return | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/calculator/eval/reward/EvalRewardBaseCalculator.java
... | ... | @@ -170,8 +170,7 @@ public abstract class EvalRewardBaseCalculator implements Calculator<EvalGroupUs |
170 | 170 | } |
171 | 171 | for (EvalGroupRewardPrecondition precondition : preconditions) { |
172 | 172 | String indicatorCode = precondition.getCode(); |
173 | - JSONObject jsonObject = queryValue(userShop, precondition.getCodeType(), indicatorCode); | |
174 | - final BigDecimal indicatorValue = Optional.ofNullable(jsonObject.getBigDecimal(indicatorCode)).orElse(BigDecimal.ZERO); | |
173 | + final BigDecimal indicatorValue = queryValue(userShop, precondition.getCodeType(), indicatorCode).orElse(BigDecimal.ZERO); | |
175 | 174 | BigDecimal userValue = indicatorValue; |
176 | 175 | TargetTypeEnum targetType = precondition.getTargetType(); |
177 | 176 | final BigDecimal condValue = precondition.getCondValue(); |
... | ... | @@ -234,10 +233,8 @@ public abstract class EvalRewardBaseCalculator implements Calculator<EvalGroupUs |
234 | 233 | * @param indicatorCode |
235 | 234 | * @return |
236 | 235 | */ |
237 | - protected JSONObject queryValue(EvalGroupUserShop obj, IndicatorCodeTypeEnum codeType, String indicatorCode) { | |
238 | - JSONObject jsonObject = new JSONObject(); | |
236 | + protected Optional<BigDecimal> queryValue(EvalGroupUserShop obj, IndicatorCodeTypeEnum codeType, String indicatorCode) { | |
239 | 237 | DimensionTypeEnum dimensionType = EvalScopeEnum.STAFF.equals(obj.getScopeType()) ? DimensionTypeEnum.STAFF : DimensionTypeEnum.SHOP; |
240 | - Optional<String> jsonValue = null; | |
241 | 238 | if (IndicatorCodeTypeEnum.INDICATOR.equals(codeType)) { |
242 | 239 | LambdaQueryWrapper<IndicatorUserValue> queryWrapper = Wrappers.<IndicatorUserValue>lambdaQuery() |
243 | 240 | .eq(IndicatorUserValue::getIndicatorCode, indicatorCode) |
... | ... | @@ -251,23 +248,32 @@ public abstract class EvalRewardBaseCalculator implements Calculator<EvalGroupUs |
251 | 248 | queryWrapper.eq(IndicatorUserValue::getShopId, obj.getReferId()); |
252 | 249 | } |
253 | 250 | IndicatorUserValue indicatorUserValue = indicatorUserValueService.getOne(queryWrapper, Boolean.FALSE); |
254 | - jsonValue = Optional.ofNullable(indicatorUserValue).map(IndicatorUserValue::getIndicatorValue); | |
251 | + return queryKpiIndicatorValue(indicatorUserValue); | |
255 | 252 | } else { |
256 | 253 | EvalIndicatorValue evalIndicatorValue = evalIndicatorValueService.queryLastValue(obj.getReferId(), |
257 | 254 | dimensionType, indicatorCode, obj.getDataDate()); |
258 | - jsonValue = Optional.ofNullable(evalIndicatorValue).map(EvalIndicatorValue::getIndicatorValue); | |
255 | + return Optional.ofNullable(evalIndicatorValue).map(EvalIndicatorValue::getIndicatorValue); | |
259 | 256 | } |
257 | + } | |
260 | 258 | |
261 | - if (! jsonValue.isPresent()) { | |
262 | - log.error("[{}]指标值为空", indicatorCode); | |
263 | - return jsonObject; | |
259 | + /** | |
260 | + * 查询具体指标值 | |
261 | + * | |
262 | + * @param indicatorUserValue | |
263 | + * @return | |
264 | + */ | |
265 | + protected Optional<BigDecimal> queryKpiIndicatorValue(IndicatorUserValue indicatorUserValue) { | |
266 | + if (PublicUtil.isEmpty(indicatorUserValue) || PublicUtil.isEmpty(indicatorUserValue.getIndicatorValue())) { | |
267 | + return Optional.empty(); | |
264 | 268 | } |
269 | + BigDecimal value = BigDecimal.ZERO; | |
265 | 270 | try { |
266 | - jsonObject = JSONObject.parseObject(jsonValue.get()); | |
271 | + JSONObject jsonObject = JSONObject.parseObject(indicatorUserValue.getIndicatorValue()); | |
272 | + value = Optional.ofNullable(jsonObject.getBigDecimal(indicatorUserValue.getIndicatorCode())).orElse(BigDecimal.ZERO); | |
267 | 273 | } catch (Exception e) { |
268 | - log.error("[{}]指标值转化失败", indicatorCode, e); | |
274 | + log.error("[{}]指标值转化失败", indicatorUserValue, e); | |
269 | 275 | } |
270 | - return jsonObject; | |
276 | + return Optional.of(value); | |
271 | 277 | } |
272 | 278 | |
273 | 279 | /** |
... | ... | @@ -360,8 +366,7 @@ public abstract class EvalRewardBaseCalculator implements Calculator<EvalGroupUs |
360 | 366 | BigDecimal proportion = param.getProportion(); |
361 | 367 | TargetTypeEnum targetType = param.getTargetType(); |
362 | 368 | ParamTypeEnum paramType = param.getParamType(); |
363 | - JSONObject jsonObject = queryValue(rewardObjectBO, param.getCodeType(), indicatorCode); | |
364 | - final BigDecimal userOriginValue = Optional.ofNullable(jsonObject.getBigDecimal(indicatorCode)).orElse(BigDecimal.ZERO); | |
369 | + final BigDecimal userOriginValue = queryValue(rewardObjectBO, param.getCodeType(), indicatorCode).orElse(BigDecimal.ZERO); | |
365 | 370 | BigDecimal _calcValue = userOriginValue; |
366 | 371 | if (!TargetTypeEnum.NO.equals(targetType)) { |
367 | 372 | _calcValue = calculateTargetValue(param.getTargetCalcType(), param.getTargetValue(), _calcValue); | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/calculator/eval/reward/EvalRewardLadderCalculator.java
... | ... | @@ -96,8 +96,7 @@ public class EvalRewardLadderCalculator extends EvalRewardBaseCalculator { |
96 | 96 | BigDecimal proportion = projectParam.getProportion(); |
97 | 97 | TargetTypeEnum targetType = projectParam.getTargetType(); |
98 | 98 | ParamTypeEnum paramType = projectParam.getParamType(); |
99 | - JSONObject jsonObject = queryValue(param, projectParam.getCodeType(), indicatorCode); | |
100 | - final BigDecimal userOriginValue = Optional.ofNullable(jsonObject.getBigDecimal(indicatorCode)).orElse(BigDecimal.ZERO); | |
99 | + final BigDecimal userOriginValue = queryValue(param, projectParam.getCodeType(), indicatorCode).orElse(BigDecimal.ZERO); | |
101 | 100 | BigDecimal _calcValue = userOriginValue; |
102 | 101 | if (!TargetTypeEnum.NO.equals(targetType)) { |
103 | 102 | _calcValue = calculateTargetValue(projectParam.getTargetCalcType(), projectParam.getTargetValue(), _calcValue); | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/calculator/eval/reward/EvalRewardLadderDoubleCalculator.java
... | ... | @@ -114,8 +114,7 @@ public class EvalRewardLadderDoubleCalculator extends EvalRewardBaseCalculator { |
114 | 114 | BigDecimal proportion = projectParam.getProportion(); |
115 | 115 | TargetTypeEnum targetType = projectParam.getTargetType(); |
116 | 116 | ParamTypeEnum paramType = projectParam.getParamType(); |
117 | - JSONObject jsonObject = queryValue(param, projectParam.getCodeType(), indicatorCode); | |
118 | - final BigDecimal userOriginValue = Optional.ofNullable(jsonObject.getBigDecimal(indicatorCode)).orElse(BigDecimal.ZERO); | |
117 | + final BigDecimal userOriginValue = queryValue(param, projectParam.getCodeType(), indicatorCode).orElse(BigDecimal.ZERO); | |
119 | 118 | BigDecimal _calcValue = userOriginValue; |
120 | 119 | if (!TargetTypeEnum.NO.equals(targetType)) { |
121 | 120 | _calcValue = calculateTargetValue(projectParam.getTargetCalcType(), projectParam.getTargetValue(), _calcValue); | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalGroupPoolService.java
... | ... | @@ -328,10 +328,6 @@ public class EvalGroupPoolService { |
328 | 328 | * @return |
329 | 329 | */ |
330 | 330 | public EvalPoolIndicatorDetailVO getHitIndicatorDetail(Long evalPoolId, EvalScopeEnum scopeType, Long referId, Long evalGroupIndicatorId, LocalDate dataDate) { |
331 | -// EvalUserPool pool = evalUserPoolService.getById(evalPoolId); | |
332 | -// Long userId = pool.getUserId(); | |
333 | -// EvalScopeEnum scopeType = EvalScopeEnum.STAFF; | |
334 | -// BV.notNull(pool, "考评池不存在"); | |
335 | 331 | EvalPoolIndicatorDetailVO indicatorDetail = evalPoolIndicatorDetailService.getStaffIndicatorValue(evalPoolId, scopeType, evalGroupIndicatorId, dataDate); |
336 | 332 | BV.notNull(indicatorDetail, "考评指标明细不存在"); |
337 | 333 | |
... | ... | @@ -743,14 +739,7 @@ public class EvalGroupPoolService { |
743 | 739 | * @param dto |
744 | 740 | * @return |
745 | 741 | */ |
746 | - public KpiIndicatorRankVO queryEvalIndicatorRank(EvalGroupIndicatorRankDTO dto) { | |
747 | - LocalDate dataDate = dto.getDataDate(); | |
748 | - List<EvalUserPool> pools = evalUserPoolService.list(Wrappers.<EvalUserPool>lambdaQuery() | |
749 | - .eq(EvalUserPool::getEvalGroupId, dto.getEvalGroupId()) | |
750 | - .eq(EvalUserPool::getMonthly, YearMonth.from(dataDate)) | |
751 | - .eq(EvalUserPool::getYn, Boolean.TRUE) | |
752 | - ); | |
753 | - | |
742 | + public KpiIndicatorRankVO queryIndicatorRank(EvalGroupIndicatorRankDTO dto, EvalScopeEnum scopeType) { | |
754 | 743 | Long referId = null; |
755 | 744 | String code = null; |
756 | 745 | String name = null; |
... | ... | @@ -802,7 +791,7 @@ public class EvalGroupPoolService { |
802 | 791 | } |
803 | 792 | } |
804 | 793 | |
805 | - KpiIndicatorRankVO kpiIndicatorRankVO = KpiIndicatorRankVO.builder() | |
794 | + KpiIndicatorRankVO result = KpiIndicatorRankVO.builder() | |
806 | 795 | .indicatorCode(code) |
807 | 796 | .indicatorName(name) |
808 | 797 | .dataType(dataType) |
... | ... | @@ -810,17 +799,68 @@ public class EvalGroupPoolService { |
810 | 799 | .deadlineDate(DateUtil.localDate2Date(dto.getDataDate())) |
811 | 800 | .build(); |
812 | 801 | |
802 | + if (EvalScopeEnum.STAFF.equals(scopeType)) { | |
803 | + return getStaffIndicatorRank(dto, result, referId, indicatorTypeEnum, codeType); | |
804 | + } | |
805 | + return getShopIndicatorRank(dto, result, referId, indicatorTypeEnum, codeType); | |
806 | + } | |
807 | + | |
808 | + public KpiIndicatorRankVO getStaffIndicatorRank(EvalGroupIndicatorRankDTO dto, | |
809 | + KpiIndicatorRankVO result, | |
810 | + Long referId, | |
811 | + IndicatorTypeEnum indicatorTypeEnum, | |
812 | + IndicatorCodeTypeEnum codeType) { | |
813 | + String code = result.getIndicatorCode(); | |
814 | + LocalDate dataDate = dto.getDataDate(); | |
815 | + TargetTypeEnum targetType = result.getTargetType(); | |
816 | + | |
817 | + List<EvalUserPool> pools = evalUserPoolService.list(Wrappers.<EvalUserPool>lambdaQuery() | |
818 | + .eq(EvalUserPool::getEvalGroupId, dto.getEvalGroupId()) | |
819 | + .eq(EvalUserPool::getMonthly, YearMonth.from(dataDate)) | |
820 | + .eq(EvalUserPool::getYn, Boolean.TRUE) | |
821 | + ); | |
813 | 822 | if (! TargetTypeEnum.NO.equals(targetType)) { |
814 | - return queryTargetIndicatorRank(kpiIndicatorRankVO, pools, dto.getDataDate(), referId, indicatorTypeEnum, dto.getIsEvalGroupIndicator()); | |
823 | + return queryTargetIndicatorRank(result, pools, dto.getDataDate(), referId, indicatorTypeEnum, dto.getIsEvalGroupIndicator()); | |
815 | 824 | } |
816 | 825 | |
817 | 826 | if (IndicatorCodeTypeEnum.INDICATOR.equals(codeType)) { |
818 | - kpiIndicatorRankVO.setStaffs(getNoTargetIndicatorRanks(code, dataDate, pools)); | |
819 | - return kpiIndicatorRankVO; | |
827 | + result.setStaffs(getNoTargetIndicatorRanks(code, dataDate, pools)); | |
828 | + return result; | |
820 | 829 | } |
821 | 830 | |
822 | - kpiIndicatorRankVO.setStaffs(getNoTargetEvalIndicatorRanks(code, dataDate, pools)); | |
823 | - return kpiIndicatorRankVO; | |
831 | + result.setStaffs(getNoTargetEvalIndicatorRanks(code, dataDate, pools)); | |
832 | + return result; | |
833 | + } | |
834 | + | |
835 | + public KpiIndicatorRankVO getShopIndicatorRank(EvalGroupIndicatorRankDTO dto, | |
836 | + KpiIndicatorRankVO result, | |
837 | + Long referId, | |
838 | + IndicatorTypeEnum indicatorTypeEnum, | |
839 | + IndicatorCodeTypeEnum codeType) { | |
840 | + String code = result.getIndicatorCode(); | |
841 | + LocalDate dataDate = dto.getDataDate(); | |
842 | + TargetTypeEnum targetType = result.getTargetType(); | |
843 | + | |
844 | + List<EvalShopPool> pools = evalShopPoolService.list(Wrappers.<EvalShopPool>lambdaQuery() | |
845 | + .eq(EvalShopPool::getEvalGroupId, dto.getEvalGroupId()) | |
846 | + .eq(EvalShopPool::getMonthly, YearMonth.from(dataDate)) | |
847 | + .eq(EvalShopPool::getYn, Boolean.TRUE) | |
848 | + ); | |
849 | + List<EvalIndicatorRankShopVO> shopVos = null; | |
850 | + if (! TargetTypeEnum.NO.equals(targetType)) { | |
851 | + shopVos = getShopTargetIndicatorRanks(referId, dataDate, pools, indicatorTypeEnum, result.getDataType()); | |
852 | + } else { | |
853 | + if (IndicatorCodeTypeEnum.INDICATOR.equals(codeType)) { | |
854 | + shopVos = getShopNoTargetIndicatorRanks(code, dataDate, pools); | |
855 | + } else { | |
856 | + shopVos = getShopNoTargetEvalIndicatorRanks(code, dataDate, pools); | |
857 | + } | |
858 | + } | |
859 | + | |
860 | + Collections.sort(shopVos); | |
861 | + calcShopRank(shopVos); | |
862 | + result.setShops(shopVos); | |
863 | + return result; | |
824 | 864 | } |
825 | 865 | |
826 | 866 | /** |
... | ... | @@ -833,7 +873,7 @@ public class EvalGroupPoolService { |
833 | 873 | */ |
834 | 874 | public List<KpiIndicatorRankStaffVO> getNoTargetIndicatorRanks(String indicatorCode, LocalDate localDate, List<EvalUserPool> pools) { |
835 | 875 | Set<Long> userIds = pools.stream().map(EvalUserPool::getUserId).collect(Collectors.toSet()); |
836 | - List<IndicatorUserValueVO> indicatorUserValues = indicatorUserValueService.getIndicatorReportData(indicatorCode, YearMonth.from(localDate), userIds); | |
876 | + List<IndicatorUserValueVO> indicatorUserValues = indicatorUserValueService.getStaffReportData(indicatorCode, YearMonth.from(localDate), userIds); | |
837 | 877 | |
838 | 878 | Map<Long, IndicatorUserValueVO> indicatorUserValueMap = indicatorUserValues.stream() |
839 | 879 | .collect(Collectors.toMap(IndicatorUserValueVO::getUserId, Function.identity(), (v1, v2) -> v1)); |
... | ... | @@ -869,11 +909,40 @@ public class EvalGroupPoolService { |
869 | 909 | * @param pools |
870 | 910 | * @return |
871 | 911 | */ |
912 | + public List<EvalIndicatorRankShopVO> getShopNoTargetIndicatorRanks(String indicatorCode, LocalDate localDate, List<EvalShopPool> pools) { | |
913 | + Set<Long> shopIds = pools.stream().map(EvalShopPool::getShopId).collect(Collectors.toSet()); | |
914 | + List<IndicatorUserValueVO> indicatorUserValues = indicatorUserValueService.getShopReportData(indicatorCode, YearMonth.from(localDate), shopIds); | |
915 | + | |
916 | + Map<Long, IndicatorUserValueVO> indicatorUserValueMap = indicatorUserValues.stream() | |
917 | + .collect(Collectors.toMap(IndicatorUserValueVO::getUserId, Function.identity(), (v1, v2) -> v1)); | |
918 | + | |
919 | + List<EvalIndicatorRankShopVO> staffRanks = Lists.newArrayListWithCapacity(indicatorUserValues.size()); | |
920 | + for (EvalShopPool pool : pools) { | |
921 | + EvalIndicatorRankShopVO rankShopVO = new EvalIndicatorRankShopVO(); | |
922 | + rankShopVO.setShopId(pool.getShopId()); | |
923 | + rankShopVO.setShopName(pool.getShopName()); | |
924 | + if (indicatorUserValueMap.containsKey(pool.getShopId())) { | |
925 | + IndicatorUserValueVO indicatorUserValueVO = indicatorUserValueMap.get(pool.getShopId()); | |
926 | + rankShopVO.setOriginValue(commonService.queryIndicatorValueVO(indicatorCode, indicatorUserValueVO)); | |
927 | + } | |
928 | + staffRanks.add(rankShopVO); | |
929 | + } | |
930 | + return staffRanks; | |
931 | + } | |
932 | + | |
933 | + /** | |
934 | + * 无目标指标排名 | |
935 | + * | |
936 | + * @param indicatorCode | |
937 | + * @param localDate | |
938 | + * @param pools | |
939 | + * @return | |
940 | + */ | |
872 | 941 | public List<KpiIndicatorRankStaffVO> getNoTargetEvalIndicatorRanks(String indicatorCode, LocalDate localDate, List<EvalUserPool> pools) { |
873 | 942 | Set<Long> userIds = pools.stream().map(EvalUserPool::getUserId).collect(Collectors.toSet()); |
874 | 943 | |
875 | 944 | YearMonth lastMonth = YearMonth.from(localDate).minusMonths(1); |
876 | - List<EvalIndicatorValue> indicatorUserValues = evalIndicatorValueService.getIndicatorReportData(indicatorCode, lastMonth, userIds); | |
945 | + List<EvalIndicatorValue> indicatorUserValues = evalIndicatorValueService.getStaffReportData(indicatorCode, lastMonth, userIds); | |
877 | 946 | |
878 | 947 | Map<Long, EvalIndicatorValue> indicatorUserValueMap = indicatorUserValues.stream() |
879 | 948 | .collect(Collectors.toMap(EvalIndicatorValue::getUserId, Function.identity(), (v1, v2) -> v1)); |
... | ... | @@ -902,6 +971,37 @@ public class EvalGroupPoolService { |
902 | 971 | return staffRanks; |
903 | 972 | } |
904 | 973 | |
974 | + /** | |
975 | + * 无目标指标排名 | |
976 | + * | |
977 | + * @param indicatorCode | |
978 | + * @param localDate | |
979 | + * @param pools | |
980 | + * @return | |
981 | + */ | |
982 | + public List<EvalIndicatorRankShopVO> getShopNoTargetEvalIndicatorRanks(String indicatorCode, LocalDate localDate, List<EvalShopPool> pools) { | |
983 | + Set<Long> shopIds = pools.stream().map(EvalShopPool::getShopId).collect(Collectors.toSet()); | |
984 | + | |
985 | + YearMonth lastMonth = YearMonth.from(localDate).minusMonths(1); | |
986 | + List<EvalIndicatorValue> indicatorUserValues = evalIndicatorValueService.getShopReportData(indicatorCode, lastMonth, shopIds); | |
987 | + | |
988 | + Map<Long, EvalIndicatorValue> indicatorUserValueMap = indicatorUserValues.stream() | |
989 | + .collect(Collectors.toMap(EvalIndicatorValue::getUserId, Function.identity(), (v1, v2) -> v1)); | |
990 | + | |
991 | + List<EvalIndicatorRankShopVO> staffRanks = Lists.newArrayListWithCapacity(indicatorUserValues.size()); | |
992 | + for (EvalShopPool pool : pools) { | |
993 | + EvalIndicatorRankShopVO shopVO = new EvalIndicatorRankShopVO(); | |
994 | + shopVO.setShopId(pool.getShopId()); | |
995 | + shopVO.setShopName(pool.getShopName()); | |
996 | + if (indicatorUserValueMap.containsKey(pool.getShopId())) { | |
997 | + EvalIndicatorValue indicatorUserValueVO = indicatorUserValueMap.get(pool.getShopId()); | |
998 | + shopVO.setOriginValue(commonService.queryEvalIndicatorValueVO(indicatorCode, indicatorUserValueVO)); | |
999 | + } | |
1000 | + staffRanks.add(shopVO); | |
1001 | + } | |
1002 | + return staffRanks; | |
1003 | + } | |
1004 | + | |
905 | 1005 | public KpiIndicatorRankVO queryTargetIndicatorRank(KpiIndicatorRankVO kpiIndicatorRankVO, |
906 | 1006 | List<EvalUserPool> pools, |
907 | 1007 | LocalDate dataDate, |
... | ... | @@ -917,7 +1017,6 @@ public class EvalGroupPoolService { |
917 | 1017 | |
918 | 1018 | Collections.sort(staffs); |
919 | 1019 | calcRank(staffs); |
920 | - | |
921 | 1020 | kpiIndicatorRankVO.setStaffs(staffs); |
922 | 1021 | return kpiIndicatorRankVO; |
923 | 1022 | } |
... | ... | @@ -978,6 +1077,43 @@ public class EvalGroupPoolService { |
978 | 1077 | * @param indicatorTypeEnum |
979 | 1078 | * @return |
980 | 1079 | */ |
1080 | + public List<EvalIndicatorRankShopVO> getShopTargetIndicatorRanks(Long referId, | |
1081 | + LocalDate localDate, | |
1082 | + List<EvalShopPool> pools, | |
1083 | + IndicatorTypeEnum indicatorTypeEnum, | |
1084 | + DataTypeEnum dataType) { | |
1085 | + Set<Long> poolIds = pools.stream().map(EvalShopPool::getId).collect(Collectors.toSet()); | |
1086 | + List<EvalGroupIndicatorTargetHitLogVO> indicatorTargetHitLogs = evalGroupIndicatorTargetHitLogService.getIndicatorData(referId, | |
1087 | + YearMonth.from(localDate), indicatorTypeEnum, poolIds, EvalScopeEnum.SHOP); | |
1088 | + | |
1089 | + Map<Long, EvalGroupIndicatorTargetHitLogVO> indicatorTargetMap = indicatorTargetHitLogs.stream() | |
1090 | + .collect(Collectors.toMap(EvalGroupIndicatorTargetHitLogVO::getPoolId, Function.identity(), (v1, v2) -> v1)); | |
1091 | + | |
1092 | + List<EvalIndicatorRankShopVO> shopRanks = Lists.newArrayListWithCapacity(indicatorTargetMap.size()); | |
1093 | + for (EvalShopPool shopPool : pools) { | |
1094 | + EvalIndicatorRankShopVO shopVO = new EvalIndicatorRankShopVO(); | |
1095 | + shopVO.setShopId(shopPool.getShopId()); | |
1096 | + shopVO.setShopName(shopPool.getShopName()); | |
1097 | + if (indicatorTargetMap.containsKey(shopPool.getId())) { | |
1098 | + EvalGroupIndicatorTargetHitLogVO targetHitLogVO = indicatorTargetMap.get(shopPool.getId()); | |
1099 | + shopVO.setOriginValue(targetHitLogVO.getValue()); | |
1100 | + shopVO.setReachValue(targetHitLogVO.getReachValue()); | |
1101 | + shopVO.convertValueForTarget(dataType); | |
1102 | + } | |
1103 | + shopRanks.add(shopVO); | |
1104 | + } | |
1105 | + return shopRanks; | |
1106 | + } | |
1107 | + | |
1108 | + /** | |
1109 | + * 有目标指标排名 | |
1110 | + * | |
1111 | + * @param referId | |
1112 | + * @param localDate | |
1113 | + * @param pools | |
1114 | + * @param indicatorTypeEnum | |
1115 | + * @return | |
1116 | + */ | |
981 | 1117 | public List<KpiIndicatorRankStaffVO> getTargetRewardRanks(Long referId, |
982 | 1118 | LocalDate localDate, |
983 | 1119 | List<EvalUserPool> pools, |
... | ... | @@ -1041,4 +1177,26 @@ public class EvalGroupPoolService { |
1041 | 1177 | } |
1042 | 1178 | } |
1043 | 1179 | |
1180 | + /** | |
1181 | + * 设置排名序号 | |
1182 | + * | |
1183 | + * @return | |
1184 | + */ | |
1185 | + public void calcShopRank(List<EvalIndicatorRankShopVO> shops) { | |
1186 | + int rank = 1; | |
1187 | + BigDecimal lastIndicatorValue = null; | |
1188 | + for (EvalIndicatorRankShopVO shop : shops) { | |
1189 | + if (PublicUtil.isEmpty(lastIndicatorValue) || PublicUtil.isEmpty(shop.getOriginValue()) ) { | |
1190 | + shop.setIndicatorRank(rank); | |
1191 | + lastIndicatorValue = shop.getOriginValue(); | |
1192 | + continue; | |
1193 | + } | |
1194 | + if (lastIndicatorValue.compareTo(shop.getOriginValue()) != 0) { | |
1195 | + rank++; | |
1196 | + } | |
1197 | + shop.setIndicatorRank(rank); | |
1198 | + lastIndicatorValue = shop.getOriginValue(); | |
1199 | + } | |
1200 | + } | |
1201 | + | |
1044 | 1202 | } | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalIndicatorReportService.java
... | ... | @@ -33,11 +33,14 @@ import org.springframework.web.multipart.MultipartFile; |
33 | 33 | import javax.servlet.http.HttpServletRequest; |
34 | 34 | import javax.servlet.http.HttpServletResponse; |
35 | 35 | import java.io.IOException; |
36 | +import java.math.BigDecimal; | |
36 | 37 | import java.time.LocalDate; |
37 | 38 | import java.time.YearMonth; |
39 | +import java.time.format.DateTimeFormatter; | |
38 | 40 | import java.util.ArrayList; |
39 | 41 | import java.util.List; |
40 | 42 | import java.util.Map; |
43 | +import java.util.Optional; | |
41 | 44 | import java.util.function.Function; |
42 | 45 | import java.util.stream.Collectors; |
43 | 46 | |
... | ... | @@ -123,9 +126,7 @@ public class EvalIndicatorReportService { |
123 | 126 | @Transactional(rollbackFor = Exception.class) |
124 | 127 | public List<StaffIndicatorValueVO> uploadStaffIndicator(MultipartFile file, LoginAuthBean user) { |
125 | 128 | MultiKeyMap<String, EvalUserPool> staffPostMap = getShopUserPoolMap(user); |
126 | - | |
127 | 129 | Map<String, EvalIndicator> evalIndicatorMap = getNameIndicatorMap(); |
128 | - | |
129 | 130 | EvalIndicatorImportRecord importRecord = createRecord(user); |
130 | 131 | evalIndicatorImportRecordService.save(importRecord); |
131 | 132 | |
... | ... | @@ -143,9 +144,16 @@ public class EvalIndicatorReportService { |
143 | 144 | Map<String, String> headerAlias = ExcelDataUtil.getTitleMappingField(StaffIndicatorValueVO.class); |
144 | 145 | reader.setHeaderAlias(headerAlias); |
145 | 146 | indicatorValues = reader.readAll(StaffIndicatorValueVO.class); |
147 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd"); | |
146 | 148 | for (StaffIndicatorValueVO staff : indicatorValues) { |
149 | + | |
147 | 150 | EvalIndicatorImportDetail importDetail = new EvalIndicatorImportDetail(); |
148 | - importDetail.setDataDate(LocalDate.parse(staff.getDataDate())); | |
151 | + try { | |
152 | + importDetail.setDataDate(LocalDate.parse(staff.getDataDate(), formatter)); | |
153 | + } catch (Exception e) { | |
154 | + log.error("考评数据导入,日期转换失败,{},{}", staff.getDataDate(), e); | |
155 | + importDetail.setDataDate(LocalDate.now()); | |
156 | + } | |
149 | 157 | if (staffPostMap.containsKey(staff.getShopName(), staff.getStaffName())) { |
150 | 158 | EvalUserPool userPool = staffPostMap.get(staff.getShopName(), staff.getStaffName()); |
151 | 159 | importDetail.setUserId(userPool.getUserId()); |
... | ... | @@ -161,7 +169,7 @@ public class EvalIndicatorReportService { |
161 | 169 | EvalIndicator evalIndicator = evalIndicatorMap.get(staff.getIndicatorName()); |
162 | 170 | importDetail.setIndicatorCode(evalIndicator.getCode()); |
163 | 171 | importDetail.setIndicatorName(evalIndicator.getName()); |
164 | - importDetail.setIndicatorValue(staff.getIndicatorValue()); | |
172 | + importDetail.setIndicatorValue(new BigDecimal(staff.getIndicatorValue())); | |
165 | 173 | } else { |
166 | 174 | importDetail.setErrorType(ImportErrorReasonEnum.NO_MATCH_INDICATOR); |
167 | 175 | errorNum += 1; |
... | ... | @@ -172,6 +180,9 @@ public class EvalIndicatorReportService { |
172 | 180 | |
173 | 181 | } |
174 | 182 | |
183 | + Optional<EvalIndicatorImportDetail> detailOptional = details.stream().findFirst(); | |
184 | + importRecord.setIndicatorCode(detailOptional.map(EvalIndicatorImportDetail::getIndicatorCode).orElse("")); | |
185 | + importRecord.setIndicatorName(detailOptional.map(EvalIndicatorImportDetail::getIndicatorName).orElse("")); | |
175 | 186 | importRecord.setErrorNum(errorNum); |
176 | 187 | importRecord.setNum(indicatorValues.size()); |
177 | 188 | importRecord.setSuccessNum(indicatorValues.size() - errorNum); |
... | ... | @@ -225,7 +236,7 @@ public class EvalIndicatorReportService { |
225 | 236 | EvalIndicator evalIndicator = evalIndicatorMap.get(shop.getIndicatorName()); |
226 | 237 | importDetail.setIndicatorCode(evalIndicator.getCode()); |
227 | 238 | importDetail.setIndicatorName(evalIndicator.getName()); |
228 | - importDetail.setIndicatorValue(shop.getIndicatorValue()); | |
239 | + importDetail.setIndicatorValue(new BigDecimal(shop.getIndicatorValue())); | |
229 | 240 | } else { |
230 | 241 | importDetail.setErrorType(ImportErrorReasonEnum.NO_MATCH_INDICATOR); |
231 | 242 | errorNum += 1; | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/kpi/KpiGroupIndicatorBizService.java
... | ... | @@ -396,7 +396,7 @@ public class KpiGroupIndicatorBizService { |
396 | 396 | */ |
397 | 397 | public List<KpiIndicatorRankStaffVO> getNoTargetIndicatorRanks(String indicatorCode, LocalDate localDate, List<KpiPool> pools) { |
398 | 398 | Set<Long> userIds = pools.stream().map(KpiPool::getUserId).collect(Collectors.toSet()); |
399 | - List<IndicatorUserValueVO> indicatorUserValues = indicatorUserValueService.getIndicatorReportData(indicatorCode, YearMonth.from(localDate), userIds); | |
399 | + List<IndicatorUserValueVO> indicatorUserValues = indicatorUserValueService.getStaffReportData(indicatorCode, YearMonth.from(localDate), userIds); | |
400 | 400 | |
401 | 401 | Map<Long, IndicatorUserValueVO> indicatorUserValueMap = indicatorUserValues.stream() |
402 | 402 | .collect(Collectors.toMap(IndicatorUserValueVO::getUserId, Function.identity(), (v1, v2) -> v1)); | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/EvalIndicatorValueService.java
... | ... | @@ -41,6 +41,16 @@ public interface EvalIndicatorValueService extends IService<EvalIndicatorValue> |
41 | 41 | * @param userIds |
42 | 42 | * @return |
43 | 43 | */ |
44 | - List<EvalIndicatorValue> getIndicatorReportData(String code, YearMonth monthly, Set<Long> userIds); | |
44 | + List<EvalIndicatorValue> getStaffReportData(String code, YearMonth monthly, Set<Long> userIds); | |
45 | + | |
46 | + /** | |
47 | + * 获取指标原始上报记录 | |
48 | + * | |
49 | + * @param code | |
50 | + * @param monthly | |
51 | + * @param shopIds | |
52 | + * @return | |
53 | + */ | |
54 | + List<EvalIndicatorValue> getShopReportData(String code, YearMonth monthly, Set<Long> shopIds); | |
45 | 55 | |
46 | 56 | } | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/data/eval/impl/EvalIndicatorValueServiceImpl.java
... | ... | @@ -34,7 +34,12 @@ public class EvalIndicatorValueServiceImpl extends ServiceImpl<EvalIndicatorValu |
34 | 34 | } |
35 | 35 | |
36 | 36 | @Override |
37 | - public List<EvalIndicatorValue> getIndicatorReportData(String code, YearMonth monthly, Set<Long> userIds) { | |
37 | + public List<EvalIndicatorValue> getStaffReportData(String code, YearMonth monthly, Set<Long> userIds) { | |
38 | 38 | return this.baseMapper.getIndicatorReportData(code, monthly,userIds, DimensionTypeEnum.STAFF.getValue()); |
39 | 39 | } |
40 | + | |
41 | + @Override | |
42 | + public List<EvalIndicatorValue> getShopReportData(String code, YearMonth monthly, Set<Long> shopIds) { | |
43 | + return this.baseMapper.getIndicatorReportData(code, monthly,shopIds, DimensionTypeEnum.SHOP.getValue()); | |
44 | + } | |
40 | 45 | } | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/data/kpi/IndicatorUserValueService.java
... | ... | @@ -29,5 +29,15 @@ public interface IndicatorUserValueService extends IService<IndicatorUserValue> |
29 | 29 | * @param userIds |
30 | 30 | * @return |
31 | 31 | */ |
32 | - List<IndicatorUserValueVO> getIndicatorReportData(String indicatorCode, YearMonth monthly, Set<Long> userIds); | |
32 | + List<IndicatorUserValueVO> getStaffReportData(String indicatorCode, YearMonth monthly, Set<Long> userIds); | |
33 | + | |
34 | + /** | |
35 | + * 获取指标原始上报记录 | |
36 | + * | |
37 | + * @param indicatorCode | |
38 | + * @param monthly | |
39 | + * @param shopIds | |
40 | + * @return | |
41 | + */ | |
42 | + List<IndicatorUserValueVO> getShopReportData(String indicatorCode, YearMonth monthly, Set<Long> shopIds); | |
33 | 43 | } | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/data/kpi/impl/IndicatorUserValueServiceImpl.java
... | ... | @@ -3,13 +3,11 @@ package cn.fw.morax.service.data.kpi.impl; |
3 | 3 | import cn.fw.morax.dao.kpi.IndicatorUserValueDao; |
4 | 4 | import cn.fw.morax.domain.db.kpi.IndicatorUserValue; |
5 | 5 | import cn.fw.morax.domain.vo.kpi.IndicatorUserValueVO; |
6 | -import cn.fw.morax.domain.vo.kpi.KpiIndicatorRankStaffVO; | |
7 | 6 | import cn.fw.morax.service.data.kpi.IndicatorUserValueService; |
8 | 7 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
9 | 8 | import lombok.extern.slf4j.Slf4j; |
10 | 9 | import org.springframework.stereotype.Service; |
11 | 10 | |
12 | -import java.time.LocalDate; | |
13 | 11 | import java.time.YearMonth; |
14 | 12 | import java.util.List; |
15 | 13 | import java.util.Set; |
... | ... | @@ -28,7 +26,12 @@ import java.util.Set; |
28 | 26 | public class IndicatorUserValueServiceImpl extends ServiceImpl<IndicatorUserValueDao, IndicatorUserValue> implements IndicatorUserValueService { |
29 | 27 | |
30 | 28 | @Override |
31 | - public List<IndicatorUserValueVO> getIndicatorReportData(String indicatorCode, YearMonth monthly, Set<Long> userIds) { | |
32 | - return this.baseMapper.getIndicatorReportData(indicatorCode, monthly, userIds); | |
29 | + public List<IndicatorUserValueVO> getStaffReportData(String indicatorCode, YearMonth monthly, Set<Long> userIds) { | |
30 | + return this.baseMapper.getReportData(indicatorCode, monthly, userIds, null); | |
31 | + } | |
32 | + | |
33 | + @Override | |
34 | + public List<IndicatorUserValueVO> getShopReportData(String indicatorCode, YearMonth monthly, Set<Long> shopIds) { | |
35 | + return this.baseMapper.getReportData(indicatorCode, monthly, null, shopIds); | |
33 | 36 | } |
34 | 37 | } | ... | ... |