Commit b3346a1e authored by zhoushiguang's avatar zhoushiguang

方向处理

parent ec7a762a
package net.wanji.opt.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.exception.DubboProviderException;
......@@ -72,9 +73,14 @@ public class EventServiceImpl implements EventService {
Map<String, Long> countMap = null;
List<Map<String, Object>> list = new ArrayList<>();
if (Objects.nonNull(dirs)) {
String[] sps = dirs.split(",");
String[] dirList = dirs.split("@");
List<String> allDirList = new ArrayList<>();
for (String dirArr : dirList) {
List<String> jsonArray = JSONArray.parseArray(dirArr,String.class);
allDirList.addAll(jsonArray.stream().map(o->(Integer.valueOf(o).toString())).distinct().collect(Collectors.toList()));
}
//统计每个方向发生的次数
countMap = Arrays.stream(sps).collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
countMap = allDirList.stream().collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
countMap.entrySet().forEach(o -> {
Map<String, Object> map = new HashMap<>();
map.put("dir", o.getKey());
......@@ -208,7 +214,7 @@ public class EventServiceImpl implements EventService {
List<EventInfoTrafficStatusPO> eventInfoTrafficStatusPOS = holoEventMapper.trafficStatus(eventInfoTrafficStatusDTO);
//获取当前时间的时间轴
Set<String> timeScopeList = getTimeScopeList(DateTime.now().withTimeAtStartOfDay(), new DateTime(), EsDateIndexUtil.H_FORMATTER);
if (ObjectUtil.isNotEmpty(timeScopeList)){
if (ObjectUtil.isNotEmpty(timeScopeList)) {
ArrayList<String> arrayList = timeScopeList.stream().collect(Collectors.toCollection(ArrayList::new));
List<String> collect = arrayList.stream().sorted(Comparator.comparing(time -> Integer.valueOf(time.split(":")[0]))).collect(Collectors.toList());
......@@ -223,7 +229,7 @@ public class EventServiceImpl implements EventService {
List<String> timeList = eventInfoTrafficStatusPOS.stream().map(EventInfoTrafficStatusPO::getTimeAxisStart).collect(Collectors.toList());
//补充缺少时段数据
for (String s : timeScopeList) {
if (!timeList.contains(s)){
if (!timeList.contains(s)) {
EventInfoTrafficStatusPO eventInfoTrafficStatusPO = new EventInfoTrafficStatusPO();
eventInfoTrafficStatusPO.setDuration(0);
eventInfoTrafficStatusPO.setCount(0);
......@@ -240,6 +246,7 @@ public class EventServiceImpl implements EventService {
}
return eventInfoTrafficStatusVO;
}
/**
* @return java.util.List<java.lang.Integer>
* @Description 根据集合长度,获取默认0补充的list
......@@ -252,6 +259,7 @@ public class EventServiceImpl implements EventService {
}
return list;
}
@Override
public List<EventAlarmInfo> findEventAlarmInfo(String realtimeType, String eventType, String name) throws DubboProviderException {
//获取数据库数据
......
......@@ -83,7 +83,7 @@
<!-- 查看路口事件数量 -->
<select id="findCrossEventCount" resultType="net.wanji.opt.po.base.EventStatisticPo">
select cross_id, type as event_type,count(*) event_count,group_concat(dir) dirs,b.label as event_type_desc
select cross_id, type as event_type,count(*) event_count,group_concat(dir SEPARATOR '@') dirs,b.label as event_type_desc
from t_event_info a left join t_config_event_category b on a.type=b.event_type
where 1=1
<if test="crossId !=null and crossId !=''">
......
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