@ -8,6 +8,7 @@ import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.model.StatObj ;
import org.dromara.business.domain.model.StatObj ;
import org.dromara.business.mapper.BusinessAlertMapper ;
import org.dromara.business.mapper.BusinessAlertMapper ;
import org.dromara.business.service.IBusinessAlertStatisticsService ;
import org.dromara.business.service.IBusinessAlertStatisticsService ;
import org.dromara.common.core.exception.ServiceException ;
import org.dromara.common.satoken.utils.LoginHelper ;
import org.dromara.common.satoken.utils.LoginHelper ;
import org.dromara.system.api.RemoteDeptService ;
import org.dromara.system.api.RemoteDeptService ;
import org.dromara.system.api.RemoteLabelPostService ;
import org.dromara.system.api.RemoteLabelPostService ;
@ -45,6 +46,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@DubboReference
@DubboReference
RemotePostService remotePostService ;
RemotePostService remotePostService ;
/ * *
/ * *
* 按照月份分类预警数量 ( 包含权限 )
* 按照月份分类预警数量 ( 包含权限 )
* @param businessAlertBo
* @param businessAlertBo
@ -129,7 +131,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
@Override
public List < StatObj > countPanelAlert ( BusinessAlertBo businessAlertBo ) {
public List < StatObj > countPanelAlert ( BusinessAlertBo businessAlertBo ) {
businessAlertBo . setAiLabelEnList ( getAiLabel ( businessAlertBo . getPostCode ( ) ) ) ;
if ( ObjectUtil . isNotEmpty ( businessAlertBo . getPostCode ( ) ) ) {
LocalDate today = LocalDate . now ( ) ;
businessAlertBo . setCreateTime ( today . getYear ( ) + "-" + today . getMonthValue ( ) + "-" + today . getDayOfMonth ( ) ) ;
businessAlertBo . setAiLabelEnList ( getAiLabel ( businessAlertBo . getPostCode ( ) ) ) ;
}
List < Map < String , Object > > mapList = baseMapper . countPanelAlert ( businessAlertBo ) ;
List < Map < String , Object > > mapList = baseMapper . countPanelAlert ( businessAlertBo ) ;
return mapList . stream ( )
return mapList . stream ( )
@ -157,12 +165,15 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
@Override
public Map < String , Object > countPanelTotalAlert ( BusinessAlertBo businessAlertBo ) {
public Map < String , Object > countPanelTotalAlert ( BusinessAlertBo businessAlertBo ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
List < String > labelList = getAiLabel ( businessAlertBo . getPostCode ( ) ) ;
if ( ObjectUtil . isNotEmpty ( businessAlertBo . getPostCode ( ) ) ) {
businessAlertBo . setAiLabelEnList ( labelList ) ;
List < String > labelList = getAiLabel ( businessAlertBo . getPostCode ( ) ) ;
//2024一直到当前年份处理预警个数
businessAlertBo . setAiLabelEnList ( labelList ) ;
}
// 1、2024一直到当前年份处理预警个数
Integer totalFinishCount = baseMapper . countFromOldToCurrent ( businessAlertBo ) ;
Integer totalFinishCount = baseMapper . countFromOldToCurrent ( businessAlertBo ) ;
result . put ( "totalFinishCount" , totalFinishCount ) ;
result . put ( "totalFinishCount" , totalFinishCount ) ;
//今年处理率 今年的预警总数 今年处理个数
//2、 今年处理率 今年的预警总数 今年处理个数
Map < String , Object > currentYearMap = baseMapper . countCurrentAlert ( businessAlertBo ) ;
Map < String , Object > currentYearMap = baseMapper . countCurrentAlert ( businessAlertBo ) ;
// 四舍五入保留两位小数
// 四舍五入保留两位小数
double yearTotal = Double . parseDouble ( String . valueOf ( currentYearMap . get ( "total" ) ) ) ;
double yearTotal = Double . parseDouble ( String . valueOf ( currentYearMap . get ( "total" ) ) ) ;
@ -173,7 +184,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
result . put ( "yearFinishCount" , currentYearMap . get ( "finishCount" ) ) ;
result . put ( "yearFinishCount" , currentYearMap . get ( "finishCount" ) ) ;
result . put ( "yearRate" , currentYearAverage ) ;
result . put ( "yearRate" , currentYearAverage ) ;
//本月处理率 本月预警总数 本月处理个数
//3、 本月处理率 本月预警总数 本月处理个数
Map < String , Object > monthMap = baseMapper . countMonthAlert ( businessAlertBo ) ;
Map < String , Object > monthMap = baseMapper . countMonthAlert ( businessAlertBo ) ;
// 四舍五入保留两位小数
// 四舍五入保留两位小数
@ -186,6 +197,13 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
result . put ( "monthFinishCount" , monthMap . get ( "finishCount" ) ) ;
result . put ( "monthFinishCount" , monthMap . get ( "finishCount" ) ) ;
result . put ( "monthRate" , currentMonthAverage ) ;
result . put ( "monthRate" , currentMonthAverage ) ;
//4、今日预警总数 今日处理个数 今日未处理个数
Map < String , Object > dayMap = this . baseMapper . countCurrentDayAlert ( businessAlertBo ) ;
result . put ( "dayTotal" , dayMap . get ( "total" ) ) ;
result . put ( "dayFinishCount" , dayMap . get ( "finishCount" ) ) ;
result . put ( "dayTodo" , dayMap . get ( "todoCount" ) ) ;
return result ;
return result ;
}
}
@ -197,8 +215,11 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
@Override
@Override
public Map < String , Object > countCurrentDayAlert ( BusinessAlertBo businessAlertBo ) {
public Map < String , Object > countCurrentDayAlert ( BusinessAlertBo businessAlertBo ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
List < String > labelList = getAiLabel ( businessAlertBo . getPostCode ( ) ) ;
businessAlertBo . setAiLabelEnList ( labelList ) ;
if ( ObjectUtil . isNotEmpty ( businessAlertBo . getPostCode ( ) ) ) {
List < String > labelList = getAiLabel ( businessAlertBo . getPostCode ( ) ) ;
businessAlertBo . setAiLabelEnList ( labelList ) ;
}
Map < String , Object > dayMap = this . baseMapper . countCurrentDayAlert ( businessAlertBo ) ;
Map < String , Object > dayMap = this . baseMapper . countCurrentDayAlert ( businessAlertBo ) ;
@ -252,12 +273,11 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
postVoList . forEach ( postVo - > {
postVoList . forEach ( postVo - > {
List < String > labelList = getAiLabel ( postVo . getPostCode ( ) ) ;
List < String > labelList = getAiLabel ( postVo . getPostCode ( ) ) ;
businessAlertBo . setAiLabelEnList ( labelList ) ;
businessAlertBo . setAiLabelEnList ( labelList ) ;
Map < String , Object > dateMap = switch ( businessAlertBo . getDateType ( ) ) {
List < String > monthList = getLastSixMonths ( ) ;
case 1 - > baseMapper . countCurrentAlert ( businessAlertBo ) ;
String startTime = monthList . get ( monthList . size ( ) - 1 ) ;
case 2 - > baseMapper . countMonthAlert ( businessAlertBo ) ;
String endTime = monthList . get ( 0 ) ;
case 3 - > baseMapper . countCurrentDayAlert ( businessAlertBo ) ;
default - > baseMapper . countCurrentAlert ( businessAlertBo ) ;
Map < String , Object > dateMap = baseMapper . countPastYearAlert ( businessAlertBo , startTime , endTime ) ;
} ;
result . add ( new StatObj (
result . add ( new StatObj (
postVo . getPostName ( ) ,
postVo . getPostName ( ) ,
@ -291,11 +311,20 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
List < StatObj > statObjs = new ArrayList < > ( ) ;
List < StatObj > statObjs = new ArrayList < > ( ) ;
postVoList . forEach ( postVo - > {
postVoList . forEach ( postVo - > {
List < String > labelList = getAiLabel ( postVo . getPostCode ( ) ) ;
List < String > labelList = getAiLabel ( postVo . getPostCode ( ) ) ;
businessAlertBo . setAiLabelEnList ( labelList ) ;
Map < String , Object > rateMap = baseMapper . handlerRate ( businessAlertBo , month ) ;
StatObj statObj1 = new StatObj ( ) ;
StatObj statObj1 = new StatObj ( ) ;
statObj1 . setStatKey ( postVo . getPostName ( ) ) ;
if ( ObjectUtil . isEmpty ( labelList ) ) {
statObj1 . setStatVal ( rateMap . get ( "avgInfo" ) ) ;
statObj1 . setStatVal ( 0 ) ;
} else {
businessAlertBo . setAiLabelEnList ( labelList ) ;
Map < String , Object > rateMap = baseMapper . handlerRate ( businessAlertBo , month ) ;
statObj1 . setStatKey ( postVo . getPostName ( ) ) ;
if ( ObjectUtil . isNotEmpty ( rateMap ) ) {
statObj1 . setStatVal ( rateMap . get ( "avgInfo" ) ) ;
} else {
statObj1 . setStatVal ( 0 ) ;
}
}
statObjs . add ( statObj1 ) ;
statObjs . add ( statObj1 ) ;
} ) ;
} ) ;
statObj . setNextStatList ( statObjs ) ;
statObj . setNextStatList ( statObjs ) ;
@ -305,6 +334,83 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
return result ;
return result ;
}
}
@Override
public Map < String , Object > comprehensiveManage ( BusinessAlertBo businessAlertBo ) {
if ( ObjectUtil . isEmpty ( businessAlertBo . getPostCode ( ) ) ) {
throw new ServiceException ( "【postCode】 岗位编码为空!" ) ;
}
Map < String , Object > result = new HashMap < > ( ) ;
List < String > aiLabelList = getAiLabel ( businessAlertBo . getPostCode ( ) ) ;
businessAlertBo . setAiLabelEnList ( aiLabelList ) ;
List < String > monthList = getLastSixMonths ( ) ;
String startTime = monthList . get ( monthList . size ( ) - 1 ) ;
String endTime = monthList . get ( 0 ) ;
List < Map < String , Object > > labelMapList = this . baseMapper . countAiLabel ( businessAlertBo , startTime , endTime ) ;
Map < String , Object > labelMap = new HashMap < > ( ) ;
labelMapList . forEach ( label - > {
labelMap . put ( label . get ( "labelCn" ) + "" , label . get ( "total" ) ) ;
} ) ;
//识别类型存储
result . put ( "label" , labelMap ) ;
//事件高发区
Long deptId = LoginHelper . getDeptId ( ) ;
//获取街道信息
List < RemoteDeptVo > streetList = remoteDeptService . selectListByParentId ( String . valueOf ( deptId ) ) ;
Map < String , Integer > streeMap = new HashMap < > ( ) ;
streetList . forEach ( street - > {
businessAlertBo . setDeptId ( String . valueOf ( street . getDeptId ( ) ) ) ;
Integer alertCount = this . baseMapper . countStreetAlert ( businessAlertBo , startTime , endTime ) ;
streeMap . put ( street . getDeptName ( ) , alertCount ) ;
} ) ;
//降序排序,取前五个
Map < String , Integer > top5Map = streeMap . entrySet ( ) . stream ( )
. sorted ( Map . Entry . < String , Integer > comparingByValue ( ) . reversed ( ) )
. limit ( 5 )
. collect ( Collectors . toMap (
Map . Entry : : getKey ,
Map . Entry : : getValue ,
( e1 , e2 ) - > e1 ,
LinkedHashMap : : new
) ) ;
result . put ( "streetCount" , top5Map ) ;
//处理效率top5
Map < String , Integer > streeRateMap = new HashMap < > ( ) ;
streetList . forEach ( street - > {
businessAlertBo . setDeptId ( String . valueOf ( street . getDeptId ( ) ) ) ;
Integer alertCount = this . baseMapper . countStreetRateAlert ( businessAlertBo , startTime , endTime ) ;
if ( ObjectUtil . isEmpty ( alertCount ) ) {
streeRateMap . put ( street . getDeptName ( ) , 0 ) ;
} else {
streeRateMap . put ( street . getDeptName ( ) , alertCount ) ;
}
} ) ;
Map < String , Integer > streeRatetop5Map = streeRateMap . entrySet ( ) . stream ( )
. sorted ( Map . Entry . < String , Integer > comparingByValue ( ) . reversed ( ) )
. limit ( 5 )
. collect ( Collectors . toMap (
Map . Entry : : getKey ,
Map . Entry : : getValue ,
( e1 , e2 ) - > e1 ,
LinkedHashMap : : new
) ) ;
result . put ( "handlerRate" , streeRatetop5Map ) ;
return result ;
}
/ * *
/ * *
* 获取近6个月的月份集合 ( 格式 : yyyy - MM )
* 获取近6个月的月份集合 ( 格式 : yyyy - MM )
* /
* /