Commit 5a81c97c authored by zhouleilei's avatar zhouleilei

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	signal-optimize-service/src/main/java/net/wanji/opt/controller/EventController.java
#	signal-optimize-service/src/main/java/net/wanji/opt/dao/mapper/HoloEventMapper.java
#	signal-optimize-service/src/main/java/net/wanji/opt/service/EventService.java
#	signal-optimize-service/src/main/java/net/wanji/opt/service/impl/EventServiceImpl.java
parents 2913816b 630f4e07
...@@ -4,14 +4,13 @@ import io.swagger.annotations.*; ...@@ -4,14 +4,13 @@ import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; 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.databus.dto.EventInfoTrafficStatusDTO;
import net.wanji.databus.vo.EventInfoTrafficStatusVO;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.service.EventService; import net.wanji.opt.service.EventService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -94,4 +93,30 @@ public class EventController { ...@@ -94,4 +93,30 @@ public class EventController {
} }
@GetMapping("/getAlarmInfo")
@ApiOperation(hidden = false, value = "事件报警", notes = "", produces = "application/json")
@ApiImplicitParams({
@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 = "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 realtimeType, @RequestParam(defaultValue = "") String eventType , @RequestParam(defaultValue = "") String name) {
try {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
List<EventAlarmInfo> eventAlarmInfo = eventService.findEventAlarmInfo(realtimeType,eventType,name);
return jsonViewObject.success(eventAlarmInfo);
} catch (Exception e) {
log.error("", e);
return JsonViewObject.newInstance().fail("请求失败");
}
}
} }
\ No newline at end of file
package net.wanji.opt.controller.signalopt; package net.wanji.opt.controller.signalopt;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation; import net.wanji.common.framework.i18n.I18nResourceBundle;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.po.CrossDataRealtimePO; import net.wanji.databus.po.CrossDataRealtimePO;
...@@ -11,6 +9,7 @@ import net.wanji.databus.po.CrossDirDataRealtimePO; ...@@ -11,6 +9,7 @@ import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.databus.po.CrossDirStatusDataPO; import net.wanji.databus.po.CrossDirStatusDataPO;
import net.wanji.databus.po.TBaseCrossInfo; import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO; import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.po.trend.HoloEventInfoPO; import net.wanji.opt.po.trend.HoloEventInfoPO;
import net.wanji.opt.service.CrossIndexService; import net.wanji.opt.service.CrossIndexService;
import net.wanji.opt.vo.AIOptResultVO; import net.wanji.opt.vo.AIOptResultVO;
...@@ -153,4 +152,23 @@ public class CrossIndexController { ...@@ -153,4 +152,23 @@ public class CrossIndexController {
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
@GetMapping("/selectCrossEventList")
@ApiOperation(httpMethod="GET",value="路口监测左下角路口事件列表", notes="")
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenWaveCrossTurnIndex() {
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
List<HoloEventInfoPO> list = crossIndexService.selectCrossEventList();
jsonView.success(list);
} catch (Exception e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
}
return jsonView;
}
} }
package net.wanji.opt.dao.mapper; package net.wanji.opt.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dto.EventInfoTrafficStatusDTO;
import net.wanji.databus.po.EventInfoTrafficStatusPO;
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;
...@@ -25,10 +23,14 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> { ...@@ -25,10 +23,14 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> {
List<HoloEventInfoPO> selectAIList(Date startTime); List<HoloEventInfoPO> selectAIList(Date startTime);
List<HoloEventInfoPO> selectAIGreenList(Date startTime); List<HoloEventInfoPO> selectAIGreenList(Date startTime);
List<HoloEventInfoPO> selectCrossEventList();
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<EventInfoTrafficStatusPO> trafficStatus(EventInfoTrafficStatusDTO eventInfoTrafficStatusDTO); List<EventInfoTrafficStatusPO> trafficStatus(EventInfoTrafficStatusDTO eventInfoTrafficStatusDTO);
List<EventAlarmInfo> findEventAlarmInfo(String realtimeType,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;
@ApiModelProperty(value = "持续时间,单位秒")
private Integer duration;
}
...@@ -105,7 +105,7 @@ public class HoloEventInfoPO implements Serializable { ...@@ -105,7 +105,7 @@ public class HoloEventInfoPO implements Serializable {
private String remark; private String remark;
@ApiModelProperty(value = "拓展字段") @ApiModelProperty(value = "拓展字段")
private String extend; private String extend;
@ApiModelProperty(value = "拓展字段") @ApiModelProperty(value = "告警状态 告警状态 0未处理 1分析中 2优化中 3优化完 4已结束")
private Integer alarmStatus; private Integer alarmStatus;
@ApiModelProperty(value = "时间轴", notes = "") @ApiModelProperty(value = "时间轴", notes = "")
......
...@@ -30,6 +30,7 @@ public interface CrossIndexService { ...@@ -30,6 +30,7 @@ public interface CrossIndexService {
List<CrossStatusCountVO> crossStatusCount(String crossId) throws Exception; List<CrossStatusCountVO> crossStatusCount(String crossId) throws Exception;
HoloEventInfoPO crossEventDirTurn(String crossId) throws Exception; HoloEventInfoPO crossEventDirTurn(String crossId) throws Exception;
List<HoloEventInfoPO> selectCrossEventList() throws Exception;
/** /**
* @Description 查询据当前时间某小时的数据 * @Description 查询据当前时间某小时的数据
...@@ -38,4 +39,5 @@ public interface CrossIndexService { ...@@ -38,4 +39,5 @@ public interface CrossIndexService {
* @return java.util.List<net.wanji.databus.po.CrossDirDataHistPO> * @return java.util.List<net.wanji.databus.po.CrossDirDataHistPO>
**/ **/
CrossDirStatusDataPO selectByCrossIdAndHour(String crossId,int hour); CrossDirStatusDataPO selectByCrossIdAndHour(String crossId,int hour);
} }
package net.wanji.opt.service; package net.wanji.opt.service;
import net.wanji.common.framework.exception.DubboProviderException; import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.databus.dto.EventInfoTrafficStatusDTO;
import net.wanji.databus.vo.EventInfoTrafficStatusVO;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import java.util.List; import java.util.List;
...@@ -39,4 +37,14 @@ public interface EventService { ...@@ -39,4 +37,14 @@ public interface EventService {
*/ */
EventInfoTrafficStatusVO trafficStatus(EventInfoTrafficStatusDTO eventInfoTrafficStatusDTO) throws DubboProviderException; EventInfoTrafficStatusVO trafficStatus(EventInfoTrafficStatusDTO eventInfoTrafficStatusDTO) throws DubboProviderException;
/**
* 当时事件报警数据监测
* @param greenId
* @param crossId
* @param type 为1时查询当天最近30条,为空时查询当天所有
* @return
* @throws DubboProviderException
*/
List<EventAlarmInfo> findEventAlarmInfo(String realtimeType,String eventType,String name) throws DubboProviderException;
} }
...@@ -248,4 +248,10 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -248,4 +248,10 @@ public class CrossIndexServiceImpl implements CrossIndexService {
throw new Exception(e); throw new Exception(e);
} }
} }
@Override
public List<HoloEventInfoPO> selectCrossEventList() throws Exception {
List<HoloEventInfoPO> holoEventInfoPOS = holoEventMapper.selectCrossEventList();
return holoEventInfoPOS;
}
} }
...@@ -12,10 +12,28 @@ import net.wanji.opt.common.EsDateIndexUtil; ...@@ -12,10 +12,28 @@ import net.wanji.opt.common.EsDateIndexUtil;
import net.wanji.opt.common.enums.EventInfoTypeEnum; import net.wanji.opt.common.enums.EventInfoTypeEnum;
import net.wanji.opt.dao.mapper.HoloEventMapper; import net.wanji.opt.dao.mapper.HoloEventMapper;
import net.wanji.opt.dao.mapper.base.BaseRidInfoMapper; 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.BaseRidInfo;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.po.strategy.ScenePO;
import net.wanji.opt.po.strategy.SceneStrategyPO;
import net.wanji.opt.po.strategy.StrategyPO;
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.service.EventService; import net.wanji.opt.service.EventService;
import net.wanji.opt.service.SchemeEvaluateService;
import net.wanji.opt.vo.RunningEvaluateMetricsDetailVO;
import net.wanji.opt.vo.SchemeEvaluateCrossSchemeListVO;
import net.wanji.opt.vo.SchemeEvaluateCurveChartVO;
import net.wanji.opt.vo.SchemeEvaluateProblemSchemeVO;
import net.wanji.opt.vo.SchemeEvaluateSchemeDetailOverallVO;
import net.wanji.opt.vo.SchemeEvaluateSchemeDetailedProblemVO;
import net.wanji.opt.vo.SchemeEvaluateStrategyMetricMenuVO;
import org.jetbrains.annotations.NotNull;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Minutes; import org.joda.time.Minutes;
import org.joda.time.Seconds; import org.joda.time.Seconds;
...@@ -234,6 +252,14 @@ public class EventServiceImpl implements EventService { ...@@ -234,6 +252,14 @@ public class EventServiceImpl implements EventService {
} }
return list; return list;
} }
@Override
public List<EventAlarmInfo> findEventAlarmInfo(String realtimeType, String eventType, String name) throws DubboProviderException {
//获取数据库数据
List<EventAlarmInfo> eventAlarmInfo = holoEventMapper.findEventAlarmInfo(realtimeType, eventType, name);
return eventAlarmInfo;
}
public static Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) { public static Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) {
......
...@@ -435,20 +435,25 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -435,20 +435,25 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
if (Objects.equals(4, objectType)) { if (Objects.equals(4, objectType)) {
//路口级
TBaseCrossInfo tBaseCrossInfo = baseCrossInfoMapper.selectByPrimaryKey(sps[0]); TBaseCrossInfo tBaseCrossInfo = baseCrossInfoMapper.selectByPrimaryKey(sps[0]);
dirTurnDesc = tBaseCrossInfo.getName(); dirTurnDesc = tBaseCrossInfo.getName();
dirType = 0;
} else if (Objects.equals(3, objectType)) { } else if (Objects.equals(3, objectType)) {
//车道级
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
dirType = Integer.parseInt(sps[2]); dirType = Integer.parseInt(sps[2]);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3])); turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "进口" + turnDesc + laneNo + "车道"; dirTurnDesc = dirName + "进口" + turnDesc + laneNo + "车道";
} else if (Objects.equals(2, objectType)) { } else if (Objects.equals(2, objectType)) {
//转向级
dirType = Integer.parseInt(sps[2]); dirType = Integer.parseInt(sps[2]);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3])); turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "进口" + turnDesc; dirTurnDesc = dirName + "进口" + turnDesc;
} else if (Objects.equals(1, objectType)) { } else if (Objects.equals(1, objectType)) {
//方向级
dirType = Integer.parseInt(sps[2]); dirType = Integer.parseInt(sps[2]);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
dirTurnDesc = dirName + "进口"; dirTurnDesc = dirName + "进口";
...@@ -461,6 +466,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -461,6 +466,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("dirType",dirType);
mapList.put("scopeName", dirTurnDesc); mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value); mapList.put("list", value);
allList.add(mapList); allList.add(mapList);
...@@ -478,6 +484,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -478,6 +484,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
mapList.put("scopeCode", ""); mapList.put("scopeCode", "");
mapList.put("scopeName", scopeName1); mapList.put("scopeName", scopeName1);
mapList.put("dirType", BaseEnum.SignalDirectionEnum.getCodeByName(scopeName1.substring(0,scopeName1.indexOf("进口"))));
List<CrossLaneDataHistPoExtend> tmpList = new ArrayList<>(); List<CrossLaneDataHistPoExtend> tmpList = new ArrayList<>();
//补充所有时段字段对象 //补充所有时段字段对象
for (String time : sortedSet) { for (String time : sortedSet) {
...@@ -503,6 +510,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -503,6 +510,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
} }
} }
} }
allList = allList.stream().sorted(Comparator.comparing(o->Integer.valueOf(o.get("dirType").toString()))).collect(Collectors.toList());
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet); jsonObject.put("timeList", sortedSet);
...@@ -598,6 +606,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -598,6 +606,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
tmp.setDirTypeName(dirTurnDesc); tmp.setDirTypeName(dirTurnDesc);
tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length())); tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length()));
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName())); tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName()));
hasDataScopeList.add(tmp.getDirTypeName()+tmp.getTurnTypeName());
//利用正则表达式取车道号 //利用正则表达式取车道号
if (Objects.equals(3, objectType)) { if (Objects.equals(3, objectType)) {
Pattern pattern = Pattern.compile("\\d+"); Pattern pattern = Pattern.compile("\\d+");
......
...@@ -209,7 +209,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -209,7 +209,7 @@ public class TrendServiceImpl implements TrendService {
} }
if (Objects.equals(2, value.size())) { if (Objects.equals(2, value.size())) {
Double speed = 0.0; Double speed = 0.0;
Double trafficIndex = 1.0; Double trafficIndex = 0.0;
int travelTime = 0; int travelTime = 0;
Integer stopTimes = 0; Integer stopTimes = 0;
GreenwaveListVO wDirVo = new GreenwaveListVO(); GreenwaveListVO wDirVo = new GreenwaveListVO();
......
package net.wanji.opt.vo;
import lombok.Data;
/**
* @author duanruiming
* @date 2025/01/14 15:32
* @description 路口监测左下角路口事件列表
*/
@Data
public class CrossEventListPO {
private String crossId;
private String name;
private Integer count;
private Integer duration;
private String type;
private String typeName;
}
...@@ -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
...@@ -84,6 +97,98 @@ ...@@ -84,6 +97,98 @@
</if> </if>
GROUP BY cross_id,type GROUP BY cross_id,type
</select> </select>
<!-- 路口监测左下角路口事件列表 -->
<select id = "selectCrossEventList" resultType="net.wanji.opt.vo.CrossEventListPO">
select t1.id crossId, t2.type, ifnull(t2.place_desc, "畅通") typeName,
ifnull(t2.count, 0) count, ifnull(t2.duration, 0) duration, t1.`name` name
from t_base_cross_info t1
left join
(select t1.cross_id, t1.type, t1.place_desc,
count(*) count,
sum(TIMESTAMPDIFF(SECOND, t1.start_time, ifnull(t1.end_time,now()))) duration
from t_event_info t1
left join (
select t2.cross_id, MAX(t2.start_time) start_time
from t_event_info t2
where t2.type in (701, 702, 703, 707) and t2.start_time > DATE_FORMAT(now(),'%Y-%m-%d 00:00:00')
group by t2.cross_id
) t2 on t1.cross_id = t2.cross_id and t1.start_time and t2.start_time
where t1.start_time > DATE_FORMAT(now(),'%Y-%m-%d 00:00:00')
group by t1.cross_id) t2
on t2.cross_id = t1.id
where t1.is_signal = 1
order by t2.duration desc
</select>
<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,d.duration
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,b.duration
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
,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
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
,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
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,b.duration
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,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
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
,TIMESTAMPDIFF(SECOND,a.start_time, ifnull(a.end_time,now())) duration
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
<!-- 实时报警时,结束状态只取最后30条 -->
<if test="realtimeType != null and realtimeType != '' and realtimeType=='1'.toString()">
LIMIT 30
</if>
)
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>
</select>
<!-- 查看路口事件数量 --> <!-- 查看路口事件数量 -->
<select id="trafficStatus" resultType="net.wanji.databus.po.EventInfoTrafficStatusPO"> <select id="trafficStatus" resultType="net.wanji.databus.po.EventInfoTrafficStatusPO">
......
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