From 47df3eb1d15f4e21a88d6ba46d701ae6d545f3bb Mon Sep 17 00:00:00 2001 From: kami <605128600@qq.com> Date: Sat, 16 Nov 2024 17:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/NegativeBlameMapper.java | 16 ++ .../supervision/pojo/vo/BlamePerson.java | 30 ++++ .../service/ProblemSourceService.java | 151 +++++++++++++++--- 3 files changed, 178 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java index 6e01d25..f654551 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java @@ -2,6 +2,7 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.supervision.pojo.entity.NegativeBlame; +import com.biutag.supervision.pojo.vo.BlamePerson; import org.apache.ibatis.annotations.Select; import java.time.LocalDateTime; @@ -25,4 +26,19 @@ public interface NegativeBlameMapper extends BaseMapper { "where n.checkStatus in ('1', '2') and n.processing_status = 'completed' and pr.threeLevelCode is not null") List selectVerifyTrue(); + + @Select(" SELECT blameIdCode, blameName, count(1) as number FROM `negative_blame` " + + " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode = 1 " + + " 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 " + + " 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 " + + " 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 new file mode 100644 index 0000000..369ca6f --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java @@ -0,0 +1,30 @@ +package com.biutag.supervision.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; + +/** + * @author kami on 2024-11-16 17:28:03 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@Builder +@Slf4j +@AllArgsConstructor +@NoArgsConstructor(force = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BlamePerson implements Serializable { + + String blameIdCode; + + 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 c725928..9ed34b3 100644 --- a/src/main/java/com/biutag/supervision/service/ProblemSourceService.java +++ b/src/main/java/com/biutag/supervision/service/ProblemSourceService.java @@ -1,14 +1,9 @@ package com.biutag.supervision.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.biutag.supervision.mapper.BusinessDepartMapper; -import com.biutag.supervision.mapper.NegativeBlameMapper; -import com.biutag.supervision.mapper.NegativeMapper; -import com.biutag.supervision.mapper.SupDepartMapper; -import com.biutag.supervision.pojo.entity.BusinessDepart; -import com.biutag.supervision.pojo.entity.Negative; -import com.biutag.supervision.pojo.entity.NegativeBlame; -import com.biutag.supervision.pojo.entity.SupDepart; +import com.biutag.supervision.mapper.*; +import com.biutag.supervision.pojo.entity.*; +import com.biutag.supervision.pojo.vo.BlamePerson; import com.biutag.supervision.pojo.vo.ProblemSourceStatisticsVo; import com.biutag.supervision.pojo.vo.ProblemSourceVo; import com.biutag.supervision.util.CompletableUtils.CompletableFutureUtil; @@ -27,6 +22,7 @@ import java.util.stream.Collectors; /** * 灵敏感知大屏 + * * @author kami on 2024-11-16 15:04:16 * @version 0.0.1 * @since 1.8 @@ -44,14 +40,15 @@ public class ProblemSourceService { /** * 数量统计 + * * @return 统计结构 */ public ProblemSourceStatisticsVo totalStatistics() { ProblemSourceStatisticsVo.ProblemSourceStatisticsVoBuilder build = ProblemSourceStatisticsVo.builder(); 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.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())) ).join(); List list = blameMapper.selectList(new LambdaQueryWrapper().select(NegativeBlame::getBlameIdCode)); Long count = list.stream().map(NegativeBlame::getBlameIdCode).distinct().count(); @@ -64,39 +61,155 @@ public class ProblemSourceService { private final SupDepartMapper supDepartMapper; /** - * - * @param type 类型 1- 风险值 2- 问题数 3-问题发生率 + * @param type 类型 1- 风险值 2- 问题数 3-问题发生率 * @param businessType */ public void rankStatistics(Integer type, Integer businessType) { - List departs = supDepartMapper.selectList(new LambdaQueryWrapper() + 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)); + 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))); + .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) { + if (depart == null) { continue; } - if(depart.getLevel() == 3) { + 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) { + 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; + + public void statisticsGroupRank() { + StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() + .eq(StatisticsGroup::getName, "交警大队").last("limit 1")); + + List list = departMapper.selectList(new LambdaQueryWrapper() + .eq(StatisticsDepart::getLevel, 3) + .eq(StatisticsDepart::getGroupId, group.getGroupId())); + + Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); + + List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2))); + Map mapLevel3 = new HashMap<>(); + for (Negative negative : negatives) { + if (departMap.get(negative.getInvolveDepartId()) == null) { + continue; + } + Integer count = Optional.ofNullable(mapLevel3.get(negative.getInvolveDepartId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + } + for (Map.Entry entry : mapLevel3.entrySet()) { + log.info("机构:{} | {}", departMap.get(entry.getKey()).getName(), entry.getValue()); + } + } + + /** + * 派出所 + */ + public void statisticsGroupRank2() { + StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() + .eq(StatisticsGroup::getName, "派出所").last("limit 1")); + + List list = departMapper.selectList(new LambdaQueryWrapper() + .eq(StatisticsDepart::getLevel, 3) + .eq(StatisticsDepart::getGroupId, group.getGroupId())); + + Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); + + List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2))); + Map mapLevel3 = new HashMap<>(); + for (Negative negative : negatives) { + if (departMap.get(negative.getInvolveDepartId()) == null) { + continue; + } + Integer count = Optional.ofNullable(mapLevel3.get(negative.getInvolveDepartId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + } + for (Map.Entry entry : mapLevel3.entrySet()) { + log.info("机构:{} | {}", departMap.get(entry.getKey()).getName(), entry.getValue()); + } + } + + // 分县 + public void statisticsGroupRank3() { + StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() + .eq(StatisticsGroup::getName, "派出所").last("limit 1")); + + List list = departMapper.selectList(new LambdaQueryWrapper() + .eq(StatisticsDepart::getLevel, 3) + .eq(StatisticsDepart::getGroupId, group.getGroupId())); + Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); + + List departs = supDepartMapper.selectList(new LambdaQueryWrapper() + .eq(SupDepart::getLevel, 2) + .select(SupDepart::getId, SupDepart::getPid, SupDepart::getName, SupDepart::getLevel)); + Map areaMap = 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<>(); + for (Negative negative : negatives) { + StatisticsDepart depart = departMap.get(negative.getInvolveDepartId()); + if (depart == null) { + continue; + } + SupDepart area = areaMap.get(depart.getPid()); + if (area == null) { + continue; + } + Integer count = Optional.ofNullable(mapLevel3.get(area.getId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + } + for (Map.Entry entry : mapLevel3.entrySet()) { + log.info("机构:{} | {}", areaMap.get(entry.getKey()).getName(), entry.getValue()); + } + } + + + /** + * 民警、辅警 + */ + public void personStatistics() { + List list = blameMapper.statisticsBlame(); + + List list2 = blameMapper.statisticsBlame2(); + + List list3 = blameMapper.statisticsBlame3(); + + for (BlamePerson blamePerson : list) { + log.info("民警:{} | {}", blamePerson.getBlameName(), blamePerson.getNumber()); + } + for (BlamePerson blamePerson : list2) { + log.info("辅警:{} | {}", blamePerson.getBlameName(), blamePerson.getNumber()); + } + for (BlamePerson blamePerson : list3) { + log.info("领导:{} | {}", blamePerson.getBlameName(), blamePerson.getNumber()); + } } }