Blame view

fw-morax-service/src/main/java/cn/fw/morax/service/biz/kpi/KpiPoolBizService.java 45.2 KB
5bca06a2   姜超   feature(*): 绩效池接口
1
2
  package cn.fw.morax.service.biz.kpi;
  
92652a3f   张志伟   feature(KpiPoolBi...
3
  import cn.fw.common.exception.BusinessException;
46276518   张志伟   feature(*): 完善deb...
4
  import cn.fw.common.web.annotation.DisLock;
a8289dd2   姜超   feature(*): 绩效详情接口修改
5
  import cn.fw.morax.common.constant.Constant;
92652a3f   张志伟   feature(KpiPoolBi...
6
7
  import cn.fw.morax.common.utils.DateUtil;
  import cn.fw.morax.common.utils.MessageFormatUtil;
da234187   姜超   feature(*): 绩效、薪酬...
8
  import cn.fw.morax.common.utils.PublicUtil;
23568a66   张志伟   feature(*): 绩效计算
9
  import cn.fw.morax.common.utils.StringUtils;
e45e50c3   张志伟   feature(*): 计算用户绩...
10
  import cn.fw.morax.domain.bo.kpi.KpiGroupCalculableBO;
864042ba   姜超   feature(*): 通过绩效组...
11
  import cn.fw.morax.domain.bo.kpi.KpiGroupCalculableRankBO;
6d89f27c   姜超   feature(*): 计算排名修改
12
  import cn.fw.morax.domain.bo.kpi.KpiRankCalculableBO;
864042ba   姜超   feature(*): 通过绩效组...
13
  import cn.fw.morax.domain.bo.kpi.KpiStarLadderBO;
da234187   姜超   feature(*): 绩效、薪酬...
14
  import cn.fw.morax.domain.db.kpi.*;
f143d42f   xianpengcheng   修改字段统一
15
  import cn.fw.morax.domain.dto.kpi.KpiGroupRankConfigQueryDTO;
f11b16d6   姜超   feature(*): 绩效排名组...
16
  import cn.fw.morax.domain.enums.*;
71dbfe97   姜超   feature(*): 绩效详情返...
17
  import cn.fw.morax.domain.vo.kpi.*;
4abb00e4   张志伟   feature(*): 计算用户人员星级
18
  import cn.fw.morax.service.data.kpi.*;
459e4fde   姜超   fix(kpipool、salar...
19
  import com.alibaba.fastjson.JSON;
e45e50c3   张志伟   feature(*): 计算用户绩...
20
  import com.alibaba.fastjson.JSONObject;
23568a66   张志伟   feature(*): 绩效计算
21
  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
e45e50c3   张志伟   feature(*): 计算用户绩...
22
  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
23568a66   张志伟   feature(*): 绩效计算
23
  import lombok.Getter;
5bca06a2   姜超   feature(*): 绩效池接口
24
25
  import lombok.RequiredArgsConstructor;
  import lombok.extern.slf4j.Slf4j;
23568a66   张志伟   feature(*): 绩效计算
26
  import org.springframework.beans.factory.annotation.Value;
da234187   姜超   feature(*): 绩效、薪酬...
27
  import org.springframework.cache.annotation.Cacheable;
92652a3f   张志伟   feature(KpiPoolBi...
28
  import org.springframework.data.redis.core.BoundZSetOperations;
23568a66   张志伟   feature(*): 绩效计算
29
30
  import org.springframework.data.redis.core.ListOperations;
  import org.springframework.data.redis.core.StringRedisTemplate;
92652a3f   张志伟   feature(KpiPoolBi...
31
  import org.springframework.lang.NonNull;
5bca06a2   姜超   feature(*): 绩效池接口
32
  import org.springframework.stereotype.Service;
e45e50c3   张志伟   feature(*): 计算用户绩...
33
  import org.springframework.transaction.annotation.Transactional;
5bca06a2   姜超   feature(*): 绩效池接口
34
  
e45e50c3   张志伟   feature(*): 计算用户绩...
35
36
  import java.math.BigDecimal;
  import java.math.RoundingMode;
73a0ce39   姜超   feature(kpipool):...
37
  import java.text.DecimalFormat;
e45e50c3   张志伟   feature(*): 计算用户绩...
38
39
  import java.time.LocalDate;
  import java.time.YearMonth;
92652a3f   张志伟   feature(KpiPoolBi...
40
  import java.util.*;
da234187   姜超   feature(*): 绩效、薪酬...
41
  import java.util.stream.Collectors;
23568a66   张志伟   feature(*): 绩效计算
42
  
4abb00e4   张志伟   feature(*): 计算用户人员星级
43
  import static cn.fw.common.businessvalidator.Validator.BV;
7652457e   张志伟   feature(*): 手动计算绩...
44
  import static cn.fw.morax.common.utils.MessageFormatUtil.MessageFormatTransfer;
4abb00e4   张志伟   feature(*): 计算用户人员星级
45
46
47
48
49
50
  
  /**
   * 绩效池业务处理服务
   *
   * @author kurisu
   */
5bca06a2   姜超   feature(*): 绩效池接口
51
52
53
54
55
  @RequiredArgsConstructor
  @Service
  @Slf4j
  public class KpiPoolBizService {
  
5bca06a2   姜超   feature(*): 绩效池接口
56
      private final KpiPoolService kpiPoolService;
4abb00e4   张志伟   feature(*): 计算用户人员星级
57
      private final KpiGroupService kpiGroupService;
4abb00e4   张志伟   feature(*): 计算用户人员星级
58
      private final KpiStarRuleService kpiStarRuleService;
864042ba   姜超   feature(*): 通过绩效组...
59
60
      private final KpiGroupRankService kpiGroupRankService;
      private final StringRedisTemplate stringRedisTemplate;
459e4fde   姜超   fix(kpipool、salar...
61
      private final KpiGroupUserService kpiGroupUserService;
58aa0677   姜超   feature(*): 绩效得分详情修改
62
      private final KpiRewardPointService kpiRewardPointService;
864042ba   姜超   feature(*): 通过绩效组...
63
64
      private final KpiStarLaddersService kpiStarLaddersService;
      private final KpiGroupIndicatorService kpiGroupIndicatorService;
0b67bdb4   张志伟   feature(*): 完成绩效分计算
65
      private final KpiGroupIndicatorHitLogService kpiGroupIndicatorHitLogService;
864042ba   姜超   feature(*): 通过绩效组...
66
67
      private final KpiPoolIndicatorValueService kpiPoolIndicatorValueService;
      private final KpiGroupRankStarLaddersService kpiGroupRankStarLaddersService;
da234187   姜超   feature(*): 绩效、薪酬...
68
      private final KpiGroupIndicatorLaddersService kpiGroupIndicatorLaddersService;
71dbfe97   姜超   feature(*): 绩效详情返...
69
      private final KpiAssessPenaltyStaffService kpiAssessPenaltyStaffService;
3e4ca434   姜超   feature(*): 人员质量评...
70
      private final KpiAssessPenaltyService kpiAssessPenaltyService;
e83f6066   xianpengcheng   绩效报表-排名处理
71
      private final ReportKpiRankService reportKpiRankService;
5bca06a2   姜超   feature(*): 绩效池接口
72
  
23568a66   张志伟   feature(*): 绩效计算
73
74
75
76
      @Value("${spring.cache.custom.global-prefix}:calculate-scoring-rate:kpi-group")
      @Getter
      private String calcuScoringRateKey;
  
e45e50c3   张志伟   feature(*): 计算用户绩...
77
78
79
      @Value("${spring.cache.custom.global-prefix}:calculate-star-level:kpi-group")
      @Getter
      private String calcuStarKey;
23568a66   张志伟   feature(*): 绩效计算
80
  
92652a3f   张志伟   feature(KpiPoolBi...
81
82
83
84
      @Value("${spring.cache.custom.global-prefix}:scoring-rate:short-key")
      @Getter
      private String prefixShortKey;
  
23568a66   张志伟   feature(*): 绩效计算
85
86
87
88
89
90
      /**
       * 计算绩效组得分率
       */
      public void calcuScoringRate() {
          ListOperations<String, String> listOps = stringRedisTemplate.opsForList();
          List<String> errList = new ArrayList<>();
e45e50c3   张志伟   feature(*): 计算用户绩...
91
92
93
94
95
96
97
          String jsonStr;
          while ((jsonStr = listOps.leftPop(getCalcuScoringRateKey())) != null) {
              if (StringUtils.isEmpty(jsonStr)) {
                  continue;
              }
              KpiGroupCalculableBO calculableBO = JSONObject.parseObject(jsonStr, KpiGroupCalculableBO.class);
              if (Objects.isNull(calculableBO)) {
23568a66   张志伟   feature(*): 绩效计算
98
99
                  continue;
              }
23568a66   张志伟   feature(*): 绩效计算
100
              try {
e45e50c3   张志伟   feature(*): 计算用户绩...
101
                  calcuScoringRate(calculableBO);
23568a66   张志伟   feature(*): 绩效计算
102
              } catch (Exception ex) {
e45e50c3   张志伟   feature(*): 计算用户绩...
103
104
                  log.error("计算绩效组得分率失败:[{}]", jsonStr, ex);
                  errList.add(jsonStr);
23568a66   张志伟   feature(*): 绩效计算
105
106
107
108
109
110
111
112
113
114
              }
          }
          if (!CollectionUtils.isEmpty(errList)) {
              listOps.rightPushAll(getCalcuScoringRateKey(), errList);
          }
      }
  
      /**
       * 计算绩效组得分率
       *
e45e50c3   张志伟   feature(*): 计算用户绩...
115
       * @param bo 绩效组信息和日期
23568a66   张志伟   feature(*): 绩效计算
116
       */
e45e50c3   张志伟   feature(*): 计算用户绩...
117
118
119
120
      @Transactional(rollbackFor = Exception.class)
      public void calcuScoringRate(final KpiGroupCalculableBO bo) {
          Long kpiGroupId = bo.getKpiGroupId();
          LocalDate localDate = bo.getLocalDate();
3996a188   姜超   feature(*): 绩效得分率计算
121
122
          KpiGroup kpiGroup = kpiGroupService.getById(kpiGroupId);
          BV.notNull(kpiGroup, () -> "绩效组配置不存在");
e45e50c3   张志伟   feature(*): 计算用户绩...
123
124
125
          List<KpiPool> poolList = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
                  .eq(KpiPool::getKpiGroupId, kpiGroupId)
                  .eq(KpiPool::getMonthly, YearMonth.from(localDate))
e45e50c3   张志伟   feature(*): 计算用户绩...
126
127
                  .eq(KpiPool::getYn, Boolean.TRUE)
          );
e45e50c3   张志伟   feature(*): 计算用户绩...
128
          if (CollectionUtils.isEmpty(poolList)) {
90662047   张志伟   feature(*): 薪资计算
129
              log.error("绩效池查无数据:[{}] [{}]", kpiGroupId, localDate);
e45e50c3   张志伟   feature(*): 计算用户绩...
130
131
              return;
          }
c6a571bc   姜超   fix(*): 绩效分、星级修改
132
133
134
135
          List<KpiGroupIndicator> indicators = kpiGroupIndicatorService.list(Wrappers.<KpiGroupIndicator>lambdaQuery()
                  .eq(KpiGroupIndicator::getKpiGroupId, kpiGroupId)
                  .eq(KpiGroupIndicator::getYn, Boolean.TRUE)
          );
5afe0cb9   张志伟   feature(*): revie...
136
          final BigDecimal totalScore = indicators.stream().map(indicator -> BigDecimal.valueOf(indicator.getBaseScore()))
e45e50c3   张志伟   feature(*): 计算用户绩...
137
                  .reduce(BigDecimal.ZERO, BigDecimal::add);
c6a571bc   姜超   fix(*): 绩效分、星级修改
138
  
3996a188   姜超   feature(*): 绩效得分率计算
139
140
141
142
143
144
145
          KpiStarRule starRule = kpiStarRuleService.getOne(Wrappers.<KpiStarRule>lambdaQuery()
                          .eq(KpiStarRule::getGroupId, kpiGroup.getGroupId())
                          .eq(KpiStarRule::getYn, Boolean.TRUE)
                  , Boolean.FALSE);
          BV.notNull(starRule, () -> "星级规则配置不存在");
          int rollMonth = Optional.ofNullable(starRule.getRollMonth()).orElse(3);
  
e45e50c3   张志伟   feature(*): 计算用户绩...
146
147
148
149
          for (KpiPool pool : poolList) {
              BigDecimal kpiScore = Optional.ofNullable(pool.getKpiScore()).orElse(BigDecimal.ZERO);
              BigDecimal kpiScoreRatio = kpiScore.divide(totalScore, 4, RoundingMode.HALF_UP);
              pool.setKpiScoreRatio(kpiScoreRatio);
8dbff116   姜超   feature(*): 计算上月绩...
150
              calcAverageRatio(pool,rollMonth);
e45e50c3   张志伟   feature(*): 计算用户绩...
151
152
          }
          kpiPoolService.updateBatchById(poolList);
e45e50c3   张志伟   feature(*): 计算用户绩...
153
154
      }
  
5bca06a2   姜超   feature(*): 绩效池接口
155
  
4abb00e4   张志伟   feature(*): 计算用户人员星级
156
157
158
      /**
       * 计算绩效组人员星级
       */
e45e50c3   张志伟   feature(*): 计算用户绩...
159
      public void calcuStarLevel() {
4abb00e4   张志伟   feature(*): 计算用户人员星级
160
161
162
163
164
          ListOperations<String, String> listOps = stringRedisTemplate.opsForList();
          List<String> errList = new ArrayList<>();
          String jsonStr;
          while ((jsonStr = listOps.leftPop(getCalcuStarKey())) != null) {
              if (StringUtils.isValid(jsonStr)) {
864042ba   姜超   feature(*): 通过绩效组...
165
                  KpiGroupCalculableRankBO calculableBO = JSONObject.parseObject(jsonStr, KpiGroupCalculableRankBO.class);
4abb00e4   张志伟   feature(*): 计算用户人员星级
166
167
168
169
                  if (Objects.nonNull(calculableBO)) {
                      try {
                          calcuStarLevel(calculableBO);
                      } catch (Exception ex) {
864042ba   姜超   feature(*): 通过绩效组...
170
                          log.error("计算绩效星级失败:[{}]", jsonStr, ex);
4abb00e4   张志伟   feature(*): 计算用户人员星级
171
172
173
174
175
176
177
178
179
180
181
182
                          errList.add(jsonStr);
                      }
                  }
              }
          }
          if (!CollectionUtils.isEmpty(errList)) {
              listOps.rightPushAll(getCalcuStarKey(), errList);
          }
      }
  
  
      /**
864042ba   姜超   feature(*): 通过绩效组...
183
       * 计算星级、排名
4abb00e4   张志伟   feature(*): 计算用户人员星级
184
185
186
       *
       * @param bo
       */
6fd1b45f   张志伟   feature(*): 星级计算
187
      @Transactional(rollbackFor = Exception.class)
864042ba   姜超   feature(*): 通过绩效组...
188
189
      public void calcuStarLevel(KpiGroupCalculableRankBO bo) {
          final List<Long> kpiGroupIds = bo.getKpiGroupIds();
92652a3f   张志伟   feature(KpiPoolBi...
190
          final LocalDate localDate = bo.getLocalDate();
6fd1b45f   张志伟   feature(*): 星级计算
191
          final BigDecimal revokedScoreRatio = bo.getRevokedScoreRatio();
864042ba   姜超   feature(*): 通过绩效组...
192
193
194
          List<KpiGroup> kpiGroups = kpiGroupService.listByIds(kpiGroupIds);
          BV.notNull(kpiGroups, () -> "绩效组配置不能为空");
  
6d89f27c   姜超   feature(*): 计算排名修改
195
196
          KpiRankCalculableBO calculableBO = getStarConfig(bo, kpiGroups);
          StarEvaluationEnum starEvaluationType = calculableBO.getStarEvaluationType();
4abb00e4   张志伟   feature(*): 计算用户人员星级
197
  
92652a3f   张志伟   feature(KpiPoolBi...
198
          // 查询绩效组下所有人的绩效池信息
4abb00e4   张志伟   feature(*): 计算用户人员星级
199
          List<KpiPool> poolList = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
864042ba   姜超   feature(*): 通过绩效组...
200
                  .in(KpiPool::getKpiGroupId, kpiGroupIds)
4abb00e4   张志伟   feature(*): 计算用户人员星级
201
202
203
                  .eq(KpiPool::getMonthly, YearMonth.from(localDate))
                  .eq(KpiPool::getYn, Boolean.TRUE)
          );
92652a3f   张志伟   feature(KpiPoolBi...
204
205
206
207
          if (CollectionUtils.isEmpty(poolList)) {
              return;
          }
  
92652a3f   张志伟   feature(KpiPoolBi...
208
209
210
211
          if (StarEvaluationEnum.SCORING_RATE.equals(starEvaluationType)) {
              for (KpiPool kpiPool : poolList) {
                  if (!Boolean.TRUE.equals(kpiPool.getInclusion())) {
                      kpiPool.setStarLevel(StarLevelEnum.C);
90662047   张志伟   feature(*): 薪资计算
212
                      kpiPool.setActualStar(StarLevelEnum.C);
92652a3f   张志伟   feature(KpiPoolBi...
213
214
                      continue;
                  }
3996a188   姜超   feature(*): 绩效得分率计算
215
                  calcRatioStarLevel(kpiPool, calculableBO.getStarLadders());
92652a3f   张志伟   feature(KpiPoolBi...
216
217
              }
          } else if (StarEvaluationEnum.PERSONNEL_RATE.equals(starEvaluationType)) {
3996a188   姜超   feature(*): 绩效得分率计算
218
              calcRateStarLevel(kpiGroups, poolList, calculableBO);
92652a3f   张志伟   feature(KpiPoolBi...
219
220
          }
  
6fd1b45f   张志伟   feature(*): 星级计算
221
222
223
224
225
226
227
228
229
          if (Objects.nonNull(revokedScoreRatio) && BigDecimal.ZERO.compareTo(revokedScoreRatio) < 0) {
              for (KpiPool pool : poolList) {
                  BigDecimal kpiScore = pool.getKpiScore();
                  StarLevelEnum actualStar = pool.getActualStar();
                  if (kpiScore.compareTo(revokedScoreRatio) >= 0 && StarLevelEnum.D.equals(actualStar)) {
                      pool.setActualStar(StarLevelEnum.C);
                  }
              }
          }
6d89f27c   姜超   feature(*): 计算排名修改
230
231
          //计算排名
          calcRank(poolList);
2a32e29a   姜超   feature(*): 人员质量评...
232
233
          calcActualRank(bo, poolList, kpiGroupIds);
  
92652a3f   张志伟   feature(KpiPoolBi...
234
235
          kpiPoolService.updateBatchById(poolList);
      }
4abb00e4   张志伟   feature(*): 计算用户人员星级
236
  
92652a3f   张志伟   feature(KpiPoolBi...
237
238
239
      /**
       * 按绩效得分率
       */
3996a188   姜超   feature(*): 绩效得分率计算
240
241
      private void calcRatioStarLevel(KpiPool kpiPool, List<KpiStarLadderBO> startLadders) {
          final BigDecimal average = kpiPool.getAverageKpiScoreRatio();
864042ba   姜超   feature(*): 通过绩效组...
242
          KpiStarLadderBO ladder = startLadders.stream()
92652a3f   张志伟   feature(KpiPoolBi...
243
244
245
246
247
                  .filter(r -> average.compareTo(r.getLower()) >= 0)
                  .filter(a -> average.compareTo(a.getUpper()) < 0)
                  .findFirst()
                  .orElseThrow(() -> new BusinessException("未找到对应阶梯值"));
  
864042ba   姜超   feature(*): 通过绩效组...
248
249
          kpiPool.setStarLevel(ladder.getLevel());
          kpiPool.setActualStar(ladder.getLevel());
23568a66   张志伟   feature(*): 绩效计算
250
      }
5bca06a2   姜超   feature(*): 绩效池接口
251
  
92652a3f   张志伟   feature(KpiPoolBi...
252
253
254
      /**
       * 按人员数量
       */
3996a188   姜超   feature(*): 绩效得分率计算
255
      private void calcRateStarLevel(List<KpiGroup> kpiGroups, List<KpiPool> poolList, KpiRankCalculableBO calculableBO) {
6d89f27c   姜超   feature(*): 计算排名修改
256
257
          List<KpiStarLadderBO> startLadders = calculableBO.getStarLadders();
          BigDecimal revokedScoreRatio = calculableBO.getRevokedScoreRatio();
864042ba   姜超   feature(*): 通过绩效组...
258
259
260
261
          String kgcStr = kpiGroups.stream().map(KpiGroup::getKgc).collect(Collectors.joining("-"));
          String key = getShortKey(kgcStr);
          BoundZSetOperations<String, String> zSetOps = stringRedisTemplate.boundZSetOps(key);
          stringRedisTemplate.expireAt(key, DateUtil.localDate2Date(LocalDate.now().plusDays(1L)));
92652a3f   张志伟   feature(KpiPoolBi...
262
263
264
          for (KpiPool kpiPool : poolList) {
              if (!Boolean.TRUE.equals(kpiPool.getInclusion())) {
                  kpiPool.setStarLevel(StarLevelEnum.C);
90662047   张志伟   feature(*): 薪资计算
265
                  kpiPool.setActualStar(StarLevelEnum.C);
92652a3f   张志伟   feature(KpiPoolBi...
266
267
                  continue;
              }
3996a188   姜超   feature(*): 绩效得分率计算
268
              zSetOps.add(kpiPool.getId().toString(), kpiPool.getAverageKpiScoreRatio().doubleValue());
92652a3f   张志伟   feature(KpiPoolBi...
269
          }
864042ba   姜超   feature(*): 通过绩效组...
270
271
          Map<StarLevelEnum, KpiStarLadderBO> map = new HashMap<>(StarLevelEnum.values().length);
          for (KpiStarLadderBO ladder : startLadders) {
92652a3f   张志伟   feature(KpiPoolBi...
272
273
274
              map.put(ladder.getLevel(), ladder);
          }
  
6d89f27c   姜超   feature(*): 计算排名修改
275
          Map<String, StarLevelEnum> starLevelSetMap = calcPersonRateStarLevel(zSetOps, map, poolList, revokedScoreRatio);
92652a3f   张志伟   feature(KpiPoolBi...
276
277
278
279
280
281
          if (!CollectionUtils.isEmpty(starLevelSetMap)) {
              for (KpiPool pool : poolList) {
                  if (!Boolean.TRUE.equals(pool.getInclusion())) {
                      continue;
                  }
                  Long poolId = pool.getId();
90662047   张志伟   feature(*): 薪资计算
282
283
284
                  StarLevelEnum starLevel = Optional.ofNullable(starLevelSetMap.get(String.valueOf(poolId))).orElse(StarLevelEnum.C);
                  pool.setStarLevel(starLevel);
                  pool.setActualStar(starLevel);
92652a3f   张志伟   feature(KpiPoolBi...
285
286
              }
          }
864042ba   姜超   feature(*): 通过绩效组...
287
          stringRedisTemplate.delete(key);
92652a3f   张志伟   feature(KpiPoolBi...
288
289
290
291
292
293
294
295
      }
  
      /**
       * 按人数百分比计算等级
       *
       * @param zSetOps
       * @param map
       */
6d89f27c   姜超   feature(*): 计算排名修改
296
297
298
      private Map<String, StarLevelEnum> calcPersonRateStarLevel(BoundZSetOperations<String, String> zSetOps,
                                                                 Map<StarLevelEnum, KpiStarLadderBO> map,
                                                                 List<KpiPool> pools, BigDecimal revokedScoreRatio) {
92652a3f   张志伟   feature(KpiPoolBi...
299
300
301
302
303
304
          final Long personCount = zSetOps.size();
          if (Objects.isNull(personCount) || Objects.equals(personCount, 0L)) {
              return null;
          }
          Map<String, StarLevelEnum> levelIdMap = new HashMap<>();
  
864042ba   姜超   feature(*): 通过绩效组...
305
          KpiStarLadderBO aladder = map.get(StarLevelEnum.A);
92652a3f   张志伟   feature(KpiPoolBi...
306
307
308
309
310
311
312
313
          BV.notNull(aladder, () -> "星级A阶梯配置不存在");
          BigDecimal upper = aladder.getUpper();
          int ai = upper.multiply(BigDecimal.valueOf(personCount)).divide(BigDecimal.ONE, 0, RoundingMode.FLOOR).intValue();
          if (ai > 0) {
              assembleLevelIdMap(levelIdMap, StarLevelEnum.A, zSetOps.reverseRange(0, ai - 1));
  
          }
  
864042ba   姜超   feature(*): 通过绩效组...
314
          KpiStarLadderBO bladder = map.get(StarLevelEnum.B);
92652a3f   张志伟   feature(KpiPoolBi...
315
316
317
318
319
320
321
          BV.notNull(bladder, () -> "星级B阶梯配置不存在");
          BigDecimal bupper = bladder.getUpper();
          int bi = bupper.multiply(BigDecimal.valueOf(personCount)).divide(BigDecimal.ONE, 0, RoundingMode.FLOOR).intValue();
          if (bi > ai) {
              assembleLevelIdMap(levelIdMap, StarLevelEnum.B, zSetOps.reverseRange(ai, bi - 1));
          }
  
864042ba   姜超   feature(*): 通过绩效组...
322
          KpiStarLadderBO dladder = map.get(StarLevelEnum.D);
92652a3f   张志伟   feature(KpiPoolBi...
323
324
325
326
          BV.notNull(dladder, () -> "星级D阶梯配置不存在");
          BigDecimal lower = dladder.getLower();
          int di = lower.multiply(BigDecimal.valueOf(personCount)).divide(BigDecimal.ONE, 0, RoundingMode.CEILING).intValue();
          if (di < personCount) {
6d89f27c   姜超   feature(*): 计算排名修改
327
328
329
330
331
332
              Set<String> poolIds = zSetOps.reverseRange(di, -1);
              if (PublicUtil.isEmpty(revokedScoreRatio) || (BigDecimal.ZERO.compareTo(revokedScoreRatio) == 0)) {
                  assembleLevelIdMap(levelIdMap, StarLevelEnum.D, poolIds);
              } else {
                  Map<String, BigDecimal> poolMap = pools.stream().collect(Collectors.toMap(pool -> pool.getId().toString(), KpiPool::getAverageKpiScoreRatio));
                  Set<String> notRevokedIds = poolIds.stream().filter(poolId ->
5afe0cb9   张志伟   feature(*): revie...
333
                          poolMap.get(poolId).compareTo(revokedScoreRatio) < 0
6d89f27c   姜超   feature(*): 计算排名修改
334
335
336
                  ).collect(Collectors.toSet());
                  assembleLevelIdMap(levelIdMap, StarLevelEnum.D, notRevokedIds);
              }
92652a3f   张志伟   feature(KpiPoolBi...
337
          }
92652a3f   张志伟   feature(KpiPoolBi...
338
339
340
341
342
343
344
345
346
347
          return levelIdMap;
      }
  
      /**
       * 计算滚动月份平均得分率
       *
       * @param kpiPool
       * @param rollMonth
       * @return
       */
8dbff116   姜超   feature(*): 计算上月绩...
348
      private void calcAverageRatio(KpiPool kpiPool, int rollMonth) {
9726886a   姜超   feature(*): 人员质量评测修改
349
350
          //未纳入绩效考核人员也计算平均得分率,返回当月绩效完成率
          if (Boolean.FALSE.equals(kpiPool.getInclusion())) {
8dbff116   姜超   feature(*): 计算上月绩...
351
352
353
354
              kpiPool.setAverageKpiScoreRatio(Optional.ofNullable(kpiPool.getKpiScoreRatio()).orElse(BigDecimal.ZERO));
              kpiPool.setLastOneKpiScoreRatio(BigDecimal.ZERO);
              kpiPool.setLastTwoKpiScoreRatio(BigDecimal.ZERO);
              return;
9726886a   姜超   feature(*): 人员质量评测修改
355
          }
92652a3f   张志伟   feature(KpiPoolBi...
356
          List<KpiPool> poolList = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
c6a571bc   姜超   fix(*): 绩效分、星级修改
357
358
                  .eq(KpiPool::getUserId, kpiPool.getUserId())
                  .eq(KpiPool::getPostId, kpiPool.getPostId())
92652a3f   张志伟   feature(KpiPoolBi...
359
360
361
362
363
364
                  .eq(KpiPool::getInclusion, Boolean.TRUE)
                  .le(KpiPool::getCreateTime, kpiPool.getCreateTime())
                  .eq(KpiPool::getYn, Boolean.TRUE)
                  .orderByDesc(KpiPool::getCreateTime)
                  .last(MessageFormatUtil.MessageFormatTransfer(" limit  {0}", rollMonth))
          );
8dbff116   姜超   feature(*): 计算上月绩...
365
          double averageKpiScoreRatio = poolList.stream()
61c41ffa   张志伟   feature(Controlle...
366
367
368
                  .mapToDouble(r -> Optional.ofNullable(r.getKpiScoreRatio()).orElse(BigDecimal.ZERO).doubleValue())
                  .average()
                  .orElse(0);
8dbff116   姜超   feature(*): 计算上月绩...
369
370
371
372
373
374
375
376
377
378
379
          kpiPool.setAverageKpiScoreRatio(BigDecimal.valueOf(averageKpiScoreRatio));
          YearMonth lastMonth = kpiPool.getMonthly().minusMonths(1);
          YearMonth preTwoMonth = kpiPool.getMonthly().minusMonths(2);
          BigDecimal lastMonthRatio = poolList.stream()
                  .filter(pool -> lastMonth.compareTo(pool.getMonthly()) == 0).findFirst()
                  .map(KpiPool::getKpiScoreRatio).orElse(BigDecimal.ZERO);
          BigDecimal preTwoMonthRatio = poolList.stream()
                  .filter(pool -> preTwoMonth.compareTo(pool.getMonthly()) == 0).findFirst()
                  .map(KpiPool::getKpiScoreRatio).orElse(BigDecimal.ZERO);
          kpiPool.setLastOneKpiScoreRatio(lastMonthRatio);
          kpiPool.setLastTwoKpiScoreRatio(preTwoMonthRatio);
92652a3f   张志伟   feature(KpiPoolBi...
380
381
      }
  
60f70b0b   姜超   feature(*): 绩效组排名...
382
383
384
385
386
387
388
389
390
391
392
  
      /**
       * 计算排名
       *
       * @param poolList
       */
      public void calcRank(List<KpiPool> poolList) {
          if (PublicUtil.isEmpty(poolList)) {
              return;
          }
          List<KpiPool> pools = poolList.stream()
2a32e29a   姜超   feature(*): 人员质量评...
393
                  .filter(pool -> Boolean.TRUE.equals(pool.getInclusion()))
6d89f27c   姜超   feature(*): 计算排名修改
394
                  .sorted(Comparator.comparing(KpiPool::getAverageKpiScoreRatio, BigDecimal::compareTo).reversed())
60f70b0b   姜超   feature(*): 绩效组排名...
395
396
                  .collect(Collectors.toList());
  
6fd1b45f   张志伟   feature(*): 星级计算
397
          int rank = 1;
60f70b0b   姜超   feature(*): 绩效组排名...
398
399
          BigDecimal lastKpiScoreRatio = null;
          for (KpiPool pool : pools) {
6d89f27c   姜超   feature(*): 计算排名修改
400
              if (PublicUtil.isNotEmpty(lastKpiScoreRatio) && (lastKpiScoreRatio.compareTo(pool.getAverageKpiScoreRatio()) != 0)) {
6fd1b45f   张志伟   feature(*): 星级计算
401
                  rank++;
60f70b0b   姜超   feature(*): 绩效组排名...
402
              }
c222645a   姜超   fix(*): 修改bug
403
              pool.setRank(rank);
6d89f27c   姜超   feature(*): 计算排名修改
404
              lastKpiScoreRatio = pool.getAverageKpiScoreRatio();
60f70b0b   姜超   feature(*): 绩效组排名...
405
          }
e83f6066   xianpengcheng   绩效报表-排名处理
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
  
          //本月绩效排名
          List<KpiPool> pools2 = poolList.stream()
                  .filter(pool -> Boolean.TRUE.equals(pool.getInclusion()))
                  .sorted(Comparator.comparing(KpiPool::getKpiScoreRatio, BigDecimal::compareTo).reversed())
                  .collect(Collectors.toList());
  
          int rank2 = 1;
          BigDecimal lastKpiScoreRatio2 = null;
          for (KpiPool pool : pools2) {
              if (PublicUtil.isNotEmpty(lastKpiScoreRatio2) && (lastKpiScoreRatio2.compareTo(pool.getKpiScoreRatio()) != 0)) {
                  rank2++;
              }
              pool.setMonthRank(rank2);
              lastKpiScoreRatio2 = pool.getKpiScoreRatio();
          }
60f70b0b   姜超   feature(*): 绩效组排名...
422
423
      }
  
92652a3f   张志伟   feature(KpiPoolBi...
424
      /**
2a32e29a   姜超   feature(*): 人员质量评...
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
       * 计算转正保护期、正式员工排名排名
       *
       * @param poolList
       */
      public void calcActualRank(KpiGroupCalculableRankBO bo, List<KpiPool> poolList, List<Long> kpiGroupIds) {
          if (Boolean.FALSE.equals(bo.getFinalCalc()) || PublicUtil.isEmpty(poolList)) {
              return;
          }
          LocalDate localDate = bo.getLocalDate();
          List<KpiGroupUser> turnPositiveUsers = kpiGroupUserService.list(Wrappers.<KpiGroupUser>lambdaQuery()
                  .in(KpiGroupUser::getKpiGroupId, kpiGroupIds)
                  .eq(KpiGroupUser::getIgnored, Boolean.TRUE)
                  .eq(KpiGroupUser::getIgnoreCause, KpiIgnoreCauseEnum.TURN_POSITIVE_AFTER)
                  .eq(KpiGroupUser::getDataDate, localDate)
                  .eq(KpiGroupUser::getYn, Boolean.TRUE)
          );
          Set<Long> turnPositiveUserIds = turnPositiveUsers.stream().map(KpiGroupUser::getUserId).collect(Collectors.toSet());
          //转正保护期员工一起排名
          List<KpiPool> pools = poolList.stream()
                  .filter(pool -> {
                      return Boolean.TRUE.equals(pool.getInclusion()) || (turnPositiveUserIds.contains(pool.getUserId()));
                  })
                  .sorted(Comparator.comparing(KpiPool::getAverageKpiScoreRatio, BigDecimal::compareTo).reversed())
                  .collect(Collectors.toList());
  
          int rank = 1;
          BigDecimal lastKpiScoreRatio = null;
          for (KpiPool pool : pools) {
              if (PublicUtil.isNotEmpty(lastKpiScoreRatio) && (lastKpiScoreRatio.compareTo(pool.getAverageKpiScoreRatio()) != 0)) {
                  rank++;
              }
              pool.setAssessRank(rank);
              lastKpiScoreRatio = pool.getAverageKpiScoreRatio();
          }
      }
  
      /**
92652a3f   张志伟   feature(KpiPoolBi...
462
463
       * 生成排序key
       *
864042ba   姜超   feature(*): 通过绩效组...
464
       * @param key
92652a3f   张志伟   feature(KpiPoolBi...
465
466
       * @return
       */
864042ba   姜超   feature(*): 通过绩效组...
467
468
      private String getShortKey(@NonNull String key) {
          return String.format("%s:%s", getPrefixShortKey(), key);
92652a3f   张志伟   feature(KpiPoolBi...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
      }
  
  
      /**
       * 组装id对应等级
       *
       * @param levelIdMap
       * @param level
       * @param ids
       */
      private void assembleLevelIdMap(Map<String, StarLevelEnum> levelIdMap, StarLevelEnum level, Set<String> ids) {
          if (CollectionUtils.isNotEmpty(ids)) {
              for (String s : ids) {
                  levelIdMap.put(s, level);
              }
          }
      }
0684035f   姜超   feature(*): 人员绩效组...
486
487
488
489
490
491
492
493
494
495
496
  
      /**
       * 失效用户所有绩效池
       * 不参与滚动计算平均三个月绩效得分率,不纳入D级次数计算。场景:
       * 1 用户申请重新计算绩效考核
       * 2. 调岗
       * 3. 待岗
       *
       * @param userId
       */
      @Transactional(rollbackFor = Exception.class)
1355883a   姜超   feature(*): 人员调岗修...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
      public void invalidKpiPool(KpiGroup originKpiGroup, Long userId, LocalDate anticipatedDate) {
          KpiGroupUser groupUser = kpiGroupUserService.getOne(Wrappers.<KpiGroupUser>lambdaQuery()
                  .eq(KpiGroupUser::getKgc, originKpiGroup.getKgc())
                  .eq(KpiGroupUser::getUserId, userId)
                  .eq(KpiGroupUser::getDataDate, LocalDate.now())
                  .eq(KpiGroupUser::getYn, Boolean.TRUE)
          );
          if (PublicUtil.isNotEmpty(groupUser)) {
              groupUser.setIgnored(Boolean.TRUE);
              if (PublicUtil.isNotEmpty(anticipatedDate)) {
                  groupUser.setAnticipatedDate(anticipatedDate);
              }
              groupUser.setIgnoreCause(KpiIgnoreCauseEnum.TRANSFER_NEW_POSITION_AFTER);
              groupUser.setIgnoreCauseDesc(KpiIgnoreCauseEnum.TRANSFER_NEW_POSITION_AFTER.getName());
              kpiGroupUserService.updateById(groupUser);
          }
  
          kpiPoolService.update(Wrappers.<KpiPool>lambdaUpdate()
0684035f   姜超   feature(*): 人员绩效组...
515
                  .set(KpiPool::getInclusion, Boolean.FALSE)
9439d750   姜超   feature(*): 调岗后排名...
516
                  .set(KpiPool::getRank, null)
0684035f   姜超   feature(*): 人员绩效组...
517
                  .eq(KpiPool::getUserId, userId)
9439d750   姜超   feature(*): 调岗后排名...
518
                  .eq(KpiPool::getMonthly, YearMonth.now())
0684035f   姜超   feature(*): 人员绩效组...
519
520
                  .eq(KpiPool::getInclusion, Boolean.TRUE)
          );
0684035f   姜超   feature(*): 人员绩效组...
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
      }
  
      /**
       * 失效用户所有绩效得分率。场景:
       * 1 用户申请重新计算绩效考核
       * 2. 调岗
       * 3. 待岗
       *
       * @param userId
       */
      @Transactional(rollbackFor = Exception.class)
      public void adjustmentKpiPool(Long userId, StarLevelEnum starLevelEnum, YearMonth yearMonth) {
          Boolean result = kpiPoolService.update(Wrappers.<KpiPool>lambdaUpdate()
                  .set(KpiPool::getActualStar, starLevelEnum)
                  .eq(KpiPool::getUserId, userId)
                  .eq(KpiPool::getMonthly, yearMonth)
          );
          BV.isTrue(result, "绩效池是否纳入绩效计算修改失败");
      }
  
da234187   姜超   feature(*): 绩效、薪酬...
541
542
543
544
545
546
      /**
       * 查询薪酬池详情
       *
       * @param poolId 薪酬池id
       * @return 薪酬池详情
       */
3ecdbd72   姜超   feature(*): 展示工资明...
547
      public KpiPoolDetailVO queryPoolDetail(final Long poolId, YearMonth yearMonth) {
da234187   姜超   feature(*): 绩效、薪酬...
548
          KpiPool pool = kpiPoolService.getById(poolId);
9f47fb88   姜超   feature(*): 薪酬组人员日期
549
550
  //        boolean flag = Objects.nonNull(pool) && Boolean.TRUE.equals(pool.getYn());
  //        BV.isTrue(flag, () -> "该人员绩效数据不存在");
a7a46424   姜超   feature(*): 薪酬报表
551
          if (PublicUtil.isEmpty(pool)) {
9f47fb88   姜超   feature(*): 薪酬组人员日期
552
553
              return null;
          }
5afe0cb9   张志伟   feature(*): revie...
554
          if (PublicUtil.isNotEmpty(yearMonth) && (!yearMonth.equals(pool.getMonthly()))) {
3ecdbd72   姜超   feature(*): 展示工资明...
555
              List<KpiPool> list = userSalaryPool(pool.getUserId(), yearMonth);
9f47fb88   姜超   feature(*): 薪酬组人员日期
556
557
558
559
  //            BV.isNotEmpty(list, () -> "人员薪酬数据不存在");
              if (PublicUtil.isEmpty(list)) {
                  return null;
              }
3ecdbd72   姜超   feature(*): 展示工资明...
560
561
              pool = list.get(0);
          }
da234187   姜超   feature(*): 绩效、薪酬...
562
563
564
565
566
567
568
569
570
571
          return getPoolDetail(pool);
      }
  
      /**
       * 查询薪酬池详情
       *
       * @param userId    用户id
       * @param yearMonth 月度
       * @return 薪酬池详情
       */
3ecdbd72   姜超   feature(*): 展示工资明...
572
      public KpiPoolDetailVO queryUserPoolDetail(final Long userId, final YearMonth yearMonth) {
da234187   姜超   feature(*): 绩效、薪酬...
573
          List<KpiPool> list = userSalaryPool(userId, yearMonth);
9f47fb88   姜超   feature(*): 薪酬组人员日期
574
575
576
577
  //        BV.isNotEmpty(list, () -> "人员薪酬数据不存在");
          if (PublicUtil.isEmpty(list)) {
              return null;
          }
da234187   姜超   feature(*): 绩效、薪酬...
578
579
580
581
582
583
584
585
586
587
588
589
590
          KpiPool kpiPool = list.get(0);
          return getPoolDetail(kpiPool);
      }
  
      /**
       * 绩效池详情构建
       *
       * @param kpiPool
       * @return
       */
      private KpiPoolDetailVO getPoolDetail(KpiPool kpiPool) {
          Long userId = kpiPool.getUserId();
          Long kpiPoolId = kpiPool.getId();
a403bf65   姜超   feature(*): 查询薪酬、...
591
          Long kpiGroupId = kpiPool.getKpiGroupId();
da234187   姜超   feature(*): 绩效、薪酬...
592
          KpiPoolDetailVO kpiPoolDetailVo = PublicUtil.copy(kpiPool, KpiPoolDetailVO.class);
58aa0677   姜超   feature(*): 绩效得分详情修改
593
          //奖惩绩效分
d382e392   姜超   feature(*): 绩效计算查...
594
  //        this.processRewardPoint(kpiPool, kpiPoolDetailVo);
0ac3000c   姜超   feature(*): 绩效详情查看
595
          //近一年绩效情况
da234187   姜超   feature(*): 绩效、薪酬...
596
          List<KpiPool> kpiPools = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
0ac3000c   姜超   feature(*): 绩效详情查看
597
                  .ge(KpiPool::getMonthly, kpiPool.getMonthly().minusMonths(12L))
da234187   姜超   feature(*): 绩效、薪酬...
598
599
600
                  .eq(KpiPool::getUserId, userId)
                  .eq(KpiPool::getInclusion, Boolean.TRUE)
                  .eq(KpiPool::getYn, Boolean.TRUE)
dad803db   姜超   feature(*): 修改展示查询
601
                  .orderByDesc(KpiPool::getMonthly)
da234187   姜超   feature(*): 绩效、薪酬...
602
          );
1c236c95   姜超   feature(*): 绩效池查询
603
          if (PublicUtil.isNotEmpty(kpiPools)) {
a8289dd2   姜超   feature(*): 绩效详情接口修改
604
              List<KpiPoolDetailVO> kpis = PublicUtil.copyList(kpiPools, KpiPoolDetailVO.class);
43fb9eed   姜超   feature(*): 薪酬详情查询修改
605
              kpis.stream().forEach(KpiPoolDetailVO::convertToPercent);
c20b66b6   姜超   fix(*): 绩效得分率百分比修改
606
              kpiPoolDetailVo.setKpis(kpis);
1c236c95   姜超   feature(*): 绩效池查询
607
          }
ea01c66f   姜超   feature(*): 管理角色查询接口
608
609
          buildPoolData(kpiPool, kpiPoolDetailVo);
          LocalDate dataDate = LocalDate.from(kpiPoolDetailVo.getEndTime());
0ac3000c   姜超   feature(*): 绩效详情查看
610
  
4dec65f8   姜超   feature(*): 薪酬星级计...
611
          kpiPoolDetailVo.setTotalScore(this.getKpiGroupIndicatorTotalScore(kpiGroupId));
a8289dd2   姜超   feature(*): 绩效详情接口修改
612
          kpiPoolDetailVo.setKpiScoreRatio(kpiPoolDetailVo.getKpiScoreRatio().multiply(Constant.ONE_HUNDRED));
71dbfe97   姜超   feature(*): 绩效详情返...
613
          this.setRewardPunish(kpiPool, kpiPoolDetailVo);
558ea833   姜超   feature(*): 绩效奖惩分数
614
615
616
617
618
          this.setIndicatorVos(kpiPoolId, kpiGroupId, dataDate, kpiPoolDetailVo);
          this.setAssess(kpiPoolDetailVo);
          return kpiPoolDetailVo;
      }
  
71dbfe97   姜超   feature(*): 绩效详情返...
619
620
621
622
623
624
      public void setRewardPunish(KpiPool pool, KpiPoolDetailVO kpiPoolDetailVO) {
          List<KpiRewardPoint> rewardPoints = kpiRewardPointService.list(Wrappers.<KpiRewardPoint>lambdaQuery()
                  .eq(KpiRewardPoint::getUserId, pool.getUserId())
                  .eq(KpiRewardPoint::getPostId, pool.getPostId())
                  .eq(KpiRewardPoint::getShopId, pool.getShopId())
                  .eq(KpiRewardPoint::getMonthly, pool.getMonthly())
d382e392   姜超   feature(*): 绩效计算查...
625
                  .le(KpiRewardPoint::getCreateTime, kpiPoolDetailVO.getEndTime())
71dbfe97   姜超   feature(*): 绩效详情返...
626
627
                  .eq(KpiRewardPoint::getGroupId, pool.getGroupId())
          );
d382e392   姜超   feature(*): 绩效计算查...
628
629
630
631
632
633
634
635
636
637
638
639
  
          //计算分数时将
          BigDecimal rewardScore = BigDecimal.ZERO;
          BigDecimal punishScore = BigDecimal.ZERO;
          for (KpiRewardPoint point : rewardPoints) {
              if (BigDecimal.ZERO.compareTo(point.getScorePoint()) > 0) {
                  punishScore = punishScore.add(point.getScorePoint());
              } else {
                  rewardScore = rewardScore.add(point.getScorePoint());
              }
          }
          //奖励分正数、惩罚分负数,减去奖惩分数,得到原始分数
0992692a   姜超   feature(*): 考评不抽取日志
640
          BigDecimal originKpiScore = pool.getKpiScore().subtract(rewardScore).subtract(punishScore);
d8b80418   姜超   feature(*): 考评不抽取日志
641
642
643
          if (BigDecimal.ZERO.compareTo(originKpiScore) > 0) {
              originKpiScore = BigDecimal.ZERO;
          }
d382e392   姜超   feature(*): 绩效计算查...
644
645
          kpiPoolDetailVO.setRewardScore(rewardScore);
          kpiPoolDetailVO.setPunishScore(punishScore.abs());
130b59f8   姜超   feature(*): 绩效分数展示修改
646
647
          kpiPoolDetailVO.setRealKpiScore(pool.getKpiScore());
          kpiPoolDetailVO.setOriginKpiScore(originKpiScore);
d382e392   姜超   feature(*): 绩效计算查...
648
  
71dbfe97   姜超   feature(*): 绩效详情返...
649
650
651
652
653
654
655
656
657
          kpiPoolDetailVO.setRewards(new ArrayList<>());
          kpiPoolDetailVO.setPunishments(new ArrayList<>());
          rewardPoints.stream().forEach(point -> {
              KpiRewardPointVO pointVO = PublicUtil.copy(point, KpiRewardPointVO.class);
              pointVO.setExpectation(Boolean.FALSE);
              if (point.getScorePoint().compareTo(BigDecimal.ZERO) > 0) {
                  kpiPoolDetailVO.getRewards().add(pointVO);
              }
              if (point.getScorePoint().compareTo(BigDecimal.ZERO) < 0) {
19382fcb   姜超   feature(*): 查询奖惩修改
658
                  pointVO.setScorePoint(pointVO.getScorePoint().abs());
71dbfe97   姜超   feature(*): 绩效详情返...
659
660
661
662
663
                  kpiPoolDetailVO.getPunishments().add(pointVO);
              }
          });
      }
  
558ea833   姜超   feature(*): 绩效奖惩分数
664
665
      public void setIndicatorVos(Long kpiPoolId, Long kpiGroupId, LocalDate dataDate, KpiPoolDetailVO kpiPoolDetailVo) {
          DecimalFormat decimalFormat = new DecimalFormat("##########.##");
ea01c66f   姜超   feature(*): 管理角色查询接口
666
          List<KpiPoolIndicatorValueVO> indicatorValueVOS = kpiPoolIndicatorValueService.getStaffIndicatorValue(kpiPoolId, kpiGroupId, dataDate);
a8289dd2   姜超   feature(*): 绩效详情接口修改
667
          for (KpiPoolIndicatorValueVO indicatorValueVO : indicatorValueVOS) {
73a0ce39   姜超   feature(kpipool):...
668
              indicatorValueVO.setIndicatorScoreFormat(decimalFormat.format(indicatorValueVO.getIndicatorScore()));
9fe049d0   姜超   feature(*): 修改薪酬计...
669
670
  
              BigDecimal indicatorScoreRatio = indicatorValueVO.getIndicatorScore().divide(indicatorValueVO.getBaseScore(), 2, RoundingMode.DOWN);
7de20f3f   姜超   feature(*): 绩效薪酬查看
671
              indicatorScoreRatio = indicatorScoreRatio.multiply(Constant.ONE_HUNDRED);
9fe049d0   姜超   feature(*): 修改薪酬计...
672
              indicatorValueVO.setIndicatorScoreRatio(decimalFormat.format(indicatorScoreRatio));
558ea833   姜超   feature(*): 绩效奖惩分数
673
674
675
  //            BigDecimal lossIndicatorScoreRatio = (Constant.ONE_HUNDRED.compareTo(indicatorScoreRatio) > 0) ?
  //                    BigDecimal.ZERO : Constant.ONE_HUNDRED.subtract(indicatorScoreRatio);
  //            indicatorValueVO.setLossIndicatorScoreRatio(decimalFormat.format(lossIndicatorScoreRatio));
a8289dd2   姜超   feature(*): 绩效详情接口修改
676
677
          }
          kpiPoolDetailVo.setKpiValues(indicatorValueVOS);
da234187   姜超   feature(*): 绩效、薪酬...
678
679
      }
  
3e4ca434   姜超   feature(*): 人员质量评...
680
681
      public void setAssess(KpiPoolDetailVO kpiPoolDetailVo) {
          if (! LocalDate.now().minusDays(1L).equals(LocalDate.from(kpiPoolDetailVo.getEndTime()))) {
3e4ca434   姜超   feature(*): 人员质量评...
682
683
              return;
          }
71dbfe97   姜超   feature(*): 绩效详情返...
684
          List<KpiAssessPenalty> penalties = kpiAssessPenaltyService.list(Wrappers.<KpiAssessPenalty>lambdaQuery()
3e4ca434   姜超   feature(*): 人员质量评...
685
686
687
688
689
                  .eq(KpiAssessPenalty::getUserId, kpiPoolDetailVo.getUserId())
                  .eq(KpiAssessPenalty::getDataDate, LocalDate.from(kpiPoolDetailVo.getEndTime()))
                  .eq(KpiAssessPenalty::getExpectedPenalty, Boolean.TRUE)
                  .eq(KpiAssessPenalty::getYn, Boolean.TRUE)
          );
71dbfe97   姜超   feature(*): 绩效详情返...
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
          Map<KpiAssessTypeEnum, List<KpiAssessPenalty>> typeMap = penalties.stream().collect(Collectors.groupingBy(KpiAssessPenalty::getType));
          for (Map.Entry<KpiAssessTypeEnum, List<KpiAssessPenalty>> entry : typeMap.entrySet()) {
              BigDecimal score = entry.getValue().stream().map(KpiAssessPenalty::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
              if (BigDecimal.ZERO.compareTo(score) == 0) {
                  continue;
              }
              KpiRewardPointVO point = new KpiRewardPointVO();
              point.setExpectation(Boolean.TRUE);
              point.setTypeName(entry.getKey().getName());
              point.setDataId(entry.getKey().getValue().toString());
  
              //奖励
              if (score.compareTo(BigDecimal.ZERO) > 0) {
                  point.setScorePoint(score);
                  kpiPoolDetailVo.getRewards().add(point);
              } else {
                  point.setScorePoint(score.abs());
                  kpiPoolDetailVo.getPunishments().add(point);
              }
          }
3e4ca434   姜超   feature(*): 人员质量评...
710
711
      }
  
da234187   姜超   feature(*): 绩效、薪酬...
712
      /**
58aa0677   姜超   feature(*): 绩效得分详情修改
713
714
715
716
       * 获取奖惩绩效分
       *
       * @param pool
       */
5e6a6922   姜超   feature(*): 筛选修改
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
  //    public void processRewardPoint(KpiPool pool, KpiPoolDetailVO poolDetailVO) {
  //        List<KpiRewardPoint> list = kpiRewardPointService.list(Wrappers.<KpiRewardPoint>lambdaQuery()
  //                .eq(KpiRewardPoint::getUserId, pool.getUserId())
  //                .eq(KpiRewardPoint::getPostId, pool.getPostId())
  //                .eq(KpiRewardPoint::getShopId, pool.getShopId())
  //                .eq(KpiRewardPoint::getMonthly, pool.getMonthly())
  //                .eq(KpiRewardPoint::getGroupId, pool.getGroupId())
  //        );
  //        BigDecimal rewardScore = BigDecimal.ZERO;
  //        BigDecimal punishScore = BigDecimal.ZERO;
  //        for (KpiRewardPoint point : list) {
  //            if (BigDecimal.ZERO.compareTo(point.getScorePoint()) > 0) {
  //                punishScore = punishScore.add(point.getScorePoint());
  //            } else {
  //                rewardScore = rewardScore.add(point.getScorePoint());
  //            }
  //        }
  //        //奖励分正数、惩罚分负数,减去奖惩分数,得到原始分数
  //        BigDecimal originKpiScore = poolDetailVO.getKpiScore().subtract(rewardScore).subtract(punishScore);
  //        poolDetailVO.setRewardScore(rewardScore);
  //        poolDetailVO.setPunishScore(punishScore.abs());
  //        poolDetailVO.setOriginKpiScore(originKpiScore);
  //    }
58aa0677   姜超   feature(*): 绩效得分详情修改
740
741
  
      /**
4dec65f8   姜超   feature(*): 薪酬星级计...
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
       * 获取绩效组指标总分
       *
       * @param kpiGroupId
       * @return
       */
      public BigDecimal getKpiGroupIndicatorTotalScore(Long kpiGroupId) {
          List<KpiGroupIndicator> indicators = kpiGroupIndicatorService.list(Wrappers.<KpiGroupIndicator>lambdaQuery()
                  .eq(KpiGroupIndicator::getKpiGroupId, kpiGroupId)
                  .eq(KpiGroupIndicator::getYn, Boolean.TRUE)
          );
          final BigDecimal totalScore = indicators.stream().map(indicator -> BigDecimal.valueOf(indicator.getBaseScore()))
                  .reduce(BigDecimal.ZERO, BigDecimal::add);
          return totalScore;
      }
  
      /**
459e4fde   姜超   fix(kpipool、salar...
758
759
760
761
762
       * 获取绩效池详情最近日期
       *
       * @param kpiPool
       * @return
       */
ea01c66f   姜超   feature(*): 管理角色查询接口
763
      public void buildPoolData(KpiPool kpiPool, KpiPoolDetailVO kpiPoolDetailVo) {
a92022b7   姜超   feature(*): 绩效不再使...
764
          KpiGroupUser kpiGroupUser = kpiGroupUserService.getMonthLastData(kpiPool.getKpiGroupId(), kpiPool.getUserId(), kpiPool.getMonthly());
459e4fde   姜超   fix(kpipool、salar...
765
766
          if (PublicUtil.isEmpty(kpiGroupUser)) {
              log.error("员工绩效池:{},不存在绩效组人员", JSON.toJSONString(kpiPool));
ea01c66f   姜超   feature(*): 管理角色查询接口
767
768
769
              kpiPoolDetailVo.setEndTime(PublicUtil.getYesterdayOrEndOfMonthDay(kpiPool.getMonthly()).atTime(23, 59, 59));
              kpiPoolDetailVo.setStartTime(kpiPool.getMonthly().atDay(1).atTime(00, 00, 00));
              return;
459e4fde   姜超   fix(kpipool、salar...
770
          }
6a162455   姜超   feature(*): 不参与绩效...
771
772
773
774
775
          //不纳入绩效计算 并且 绩效组人员不为空
          if (! kpiPool.getInclusion() && PublicUtil.isNotEmpty(kpiGroupUser)) {
              kpiPoolDetailVo.setIgnoreCause(kpiGroupUser.getIgnoreCause());
              kpiPoolDetailVo.setIgnoreCauseDesc(kpiGroupUser.getIgnoreCauseDesc());
          }
ea01c66f   姜超   feature(*): 管理角色查询接口
776
          kpiPoolDetailVo.setEndTime(kpiGroupUser.getDataDate().atTime(23, 59, 59));
a92022b7   姜超   feature(*): 绩效不再使...
777
          KpiGroupUser firstKpiGroupUser = kpiGroupUserService.getMonthFirstData(kpiPool.getKpiGroupId(), kpiPool.getUserId(), kpiPool.getMonthly());
ea01c66f   姜超   feature(*): 管理角色查询接口
778
          kpiPoolDetailVo.setStartTime(firstKpiGroupUser.getDataDate().atTime(00, 00, 00));
459e4fde   姜超   fix(kpipool、salar...
779
780
781
      }
  
      /**
da234187   姜超   feature(*): 绩效、薪酬...
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
       * 查询用户月度绩效池列表
       *
       * @param userId    用户id
       * @param yearMonth 月度
       * @return 返回结果
       */
      @Cacheable(cacheNames = "kpi", key = "':user:pool:'+ #yearMonth.toString() +':'+ #userId", unless = "#result.size() < 1")
      public List<KpiPool> userSalaryPool(final Long userId, final YearMonth yearMonth) {
          List<KpiPool> list = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
                  .eq(KpiPool::getUserId, userId)
                  .eq(KpiPool::getMonthly, yearMonth)
                  .eq(KpiPool::getYn, Boolean.TRUE)
                  .orderByDesc(KpiPool::getId)
          );
          if (CollectionUtils.isEmpty(list)) {
              return new ArrayList<>();
          }
          return list;
      }
  
278ef9ef   姜超   feature(bug): 修改目...
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
  //    /**
  //     * 绩效项目阶梯详情
  //     *
  //     * @param kpiPoolId
  //     * @param kpiGroupIndicatorId
  //     * @param yearMonth
  //     * @return
  //     */
  //    public KpiGroupIndicatorDetailVO getHitIndicatorLadder(Long kpiPoolId, Long kpiGroupIndicatorId, YearMonth yearMonth) {
  //
  //        KpiGroupIndicator kpiGroupIndicator = kpiGroupIndicatorService.getById(kpiGroupIndicatorId);
  //        BV.notNull(kpiGroupIndicator, "指标不存在");
  ////        Indicators indicator = indicatorsService.queryByCode(kpiGroupIndicator.getIndicatorCode(), Boolean.TRUE);
  ////        BV.notNull(indicator, "指标不存在");
  //        KpiGroup kpiGroup = kpiGroupService.getAllDataById(kpiGroupIndicator.getKpiGroupId());
  //        BV.notNull(kpiGroup, "绩效组不存在");
  //        KpiGroupIndicatorDetailVO detailVO = new KpiGroupIndicatorDetailVO();
  //        LocalDate localDate = PublicUtil.getYesterdayOrEndOfMonthDay(yearMonth);
  //
  //        if (ScoreWayEnum.LADDER.equals(kpiGroupIndicator.getScoreWay())) {
  //            KpiGroupIndicatorHitLog kpiIndicatorHitLog = kpiGroupIndicatorHitLogService.getOne(Wrappers.<KpiGroupIndicatorHitLog>lambdaQuery()
  //                    .eq(KpiGroupIndicatorHitLog::getKpiGroupIndicatorId, kpiGroupIndicatorId)
  //                    .eq(KpiGroupIndicatorHitLog::getDataDate, localDate)
  //                    .eq(KpiGroupIndicatorHitLog::getYn, Boolean.TRUE)
  //            );
  //            BV.notNull(kpiIndicatorHitLog, "绩效命中记录不存在");
  //            Long hitKpiIndicatorLaddersId = kpiIndicatorHitLog.getKpiGroupIndicatorLaddersId();
  //
  //            List<KpiGroupIndicatorLadders> settins = kpiGroupIndicatorLaddersService.list(Wrappers.<KpiGroupIndicatorLadders>lambdaQuery()
  //                    .eq(KpiGroupIndicatorLadders::getKpiGroupIndicatorId, kpiGroupIndicatorId)
  //                    .eq(KpiGroupIndicatorLadders::getYn, Boolean.TRUE)
  //                    .orderByAsc(KpiGroupIndicatorLadders::getId)
  //            );
  //
  //            detailVO.setLadders(settins.stream().map(indicatorLadders -> {
  //                KpiGroupIndicatorLaddersVO indicatorLaddersVO = PublicUtil.copy(indicatorLadders, KpiGroupIndicatorLaddersVO.class);
  //                indicatorLaddersVO.setHit((hitKpiIndicatorLaddersId.equals(indicatorLaddersVO.getId()) ? Boolean.TRUE : Boolean.FALSE));
  //                indicatorLaddersVO.convertLadderToPercent();
  //                return indicatorLaddersVO;
  //            }).collect(Collectors.toList()));
  //        }
  //
  //        detailVO.setKpiTime(localDate.atTime(23, 59, 59));
  //        detailVO.setPostId(kpiGroup.getPostId());
  //        detailVO.setPostName(kpiGroup.getPostName());
  //        detailVO.setKpiGroupShopIds(kpiGroup.getShopIds());
  //        detailVO.setKpiGroupShopNames(kpiGroup.getShopNames());
  //
  ////        detailVO.setSysName(indicator.getSysName());
  ////        detailVO.setSysPrefix(indicator.getSysPrefix());
  ////        detailVO.setIndicatorCode(indicator.getIndicatorCode());
  ////        detailVO.setIndicatorName(indicator.getIndicatorName());
  //        return detailVO;
  //
  //    }
60f70b0b   姜超   feature(*): 绩效组排名...
857
  
864042ba   姜超   feature(*): 通过绩效组...
858
      /**
7652457e   张志伟   feature(*): 手动计算绩...
859
860
       * debug用计算单个绩效组排名
       *
46276518   张志伟   feature(*): 完善deb...
861
       * @param kpiGroupId 绩效组id
6467e2b8   张志伟   :zap:
862
       * @param localDate  日期
7652457e   张志伟   feature(*): 手动计算绩...
863
       */
46276518   张志伟   feature(*): 完善deb...
864
      @DisLock(key = "#localDate.toString()+':'+ #kpiGroupId", message = "请勿重复操作")
7652457e   张志伟   feature(*): 手动计算绩...
865
866
867
868
869
870
871
872
873
874
875
      public void cacheCalculableKpiGroupRank(Long kpiGroupId, LocalDate localDate) {
          final KpiGroup kpiGroup = kpiGroupService.getAllDataById(kpiGroupId);
          final String kgc = kpiGroup.getKgc();
          final Long groupId = kpiGroup.getGroupId();
          final KpiGroupRank groupRank = kpiGroupRankService.getOne(Wrappers.<KpiGroupRank>lambdaQuery()
                          .eq(KpiGroupRank::getGroupId, groupId)
                          .eq(KpiGroupRank::getYn, Boolean.TRUE)
                          .apply("FIND_IN_SET({0}, kgcs)", kgc),
                  Boolean.FALSE
          );
          if (Objects.isNull(groupRank)) {
3e4ca434   姜超   feature(*): 人员质量评...
876
              KpiGroupCalculableRankBO rankBO = cacheCalculableKpiGroupRank(kpiGroup, localDate);
7652457e   张志伟   feature(*): 手动计算绩...
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
              calcuStarLevel(rankBO);
              return;
          }
          List<KpiGroup> kpiGroups = kpiGroupService.queryKgiGroupsByDay(localDate);
          BV.isNotEmpty(kpiGroups, () -> "没有需要计算排名的绩效组");
          Map<String, Long> kgcIdMap = kpiGroups.stream().collect(Collectors.toMap(KpiGroup::getKgc, KpiGroup::getId, (v1, v2) -> v1));
          List<String> kgcList = groupRank.getKgcs();
          Set<Long> kpiGroupIds = new HashSet<>();
          for (String kgcStr : kgcList) {
              Long id = kgcIdMap.getOrDefault(kgcStr, 0L);
              if (id > 0) {
                  kpiGroupIds.add(kpiGroupId);
              }
          }
          BV.isNotEmpty(kpiGroupIds, () -> MessageFormatTransfer("绩效排名组[{0}]不包含任何绩效组", groupRank.getId()));
3e4ca434   姜超   feature(*): 人员质量评...
892
          KpiGroupCalculableRankBO bo = cacheCalculableKpiGroupRank(groupRank, kpiGroupIds, localDate);
7652457e   张志伟   feature(*): 手动计算绩...
893
894
895
896
          calcuStarLevel(bo);
      }
  
      /**
864042ba   姜超   feature(*): 通过绩效组...
897
       * 缓存需要计算绩效排名
6fd1b45f   张志伟   feature(*): 星级计算
898
       *
864042ba   姜超   feature(*): 通过绩效组...
899
900
       * @param localDate
       */
3e4ca434   姜超   feature(*): 人员质量评...
901
      public void cacheCalculableKpiGroupRank(LocalDate localDate) {
6fd1b45f   张志伟   feature(*): 星级计算
902
          List<String> rankBOS = new ArrayList<>();
f11b16d6   姜超   feature(*): 绩效排名组...
903
904
905
906
          List<KpiGroupRank> kpiGroupRanks = kpiGroupRankService.list(Wrappers.<KpiGroupRank>lambdaQuery()
                  .eq(KpiGroupRank::getStatus, SettingStatusEnum.EFFECTIVE)
                  .eq(KpiGroupRank::getYn, Boolean.TRUE)
          );
864042ba   姜超   feature(*): 通过绩效组...
907
          for (KpiGroupRank kpiGroupRank : kpiGroupRanks) {
f11b16d6   姜超   feature(*): 绩效排名组...
908
909
910
              if (PublicUtil.isNotEmpty(kpiGroupRank.getKpiGroupIds())) {
                  rankBOS.add(JSONObject.toJSONString(cacheCalculableKpiGroupRank(kpiGroupRank,
                          new HashSet<>(kpiGroupRank.getKpiGroupIds()), localDate)));
864042ba   姜超   feature(*): 通过绩效组...
911
912
              }
          }
f11b16d6   姜超   feature(*): 绩效排名组...
913
914
915
916
          if (PublicUtil.isNotEmpty(rankBOS)) {
              ListOperations<String, String> listOps = stringRedisTemplate.opsForList();
              listOps.rightPushAll(getCalcuStarKey(), rankBOS);
          }
864042ba   姜超   feature(*): 通过绩效组...
917
918
919
920
921
922
923
      }
  
      /**
       * 获取星级配置
       *
       * @param bo
       * @param kpiGroups
864042ba   姜超   feature(*): 通过绩效组...
924
925
       * @return
       */
6d89f27c   姜超   feature(*): 计算排名修改
926
      public KpiRankCalculableBO getStarConfig(KpiGroupCalculableRankBO bo, List<KpiGroup> kpiGroups) {
6d89f27c   姜超   feature(*): 计算排名修改
927
          KpiRankCalculableBO calculableBO = new KpiRankCalculableBO();
864042ba   姜超   feature(*): 通过绩效组...
928
929
          if (bo.getCalculateSeparately()) {
              KpiGroup kpiGroup = kpiGroups.get(0);
864042ba   姜超   feature(*): 通过绩效组...
930
931
932
933
934
              List<KpiStarLadders> kpiStarLadders = kpiStarLaddersService.list(Wrappers.<KpiStarLadders>lambdaQuery()
                      .eq(KpiStarLadders::getKpiGroupId, kpiGroup.getId())
                      .eq(KpiStarLadders::getYn, Boolean.TRUE)
              );
              BV.isNotEmpty(kpiStarLadders, () -> "星级阶梯配置不存在");
6d89f27c   姜超   feature(*): 计算排名修改
935
936
937
938
939
              if (PublicUtil.isNotEmpty(kpiGroup.getRevokedScoreRatio())) {
                  calculableBO.setRevokedScoreRatio(kpiGroup.getRevokedScoreRatio());
              }
              calculableBO.setStarEvaluationType(kpiGroup.getStarEvaluationType());
              calculableBO.setStarLadders(PublicUtil.copyList(kpiStarLadders, KpiStarLadderBO.class));
864042ba   姜超   feature(*): 通过绩效组...
940
941
          } else {
              KpiGroupRank kpiGroupRank = kpiGroupRankService.getById(bo.getKpiGroupRankId());
864042ba   姜超   feature(*): 通过绩效组...
942
943
944
945
946
              List<KpiGroupRankStarLadders> kpiGroupRankStarLadders = kpiGroupRankStarLaddersService.list(Wrappers.<KpiGroupRankStarLadders>lambdaQuery()
                      .eq(KpiGroupRankStarLadders::getKpiGroupRankId, bo.getKpiGroupRankId())
                      .eq(KpiGroupRankStarLadders::getYn, Boolean.TRUE)
              );
              BV.isNotEmpty(kpiGroupRankStarLadders, () -> "排名星级阶梯配置不存在");
6d89f27c   姜超   feature(*): 计算排名修改
947
948
949
950
951
              if (PublicUtil.isNotEmpty(kpiGroupRank.getRevokedScoreRatio())) {
                  calculableBO.setRevokedScoreRatio(kpiGroupRank.getRevokedScoreRatio());
              }
              calculableBO.setStarEvaluationType(kpiGroupRank.getStarEvaluationType());
              calculableBO.setStarLadders(PublicUtil.copyList(kpiGroupRankStarLadders, KpiStarLadderBO.class));
864042ba   姜超   feature(*): 通过绩效组...
952
          }
6d89f27c   姜超   feature(*): 计算排名修改
953
          return calculableBO;
864042ba   姜超   feature(*): 通过绩效组...
954
      }
7652457e   张志伟   feature(*): 手动计算绩...
955
  
2a32e29a   姜超   feature(*): 人员质量评...
956
      private KpiGroupCalculableRankBO cacheCalculableKpiGroupRank(KpiGroupRank kpiGroupRank, Set<Long> kpiGroupIds,
3e4ca434   姜超   feature(*): 人员质量评...
957
                                                                   LocalDate date) {
7652457e   张志伟   feature(*): 手动计算绩...
958
959
960
961
962
963
964
          return KpiGroupCalculableRankBO.builder()
                  .kpiGroupIds(new ArrayList<>(kpiGroupIds))
                  .groupId(kpiGroupRank.getGroupId())
                  .localDate(date)
                  .revokedScoreRatio(kpiGroupRank.getRevokedScoreRatio())
                  .calculateSeparately(Boolean.FALSE)
                  .kpiGroupRankId(kpiGroupRank.getId())
7652457e   张志伟   feature(*): 手动计算绩...
965
966
967
                  .build();
      }
  
3e4ca434   姜超   feature(*): 人员质量评...
968
      private KpiGroupCalculableRankBO cacheCalculableKpiGroupRank(KpiGroup kpiGroup, LocalDate date) {
7652457e   张志伟   feature(*): 手动计算绩...
969
970
971
972
973
974
          return KpiGroupCalculableRankBO.builder()
                  .kpiGroupIds(Collections.singletonList(kpiGroup.getId()))
                  .groupId(kpiGroup.getGroupId())
                  .revokedScoreRatio(kpiGroup.getRevokedScoreRatio())
                  .localDate(date)
                  .calculateSeparately(Boolean.TRUE)
7652457e   张志伟   feature(*): 手动计算绩...
975
976
977
                  .build();
  
      }
e83f6066   xianpengcheng   绩效报表-排名处理
978
979
980
981
982
983
  
      /**
       * 绩效报表-绩效得分率排名详情
       * @param dto
       * @return
       */
f143d42f   xianpengcheng   修改字段统一
984
      public List<KpiPoolVO> queryKpiRankPool(KpiGroupRankConfigQueryDTO dto) {
e83f6066   xianpengcheng   绩效报表-排名处理
985
          List<KpiPool> list = kpiPoolService.list(Wrappers.<KpiPool>lambdaQuery()
f143d42f   xianpengcheng   修改字段统一
986
987
                  .in(KpiPool::getKpiGroupId, dto.getKpiGroupIds())
                  .eq(KpiPool::getMonthly, dto.getYearMonth())
e83f6066   xianpengcheng   绩效报表-排名处理
988
                  .eq(KpiPool::getYn, Boolean.TRUE)
f143d42f   xianpengcheng   修改字段统一
989
                  .last("ORDER BY ISNULL(rank), rank ASC")
e83f6066   xianpengcheng   绩效报表-排名处理
990
991
992
993
994
          );
          if (CollectionUtils.isEmpty(list)) {
              return Collections.emptyList();
          }
          List<KpiPoolVO> kpiPoolVOS = PublicUtil.copyList(list, KpiPoolVO.class);
959e7e91   xianpengcheng   返回绩效率乘以100
995
996
997
998
999
1000
1001
          for (KpiPoolVO kpiPoolVO : kpiPoolVOS) {
              //处理得分率 乘以 100
              kpiPoolVO.setKpiScoreRatio(Optional.ofNullable(kpiPoolVO.getKpiScoreRatio()).orElse(BigDecimal.ZERO).multiply(Constant.ONE_HUNDRED));
              kpiPoolVO.setLastOneKpiScoreRatio(Optional.ofNullable(kpiPoolVO.getLastOneKpiScoreRatio()).orElse(BigDecimal.ZERO).multiply(Constant.ONE_HUNDRED));
              kpiPoolVO.setLastTwoKpiScoreRatio(Optional.ofNullable(kpiPoolVO.getLastTwoKpiScoreRatio()).orElse(BigDecimal.ZERO).multiply(Constant.ONE_HUNDRED));
              kpiPoolVO.setAverageKpiScoreRatio(Optional.ofNullable(kpiPoolVO.getAverageKpiScoreRatio()).orElse(BigDecimal.ZERO).multiply(Constant.ONE_HUNDRED));
          }
e83f6066   xianpengcheng   绩效报表-排名处理
1002
1003
          return kpiPoolVOS;
      }
5bca06a2   姜超   feature(*): 绩效池接口
1004
  }