Commit 4cb329da authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

parents 6be6e63e ec65fb62
......@@ -7,6 +7,8 @@ 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;
......@@ -14,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;
......@@ -58,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 {
......@@ -209,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)) {
......@@ -248,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
......
......@@ -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