Commit bd0327a7 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 73add64c 3ddf29dc
...@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.exception.DubboProviderException; import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dto.CrossIdAndMinutesDTO; import net.wanji.opt.dto.CrossIdAndMinutesDTO;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.service.EvaluateService; import net.wanji.opt.service.EvaluateService;
import net.wanji.opt.service.EventService; import net.wanji.opt.service.EventService;
...@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -89,4 +91,30 @@ public class EventController { ...@@ -89,4 +91,30 @@ public class EventController {
} }
@GetMapping("/getAlarmInfo")
@ApiOperation(hidden = false, value = "事件报警", notes = "", produces = "application/json")
@ApiImplicitParams({
@ApiImplicitParam(name = "timeScope", value = "时间范围:为1查询最近实时30条,为空时查询当天历史", 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"),
}
)
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = EventAlarmInfo.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject list(@RequestParam(defaultValue = "") String timeScope, @RequestParam(defaultValue = "") String eventType , @RequestParam(defaultValue = "") String name) {
try {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
List<EventAlarmInfo> eventAlarmInfo = eventService.findEventAlarmInfo(timeScope,eventType,name);
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; ...@@ -2,9 +2,11 @@ package net.wanji.opt.dao.mapper;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.base.EventStatisticPo;
import net.wanji.opt.po.trend.EventInfoSimplePo; import net.wanji.opt.po.trend.EventInfoSimplePo;
import net.wanji.opt.po.trend.HoloEventInfoPO; import net.wanji.opt.po.trend.HoloEventInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date; import java.util.Date;
...@@ -29,4 +31,7 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> { ...@@ -29,4 +31,7 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> {
EventStatisticPo findCrossEventCount(Map<String,Object> params); EventStatisticPo findCrossEventCount(Map<String,Object> params);
List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params); List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params);
List<EventAlarmInfo> findEventAlarmInfo(String timeScope,String eventType,String name);
} }
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;
}
...@@ -18,8 +18,8 @@ public class CrossLaneDataHistPoExtend { ...@@ -18,8 +18,8 @@ public class CrossLaneDataHistPoExtend {
@ApiModelProperty(name = "路口编号",notes = "") @ApiModelProperty(name = "路口编号",notes = "")
private String crossId; private String crossId;
//车道ID //车道ID
@ApiModelProperty(value = "车道ID", notes = "") @ApiModelProperty(value = "车道", notes = "")
private String laneId; private Integer laneNo;
//方向 //方向
@ApiModelProperty(value = "方向", notes = "") @ApiModelProperty(value = "方向", notes = "")
private Integer dirType; private Integer dirType;
......
...@@ -12,6 +12,7 @@ import net.wanji.opt.bo.GreenwaveIdBO; ...@@ -12,6 +12,7 @@ import net.wanji.opt.bo.GreenwaveIdBO;
import net.wanji.opt.bo.SaveGreenwaveStrategyBO; import net.wanji.opt.bo.SaveGreenwaveStrategyBO;
import net.wanji.opt.dto.trend.AbnormalCrossListDTO; import net.wanji.opt.dto.trend.AbnormalCrossListDTO;
import net.wanji.opt.dto.trend.GreenwaveListDTO; 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.base.EventStatisticPo;
import net.wanji.opt.po.trend.AnalysisRidTurnIndicators; import net.wanji.opt.po.trend.AnalysisRidTurnIndicators;
import net.wanji.opt.po.trend.HoloEventInfoPO; import net.wanji.opt.po.trend.HoloEventInfoPO;
...@@ -69,4 +70,14 @@ public interface EventService { ...@@ -69,4 +70,14 @@ public interface EventService {
* @return * @return
*/ */
List<Map<String,Object>> findEventDistribute(String crossId, String startTime, String endTime) throws DubboProviderException; 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(String timeScope,String eventType,String name) throws DubboProviderException;
} }
...@@ -45,6 +45,7 @@ import net.wanji.opt.dao.mapper.base.BaseRidInfoMapper; ...@@ -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.SceneMapper;
import net.wanji.opt.dao.mapper.strategy.SceneStrategyMapper; import net.wanji.opt.dao.mapper.strategy.SceneStrategyMapper;
import net.wanji.opt.dao.mapper.strategy.StrategyMapper; 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.BaseRidInfo;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend; import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
...@@ -224,9 +225,9 @@ public class EventServiceImpl implements EventService { ...@@ -224,9 +225,9 @@ public class EventServiceImpl implements EventService {
} }
}); });
}); });
List<EventInfoSimplePo> sortList = tmpList.stream().sorted(Comparator.comparing(o->o.getStartTime())).collect(Collectors.toList()); List<EventInfoSimplePo> sortList = tmpList.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
sortList.forEach(po -> { sortList.forEach(po -> {
String axis = DateUtil.formatDate(po.getStartTime(), "M/d") + "," + DateUtil.formatDate(po.getStartTime(), "HH:mm:ss") +","+ po.getEventType(); String axis = DateUtil.formatDate(po.getStartTime(), "M/d") + "," + DateUtil.formatDate(po.getStartTime(), "HH:mm:ss") + "," + po.getEventType();
dataserList.add(axis); dataserList.add(axis);
}); });
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -249,6 +250,14 @@ public class EventServiceImpl implements EventService { ...@@ -249,6 +250,14 @@ public class EventServiceImpl implements EventService {
return retList; return retList;
} }
@Override
public List<EventAlarmInfo> findEventAlarmInfo(String timeScope, String eventType, String name) throws DubboProviderException {
//获取数据库数据
List<EventAlarmInfo> eventAlarmInfo = holoEventMapper.findEventAlarmInfo(timeScope, eventType, name);
return eventAlarmInfo;
}
public Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) { public Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) {
Set<String> indexList = new HashSet<>(); Set<String> indexList = new HashSet<>();
......
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time, SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id , cross_id ,
lane_id , lane_no ,
dir_type , dir_type ,
turn_type , turn_type ,
SUM(flow) flow, SUM(flow) flow,
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
<!-- 方向级 --> <!-- 方向级 -->
<when test="objectType==1"> <when test="objectType==1">
dir_type, dir_type,
null as lane_id, null as lane_no,
null as turn_type, null as turn_type,
null as service_level, null as service_level,
</when> </when>
...@@ -286,19 +286,19 @@ ...@@ -286,19 +286,19 @@
<when test="objectType==2"> <when test="objectType==2">
t.in_dir+1 as dir_type, t.in_dir+1 as dir_type,
t.turn_type, t.turn_type,
null as lane_id, null as lane_no,
null as service_level, null as service_level,
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
t.id as lane_id, t2.sort as lane_no,
t2.dir as dir_type, t2.dir as dir_type,
t2.turn as turn_type, t2.turn as turn_type,
null as service_level, null as service_level,
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4"> <when test="objectType==4">
null as lane_id, null as lane_no,
null as dir_type, null as dir_type,
null as turn_type, null as turn_type,
ifnull(service_level,'A') service_level, ifnull(service_level,'A') service_level,
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
GROUP BY t.cross_id,t.lane_id,t.dir_type,t.turn_type,unit_time GROUP BY t.cross_id,t.lane_no,t.dir_type,t.turn_type,unit_time
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4"> <when test="objectType==4">
......
...@@ -2,6 +2,19 @@ ...@@ -2,6 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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"> <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 id="selectCrossEmergencyCount" resultType="java.lang.Integer">
SELECT COUNT(*) SELECT COUNT(*)
FROM t_event_info FROM t_event_info
...@@ -108,5 +121,69 @@ ...@@ -108,5 +121,69 @@
</select> </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,b.event_type
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
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.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
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)
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,b.event_type
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,
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.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
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)
order by b.issue_time desc
)
ORDER BY type2,issue_time desc
) d
where 1=1
<if test= "name != null and name != '' ">
and instr(d.cross_name,#{name})>0
</if>
<if test= "eventType != null and eventType != '' ">
and d.event_type = #{eventType}
</if>
<if test="timeScope != null and timeScope != '' ">
LIMIT 30
</if>
</select>
</mapper> </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