diff --git a/src/main/java/com/biutag/supervision/controller/sensitiveperception/ProfileDepartController.java b/src/main/java/com/biutag/supervision/controller/sensitiveperception/ProfileDepartController.java index 49b97bb..b4a48a5 100644 --- a/src/main/java/com/biutag/supervision/controller/sensitiveperception/ProfileDepartController.java +++ b/src/main/java/com/biutag/supervision/controller/sensitiveperception/ProfileDepartController.java @@ -19,6 +19,7 @@ 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 dm.jdbc.util.StringUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.format.annotation.DateTimeFormat; @@ -151,41 +152,60 @@ public class ProfileDepartController { profileDepart.setProblemTypeList(problemTypeList); // 个人问题排名 List blames = blameService.list(new LambdaQueryWrapper().in(NegativeBlame::getNegativeId, negativeIds).eq(NegativeBlame::getType, BlameType.personal.name())); - Map> policeGroup = blames.stream().collect(Collectors.groupingBy(NegativeBlame::getBlameEmpNo)); - List policeBarList = policeGroup.keySet().stream().map(key -> { - List 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); - // 问题涉及领导 - Map> policeLeadGroup = blames.stream().collect(Collectors.groupingBy(NegativeBlame::getLeadEmpNo)); - List policeLeadBarList = policeLeadGroup.keySet().stream().map(key -> { - List 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); - - // 突出问题排名 - Map> collect = negativeProblemRelations.stream().collect(Collectors.groupingBy(item -> item.getOneLevelContent() + " / " + item.getTwoLevelContent() + " / " + item.getThreeLevelContent())); - List 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); + blames= blames.stream().filter(s-> StringUtil.isNotEmpty(s.getBlameEmpNo())).toList(); + if(CollectionUtil.isNotEmpty(blames)){ + Map> policeGroup = blames.stream().collect(Collectors.groupingBy(NegativeBlame::getBlameEmpNo)); + List policeBarList = policeGroup.keySet().stream().map(key -> { + List 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); + // 问题涉及领导 + Map> policeLeadGroup = blames.stream().collect(Collectors.groupingBy(NegativeBlame::getLeadEmpNo)); + List policeLeadBarList = policeLeadGroup.keySet().stream().map(key -> { + List 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); + }else{ + profileDepart.setPoliceBarList(new ArrayList<>()); + profileDepart.setPoliceLeadBarList(new ArrayList<>()); + } + + + if(CollectionUtil.isNotEmpty(negativeProblemRelations)){ + // 突出问题排名 + Map> collect = negativeProblemRelations.stream().collect(Collectors.groupingBy(item -> item.getOneLevelContent() + " / " + item.getTwoLevelContent() + " / " + item.getThreeLevelContent())); + List 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); + }else{ + profileDepart.setProblemTypeBarList(new ArrayList<>()); + } + //List result = negativeScoreService.calculateDepartScore(beginTime, endTime, departId); + if(CollectionUtil.isNotEmpty(list)){ + profileDepart.setScore(BigDecimal.valueOf(list.stream().mapToDouble(NegativeScoreDepart::getScore).sum())); + } - profileDepart.setScore(BigDecimal.valueOf(list.stream().mapToDouble(NegativeScoreDepart::getScore).sum())); // profileDepart.setExpression(result.get(1).toString()); // profileDepart.setRemarks(result.get(2).toString()); - List 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(negativeProblemRelationService::getProblemType).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); + if(CollectionUtil.isNotEmpty(negatives)){ + List 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(negativeProblemRelationService::getProblemType).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); + }else{ + profileDepart.setNegatives(new ArrayList<>()); + } + return Result.success(profileDepart); }