Commit 0305498e authored by zhoushiguang's avatar zhoushiguang

事件查询优化

parent 47c37a7a
...@@ -8,9 +8,11 @@ import net.wanji.common.enums.BaseEnum; ...@@ -8,9 +8,11 @@ import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.exception.DubboProviderException; import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.utils.tool.DateUtil; import net.wanji.common.utils.tool.DateUtil;
import net.wanji.databus.dao.entity.GreenwaveHistPO; import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.GreenwaveHistMapper; import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.dto.EventInfoTrafficStatusDTO; import net.wanji.databus.dto.EventInfoTrafficStatusDTO;
import net.wanji.databus.po.EventInfoTrafficStatusPO; import net.wanji.databus.po.EventInfoTrafficStatusPO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.databus.vo.EventInfoTrafficStatusVO; import net.wanji.databus.vo.EventInfoTrafficStatusVO;
import net.wanji.opt.common.EsDateIndexUtil; import net.wanji.opt.common.EsDateIndexUtil;
import net.wanji.opt.common.enums.EventInfoTypeEnum; import net.wanji.opt.common.enums.EventInfoTypeEnum;
...@@ -43,6 +45,9 @@ public class EventServiceImpl implements EventService { ...@@ -43,6 +45,9 @@ public class EventServiceImpl implements EventService {
@Resource @Resource
BaseRidInfoMapper baseRidInfoMapper; BaseRidInfoMapper baseRidInfoMapper;
@Resource
BaseCrossInfoMapper baseCrossInfoMapper;
@Resource @Resource
GreenwaveHistMapper greenwaveHistMapper; GreenwaveHistMapper greenwaveHistMapper;
...@@ -322,10 +327,19 @@ public class EventServiceImpl implements EventService { ...@@ -322,10 +327,19 @@ public class EventServiceImpl implements EventService {
@Override @Override
public List<EventAlarmInfo> findNotFinishAlarmInfo() throws DubboProviderException { public List<EventAlarmInfo> findNotFinishAlarmInfo() throws DubboProviderException {
Map<String,Object> param = new HashMap<>();
param.put("is_signal",1);
List<TBaseCrossInfo> crossList = baseCrossInfoMapper.selectByMap(param);
List<EventAlarmInfo> list = holoEventMapper.findNotFinishAlarmInfo(); List<EventAlarmInfo> list = holoEventMapper.findNotFinishAlarmInfo();
List<String> cidList = new ArrayList<>();
for (EventAlarmInfo info : list) { for (EventAlarmInfo info : list) {
String dir = info.getDir(); String dir = info.getDir();
String turn = info.getTurn(); String turn = info.getTurn();
cidList.add(info.getCrossId());
if (Objects.nonNull(dir)) { if (Objects.nonNull(dir)) {
List<Integer> dirJsonArray = JSONArray.parseArray(dir, Integer.class); List<Integer> dirJsonArray = JSONArray.parseArray(dir, Integer.class);
...@@ -374,8 +388,26 @@ public class EventServiceImpl implements EventService { ...@@ -374,8 +388,26 @@ public class EventServiceImpl implements EventService {
} }
info.setDirDesc(stringBuilder.toString()); info.setDirDesc(stringBuilder.toString());
} }
}
for (TBaseCrossInfo info : crossList) {
String crossId = info.getId();
if (cidList.contains(crossId)) {
continue;
}
EventAlarmInfo emptyAlarm = new EventAlarmInfo();
emptyAlarm.setStatus(0);
emptyAlarm.setCrossId(crossId);
emptyAlarm.setCrossName(info.getName());
String wkt = info.getLocation();//.replaceAll(" ",",");
wkt = wkt.replaceAll("POINT\\(","");
wkt = wkt.replaceAll("\\)","");
emptyAlarm.setWkt(wkt);
list.add(emptyAlarm);
} }
return list; return list;
} }
......
...@@ -130,8 +130,8 @@ ...@@ -130,8 +130,8 @@
dir, dir,
if(turn='null',null,turn) turn if(turn='null',null,turn) turn
from t_base_cross_info c from t_base_cross_info c
left join (select * from t_event_info where dt = DATE_FORMAT(NOW(),'%Y%m%d') and type in (701,702,703,707) and alarm_status in (0,1,2)) a on a.cross_id = c.id <!-- left --> join (select * from t_event_info where dt = DATE_FORMAT(NOW(),'%Y%m%d') and type in (701,702,703,707) and alarm_status in (0,1,2)) a on a.cross_id = c.id
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 (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
where c.is_signal=1 where c.is_signal=1
</select> </select>
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
from t_event_info a 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 (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 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() where a.dt=DATE_FORMAT(NOW(),'%Y%m%d') and a.type in (701,702,703,707)
union 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 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
...@@ -161,8 +161,8 @@ ...@@ -161,8 +161,8 @@
from t_event_info a 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 (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 left join t_greenwave_info c on a.green_id = c.id
where a.type in (705,706) and DATE(a.start_time) = CURDATE() where dt=DATE_FORMAT(NOW(),'%Y%m%d') and a.type in (705,706)
) b where b.alarm_status in (0,1,2) ) b where b.alarm_status in (0,1,2)
order by b.issue_time desc order by b.issue_time desc
) )
union union
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
from t_event_info a 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 (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 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() where dt=DATE_FORMAT(NOW(),'%Y%m%d') and a.type in (701,702,703,707)
union 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 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
...@@ -184,8 +184,8 @@ ...@@ -184,8 +184,8 @@
from t_event_info a 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 (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 left join t_greenwave_info c on a.green_id = c.id
where a.type in (705,706) and DATE(a.start_time) = CURDATE() where dt=DATE_FORMAT(NOW(),'%Y%m%d') and a.type in (705,706)
) b ) b
where b.alarm_status in (3,4) where b.alarm_status in (3,4)
order by b.issue_time desc order by b.issue_time desc
<!-- 实时报警时,结束状态只取最后30条 --> <!-- 实时报警时,结束状态只取最后30条 -->
......
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