diff --git a/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java b/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java index 7dff98c..edeee4c 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java @@ -1,20 +1,10 @@ package com.biutag.supervision.controller.datav; -import cn.hutool.core.util.NumberUtil; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.biutag.supervision.constants.enums.CaseVerifProblemNatureEnum; -import com.biutag.supervision.constants.enums.DepartGroupEnum; -import com.biutag.supervision.mapper.DataRightsComfortMapper; -import com.biutag.supervision.mapper.RpcApplyMapper; import com.biutag.supervision.pojo.Result; -import com.biutag.supervision.pojo.dto.CaseVerifDepart; -import com.biutag.supervision.pojo.dto.common.PieItem; -import com.biutag.supervision.pojo.entity.DataCaseVerif; -import com.biutag.supervision.pojo.entity.DataRightsComfort; -import com.biutag.supervision.pojo.entity.RpcApply; +import com.biutag.supervision.pojo.model.DataRightsComfortModel; import com.biutag.supervision.service.DataRightsComfortService; import com.biutag.supervision.service.RpcApplyService; +import com.biutag.supervision.service.RpcInfringerResultService; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.GetMapping; @@ -22,9 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.math.BigDecimal; import java.util.Date; -import java.util.List; @RequestMapping("datav/rightsComfort") @RequiredArgsConstructor @@ -33,47 +21,34 @@ public class DatavRightsComfortController { private final RpcApplyService rpcApplyService; - private final RpcApplyMapper rpcApplyMapper; + private final DataRightsComfortService dataRightsComfortService; + private final RpcInfringerResultService rpcInfringerResultService; @GetMapping - public Result rightsComfort(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + public Result rightsComfort(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + DataRightsComfortModel result = new DataRightsComfortModel(); + // 维权案件总数 + + // 受侵害人数 + // 抚慰人数 - long total = rpcApplyService.count(new LambdaQueryWrapper().between(RpcApply::getApplyDate, beginTime, endTime)); - long confirmed = 0; - JSONObject overview = new JSONObject() - // 抚慰人数 - .fluentPut("total", total); - /* // 维权案件总数 - .fluentPut("confirmed", 0) - // 受侵害人数 - .fluentPut("investigateAndPunish", 0) - // 打击处理人数 - .fluentPut("accountablePeopleNumber", 0) - // 抚慰金额(万元) - .fluentPut("accountableDepartNumber", 0) - // 查实率 - .fluentPut("confirmedRate", total == 0 ? 0 : BigDecimal.valueOf(NumberUtil.div(confirmed, total) * 100).intValue()); - // 分县市局排名 - List fxsjBarList = dataCaseVerifMapper.selectDepartStatistic(DepartGroupEnum.COUNTY_CITY_BUREAUS.getId(), beginTime, endTime); - // 局属单位排名 - List jsdwBarList = dataCaseVerifMapper.selectDepartStatistic(DepartGroupEnum.BUREAU_AFFILIATED.getId(), beginTime, endTime); - // 执法办案 - List zfbaPieList = dataCaseVerifMapper.selectInvolveProblemGroupByBusinessTypeName(CaseVerifProblemNatureEnum.ZFBA.getLaebl(), beginTime, endTime); - // 服务管理 - List fwglPieList = dataCaseVerifMapper.selectInvolveProblemGroupByBusinessTypeName(CaseVerifProblemNatureEnum.FWGL.getLaebl(), beginTime, endTime); - // 警察纪警规 - List jjjgPieList = dataCaseVerifMapper.selectInvolveProblemGroupByBusinessTypeName(CaseVerifProblemNatureEnum.JJJG.getLaebl(), beginTime, endTime); - // 案件来源占比 - List ajlyPieList = dataCaseVerifMapper.selectGroupByProblemSources(beginTime, endTime); + result.setComfortPersonNumber(dataRightsComfortService.countComfortPersonNumber(beginTime, endTime)); + // 打击处理人数 + result.setHitPersonNumber(dataRightsComfortService.countHitPersonNumber(beginTime, endTime)); + // 抚慰金额(万元) + result.setComfortMoney(dataRightsComfortService.countComfortMoney(beginTime, endTime)); + // 维权案件情况 + + // 案件类别占比 + + // 打处情况 + result.setPunishmentSituation(dataRightsComfortService.selectPunishmentSituation(beginTime, endTime)); + // 抚慰情况 + result.setComfortSituation(dataRightsComfortService.selectComfortSituation(beginTime, endTime)); + // 民辅警受伤情况 + + // 发案情况占比 - JSONObject data = new JSONObject().fluentPut("overview", overview) - .fluentPut("fxsjBarList", fxsjBarList) - .fluentPut("jsdwBarList", jsdwBarList) - .fluentPut("zfbaPieList", zfbaPieList) - .fluentPut("fwglPieList", fwglPieList) - .fluentPut("jjjgPieList", jjjgPieList) - .fluentPut("ajlyPieList", ajlyPieList); - return Result.success(data);*/ - return null; + return Result.success(result); } } diff --git a/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java b/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java index de061dc..293a8e0 100644 --- a/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java @@ -1,8 +1,37 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.supervision.pojo.dto.common.PieItem; import com.biutag.supervision.pojo.entity.RpcApply; +import com.biutag.supervision.pojo.entity.RpcInfringerResult; +import org.apache.ibatis.annotations.Select; + +import java.util.Date; +import java.util.List; public interface RpcApplyMapper extends BaseMapper { + @Select("SELECT COUNT(a.rpc_id) FROM rpc_apply_person a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + Integer countComfortPersonNumber(Date beginTime, Date endTime); + + @Select("SELECT a.tort_name FROM rpc_infringer_result a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + List getHitPeople(Date beginTime, Date endTime); + + @Select("SELECT SUM(a.provide_relief) FROM rpc_apply_person a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + Double countComfortMoney(Date beginTime, Date endTime); + + @Select("select tort_name, defend_handle_way_name from rpc_infringer_result a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + List selectPunishmentSituation(Date beginTime, Date endTime); + + @Select("SELECT c.job name, COUNT(c.job) value FROM sup_police c JOIN " + + "(SELECT a.emp_no FROM rpc_apply_person a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2) d on c.emp_no = d.emp_no " + + "GROUP BY c.job") + List selectComfortSituation(Date beginTime, Date endTime); + + } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/dto/common/PieItem.java b/src/main/java/com/biutag/supervision/pojo/dto/common/PieItem.java index cd8979e..0960e65 100644 --- a/src/main/java/com/biutag/supervision/pojo/dto/common/PieItem.java +++ b/src/main/java/com/biutag/supervision/pojo/dto/common/PieItem.java @@ -1,5 +1,6 @@ package com.biutag.supervision.pojo.dto.common; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -9,6 +10,7 @@ import lombok.Setter; */ @Setter @Getter +@AllArgsConstructor public class PieItem { private String name; diff --git a/src/main/java/com/biutag/supervision/pojo/model/DataRightsComfortModel.java b/src/main/java/com/biutag/supervision/pojo/model/DataRightsComfortModel.java new file mode 100644 index 0000000..f7b71f4 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/model/DataRightsComfortModel.java @@ -0,0 +1,28 @@ +package com.biutag.supervision.pojo.model; + +import com.biutag.supervision.pojo.dto.common.PieItem; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Setter +@Getter +public class DataRightsComfortModel { + // 维权案件总数 + // 受侵害人数 + // 抚慰人数 + private Integer comfortPersonNumber; + // 打击处理人数 + Integer hitPersonNumber; + // 抚慰金额(万元) + Double comfortMoney; + // 维权案件情况 + // 案件类别占比 + // 打处情况 + List punishmentSituation; + // 抚慰情况 + List comfortSituation; + // 民辅警受伤情况 + // 发案情况占比 +} diff --git a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java index 1ef2dbd..c4a2d1e 100644 --- a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java +++ b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java @@ -11,6 +11,7 @@ import com.biutag.supervision.pojo.entity.BusinessLog; import com.biutag.supervision.pojo.entity.GBaseAJJBXX; import com.biutag.supervision.pojo.entity.GBaseJJD; import com.biutag.supervision.pojo.model.BusinessPoliceModel; +import com.biutag.supervision.pojo.model.DataRightsComfortModel; import com.biutag.supervision.pojo.param.BusinessQueryParam; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -45,6 +46,8 @@ public class BusinessDepartService extends ServiceImpl page(BusinessQueryParam businessQueryParam) { // 测基础数据 if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) { @@ -75,6 +78,13 @@ public class BusinessDepartService extends ServiceImpl hitPeople = rpcApplyMapper.getHitPeople(beginTime, endTime); + int totalPeople = 0; + if (hitPeople == null || hitPeople.isEmpty()) { + return 0; + } + for (String hitPerson : hitPeople) { + if (hitPerson.isEmpty()) { + continue; + } + if (hitPerson.contains(",")) { + String[] people = hitPerson.split(","); + totalPeople += people.length; + } else { + totalPeople += 1; + } + } + return totalPeople; + } + + public Double countComfortMoney(Date beginTime, Date endTime) { + return rpcApplyMapper.countComfortMoney(beginTime, endTime) / 10000.0; + } + + public List selectPunishmentSituation(Date beginTime, Date endTime) { + List rpcInfringerResults = rpcApplyMapper.selectPunishmentSituation(beginTime, endTime); + if (rpcInfringerResults == null || rpcInfringerResults.isEmpty()) { + return new ArrayList<>(); + } + Map countMap = new HashMap<>(); + for (RpcInfringerResult rpcInfringerResult : rpcInfringerResults) { + String defendHandleWayName = rpcInfringerResult.getDefendHandleWayName(); + String tortName = rpcInfringerResult.getTortName(); + String[] names = tortName.split(","); + int count = names.length; + countMap.put(defendHandleWayName, countMap.getOrDefault(defendHandleWayName, 0) + count); + } + return countMap.entrySet().stream().map(entry -> new PieItem(entry.getKey(), entry.getValue())).collect(Collectors.toList()); + } + public List selectComfortSituation(Date beginTime, Date endTime) { + return rpcApplyMapper.selectComfortSituation(beginTime, endTime); + } } diff --git a/src/main/java/com/biutag/supervision/service/RpcInfringerResultService.java b/src/main/java/com/biutag/supervision/service/RpcInfringerResultService.java index 2add95e..5058903 100644 --- a/src/main/java/com/biutag/supervision/service/RpcInfringerResultService.java +++ b/src/main/java/com/biutag/supervision/service/RpcInfringerResultService.java @@ -1,8 +1,8 @@ package com.biutag.supervision.service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.biutag.supervision.pojo.entity.RpcInfringerResult; import com.biutag.supervision.mapper.RpcInfringerResultMapper; +import com.biutag.supervision.pojo.entity.RpcInfringerResult; import org.springframework.stereotype.Service; @Service