Commit b983208b authored by zhoushiguang's avatar zhoushiguang

事件报警

parent 3ddf29dc
...@@ -95,7 +95,7 @@ public class EventController { ...@@ -95,7 +95,7 @@ public class EventController {
@GetMapping("/getAlarmInfo") @GetMapping("/getAlarmInfo")
@ApiOperation(hidden = false, value = "事件报警", notes = "", produces = "application/json") @ApiOperation(hidden = false, value = "事件报警", notes = "", produces = "application/json")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "timeScope", value = "时间范围:为1查询最近实时30条,为空时查询当天历史", required = false, dataType = "String"), @ApiImplicitParam(name = "realtimeType", value = "查询类型:1为实时 2为历史", required = false, dataType = "String"),
@ApiImplicitParam(name = "eventType", value = "事件类型,701:空放 702:失衡 703:溢出 705:干线缓行 706:干线拥堵 707:路口拥堵", required = false, dataType = "String"), @ApiImplicitParam(name = "eventType", value = "事件类型,701:空放 702:失衡 703:溢出 705:干线缓行 706:干线拥堵 707:路口拥堵", required = false, dataType = "String"),
@ApiImplicitParam(name = "name", value = "按名称模糊查询", required = false, dataType = "String"), @ApiImplicitParam(name = "name", value = "按名称模糊查询", required = false, dataType = "String"),
...@@ -105,10 +105,10 @@ public class EventController { ...@@ -105,10 +105,10 @@ public class EventController {
@ApiResponse(code = 200, message = "成功", response = EventAlarmInfo.class, @ApiResponse(code = 200, message = "成功", response = EventAlarmInfo.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")}) responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
}) })
public JsonViewObject list(@RequestParam(defaultValue = "") String timeScope, @RequestParam(defaultValue = "") String eventType , @RequestParam(defaultValue = "") String name) { public JsonViewObject list(@RequestParam(defaultValue = "") String realtimeType, @RequestParam(defaultValue = "") String eventType , @RequestParam(defaultValue = "") String name) {
try { try {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
List<EventAlarmInfo> eventAlarmInfo = eventService.findEventAlarmInfo(timeScope,eventType,name); List<EventAlarmInfo> eventAlarmInfo = eventService.findEventAlarmInfo(realtimeType,eventType,name);
return jsonViewObject.success(eventAlarmInfo); return jsonViewObject.success(eventAlarmInfo);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
......
...@@ -31,6 +31,6 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> { ...@@ -31,6 +31,6 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> {
List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params); List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params);
List<EventAlarmInfo> findEventAlarmInfo(String timeScope,String eventType,String name); List<EventAlarmInfo> findEventAlarmInfo(String realtimeType,String eventType,String name);
} }
...@@ -45,4 +45,7 @@ public class EventAlarmInfo { ...@@ -45,4 +45,7 @@ public class EventAlarmInfo {
@ApiModelProperty(value = "是否优化标识") @ApiModelProperty(value = "是否优化标识")
private String optStatus; private String optStatus;
@ApiModelProperty(value = "持续时间,单位秒")
private Integer duration;
} }
...@@ -79,5 +79,5 @@ public interface EventService { ...@@ -79,5 +79,5 @@ public interface EventService {
* @return * @return
* @throws DubboProviderException * @throws DubboProviderException
*/ */
List<EventAlarmInfo> findEventAlarmInfo(String timeScope,String eventType,String name) throws DubboProviderException; List<EventAlarmInfo> findEventAlarmInfo(String realtimeType,String eventType,String name) throws DubboProviderException;
} }
...@@ -251,9 +251,9 @@ public class EventServiceImpl implements EventService { ...@@ -251,9 +251,9 @@ public class EventServiceImpl implements EventService {
} }
@Override @Override
public List<EventAlarmInfo> findEventAlarmInfo(String timeScope, String eventType, String name) throws DubboProviderException { public List<EventAlarmInfo> findEventAlarmInfo(String realtimeType, String eventType, String name) throws DubboProviderException {
//获取数据库数据 //获取数据库数据
List<EventAlarmInfo> eventAlarmInfo = holoEventMapper.findEventAlarmInfo(timeScope, eventType, name); List<EventAlarmInfo> eventAlarmInfo = holoEventMapper.findEventAlarmInfo(realtimeType, eventType, name);
return eventAlarmInfo; return eventAlarmInfo;
} }
......
...@@ -100,17 +100,19 @@ ...@@ -100,17 +100,19 @@
<select id="findEventAlarmInfo" parameterType="String" resultMap="eventAlarm"> <select id="findEventAlarmInfo" parameterType="String" resultMap="eventAlarm">
<!-- 已结束的排在后面,未结束的排在前面 --> <!-- 已结束的排在后面,未结束的排在前面,【实时报警时,结束状态只取最近30条,未结束的全部展示】 -->
select d.green_id ,d.cross_id , d.cross_name ,d.issue_time ,d.current_algo ,d.wkt , d.type,d.new_recoder , d.opt_status from select d.green_id ,d.cross_id , d.cross_name ,d.issue_time ,d.current_algo ,d.wkt , d.type,d.new_recoder , d.opt_status,d.duration
from
( (
( <!-- 查询未结束事件b.alarm_status in (0,1,2) --> ( <!-- 查询未结束事件b.alarm_status in (0,1,2) -->
select b.green_id ,b.cross_id , b.cross_name , DATE_FORMAT(b.issue_time,'%H:%i') as issue_time ,b.current_algo ,b.wkt , select b.green_id ,b.cross_id , b.cross_name , DATE_FORMAT(b.issue_time,'%H:%i') as issue_time ,b.current_algo ,b.wkt ,
case b.alarm_status when 0 then '未处理' when 1 then '分析中' when 2 then '优化中' end as type, b.opt_status, case b.alarm_status when 0 then '未处理' when 1 then '分析中' when 2 then '优化中' end as type, b.opt_status,
case when b.issue_time > DATE_SUB(NOW(), INTERVAL 1 MINUTE) then '1' else '0' end as new_recoder, 1 as type2,b.event_type case when b.issue_time > DATE_SUB(NOW(), INTERVAL 1 MINUTE) then '1' else '0' end as new_recoder, 1 as type2,b.event_type,b.duration
from from
( (
<!-- 查询路口事件 --> <!-- 查询路口事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , a.start_time as issue_time, b.label as current_algo, SUBSTRING(c.location FROM 7 FOR 20) as wkt,a.alarm_status,a.opt_status select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , a.start_time as issue_time, b.label as current_algo, SUBSTRING(c.location FROM 7 FOR 20) as wkt,a.alarm_status,a.opt_status
,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
from t_event_info a from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
left join t_base_cross_info c on a.cross_id = c.id left join t_base_cross_info c on a.cross_id = c.id
...@@ -118,6 +120,7 @@ ...@@ -118,6 +120,7 @@
union union
<!-- 查询干线事件 --> <!-- 查询干线事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , a.start_time as issue_time, b.label as current_algo, c.wkt,a.alarm_status,a.opt_status select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , a.start_time as issue_time, b.label as current_algo, c.wkt,a.alarm_status,a.opt_status
,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
from t_event_info a from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
left join t_greenwave_info c on a.green_id = c.id left join t_greenwave_info c on a.green_id = c.id
...@@ -128,11 +131,11 @@ ...@@ -128,11 +131,11 @@
union union
( <!-- 查询事件结束b.alarm_status in (3,4) --> ( <!-- 查询事件结束b.alarm_status in (3,4) -->
select b.green_id ,b.cross_id , b.cross_name , b.issue_time ,b.current_algo ,b.wkt , select b.green_id ,b.cross_id , b.cross_name , b.issue_time ,b.current_algo ,b.wkt ,
'已结束' as type, b.opt_status,'0' as new_recoder, 2 as type2,b.event_type '已结束' as type, b.opt_status,'0' as new_recoder, 2 as type2,b.event_type,b.duration
from from
( <!-- 查询路口空放、失衡、溢出、拥堵事件 --> ( <!-- 查询路口空放、失衡、溢出、拥堵事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , DATE_FORMAT(a.start_time,'%H:%i') as issue_time, b.label as current_algo, SUBSTRING(c.location FROM 7 FOR 20) as wkt, select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , DATE_FORMAT(a.start_time,'%H:%i') as issue_time, b.label as current_algo, SUBSTRING(c.location FROM 7 FOR 20) as wkt,
a.alarm_status ,a.opt_status a.alarm_status ,a.opt_status,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
from t_event_info a from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
left join t_base_cross_info c on a.cross_id = c.id left join t_base_cross_info c on a.cross_id = c.id
...@@ -140,6 +143,7 @@ ...@@ -140,6 +143,7 @@
union union
<!-- 查询干线事件缓行、拥堵事件 --> <!-- 查询干线事件缓行、拥堵事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , DATE_FORMAT(a.start_time,'%H:%i') as issue_time, b.label as current_algo, c.wkt,a.alarm_status ,a.opt_status select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , DATE_FORMAT(a.start_time,'%H:%i') as issue_time, b.label as current_algo, c.wkt,a.alarm_status ,a.opt_status
,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
from t_event_info a from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4 ) b on a.type = b.event_type left join (select a.event_type, a.label from t_config_event_category a where a.category = 4 ) b on a.type = b.event_type
left join t_greenwave_info c on a.green_id = c.id left join t_greenwave_info c on a.green_id = c.id
...@@ -147,6 +151,10 @@ ...@@ -147,6 +151,10 @@
) b ) b
where b.alarm_status in (3,4) where b.alarm_status in (3,4)
order by b.issue_time desc order by b.issue_time desc
<!-- 实时报警时,结束状态只取最后30条 -->
<if test="realtimeType != null and realtimeType != '' and realtimeType=='1'.toString()">
LIMIT 30
</if>
) )
ORDER BY type2,issue_time desc ORDER BY type2,issue_time desc
) d ) d
...@@ -157,9 +165,7 @@ ...@@ -157,9 +165,7 @@
<if test= "eventType != null and eventType != '' "> <if test= "eventType != null and eventType != '' ">
and d.event_type = #{eventType} and d.event_type = #{eventType}
</if> </if>
<if test="timeScope != null and timeScope != '' ">
LIMIT 30
</if>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment