Browse Source

事件管控分析接口

develop
lau572 10 months ago
parent
commit
e19d696d2e
  1. 95
      zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java
  2. 68
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java
  3. 84
      zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java
  4. 287
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java
  5. 188
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

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

@ -6,10 +6,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @Description 交通事件统计
@ -82,16 +81,100 @@ public class DcTrafficIncidentsController {
}
/**
* @Description 路网管控-事件管控分析-统计各类型的交通事件数量
* @Description 路网管控-事件管控分析-事件类型分析占比
*
* @author liuwenge
* @date 2024/1/13 15:07
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("统计各类型的交通事件数量")
@ApiOperation("事件类型分析占比")
@GetMapping("/getAllEventNum")
public AjaxResult getAllEventNum(){
return trafficIncidentsService.getAllEventNum();
}
/**
* @Description 路网管控-事件管控分析-事件源分析占比
*
* @author liuwenge
* @date 2024/1/13 15:07
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("事件源分析占比")
@GetMapping("/getEventSourceRatio")
public AjaxResult getEventSourceRatio(){
return trafficIncidentsService.getEventSourceRatio();
}
/**
* @Description 路网管控-事件管控分析-今日事件趋势
*
* @author liuwenge
* @date 2024/1/15 14:30
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("今日事件趋势")
@GetMapping("/getEventTrend")
public AjaxResult getEventTrend(){
return trafficIncidentsService.getEventTrend();
}
/**
* @Description 路网管控-事件管控分析-事故车型分析
*
* @author liuwenge
* @date 2024/1/15 15:38
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("事故车型分析")
@GetMapping("/getAccidentVehicleAnalysis")
public AjaxResult getAccidentVehicleAnalysis(){
return trafficIncidentsService.getAccidentVehicleAnalysis();
}
/**
* @Description 路网管控-事件管控分析-收费站统计分析table
*
* @author liuwenge
* @date 2024/1/15 17:31
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("收费站统计分析table")
@PostMapping("/selectTollStationAnalysis")
public AjaxResult selectTollStationAnalysis(@RequestBody Map<String,Object> params){
return trafficIncidentsService.selectTollStationAnalysis(params);
}
/**
* @Description 路网管控-事件管控分析-收费站统计分析echarts(当月)
*
* @author liuwenge
* @date 2024/1/16 11:09
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("收费站统计分析echarts(当月)")
@GetMapping("/getTollStationAnalysis")
public AjaxResult getTollStationAnalysis(){
return trafficIncidentsService.getTollStationAnalysis();
}
/**
* @Description 路网管控-事件管控分析-事故多发路段分析
*
* @author liuwenge
* @date 2024/1/16 15:52
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("收费站统计分析table")
@PostMapping("/selectRoadSectionAnalysis")
public AjaxResult selectRoadSectionAnalysis(@RequestBody Map<String,Object> params){
return trafficIncidentsService.selectRoadSectionAnalysis(params);
}
}

68
zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java

@ -121,5 +121,73 @@ public interface DcTrafficIncidentsMapper {
*/
List<Map<String,Object>> selectStatusCountByEventType(String eventType);
/**
* @Description 路网管控-事件管控分析-事件类型分析占比
*
* @author liuwenge
* @date 2024/1/13 17:42
* @param
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String, Object>> getEventTypeRatio();
/**
* @Description 路网管控-事件管控分析-事件源分析占比
*
* @author liuwenge
* @date 2024/1/13 17:42
* @param
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String, Object>> getEventSourceRatio();
/**
* @Description 当日交通事件趋势
*
* @author liuwenge
* @date 2024/1/15 14:33
* @param
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String, Object>> getTrafficTrend();
/**
* @Description 当日感知事件趋势
*
* @author liuwenge
* @date 2024/1/15 14:33
* @param
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String, Object>> getPerceptionTrend();
/**
* @Description 事故车型分析
*
* @author liuwenge
* @date 2024/1/15 15:41
* @param
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String,Long>> getAccidentVehicleAnalysis();
/**
* @Description 收费站统计分析table
*
* @author liuwenge
* @date 2024/1/16 14:18
* @param params
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String,Object>> selectTollStationAnalysis(Map<String,Object> params);
/**
* @Description 收费站统计分析echarts
*
* @author liuwenge
* @date 2024/1/16 14:18
* @param
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String,Object>> getTollStationAnalysis();
}

84
zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java

@ -1,6 +1,11 @@
package com.zc.business.service;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
/**
* @Description 交通事件统计Service接口
@ -11,52 +16,103 @@ import com.ruoyi.common.core.domain.AjaxResult;
public interface IDcTrafficIncidentsService {
/**
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 首页-重点数据
*
* @author liuwenge
* @date 2024/1/13 10:09
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult getKeyData();
/**
* @param eventType
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 首页-事件专题-根据事件类型获取事件列表
*
* @author liuwenge
* @date 2024/1/13 14:26
* @param eventType
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult getEventListByType(String eventType);
/**
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 首页-事件专题-根据事件id获取详情
*
* @author liuwenge
* @date 2024/1/13 14:43
* @param eventId
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult getEventInfo(String eventId);
/**
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 首页-状况统计-获取日年的交通事件数量
*
* @author liuwenge
* @date 2024/1/13 15:08
*/
AjaxResult getTrafficIncidentsNum();
/**
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 路网管控-事件管控分析-事件类型分析占比
* @author liuwenge
* @date 2024/1/13 15:46
*/
AjaxResult getTrafficIncidentsNum();
AjaxResult getAllEventNum();
/**
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 路网管控-事件管控分析-事件源分析占比
* @author liuwenge
* @date 2024/1/13 17:37
*/
AjaxResult getEventSourceRatio();
/**
* @Description 路网管控-事件管控分析-统计各类型的交通事件数量
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 路网管控-事件管控分析-今日事件趋势
* @author liuwenge
* @date 2024/1/15 14:30
*/
AjaxResult getEventTrend();
/**
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 路网管控-事件管控分析-事故车型分析
* @author liuwenge
* @date 2024/1/15 15:38
*/
AjaxResult getAccidentVehicleAnalysis();
/**
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
* @Description 路网管控-事件管控分析-收费站统计分析table
* @author liuwenge
* @date 2024/1/15 17:31
*/
AjaxResult selectTollStationAnalysis(Map<String, Object> params);
/**
* @Description 路网管控-事件管控分析-收费站统计分析echarts(当月)
*
* @author liuwenge
* @date 2024/1/13 15:46
* @date 2024/1/16 11:11
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult getAllEventNum();
AjaxResult getTollStationAnalysis();
/**
* @Description 路网管控-事件管控分析-事故多发路段分析
*
* @author liuwenge
* @date 2024/1/16 15:52
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult selectRoadSectionAnalysis(Map<String,Object> params);
}

287
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java

@ -8,9 +8,12 @@ import com.zc.business.service.IDcTrafficIncidentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.Year;
import java.util.*;
/**
* @Description 交通事件统计Service业务层处理
@ -101,7 +104,7 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService
}
/**
* @Description 路网管控-事件管控分析-统计各类型的交通事件数量
* @Description 路网管控-事件管控分析-事件类型分析占比
*
* @author liuwenge
* @date 2024/1/13 15:46
@ -110,7 +113,7 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService
*/
@Override
public AjaxResult getAllEventNum(){
//事件类型
/*//事件类型
List<Map<String,Object>> eventTypeList = trafficIncidentsMapper.selectEventTypeList();
for (Map<String, Object> eventType : eventTypeList) {
@ -135,19 +138,289 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService
total += Integer.parseInt(eventTypeData.get("num").toString());
}
eventType.put("total",total);
} else {
}
if (!eventType.containsKey("unconfirmed")){
//待确认
eventType.put("unconfirmed", "0");
} else if (!eventType.containsKey("processing")){
//处理中
eventType.put("processing", "0");
} else if (!eventType.containsKey("finished")){
//已完成
eventType.put("finished", "0");
} else if (!eventType.containsKey("total")){
//总数
eventType.put("total", "0");
}
}*/
List<Map<String,Object>> eventTypeRatio = trafficIncidentsMapper.getEventTypeRatio();
return AjaxResult.success(eventTypeRatio);
}
/**
* @Description 路网管控-事件管控分析-事件源分析占比
*
* @author liuwenge
* @date 2024/1/13 17:38
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult getEventSourceRatio(){
List<Map<String,Object>> eventSourceRatio = trafficIncidentsMapper.getEventSourceRatio();
return AjaxResult.success(eventSourceRatio);
}
/**
* @Description 路网管控-事件管控分析-今日事件趋势
*
* @author liuwenge
* @date 2024/1/15 14:31
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult getEventTrend(){
Map<String,Object> result = new HashMap<>();
//交通事件趋势
List<Map<String,Object>> traffic = trafficIncidentsMapper.getTrafficTrend();
//感知世间趋势
List<Map<String,Object>> perception = trafficIncidentsMapper.getPerceptionTrend();
result.put("traffic",traffic);
result.put("perception",perception);
return AjaxResult.success(result);
}
/**
* @Description 路网管控-事件管控分析-事故车型分析
*
* @author liuwenge
* @date 2024/1/15 15:38
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult getAccidentVehicleAnalysis(){
List<Map<String,Long>> list = trafficIncidentsMapper.getAccidentVehicleAnalysis();
Map<String,Object> smallCar = new HashMap<>();
smallCar.put("type","smallCar");
smallCar.put("num",0);
smallCar.put("allTime",0);
Map<String,Object> trucks = new HashMap<>();
trucks.put("type","trucks");
trucks.put("num",0);
trucks.put("allTime",0);
Map<String,Object> buses = new HashMap<>();
buses.put("type","buses");
buses.put("num",0);
buses.put("allTime",0);
Map<String,Object> tankers = new HashMap<>();
tankers.put("type","tankers");
tankers.put("num",0);
tankers.put("allTime",0);
//计算各车型总处理时长
for (Map<String, Long> data : list) {
if (data.get("smallCar") > 0){
smallCar.put("num",Integer.parseInt(smallCar.get("num").toString()) + 1);
smallCar.put("allTime",Long.parseLong(smallCar.get("allTime").toString()) + data.get("minuteTime"));
}
if (data.get("trucks") > 0){
trucks.put("num",Integer.parseInt(trucks.get("num").toString()) + 1);
trucks.put("allTime",Long.parseLong(trucks.get("allTime").toString()) + data.get("minuteTime"));
}
if (data.get("buses") > 0){
buses.put("num",Integer.parseInt(buses.get("num").toString()) + 1);
buses.put("allTime",Long.parseLong(buses.get("allTime").toString()) + data.get("minuteTime"));
}
if (data.get("tankers") > 0){
tankers.put("num",Integer.parseInt(tankers.get("num").toString()) + 1);
tankers.put("allTime",Long.parseLong(tankers.get("allTime").toString()) + data.get("minuteTime"));
}
}
List<Map<String,Object>> result = new ArrayList<>();
//小型车平均时长
if (Long.parseLong(smallCar.get("num").toString()) > 0){
smallCar.put("avgTime",Long.parseLong(smallCar.get("allTime").toString()) / Long.parseLong(smallCar.get("num").toString()));
} else {
smallCar.put("avgTime",0);
}
result.add(smallCar);
//货车平均时长
if (Long.parseLong(trucks.get("num").toString()) > 0){
trucks.put("avgTime",Long.parseLong(trucks.get("allTime").toString()) / Long.parseLong(trucks.get("num").toString()));
} else {
trucks.put("avgTime",0);
}
result.add(trucks);
//客车平均时长
if (Long.parseLong(buses.get("num").toString()) > 0){
buses.put("avgTime",Long.parseLong(buses.get("allTime").toString()) / Long.parseLong(buses.get("num").toString()));
} else {
buses.put("avgTime",0);
}
result.add(buses);
//罐车平均时长
if (Long.parseLong(tankers.get("num").toString()) > 0){
tankers.put("avgTime",Long.parseLong(tankers.get("allTime").toString()) / Long.parseLong(tankers.get("num").toString()));
} else {
tankers.put("avgTime",0);
}
result.add(tankers);
return AjaxResult.success(result);
}
/**
* @Description 路网管控-事件管控分析-收费站统计分析table
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
* @author liuwenge
* @date 2024/1/15 17:31
*/
@Override
public AjaxResult selectTollStationAnalysis(Map<String, Object> params){
//目标时段
List<Map<String,Object>> list = trafficIncidentsMapper.selectTollStationAnalysis(params);
BigDecimal allNum = BigDecimal.ZERO;
BigDecimal allTime = BigDecimal.ZERO;
for (Map<String, Object> data : list) {
allNum = allNum.add(new BigDecimal(data.get("num").toString()));
allTime = allTime.add(new BigDecimal(data.get("minuteTime").toString()));
}
for (Map<String, Object> data : list) {
//计算站次占比
if (allNum.compareTo(BigDecimal.ZERO) > 0){
BigDecimal numRatio = new BigDecimal(data.get("num").toString()).multiply(new BigDecimal("100")).divide(allNum,2, RoundingMode.HALF_UP);
data.put("numRatio",numRatio);
} else {
data.put("numRatio",0);
}
//计算时长占比
if (allTime.compareTo(BigDecimal.ZERO) > 0){
BigDecimal timeRatio = new BigDecimal(data.get("minuteTime").toString()).multiply(new BigDecimal("100")).divide(allTime,2, RoundingMode.HALF_UP);
data.put("timeRatio",timeRatio);
} else {
data.put("timeRatio",0);
}
}
//去年同期
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
Date startDate = dateFormat.parse(params.get("startTime").toString());
cal.setTime(startDate);
cal.add(Calendar.YEAR,-1);
String lastStartTime = dateFormat.format(cal.getTime());
Date endDate = dateFormat.parse(params.get("endTime").toString());
cal.setTime(endDate);
cal.add(Calendar.YEAR,-1);
String lastEndTime = dateFormat.format(cal.getTime());
params.put("startTime",lastStartTime);
params.put("endTime",lastEndTime);
List<Map<String,Object>> lastList = trafficIncidentsMapper.selectTollStationAnalysis(params);
BigDecimal lastAllNum = BigDecimal.ZERO;
BigDecimal lastAllTime = BigDecimal.ZERO;
for (int i = 0; i < lastList.size(); i++) {
//去年同期站次
lastAllNum = lastAllNum.add(new BigDecimal(lastList.get(i).get("num").toString()));
list.get(i).put("lastYearNum",lastList.get(i).get("num").toString());
//去年同期时长
lastAllTime = lastAllTime.add(new BigDecimal(lastList.get(i).get("minuteTime").toString()));
list.get(i).put("lastYearTime",lastList.get(i).get("minuteTime").toString());
}
for (int i = 0; i < lastList.size(); i++) {
//去年同期站次占比
if (lastAllNum.compareTo(BigDecimal.ZERO) > 0){
BigDecimal numRatio = new BigDecimal(lastList.get(i).get("num").toString()).multiply(new BigDecimal("100")).divide(lastAllNum,2, RoundingMode.HALF_UP);
list.get(i).put("lastYearNumRatio",numRatio);
} else {
list.get(i).put("lastYearNumRatio",0);
}
////去年同期时长占比
if (lastAllTime.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal timeRatio = new BigDecimal(lastList.get(i).get("minuteTime").toString()).multiply(new BigDecimal("100")).divide(lastAllTime, 2, RoundingMode.HALF_UP);
list.get(i).put("lastYearTimeRatio", timeRatio);
} else {
list.get(i).put("lastYearTimeRatio", 0);
}
}
//同比
for (Map<String, Object> map : list) {
//站次同比
if (new BigDecimal(map.get("lastYearNum").toString()).compareTo(BigDecimal.ZERO) > 0){
BigDecimal yearNumRatio = new BigDecimal(map.get("num").toString()).multiply(new BigDecimal("100")).divide(new BigDecimal(map.get("lastYearNum").toString()),2, RoundingMode.HALF_UP);
map.put("yearNumRatio",yearNumRatio);
} else {
map.put("ratio",0);
}
//时长同比
if (new BigDecimal(map.get("lastYearTime").toString()).compareTo(BigDecimal.ZERO) > 0){
BigDecimal yearTimeRatio = new BigDecimal(map.get("minuteTime").toString()).multiply(new BigDecimal("100")).divide(new BigDecimal(map.get("lastYearTime").toString()),2, RoundingMode.HALF_UP);
map.put("yearTimeRatio",yearTimeRatio);
} else {
map.put("yearTimeRatio",0);
}
}
} catch (Exception e){
e.printStackTrace();
}
return AjaxResult.success(list);
}
/**
* @Description 路网管控-事件管控分析-收费站统计分析echarts(当月)
*
* @author liuwenge
* @date 2024/1/16 11:11
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult getTollStationAnalysis(){
List<Map<String,Object>> list = trafficIncidentsMapper.getTollStationAnalysis();
return AjaxResult.success(list);
}
/**
* @Description 路网管控-事件管控分析-事故多发路段分析
*
* @author liuwenge
* @date 2024/1/16 15:52
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult selectRoadSectionAnalysis(Map<String,Object> params){
return AjaxResult.success(eventTypeList);
return AjaxResult.success();
}
}

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

@ -7,13 +7,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTrafficIncidentsProcessing" resultType="Integer">
select count(*) from dc_event
where event_type = '1' and event_state != '2' and date_format(create_time,'%y%m%d') = date_format(now(),'%y%m%d')
where event_type = '1' and event_state != '2' and date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
</select>
<select id="getTrafficIncidentsAll" resultType="Integer">
select count(*) from dc_event
where event_type = '1' and date_format(create_time,'%y%m%d') = date_format(now(),'%y%m%d')
where event_type = '1' and date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
</select>
<select id="getConstructionNum" resultType="java.lang.Integer">
@ -29,22 +29,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTrafficIncidentsDay" resultType="Long">
select count(*) from dc_event
where date_format(create_time,'%y%m%d') = date_format(now(),'%y%m%d')
where date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
</select>
<select id="selectTrafficIncidentsWeek" resultType="Long">
select count(*) from dc_event
where YEARWEEK(create_time, 1) = YEARWEEK(now(), 1)
where YEARWEEK(start_time, 1) = YEARWEEK(now(), 1)
</select>
<select id="selectTrafficIncidentsMonth" resultType="Long">
select count(*) from dc_event
where date_format(create_time,'%y%m') = date_format(now(),'%y%m')
where date_format(start_time,'%y%m') = date_format(now(),'%y%m')
</select>
<select id="selectTrafficIncidentsYear" resultType="Long">
select count(*) from dc_event
where date_format(create_time,'%y') = date_format(now(),'%y')
where date_format(start_time,'%y') = date_format(now(),'%y')
</select>
<select id="selectTrafficIncidentsAllProcessing" resultType="java.lang.Long">
@ -58,8 +58,182 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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(create_time,'%y%m%d') = date_format(now(),'%y%m%d')
where event_type = #{eventType} and date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
group by event_state
</select>
<select id="getEventTypeRatio" resultType="java.util.Map">
select t1.event_type eventType,t1.event_name eventName,IFNULL(num,0) num
FROM dc_event_type t1
left join
(select event_type eventType, count(*) num
from dc_event
where date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
group by event_type) t2
on t1.event_type = t2.eventType
</select>
<select id="getEventSourceRatio" resultType="java.util.Map">
select t1.eventSource,t1.eventSourceName,IFNULL(t2.num,0) num from
(select '1' as eventSource,'96659' as eventSourceName
UNION ALL select '2' as eventSource,'交警转接' as eventSourceName
UNION ALL select '3' as eventSource,'道路巡查' as eventSourceName
UNION ALL select '4' as eventSource,'视频巡查' as eventSourceName
UNION ALL select '5' as eventSource,'视频AI' as eventSourceName
UNION ALL select '6' as eventSource,'一键救援' as eventSourceName
UNION ALL select '7' as eventSource,'其他' as eventSourceName) t1
LEFT JOIN
(select event_source eventSource,count(*) num
from dc_event
where date_format(start_time,'%y%m%d') = date_format(now(),'%y%m%d')
group by event_source) t2
on t1.eventSource = t2.eventSource
</select>
<select id="getTrafficTrend" resultType="java.util.Map">
SELECT t1.hours, ifnull(t2.num, 0) num
FROM
(SELECT 0 hours
UNION ALL SELECT 1 hours
UNION ALL SELECT 2 hours
UNION ALL SELECT 3 hours
UNION ALL SELECT 4 hours
UNION ALL SELECT 5 hours
UNION ALL SELECT 6 hours
UNION ALL SELECT 7 hours
UNION ALL SELECT 8 hours
UNION ALL SELECT 9 hours
UNION ALL SELECT 10 hours
UNION ALL SELECT 11 hours
UNION ALL SELECT 12 hours
UNION ALL SELECT 13 hours
UNION ALL SELECT 14 hours
UNION ALL SELECT 15 hours
UNION ALL SELECT 16 hours
UNION ALL SELECT 17 hours
UNION ALL SELECT 18 hours
UNION ALL SELECT 19 hours
UNION ALL SELECT 20 hours
UNION ALL SELECT 21 hours
UNION ALL SELECT 22 hours
UNION ALL SELECT 23 hours
) t1
LEFT JOIN
(SELECT
hour(create_time) hours,
count(*) num
FROM dc_event
WHERE date_format(start_time, '%Y-%m-%d') = current_date
GROUP BY date_format(start_time, '%Y%m%d-%H'), hours
) t2
ON t1.hours = t2.hours
where HOUR(now()) >= t1.hours
ORDER BY hours
</select>
<select id="getPerceptionTrend" resultType="java.util.Map">
SELECT t1.hours, ifnull(t2.num, 0) num
FROM
(SELECT 0 hours
UNION ALL SELECT 1 hours
UNION ALL SELECT 2 hours
UNION ALL SELECT 3 hours
UNION ALL SELECT 4 hours
UNION ALL SELECT 5 hours
UNION ALL SELECT 6 hours
UNION ALL SELECT 7 hours
UNION ALL SELECT 8 hours
UNION ALL SELECT 9 hours
UNION ALL SELECT 10 hours
UNION ALL SELECT 11 hours
UNION ALL SELECT 12 hours
UNION ALL SELECT 13 hours
UNION ALL SELECT 14 hours
UNION ALL SELECT 15 hours
UNION ALL SELECT 16 hours
UNION ALL SELECT 17 hours
UNION ALL SELECT 18 hours
UNION ALL SELECT 19 hours
UNION ALL SELECT 20 hours
UNION ALL SELECT 21 hours
UNION ALL SELECT 22 hours
UNION ALL SELECT 23 hours
) t1
LEFT JOIN
(SELECT
hour(create_time) hours,count(*) num
FROM dc_warning
WHERE date_format(create_time, '%Y-%m-%d') = current_date
GROUP BY date_format(create_time, '%Y%m%d-%H'), hours) t2
ON t1.hours = t2.hours
where HOUR(now()) >= t1.hours
ORDER BY hours
</select>
<select id="getAccidentVehicleAnalysis" resultType="java.util.Map">
select t1.id,
case when ISNULL(end_time) then TIMESTAMPDIFF(MINUTE,start_time,now()) else TIMESTAMPDIFF(MINUTE,start_time,end_time) end minuteTime,
ifNull(t2.small_car,0) smallCar,
ifNull(t2.trucks,0) trucks,
ifNull(t2.buses,0) buses,
ifNull(t2.tankers,0) tankers
from dc_event t1
left join dc_event_vehicle_accident t2 on t1.id = t2.id
where event_type = '1' and date_format(start_time,'%Y-%m-%d') = current_date
</select>
<select id="selectTollStationAnalysis" resultType="java.util.Map">
select t3.control_cause controlCause,t3.cause_type causeType,controlCauseName,causeTypeName,IFNULL(t4.num,0) num,ifNull(t4.minuteTime,0) minuteTime
from
(select 1 control_cause,'' cause_type,'车流量大' controlCauseName,'' causeTypeName
UNION ALL select 2 control_cause,'' cause_type,'交通事故' controlCauseName,'' causeTypeName
UNION ALL select 3 control_cause,'3-1' cause_type,'恶劣天气' controlCauseName,'雨' causeTypeName
UNION ALL select 3 control_cause,'3-2' cause_type,'恶劣天气' controlCauseName,'雪' causeTypeName
UNION ALL select 3 control_cause,'3-3' cause_type,'恶劣天气' controlCauseName,'雾' causeTypeName
UNION ALL select 3 control_cause,'3-4' cause_type,'恶劣天气' controlCauseName,'道路积水' causeTypeName
UNION ALL select 3 control_cause,'3-5' cause_type,'恶劣天气' controlCauseName,'道路湿滑' causeTypeName
UNION ALL select 3 control_cause,'3-6' cause_type,'恶劣天气' controlCauseName,'道路结冰' causeTypeName
UNION ALL select 3 control_cause,'3-7' cause_type,'恶劣天气' controlCauseName,'沙尘暴' causeTypeName
UNION ALL select 4 control_cause,'' cause_type,'施工' controlCauseName,'' causeTypeName
UNION ALL select 5 control_cause,'' cause_type,'警备任务' controlCauseName,'' causeTypeName
UNION ALL select 6 control_cause,'' cause_type,'其他' controlCauseName,'' causeTypeName) t3
LEFT JOIN
(select t2.control_type,t2.control_cause,t2.cause_type,count(*) num,sum(
case when date_format(#{startTime},'%Y-%m-%d %H:%i:%s') >= date_format(t1.start_time,'%Y-%m-%d %H:%i:%s')
and (DATE_FORMAT(t1.end_time,'%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s') or ISNULL(t1.end_time))
then TIMESTAMPDIFF(MINUTE,t1.start_time,now())
when date_format(#{startTime},'%Y-%m-%d %H:%i:%s') >= date_format(t1.start_time,'%Y-%m-%d %H:%i:%s')
and DATE_FORMAT(t1.end_time,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
then TIMESTAMPDIFF(MINUTE,#{startTime},t1.end_time)
when date_format(#{startTime},'%Y-%m-%d %H:%i:%s') &lt;= date_format(t1.start_time,'%Y-%m-%d %H:%i:%s')
and (DATE_FORMAT(t1.end_time,'%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s') or ISNULL(t1.end_time))
then TIMESTAMPDIFF(MINUTE,t1.start_time,#{endTime})
when date_format(#{startTime},'%Y-%m-%d %H:%i:%s') &lt;= date_format(t1.start_time,'%Y-%m-%d %H:%i:%s')
and DATE_FORMAT(t1.end_time,'%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
then TIMESTAMPDIFF(MINUTE,t1.start_time,t1.end_time)
else 0 end) minuteTime
from dc_event t1 LEFT JOIN dc_event_traffic_control t2 on t1.id = t2.id
where
t1.event_type = '3' and t1.event_subclass = '3-2' and t2.control_type = #{controlType}
and date_format(t1.start_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
and (date_format(t1.end_time,'%Y-%m-%d %H:%i:%s') > date_format(#{startTime},'%Y-%m-%d %H:%i:%s') or ISNULL(t1.end_time))
GROUP BY t2.control_cause,t2.cause_type) t4
on t3.control_cause = t4.control_cause and t3.cause_type = t4.cause_type
ORDER BY t3.control_cause, t3.cause_type
</select>
<select id="getTollStationAnalysis" resultType="java.util.Map">
select t3.facility_name facilityName,ifNull(t4.trafficClose,0) trafficClose, ifnull(t4.trafficRestriction,0) trafficRestriction
from
(select * from dc_facility where facility_type = '1' ) t3
LEFT JOIN
(select t2.facility_id facilityId,sum(case when t2.control_type = '1' then 1 else 0 end) trafficClose,
sum(case when t2.control_type = '2' then 1 else 0 end) trafficRestriction
from dc_event t1 left join dc_event_traffic_control t2 on t1.id = t2.id
where (DATE_FORMAT(t1.start_time,'%Y-%m') = DATE_FORMAT(now(),'%Y-%m') or DATE_FORMAT(t1.end_time,'%Y-%m') = DATE_FORMAT(now(),'%Y-%m') or ISNULL(t1.end_time))
and t1.event_type = '3' and t1.event_subclass = '3-2'
GROUP BY t2.facility_id) t4
on t3.id = t4.facilityId
</select>
</mapper>
Loading…
Cancel
Save