|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.biutag.supervision.controller.sensitivePerception; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
@ -13,9 +14,7 @@ import com.biutag.supervision.pojo.domain.ProfileDepart;
|
|
|
|
|
import com.biutag.supervision.pojo.domain.ProfilePolice; |
|
|
|
|
import com.biutag.supervision.pojo.dto.common.BarItem; |
|
|
|
|
import com.biutag.supervision.pojo.dto.common.PieItem; |
|
|
|
|
import com.biutag.supervision.pojo.entity.BusinessPolice; |
|
|
|
|
import com.biutag.supervision.pojo.entity.Negative; |
|
|
|
|
import com.biutag.supervision.pojo.entity.NegativeBlame; |
|
|
|
|
import com.biutag.supervision.pojo.entity.*; |
|
|
|
|
import com.biutag.supervision.pojo.model.PoliceNegativeModel; |
|
|
|
|
import com.biutag.supervision.pojo.param.DepartPoliceQueryParam; |
|
|
|
|
import com.biutag.supervision.service.*; |
|
|
|
|
@ -66,6 +65,9 @@ public class ProfilePoliceController {
|
|
|
|
|
return Result.success(page); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final NegativeScorePoliceService negativeScorePoliceService; |
|
|
|
|
private final NegativeProblemRelationService negativeProblemRelationService; |
|
|
|
|
|
|
|
|
|
@GetMapping("{idCode}") |
|
|
|
|
public Result<ProfilePolice> profile(@PathVariable String idCode, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) { |
|
|
|
|
if (Objects.isNull(beginTime)) { |
|
|
|
|
@ -77,6 +79,8 @@ public class ProfilePoliceController {
|
|
|
|
|
ProfilePolice profilePolice = new ProfilePolice(); |
|
|
|
|
profilePolice.setPoliceInfo(policeService.getByIdCode(idCode)); |
|
|
|
|
|
|
|
|
|
List<NegativeScorePolice> negatives = negativeScorePoliceService.list(new LambdaQueryWrapper<NegativeScorePolice>().between(NegativeScorePolice::getDiscoveryTime, beginTime, endTime).eq(NegativeScorePolice::getIdCode, idCode)); |
|
|
|
|
|
|
|
|
|
int jcj110BusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>() |
|
|
|
|
.between(BusinessPolice::getDate, beginTime, endTime) |
|
|
|
|
.eq(BusinessPolice::getBusinessType, BusinessTypeEnum.JCJ_110.getValue()) |
|
|
|
|
@ -84,12 +88,6 @@ public class ProfilePoliceController {
|
|
|
|
|
.eq(BusinessPolice::getPoliceName, profilePolice.getPoliceInfo().getName())) |
|
|
|
|
.stream().mapToInt(BusinessPolice::getNumber).sum(); |
|
|
|
|
|
|
|
|
|
Set<String> negativeIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>().eq(NegativeBlame::getBlameIdCode, idCode)).stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet()); |
|
|
|
|
int jcj110Size = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>() |
|
|
|
|
.between(Negative::getDiscoveryTime, beginTime, endTime) |
|
|
|
|
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_110.getValue()) |
|
|
|
|
.in(Negative::getId, negativeIds) |
|
|
|
|
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size(); |
|
|
|
|
int jcj122BusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>() |
|
|
|
|
.between(BusinessPolice::getDate, beginTime, endTime) |
|
|
|
|
.eq(BusinessPolice::getBusinessType, BusinessTypeEnum.JCJ_122.getValue()) |
|
|
|
|
@ -97,11 +95,6 @@ public class ProfilePoliceController {
|
|
|
|
|
.eq(BusinessPolice::getPoliceName, profilePolice.getPoliceInfo().getName())) |
|
|
|
|
.stream().mapToInt(BusinessPolice::getNumber).sum(); |
|
|
|
|
|
|
|
|
|
int jcj122Size = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>() |
|
|
|
|
.between(Negative::getDiscoveryTime, beginTime, endTime) |
|
|
|
|
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_122.getValue()) |
|
|
|
|
.in(Negative::getId, negativeIds) |
|
|
|
|
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size(); |
|
|
|
|
|
|
|
|
|
int zfbaBusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>() |
|
|
|
|
.between(BusinessPolice::getDate, beginTime, endTime) |
|
|
|
|
@ -109,46 +102,51 @@ public class ProfilePoliceController {
|
|
|
|
|
.eq(BusinessPolice::getEmpNo, profilePolice.getPoliceInfo().getEmpNo()) |
|
|
|
|
.eq(BusinessPolice::getPoliceName, profilePolice.getPoliceInfo().getName())) |
|
|
|
|
.stream().mapToInt(BusinessPolice::getNumber).sum(); |
|
|
|
|
int zfbaSize = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>() |
|
|
|
|
.between(Negative::getDiscoveryTime, beginTime, endTime) |
|
|
|
|
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.ZFBA.getValue()) |
|
|
|
|
.in(Negative::getId, negativeIds) |
|
|
|
|
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size(); |
|
|
|
|
profilePolice.getNegativeInfo().setJcj110BusinessSize(jcj110BusinessSize).setJcj110Size(jcj110Size) |
|
|
|
|
.setJcj122BusinessSize(jcj122BusinessSize).setJcj122Size(jcj122Size) |
|
|
|
|
.setZfbaBusinessSize(zfbaBusinessSize).setZfbaSize(zfbaSize); |
|
|
|
|
|
|
|
|
|
List<Negative> list = negativeIds.isEmpty() ? new ArrayList<>() : negativeService.list(new LambdaQueryWrapper<Negative>() |
|
|
|
|
.between(Negative::getDiscoveryTime, beginTime, endTime) |
|
|
|
|
.in(Negative::getId, negativeIds) |
|
|
|
|
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))); |
|
|
|
|
profilePolice.getNegativeInfo() |
|
|
|
|
.setScore(NumberUtil.round(negatives.stream().mapToDouble(NegativeScorePolice::getScore).sum(), 2).doubleValue()) |
|
|
|
|
.setJcj110BusinessSize(jcj110BusinessSize) |
|
|
|
|
.setSize(negatives.size()) |
|
|
|
|
.setJcj110Size(negatives.stream().filter(item -> BusinessTypeEnum.JCJ_110.getValue().equals(item.getBusinessTypeCode())).count()) |
|
|
|
|
.setJcj122BusinessSize(jcj122BusinessSize) |
|
|
|
|
.setJcj122Size(negatives.stream().filter(item -> BusinessTypeEnum.JCJ_122.getValue().equals(item.getBusinessTypeCode())).count()) |
|
|
|
|
.setZfbaBusinessSize(zfbaBusinessSize) |
|
|
|
|
.setZfbaSize(negatives.stream().filter(item -> BusinessTypeEnum.ZFBA.getValue().equals(item.getBusinessTypeCode())).count()); |
|
|
|
|
|
|
|
|
|
Set<String> negativeIds = negatives.stream().map(NegativeScorePolice::getNegativeId).collect(Collectors.toSet()); |
|
|
|
|
List<Negative> list = negatives.isEmpty() ? new ArrayList<>() : negativeService.list(new LambdaQueryWrapper<Negative>() |
|
|
|
|
.in(Negative::getId, negativeIds)); |
|
|
|
|
// 问题来源占比
|
|
|
|
|
Map<String, List<Negative>> problemSourcesGroup = list.stream().collect(Collectors.groupingBy(Negative::getProblemSourcesCode)); |
|
|
|
|
List<PieItem> problemSourcesList = problemSourcesGroup.keySet().stream().map(key -> new PieItem(Optional.ofNullable(ProblemSourcesEnum.get(key)).map(ProblemSourcesEnum::getLabel).orElse(key), |
|
|
|
|
List<PieItem> problemSourcesList = problemSourcesGroup.keySet().stream() |
|
|
|
|
.map(key -> new PieItem(Optional.ofNullable(ProblemSourcesEnum.get(key)).map(ProblemSourcesEnum::getLabel).orElse(key), |
|
|
|
|
problemSourcesGroup.get(key).size())).toList(); |
|
|
|
|
profilePolice.setProblemSourcesList(problemSourcesList); |
|
|
|
|
// 业务类型占比
|
|
|
|
|
Map<String, List<Negative>> businessTypeGroup = list.stream().collect(Collectors.groupingBy(Negative::getBusinessTypeCode)); |
|
|
|
|
List<PieItem> businessTypeList = businessTypeGroup.keySet().stream().map(key -> new PieItem(Optional.ofNullable(BusinessTypeEnum.get(key)).map(BusinessTypeEnum::getLabel).orElse(key) |
|
|
|
|
, businessTypeGroup.get(key).size())).toList(); |
|
|
|
|
profilePolice.setBusinessTypeList(businessTypeList); |
|
|
|
|
// 风险问题构成 雷达图
|
|
|
|
|
List<BarItem> problemTypeBarList = profilePoliceMapper.selectProblemType(idCode, beginTime, endTime); |
|
|
|
|
int max = problemTypeBarList.stream().mapToInt(BarItem::getValue).max().getAsInt(); |
|
|
|
|
List<ProfileDepart.RadarIndicatorItem> problemTypeRadarIndicator = problemTypeBarList.stream().map(item -> { |
|
|
|
|
ProfileDepart.RadarIndicatorItem radarIndicatorItem = new ProfileDepart.RadarIndicatorItem(); |
|
|
|
|
radarIndicatorItem.setMax(max); |
|
|
|
|
radarIndicatorItem.setName(item.getLabel()); |
|
|
|
|
return radarIndicatorItem; |
|
|
|
|
}).toList(); |
|
|
|
|
List<Integer> problemTypeRadarData = problemTypeBarList.stream().map(BarItem::getValue).toList(); |
|
|
|
|
profilePolice.setProblemTypeRadarIndicator(problemTypeRadarIndicator); |
|
|
|
|
profilePolice.setProblemTypeRadarData(problemTypeRadarData); |
|
|
|
|
// 问题类型占比
|
|
|
|
|
if (!negativeIds.isEmpty()) { |
|
|
|
|
List<String> blameIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>() |
|
|
|
|
.in(NegativeBlame::getNegativeId, negativeIds) |
|
|
|
|
.eq(NegativeBlame::getBlameIdCode, idCode)) |
|
|
|
|
.stream().map(NegativeBlame::getBlameId).toList(); |
|
|
|
|
if (!blameIds.isEmpty()) { |
|
|
|
|
List<NegativeProblemRelation> problemRelations = negativeProblemRelationService.list(new LambdaQueryWrapper<NegativeProblemRelation>() |
|
|
|
|
.in(NegativeProblemRelation::getBlameId, blameIds) |
|
|
|
|
.in(NegativeProblemRelation::getNegativeId, negativeIds)); |
|
|
|
|
Map<String, List<NegativeProblemRelation>> groups = problemRelations.stream().collect(Collectors.groupingBy(NegativeProblemRelation::getThreeLevelContent)); |
|
|
|
|
List<PieItem> problemTypeList = groups.keySet().stream().map(key -> new PieItem(key, groups.get(key).size())).toList(); |
|
|
|
|
profilePolice.setProblemTypeList(problemTypeList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Object> result = negativeScoreService.calculatePoliceScore(beginTime, endTime, idCode); |
|
|
|
|
profilePolice.setScore((BigDecimal) result.get(0)); |
|
|
|
|
profilePolice.setExpression(result.get(1).toString()); |
|
|
|
|
profilePolice.setRemarks(result.get(2).toString()); |
|
|
|
|
// 雷达图
|
|
|
|
|
profilePolice.setBusinessTypeRadarIndicator(Arrays.stream(BusinessTypeEnum.values()) |
|
|
|
|
.map(item -> new ProfileDepart.RadarIndicatorItem().setName(item.getLabel()).setMax(100)).toList()); |
|
|
|
|
profilePolice.setBusinessTypeScoreRadarData((List<Double>) result.get(3)); |
|
|
|
|
profilePolice.setBusinessTypeWeightRadarData((List<Double>) result.get(4)); |
|
|
|
|
return Result.success(profilePolice); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|