Blame view

fw-morax-service/src/main/java/cn/fw/morax/service/biz/calculator/eval/kpi/EvalKpiBaseCalculator.java 19 KB
e79c21f9   姜超   feature(*): 计算计算修改
1
2
  package cn.fw.morax.service.biz.calculator.eval.kpi;
  
e1778851   姜超   feature(*): 计算考评调整
3
  import cn.fw.morax.common.utils.PublicUtil;
e2386ce2   姜超   feature(*): 考评计算得分修改
4
  import cn.fw.morax.domain.bo.eval.EvalGroupUserShop;
e79c21f9   姜超   feature(*): 计算计算修改
5
6
7
8
9
10
11
  import cn.fw.morax.domain.db.eval.*;
  import cn.fw.morax.domain.db.kpi.*;
  import cn.fw.morax.domain.enums.*;
  import cn.fw.morax.service.biz.calculator.Calculator;
  import cn.fw.morax.service.data.eval.*;
  import cn.fw.morax.service.data.kpi.*;
  import com.alibaba.fastjson.JSONObject;
aaab7f45   姜超   feature(*): 考评指标计算
12
  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
e79c21f9   姜超   feature(*): 计算计算修改
13
14
15
16
17
18
19
  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  import lombok.extern.slf4j.Slf4j;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import java.math.BigDecimal;
  import java.math.RoundingMode;
e79c21f9   姜超   feature(*): 计算计算修改
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Objects;
  import java.util.Optional;
  import java.util.function.Consumer;
  
  /**
   * 考评基础计算器
   *
   * @author : kurisu
   * @version : 2.0
   * @className : BaseCalculator
   * @description : 考评基础计算器
   * @date : 2022-12-26 14:17
   */
  @Slf4j
e2386ce2   姜超   feature(*): 考评计算得分修改
36
  public abstract class EvalKpiBaseCalculator implements Calculator<EvalGroupUserShop, EvalGroupIndicator, BigDecimal> {
e79c21f9   姜超   feature(*): 计算计算修改
37
38
39
40
41
42
  
      @Autowired
      protected EvalGroupIndicatorHitLogService evalGroupIndicatorHitLogService;
      @Autowired
      protected IndicatorUserValueService indicatorUserValueService;
      @Autowired
80e64f6f   姜超   feature(*): 考评排名组...
43
44
      protected IndicatorUserStageValueService indicatorUserStageValueService;
      @Autowired
aaab7f45   姜超   feature(*): 考评指标计算
45
46
      protected EvalIndicatorValueService evalIndicatorValueService;
      @Autowired
e79c21f9   姜超   feature(*): 计算计算修改
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
      protected EvalGroupIndicatorParamService evalGroupIndicatorParamService;
      @Autowired
      protected EvalGroupIndicatorPreconditionService evalGroupIndicatorPreconditionService;
      @Autowired
      protected EvalGroupIndicatorPreconditionHitLogService preconditionHitLogService;
      @Autowired
      protected EvalGroupIndicatorPreconditionLaddersService preconditionLaddersService;
      @Autowired
      protected EvalGroupIndicatorTargetHitLogService evalGroupIndicatorTargetHitLogService;
  
      /**
       * 获取设置类型
       *
       * @return
       */
      public abstract ScoreWayEnum getCalMethod();
  
      /**
       * 通过前置条件计算绩效得分系数
       *
aaab7f45   姜超   feature(*): 考评指标计算
67
       * @param preconditions
e79c21f9   姜超   feature(*): 计算计算修改
68
69
       * @return
       */
e2386ce2   姜超   feature(*): 考评计算得分修改
70
      protected BigDecimal calcCoefficient(EvalGroupUserShop obj, List<EvalGroupIndicatorPrecondition> preconditions) {
e79c21f9   姜超   feature(*): 计算计算修改
71
          BigDecimal coefficient = BigDecimal.ONE;
aaab7f45   姜超   feature(*): 考评指标计算
72
          if (CollectionUtils.isEmpty(preconditions)) {
e79c21f9   姜超   feature(*): 计算计算修改
73
74
              return coefficient;
          }
aaab7f45   姜超   feature(*): 考评指标计算
75
76
          for (int i = 0; i < preconditions.size(); i++) {
              EvalGroupIndicatorPrecondition precondition = preconditions.get(i);
80e64f6f   姜超   feature(*): 考评排名组...
77
              TargetCalcTypeEnum targetCalcType = precondition.getTargetCalcType();
e79c21f9   姜超   feature(*): 计算计算修改
78
              TargetTypeEnum targetType = precondition.getTargetType();
e1778851   姜超   feature(*): 计算考评调整
79
              Optional<BigDecimal> valueOptional = queryValue(obj, precondition.getCodeType(), precondition.getCode());
aaab7f45   姜超   feature(*): 考评指标计算
80
              if (! valueOptional.isPresent()) {
e79c21f9   姜超   feature(*): 计算计算修改
81
82
                  return BigDecimal.ZERO;
              }
e376b24c   姜超   feature(*): 修改个人考评
83
              final BigDecimal originValue = valueOptional.get();
e79c21f9   姜超   feature(*): 计算计算修改
84
              BigDecimal indicatorValue = originValue;
e376b24c   姜超   feature(*): 修改个人考评
85
86
              EvalUseTargetEnum useTarget = EvalUseTargetEnum.NO;
  
e79c21f9   姜超   feature(*): 计算计算修改
87
              if (!TargetTypeEnum.NO.equals(targetType)) {
e376b24c   姜超   feature(*): 修改个人考评
88
                  useTarget = EvalUseTargetEnum.FIRST_TARGET;
e79c21f9   姜超   feature(*): 计算计算修改
89
                  BigDecimal targetValue = precondition.getTargetValue();
80e64f6f   姜超   feature(*): 考评排名组...
90
                  if (TargetCalcTypeEnum.TARGET_VALUE.equals(targetCalcType) || TargetCalcTypeEnum.STAGE_TARGET.equals(targetCalcType)) {
e79c21f9   姜超   feature(*): 计算计算修改
91
                      indicatorValue = indicatorValue.divide(targetValue, 4, RoundingMode.HALF_UP);
80e64f6f   姜超   feature(*): 考评排名组...
92
                  } else if (TargetCalcTypeEnum.MINIMUM.equals(targetCalcType)){
e79c21f9   姜超   feature(*): 计算计算修改
93
94
95
96
                      BigDecimal difference = BigDecimal.ONE.subtract(targetValue);
                      if (BigDecimal.ZERO.compareTo(difference) == 0) {
                          difference = BigDecimal.ONE;
                      }
7e8fb0fe   姜超   feature(*): 考评计算修改
97
98
99
100
101
102
                      BigDecimal userDiffValue = indicatorValue.subtract(targetValue);
                      if (userDiffValue.compareTo(BigDecimal.ZERO) <= 0) {
                          indicatorValue = BigDecimal.ZERO;
                      } else {
                          indicatorValue = userDiffValue.divide(difference, 4, RoundingMode.HALF_UP);
                      }
e79c21f9   姜超   feature(*): 计算计算修改
103
                  }
e79c21f9   姜超   feature(*): 计算计算修改
104
              }
e376b24c   姜超   feature(*): 修改个人考评
105
106
107
108
109
110
  
              EvalGroupIndicatorTargetHitLog log = new EvalGroupIndicatorTargetHitLog();
              log.setValue(originValue);
              log.setReachValue(indicatorValue);
              log.setUseTarget(useTarget);
              saveTargetHitLog(obj, precondition.getId(), IndicatorTypeEnum.PRE, originValue, log);
e79c21f9   姜超   feature(*): 计算计算修改
111
112
113
114
115
              coefficient = coefficient(obj, precondition.getId(), indicatorValue);
          }
          return coefficient;
      }
  
e2386ce2   姜超   feature(*): 考评计算得分修改
116
      protected BigDecimal coefficient(EvalGroupUserShop obj, Long preconditionId, BigDecimal value) {
e79c21f9   姜超   feature(*): 计算计算修改
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
          EvalGroupIndicatorPreconditionLadders ladder = preconditionLaddersService.getOne(Wrappers.<EvalGroupIndicatorPreconditionLadders>lambdaQuery()
                          .eq(EvalGroupIndicatorPreconditionLadders::getPreconditionId, preconditionId)
                          .gt(EvalGroupIndicatorPreconditionLadders::getUpper, value)
                          .le(EvalGroupIndicatorPreconditionLadders::getLower, value)
                          .eq(EvalGroupIndicatorPreconditionLadders::getYn, Boolean.TRUE),
                  Boolean.FALSE
          );
          if (Objects.isNull(ladder)) {
              savePreconditionHitLog(obj, preconditionId, hitLog -> {
                  hitLog.setPreconditionLaddersId(-1L);
                  hitLog.setValue(value);
              });
              return BigDecimal.ZERO;
          }
  
          savePreconditionHitLog(obj, preconditionId, hitLog -> {
              hitLog.setPreconditionLaddersId(ladder.getId());
              hitLog.setValue(value);
          });
          return ladder.getScorePercent();
      }
  
      /**
       * 计算最终的指标值
       *
       * @param params
7e8fb0fe   姜超   feature(*): 考评计算修改
143
       * @param userShop
e79c21f9   姜超   feature(*): 计算计算修改
144
145
146
       * @param evalGroupIndicatorId
       * @return
       */
e2386ce2   姜超   feature(*): 考评计算得分修改
147
      protected BigDecimal calculateFinalIndValue(List<EvalGroupIndicatorParam> params, EvalGroupUserShop userShop, Long evalGroupIndicatorId) {
e79c21f9   姜超   feature(*): 计算计算修改
148
149
150
151
152
153
          BigDecimal rate = BigDecimal.ZERO;
          if (CollectionUtils.isEmpty(params)) {
              log.info("指标[{}]配置不存在", evalGroupIndicatorId);
              return rate;
          }
          for (EvalGroupIndicatorParam param : params) {
e1778851   姜超   feature(*): 计算考评调整
154
              Optional<BigDecimal> valueOptional = queryValue(userShop, param.getCodeType(), param.getCode());
aaab7f45   姜超   feature(*): 考评指标计算
155
              if (! valueOptional.isPresent()) {
7e7c92a1   姜超   feature(*): 考评排名组...
156
                  log.info("[{}] [{}]指标[{}]值不存在", userShop.getScopeType().getName(), userShop.getReferId(), param.getCode());
e79c21f9   姜超   feature(*): 计算计算修改
157
158
159
                  continue;
              }
              TargetTypeEnum targetType = param.getTargetType();
7e7c92a1   姜超   feature(*): 考评排名组...
160
              TargetTypeEnum extraTargetType = param.getExtraTargetType();
e1778851   姜超   feature(*): 计算考评调整
161
              final BigDecimal originValue = valueOptional.get();
e376b24c   姜超   feature(*): 修改个人考评
162
163
164
165
166
167
168
169
170
              BigDecimal indicatorValue = originValue;
              BigDecimal reachValue = BigDecimal.ZERO;
              BigDecimal extraReachValue = BigDecimal.ZERO;
              EvalUseTargetEnum useTarget = EvalUseTargetEnum.NO;
  
              if (PublicUtil.isNotEmpty(targetType) && !TargetTypeEnum.NO.equals(targetType)) {
                  reachValue = calcTarget(param.getTargetCalcType(), originValue, param.getTargetValue());
                  useTarget = EvalUseTargetEnum.FIRST_TARGET;
                  indicatorValue = reachValue;
29de1560   姜超   feature(*): 考评排名组...
171
172
              }
              if (PublicUtil.isNotEmpty(extraTargetType) && (!TargetTypeEnum.NO.equals(extraTargetType))) {
e376b24c   姜超   feature(*): 修改个人考评
173
                  extraReachValue = calcTarget(param.getExtraTargetCalcType(), originValue, param.getExtraTargetValue());
08df0045   姜超   feature(*): 考评排名组...
174
                  //额外计算类型值  原始计算类型值  用大的那个值
e376b24c   姜超   feature(*): 修改个人考评
175
176
177
                  if (PublicUtil.isEmpty(reachValue) || (extraReachValue.compareTo(reachValue) > 0)) {
                      indicatorValue = extraReachValue;
                      useTarget = EvalUseTargetEnum.EXTRA_TARGET;
e79c21f9   姜超   feature(*): 计算计算修改
178
                  }
e79c21f9   姜超   feature(*): 计算计算修改
179
              }
e376b24c   姜超   feature(*): 修改个人考评
180
181
182
183
184
185
              EvalGroupIndicatorTargetHitLog log = new EvalGroupIndicatorTargetHitLog();
              log.setValue(originValue);
              log.setReachValue(reachValue);
              log.setExtraReachValue(extraReachValue);
              log.setUseTarget(useTarget);
              saveTargetHitLog(userShop, param.getId(), IndicatorTypeEnum.EXAMINE, originValue, log);
29de1560   姜超   feature(*): 考评排名组...
186
  
e79c21f9   姜超   feature(*): 计算计算修改
187
188
189
190
191
192
193
194
195
196
197
              boolean isCap = Boolean.TRUE.equals(param.getCap());
              BigDecimal proportion = param.getProportion();
              if (isCap) {
                  indicatorValue = BigDecimal.ONE.compareTo(indicatorValue) > 0 ? indicatorValue : BigDecimal.ONE;
              }
              rate = rate.add(proportion.multiply(indicatorValue));
          }
          return rate;
      }
  
      /**
7e7c92a1   姜超   feature(*): 考评排名组...
198
199
200
       * 计算目标
       */
      public BigDecimal calcTarget(TargetCalcTypeEnum targetCalcType, BigDecimal indicatorValue, BigDecimal targetValue) {
bc484bc4   姜超   feature(*): 定时任务发送修改
201
202
203
          if (PublicUtil.isEmpty(targetValue) || BigDecimal.ZERO.compareTo(targetValue) == 0) {
              return BigDecimal.ZERO;
          }
7e7c92a1   姜超   feature(*): 考评排名组...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
         if (TargetCalcTypeEnum.MINIMUM.equals(targetCalcType)) {
              BigDecimal difference = BigDecimal.ONE.subtract(targetValue);
              if (BigDecimal.ZERO.compareTo(difference) == 0) {
                  difference = BigDecimal.ONE;
              }
              BigDecimal userDiffValue = indicatorValue.subtract(targetValue);
              if (userDiffValue.compareTo(BigDecimal.ZERO) <= 0) {
                  return BigDecimal.ZERO;
              } else {
                  return userDiffValue.divide(difference, 4, RoundingMode.HALF_UP);
              }
         }
  
          return  indicatorValue.divide(targetValue, 4, RoundingMode.HALF_UP);
      }
  
      /**
e79c21f9   姜超   feature(*): 计算计算修改
221
222
       * 查询指标值
       *
e79c21f9   姜超   feature(*): 计算计算修改
223
224
       * @return
       */
e1778851   姜超   feature(*): 计算考评调整
225
      protected Optional<BigDecimal> queryValue(EvalGroupUserShop obj, IndicatorCodeTypeEnum codeType, String indicatorCode) {
aaab7f45   姜超   feature(*): 考评指标计算
226
227
          DimensionTypeEnum dimensionType = EvalScopeEnum.STAFF.equals(obj.getScopeType()) ? DimensionTypeEnum.STAFF : DimensionTypeEnum.SHOP;
          if (IndicatorCodeTypeEnum.INDICATOR.equals(codeType)) {
80e64f6f   姜超   feature(*): 考评排名组...
228
229
230
231
232
233
234
              LambdaQueryWrapper<IndicatorUserStageValue> queryWrapper = Wrappers.<IndicatorUserStageValue>lambdaQuery()
                      .eq(IndicatorUserStageValue::getIndicatorCode, indicatorCode)
                      .eq(IndicatorUserStageValue::getBeginDate, obj.getBeginDate())
                      .eq(IndicatorUserStageValue::getEndDate, obj.getDataDate())
                      .eq(IndicatorUserStageValue::getDimensionType, dimensionType)
                      .eq(IndicatorUserStageValue::getYn, Boolean.TRUE)
                      .eq(IndicatorUserStageValue::getGroupId, obj.getGroupId());
aaab7f45   姜超   feature(*): 考评指标计算
235
              if (EvalScopeEnum.STAFF.equals(obj.getScopeType())) {
80e64f6f   姜超   feature(*): 考评排名组...
236
                  queryWrapper.eq(IndicatorUserStageValue::getUserId, obj.getReferId());
aaab7f45   姜超   feature(*): 考评指标计算
237
              } else {
80e64f6f   姜超   feature(*): 考评排名组...
238
                  queryWrapper.eq(IndicatorUserStageValue::getShopId, obj.getReferId());
aaab7f45   姜超   feature(*): 考评指标计算
239
              }
80e64f6f   姜超   feature(*): 考评排名组...
240
241
              IndicatorUserStageValue indicatorUserStageValue = indicatorUserStageValueService.getOne(queryWrapper, Boolean.FALSE);
              return queryKpiIndicatorValue(indicatorUserStageValue);
aaab7f45   姜超   feature(*): 考评指标计算
242
243
          }
  
c06a04fb   姜超   feature(*): 考评指标详情
244
          EvalIndicatorValue evalIndicatorValue = evalIndicatorValueService.queryLastValue(obj.getReferId(),
f692be3a   姜超   feature(*): 查询修改
245
                  dimensionType, indicatorCode, obj.getDataDate());
aaab7f45   姜超   feature(*): 考评指标计算
246
          return Optional.ofNullable(evalIndicatorValue).map(EvalIndicatorValue::getIndicatorValue);
e79c21f9   姜超   feature(*): 计算计算修改
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
      }
  
      /**
       * 查询前置条件
       *
       * @param evalGroupIndicatorId
       * @return
       */
      protected List<EvalGroupIndicatorPrecondition> queryPrecondition(Long evalGroupIndicatorId) {
          List<EvalGroupIndicatorPrecondition> preList = evalGroupIndicatorPreconditionService.list(Wrappers.<EvalGroupIndicatorPrecondition>lambdaQuery()
                  .eq(EvalGroupIndicatorPrecondition::getEvalGroupIndicatorId, evalGroupIndicatorId)
                  .eq(EvalGroupIndicatorPrecondition::getYn, Boolean.TRUE)
                  .orderByAsc(EvalGroupIndicatorPrecondition::getSort)
          );
          return Optional.ofNullable(preList).orElse(new ArrayList<>());
      }
  
      /**
       * 查询指标配置
       *
       * @param evalGroupIndicatorId
       * @return
       */
      protected List<EvalGroupIndicatorParam> queryParam(Long evalGroupIndicatorId) {
          List<EvalGroupIndicatorParam> list = evalGroupIndicatorParamService.list(Wrappers.<EvalGroupIndicatorParam>lambdaQuery()
                  .eq(EvalGroupIndicatorParam::getEvalGroupIndicatorId, evalGroupIndicatorId)
                  .eq(EvalGroupIndicatorParam::getYn, Boolean.TRUE)
          );
          return Optional.ofNullable(list).orElse(new ArrayList<>());
      }
  
      /**
e79c21f9   姜超   feature(*): 计算计算修改
279
280
       * 查询具体指标值
       *
80e64f6f   姜超   feature(*): 考评排名组...
281
       * @param indicatorUserStageValue
e1778851   姜超   feature(*): 计算考评调整
282
283
       * @return
       */
80e64f6f   姜超   feature(*): 考评排名组...
284
285
      protected Optional<BigDecimal> queryKpiIndicatorValue(IndicatorUserStageValue indicatorUserStageValue) {
          if (PublicUtil.isEmpty(indicatorUserStageValue) || PublicUtil.isEmpty(indicatorUserStageValue.getIndicatorValue())) {
e1778851   姜超   feature(*): 计算考评调整
286
287
288
289
              return Optional.empty();
          }
          BigDecimal value = BigDecimal.ZERO;
          try {
80e64f6f   姜超   feature(*): 考评排名组...
290
291
              JSONObject jsonObject = JSONObject.parseObject(indicatorUserStageValue.getIndicatorValue());
              value = Optional.ofNullable(jsonObject.getBigDecimal(indicatorUserStageValue.getIndicatorCode())).orElse(BigDecimal.ZERO);
e1778851   姜超   feature(*): 计算考评调整
292
          } catch (Exception e) {
80e64f6f   姜超   feature(*): 考评排名组...
293
              log.error("[{}]指标值转化失败", indicatorUserStageValue, e);
e1778851   姜超   feature(*): 计算考评调整
294
295
296
297
298
299
300
          }
          return Optional.of(value);
      }
  
      /**
       * 查询具体指标值
       *
e376b24c   姜超   feature(*): 修改个人考评
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
       * @param indicatorUserValue
       * @return
       */
      protected Optional<BigDecimal> queryKpiIndicatorValue(IndicatorUserValue indicatorUserValue) {
          if (PublicUtil.isEmpty(indicatorUserValue) || PublicUtil.isEmpty(indicatorUserValue.getIndicatorValue())) {
              return Optional.empty();
          }
          BigDecimal value = BigDecimal.ZERO;
          try {
              JSONObject jsonObject = JSONObject.parseObject(indicatorUserValue.getIndicatorValue());
              value = Optional.ofNullable(jsonObject.getBigDecimal(indicatorUserValue.getIndicatorCode())).orElse(BigDecimal.ZERO);
          } catch (Exception e) {
              log.error("[{}]指标值转化失败", indicatorUserValue, e);
          }
          return Optional.of(value);
      }
  
      /**
       * 查询具体指标值
       *
e79c21f9   姜超   feature(*): 计算计算修改
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
       * @param indicatorCode
       * @param originalValue
       * @return
       */
      protected BigDecimal queryIndicatorValue(String indicatorCode, String originalValue) {
          BigDecimal value = BigDecimal.ZERO;
          try {
              JSONObject jsonObject = JSONObject.parseObject(originalValue);
              value = Optional.ofNullable(jsonObject.getBigDecimal(indicatorCode)).orElse(BigDecimal.ZERO);
          } catch (Exception e) {
              log.error("[{}]指标值转化失败", indicatorCode, e);
          }
          return value;
      }
  
08c31209   姜超   feature(*): 考评详情
336
337
338
      protected void savePreconditionHitLog(EvalGroupUserShop userShop, Long preconditionId, Consumer<EvalGroupIndicatorPreconditionHitLog> consumer) {
          Long poolId = userShop.getPoolId();
          EvalScopeEnum evalScope = userShop.getScopeType();
e79c21f9   姜超   feature(*): 计算计算修改
339
340
  
          preconditionHitLogService.remove(Wrappers.<EvalGroupIndicatorPreconditionHitLog>lambdaQuery()
08c31209   姜超   feature(*): 考评详情
341
                  .eq(EvalGroupIndicatorPreconditionHitLog::getPoolId, poolId)
e79c21f9   姜超   feature(*): 计算计算修改
342
                  .eq(EvalGroupIndicatorPreconditionHitLog::getPreconditionId, preconditionId)
08c31209   姜超   feature(*): 考评详情
343
344
                  .eq(EvalGroupIndicatorPreconditionHitLog::getDataDate, userShop.getDataDate())
                  .eq(EvalGroupIndicatorPreconditionHitLog::getGroupId, userShop.getGroupId())
e79c21f9   姜超   feature(*): 计算计算修改
345
346
347
          );
          EvalGroupIndicatorPreconditionHitLog hitLog = new EvalGroupIndicatorPreconditionHitLog();
          hitLog.setPreconditionId(preconditionId);
08c31209   姜超   feature(*): 考评详情
348
          hitLog.setPoolId(poolId);
e79c21f9   姜超   feature(*): 计算计算修改
349
          hitLog.setScopeType(evalScope);
08c31209   姜超   feature(*): 考评详情
350
351
          hitLog.setDataDate(userShop.getDataDate());
          hitLog.setGroupId(userShop.getGroupId());
e79c21f9   姜超   feature(*): 计算计算修改
352
353
354
355
356
357
          if (consumer != null) {
              consumer.accept(hitLog);
          }
          preconditionHitLogService.save(hitLog);
      }
  
e376b24c   姜超   feature(*): 修改个人考评
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
      protected void saveTargetHitLog(EvalGroupUserShop userShop, Long referId, IndicatorTypeEnum targetType, BigDecimal value, EvalGroupIndicatorTargetHitLog log) {
          evalGroupIndicatorTargetHitLogService.remove(Wrappers.<EvalGroupIndicatorTargetHitLog>lambdaQuery()
                  .eq(EvalGroupIndicatorTargetHitLog::getPoolId, userShop.getPoolId())
                  .eq(EvalGroupIndicatorTargetHitLog::getScopeType, userShop.getScopeType())
                  .eq(EvalGroupIndicatorTargetHitLog::getTargetType, targetType)
                  .eq(EvalGroupIndicatorTargetHitLog::getDataDate, userShop.getDataDate())
                  .eq(EvalGroupIndicatorTargetHitLog::getReferId, referId)
          );
          log.setPoolId(userShop.getPoolId());
          log.setScopeType(userShop.getScopeType());
          log.setReferId(referId);
          log.setTargetType(targetType);
          log.setValue(value);
          log.setDataDate(userShop.getDataDate());
          log.setGroupId(userShop.getGroupId());
          log.setYn(Boolean.TRUE);
          evalGroupIndicatorTargetHitLogService.save(log);
      }
  
08c31209   姜超   feature(*): 考评详情
377
      protected void saveTargetHitLog(EvalGroupUserShop userShop, Long referId, IndicatorTypeEnum targetType, BigDecimal value, BigDecimal reachValue) {
e79c21f9   姜超   feature(*): 计算计算修改
378
          evalGroupIndicatorTargetHitLogService.remove(Wrappers.<EvalGroupIndicatorTargetHitLog>lambdaQuery()
08c31209   姜超   feature(*): 考评详情
379
380
                  .eq(EvalGroupIndicatorTargetHitLog::getPoolId, userShop.getPoolId())
                  .eq(EvalGroupIndicatorTargetHitLog::getScopeType, userShop.getScopeType())
e79c21f9   姜超   feature(*): 计算计算修改
381
                  .eq(EvalGroupIndicatorTargetHitLog::getTargetType, targetType)
08c31209   姜超   feature(*): 考评详情
382
383
                  .eq(EvalGroupIndicatorTargetHitLog::getDataDate, userShop.getDataDate())
                  .eq(EvalGroupIndicatorTargetHitLog::getReferId, referId)
e79c21f9   姜超   feature(*): 计算计算修改
384
385
          );
          EvalGroupIndicatorTargetHitLog log = new EvalGroupIndicatorTargetHitLog();
08c31209   姜超   feature(*): 考评详情
386
387
388
          log.setPoolId(userShop.getPoolId());
          log.setScopeType(userShop.getScopeType());
          log.setReferId(referId);
e79c21f9   姜超   feature(*): 计算计算修改
389
390
391
          log.setTargetType(targetType);
          log.setValue(value);
          log.setReachValue(reachValue);
e376b24c   姜超   feature(*): 修改个人考评
392
          log.setUseTarget(EvalUseTargetEnum.FIRST_TARGET);
08c31209   姜超   feature(*): 考评详情
393
394
          log.setDataDate(userShop.getDataDate());
          log.setGroupId(userShop.getGroupId());
e79c21f9   姜超   feature(*): 计算计算修改
395
396
397
398
399
400
401
402
          log.setYn(Boolean.TRUE);
          evalGroupIndicatorTargetHitLogService.save(log);
      }
  
      /**
       * 储存命中记录
       *
       * @param evalGroupIndicatorId
c06a04fb   姜超   feature(*): 考评指标详情
403
       * @param userShop
e79c21f9   姜超   feature(*): 计算计算修改
404
       */
c06a04fb   姜超   feature(*): 考评指标详情
405
406
      protected void saveParamHitLog(Long evalGroupIndicatorId, EvalGroupUserShop userShop,
                                     Consumer<EvalGroupIndicatorHitLog> consumer) {
e79c21f9   姜超   feature(*): 计算计算修改
407
408
          EvalGroupIndicatorHitLog hitLog = new EvalGroupIndicatorHitLog();
          hitLog.setEvalGroupIndicatorId(evalGroupIndicatorId);
08c31209   姜超   feature(*): 考评详情
409
          hitLog.setPoolId(userShop.getPoolId());
c06a04fb   姜超   feature(*): 考评指标详情
410
411
412
          hitLog.setScopeType(userShop.getScopeType());
          hitLog.setDataDate(userShop.getDataDate());
          hitLog.setGroupId(userShop.getGroupId());
e79c21f9   姜超   feature(*): 计算计算修改
413
          hitLog.setYn(Boolean.TRUE);
c06a04fb   姜超   feature(*): 考评指标详情
414
415
416
          if (consumer != null) {
              consumer.accept(hitLog);
          }
e79c21f9   姜超   feature(*): 计算计算修改
417
418
419
420
          evalGroupIndicatorHitLogService.saveUnique(hitLog);
      }
  
  }