Commit bf4d41b5 authored by Zheng Yi Fan's avatar Zheng Yi Fan

监测详情-路口事件-路口实时告警接口

parent f65dfedb
...@@ -4,7 +4,9 @@ import io.swagger.annotations.*; ...@@ -4,7 +4,9 @@ import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.servicev2.CrossService; import net.wanji.opt.servicev2.CrossService;
import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity; import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import net.wanji.opt.vo2.CrossStatusDistributionVO; import net.wanji.opt.vo2.CrossStatusDistributionVO;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -13,16 +15,13 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -13,16 +15,13 @@ 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;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author zhengyifan * @author zhengyifan
* @date 2025/3/15 * @date 2025/3/15
*/ */
@Api(value = "CrossController", description = "监测详情-路口事件详情-路口状态分布") @Api(value = "CrossController", description = "监测详情-路口事件详情")
@RequestMapping(value = "/cross") @RequestMapping(value = "/cross")
@RestController @RestController
@Slf4j @Slf4j
...@@ -53,4 +52,26 @@ public class CrossController { ...@@ -53,4 +52,26 @@ public class CrossController {
} }
return jsonViewObject.success(result); return jsonViewObject.success(result);
} }
@ApiOperation(value = "路口实时告警", notes = "路口实时告警", response = JsonViewObject.class, httpMethod="GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossID", value = "路口ID", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "time", value = "时间 格式:yyyy-MM-dd HH:ii:ss", dataType = "String", paramType = "query"),
})
@GetMapping(value = "/getCrossRealTimeAlarm")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossRealTimeAlarmVO.class),
})
public JsonViewObject getCrossRealTimeAlarm(String crossID, @RequestParam(defaultValue = "") String time) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
List<CrossRealTimeAlarmEntity> result;
try {
result = crossService.getCrossRealTimeAlarm(crossID, time);
} catch (Exception e) {
log.error("监测详情-路口事件详情-路口实时告警: ", e);
return jsonViewObject.fail("路口实时告警查询失败");
}
return jsonViewObject.success(result);
}
} }
package net.wanji.opt.dao.mapper; package net.wanji.opt.dao.mapper;
import net.wanji.databus.po.CrossDataHistPO; import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity; import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity;
import net.wanji.opt.synthesis.pojo.StrategyCrossResultEntity; import net.wanji.opt.synthesis.pojo.StrategyCrossResultEntity;
...@@ -21,4 +22,12 @@ public interface CrossMapper { ...@@ -21,4 +22,12 @@ public interface CrossMapper {
* @return * @return
*/ */
List<CrossStatusDisOptTimeEntity> getOptTimes(String crossID); List<CrossStatusDisOptTimeEntity> getOptTimes(String crossID);
/**
* 监测详情-路口事件详情-路口实时告警
* @param crossID
* @param time
* @return
*/
List<CrossRealTimeAlarmEntity> getCrossRealTimeAlarms(String crossID, String time);
} }
package net.wanji.opt.servicev2; package net.wanji.opt.servicev2;
import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.vo2.CrossStatusDistributionVO; import net.wanji.opt.vo2.CrossStatusDistributionVO;
import java.util.List; import java.util.List;
...@@ -23,4 +24,13 @@ public interface CrossService { ...@@ -23,4 +24,13 @@ public interface CrossService {
* @return 包含状态分布信息列表与优化时间列表 * @return 包含状态分布信息列表与优化时间列表
*/ */
Map<String, List<?>> getCrossStatusDistribution(String crossID, String date, String groupType, Integer objectType, String directionName); Map<String, List<?>> getCrossStatusDistribution(String crossID, String date, String groupType, Integer objectType, String directionName);
/**
* 获取路口实时告警
* @param crossID
* @param time 可选参数
* @return
*/
List<CrossRealTimeAlarmEntity> getCrossRealTimeAlarm(String crossID, String time);
} }
...@@ -9,6 +9,7 @@ import net.wanji.opt.dao.mapper.CrossMapper; ...@@ -9,6 +9,7 @@ import net.wanji.opt.dao.mapper.CrossMapper;
import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper; import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend; import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.servicev2.CrossService; import net.wanji.opt.servicev2.CrossService;
import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity; import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity;
import net.wanji.opt.synthesis.pojo.StrategyCrossResultEntity; import net.wanji.opt.synthesis.pojo.StrategyCrossResultEntity;
import net.wanji.opt.vo2.CrossStatusDistributionVO; import net.wanji.opt.vo2.CrossStatusDistributionVO;
...@@ -21,8 +22,7 @@ import java.util.*; ...@@ -21,8 +22,7 @@ import java.util.*;
/** /**
* <p> * <p>
* 监测详情-路口事件详情-路口状态分布实现类 * 监测详情-路口事件详情
* </p>
* @author zhengyifan * @author zhengyifan
* @date 2025/3/15 * @date 2025/3/15
*/ */
...@@ -34,6 +34,15 @@ public class CrossServiceImpl implements CrossService { ...@@ -34,6 +34,15 @@ public class CrossServiceImpl implements CrossService {
@Resource @Resource
private GreenwaveHistoryMapper greenwaveHistoryMapper; private GreenwaveHistoryMapper greenwaveHistoryMapper;
/**
* 路口状态分布
* @param crossID 路口ID
* @param date 日期
* @param groupType 时间粒度 参数要求:0--5分钟 1--15分钟 2--30分钟 3--60分钟
* @param objectType 范围 参数要求:1--方向级 2--转向级 3--车道级 4--路口级
* @param directionName 方向
* @return
*/
@Override @Override
public Map<String, List<?>> getCrossStatusDistribution(String crossID, String date, String groupType, Integer objectType, String directionName) { public Map<String, List<?>> getCrossStatusDistribution(String crossID, String date, String groupType, Integer objectType, String directionName) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
...@@ -67,4 +76,15 @@ public class CrossServiceImpl implements CrossService { ...@@ -67,4 +76,15 @@ public class CrossServiceImpl implements CrossService {
return result; return result;
} }
/**
* 路口实时告警
* @param crossID
* @param time 可选参数
* @return
*/
@Override
public List<CrossRealTimeAlarmEntity> getCrossRealTimeAlarm(String crossID, String time) {
return crossMapper.getCrossRealTimeAlarms(crossID, time);
}
} }
package net.wanji.opt.synthesis.pojo;
import lombok.Data;
@Data
public class CrossRealTimeAlarmEntity {
private String type;
private String startTime;
private String dir;
}
package net.wanji.opt.vo2;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "CrossRealTimeAlarmVO", description = "监测详情-路口事件-路口实时告警")
public class CrossRealTimeAlarmVO {
@ApiModelProperty(value = "事件类型")
private String type;
@ApiModelProperty(value = "事件时间")
private String startTime;
@ApiModelProperty(value = "事件方向")
private String dir;
}
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<result property="startTime" column="startTime"></result> <result property="startTime" column="startTime"></result>
<result property="endTime" column="endTime"></result> <result property="endTime" column="endTime"></result>
</resultMap> </resultMap>
<resultMap id="CrossRealTimeAlarmsResultMap" type="net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity">
<result property="type" column="type"></result>
<result property="startTime" column="startTime"></result>
<result property="dir" column="dir"></result>
</resultMap>
<select id="getOptTimes" resultMap="BaseResultMap" parameterType="String"> <select id="getOptTimes" resultMap="BaseResultMap" parameterType="String">
select distinct DATE_FORMAT(issue_time, '%H:%i') as startTime, select distinct DATE_FORMAT(issue_time, '%H:%i') as startTime,
...@@ -53,4 +58,49 @@ ...@@ -53,4 +58,49 @@
) b ) b
order by b.issue_time order by b.issue_time
</select> </select>
<select id="getCrossRealTimeAlarms" parameterType="String" resultMap="CrossRealTimeAlarmsResultMap">
select
a.type ,
MAX(a.start_time) as startTime ,
SUBSTR(a.dir, 2, length(a.dir)-2) as dir
from
t_event_info a
where 1=1
and a.cross_id = #{crossID}
<if test="time != null and time != ''">
and a.start_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
</if>
union
select
'' as type,
max(b.issue_time) as startTime ,
'' as dir
from
(
select
max(a.issue_time) as issue_time
from
t_strategy_cross_result a
where 1=1
and a.cross_id = #{crossID}
and (a.current_algo in (2, 3)
and a.response_code = 200)
<if test="time != null and time != ''">
and a.issue_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
</if>
union
select
max(a.issue_time) as issue_time
from
t_strategy_cross_result a
where 1=1
and a.cross_id = #{crossID}
and (SIGN(a.rtn_type) = -1
and a.current_algo = 1)
<if test="time != null and time != ''">
and a.issue_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
</if>
) b
</select>
</mapper> </mapper>
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