@ -1,7 +1,10 @@
package com.zc.business.controller ;
import com.ruoyi.common.core.domain.AjaxResult ;
import com.ruoyi.common.utils.poi.ExcelUtil ;
import com.zc.business.domain.DcEventListQuery ;
import com.zc.business.domain.export.* ;
import com.zc.business.enums.UniversalEnum ;
import com.zc.business.service.IDcTrafficIncidentsService ;
import io.swagger.annotations.Api ;
import io.swagger.annotations.ApiOperation ;
@ -10,8 +13,12 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.web.bind.annotation.* ;
import javax.servlet.http.HttpServletResponse ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.List ;
import java.util.Map ;
import java.util.stream.Collectors ;
/ * *
* @Description 交通事件统计
@ -111,6 +118,31 @@ public class DcTrafficIncidentsController {
return trafficIncidentsService . getAllEventNum ( ) ;
}
@ApiOperation ( value = "导出事件类型分析" , tags = { "ECharts导出" } )
@GetMapping ( "/exportGetAllEventNum" )
public void exportGetAllEventNum ( HttpServletResponse response ) {
AjaxResult ajaxResult = trafficIncidentsService . getAllEventNum ( ) ;
List < AllEventNum > list = new ArrayList < > ( ) ;
if ( ajaxResult . get ( "code" ) . equals ( UniversalEnum . TWO_HUNDRED . getNumber ( ) ) ) {
List < Map < String , Object > > data = ( List < Map < String , Object > > ) ajaxResult . get ( "data" ) ;
Long total = data . stream ( ) . mapToLong ( item - > ( long ) item . get ( "num" ) ) . sum ( ) ;
for ( Map < String , Object > datum : data ) {
AllEventNum allEventNum = new AllEventNum ( ) ;
allEventNum . setEventName ( datum . get ( "eventName" ) . toString ( ) ) ;
allEventNum . setNum ( datum . get ( "num" ) . toString ( ) ) ;
//计算百分比
double ratio = ( double ) Long . parseLong ( datum . get ( "num" ) . toString ( ) ) / total * 100 ;
ratio = Math . round ( ratio * 100 . 0 ) / 100 . 0 ;
allEventNum . setRatio ( ratio + "%" ) ;
list . add ( allEventNum ) ;
}
}
ExcelUtil < AllEventNum > util = new ExcelUtil < > ( AllEventNum . class ) ;
util . exportExcel ( response , list , "事件类型分析" ) ;
}
/ * *
* @Description 路网管控 - 事件管控分析 - 事件源分析占比
*
@ -139,6 +171,27 @@ public class DcTrafficIncidentsController {
return trafficIncidentsService . getEventTrend ( ) ;
}
@ApiOperation ( value = "导出今日事件趋势" , tags = { "ECharts导出" } )
@GetMapping ( "/exportGetEventTrend" )
public void exportGetEventTrend ( HttpServletResponse response ) {
AjaxResult ajaxResult = trafficIncidentsService . getEventTrend ( ) ;
List < EventTrend > list = new ArrayList < > ( ) ;
if ( ajaxResult . get ( "code" ) . equals ( UniversalEnum . TWO_HUNDRED . getNumber ( ) ) ) {
Map < String , Object > data = ( Map < String , Object > ) ajaxResult . get ( "data" ) ;
List < Map < String , Object > > perception = ( List < Map < String , Object > > ) data . get ( "perception" ) ;
List < Map < String , Object > > traffic = ( List < Map < String , Object > > ) data . get ( "traffic" ) ;
for ( int i = 0 ; i < perception . size ( ) ; i + + ) {
EventTrend eventTrend = new EventTrend ( ) ;
eventTrend . setHours ( perception . get ( i ) . get ( "hours" ) . toString ( ) + "时" ) ;
eventTrend . setPerception ( perception . get ( i ) . get ( "num" ) . toString ( ) ) ;
eventTrend . setTraffic ( traffic . get ( i ) . get ( "num" ) . toString ( ) ) ;
list . add ( eventTrend ) ;
}
}
ExcelUtil < EventTrend > util = new ExcelUtil < > ( EventTrend . class ) ;
util . exportExcel ( response , list , "今日事件趋势" ) ;
}
/ * *
* @Description 路网管控 - 事件管控分析 - 事故车型分析
*
@ -157,6 +210,28 @@ public class DcTrafficIncidentsController {
@ApiParam ( value = "时间" , name = "startTime" , required = true ) @RequestParam ( "startTime" ) String startTime ) {
return trafficIncidentsService . getAccidentVehicleAnalysis ( direction , type , startTime ) ;
}
@ApiOperation ( value = "导出事故车型分析" , tags = { "ECharts导出" } )
@GetMapping ( "/exportSelectAccidentVehicleAnalysis" )
public void exportSelectAccidentVehicleAnalysis ( HttpServletResponse response ,
@ApiParam ( value = "方向" , name = "direction" , required = true ) @RequestParam ( "direction" ) String direction ,
@ApiParam ( value = "类型(1:日, 2:月, 3:季度, 4-年)" , name = "type" , required = true ) @RequestParam ( "type" ) String type ,
@ApiParam ( value = "时间" , name = "startTime" , required = true ) @RequestParam ( "startTime" ) String startTime ) {
AjaxResult ajaxResult = trafficIncidentsService . getAccidentVehicleAnalysis ( direction , type , startTime ) ;
List < AccidentVehicleAnalysis > list = new ArrayList < > ( ) ;
if ( ajaxResult . get ( "code" ) . equals ( UniversalEnum . TWO_HUNDRED . getNumber ( ) ) ) {
List < Map < String , Object > > data = ( List < Map < String , Object > > ) ajaxResult . get ( "data" ) ;
for ( Map < String , Object > datum : data ) {
AccidentVehicleAnalysis accidentVehicleAnalysis = new AccidentVehicleAnalysis ( ) ;
accidentVehicleAnalysis . setTypeName ( datum . get ( "typeName" ) . toString ( ) ) ;
accidentVehicleAnalysis . setNum ( datum . get ( "num" ) . toString ( ) ) ;
accidentVehicleAnalysis . setAvgTime ( datum . get ( "avgTime" ) . toString ( ) ) ;
list . add ( accidentVehicleAnalysis ) ;
}
}
ExcelUtil < AccidentVehicleAnalysis > util = new ExcelUtil < > ( AccidentVehicleAnalysis . class ) ;
util . exportExcel ( response , list , "事故车型分析" ) ;
}
/ * *
* @Description 路网管控 - 事件管控分析 - 收费站统计分析table
@ -194,6 +269,25 @@ public class DcTrafficIncidentsController {
return trafficIncidentsService . getTollStationAnalysis ( ) ;
}
@ApiOperation ( value = "导出收费站管制分析" , tags = { "ECharts导出" } )
@GetMapping ( "/exportGetTollStationAnalysis" )
public void exportGetTollStationAnalysis ( HttpServletResponse response ) {
AjaxResult ajaxResult = trafficIncidentsService . getTollStationAnalysis ( ) ;
List < TollStationAnalysis > list = new ArrayList < > ( ) ;
if ( ajaxResult . get ( "code" ) . equals ( UniversalEnum . TWO_HUNDRED . getNumber ( ) ) ) {
List < Map < String , Object > > data = ( List < Map < String , Object > > ) ajaxResult . get ( "data" ) ;
for ( Map < String , Object > datum : data ) {
TollStationAnalysis tollStationAnalysis = new TollStationAnalysis ( ) ;
tollStationAnalysis . setFacilityName ( datum . get ( "facilityName" ) . toString ( ) ) ;
tollStationAnalysis . setTrafficClose ( datum . get ( "trafficClose" ) . toString ( ) ) ;
tollStationAnalysis . setTrafficRestriction ( datum . get ( "trafficRestriction" ) . toString ( ) ) ;
list . add ( tollStationAnalysis ) ;
}
}
ExcelUtil < TollStationAnalysis > util = new ExcelUtil < > ( TollStationAnalysis . class ) ;
util . exportExcel ( response , list , "收费站管制分析" ) ;
}
/ * *
* @Description 路网管控 - 事件管控分析 - 事故多发路段分析
*
@ -212,6 +306,31 @@ public class DcTrafficIncidentsController {
return trafficIncidentsService . selectRoadSectionAnalysis ( direction , type , startTime ) ;
}
@ApiOperation ( value = "导出事故多发路段分析" , tags = { "ECharts导出" } )
@GetMapping ( "/exportSelectRoadSectionAnalysis" )
public void exportSelectRoadSectionAnalysis ( HttpServletResponse response ,
@ApiParam ( value = "方向" , name = "direction" , required = true ) @RequestParam ( "direction" ) String direction ,
@ApiParam ( value = "类型(1:日, 2:月, 3:季度, 4-年)" , name = "type" , required = true ) @RequestParam ( "type" ) String type ,
@ApiParam ( value = "时间" , name = "startTime" , required = true ) @RequestParam ( "startTime" ) String startTime ) {
AjaxResult ajaxResult = trafficIncidentsService . selectRoadSectionAnalysis ( direction , type , startTime ) ;
List < RoadSectionAnalysis > list = new ArrayList < > ( ) ;
if ( ajaxResult . get ( "code" ) . equals ( UniversalEnum . TWO_HUNDRED . getNumber ( ) ) ) {
List < Map < String , Object > > data = ( List < Map < String , Object > > ) ajaxResult . get ( "data" ) ;
for ( Map < String , Object > datum : data ) {
RoadSectionAnalysis roadSectionAnalysis = new RoadSectionAnalysis ( ) ;
roadSectionAnalysis . setSection_name ( datum . get ( "section_name" ) . toString ( ) ) ;
roadSectionAnalysis . setNum ( datum . get ( "num" ) . toString ( ) ) ;
roadSectionAnalysis . setAvgNum ( datum . get ( "avgNum" ) . toString ( ) ) ;
roadSectionAnalysis . setLastNum ( datum . get ( "lastNum" ) . toString ( ) ) ;
roadSectionAnalysis . setMileage ( datum . get ( "mileage" ) . toString ( ) ) ;
list . add ( roadSectionAnalysis ) ;
}
}
ExcelUtil < RoadSectionAnalysis > util = new ExcelUtil < > ( RoadSectionAnalysis . class ) ;
util . exportExcel ( response , list , "事故多发路段分析" ) ;
}
/ * *
* @Description 路网管控 - 事件管控分析 - 事故类型分析
*
@ -229,4 +348,29 @@ public class DcTrafficIncidentsController {
@ApiParam ( value = "时间" , name = "startTime" , required = true ) @RequestParam ( "startTime" ) String startTime ) {
return trafficIncidentsService . selectEventTypeAnalysis ( direction , type , startTime ) ;
}
@ApiOperation ( value = "导出事故类型分析" , tags = { "ECharts导出" } )
@GetMapping ( "/exportSelectEventTypeAnalysis" )
public void exportSelectEventTypeAnalysis ( HttpServletResponse response ,
@ApiParam ( value = "方向" , name = "direction" , required = true ) @RequestParam ( "direction" ) String direction ,
@ApiParam ( value = "类型(1:日, 2:月, 3:季度, 4-年)" , name = "type" , required = true ) @RequestParam ( "type" ) String type ,
@ApiParam ( value = "时间" , name = "startTime" , required = true ) @RequestParam ( "startTime" ) String startTime ) {
AjaxResult ajaxResult = trafficIncidentsService . selectEventTypeAnalysis ( direction , type , startTime ) ;
List < EventTypeAnalysis > list = new ArrayList < > ( ) ;
if ( ajaxResult . get ( "code" ) . equals ( UniversalEnum . TWO_HUNDRED . getNumber ( ) ) ) {
List < Map < String , Object > > data = ( List < Map < String , Object > > ) ajaxResult . get ( "data" ) ;
for ( Map < String , Object > datum : data ) {
EventTypeAnalysis eventTypeAnalysis = new EventTypeAnalysis ( ) ;
eventTypeAnalysis . setEventSubclassName ( datum . get ( "eventSubclassName" ) . toString ( ) ) ;
eventTypeAnalysis . setNum ( datum . get ( "num" ) . toString ( ) ) ;
eventTypeAnalysis . setLastNum ( datum . get ( "lastNum" ) . toString ( ) ) ;
eventTypeAnalysis . setAvgTime ( datum . get ( "avgTime" ) . toString ( ) ) ;
eventTypeAnalysis . setLastAvgTime ( datum . get ( "lastAvgTime" ) . toString ( ) ) ;
list . add ( eventTypeAnalysis ) ;
}
}
ExcelUtil < EventTypeAnalysis > util = new ExcelUtil < > ( EventTypeAnalysis . class ) ;
util . exportExcel ( response , list , "事故类型分析" ) ;
}
}