Commit 7b89ffc9 authored by zhoushiguang's avatar zhoushiguang

场景事件路口级指标

parent 86d4190e
...@@ -239,10 +239,10 @@ public class GreenwaveHistRestServer { ...@@ -239,10 +239,10 @@ public class GreenwaveHistRestServer {
@ApiOperation(httpMethod="GET",value="路口进口【方向级、转向级、车道级】->分粒度指标趋势", notes="") @ApiOperation(httpMethod="GET",value="路口进口【方向级、转向级、车道级】->分粒度指标趋势", notes="")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"), @ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"),
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度 4:天粒度", required = true, dataType = "Integer",defaultValue = "1"), @ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度 4:天粒度 5:按时间范围直接做平均【不分粒度】", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 00:00:00"), @ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 23:59:59"), @ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 23:59:59"),
@ApiImplicitParam(name = "objectType", value = "统计对象类型 1:方向级指标 2:转向级指标 3:车道级指标", required = true, dataType = "Integer",defaultValue = "1"), @ApiImplicitParam(name = "objectType", value = "统计对象类型 1:方向级指标 2:转向级指标 3:车道级指标 4:路口级指标", required = true, dataType = "Integer",defaultValue = "1"),
}) })
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "成功", response = CrossLaneDataHistPoExtend.class, @ApiResponse(code = 200, message = "成功", response = CrossLaneDataHistPoExtend.class,
......
...@@ -50,6 +50,9 @@ public class CrossLaneDataHistPoExtend { ...@@ -50,6 +50,9 @@ public class CrossLaneDataHistPoExtend {
@ApiModelProperty(value = "饱和度",notes = "") @ApiModelProperty(value = "饱和度",notes = "")
private Double sturation; private Double sturation;
@ApiModelProperty(value = "服务水平",notes = "")
private String serviceLevel;
@ApiModelProperty(value = "开始时间:yyyy-MM-dd HH:mm:ss", notes = "") @ApiModelProperty(value = "开始时间:yyyy-MM-dd HH:mm:ss", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss") @JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
......
...@@ -49,6 +49,9 @@ public class EventInfoSimplePo implements Serializable { ...@@ -49,6 +49,9 @@ public class EventInfoSimplePo implements Serializable {
@ApiModelProperty(value = "事件持续时长,单位秒") @ApiModelProperty(value = "事件持续时长,单位秒")
private Integer duration; private Integer duration;
@ApiModelProperty(value = "事件发生次数")
private Integer count=1;
@ApiModelProperty(value = "横轴时间轴start", notes = "") @ApiModelProperty(value = "横轴时间轴start", notes = "")
private String timeAxisStart; private String timeAxisStart;
......
...@@ -190,6 +190,7 @@ public class EventServiceImpl implements EventService { ...@@ -190,6 +190,7 @@ public class EventServiceImpl implements EventService {
po.setStartTime(agoStartTime); po.setStartTime(agoStartTime);
po.setEndTime(currentEndTime); po.setEndTime(currentEndTime);
po.setTimeAxisStart(tmp.getTimeAxisStart()); po.setTimeAxisStart(tmp.getTimeAxisStart());
po.setCount(po.getCount()+1);
//清理合并前的记录 //清理合并前的记录
tmpList.remove(tmp); tmpList.remove(tmp);
} }
......
...@@ -17,6 +17,7 @@ import net.wanji.databus.po.CrossTurnInfoPO; ...@@ -17,6 +17,7 @@ import net.wanji.databus.po.CrossTurnInfoPO;
import net.wanji.opt.bo.BottomMenuBO; import net.wanji.opt.bo.BottomMenuBO;
import net.wanji.opt.common.EsDateIndexUtil; import net.wanji.opt.common.EsDateIndexUtil;
import net.wanji.opt.common.enums.TimeGranularityEnum; import net.wanji.opt.common.enums.TimeGranularityEnum;
import net.wanji.opt.constant.ServiceLevelEnum;
import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper; import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper;
import net.wanji.opt.entity.GreenwaveHist; import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend; import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
...@@ -389,6 +390,9 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -389,6 +390,9 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
List<Map<String, Object>> allList = new ArrayList<>(); List<Map<String, Object>> allList = new ArrayList<>();
List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params); List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组 //按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList())); Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
...@@ -400,7 +404,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -400,7 +404,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneId = sps[1]; String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2); String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]); Integer dirType = null;
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
String dirTurnDesc = null; String dirTurnDesc = null;
...@@ -410,15 +414,17 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -410,15 +414,17 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
if (Objects.equals(3, objectType)) { if (Objects.equals(3, objectType)) {
mapList.put("laneId", laneId); mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
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]);
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]);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
dirTurnDesc = dirName + "进口"; dirTurnDesc = dirName + "进口";
} }
...@@ -428,6 +434,8 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -428,6 +434,8 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//补充缺少时段数据,保留时段字段默认值 //补充缺少时段数据,保留时段字段默认值
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime); List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc); mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value); mapList.put("list", value);
...@@ -439,34 +447,36 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -439,34 +447,36 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
bo.setScope(objectType); bo.setScope(objectType);
List<String> scopeList = mainlineEvaluateService.bottomMenu(bo); List<String> scopeList = mainlineEvaluateService.bottomMenu(bo);
//补充一条时段都没有的 if (Objects.nonNull(scopeList)) {
for (String scopeName1 : scopeList) { //补充一条时段都没有的
if (!hasDataScopeList.contains(scopeName1)) { for (String scopeName1 : scopeList) {
Map<String, Object> mapList = new HashMap<>(); if (!hasDataScopeList.contains(scopeName1)) {
mapList.put("scopeCode", ""); Map<String, Object> mapList = new HashMap<>();
mapList.put("scopeName", scopeName1); mapList.put("scopeCode", "");
List<CrossLaneDataHistPoExtend> tmpList = new ArrayList<>(); mapList.put("scopeName", scopeName1);
//补充所有时段字段对象 List<CrossLaneDataHistPoExtend> tmpList = new ArrayList<>();
for (String time : sortedSet) { //补充所有时段字段对象
CrossLaneDataHistPoExtend po = new CrossLaneDataHistPoExtend(); for (String time : sortedSet) {
try { CrossLaneDataHistPoExtend po = new CrossLaneDataHistPoExtend();
if (Objects.equals("4", groupType)) { try {
//天粒度 if (Objects.equals("4", groupType)) {
String st = time + "000000"; //天粒度
po.setStartTime(DateUtil.parse(st, "yyyyMMddHHmmss")); String st = time + "000000";
po.setStartTime(DateUtil.parse(st, "yyyyMMddHHmmss"));
} else {
String st = startTime.substring(0, startTime.lastIndexOf(" ") + 1) + time + ":00"; } else {
po.setStartTime(DateUtil.parse(st, "yyyy-MM-dd HH:mm:ss")); String st = startTime.substring(0, startTime.lastIndexOf(" ") + 1) + time + ":00";
po.setStartTime(DateUtil.parse(st, "yyyy-MM-dd HH:mm:ss"));
}
} catch (ParseException e) {
e.printStackTrace();
} }
} catch (ParseException e) { tmpList.add(po);
e.printStackTrace(); po.setTimeAxis(time);
} }
tmpList.add(po); mapList.put("list", tmpList);
po.setTimeAxis(time); allList.add(mapList);
} }
mapList.put("list", tmpList);
allList.add(mapList);
} }
} }
...@@ -620,6 +630,23 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -620,6 +630,23 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
private List<CrossLaneDataHistPoExtend> processData(Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry, String groupType, Set<String> sortedSet, String startTime) { private List<CrossLaneDataHistPoExtend> processData(Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry, String groupType, Set<String> sortedSet, String startTime) {
//按方向排序 //按方向排序
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//========================路口级服务水平加权平均=================================================================//
String serviceLevelList = value.get(0).getServiceLevel();
StringBuilder serviceLevelBuf = new StringBuilder();
if (serviceLevelList != null) {
Map<String,Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf,Collectors.counting()));
double total = 0;
for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) {
String key = entry1.getKey();
total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue();
}
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total/value.size());
String avgServiceLevel = ServiceLevelEnum.getByVal(avgService)==null?"A":ServiceLevelEnum.getByVal(avgService).getType();
serviceLevelBuf.append(avgServiceLevel);
}
//有实际数据的时刻点 //有实际数据的时刻点
Set<String> timeList = new HashSet<>(); Set<String> timeList = new HashSet<>();
if (Objects.equals("4", groupType)) { if (Objects.equals("4", groupType)) {
...@@ -647,6 +674,10 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -647,6 +674,10 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
} }
} }
value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList()); value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList());
//==========================================================================================================//
//时间轴 //时间轴
value.forEach(o -> { value.forEach(o -> {
if (Objects.equals("4", groupType)) { if (Objects.equals("4", groupType)) {
...@@ -656,6 +687,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -656,6 +687,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
} else { } else {
o.setTimeAxis(DateUtil.formatDate(o.getStartTime(), EsDateIndexUtil.HM_FORMATTER)); o.setTimeAxis(DateUtil.formatDate(o.getStartTime(), EsDateIndexUtil.HM_FORMATTER));
} }
o.setServiceLevel(serviceLevelBuf.toString());
}); });
return value; return value;
......
...@@ -168,6 +168,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService { ...@@ -168,6 +168,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
String key = entry1.getKey(); String key = entry1.getKey();
total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue().size(); total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue().size();
} }
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total/crossDataHistPOList.size()); int avgService = (int) Math.round(total/crossDataHistPOList.size());
String serviceLevel = ServiceLevelEnum.getByVal(avgService)==null?"A":ServiceLevelEnum.getByVal(avgService).getType(); String serviceLevel = ServiceLevelEnum.getByVal(avgService)==null?"A":ServiceLevelEnum.getByVal(avgService).getType();
......
...@@ -244,7 +244,8 @@ ...@@ -244,7 +244,8 @@
round(AVG(queue_length)) avg_queue_length, round(AVG(queue_length)) avg_queue_length,
round(AVG(stop_times),2) stop_times, round(AVG(stop_times),2) stop_times,
round(AVG(delay_time),2) delay_time, round(AVG(delay_time),2) delay_time,
round(AVG(sturation),4) sturation round(AVG(sturation),4) sturation,
group_concat(service_level) service_level
FROM FROM
( (
SELECT start_time, SELECT start_time,
...@@ -264,18 +265,28 @@ ...@@ -264,18 +265,28 @@
dir_type, dir_type,
null as lane_id, null as lane_id,
null as turn_type, null as turn_type,
null as service_level,
</when> </when>
<!-- 转向级 --> <!-- 转向级 -->
<when test="objectType==2"> <when test="objectType==2">
t.in_dir as dir_type, t.in_dir as dir_type,
t.turn_type, t.turn_type,
null as lane_id, null as lane_id,
null as service_level,
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
t.id as lane_id, t.id as lane_id,
t2.dir as dir_type, t2.dir as dir_type,
t2.turn as turn_type, t2.turn as turn_type,
null as service_level,
</when>
<!-- 路口级 -->
<when test="objectType==4">
null as lane_id,
null as dir_type,
null as turn_type,
ifnull(service_level,'A') service_level,
</when> </when>
<otherwise> <otherwise>
</otherwise> </otherwise>
...@@ -300,6 +311,10 @@ ...@@ -300,6 +311,10 @@
FROM t_lane_data_hist t join t_base_lane_info t2 on t.id=t2.id FROM t_lane_data_hist t join t_base_lane_info t2 on t.id=t2.id
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4">
FROM t_cross_data_hist t
</when>
<otherwise> <otherwise>
</otherwise> </otherwise>
</choose> </choose>
...@@ -324,6 +339,10 @@ ...@@ -324,6 +339,10 @@
<when test="objectType==3"> <when test="objectType==3">
GROUP BY t.cross_id,t.lane_id,t.dir_type,t.turn_type,unit_time GROUP BY t.cross_id,t.lane_id,t.dir_type,t.turn_type,unit_time
</when> </when>
<!-- 路口级 -->
<when test="objectType==4">
GROUP BY t.cross_id,unit_time
</when>
<otherwise> <otherwise>
</otherwise> </otherwise>
</choose> </choose>
......
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