Commit 2d17e884 authored by duanruiming's avatar duanruiming

[add] AI路口优化

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