9 changed files with 380 additions and 28 deletions
@ -0,0 +1,95 @@ |
|||||||
|
package com.biutag.supervision.controller.datav; |
||||||
|
|
||||||
|
import com.biutag.supervision.pojo.Result; |
||||||
|
import com.biutag.supervision.pojo.vo.ProblemSourceStatisticsVo; |
||||||
|
import com.biutag.supervision.pojo.vo.RiskStatisticsVo; |
||||||
|
import com.biutag.supervision.service.ProblemSourceService; |
||||||
|
import com.biutag.supervision.service.RiskStatisticsService; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author kami on 2024-11-16 19:16:04 |
||||||
|
* @version 0.0.1 |
||||||
|
* @since 1.8 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@RestController |
||||||
|
@RequestMapping("/datav/risk") |
||||||
|
@AllArgsConstructor |
||||||
|
public class RiskDataController { |
||||||
|
|
||||||
|
private final ProblemSourceService sourceService; |
||||||
|
|
||||||
|
private final RiskStatisticsService statisticsService; |
||||||
|
|
||||||
|
@GetMapping("/total/statistics") |
||||||
|
public Result<ProblemSourceStatisticsVo> totalStatistics() { |
||||||
|
return Result.success(sourceService.totalStatistics()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/area/risk/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> areaRiskStatistics() { |
||||||
|
return Result.success(statisticsService.riskStatisticsBigOrg()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/risk/org/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> riskOrgStatistics() { |
||||||
|
return Result.success(statisticsService.riskStatisticsOrg("派出所")); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/risk/org/car/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> riskOrgCarStatistics() { |
||||||
|
return Result.success(statisticsService.riskStatisticsOrg("交警大队")); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/risk/police/a/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> riskPoliceAStatistics() { |
||||||
|
return Result.success(statisticsService.personStatistics()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/risk/police/b/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> riskPoliceBStatistics() { |
||||||
|
return Result.success(statisticsService.personStatistics2()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/risk/leader/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> riskLeaderStatistics() { |
||||||
|
return Result.success(statisticsService.leaderStatistics()); |
||||||
|
} |
||||||
|
// **********问题数*************
|
||||||
|
@GetMapping("/area/negative/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> areaNegativeStatistics() { |
||||||
|
return Result.success(sourceService.statisticsGroupRank3()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/org/negative/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> orgNegativeStatistics() { |
||||||
|
return Result.success(sourceService.statisticsGroupRank2()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/org/car/negative/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> orgCarNegativeStatistics() { |
||||||
|
return Result.success(sourceService.statisticsGroupRank()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/police/a/negative/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> policeANegativeStatistics() { |
||||||
|
return Result.success(sourceService.personA()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/police/b/negative/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> policeBNegativeStatistics() { |
||||||
|
return Result.success(sourceService.personB()); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/police/leader/negative/statistics") |
||||||
|
public Result<List<RiskStatisticsVo>> policeLeaderNegativeStatistics() { |
||||||
|
return Result.success(sourceService.personB()); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.biutag.supervision.pojo.vo; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author kami on 2024-11-16 18:22:46 |
||||||
|
* @version 0.0.1 |
||||||
|
* @since 1.8 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class RiskStatisticsVo { |
||||||
|
|
||||||
|
String name; |
||||||
|
|
||||||
|
String idCode; |
||||||
|
|
||||||
|
String departId; |
||||||
|
|
||||||
|
Double score; |
||||||
|
|
||||||
|
Integer value; |
||||||
|
|
||||||
|
String label; |
||||||
|
} |
||||||
@ -0,0 +1,167 @@ |
|||||||
|
package com.biutag.supervision.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.biutag.supervision.mapper.*; |
||||||
|
import com.biutag.supervision.pojo.entity.NegativeBlame; |
||||||
|
import com.biutag.supervision.pojo.entity.StatisticsGroup; |
||||||
|
import com.biutag.supervision.pojo.entity.SupDepart; |
||||||
|
import com.biutag.supervision.pojo.vo.RiskStatisticsVo; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.*; |
||||||
|
import java.util.function.Function; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author kami on 2024-11-16 18:22:13 |
||||||
|
* @version 0.0.1 |
||||||
|
* @since 1.8 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Service |
||||||
|
@AllArgsConstructor |
||||||
|
public class RiskStatisticsService { |
||||||
|
|
||||||
|
private final StatisticsGroupMapper statisticsGroupMapper; |
||||||
|
|
||||||
|
private final NegativeScoreDepartMapper negativeScoreDepartMapper; |
||||||
|
|
||||||
|
private final SupDepartMapper supDepartMapper; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 分机构统计风险分 |
||||||
|
* |
||||||
|
* @param name 机构类型名称 |
||||||
|
* @return 列表 |
||||||
|
*/ |
||||||
|
public List<RiskStatisticsVo> riskStatisticsOrg(String name) { |
||||||
|
List<SupDepart> departs = supDepartMapper.selectList(new LambdaQueryWrapper<SupDepart>() |
||||||
|
.select(SupDepart::getId, SupDepart::getPid, SupDepart::getName, SupDepart::getLevel)); |
||||||
|
Map<String, SupDepart> departMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue)); |
||||||
|
|
||||||
|
StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper<StatisticsGroup>() |
||||||
|
.eq(StatisticsGroup::getName, name).last("limit 1")); |
||||||
|
List<RiskStatisticsVo> vo = negativeScoreDepartMapper.statistics(group.getGroupId()); |
||||||
|
vo.sort(Comparator.comparing(RiskStatisticsVo::getScore, Comparator.reverseOrder())); |
||||||
|
if (vo.size() > 10) { |
||||||
|
vo = vo.subList(0, 10); |
||||||
|
} |
||||||
|
// 补名字
|
||||||
|
for (RiskStatisticsVo r : vo) { |
||||||
|
SupDepart depart = departMap.get(r.getDepartId()); |
||||||
|
r.setName(depart.getName().replaceFirst("湖南省长沙市公安局", "").replaceFirst("湖南省长沙市", "").replaceFirst("湖南省", "")); |
||||||
|
} |
||||||
|
return vo; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 分县统计风险分 |
||||||
|
* |
||||||
|
* @return 列表 |
||||||
|
*/ |
||||||
|
public List<RiskStatisticsVo> riskStatisticsBigOrg() { |
||||||
|
StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper<StatisticsGroup>() |
||||||
|
.eq(StatisticsGroup::getName, "派出所").last("limit 1")); |
||||||
|
List<RiskStatisticsVo> vo = negativeScoreDepartMapper.statistics(group.getGroupId()); |
||||||
|
|
||||||
|
List<SupDepart> departs = supDepartMapper.selectList(new LambdaQueryWrapper<SupDepart>() |
||||||
|
.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)); |
||||||
|
|
||||||
|
Map<String, Double> map = new HashMap<>(); |
||||||
|
for (RiskStatisticsVo depart : vo) { |
||||||
|
SupDepart department = areaMap.get(depart.getDepartId()); |
||||||
|
if(department == null) { |
||||||
|
log.info("统计未找到该id的机构:{}", depart.getDepartId()); |
||||||
|
continue; |
||||||
|
} |
||||||
|
SupDepart area = areaMap.get(department.getPid()); |
||||||
|
Double score = Optional.ofNullable(map.get(area.getId())).orElse(0.0); |
||||||
|
score += depart.getScore(); |
||||||
|
map.put(area.getId(), score); |
||||||
|
} |
||||||
|
List<RiskStatisticsVo> result = new ArrayList<>(); |
||||||
|
for (Map.Entry<String, Double> entry : map.entrySet()) { |
||||||
|
RiskStatisticsVo tmp = new RiskStatisticsVo(); |
||||||
|
tmp.setDepartId(entry.getKey()); |
||||||
|
tmp.setScore(entry.getValue()); |
||||||
|
SupDepart depart = areaMap.get(entry.getKey()); |
||||||
|
tmp.setName(depart.getName().replaceFirst("湖南省长沙市公安局", "").replaceFirst("湖南省长沙市", "").replaceFirst("湖南省", "")); |
||||||
|
result.add(tmp); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
private final NegativeBlameMapper blameMapper; |
||||||
|
|
||||||
|
private final NegativeScorePoliceMapper policeMapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* 民警 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public List<RiskStatisticsVo> personStatistics() { |
||||||
|
List<NegativeBlame> blames = blameMapper.selectList(new LambdaQueryWrapper<NegativeBlame>() |
||||||
|
.select(NegativeBlame::getBlameName, NegativeBlame::getBlameIdCode) |
||||||
|
.isNotNull(NegativeBlame::getBlameIdCode) |
||||||
|
.eq(NegativeBlame::getIvPersonTypeCode, "1")); |
||||||
|
Map<String, NegativeBlame> blameMap = blames.stream().collect(Collectors.toMap(NegativeBlame::getBlameIdCode, Function.identity(), (oldValue, newValue) -> newValue)); |
||||||
|
List<RiskStatisticsVo> list = policeMapper.statisticsPolice(); |
||||||
|
for (RiskStatisticsVo riskStatisticsVo : list) { |
||||||
|
NegativeBlame map = blameMap.get(riskStatisticsVo.getIdCode()); |
||||||
|
if (map == null) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
riskStatisticsVo.setName(map.getBlameName()); |
||||||
|
} |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 辅警/协警 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public List<RiskStatisticsVo> personStatistics2() { |
||||||
|
List<NegativeBlame> blames = blameMapper.selectList(new LambdaQueryWrapper<NegativeBlame>() |
||||||
|
.select(NegativeBlame::getBlameName, NegativeBlame::getBlameIdCode) |
||||||
|
.isNotNull(NegativeBlame::getBlameIdCode) |
||||||
|
.ne(NegativeBlame::getIvPersonTypeCode, "1")); |
||||||
|
Map<String, NegativeBlame> blameMap = blames.stream().collect(Collectors.toMap(NegativeBlame::getBlameIdCode, Function.identity(), (oldValue, newValue) -> newValue)); |
||||||
|
List<RiskStatisticsVo> list = policeMapper.statisticsPolice2(); |
||||||
|
for (RiskStatisticsVo riskStatisticsVo : list) { |
||||||
|
NegativeBlame map = blameMap.get(riskStatisticsVo.getIdCode()); |
||||||
|
if (map == null) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
riskStatisticsVo.setName(map.getBlameName()); |
||||||
|
} |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 领导 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public List<RiskStatisticsVo> leaderStatistics() { |
||||||
|
List<NegativeBlame> blames = blameMapper.selectList(new LambdaQueryWrapper<NegativeBlame>() |
||||||
|
.select(NegativeBlame::getLeadIdCode, NegativeBlame::getLeadName) |
||||||
|
.isNotNull(NegativeBlame::getLeadIdCode) |
||||||
|
.ne(NegativeBlame::getIvPersonTypeCode, "1")); |
||||||
|
Map<String, NegativeBlame> blameMap = blames.stream().collect(Collectors.toMap(NegativeBlame::getLeadIdCode, Function.identity(), (oldValue, newValue) -> newValue)); |
||||||
|
List<RiskStatisticsVo> list = policeMapper.statisticsLeader(); |
||||||
|
for (RiskStatisticsVo riskStatisticsVo : list) { |
||||||
|
NegativeBlame map = blameMap.get(riskStatisticsVo.getIdCode()); |
||||||
|
if (map == null) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
riskStatisticsVo.setName(map.getLeadName()); |
||||||
|
} |
||||||
|
return list; |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue