Blame view

fw-morax-service/src/main/java/cn/fw/morax/service/biz/calculator/eval/kpi/EvalKpiBaseCalculator.java 20.2 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
              }
9f48755c   姜超   feature(*): 门店奖惩审批修改
172
              //额外计算类型只能为空  或者  时间进度
29de1560   姜超   feature(*): 考评排名组...
173
              if (PublicUtil.isNotEmpty(extraTargetType) && (!TargetTypeEnum.NO.equals(extraTargetType))) {
e376b24c   姜超   feature(*): 修改个人考评
174
                  extraReachValue = calcTarget(param.getExtraTargetCalcType(), originValue, param.getExtraTargetValue());
9f48755c   姜超   feature(*): 门店奖惩审批修改
175
176
                  //只配置了时间进度  时间进度大于阶段目标 并且  时间进度大于1,取时间进度
                  if (PublicUtil.isEmpty(reachValue) || ((extraReachValue.compareTo(reachValue) > 0) && (extraReachValue.compareTo(BigDecimal.ONE) >= 0))) {
e376b24c   姜超   feature(*): 修改个人考评
177
178
                      indicatorValue = extraReachValue;
                      useTarget = EvalUseTargetEnum.EXTRA_TARGET;
e79c21f9   姜超   feature(*): 计算计算修改
179
                  }
e79c21f9   姜超   feature(*): 计算计算修改
180
              }
e376b24c   姜超   feature(*): 修改个人考评
181
182
183
184
185
186
              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(*): 考评排名组...
187
  
e79c21f9   姜超   feature(*): 计算计算修改
188
189
190
191
192
193
194
195
196
197
198
              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(*): 考评排名组...
199
200
201
       * 计算目标
       */
      public BigDecimal calcTarget(TargetCalcTypeEnum targetCalcType, BigDecimal indicatorValue, BigDecimal targetValue) {
bc484bc4   姜超   feature(*): 定时任务发送修改
202
203
204
          if (PublicUtil.isEmpty(targetValue) || BigDecimal.ZERO.compareTo(targetValue) == 0) {
              return BigDecimal.ZERO;
          }
7e7c92a1   姜超   feature(*): 考评排名组...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
         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(*): 计算计算修改
222
223
       * 查询指标值
       *
e79c21f9   姜超   feature(*): 计算计算修改
224
225
       * @return
       */
e1778851   姜超   feature(*): 计算考评调整
226
      protected Optional<BigDecimal> queryValue(EvalGroupUserShop obj, IndicatorCodeTypeEnum codeType, String indicatorCode) {
aaab7f45   姜超   feature(*): 考评指标计算
227
228
          DimensionTypeEnum dimensionType = EvalScopeEnum.STAFF.equals(obj.getScopeType()) ? DimensionTypeEnum.STAFF : DimensionTypeEnum.SHOP;
          if (IndicatorCodeTypeEnum.INDICATOR.equals(codeType)) {
9a6df217   姜超   feature(*): 修改个人考评
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
              //多阶段查询
              if (Boolean.TRUE.equals(obj.getMultiStage())) {
                  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());
                  if (EvalScopeEnum.STAFF.equals(obj.getScopeType())) {
                      queryWrapper.eq(IndicatorUserStageValue::getUserId, obj.getReferId());
                  } else {
                      queryWrapper.eq(IndicatorUserStageValue::getShopId, obj.getReferId());
                  }
                  IndicatorUserStageValue indicatorUserStageValue = indicatorUserStageValueService.getOne(queryWrapper, Boolean.FALSE);
                  return queryKpiIndicatorValue(indicatorUserStageValue);
              }
              //单阶段查询
              LambdaQueryWrapper<IndicatorUserValue> queryWrapper = Wrappers.<IndicatorUserValue>lambdaQuery()
                      .eq(IndicatorUserValue::getIndicatorCode, indicatorCode)
                      .eq(IndicatorUserValue::getDataDate, obj.getDataDate())
                      .eq(IndicatorUserValue::getDimensionType, dimensionType)
                      .eq(IndicatorUserValue::getYn, Boolean.TRUE)
                      .eq(IndicatorUserValue::getGroupId, obj.getGroupId());
aaab7f45   姜超   feature(*): 考评指标计算
253
              if (EvalScopeEnum.STAFF.equals(obj.getScopeType())) {
9a6df217   姜超   feature(*): 修改个人考评
254
                  queryWrapper.eq(IndicatorUserValue::getUserId, obj.getReferId());
aaab7f45   姜超   feature(*): 考评指标计算
255
              } else {
9a6df217   姜超   feature(*): 修改个人考评
256
                  queryWrapper.eq(IndicatorUserValue::getShopId, obj.getReferId());
aaab7f45   姜超   feature(*): 考评指标计算
257
              }
9a6df217   姜超   feature(*): 修改个人考评
258
259
              IndicatorUserValue indicatorUserValue = indicatorUserValueService.getOne(queryWrapper, Boolean.FALSE);
              return queryKpiIndicatorValue(indicatorUserValue);
aaab7f45   姜超   feature(*): 考评指标计算
260
261
          }
  
c06a04fb   姜超   feature(*): 考评指标详情
262
          EvalIndicatorValue evalIndicatorValue = evalIndicatorValueService.queryLastValue(obj.getReferId(),
f692be3a   姜超   feature(*): 查询修改
263
                  dimensionType, indicatorCode, obj.getDataDate());
aaab7f45   姜超   feature(*): 考评指标计算
264
          return Optional.ofNullable(evalIndicatorValue).map(EvalIndicatorValue::getIndicatorValue);
e79c21f9   姜超   feature(*): 计算计算修改
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
      }
  
      /**
       * 查询前置条件
       *
       * @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(*): 计算计算修改
297
298
       * 查询具体指标值
       *
80e64f6f   姜超   feature(*): 考评排名组...
299
       * @param indicatorUserStageValue
e1778851   姜超   feature(*): 计算考评调整
300
301
       * @return
       */
80e64f6f   姜超   feature(*): 考评排名组...
302
303
      protected Optional<BigDecimal> queryKpiIndicatorValue(IndicatorUserStageValue indicatorUserStageValue) {
          if (PublicUtil.isEmpty(indicatorUserStageValue) || PublicUtil.isEmpty(indicatorUserStageValue.getIndicatorValue())) {
e1778851   姜超   feature(*): 计算考评调整
304
305
306
307
              return Optional.empty();
          }
          BigDecimal value = BigDecimal.ZERO;
          try {
80e64f6f   姜超   feature(*): 考评排名组...
308
309
              JSONObject jsonObject = JSONObject.parseObject(indicatorUserStageValue.getIndicatorValue());
              value = Optional.ofNullable(jsonObject.getBigDecimal(indicatorUserStageValue.getIndicatorCode())).orElse(BigDecimal.ZERO);
e1778851   姜超   feature(*): 计算考评调整
310
          } catch (Exception e) {
80e64f6f   姜超   feature(*): 考评排名组...
311
              log.error("[{}]指标值转化失败", indicatorUserStageValue, e);
e1778851   姜超   feature(*): 计算考评调整
312
313
314
315
316
317
318
          }
          return Optional.of(value);
      }
  
      /**
       * 查询具体指标值
       *
e376b24c   姜超   feature(*): 修改个人考评
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
       * @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(*): 计算计算修改
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
       * @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(*): 考评详情
354
355
356
      protected void savePreconditionHitLog(EvalGroupUserShop userShop, Long preconditionId, Consumer<EvalGroupIndicatorPreconditionHitLog> consumer) {
          Long poolId = userShop.getPoolId();
          EvalScopeEnum evalScope = userShop.getScopeType();
e79c21f9   姜超   feature(*): 计算计算修改
357
358
  
          preconditionHitLogService.remove(Wrappers.<EvalGroupIndicatorPreconditionHitLog>lambdaQuery()
08c31209   姜超   feature(*): 考评详情
359
                  .eq(EvalGroupIndicatorPreconditionHitLog::getPoolId, poolId)
e79c21f9   姜超   feature(*): 计算计算修改
360
                  .eq(EvalGroupIndicatorPreconditionHitLog::getPreconditionId, preconditionId)
08c31209   姜超   feature(*): 考评详情
361
362
                  .eq(EvalGroupIndicatorPreconditionHitLog::getDataDate, userShop.getDataDate())
                  .eq(EvalGroupIndicatorPreconditionHitLog::getGroupId, userShop.getGroupId())
e79c21f9   姜超   feature(*): 计算计算修改
363
364
365
          );
          EvalGroupIndicatorPreconditionHitLog hitLog = new EvalGroupIndicatorPreconditionHitLog();
          hitLog.setPreconditionId(preconditionId);
08c31209   姜超   feature(*): 考评详情
366
          hitLog.setPoolId(poolId);
e79c21f9   姜超   feature(*): 计算计算修改
367
          hitLog.setScopeType(evalScope);
08c31209   姜超   feature(*): 考评详情
368
369
          hitLog.setDataDate(userShop.getDataDate());
          hitLog.setGroupId(userShop.getGroupId());
e79c21f9   姜超   feature(*): 计算计算修改
370
371
372
373
374
375
          if (consumer != null) {
              consumer.accept(hitLog);
          }
          preconditionHitLogService.save(hitLog);
      }
  
e376b24c   姜超   feature(*): 修改个人考评
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
      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(*): 考评详情
395
      protected void saveTargetHitLog(EvalGroupUserShop userShop, Long referId, IndicatorTypeEnum targetType, BigDecimal value, BigDecimal reachValue) {
e79c21f9   姜超   feature(*): 计算计算修改
396
          evalGroupIndicatorTargetHitLogService.remove(Wrappers.<EvalGroupIndicatorTargetHitLog>lambdaQuery()
08c31209   姜超   feature(*): 考评详情
397
398
                  .eq(EvalGroupIndicatorTargetHitLog::getPoolId, userShop.getPoolId())
                  .eq(EvalGroupIndicatorTargetHitLog::getScopeType, userShop.getScopeType())
e79c21f9   姜超   feature(*): 计算计算修改
399
                  .eq(EvalGroupIndicatorTargetHitLog::getTargetType, targetType)
08c31209   姜超   feature(*): 考评详情
400
401
                  .eq(EvalGroupIndicatorTargetHitLog::getDataDate, userShop.getDataDate())
                  .eq(EvalGroupIndicatorTargetHitLog::getReferId, referId)
e79c21f9   姜超   feature(*): 计算计算修改
402
403
          );
          EvalGroupIndicatorTargetHitLog log = new EvalGroupIndicatorTargetHitLog();
08c31209   姜超   feature(*): 考评详情
404
405
406
          log.setPoolId(userShop.getPoolId());
          log.setScopeType(userShop.getScopeType());
          log.setReferId(referId);
e79c21f9   姜超   feature(*): 计算计算修改
407
408
409
          log.setTargetType(targetType);
          log.setValue(value);
          log.setReachValue(reachValue);
e376b24c   姜超   feature(*): 修改个人考评
410
          log.setUseTarget(EvalUseTargetEnum.FIRST_TARGET);
08c31209   姜超   feature(*): 考评详情
411
412
          log.setDataDate(userShop.getDataDate());
          log.setGroupId(userShop.getGroupId());
e79c21f9   姜超   feature(*): 计算计算修改
413
414
415
416
417
418
419
420
          log.setYn(Boolean.TRUE);
          evalGroupIndicatorTargetHitLogService.save(log);
      }
  
      /**
       * 储存命中记录
       *
       * @param evalGroupIndicatorId
c06a04fb   姜超   feature(*): 考评指标详情
421
       * @param userShop
e79c21f9   姜超   feature(*): 计算计算修改
422
       */
c06a04fb   姜超   feature(*): 考评指标详情
423
424
      protected void saveParamHitLog(Long evalGroupIndicatorId, EvalGroupUserShop userShop,
                                     Consumer<EvalGroupIndicatorHitLog> consumer) {
e79c21f9   姜超   feature(*): 计算计算修改
425
426
          EvalGroupIndicatorHitLog hitLog = new EvalGroupIndicatorHitLog();
          hitLog.setEvalGroupIndicatorId(evalGroupIndicatorId);
08c31209   姜超   feature(*): 考评详情
427
          hitLog.setPoolId(userShop.getPoolId());
c06a04fb   姜超   feature(*): 考评指标详情
428
429
430
          hitLog.setScopeType(userShop.getScopeType());
          hitLog.setDataDate(userShop.getDataDate());
          hitLog.setGroupId(userShop.getGroupId());
e79c21f9   姜超   feature(*): 计算计算修改
431
          hitLog.setYn(Boolean.TRUE);
c06a04fb   姜超   feature(*): 考评指标详情
432
433
434
          if (consumer != null) {
              consumer.accept(hitLog);
          }
e79c21f9   姜超   feature(*): 计算计算修改
435
436
437
438
          evalGroupIndicatorHitLogService.saveUnique(hitLog);
      }
  
  }