Commit 4be6f792 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents e5e16eac 4cb329da
package net.wanji.opt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -53,4 +54,13 @@ public class EventAlarmInfo {
@ApiModelProperty(value = "路口状态 0正常 1失衡 2拥堵 3溢出 5空放")
private Integer status;
@ApiModelProperty(value = "事件发生方向",hidden = true)
private String dir;
@ApiModelProperty(value = "事件发生转向",hidden = true)
private String turn;
@ApiModelProperty(value = "事件发生方向描述")
private String dirDesc;
}
......@@ -4,8 +4,11 @@ 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.enums.BaseEnum;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.utils.tool.DateUtil;
import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.databus.dao.mapper.GreenwaveHistMapper;
import net.wanji.databus.dto.EventInfoTrafficStatusDTO;
import net.wanji.databus.po.EventInfoTrafficStatusPO;
import net.wanji.databus.vo.EventInfoTrafficStatusVO;
......@@ -13,28 +16,11 @@ import net.wanji.opt.common.EsDateIndexUtil;
import net.wanji.opt.common.enums.EventInfoTypeEnum;
import net.wanji.opt.dao.mapper.HoloEventMapper;
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.CrossLaneDataHistPoExtend;
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.HoloEventInfoPO;
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.Minutes;
import org.joda.time.Seconds;
......@@ -57,6 +43,9 @@ public class EventServiceImpl implements EventService {
@Resource
BaseRidInfoMapper baseRidInfoMapper;
@Resource
GreenwaveHistMapper greenwaveHistMapper;
@Override
public EventStatisticPo findCrossEventCount(String crossId, String type, String startTime, String endTime) throws DubboProviderException {
......@@ -76,8 +65,8 @@ public class EventServiceImpl implements EventService {
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()));
List<String> jsonArray = JSONArray.parseArray(dirArr, String.class);
allDirList.addAll(jsonArray.stream().map(o -> (Integer.valueOf(o).toString())).distinct().collect(Collectors.toList()));
}
//统计每个方向发生的次数
countMap = allDirList.stream().collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
......@@ -208,16 +197,40 @@ public class EventServiceImpl implements EventService {
public EventInfoTrafficStatusVO trafficStatus(EventInfoTrafficStatusDTO eventInfoTrafficStatusDTO) throws DubboProviderException {
EventInfoTrafficStatusVO eventInfoTrafficStatusVO = new EventInfoTrafficStatusVO();
String eventType = eventInfoTrafficStatusDTO.getEventType();
//获取type
String type = EventInfoTypeEnum.getEventInfoTypeEnum(Integer.valueOf(eventType)).getEventType();
eventInfoTrafficStatusDTO.setEventType(type);
List<EventInfoTrafficStatusPO> eventInfoTrafficStatusPOS = holoEventMapper.trafficStatus(eventInfoTrafficStatusDTO);
Integer queryType = eventInfoTrafficStatusDTO.getQueryType();
List<EventInfoTrafficStatusPO> eventInfoTrafficStatusPOS = null;
if (ObjectUtil.equals(1,queryType)){
//路口
//获取type
String type = EventInfoTypeEnum.getEventInfoTypeEnum(Integer.valueOf(eventType)).getEventType();
eventInfoTrafficStatusDTO.setEventType(type);
eventInfoTrafficStatusPOS = holoEventMapper.trafficStatus(eventInfoTrafficStatusDTO);
}else {
//干线
List<Integer> statusList = new ArrayList<>();
if (ObjectUtil.equals("6",eventType)){
//干线缓行
statusList.add(2);
}else {
//干线拥堵
statusList.add(3);
statusList.add(4);
}
List<GreenwaveHistPO> greenwaveHistPOS = greenwaveHistMapper.selectByIdAndType(Integer.valueOf(eventInfoTrafficStatusDTO.getId()), statusList);
if (ObjectUtil.isNotEmpty(greenwaveHistPOS)){
eventInfoTrafficStatusPOS = new ArrayList<EventInfoTrafficStatusPO>();
Map<Integer, List<GreenwaveHistPO>> collect = greenwaveHistPOS.stream().collect(Collectors.groupingBy(x -> x.getStartTime().getHours()));
for (Map.Entry<Integer, List<GreenwaveHistPO>> entry : collect.entrySet()) {
eventInfoTrafficStatusPOS.add(handerEntry(entry));
}
}
}
//获取当前时间的时间轴
Set<String> timeScopeList = getTimeScopeList(DateTime.now().withTimeAtStartOfDay(), new DateTime(), EsDateIndexUtil.H_FORMATTER);
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());
eventInfoTrafficStatusVO.setTimeList(collect);
//补充全部数据
if (ObjectUtil.isEmpty(eventInfoTrafficStatusPOS)) {
......@@ -247,6 +260,39 @@ public class EventServiceImpl implements EventService {
return eventInfoTrafficStatusVO;
}
/**
* @Description 干线数据处理
* @Param [entry]
* @return net.wanji.databus.po.EventInfoTrafficStatusPO
**/
private EventInfoTrafficStatusPO handerEntry(Map.Entry<Integer, List<GreenwaveHistPO>> entry){
EventInfoTrafficStatusPO eventInfoTrafficStatusPO = new EventInfoTrafficStatusPO();
Integer hour = entry.getKey();
String timeAxisStart = null;
if (hour <= 9){
timeAxisStart = "0"+entry.getKey() + ":00";
}else {
timeAxisStart = entry.getKey() + ":00";
}
int count = 0;
List<GreenwaveHistPO> value = entry.getValue();
for (int i = 0; i < value.size(); i++) {
if (i == 0){
count++;
}else {
if (value.get(i).getStartTime().getTime() - value.get(i - 1).getStartTime().getTime() >= 300) {
count++;
}
}
}
int duration = value.size()*300;
eventInfoTrafficStatusPO.setDuration(duration);
eventInfoTrafficStatusPO.setCount(count);
eventInfoTrafficStatusPO.setTimeAxisStart(timeAxisStart);
return eventInfoTrafficStatusPO;
}
/**
* @return java.util.List<java.lang.Integer>
* @Description 根据集合长度,获取默认0补充的list
......@@ -270,7 +316,55 @@ public class EventServiceImpl implements EventService {
@Override
public List<EventAlarmInfo> findNotFinishAlarmInfo() throws DubboProviderException {
return holoEventMapper.findNotFinishAlarmInfo();
List<EventAlarmInfo> list = holoEventMapper.findNotFinishAlarmInfo();
for (EventAlarmInfo info : list) {
String dir = info.getDir();
String turn = info.getTurn();
if (Objects.nonNull(dir)) {
List<Integer> dirJsonArray = JSONArray.parseArray(dir, Integer.class);
//dirJsonArray = dirJsonArray.stream().distinct().collect(Collectors.toList());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(info.getCurrentAlgo() + "发生方向:");
if (Objects.nonNull(turn)) {
//有方向、有转向
List<Integer> turnJsonArray = JSONArray.parseArray(turn, Integer.class);
//turnJsonArray = turnJsonArray.stream().distinct().collect(Collectors.toList());
for (int i = 0; i < dirJsonArray.size(); i++) {
String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirJsonArray.get(i))) + "进口";
String turnName = BaseEnum.TurnTypeEnum.getNameByCode(turnJsonArray.get(i));
String desc = dirName + turnName;
if (stringBuilder.indexOf(desc)>0){
continue;
}
if (i != dirJsonArray.size()) {
stringBuilder.append(desc);
stringBuilder.append(";");
} else {
stringBuilder.append(desc);
}
}
} else {
//只有方向
for (int i = 0; i < dirJsonArray.size(); i++) {
String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirJsonArray.get(i))) + "进口";
if (stringBuilder.indexOf(dirName)>0){
continue;
}
if (i != dirJsonArray.size()) {
stringBuilder.append(dirName);
stringBuilder.append(";");
} else {
stringBuilder.append(dirName);
}
}
}
info.setDirDesc(stringBuilder.toString());
}
}
return list;
}
......
......@@ -119,14 +119,16 @@
<!-- 查询路口未结束的报警状态 -->
<select id="findNotFinishAlarmInfo" parameterType="String" resultMap="eventAlarm">
select
DISTINCT
DISTINCT a.type as event_type,
case when a.type=701 then 5 when a.type=702 then 1 when a.type=703 then 3 when a.type=707 then 2 else ifnull(a.type,0) end as status,
c.id as cross_id,
c.name as cross_name ,
b.label as current_algo,
SUBSTRING(c.location FROM 7 FOR 20) as wkt,
ifnull(a.alarm_status,-1) alarm_status,
a.opt_status
a.opt_status,
dir,
if(turn='null',null,turn) turn
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 a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
......
......@@ -22,4 +22,7 @@ public interface GreenwaveHistMapper extends BaseMapper<GreenwaveHistPO> {
List<GreenwaveHistPO> selectByIdAndTimeSection(Integer greenwaveId, String startTimeStr, String endTimeStr);
int insertBatch(@Param("list") List<GreenwaveHistPO> list);
List<GreenwaveHistPO> selectByIdAndType(@Param("greenwaveId") Integer greenwaveId,@Param("statusList") List<Integer> statusList);
}
......@@ -107,4 +107,16 @@
gmt_modified = values(gmt_modified)
</insert>
<select id="selectByIdAndType" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select
<include refid="Base_Column_List"/>
from t_greenwave_hist
where green_id = #{greenwaveId}
and status in
<foreach collection="statusList" item="status" separator="," open="(" close=")">
#{status}
</foreach>
and start_time &gt;= DATE_FORMAT(now(), '%Y-%m-%d 00:00:00')
order by start_time asc
</select>
</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