|
|
@@ -450,4 +450,57 @@ public class EmployeePortraitServiceImpl implements IEmployeePortraitService {
|
|
450
|
450
|
default: return v;
|
|
451
|
451
|
}
|
|
452
|
452
|
}
|
|
|
453
|
+
|
|
|
454
|
+ @Override
|
|
|
455
|
+ public BigDecimal getPortraitTotalScore(String personName, String beginTime, String endTime) {
|
|
|
456
|
+ // 加载全部事件,按姓名 LIKE 过滤(支持逗号分隔多人)
|
|
|
457
|
+ ScoreEvent eventQuery = new ScoreEvent();
|
|
|
458
|
+ eventQuery.setPersonName(personName);
|
|
|
459
|
+ if (beginTime != null && !beginTime.isEmpty()) {
|
|
|
460
|
+ eventQuery.getParams().put("beginTime", beginTime);
|
|
|
461
|
+ }
|
|
|
462
|
+ if (endTime != null && !endTime.isEmpty()) {
|
|
|
463
|
+ eventQuery.getParams().put("endTime", endTime);
|
|
|
464
|
+ }
|
|
|
465
|
+ List<ScoreEvent> events = scoreEventMapper.selectList(eventQuery);
|
|
|
466
|
+
|
|
|
467
|
+ // 精确匹配(防止逗号多人字段的误匹配)
|
|
|
468
|
+ Map<Long, BigDecimal> dimMap = new HashMap<>();
|
|
|
469
|
+ for (ScoreEvent e : events) {
|
|
|
470
|
+ Long dimId = e.getDimensionId();
|
|
|
471
|
+ if (dimId == null) continue;
|
|
|
472
|
+ String raw = e.getPersonName();
|
|
|
473
|
+ if (raw == null) continue;
|
|
|
474
|
+ boolean matched = false;
|
|
|
475
|
+ for (String n : raw.split("[,,]")) {
|
|
|
476
|
+ if (personName.equals(n.trim())) {
|
|
|
477
|
+ matched = true;
|
|
|
478
|
+ break;
|
|
|
479
|
+ }
|
|
|
480
|
+ }
|
|
|
481
|
+ if (!matched) continue;
|
|
|
482
|
+ BigDecimal val = e.getTotalScore() != null ? e.getTotalScore() : BigDecimal.ZERO;
|
|
|
483
|
+ dimMap.merge(dimId, val, BigDecimal::add);
|
|
|
484
|
+ }
|
|
|
485
|
+
|
|
|
486
|
+ // 加载维度定义
|
|
|
487
|
+ ScoreDimension dq = new ScoreDimension();
|
|
|
488
|
+ dq.setStatus("0");
|
|
|
489
|
+ dq.setOrg(ScoreLevelEnum.PERSON.getCode());
|
|
|
490
|
+ List<ScoreDimension> dims = scoreDimensionMapper.selectList(dq);
|
|
|
491
|
+ dims.sort(Comparator.comparing(d -> d.getSortOrder() == null ? 999 : d.getSortOrder()));
|
|
|
492
|
+
|
|
|
493
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
494
|
+ for (ScoreDimension dim : dims) {
|
|
|
495
|
+ BigDecimal eventScore = dimMap.getOrDefault(dim.getId(), BigDecimal.ZERO);
|
|
|
496
|
+ BigDecimal base = dim.getBaseScore() != null ? dim.getBaseScore() : BigDecimal.valueOf(80);
|
|
|
497
|
+ BigDecimal dimScore = base.add(eventScore);
|
|
|
498
|
+ BigDecimal weight = dim.getWeight() != null ? dim.getWeight() : BigDecimal.ZERO;
|
|
|
499
|
+ BigDecimal contribution = dimScore.multiply(weight)
|
|
|
500
|
+ .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
|
|
501
|
+ total = total.add(contribution);
|
|
|
502
|
+ }
|
|
|
503
|
+
|
|
|
504
|
+ return total.setScale(1, RoundingMode.HALF_UP);
|
|
|
505
|
+ }
|
|
453
|
506
|
}
|