@ -1,30 +1,42 @@
package com.biutag.supervision.controller.datav ;
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.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.biutag.supervision.constants.enums.RpcApplyTypeEnum ;
import com.biutag.supervision.mapper.RpcApplyMapper ;
import com.biutag.supervision.mapper.RpcInfringerResultMapper ;
import com.biutag.supervision.mapper.SupDepartMapper ;
import com.biutag.supervision.mapper.SupDictDataMapper ;
import com.biutag.supervision.pojo.Result ;
import com.biutag.supervision.pojo.dto.common.PieItem ;
import com.biutag.supervision.pojo.entity.RpcApply ;
import com.biutag.supervision.pojo.entity.RpcInfringerResult ;
import com.biutag.supervision.pojo.entity.SupDepart ;
import com.biutag.supervision.pojo.entity.SupDictData ;
import com.biutag.supervision.pojo.model.DataRightsComfortModel ;
import com.biutag.supervision.pojo.vo.ComfortMapIconVo ;
import com.biutag.supervision.pojo.vo.EchartsVo ;
import com.biutag.supervision.pojo.vo.MailMapIconVo ;
import com.biutag.supervision.service.DataRightsComfortService ;
import com.biutag.supervision.service.RpcApplyService ;
import com.biutag.supervision.service.RpcInfringerResultService ;
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 org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.format.annotation.DateTimeFormat ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.bind.annotation.RestController ;
import org.springframework.web.bind.annotation.* ;
import java.util.* ;
import java.util.concurrent.CompletableFuture ;
import java.util.stream.Collectors ;
import static com.biutag.supervision.constants.enums.DepartGroupEnum.COUNTY_CITY_BUREAUS ;
/ * *
* 维权抚慰大屏相关
*
@ -41,7 +53,10 @@ public class DataVRightsComfortController {
private final RpcApplyService rpcApplyService ;
private final RpcApplyMapper rpcApplyMapper ;
private final RpcInfringerResultMapper rpcInfringerResultMapper ;
private final SupDictDataService supDictDataService ;
private final SupDepartMapper supDepartMapper ;
@GetMapping
public Result < DataRightsComfortModel > rightsComfort ( @RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
@ -59,9 +74,20 @@ public class DataVRightsComfortController {
// 受侵害人数
result . setVictimNumber ( list . size ( ) ) ;
// 打击处理人数
result . setHitPersonNumber ( list . size ( ) + 1 ) ;
List < String > tortNames = rpcInfringerResultMapper . selectNamesByTime ( beginTime , finalEndTime ) ;
long initialListSize = tortNames . size ( ) ;
long hitPersonNumber = tortNames . stream ( )
. filter ( s - > s . contains ( "," ) ) // 筛选出包含逗号的名称
. mapToLong ( s - > s . split ( "," ) . length ) // 拆分每个名称并计算拆分后的数组长度
. sum ( ) ; // 计算所有拆分后数组长度的总和
if ( tortNames . stream ( ) . noneMatch ( s - > s . contains ( "," ) ) ) {
result . setHitPersonNumber ( initialListSize ) ;
} else {
result . setHitPersonNumber ( initialListSize + hitPersonNumber ) ;
}
Map < String , List < RpcApply > > collect = list . stream ( ) . collect ( Collectors . groupingBy ( RpcApply : : getInfringerHandle ) ) ;
Map < String , List < RpcApply > > collect = list . stream ( ) . filter ( s - > StrUtil . isNotEmpty ( s . getInfringerHandle ( ) ) & & "1" . equals ( s . getType ( ) ) )
. collect ( Collectors . groupingBy ( RpcApply : : getInfringerHandle ) ) ;
// 打处情况
result . setPunishmentSituation ( collect . keySet ( ) . stream ( ) . map ( name - > {
return new PieItem ( name , collect . get ( name ) . size ( ) ) ;
@ -79,13 +105,42 @@ public class DataVRightsComfortController {
// 抚慰金额情况 - 分县市局
result . setCountyComfortMoneyBarList ( rpcApplyMapper . selectComfortMoneyBarList ( beginTime , finalEndTime , 3 ) ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 抚慰金额情况 - 局属单位
result . setBureauComfortMoneyBarList ( rpcApplyMapper . selectComfortMoneyBarList ( beginTime , finalEndTime , 4 ) ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 维权案件情况 - 分县市局
result . setCountyRightsBarList ( rpcApplyMapper . selectProtectRightsBarList ( beginTime , finalEndTime , 3 ) ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 维权案件情况 - 局属单位
result . setBureauRightsBarList ( rpcApplyMapper . selectProtectRightsBarList ( beginTime , finalEndTime , 4 ) ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
//案件类别 - 刑事
result . setCrownCaseBarList ( rpcApplyMapper . selectCaseData ( beginTime , finalEndTime , "1" ) ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
//案件类别 - 行政
result . setAdministrativeCaseList ( rpcApplyMapper . selectCaseData ( beginTime , endTime , "2" ) ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 民辅警受伤情况
result . setComfortPoliceInjurySituation ( rpcApplyMapper . selectComfortPoliceInjurySituation ( beginTime , finalEndTime ) ) ;
List < PieItem > data = rpcApplyMapper . selectComfortPoliceInjurySituation ( beginTime , finalEndTime ) ;
//获取字典中的民警类型
List < SupDictData > supDictDataList = supDictDataService . list ( new LambdaQueryWrapper < SupDictData > ( ) . eq ( SupDictData : : getDictType , "personType" ) ) ;
data . forEach ( s - > {
Optional < SupDictData > supDictData = supDictDataList . stream ( ) . filter ( v - > v . getDictValue ( ) . equals ( s . getName ( ) ) ) . findFirst ( ) ;
supDictData . ifPresent ( dictData - > s . setName ( dictData . getDictLabel ( ) ) ) ;
} ) ;
result . setComfortPoliceInjurySituation ( data ) ;
} ) ,
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 民辅警受伤类别
@ -104,7 +159,65 @@ public class DataVRightsComfortController {
return Result . success ( data ) ;
}
// endregion
@GetMapping ( "getComfortMapIcon" )
public Result < JSONObject > getComfortMapIcon ( @RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date beginTime ,
@RequestParam @DateTimeFormat ( pattern = "yyyy-MM-dd" ) Date endTime ) {
// 信访数据总数概览
List < ComfortMapIconVo > res = new ArrayList < > ( ) ;
// 查询所有分县市局
List < SupDepart > supDeparts = supDepartMapper . selectDepartsByGroupType ( COUNTY_CITY_BUREAUS . getId ( ) ) ;
for ( SupDepart supDepart : supDeparts ) {
ComfortMapIconVo iconVo = new ComfortMapIconVo ( ) ;
iconVo . setName ( supDepart . getShortName ( ) ) ;
iconVo . setDepartId ( supDepart . getId ( ) ) ;
res . add ( iconVo ) ;
}
for ( ComfortMapIconVo re : res ) {
String departId = re . getDepartId ( ) ;
List < RpcApply > list = rpcApplyService . list ( new LambdaQueryWrapper < RpcApply > ( )
. between ( RpcApply : : getCrtTime , beginTime , endTime )
. 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 ( list . size ( ) ) ;
// 打击处理人数
List < String > tortNames = rpcInfringerResultMapper . selectNamesByOrgTime ( beginTime , endTime , departId ) ;
long initialListSize = tortNames . size ( ) ;
long hitPersonNumber = 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 + hitPersonNumber ) ;
}
//抚慰金额
CompletableFutureUtil . runSyncObject ( ( ) - > {
re . setComfortMoney ( rpcApplyMapper . selectComfortMoneyBarByOrg ( beginTime , endTime , departId ) ) ;
} ) ;
CompletableFutureUtil . runSyncObject ( ( ) - > {
// 抚慰人数
re . setComfortPersonNumber ( rpcApplyService . orgCount ( beginTime , endTime , RpcApplyTypeEnum . COMFORT . getValue ( ) , departId ) ) ;
} ) ;
}
JSONObject data = new JSONObject ( ) . fluentPut ( "comfortMapVoList" , res ) ;
return Result . success ( data ) ;
}
// region 右边
// 民辅警受伤人数情况和受伤类别