@ -1,11 +1,29 @@
package com.biutag.supervision.controller.subdatav ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.StrUtil ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.biutag.supervision.constants.enums.RpcApplyTypeEnum ;
import com.biutag.supervision.mapper.CountyStreetDeptMapper ;
import com.biutag.supervision.mapper.RpcApplyMapper ;
import com.biutag.supervision.mapper.RpcInfringerResultMapper ;
import com.biutag.supervision.mapper.SupDepartMapper ;
import com.biutag.supervision.pojo.Result ;
import com.biutag.supervision.pojo.dto.common.BarItem ;
import com.biutag.supervision.pojo.dto.common.PieItem ;
import com.biutag.supervision.pojo.entity.CountyStreetDept ;
import com.biutag.supervision.pojo.entity.RpcApply ;
import com.biutag.supervision.pojo.entity.SupDepart ;
import com.biutag.supervision.pojo.entity.SupDictData ;
import com.biutag.supervision.pojo.vo.ComfortCountVO ;
import com.biutag.supervision.pojo.vo.ComfortMapIconVo ;
import com.biutag.supervision.pojo.vo.EchartsVo ;
import com.biutag.supervision.service.DataRightsComfortService ;
import com.biutag.supervision.service.RpcApplyService ;
import com.biutag.supervision.service.SupDepartService ;
import com.biutag.supervision.service.SupDictDataService ;
import com.biutag.supervision.util.CompletableUtils.CompletableFutureUtil ;
import io.swagger.v3.oas.annotations.tags.Tag ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
@ -15,9 +33,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.bind.annotation.RestController ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.List ;
import java.util.* ;
import java.util.stream.Collectors ;
import static com.biutag.supervision.constants.enums.DepartGroupEnum.COUNTY_CITY_BUREAUS ;
/ * *
* @Auther : sh
@ -34,24 +53,49 @@ public class SubOneRightsController {
private final DataRightsComfortService dataRightsComfortService ;
private final RpcApplyMapper rpcApplyMapper ;
private final SupDictDataService supDictDataService ;
private final CountyStreetDeptMapper countyStreetDeptMapper ;
private final RpcApplyService rpcApplyService ;
private final RpcInfringerResultMapper rpcInfringerResultMapper ;
// 大屏中央总览数据
@GetMapping ( "/getSubOneALlComfortCount" )
public Result < JSONObject > getALlComfortCount ( @RequestParam Integer departId ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
endTime = DateUtil . endOfDay ( endTime ) ;
List < RpcApply > list = rpcApplyMapper . selectList ( new LambdaQueryWrapper < RpcApply > ( )
. between ( RpcApply : : getCrtTime , beginTime , endTime )
. eq ( RpcApply : : getSecondDepartId , departId )
. eq ( RpcApply : : getType , RpcApplyTypeEnum . RIGHTS_PROTECTION . getValue ( ) ) ) ;
Long comfortTotal = rpcApplyMapper . countSubOneComfortPersonNumber ( beginTime , endTime , departId ) ;
// Integer comfortTotal = dataRightsComfortService.countComfortPersonNumber(beginTime, endTime); // 抚慰人数
Integer hitTotal = dataRightsComfortService . countSubOneHitPersonNumber ( beginTime , endTime , departId ) ; // 打击处理人数
Double comfortMoney = rpcApplyMapper . countSubOneComfortMoney ( beginTime , endTime , departId ) ;
// Double comfortMoney = dataRightsComfortService.countComfortMoney(beginTime, endTime); // 抚慰金额
Integer hitTotal = dataRightsComfortService . countSubOneHitPersonNumber ( beginTime , endTime , departId ) ; // 打击处理人数
ComfortCountVO comfortOverview = new ComfortCountVO ( ) ;
//抚慰人数
comfortOverview . setComfortTotal ( comfortTotal ) ;
//打击处理人数
comfortOverview . setHitTotal ( hitTotal ) ;
//抚慰人数
comfortOverview . setComfortMoney ( comfortMoney ) ;
comfortOverview . setComfortCaseTotal ( 0 ) ;
comfortOverview . setHurtTotal ( 0 ) ;
JSONObject data = new JSONObject ( ) . fluentPut ( "comfortOverview" , comfortOverview ) ;
//维权案件总数
comfortOverview . setComfortCaseTotal ( list . stream ( ) . map ( RpcApply : : getCaseNumber ) . collect ( Collectors . toSet ( ) ) . size ( ) ) ;
//受侵害人数
comfortOverview . setHurtTotal ( rpcApplyMapper . selectVictimNumberByOrg ( beginTime , endTime , String . valueOf ( departId ) ) ) ;
// 维权案件情况 - 派出所
List < BarItem > pcsList = rpcApplyMapper . selectSubPcsProtectRightsBarList ( beginTime , endTime , departId , 10 ) ;
// 维权案件情况 - 大队
List < BarItem > dbList = rpcApplyMapper . selectSubDdProtectRightsBarList ( beginTime , endTime , departId , 10 ) ;
JSONObject data = new JSONObject ( )
. fluentPut ( "comfortOverview" , comfortOverview )
. fluentPut ( "fxsjRightsRankList" , pcsList )
. fluentPut ( "jsdwRightsRankList" , dbList ) ;
return Result . success ( data ) ;
}
@ -62,6 +106,7 @@ public class SubOneRightsController {
public Result < JSONObject > getSubOnePoliceHurtSituationAndHurtType ( @RequestParam Integer departId ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
endTime = DateUtil . endOfDay ( endTime ) ;
List < EchartsVo > policeHurtSituationList = rpcApplyMapper . getSubOnePoliceHurtSituation ( beginTime , endTime , departId ) ; // 人数情况
List < EchartsVo > policeHurtTypeList = rpcApplyMapper . getSubOnePoliceHurtType ( beginTime , endTime , departId ) ; // 受伤类别
JSONObject data = new JSONObject ( )
@ -75,20 +120,141 @@ public class SubOneRightsController {
public Result < JSONObject > getSubOneCaseAriseSituationRate ( @RequestParam Integer departId ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
endTime = DateUtil . endOfDay ( endTime ) ;
// 发案环节
List < EchartsVo > incidentLinkList = rpcApplyMapper . getSubOneIncidentLink ( beginTime , endTime , departId ) ;
// 发案警种
List < EchartsVo > incidentPoliceTypeList = new ArrayList < > ( ) ;
List < EchartsVo > incidentPoliceList = rpcApplyMapper . getIncidentPolice ( beginTime , endTime , departId ) ;
List < SupDictData > supDictDataList = supDictDataService . list ( new LambdaQueryWrapper < SupDictData > ( ) . eq ( SupDictData : : getDictType , "personType" ) ) ;
incidentPoliceList . forEach ( s - > {
Optional < SupDictData > supDictData = supDictDataList . stream ( ) . filter ( v - > v . getDictValue ( ) . equals ( s . getName ( ) ) ) . findFirst ( ) ;
supDictData . ifPresent ( dictData - > s . setName ( dictData . getDictLabel ( ) ) ) ;
} ) ;
// 发案单位
List < EchartsVo > incidentOrgList = rpcApplyMapper . getSubOneIncidentOrg ( beginTime , endTime , departId ) ;
JSONObject data = new JSONObject ( )
. fluentPut ( "incidentLinkList" , incidentLinkList )
. fluentPut ( "incidentPoliceTypeList" , incidentPoliceTypeList )
. fluentPut ( "incidentPoliceTypeList" , incidentPoliceList )
. fluentPut ( "incidentOrgList" , incidentOrgList ) ;
return Result . success ( data ) ;
}
// endregion
@GetMapping ( "getComfortMapIcon" )
public Result < JSONObject > getComfortMapIcon ( @RequestParam Integer departId , @RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
Date finalEndTime = DateUtil . endOfDay ( endTime ) ;
// 信访数据总数概览
List < ComfortMapIconVo > res = new ArrayList < > ( ) ;
// 查询所有分县市局
List < CountyStreetDept > countyStreetDepts = countyStreetDeptMapper . getSubOneStreetMap ( departId ) ;
for ( CountyStreetDept countyStreetDept : countyStreetDepts ) {
ComfortMapIconVo iconVo = new ComfortMapIconVo ( ) ;
iconVo . setName ( countyStreetDept . getName ( ) ) ;
iconVo . setDepartId ( countyStreetDept . getDeptId ( ) ) ;
res . add ( iconVo ) ;
}
for ( ComfortMapIconVo re : res ) {
String deptId = re . getDepartId ( ) ;
List < RpcApply > list = rpcApplyService . list ( new LambdaQueryWrapper < RpcApply > ( )
. between ( RpcApply : : getCrtTime , beginTime , finalEndTime )
. eq ( RpcApply : : getSecondDepartId , departId )
. eq ( RpcApply : : getType , RpcApplyTypeEnum . RIGHTS_PROTECTION . getValue ( ) ) ) ;
Set < String > caseNumbers = list . stream ( ) . map ( RpcApply : : getCaseNumber ) . collect ( Collectors . toSet ( ) ) ;
// 维权案件总数
re . setRightsNumber ( caseNumbers . size ( ) ) ;
// 受侵害人数
re . setVictimNumber ( rpcApplyMapper . selectVictimNumberByOrg ( beginTime , finalEndTime , deptId ) ) ;
// 打击处理人数
List < String > tortNames = rpcInfringerResultMapper . selectNamesByOrgTime ( beginTime , finalEndTime , deptId ) ;
long initialListSize = tortNames . size ( ) ;
long hitPersonNumber = tortNames . stream ( )
. filter ( s - > s . contains ( "," ) ) . toList ( ) . size ( ) ;
// 筛选出包含逗号的名称
long nums = tortNames . stream ( )
. filter ( s - > s . contains ( "," ) )
. mapToLong ( s - > s . split ( "," ) . length )
. sum ( ) ; // 计算所有拆分后数组长度的总和 // 拆分每个名称并计算拆分后的数组长度
if ( tortNames . stream ( ) . noneMatch ( s - > s . contains ( "," ) ) ) {
re . setHitPersonNumber ( initialListSize ) ;
} else {
re . setHitPersonNumber ( initialListSize + nums - hitPersonNumber ) ;
}
//抚慰金额
CompletableFutureUtil . runSyncObject ( ( ) - > {
re . setComfortMoney ( rpcApplyMapper . selectComfortMoneyBarByOrg ( beginTime , finalEndTime , deptId ) ) ;
} ) ;
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 抚慰人数
re . setComfortPersonNumber ( rpcApplyService . orgCount ( beginTime , finalEndTime , RpcApplyTypeEnum . COMFORT . getValue ( ) , deptId ) ) ;
} ) ;
}
JSONObject data = new JSONObject ( ) . fluentPut ( "comfortMapVoList" , res ) ;
return Result . success ( data ) ;
}
// endregion
//打处情况
@GetMapping ( "getPunishmentSituation" )
public Result < JSONObject > getPunishmentSituation ( @RequestParam Integer departId ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
endTime = DateUtil . endOfDay ( endTime ) ;
//获取相关案件
List < RpcApply > list = rpcApplyMapper . selectList ( new LambdaQueryWrapper < RpcApply > ( )
. between ( RpcApply : : getCrtTime , beginTime , endTime )
. eq ( RpcApply : : getSecondDepartId , departId )
. eq ( RpcApply : : getType , RpcApplyTypeEnum . RIGHTS_PROTECTION . getValue ( ) ) ) ;
//案件分组
Map < String , List < RpcApply > > collect = list . stream ( )
. filter ( s - > StrUtil . isNotEmpty ( s . getInfringerHandle ( ) ) )
. collect ( Collectors . groupingBy ( RpcApply : : getInfringerHandle ) ) ;
List < PieItem > pieItems = collect . keySet ( ) . stream ( ) . map ( name - > {
return new PieItem ( name , collect . get ( name ) . size ( ) ) ;
} ) . toList ( ) ;
JSONObject data = new JSONObject ( ) . fluentPut ( "PunishmentSituation" , pieItems ) ;
return Result . success ( data ) ;
}
// 抚慰情况
@GetMapping ( "/getComfortSituation" )
public Result < JSONObject > getComfortSituation ( @RequestParam Integer departId ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
endTime = DateUtil . endOfDay ( endTime ) ;
List < PieItem > comfortSituationList = rpcApplyMapper . selectSubComfortSituation ( beginTime , endTime , departId ) ;
JSONObject data = new JSONObject ( ) . fluentPut ( "comfortSituationList" , comfortSituationList ) ;
return Result . success ( data ) ;
}
//案件类别占比
@GetMapping ( "getSubCaseType" )
public Result < JSONObject > getSubCaseType ( @RequestParam Integer departId ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
endTime = DateUtil . endOfDay ( endTime ) ;
//案件类别 - 刑事
List < EchartsVo > crownCaseBar = rpcApplyMapper . selectSubCaseData ( beginTime , endTime , "1" , departId ) ;
//案件类别 - 行政
List < EchartsVo > administrativeCase = rpcApplyMapper . selectSubCaseData ( beginTime , endTime , "2" , departId ) ;
JSONObject data = new JSONObject ( ) . fluentPut ( "crownCaseBar" , crownCaseBar ) . fluentPut ( "administrativeCase" , administrativeCase ) ;
return Result . success ( data ) ;
}
}