Commit 1db82380 authored by zhoushiguang's avatar zhoushiguang

事件报警

parent a9d2f8a1
......@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dto.CrossIdAndMinutesDTO;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.service.EvaluateService;
import net.wanji.opt.service.EventService;
......@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
......@@ -89,4 +91,29 @@ public class EventController {
}
@GetMapping("/getAlarmInfo")
@ApiOperation(hidden = false, value = "事件报警", notes = "", produces = "application/json")
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波编号,指定干线编号时查询干线相关事件", required = false, dataType = "String"),
@ApiImplicitParam(name = "crossId", value = "路口编号,指定路口编号时查询路口相关事件", required = false, dataType = "String"),
@ApiImplicitParam(name = "type", value = "为1查询最近实时30条,为空时查询当天历史", required = false, dataType = "String")
}
)
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = EventAlarmInfo.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject list(@RequestParam(defaultValue = "") Integer greenId, @RequestParam(defaultValue = "") String crossId , @RequestParam(defaultValue = "") String type) {
try {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
List<EventAlarmInfo> eventAlarmInfo = eventService.findEventAlarmInfo(greenId,crossId,type);
return jsonViewObject.success(eventAlarmInfo);
} catch (Exception e) {
log.error("", e);
return JsonViewObject.newInstance().fail("请求失败");
}
}
}
\ No newline at end of file
......@@ -2,9 +2,11 @@ package net.wanji.opt.dao.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.po.trend.EventInfoSimplePo;
import net.wanji.opt.po.trend.HoloEventInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
......@@ -28,4 +30,7 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> {
EventStatisticPo findCrossEventCount(Map<String,Object> params);
List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params);
List<EventAlarmInfo> findEventAlarmInfo(@Param(value = "greenId") Integer greenId , @Param(value = "crossId") String crossId, @Param(value = "type") String type );
}
package net.wanji.opt.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 运行监控 路口方案下发查询
* </p>
*
* @Author hwm
* @Date 2024-12-1
*/
@Data
@ApiModel(value="EventAlarmInfo对象", description="运行监控-预警事件查询")
public class EventAlarmInfo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "绿波ID")
private Integer greenId;
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "路口名称/绿波名称")
private String crossName;
@ApiModelProperty(value = "预警类型")
private String currentAlgo;
@ApiModelProperty(value = "下发时间")
private String issueTime;
@ApiModelProperty(value = "状态类型")
private String type;
@ApiModelProperty(value = "是否新记录,0否,1是")
private String newRecoder;
@ApiModelProperty(value = "坐标点")
private String wkt;
@ApiModelProperty(value = "是否优化标识")
private String optStatus;
}
......@@ -12,6 +12,7 @@ import net.wanji.opt.bo.GreenwaveIdBO;
import net.wanji.opt.bo.SaveGreenwaveStrategyBO;
import net.wanji.opt.dto.trend.AbnormalCrossListDTO;
import net.wanji.opt.dto.trend.GreenwaveListDTO;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.po.trend.AnalysisRidTurnIndicators;
import net.wanji.opt.po.trend.HoloEventInfoPO;
......@@ -69,4 +70,14 @@ public interface EventService {
* @return
*/
List<Map<String,Object>> findEventDistribute(String crossId, String startTime, String endTime) throws DubboProviderException;
/**
* 当时事件报警数据监测
* @param greenId
* @param crossId
* @param type 为1时查询当天最近30条,为空时查询当天所有
* @return
* @throws DubboProviderException
*/
List<EventAlarmInfo> findEventAlarmInfo(Integer greenId, String crossId, String type) throws DubboProviderException;
}
......@@ -45,6 +45,7 @@ import net.wanji.opt.dao.mapper.base.BaseRidInfoMapper;
import net.wanji.opt.dao.mapper.strategy.SceneMapper;
import net.wanji.opt.dao.mapper.strategy.SceneStrategyMapper;
import net.wanji.opt.dao.mapper.strategy.StrategyMapper;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.BaseRidInfo;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.po.base.EventStatisticPo;
......@@ -249,6 +250,14 @@ public class EventServiceImpl implements EventService {
return retList;
}
@Override
public List<EventAlarmInfo> findEventAlarmInfo(Integer greenId, String crossId, String type) throws DubboProviderException {
//获取数据库数据
List<EventAlarmInfo> eventAlarmInfo = holoEventMapper.findEventAlarmInfo(greenId,crossId,type);
return eventAlarmInfo;
}
public Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) {
Set<String> indexList = new HashSet<>();
......
......@@ -2,6 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.HoloEventMapper">
<resultMap id="eventAlarm" type="net.wanji.opt.entity.EventAlarmInfo">
<id column="green_id" property="greenId" />
<result column="cross_id" property="crossId"/>
<result column="cross_name" property="crossName" />
<result column="current_algo" property="currentAlgo"/>
<result column="issue_time" property="issueTime" />
<result column="type" property="type"/>
<result column="opt_status" property="optStatus"/>
<result column="new_recoder" property="newRecoder" />
<result column="wkt" property="wkt" />
</resultMap>
<select id="selectCrossEmergencyCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM t_event_info
......@@ -86,5 +99,76 @@
</select>
<select id="findEventAlarmInfo" parameterType="String" resultMap="eventAlarm">
<!-- 已结束的排在后面,未结束的排在前面 -->
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
(
( <!-- 查询未结束事件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 ,
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
from
(
<!-- 查询路口事件 -->
select 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
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 t_base_cross_info c on a.cross_id = c.id
where a.type in (701,702,703,707) and DATE(a.start_time) = CURDATE()
union
<!-- 查询干线事件 -->
select 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
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 t_greenwave_info c on a.green_id = c.id
where a.type in (705,706) and DATE(a.start_time) = CURDATE()
) b where b.alarm_status in (0,1,2)
<if test= "greenId != null and greenId != '' ">
and b.green_id = #{greenId}
</if>
<if test= "crossId != null and crossId != '' ">
and b.cross_id = #{crossId}
</if>
order by b.issue_time desc
)
union
( <!-- 查询事件结束b.alarm_status in (3,4) -->
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
from
( <!-- 查询路口空放、失衡、溢出、拥堵事件 -->
select 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
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 t_base_cross_info c on a.cross_id = c.id
where a.type in (701,702,703,707) and DATE(a.start_time) = CURDATE()
union
<!-- 查询干线事件缓行、拥堵事件 -->
select 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
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 t_greenwave_info c on a.green_id = c.id
where a.type in (705,706) and DATE(a.start_time) = CURDATE()
) b
where b.alarm_status in (3,4)
<if test= "greenId != null and greenId != '' ">
and b.green_id = #{greenId}
</if>
<if test= "crossId != null and crossId != '' ">
and b.cross_id = #{crossId}
</if>
order by b.issue_time desc
<if test="type != null and type != '' ">
LIMIT 30
</if>
)
ORDER BY type2,issue_time desc
) d
</select>
</mapper>
\ No newline at end of file
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