diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java index 2555457..752870a 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java @@ -28,17 +28,17 @@ public interface NegativeBlameMapper extends BaseMapper { @Select(" SELECT blameIdCode, blameName, count(1) as number FROM `negative_blame` " + - " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode = '1' " + + " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode = '1' and crt_time > '2024-01-01 00:00:00' " + " GROUP BY blameIdCode order by number desc limit 10") List statisticsBlame(); @Select(" SELECT blameIdCode, blameName, count(1) as number FROM `negative_blame` " + - " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode != '1' " + + " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode != '1' and crt_time > '2024-01-01 00:00:00' " + " GROUP BY blameIdCode order by number desc limit 10") List statisticsBlame2(); - @Select(" SELECT leadIdCode as blameIdCode, leadName as blameName, count(1) as number FROM `negative_blame` " + - " where leadIdCode is not null and LENGTH(leadIdCode) > 0 " + + @Select(" SELECT leadIdCode, leadName as blameName, count(distinct blameIdCode) as number FROM `negative_blame` " + + " where leadIdCode is not null and LENGTH(leadIdCode) > 0 and crt_time > '2024-01-01 00:00:00'" + " GROUP BY leadIdCode order by number desc limit 10") List statisticsBlame3(); } diff --git a/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java b/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java index 369ca6f..6e779a1 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java @@ -24,6 +24,8 @@ public class BlamePerson implements Serializable { String blameIdCode; + String leadIdCode; + String blameName; Integer number; diff --git a/src/main/java/com/biutag/supervision/service/ProblemSourceService.java b/src/main/java/com/biutag/supervision/service/ProblemSourceService.java index a924ff6..14c72fb 100644 --- a/src/main/java/com/biutag/supervision/service/ProblemSourceService.java +++ b/src/main/java/com/biutag/supervision/service/ProblemSourceService.java @@ -49,10 +49,12 @@ public class ProblemSourceService { CompletableFuture.allOf( CompletableFutureUtil.runSyncObject(() -> build.aTotal(businessDepartMapper.problemSum(List.of(1, 2), "2024-01-01 00:00:00"))), CompletableFutureUtil.runSyncObject(() -> build.caseTotal(businessDepartMapper.problemSum(List.of(4, 5, 6), "2024-01-01 00:00:00"))), - CompletableFutureUtil.runSyncObject(() -> build.negativeTotal(negativeMapper.selectCount(new LambdaQueryWrapper().in(Negative::getCheckStatus, List.of(1, 2))).intValue())) + CompletableFutureUtil.runSyncObject(() -> build.negativeTotal(negativeMapper.selectCount(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2)).ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0))).intValue())) ).join(); List list = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getBlameIdCode) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getBlameIdCode)); Long count = list.stream().map(NegativeBlame::getBlameIdCode).distinct().count(); build.peopleCount(count.intValue()); @@ -63,40 +65,6 @@ public class ProblemSourceService { private final SupDepartMapper supDepartMapper; - /** - * @param type 类型 1- 风险值 2- 问题数 3-问题发生率 - * @param businessType - */ - public void rankStatistics(Integer type, Integer businessType) { - List departs = supDepartMapper.selectList(new LambdaQueryWrapper() - .select(SupDepart::getId, SupDepart::getPid, SupDepart::getName, SupDepart::getLevel)); - Map departMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue)); - - List negatives = negativeMapper.selectList(new LambdaQueryWrapper() - .in(Negative::getCheckStatus, List.of(1, 2))); - - Map mapLevel3 = new HashMap<>(); - Map mapLevel2 = new HashMap<>(); - - for (Negative negative : negatives) { - SupDepart depart = departMap.get(negative.getInvolveDepartId()); - if (depart == null) { - continue; - } - if (depart.getLevel() == 3) { - Integer count = Optional.ofNullable(mapLevel3.get(negative.getInvolveDepartId())).orElse(0); - count++; - mapLevel3.put(negative.getInvolveDepartId(), count); - depart = departMap.get(depart.getPid()); - } - if (depart.getLevel() == 2) { - Integer count = Optional.ofNullable(mapLevel2.get(negative.getInvolveDepartId())).orElse(0); - count++; - mapLevel2.put(negative.getInvolveDepartId(), count); - } - } - } - private final StatisticsGroupMapper statisticsGroupMapper; private final StatisticsDepartMapper departMapper; @@ -104,7 +72,7 @@ public class ProblemSourceService { public List statisticsGroupRank() { StatisticsGroup group = statisticsGroupMapper .selectOne(new LambdaQueryWrapper() - .eq(StatisticsGroup::getName, "交警大队").last("limit 1")); + .eq(StatisticsGroup::getName, "交警大队").last("limit 1")); List list = departMapper.selectList(new LambdaQueryWrapper() .eq(StatisticsDepart::getLevel, 3) @@ -113,6 +81,7 @@ public class ProblemSourceService { Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .in(Negative::getCheckStatus, List.of(1, 2))); Map mapLevel3 = new HashMap<>(); for (Negative negative : negatives) { @@ -131,8 +100,8 @@ public class ProblemSourceService { vo.add(v); } vo.sort(Comparator.comparing(RiskStatisticsVo::getValue, Comparator.reverseOrder())); - if(vo.size() > 10) { - return vo.subList(0,10); + if (vo.size() > 10) { + return vo.subList(0, 10); } return vo; } @@ -151,6 +120,7 @@ public class ProblemSourceService { Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .in(Negative::getCheckStatus, List.of(1, 2))); Map mapLevel3 = new HashMap<>(); for (Negative negative : negatives) { @@ -169,8 +139,8 @@ public class ProblemSourceService { vo.add(v); } vo.sort(Comparator.comparing(RiskStatisticsVo::getValue, Comparator.reverseOrder())); - if(vo.size() > 10) { - return vo.subList(0,10); + if (vo.size() > 10) { + return vo.subList(0, 10); } return vo; } @@ -191,6 +161,7 @@ public class ProblemSourceService { Map areaMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue)); List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .in(Negative::getCheckStatus, List.of(1, 2))); Map mapLevel3 = new HashMap<>(); for (Negative negative : negatives) { @@ -242,6 +213,7 @@ public class ProblemSourceService { Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .in(Negative::getCheckStatus, List.of(1, 2))); // *********问题数********** Map mapLevel3 = new HashMap<>(); @@ -259,13 +231,14 @@ public class ProblemSourceService { List tmp = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getBlameIdCode, NegativeBlame::getThreeLevelDapart) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getBlameIdCode) .isNotNull(NegativeBlame::getThreeLevelDapart)); for (NegativeBlame negativeBlame : tmp) { if (departMap.get(negativeBlame.getThreeLevelDapart()) == null) { continue; } - if(mapPerson.get(negativeBlame.getBlameIdCode()) != null) { + if (mapPerson.get(negativeBlame.getBlameIdCode()) != null) { continue; } Integer count = Optional.ofNullable(mapPeopleCount.get(negativeBlame.getThreeLevelDapart())).orElse(0); @@ -277,18 +250,19 @@ public class ProblemSourceService { List vo = new ArrayList<>(); for (Map.Entry entry : mapLevel3.entrySet()) { Integer humanCount = mapPeopleCount.get(entry.getKey()); - if(humanCount == null) continue; + if (humanCount == null) continue; RiskStatisticsVo v = new RiskStatisticsVo(); v.setName(departMap.get(entry.getKey()).getName().replaceFirst("湖南省长沙市公安局", "").replaceFirst("湖南省长沙市", "").replaceFirst("湖南省", "")); v.setScore(new BigDecimal(entry.getValue().toString()).divide(new BigDecimal(humanCount.toString()), 2, RoundingMode.UP).doubleValue()); vo.add(v); } vo.sort(Comparator.comparing(RiskStatisticsVo::getScore, Comparator.reverseOrder())); - if(vo.size() > 10) { - return vo.subList(0,10); + if (vo.size() > 10) { + return vo.subList(0, 10); } return vo; } + // 派出所 public List statisticsGroupRate2() { StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() @@ -301,6 +275,7 @@ public class ProblemSourceService { Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .in(Negative::getCheckStatus, List.of(1, 2))); Map mapLevel3 = new HashMap<>(); for (Negative negative : negatives) { @@ -317,13 +292,14 @@ public class ProblemSourceService { List tmp = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getBlameIdCode, NegativeBlame::getThreeLevelDapart) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getBlameIdCode) .isNotNull(NegativeBlame::getThreeLevelDapart)); for (NegativeBlame negativeBlame : tmp) { if (departMap.get(negativeBlame.getThreeLevelDapart()) == null) { continue; } - if(mapPerson.get(negativeBlame.getBlameIdCode()) != null) { + if (mapPerson.get(negativeBlame.getBlameIdCode()) != null) { continue; } Integer count = Optional.ofNullable(mapPeopleCount.get(negativeBlame.getThreeLevelDapart())).orElse(0); @@ -335,15 +311,15 @@ public class ProblemSourceService { List vo = new ArrayList<>(); for (Map.Entry entry : mapLevel3.entrySet()) { Integer humanCount = mapPeopleCount.get(entry.getKey()); - if(humanCount == null) continue; + if (humanCount == null) continue; RiskStatisticsVo v = new RiskStatisticsVo(); v.setName(departMap.get(entry.getKey()).getName().replaceFirst("湖南省长沙市公安局", "").replaceFirst("湖南省长沙市", "").replaceFirst("湖南省", "")); v.setScore(new BigDecimal(entry.getValue().toString()).divide(new BigDecimal(humanCount.toString()), 2, RoundingMode.UP).doubleValue()); vo.add(v); } vo.sort(Comparator.comparing(RiskStatisticsVo::getScore, Comparator.reverseOrder())); - if(vo.size() > 10) { - return vo.subList(0,10); + if (vo.size() > 10) { + return vo.subList(0, 10); } return vo; } @@ -364,6 +340,7 @@ public class ProblemSourceService { Map areaMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue)); List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .ge(Negative::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .in(Negative::getCheckStatus, List.of(1, 2))); Map mapLevel3 = new HashMap<>(); for (Negative negative : negatives) { @@ -385,6 +362,7 @@ public class ProblemSourceService { List tmp = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getBlameIdCode, NegativeBlame::getThreeLevelDapart) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getBlameIdCode) .isNotNull(NegativeBlame::getThreeLevelDapart)); for (NegativeBlame negativeBlame : tmp) { @@ -396,7 +374,7 @@ public class ProblemSourceService { if (area == null) { continue; } - if(mapPerson.get(negativeBlame.getBlameIdCode()) != null) { + if (mapPerson.get(negativeBlame.getBlameIdCode()) != null) { continue; } Integer count = Optional.ofNullable(mapPeopleCount.get(depart.getPid())).orElse(0); @@ -410,7 +388,7 @@ public class ProblemSourceService { List vo = new ArrayList<>(); for (Map.Entry entry : mapLevel3.entrySet()) { Integer humanCount = mapPeopleCount.get(entry.getKey()); - if(humanCount == null) continue; + if (humanCount == null) continue; RiskStatisticsVo v = new RiskStatisticsVo(); v.setName(areaMap.get(entry.getKey()).getName().replaceFirst("湖南省长沙市公安局", "").replaceFirst("湖南省长沙市", "").replaceFirst("湖南省", "")); v.setScore(new BigDecimal(entry.getValue().toString()).divide(new BigDecimal(humanCount.toString()), 2, RoundingMode.UP).doubleValue()); @@ -421,7 +399,6 @@ public class ProblemSourceService { } - List trans(List list) { List vo = new ArrayList<>(); for (BlamePerson blamePerson : list) { diff --git a/src/main/java/com/biutag/supervision/service/RiskStatisticsService.java b/src/main/java/com/biutag/supervision/service/RiskStatisticsService.java index b66c7a0..03f7cb3 100644 --- a/src/main/java/com/biutag/supervision/service/RiskStatisticsService.java +++ b/src/main/java/com/biutag/supervision/service/RiskStatisticsService.java @@ -10,6 +10,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -108,6 +109,7 @@ public class RiskStatisticsService { public List personStatistics() { List blames = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getBlameName, NegativeBlame::getBlameIdCode) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getBlameIdCode) .eq(NegativeBlame::getIvPersonTypeCode, "1")); Map blameMap = blames.stream().collect(Collectors.toMap(NegativeBlame::getBlameIdCode, Function.identity(), (oldValue, newValue) -> newValue)); @@ -130,6 +132,7 @@ public class RiskStatisticsService { public List personStatistics2() { List blames = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getBlameName, NegativeBlame::getBlameIdCode) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getBlameIdCode) .ne(NegativeBlame::getIvPersonTypeCode, "1")); Map blameMap = blames.stream().collect(Collectors.toMap(NegativeBlame::getBlameIdCode, Function.identity(), (oldValue, newValue) -> newValue)); @@ -152,6 +155,7 @@ public class RiskStatisticsService { public List leaderStatistics() { List blames = blameMapper.selectList(new LambdaQueryWrapper() .select(NegativeBlame::getLeadIdCode, NegativeBlame::getLeadName) + .ge(NegativeBlame::getCrtTime, LocalDateTime.of(2024, 1, 1, 0, 0, 0)) .isNotNull(NegativeBlame::getLeadIdCode) .ne(NegativeBlame::getIvPersonTypeCode, "1")); Map blameMap = blames.stream().collect(Collectors.toMap(NegativeBlame::getLeadIdCode, Function.identity(), (oldValue, newValue) -> newValue));