|
|
|
|
@ -1,13 +1,12 @@
|
|
|
|
|
package com.biutag.supervision.controller.sensitiveperception; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.date.DateUnit; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.biutag.supervision.constants.enums.BusinessTypeEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.InspectCaseEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.PersonTypeEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.ProblemSourcesEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.*; |
|
|
|
|
import com.biutag.supervision.mapper.ProfileDepartMapper; |
|
|
|
|
import com.biutag.supervision.pojo.Result; |
|
|
|
|
import com.biutag.supervision.pojo.domain.ProfileDepart; |
|
|
|
|
@ -16,6 +15,7 @@ import com.biutag.supervision.pojo.dto.common.PieItem;
|
|
|
|
|
import com.biutag.supervision.pojo.entity.*; |
|
|
|
|
import com.biutag.supervision.pojo.model.DepartNegativeModel; |
|
|
|
|
import com.biutag.supervision.pojo.param.DepartNegativeQueryParam; |
|
|
|
|
import com.biutag.supervision.pojo.vo.NegativeProfile; |
|
|
|
|
import com.biutag.supervision.service.*; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
@ -47,10 +47,11 @@ public class ProfileDepartController {
|
|
|
|
|
private final SupPoliceService policeService; |
|
|
|
|
private final NegativeService negativeService; |
|
|
|
|
private final BusinessDepartService businessDepartService; |
|
|
|
|
private final NegativeScoreService negativeScoreService; |
|
|
|
|
|
|
|
|
|
private final NegativeScoreDepartService negativeScoreDepartService; |
|
|
|
|
private final NegativeProblemRelationService negativeProblemRelationService; |
|
|
|
|
private final SupDepartPoliceSizeService departPoliceSizeService; |
|
|
|
|
private final NegativeBlameService blameService; |
|
|
|
|
|
|
|
|
|
@GetMapping |
|
|
|
|
public Result<Page<DepartNegativeModel>> list(DepartNegativeQueryParam param) { |
|
|
|
|
@ -74,6 +75,7 @@ public class ProfileDepartController {
|
|
|
|
|
endTime = new Date(); |
|
|
|
|
} |
|
|
|
|
ProfileDepart profileDepart = new ProfileDepart(); |
|
|
|
|
profileDepart.setDays(DateUtil.between(beginTime, endTime, DateUnit.DAY)); |
|
|
|
|
SupDepart depart = departService.getById(departId); |
|
|
|
|
profileDepart.getDepartInfo() |
|
|
|
|
.setName(depart.getShortName()) |
|
|
|
|
@ -88,6 +90,10 @@ public class ProfileDepartController {
|
|
|
|
|
.between(NegativeScoreDepart::getDiscoveryTime, beginTime, endTime)); |
|
|
|
|
|
|
|
|
|
List<String> negativeIds = list.stream().map(NegativeScoreDepart::getNegativeId).toList(); |
|
|
|
|
SupDepartPoliceSize policeSize = departPoliceSizeService.getById(departId); |
|
|
|
|
profileDepart.getDepartInfo().setPoliceSize(policeSize.getPoliceSize()); |
|
|
|
|
profileDepart.getDepartInfo().setAuxSize(policeSize.getAuxSize()); |
|
|
|
|
|
|
|
|
|
if (negativeIds.isEmpty()) { |
|
|
|
|
return Result.success(profileDepart); |
|
|
|
|
} |
|
|
|
|
@ -132,28 +138,32 @@ public class ProfileDepartController {
|
|
|
|
|
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(); |
|
|
|
|
profileDepart.setBusinessTypeList(businessTypeList); |
|
|
|
|
// 问题涉及方面
|
|
|
|
|
List<NegativeProblemRelation> negativeProblemRelations = negativeProblemRelationService.list(new LambdaQueryWrapper<NegativeProblemRelation>().in(NegativeProblemRelation::getNegativeId, negativeIds)); |
|
|
|
|
Map<String, List<NegativeProblemRelation>> problemGroup = negativeProblemRelations.stream().collect(Collectors.groupingBy(NegativeProblemRelation::getOneLevelContent)); |
|
|
|
|
List<PieItem> problemTypeList = problemGroup.keySet().stream().map(key -> new PieItem(key, problemGroup.get(key).size())).sorted(Comparator.comparing(PieItem::getValue).reversed()).toList(); |
|
|
|
|
profileDepart.setProblemTypeList(problemTypeList); |
|
|
|
|
// 个人问题排名
|
|
|
|
|
List<BarItem> policeBarList = profileDepartMapper.selectPoliceNegativeCount(departId, beginTime, endTime); |
|
|
|
|
List<NegativeBlame> blames = blameService.list(new LambdaQueryWrapper<NegativeBlame>().in(NegativeBlame::getNegativeId, negativeIds).eq(NegativeBlame::getType, BlameType.personal.name())); |
|
|
|
|
Map<String, List<NegativeBlame>> policeGroup = blames.stream().collect(Collectors.groupingBy(NegativeBlame::getBlameEmpNo)); |
|
|
|
|
List<BarItem> policeBarList = policeGroup.keySet().stream().map(key -> { |
|
|
|
|
List<NegativeBlame> list1 = policeGroup.get(key); |
|
|
|
|
String blameName = list1.get(0).getBlameName(); |
|
|
|
|
return new BarItem(blameName, BigDecimal.valueOf(list1.size())); |
|
|
|
|
}).sorted(Comparator.comparing(BarItem::getValue).reversed()).toList(); |
|
|
|
|
profileDepart.setPoliceBarList(policeBarList); |
|
|
|
|
|
|
|
|
|
List<BarItem> problemTypeList = profileDepartMapper.selectProblemType(departId, beginTime, endTime); |
|
|
|
|
int max = problemTypeList.stream().mapToInt(item -> item.getValue().intValue()).max().getAsInt(); |
|
|
|
|
List<ProfileDepart.RadarIndicatorItem> problemTypeRadarIndicator = problemTypeList.stream().map(item -> { |
|
|
|
|
ProfileDepart.RadarIndicatorItem radarIndicatorItem = new ProfileDepart.RadarIndicatorItem(); |
|
|
|
|
radarIndicatorItem.setMax(max); |
|
|
|
|
radarIndicatorItem.setName(item.getLabel()); |
|
|
|
|
return radarIndicatorItem; |
|
|
|
|
}).toList(); |
|
|
|
|
profileDepart.setProblemTypeRadarIndicator(problemTypeRadarIndicator); |
|
|
|
|
List<Integer> problemTypeRadarData = problemTypeList.stream().map(item -> item.getValue().intValue()).toList(); |
|
|
|
|
profileDepart.setProblemTypeRadarData(problemTypeRadarData); |
|
|
|
|
// 问题涉及领导
|
|
|
|
|
Map<String, List<NegativeBlame>> policeLeadGroup = blames.stream().collect(Collectors.groupingBy(NegativeBlame::getLeadEmpNo)); |
|
|
|
|
List<BarItem> policeLeadBarList = policeLeadGroup.keySet().stream().map(key -> { |
|
|
|
|
List<NegativeBlame> list1 = policeLeadGroup.get(key); |
|
|
|
|
String name = list1.get(0).getLeadName(); |
|
|
|
|
return new BarItem(name, BigDecimal.valueOf(list1.size())); |
|
|
|
|
}).sorted(Comparator.comparing(BarItem::getValue).reversed()).toList(); |
|
|
|
|
profileDepart.setPoliceLeadBarList(policeLeadBarList); |
|
|
|
|
|
|
|
|
|
// 突出问题排名
|
|
|
|
|
List<NegativeProblemRelation> negativeProblemRelations = negativeProblemRelationService.list(new LambdaQueryWrapper<NegativeProblemRelation>().in(NegativeProblemRelation::getNegativeId, negativeIds)); |
|
|
|
|
Map<String, List<NegativeProblemRelation>> collect = negativeProblemRelations.stream().collect(Collectors.groupingBy(item -> item.getOneLevelContent() + " / " + item.getTwoLevelContent() + " / " + item.getThreeLevelContent())); |
|
|
|
|
List<BarItem> problemTypeBarList = collect.keySet().stream().map(key -> { |
|
|
|
|
return new BarItem(key, new BigDecimal(collect.get(key).size())); |
|
|
|
|
}).sorted(Comparator.comparing(BarItem::getValue).reversed()).toList(); |
|
|
|
|
List<BarItem> problemTypeBarList = collect.keySet().stream().map(key -> new BarItem(key, new BigDecimal(collect.get(key).size()))).sorted(Comparator.comparing(BarItem::getValue).reversed()).toList(); |
|
|
|
|
profileDepart.setProblemTypeBarList(problemTypeBarList); |
|
|
|
|
|
|
|
|
|
//List<Object> result = negativeScoreService.calculateDepartScore(beginTime, endTime, departId);
|
|
|
|
|
@ -161,6 +171,15 @@ public class ProfileDepartController {
|
|
|
|
|
profileDepart.setScore(BigDecimal.valueOf(list.stream().mapToDouble(NegativeScoreDepart::getScore).sum())); |
|
|
|
|
// profileDepart.setExpression(result.get(1).toString());
|
|
|
|
|
// profileDepart.setRemarks(result.get(2).toString());
|
|
|
|
|
List<NegativeProfile> negativeProfiles = negatives.stream().map(item -> { |
|
|
|
|
NegativeProfile negativeProfile = new NegativeProfile(); |
|
|
|
|
BeanUtil.copyProperties(item, negativeProfile); |
|
|
|
|
String problemType = negativeProblemRelations.stream().filter(p -> item.getId().equals(p.getNegativeId())).findFirst().map(p -> p.getOneLevelContent() + " / " + p.getTwoLevelContent() + " / " + p.getThreeLevelContent()).orElse(""); |
|
|
|
|
negativeProfile.setProblemType(problemType); |
|
|
|
|
negativeProfile.setScore(list.stream().filter(s -> item.getId().equals(s.getNegativeId())).findFirst().map(NegativeScoreDepart::getScore).orElse(null)); |
|
|
|
|
return negativeProfile; |
|
|
|
|
}).toList(); |
|
|
|
|
profileDepart.setNegatives(negativeProfiles); |
|
|
|
|
return Result.success(profileDepart); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|