Browse Source

预警问题

main
kami 1 year ago
parent
commit
47df3eb1d1
  1. 16
      src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java
  2. 30
      src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java
  3. 145
      src/main/java/com/biutag/supervision/service/ProblemSourceService.java

16
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<NegativeBlame> {
"where n.checkStatus in ('1', '2') and n.processing_status = 'completed' and pr.threeLevelCode is not null")
List<NegativeBlame> 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<BlamePerson> 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<BlamePerson> 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<BlamePerson> statisticsBlame3();
}

30
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;
}

145
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<Negative>().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<Negative>().in(Negative::getCheckStatus, List.of(1, 2))).intValue()))
).join();
List<NegativeBlame> list = blameMapper.selectList(new LambdaQueryWrapper<NegativeBlame>().select(NegativeBlame::getBlameIdCode));
Long count = list.stream().map(NegativeBlame::getBlameIdCode).distinct().count();
@ -64,7 +61,6 @@ public class ProblemSourceService {
private final SupDepartMapper supDepartMapper;
/**
*
* @param type 类型 1- 风险值 2- 问题数 3-问题发生率
* @param businessType
*/
@ -74,29 +70,146 @@ public class ProblemSourceService {
Map<String, SupDepart> departMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue));
List<Negative> negatives = negativeMapper.selectList(new LambdaQueryWrapper<Negative>()
.in(Negative::getCheckStatus, List.of(1,2)));
.in(Negative::getCheckStatus, List.of(1, 2)));
Map<String, Integer> mapLevel3 = new HashMap<>();
Map<String, Integer> 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<StatisticsGroup>()
.eq(StatisticsGroup::getName, "交警大队").last("limit 1"));
List<StatisticsDepart> list = departMapper.selectList(new LambdaQueryWrapper<StatisticsDepart>()
.eq(StatisticsDepart::getLevel, 3)
.eq(StatisticsDepart::getGroupId, group.getGroupId()));
Map<String, StatisticsDepart> departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue));
List<Negative> negatives = negativeMapper.selectList(new LambdaQueryWrapper<Negative>()
.in(Negative::getCheckStatus, List.of(1, 2)));
Map<String, Integer> 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<String, Integer> entry : mapLevel3.entrySet()) {
log.info("机构:{} | {}", departMap.get(entry.getKey()).getName(), entry.getValue());
}
}
/**
* 派出所
*/
public void statisticsGroupRank2() {
StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper<StatisticsGroup>()
.eq(StatisticsGroup::getName, "派出所").last("limit 1"));
List<StatisticsDepart> list = departMapper.selectList(new LambdaQueryWrapper<StatisticsDepart>()
.eq(StatisticsDepart::getLevel, 3)
.eq(StatisticsDepart::getGroupId, group.getGroupId()));
Map<String, StatisticsDepart> departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue));
List<Negative> negatives = negativeMapper.selectList(new LambdaQueryWrapper<Negative>()
.in(Negative::getCheckStatus, List.of(1, 2)));
Map<String, Integer> 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<String, Integer> entry : mapLevel3.entrySet()) {
log.info("机构:{} | {}", departMap.get(entry.getKey()).getName(), entry.getValue());
}
}
// 分县
public void statisticsGroupRank3() {
StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper<StatisticsGroup>()
.eq(StatisticsGroup::getName, "派出所").last("limit 1"));
List<StatisticsDepart> list = departMapper.selectList(new LambdaQueryWrapper<StatisticsDepart>()
.eq(StatisticsDepart::getLevel, 3)
.eq(StatisticsDepart::getGroupId, group.getGroupId()));
Map<String, StatisticsDepart> departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue));
List<SupDepart> departs = supDepartMapper.selectList(new LambdaQueryWrapper<SupDepart>()
.eq(SupDepart::getLevel, 2)
.select(SupDepart::getId, SupDepart::getPid, SupDepart::getName, SupDepart::getLevel));
Map<String, SupDepart> areaMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue));
List<Negative> negatives = negativeMapper.selectList(new LambdaQueryWrapper<Negative>()
.in(Negative::getCheckStatus, List.of(1, 2)));
Map<String, Integer> 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<String, Integer> entry : mapLevel3.entrySet()) {
log.info("机构:{} | {}", areaMap.get(entry.getKey()).getName(), entry.getValue());
}
}
/**
* 民警辅警
*/
public void personStatistics() {
List<BlamePerson> list = blameMapper.statisticsBlame();
List<BlamePerson> list2 = blameMapper.statisticsBlame2();
List<BlamePerson> 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());
}
}
}

Loading…
Cancel
Save