|
|
|
|
@ -50,20 +50,30 @@ public class NegativeScoreService {
|
|
|
|
|
flag.set(true); |
|
|
|
|
System.out.println("calculateScore-------------------------------------------------"); |
|
|
|
|
List<NegativeBlame> negativeBlames = blameMapper.selectVerifyTrue(); |
|
|
|
|
if (negativeBlames.isEmpty()) { |
|
|
|
|
flag.set(false); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
String formula = "%s + (%s * %s) + (%s * %s)"; |
|
|
|
|
List<NegativeScoreDepart> scoreDeparts = new ArrayList<>(); |
|
|
|
|
negativeScorePoliceService.remove(new LambdaQueryWrapper<>()); |
|
|
|
|
negativeScoreDepartService.remove(new LambdaQueryWrapper<>()); |
|
|
|
|
Set<String> negativeIds = negativeBlames.stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet()); |
|
|
|
|
List<NegativeProblemRelation> problemsAll = problemRelationService.list(negativeIds); |
|
|
|
|
List<Negative> negatives = negativeService.listByIds(negativeIds); |
|
|
|
|
negativeBlames.forEach(blame -> { |
|
|
|
|
Negative negative = negativeService.getById(blame.getNegativeId()); |
|
|
|
|
Negative negative = negatives.stream().filter(item -> item.getId().equals(blame.getNegativeId())).findFirst().get(); |
|
|
|
|
SupDepart depart = departService.getById(negative.getInvolveDepartId()); |
|
|
|
|
NegativeScorePolice negativeScorePolice = new NegativeScorePolice() |
|
|
|
|
.setNegativeId(blame.getNegativeId()) |
|
|
|
|
.setIdCode(blame.getBlameIdCode()) |
|
|
|
|
.setDiscoveryTime(negative.getDiscoveryTime()) |
|
|
|
|
.setIdCode(blame.getBlameIdCode()) |
|
|
|
|
.setBusinessTypeCode(negative.getBusinessTypeCode()) |
|
|
|
|
.setDepartGroupId(depart.getStatisticsGroupId()) |
|
|
|
|
.setCreateTime(LocalDateTime.now()); |
|
|
|
|
List<NegativeProblemRelation> problems = problemRelationService.list(blame.getNegativeId(), blame.getBlameId()); |
|
|
|
|
List<NegativeProblemRelation> problems = problemsAll.stream().filter(item -> item.getNegativeId().equals(blame.getNegativeId()) && |
|
|
|
|
item.getBlameId().equals(blame.getBlameId())).toList(); |
|
|
|
|
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList(); |
|
|
|
|
if (codes.isEmpty()) { |
|
|
|
|
return; |
|
|
|
|
@ -83,6 +93,7 @@ public class NegativeScoreService {
|
|
|
|
|
double score = NumberUtil.roundHalfEven(calculate, 2).doubleValue(); |
|
|
|
|
negativeScorePolice.setScore(score) |
|
|
|
|
.setExpression(expression); |
|
|
|
|
|
|
|
|
|
negativeScorePoliceService.save(negativeScorePolice); |
|
|
|
|
NegativeScoreDepart scoreDepart = scoreDeparts.stream().filter(item -> item.getNegativeId().equals(negative.getId())).findFirst().orElse(null); |
|
|
|
|
if (Objects.isNull(scoreDepart)) { |
|
|
|
|
@ -187,6 +198,8 @@ public class NegativeScoreService {
|
|
|
|
|
return 50 + (diff * 15); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final SupDepartService departService; |
|
|
|
|
|
|
|
|
|
// 平均问题数 = 单个业务问题数 / 业务涉及人数
|
|
|
|
|
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
|
|
|
|
|
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
|
|
|
|
|
@ -203,9 +216,11 @@ public class NegativeScoreService {
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<Object> calculatePoliceScore(Date beginTime, Date endTime, String idCode) { |
|
|
|
|
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime); |
|
|
|
|
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum(); |
|
|
|
|
SupPolice police = policeService.getByIdCode(idCode); |
|
|
|
|
SupDepart depart = departService.getById(police.getOrgId()); |
|
|
|
|
|
|
|
|
|
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime, depart.getStatisticsGroupId()); |
|
|
|
|
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum(); |
|
|
|
|
List<String> expressionArr = new ArrayList<>(); |
|
|
|
|
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> { |
|
|
|
|
List<NegativeScorePolice> businessScorePolice = scorePolices.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList(); |
|
|
|
|
@ -251,7 +266,8 @@ public class NegativeScoreService {
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
public List<Object> calculateDepartScore(Date beginTime, Date endTime, String departId) { |
|
|
|
|
List<NegativeScoreDepart> scoreDeparts = negativeScoreDepartService.list(beginTime, endTime); |
|
|
|
|
SupDepart depart = departService.getById(departId); |
|
|
|
|
List<NegativeScoreDepart> scoreDeparts = negativeScoreDepartService.list(beginTime, endTime, depart.getStatisticsGroupId()); |
|
|
|
|
Double totalScore = scoreDeparts.stream().mapToDouble(NegativeScoreDepart::getScore).sum(); |
|
|
|
|
List<String> expressionArr = new ArrayList<>(); |
|
|
|
|
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> { |
|
|
|
|
|