Commit 9d5bfa1f authored by 黄伟铭's avatar 黄伟铭

修正路口事件于策略关联逻辑及SQL

parent 469d38fe
...@@ -33,7 +33,7 @@ public interface CrossMapper { ...@@ -33,7 +33,7 @@ public interface CrossMapper {
* @param time * @param time
* @return * @return
*/ */
CrossRealTimeAlarmEntity getCrossRealTimeAlarmsPlan(String crossID, String time); CrossRealTimeAlarmEntity getCrossRealTimeAlarmsPlan(String crossID, String time,String eventSerialNumber);
/** /**
* 路口方向信息 * 路口方向信息
......
...@@ -13,5 +13,5 @@ public interface AnalysisProblemAndStrategyDayMapper extends BaseMapper<Analysis ...@@ -13,5 +13,5 @@ public interface AnalysisProblemAndStrategyDayMapper extends BaseMapper<Analysis
List<AnalysisProblemAndStrategyDay> selectGreenEvent(); List<AnalysisProblemAndStrategyDay> selectGreenEvent();
Integer insertProblemAndStrategy(AnalysisProblemAndStrategyDay analysisProblemAndStrategyDay); Integer insertProblemAndStrategy(AnalysisProblemAndStrategyDay analysisProblemAndStrategyDay);
AnalysisProblemAndStrategyDay getGreenStrategy(@Param("greenID") String greenID, @Param("time") String time); AnalysisProblemAndStrategyDay getGreenStrategy(@Param("greenID") String greenID, @Param("time") String time);
AnalysisProblemAndStrategyDay getCrossStrategy(@Param("crossID") String crossID, @Param("time") String time); AnalysisProblemAndStrategyDay getCrossStrategy(@Param("crossID") String crossID, @Param("time") String time,@Param("eventSerialNumber") String eventSerialNumber);
} }
...@@ -200,7 +200,7 @@ public class CrossServiceImpl implements CrossService { ...@@ -200,7 +200,7 @@ public class CrossServiceImpl implements CrossService {
if(temp != null) if(temp != null)
{ {
list.add(temp); list.add(temp);
temp1 = crossMapper.getCrossRealTimeAlarmsPlan(crossID,temp.getStartTime()); temp1 = crossMapper.getCrossRealTimeAlarmsPlan(crossID,temp.getStartTime() , temp.getEventSerialNumber() );
if(temp1 != null){ if(temp1 != null){
list.add(temp1); list.add(temp1);
} }
......
...@@ -264,13 +264,17 @@ public class TrendServiceV2Impl implements TrendServiceV2 { ...@@ -264,13 +264,17 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
if (Objects.nonNull(optTime) && StringUtils.endsWithIgnoreCase(type, evenType) && if (Objects.nonNull(optTime) && StringUtils.endsWithIgnoreCase(type, evenType) &&
!StringUtils.endsWithIgnoreCase("700", evenType)) { !StringUtils.endsWithIgnoreCase("700", evenType)) {
// 空放优化中,6秒钟结束,当前时间小于开始时间+持续时间 // 空放优化中,6秒钟结束,当前时间小于开始时间+持续时间
if (StringUtils.endsWithIgnoreCase(EventInfoTypeEnum.PHASE_EMPTY.getEventType(), evenType) && (current - optTime.getTime() <= 6 * 1000)) { // if (StringUtils.endsWithIgnoreCase(EventInfoTypeEnum.PHASE_EMPTY.getEventType(), evenType) && (current - optTime.getTime() <= 6 * 1000)) {
log.error("当前路口空放:{}, 事件类型:{}, 优化类型:{}, ", crossId, evenType, type); // log.error("当前路口空放:{}, 事件类型:{}, 优化类型:{}, ", crossId, evenType, type);
optMonitoringVO.setOptStatus(1); // optMonitoringVO.setOptStatus(1);
optMonitoringVO.setOptStatusDesc("优化中"); // optMonitoringVO.setOptStatusDesc("优化中");
// 其他事件优化中,当前时间小于优化时间+持续时间 // // 其他事件优化中,当前时间小于优化时间+持续时间
} else if (current - optTime.getTime() <= duration * 1000) { // } else if (current - optTime.getTime() <= duration * 1000) {
log.error("当前路口失衡溢出事件:{}, 事件类型:{}, 优化类型:{}, ", crossId, evenType, type); // log.error("当前路口失衡溢出事件:{}, 事件类型:{}, 优化类型:{}, ", crossId, evenType, type);
// optMonitoringVO.setOptStatus(1);
// optMonitoringVO.setOptStatusDesc("优化中");
// }
if(optMonitoringVO.getEventSerialNumber().equals(optResultDTO.getEventId())){
optMonitoringVO.setOptStatus(1); optMonitoringVO.setOptStatus(1);
optMonitoringVO.setOptStatusDesc("优化中"); optMonitoringVO.setOptStatusDesc("优化中");
} }
......
...@@ -32,7 +32,7 @@ public class AnalysisProblemAndStrategyDayImpl extends ServiceImpl<AnalysisProbl ...@@ -32,7 +32,7 @@ public class AnalysisProblemAndStrategyDayImpl extends ServiceImpl<AnalysisProbl
if (crossEvenList.size() > 0) { if (crossEvenList.size() > 0) {
//循环查找路口事件数据是否有策略下发 //循环查找路口事件数据是否有策略下发
for (AnalysisProblemAndStrategyDay vo : crossEvenList) { for (AnalysisProblemAndStrategyDay vo : crossEvenList) {
AnalysisProblemAndStrategyDay temp = analysisProblemAndStrategyDayMapper.getCrossStrategy(vo.getCrossId(), vo.getHappenStartTime()); AnalysisProblemAndStrategyDay temp = analysisProblemAndStrategyDayMapper.getCrossStrategy(vo.getCrossId(), vo.getHappenStartTime(),vo.getEventSerialNumber());
if (temp == null) { if (temp == null) {
vo.setOptStatus(0); vo.setOptStatus(0);
} else { } else {
......
...@@ -7,4 +7,5 @@ public class CrossRealTimeAlarmEntity { ...@@ -7,4 +7,5 @@ public class CrossRealTimeAlarmEntity {
private String type; private String type;
private String startTime; private String startTime;
private String dir; private String dir;
private String eventSerialNumber;
} }
...@@ -22,6 +22,8 @@ public class OptMonitoringVO { ...@@ -22,6 +22,8 @@ public class OptMonitoringVO {
private String type; private String type;
@ApiModelProperty(value = "事件名称") @ApiModelProperty(value = "事件名称")
private String typeDesc; private String typeDesc;
@ApiModelProperty(value = "事件唯一ID")
private String eventSerialNumber;
@ApiModelProperty(value = "经纬度") @ApiModelProperty(value = "经纬度")
private String wkt; private String wkt;
@ApiModelProperty(value = "持续时长") @ApiModelProperty(value = "持续时长")
......
...@@ -18,4 +18,5 @@ public class CrossLastOptResultDTO { ...@@ -18,4 +18,5 @@ public class CrossLastOptResultDTO {
private String type; private String type;
private Integer responseCode; private Integer responseCode;
private Integer duration; private Integer duration;
private String eventId;
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<result property="type" column="type"></result> <result property="type" column="type"></result>
<result property="startTime" column="startTime"></result> <result property="startTime" column="startTime"></result>
<result property="dir" column="dir"></result> <result property="dir" column="dir"></result>
<result property="eventSerialNumber" column="eventSerialNumber"></result>
</resultMap> </resultMap>
<select id="getOptTimes" resultMap="BaseResultMap" parameterType="String"> <select id="getOptTimes" resultMap="BaseResultMap" parameterType="String">
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
</select> </select>
<select id="getCrossRealTimeAlarms" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap"> <select id="getCrossRealTimeAlarms" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap">
select a.type , a.start_time as startTime , SUBSTR(a.dir, 2, length(a.dir)-2) as dir select a.type , a.start_time as startTime , SUBSTR(a.dir, 2, length(a.dir)-2) as dir , a.event_serial_number as eventSerialNumber
from t_event_info a from t_event_info a
where a.start_time = (select MAX(start_time) from t_event_info where cross_id = #{crossID} where a.start_time = (select MAX(start_time) from t_event_info where cross_id = #{crossID}
and start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and start_time >= DATE_FORMAT(DATE_SUB(#{time},INTERVAL 5 MINUTE), '%Y-%m-%d %H:%i:%s') and start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and start_time >= DATE_FORMAT(DATE_SUB(#{time},INTERVAL 5 MINUTE), '%Y-%m-%d %H:%i:%s')
...@@ -70,11 +71,10 @@ ...@@ -70,11 +71,10 @@
</select> </select>
<select id="getCrossRealTimeAlarmsPlan" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap"> <select id="getCrossRealTimeAlarmsPlan" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap">
select '' as type,a.issue_time as startTime ,'' as dir from t_strategy_cross_result a select '' as type,a.issue_time as startTime ,'' as dir ,a.event_id as eventSerialNumber from t_strategy_cross_result a
where a.issue_time = (select MIN(issue_time) from t_strategy_cross_result where cross_id = #{crossID} where a.event_id = #{eventSerialNumber}
and issue_time <![CDATA[ <= ]]> DATE_FORMAT(DATE_ADD(#{time},INTERVAL 2 MINUTE),'%Y-%m-%d %H:%i:%s') and issue_time >= DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
and response_code = 200 and response_code = 200
and dt = DATE_FORMAT(#{time}, '%Y%m%d') ) and dt = DATE_FORMAT(#{time}, '%Y%m%d')
and a.cross_id = #{crossID} and a.cross_id = #{crossID}
</select> </select>
......
...@@ -288,7 +288,8 @@ ...@@ -288,7 +288,8 @@
IFNULL(t2.type, '700') AS type, IFNULL(t2.type, '700') AS type,
REPLACE(SUBSTRING(location, 7, 18), ' ', ',') AS wkt, REPLACE(SUBSTRING(location, 7, 18), ' ', ',') AS wkt,
IFNULL(TIMESTAMPDIFF(SECOND, t2.start_time, IFNULL(t2.end_time, NOW())), 0) AS duration, IFNULL(TIMESTAMPDIFF(SECOND, t2.start_time, IFNULL(t2.end_time, NOW())), 0) AS duration,
DATE_FORMAT(IFNULL(t2.start_time, CURDATE()), '%H:%i:%s') AS startTime DATE_FORMAT(IFNULL(t2.start_time, CURDATE()), '%H:%i:%s') AS startTime,
t2.event_serial_number as eventSerialNumber
FROM t_base_cross_info t1 FROM t_base_cross_info t1
LEFT JOIN ( LEFT JOIN (
SELECT cross_id, MAX(start_time) AS start_time SELECT cross_id, MAX(start_time) AS start_time
......
...@@ -50,10 +50,11 @@ ...@@ -50,10 +50,11 @@
else '700' else '700'
end as type, end as type,
t2.response_code, t2.response_code,
ifnull(t2.duration, 0) as duration ifnull(t2.duration, 0) as duration,
t2.event_id as eventId
from from
(select id, name, location from t_base_cross_info where is_signal = 1) t1 (select id, name, location from t_base_cross_info where is_signal = 1) t1
left join (select t1.cross_id, t1.issue_time, t1.current_algo, t1.response_code, t1.duration from t_strategy_cross_result t1 left join (select t1.cross_id, t1.issue_time, t1.current_algo, t1.response_code, t1.duration,t1.event_id from t_strategy_cross_result t1
inner join (select cross_id, max(issue_time) issue_time from t_strategy_cross_result where issue_time > CURDATE() group by cross_id) t3 inner join (select cross_id, max(issue_time) issue_time from t_strategy_cross_result where issue_time > CURDATE() group by cross_id) t3
on t1.cross_id = t3.cross_id and t1.issue_time = t3.issue_time where t1.issue_time > CURDATE()) t2 on t1.cross_id = t3.cross_id and t1.issue_time = t3.issue_time where t1.issue_time > CURDATE()) t2
on t1.id = t2.cross_id on t1.id = t2.cross_id
......
...@@ -45,10 +45,9 @@ ...@@ -45,10 +45,9 @@
<select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap"> <select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
select a.issue_time as optStartTime,DATE_ADD(a.issue_time,INTERVAL a.duration SECOND ) as optEndTime,a.duration as optDuration from t_strategy_cross_result a select a.issue_time as optStartTime,DATE_ADD(a.issue_time,INTERVAL a.duration SECOND ) as optEndTime,a.duration as optDuration from t_strategy_cross_result a
where a.issue_time = (select MIN(issue_time) from t_strategy_cross_result where cross_id = #{crossID} where a.event_id = #{eventSerialNumber}
and issue_time <![CDATA[ <= ]]> DATE_FORMAT(DATE_ADD(#{time},INTERVAL 2 MINUTE),'%Y-%m-%d %H:%i:%s') and issue_time >= DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
and response_code = 200 and response_code = 200
and dt = DATE_FORMAT(#{time}, '%Y%m%d') ) and dt = DATE_FORMAT(#{time}, '%Y%m%d')
and a.cross_id = #{crossID} and a.cross_id = #{crossID}
</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