Browse Source

Merge remote-tracking branch 'origin/master'

main
sjh 1 year ago
parent
commit
f053518116
  1. 39
      src/main/java/com/biutag/supervision/constants/enums/BusinessTypeEnum.java
  2. 8
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java
  3. 50
      src/main/java/com/biutag/supervision/controller/work/NegativeController.java
  4. 3
      src/main/java/com/biutag/supervision/pojo/domain/ProfilePolice.java
  5. 3
      src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java
  6. 2
      src/main/java/com/biutag/supervision/service/BusinessPoliceService.java
  7. 2
      src/main/java/com/biutag/supervision/service/ModelClueService.java
  8. 9
      src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java
  9. 109
      src/main/java/com/biutag/supervision/service/ProfilePoliceService.java

39
src/main/java/com/biutag/supervision/constants/enums/BusinessTypeEnum.java

@ -7,20 +7,19 @@ import lombok.Getter;
@Getter
public enum BusinessTypeEnum {
JCJ_110("110接处警", "1", "110"),
JCJ_122("122接处警", "2", "122"),
RJCKFW("人境窗口服务", "3", "RJ"),
CJGFF("车驾管服务", "4", "CJG"),
JJCF("交警执法", "5", "JJ"),
ZFBA("执法办案", "6", "CF"),
ZXGZ("专项工作", "7", "ZX"),
ABWW("安保维稳", "8", "AB"),
JAFK("治安防控", "9", "ZA"),
XZGL("行政管理", "10", "XZ"),
FFJC("服务基层", "12", "FF"),
DWGL("队伍管理", "13", "DW"),
QT("其他", "14", "QT"),
;
JCJ_110("110接处警", "1", "110", true),
JCJ_122("122接处警", "2", "122", true),
RJCKFW("人境窗口服务", "3", "RJ", false),
CJGFF("车驾管服务", "4", "CJG", false),
JJCF("交警执法", "5", "JJ", false),
ZFBA("执法办案", "6", "CF", false),
ZXGZ("专项工作", "7", "ZX", false),
ABWW("安保维稳", "8", "AB", false),
JAFK("治安防控", "9", "ZA", false),
XZGL("行政管理", "10", "XZ", false),
FFJC("服务基层", "12", "FF", false),
DWGL("队伍管理", "13", "DW", false),
QT("其他", "14", "QT", false);
private String label;
@ -28,6 +27,8 @@ public enum BusinessTypeEnum {
private String key;
private Boolean businessVolume;
public static BusinessTypeEnum get(String value) {
for (BusinessTypeEnum businessTypeEnum : values()) {
if (businessTypeEnum.value.equals(value)) {
@ -36,4 +37,14 @@ public enum BusinessTypeEnum {
}
return null;
}
public static boolean isBusinessVolume(String value) {
for (BusinessTypeEnum businessTypeEnum : values()) {
if (businessTypeEnum.value.equals(value)) {
return businessTypeEnum.businessVolume;
}
}
return false;
}
}

8
src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java

@ -18,10 +18,7 @@ import com.biutag.supervision.pojo.entity.Negative;
import com.biutag.supervision.pojo.entity.NegativeBlame;
import com.biutag.supervision.pojo.model.PoliceNegativeModel;
import com.biutag.supervision.pojo.param.DepartPoliceQueryParam;
import com.biutag.supervision.service.BusinessPoliceService;
import com.biutag.supervision.service.NegativeBlameService;
import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.SupPoliceService;
import com.biutag.supervision.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
@ -44,6 +41,7 @@ import java.util.stream.Collectors;
@RestController
public class ProfilePoliceController {
private final ProfilePoliceService profilePoliceService;
private final ProfilePoliceMapper profilePoliceMapper;
private final SupPoliceService policeService;
@ -142,6 +140,8 @@ public class ProfilePoliceController {
List<Integer> problemTypeRadarData = problemTypeBarList.stream().map(BarItem::getValue).toList();
profilePolice.setProblemTypeRadarIndicator(problemTypeRadarIndicator);
profilePolice.setProblemTypeRadarData(problemTypeRadarData);
//
profilePolice.setScore(profilePoliceService.getPoliceScore(beginTime, endTime, idCode));
return Result.success(profilePolice);
}

50
src/main/java/com/biutag/supervision/controller/work/NegativeController.java

@ -121,32 +121,32 @@ public class NegativeController {
DepartNegativeRate rate = departNegativeRateService.get(negative.getInvolveDepartId(), month);
List<NegativeConfirmationCompletionVo.Blame> blames = blameService.list(id).stream().map(blame -> {
List<NegativeProblemRelation> problems = negativeProblemRelationService.list(id, blame.getBlameId());
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
if (codes.isEmpty()) {
throw new RuntimeException("数据异常");
}
SupDictProblemType problemType = supDictContentMapper.selectOneByMaxScore(codes);
NegativeConfirmationCompletionVo.Blame b = new NegativeConfirmationCompletionVo.Blame();
b.setProblems(problems);
b.setBlameId(blame.getBlameId());
b.setBlameName(blame.getBlameName());
b.setBlameEmpNo(blame.getBlameEmpNo());
b.setBlameIdCode(blame.getBlameIdCode());
b.setBaseScore(problemType.getScore());
int frequency = blameService.countByTrue(blame.getBlameIdCode(), problemType.getParentCode(), beginTime, endTime);
b.setFrequency(frequency);
b.setFrequencyScore(ScoreRule.getFrequencyScore(frequency));
if (Objects.nonNull(rate)) {
b.setIncidenceRate(rate.getIncidenceRate());
}
return b;
}).toList();
// List<NegativeConfirmationCompletionVo.Blame> blames = blameService.list(id).stream().map(blame -> {
// List<NegativeProblemRelation> problems = negativeProblemRelationService.list(id, blame.getBlameId());
// List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
// if (codes.isEmpty()) {
// throw new RuntimeException("数据异常");
// }
// SupDictProblemType problemType = supDictContentMapper.selectOneByMaxScore(codes);
//
// NegativeConfirmationCompletionVo.Blame b = new NegativeConfirmationCompletionVo.Blame();
// b.setProblems(problems);
// b.setBlameId(blame.getBlameId());
// b.setBlameName(blame.getBlameName());
// b.setBlameEmpNo(blame.getBlameEmpNo());
// b.setBlameIdCode(blame.getBlameIdCode());
// b.setBaseScore(problemType.getScore());
//
// int frequency = blameService.countByTrue(blame.getBlameIdCode(), problemType.getParentCode(), beginTime, endTime);
// b.setFrequency(frequency);
// b.setFrequencyScore(ScoreRule.getFrequencyScore(frequency));
// if (Objects.nonNull(rate)) {
// b.setIncidenceRate(rate.getIncidenceRate());
// }
// return b;
// }).toList();
NegativeConfirmationCompletionVo completionVo = new NegativeConfirmationCompletionVo();
completionVo.setBlames(blames);
// completionVo.setBlames(blames);
return Result.success(completionVo);
}

3
src/main/java/com/biutag/supervision/pojo/domain/ProfilePolice.java

@ -5,6 +5,7 @@ import com.biutag.supervision.pojo.entity.SupPolice;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -16,6 +17,8 @@ import java.util.List;
@Getter
public class ProfilePolice {
private BigDecimal score;
private SupPolice policeInfo = new SupPolice();
private NegativeInfo negativeInfo = new NegativeInfo();
private List<PieItem> problemSourcesList = new ArrayList<>();

3
src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java

@ -31,4 +31,7 @@ public class NegativeScorePolice {
// 计算公式
private String expression;
// 业务类型
private String businessTypeCode;
}

2
src/main/java/com/biutag/supervision/service/BusinessPoliceService.java

@ -427,4 +427,6 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
throw new RuntimeException("Error while hashing", e);
}
}
}

2
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -146,6 +146,8 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
negative.setProblemSources(ProblemSourcesEnum.LMGZ.getLabel());
negative.setProblemSourcesCode(ProblemSourcesEnum.LMGZ.getValue());
// TODO 业务类别 涉及问题
negative.setBusinessTypeCode(BusinessTypeEnum.QT.getValue());
negative.setBusinessTypeName(BusinessTypeEnum.QT.getLabel());
// 涉及单位
negative.setInvolveDepartId(item.getInvolveDepartId());
negative.setInvolveDepartName(item.getInvolveDepartName());

9
src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java

@ -2,10 +2,11 @@ package com.biutag.supervision.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.mapper.NegativeScorePoliceMapper;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
@ -15,4 +16,10 @@ public class NegativeScorePoliceService extends ServiceImpl<NegativeScorePoliceM
return list(new LambdaQueryWrapper<NegativeScorePolice>().eq(NegativeScorePolice::getNegativeId, negativeId));
}
public List<NegativeScorePolice> list(Date beginTime, Date endTime) {
return list(new LambdaQueryWrapper<NegativeScorePolice>()
.between(NegativeScorePolice::getDiscoveryTime, beginTime, endTime));
}
}

109
src/main/java/com/biutag/supervision/service/ProfilePoliceService.java

@ -0,0 +1,109 @@
package com.biutag.supervision.service;
import cn.hutool.core.util.NumberUtil;
import com.biutag.supervision.constants.enums.BusinessTypeEnum;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
* @author wxc
* @date 2024/11/11
*/
// 平均问题数 = 总问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
// 业务风险指数 = 50 + (业务差异值 * 15)
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
// 个人风险指数 = sum(业务风险指数 * 业务权重)
@RequiredArgsConstructor
@Service
public class ProfilePoliceService {
private final NegativeScorePoliceService negativeScorePoliceService;
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
public double getBusinessWeight(Double totalScore, List<NegativeScorePolice> businessScorePolice) {
if (totalScore == 0) {
return 0.0;
}
Double score = businessScorePolice.stream().mapToDouble(NegativeScorePolice::getScore).sum();
return NumberUtil.div(score, totalScore);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
public double getAvgNumber(int size, int policeSize) {
if (policeSize == 0) {
return 0;
}
return NumberUtil.div(size, policeSize);
}
// 业务标准差 = 根号(sum((个人问题数 - 平均问题数)²) / 业务涉及人数)
public double getSd(List<NegativeScorePolice> businessScorePolice, double avgNumber, int policeSize) {
if (policeSize == 0) {
return 0;
}
Map<String, List<NegativeScorePolice>> group = businessScorePolice.stream().collect(Collectors.groupingBy(NegativeScorePolice::getIdCode));
return Math.sqrt(group.values().stream().mapToDouble(val -> Math.pow(val.size() - avgNumber, 2)).sum() / policeSize);
}
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
public double getDiff(List<NegativeScorePolice> businessScorePolice, String idCode, double avgNumber, double sd) {
if (sd == 0) {
return 0;
}
long size = businessScorePolice.stream().filter(item -> idCode.equals(item.getIdCode())).count();
return NumberUtil.div(size - avgNumber, sd);
}
public double getBusinessScore(double diff) {
return 50 + (diff * 15);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
// 业务风险指数 = 50 + (业务差异值 * 15)
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
// 个人风险指数 = sum(业务风险指数 * 业务权重)
public BigDecimal getPoliceScore(Date beginTime, Date endTime, String idCode) {
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime);
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
List<NegativeScorePolice> businessScorePolice = scorePolices.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
// 业务涉及人数
int policeSize = businessScorePolice.stream().map(NegativeScorePolice::getIdCode).collect(Collectors.toSet()).size();
// 平均问题数
double avgNumber = getAvgNumber(businessScorePolice.size(), policeSize);
// 业务标准差
double sd = getSd(businessScorePolice, avgNumber, policeSize);
// 业务差异值
double diff = 0;
if (businessTypeEnum.getBusinessVolume()) {
} else {
diff = getDiff(businessScorePolice, idCode, avgNumber, sd);
}
// 业务风险指数
double businessScore = getBusinessScore(diff);
// 业务权重
double businessWeight = getBusinessWeight(totalScore, businessScorePolice);
return NumberUtil.mul(businessScore, businessWeight);
}).sum();
return NumberUtil.roundHalfEven(policeScore, 2);
}
}
Loading…
Cancel
Save