Commit d95eb09d authored by hanbing's avatar hanbing

[add] 绿波评价-场景数量统计

parent 8760d65e
...@@ -502,11 +502,56 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -502,11 +502,56 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
// 根据时段查询所有发生的绿波 // 根据时段查询所有发生的绿波
List<GreenwaveHistPO> greenwaveHistPOList = greenwaveHistMapper List<GreenwaveHistPO> greenwaveHistPOList = greenwaveHistMapper
.selectByTimeSection(poStartTimeStr, poEndTimeStr); .selectByTimeSection(poStartTimeStr, poEndTimeStr);
// 根据干线名称筛选结果
List<GreenwaveHistPO> filteredList = greenwaveHistPOList.stream()
.filter(po -> {
String name = po.getGreenwaveName();
int index = name.indexOf(':');
if (index != -1) {
String leftSide = name.substring(0, index).trim();
return leftSide.equals(mainlineName);
}
return false;
})
.collect(Collectors.toList());
MainlineSchemeAnalysisVO res = new MainlineSchemeAnalysisVO();
res.setSceneData(calcSceneData(filteredList));
res.setCrossData(new ArrayList<>());
res.setEvaluateData(new ArrayList<>());
res.setGreenwaveData(new ArrayList<>());
return null; return null;
} }
private List<MainlineSchemeAnalysisVO.DirectionData> calcSceneData(List<GreenwaveHistPO> filteredList) {
List<MainlineSchemeAnalysisVO.DirectionData> res = new ArrayList<>();
HashMap<String, Integer> map = new HashMap<>();
for (GreenwaveHistPO greenwaveHistPO : filteredList) {
Integer dir = greenwaveHistPO.getDir();
if (dir == 0) { // 正向
map.put("单向绿波上行", map.getOrDefault("单向绿波上行", 0) + 1);
} else if (dir == 1) { // 反向
map.put("单向绿波下行", map.getOrDefault("单向绿波下行", 0) + 1);
} else { // 双向
map.put("双向绿波", map.getOrDefault("双向绿波", 0) + 1);
}
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
MainlineSchemeAnalysisVO.DirectionData directionData = new MainlineSchemeAnalysisVO.DirectionData();
directionData.setName(entry.getKey());
directionData.setTimes(entry.getValue());
res.add(directionData);
}
return res;
}
private Date calcDate(String timeStr, Date startTime) throws ParseException { private Date calcDate(String timeStr, Date startTime) throws ParseException {
// 使用 Calendar 来获取年、月、日信息 // 使用 Calendar 来获取年、月、日信息
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
......
...@@ -11,5 +11,7 @@ import lombok.Data; ...@@ -11,5 +11,7 @@ import lombok.Data;
@Data @Data
public class GreenwaveHistPO extends GreenwaveRealtimePO{ public class GreenwaveHistPO extends GreenwaveRealtimePO{
@ApiModelProperty(value = "绿波名称",notes = "") @ApiModelProperty(value = "绿波名称",notes = "")
private String greenwaveName ; private String greenwaveName;
@ApiModelProperty(name = "协调方向:0正向;1反向;2双向")
private Integer dir;
} }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<select id="selectByTimeSection" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO"> <select id="selectByTimeSection" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select t1.id,t1.status,t1.type,t1.traffic_index,t1.speed,t1.trval_time,t1.stop_times,t1.queue_length, select t1.id,t1.status,t1.type,t1.traffic_index,t1.speed,t1.trval_time,t1.stop_times,t1.queue_length,
t1.cong_rate,t1.delay_time,t1.nopark_pass_rate,t1.cord_reliability,t1.cord_queue_ratio, t1.cong_rate,t1.delay_time,t1.nopark_pass_rate,t1.cord_reliability,t1.cord_queue_ratio,
t1.uncoordinate_phase_queue,t1.gmt_create,t1.gmt_modified, t2.name as greenwaveName t1.uncoordinate_phase_queue,t1.gmt_create,t1.gmt_modified, t2.name as greenwaveName, t2.dir
from t_greenwave_hist t1 join t_greenwave_info t2 on t1.id = t2.id from t_greenwave_hist t1 join t_greenwave_info t2 on t1.id = t2.id
where t1.gmt_modified <![CDATA[ <= ]]> #{endTimeStr} where t1.gmt_modified <![CDATA[ <= ]]> #{endTimeStr}
and t1.gmt_modified <![CDATA[ >= ]]> #{startTimeStr} and t1.gmt_modified <![CDATA[ >= ]]> #{startTimeStr}
......
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