Commit 2d17e884 authored by duanruiming's avatar duanruiming

[add] AI路口优化

parent 0a24e219
......@@ -527,33 +527,37 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private List<StrategyControlDataExt> getCrossList(Date date) {
List<StrategyControlDataExt> results = new ArrayList<>();
List<HoloEventInfoPO> holoEventInfoPOS = holoEventMapper.selectAIList(date);
if (!CollectionUtils.isEmpty(holoEventInfoPOS)) {
for (HoloEventInfoPO holoEventInfoPO : holoEventInfoPOS) {
List<StrategyCrossResultEntity> resultList = strategyCrossResultMapper.selectAICrossList(null);
if (!CollectionUtils.isEmpty(resultList)) {
for (StrategyCrossResultEntity entity : resultList) {
StrategyControlDataExt ext = new StrategyControlDataExt();
ext.setBizId(holoEventInfoPO.getCrossId());
ext.setCrossName(holoEventInfoPO.getRemark());
String location = holoEventInfoPO.getExtend();
ext.setBizId(entity.getCrossId());
ext.setCrossName(entity.getCrossName());
String location = entity.getResponseContent();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
ext.setWkt(location);
String eventType = holoEventInfoPO.getType();
Integer alarmStatus = holoEventInfoPO.getAlarmStatus();
String optMethod = "效率提升";
ext.setStatus(alarmStatus);
ext.setOptMethod(optMethod);
if (StringUtils.equals(eventType, "702")) {
ext.setOptMethod("均衡调控");
Integer currentAlgo = entity.getCurrentAlgo();
Date issueTime = entity.getIssueTime();
Date current = new Date();
// 优化时间大于5分钟,默认优化完
if (Objects.nonNull(issueTime) && current.getTime() - issueTime.getTime() > 5 * 60 * 1000) {
currentAlgo = null;
}
if (StringUtils.isBlank(eventType)) {
if (Objects.isNull(currentAlgo)) {
ext.setOptStatus("正常");
ext.setOptMethod("畅通");
ext.setStatus(-1);
} else if (Objects.equals(1, currentAlgo)) {
ext.setOptStatus("优化中");
ext.setOptMethod("均衡调控");
} else {
ext.setOptStatus("优化中");
ext.setOptMethod("效率提升");
}
String desc = EventStatusEnum.getDesc(alarmStatus);
ext.setOptStatus(desc);
results.add(ext);
}
}
results.sort(Comparator.comparing(StrategyControlDataExt::getStatus).reversed());
return results;
}
......
......@@ -7,21 +7,27 @@
<select id="selectAICrossList" resultType="net.wanji.opt.synthesis.pojo.StrategyCrossResultEntity">
select t1.id as cross_id, t1.name as cross_name, t2.current_algo, t2.issue_time
from t_base_cross_info t1 left join
(
select cross_id, cross_name, max(issue_time) issue_time, current_algo
from t_strategy_cross_result
where issue_time > #{date} and response_code = 200
union
select cross_id, cross_name, max(issue_time) issue_time, current_algo
from t_strategy_cross_result
where issue_time > #{date} and response_code &lt; 0
group by cross_id
order by issue_time
) t2 on t1.id = t2.cross_id
where t1.is_signal = 1
order by t2.issue_time desc;
select t1.id as crossId, t1.name as crossName, t2.issue_time, t2.current_algo, t2.response_code, t1.location as responseContent from
(select id, name, location from t_base_cross_info where is_signal = 1) t1
left join (select cross_id, max(issue_time) issue_time, current_algo, response_code from t_strategy_cross_result group by cross_id) t2
on t1.id = t2.cross_id
and t2.issue_time > DATE_FORMAT(now(),'%Y-%m-%d 00:00:00')
order by t2.issue_time desc
<!-- select t1.id as cross_id, t1.name as cross_name, t2.current_algo, t2.issue_time-->
<!-- from t_base_cross_info t1 left join-->
<!-- (-->
<!-- select cross_id, cross_name, max(issue_time) issue_time, current_algo-->
<!-- from t_strategy_cross_result-->
<!-- where issue_time > #{date} and response_code = 200-->
<!-- union-->
<!-- select cross_id, cross_name, max(issue_time) issue_time, current_algo-->
<!-- from t_strategy_cross_result-->
<!-- where issue_time > #{date} and response_code &lt; 0-->
<!-- group by cross_id-->
<!-- order by issue_time-->
<!-- ) t2 on t1.id = t2.cross_id-->
<!-- where t1.is_signal = 1-->
<!-- order by t2.issue_time desc;-->
</select>
</mapper>
\ No newline at end of file
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