Browse Source

管控事件分析echarts数据导出

处置记录修改
develop
lau572 5 months ago
parent
commit
b6a0d967a5
  1. 144
      zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java
  2. 63
      zc-business/src/main/java/com/zc/business/domain/export/AccidentVehicleAnalysis.java
  3. 61
      zc-business/src/main/java/com/zc/business/domain/export/AllEventNum.java
  4. 62
      zc-business/src/main/java/com/zc/business/domain/export/EventTrend.java
  5. 87
      zc-business/src/main/java/com/zc/business/domain/export/EventTypeAnalysis.java
  6. 86
      zc-business/src/main/java/com/zc/business/domain/export/RoadSectionAnalysis.java
  7. 61
      zc-business/src/main/java/com/zc/business/domain/export/TollStationAnalysis.java
  8. 1
      zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java
  9. 2
      zc-business/src/main/java/com/zc/business/enums/ValueConverter.java
  10. 3
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  11. 8
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

144
zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java

@ -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, "事故类型分析");
}
}

63
zc-business/src/main/java/com/zc/business/domain/export/AccidentVehicleAnalysis.java

@ -0,0 +1,63 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 导出事故车型分析对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class AccidentVehicleAnalysis extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 事故类型 */
@Excel(name = "车型")
private String typeName;
/** 事件数量 */
@Excel(name = "事件数量")
private String num;
/** 平均处置时长 */
@Excel(name = "平均处置时长")
private String avgTime;
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getAvgTime() {
return avgTime;
}
public void setAvgTime(String avgTime) {
this.avgTime = avgTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("typeName", getTypeName())
.append("num", getNum())
.append("avgTime", getAvgTime())
.toString();
}
}

61
zc-business/src/main/java/com/zc/business/domain/export/AllEventNum.java

@ -0,0 +1,61 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* 导出事件类型分析对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class AllEventNum extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 类型 */
@Excel(name = "类型")
private String eventName;
/** 数量 */
@Excel(name = "数量")
private String num;
/** 占比 */
@Excel(name = "占比")
private String ratio;
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getRatio() {
return ratio;
}
public void setRatio(String ratio) {
this.ratio = ratio;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("eventName", eventName)
.append("num", num)
.append("ratio", ratio)
.toString();
}
}

62
zc-business/src/main/java/com/zc/business/domain/export/EventTrend.java

@ -0,0 +1,62 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 导出今日事件趋势对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class EventTrend extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 时间 */
@Excel(name = "时间")
private String hours;
/** 感知事件 */
@Excel(name = "感知事件")
private String perception;
/** 交通事件 */
@Excel(name = "交通事件")
private String traffic;
public String getHours() {
return hours;
}
public void setHours(String hours) {
this.hours = hours;
}
public String getPerception() {
return perception;
}
public void setPerception(String perception) {
this.perception = perception;
}
public String getTraffic() {
return traffic;
}
public void setTraffic(String traffic) {
this.traffic = traffic;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("hours", hours)
.append("perception", perception)
.append("traffic", traffic)
.toString();
}
}

87
zc-business/src/main/java/com/zc/business/domain/export/EventTypeAnalysis.java

@ -0,0 +1,87 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 导出事故类型分析对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class EventTypeAnalysis extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 事故类型 */
@Excel(name = "事故类型")
private String eventSubclassName;
/** 事件数量 */
@Excel(name = "事件数量")
private String num;
/** 去年同期总量 */
@Excel(name = "去年同期总量")
private String lastNum;
/** 平均处置时长 */
@Excel(name = "平均处置时长")
private String avgTime;
/** 去年同期平均处置时长 */
@Excel(name = "去年同期平均处置时长")
private String lastAvgTime;
public String getEventSubclassName() {
return eventSubclassName;
}
public void setEventSubclassName(String eventSubclassName) {
this.eventSubclassName = eventSubclassName;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getLastNum() {
return lastNum;
}
public void setLastNum(String lastNum) {
this.lastNum = lastNum;
}
public String getAvgTime() {
return avgTime;
}
public void setAvgTime(String avgTime) {
this.avgTime = avgTime;
}
public String getLastAvgTime() {
return lastAvgTime;
}
public void setLastAvgTime(String lastAvgTime) {
this.lastAvgTime = lastAvgTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("eventSubclassName", getEventSubclassName())
.append("num", getNum())
.append("avgTime", getAvgTime())
.append("lastNum", getLastNum())
.append("lastAvgTime", getLastAvgTime())
.toString();
}
}

86
zc-business/src/main/java/com/zc/business/domain/export/RoadSectionAnalysis.java

@ -0,0 +1,86 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 导出事故多发路段分析对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class RoadSectionAnalysis extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 路段 */
@Excel(name = "路段")
private String section_name;
/** 事故总量 */
@Excel(name = "事故总量")
private String num;
/** 百公里事故总量 */
@Excel(name = "百公里事故总量")
private String avgNum;
/** 去年事故总量 */
@Excel(name = "去年事故总量")
private String lastNum;
/** 路段里程数 */
@Excel(name = "路段里程数")
private String mileage;
public String getSection_name() {
return section_name;
}
public void setSection_name(String section_name) {
this.section_name = section_name;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getAvgNum() {
return avgNum;
}
public void setAvgNum(String avgNum) {
this.avgNum = avgNum;
}
public String getLastNum() {
return lastNum;
}
public void setLastNum(String lastNum) {
this.lastNum = lastNum;
}
public String getMileage() {
return mileage;
}
public void setMileage(String mileage) {
this.mileage = mileage;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("section_name", getSection_name())
.append("num", getNum())
.append("avgNum", getAvgNum())
.append("lastNum", getLastNum())
.append("mileage", getMileage())
.toString();
}
}

61
zc-business/src/main/java/com/zc/business/domain/export/TollStationAnalysis.java

@ -0,0 +1,61 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* 导出收费站管制分析对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class TollStationAnalysis extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 时间 */
@Excel(name = "收费站")
private String facilityName;
/** 封闭 */
@Excel(name = "封闭")
private String trafficClose;
/** 限行 */
@Excel(name = "限行")
private String trafficRestriction;
public String getFacilityName() {
return facilityName;
}
public void setFacilityName(String facilityName) {
this.facilityName = facilityName;
}
public String getTrafficClose() {
return trafficClose;
}
public void setTrafficClose(String trafficClose) {
this.trafficClose = trafficClose;
}
public String getTrafficRestriction() {
return trafficRestriction;
}
public void setTrafficRestriction(String trafficRestriction) {
this.trafficRestriction = trafficRestriction;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("facilityName", facilityName)
.append("trafficClose", trafficClose)
.append("trafficRestriction", trafficRestriction)
.toString();
}
}

1
zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java

@ -1917,6 +1917,7 @@ public enum UniversalEnum {
//dcEventAccident.location
DC_EVENT_ACCIDENT_LOCATION(0, "dcEventAccident.location"),
DC_EVENT_ACCIDENT_RAMP_ID(0, "dcEventAccident.rampId"),
// warningStrategy
WARNING_STRATEGY(0, "warningStrategy"),

2
zc-business/src/main/java/com/zc/business/enums/ValueConverter.java

@ -231,7 +231,7 @@ public class ValueConverter {
eventLabel.put("dcEventAccident.fatalities","死亡(人)");
eventLabel.put("dcEventAccident.isPrivate","私密事件");
eventLabel.put("dcEventAccident.facilityId","设施");
// eventLabel.put("dcEventAccident.rampId","匝道id");
eventLabel.put("dcEventAccident.rampId","匝道id");
eventLabel.put("dcEventAccident.location","地点");
eventLabel.put("dcEventConstruction.controlMode","管制方式");
eventLabel.put("dcEventConstruction.locationType","地点类型");

3
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -1774,7 +1774,8 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
if (dcFacility != null){
result.setRight(dcFacility.getFacilityName());
}
} else if (UniversalEnum.DC_EVENT_ACCIDENT_LOCATION.getValue().equals(result.getRightPath())){
} else if (UniversalEnum.DC_EVENT_ACCIDENT_LOCATION.getValue().equals(result.getRightPath())
|| UniversalEnum.DC_EVENT_ACCIDENT_RAMP_ID.getValue().equals(result.getRightPath())){
DcEventAccident dcEventAccident = newEvent.getDcEventAccident();
if (dcEventAccident.getLocationType() == UniversalEnum.THREE.getNumber()){

8
zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

@ -65,9 +65,11 @@
</select>
<select id="selectStatusCountByEventType" resultType="java.util.Map" parameterType="String">
select event_state eventState,count(*) num from dc_event
where event_type = #{eventType} and date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
group by event_state
(SELECT '0' eventState,count(*) num FROM dc_event where event_type = #{eventType} and date_format(create_time,'%y%m%d') = date_format(now(),'%y%m%d') and event_state = '0')
UNION All
(SELECT '1' eventState,count(*) num FROM dc_event where event_type = #{eventType} and date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d') and event_state = '1')
UNION All
(SELECT '2' eventState,count(*) num FROM dc_event where event_type = #{eventType} and date_format(end_time,'%y%m%d') = date_format(now(),'%y%m%d') and event_state = '2')
</select>
<select id="getEventTypeRatio" resultType="java.util.Map">

Loading…
Cancel
Save