Commit f0f150fb authored by duanruiming's avatar duanruiming

[update] 实时监控->当前运行方案相位参数优化

parent d72234de
...@@ -10,6 +10,7 @@ import net.wanji.opt.common.exception.OptServiceException; ...@@ -10,6 +10,7 @@ import net.wanji.opt.common.exception.OptServiceException;
import net.wanji.opt.dto.*; import net.wanji.opt.dto.*;
import net.wanji.opt.service.CrossSchedulesService; import net.wanji.opt.service.CrossSchedulesService;
import net.wanji.opt.service.CrossSchemeService; import net.wanji.opt.service.CrossSchemeService;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -104,11 +105,12 @@ public class CrossDirTurnPhaseCache implements CommandLineRunner { ...@@ -104,11 +105,12 @@ public class CrossDirTurnPhaseCache implements CommandLineRunner {
turnSet.addAll(Arrays.stream(turnArr).collect(Collectors.toSet())); turnSet.addAll(Arrays.stream(turnArr).collect(Collectors.toSet()));
} }
for (String turn : turnSet) { for (String turn : turnSet) {
CrossPhaseDTO crossPhaseDTO = new CrossPhaseDTO();
BeanUtils.copyProperties(phase, crossPhaseDTO);
key = crossId + Constants.SystemParam.SEPARATOR_UNDER_LINE + dir + Constants.SystemParam.SEPARATOR_UNDER_LINE + turn; key = crossId + Constants.SystemParam.SEPARATOR_UNDER_LINE + dir + Constants.SystemParam.SEPARATOR_UNDER_LINE + turn;
phase.setDirType(dir); crossPhaseDTO.setDirType(dir);
phase.setTurnType(turn); crossPhaseDTO.setTurnType(turn);
phaseMap.put(key, phase); phaseMap.put(key, crossPhaseDTO);
} }
turnSet.clear(); turnSet.clear();
} }
......
...@@ -317,7 +317,6 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService { ...@@ -317,7 +317,6 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
} }
} }
/** /**
* 当前路口异常转向列表 element:进口方向 * 当前路口异常转向列表 element:进口方向
* *
...@@ -425,19 +424,21 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService { ...@@ -425,19 +424,21 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
} else { } else {
phaseTimeOptResultMap = getPhaseTimeOptMap(phaseTimeOffset); phaseTimeOptResultMap = getPhaseTimeOptMap(phaseTimeOffset);
} }
// 修改原始方案绿灯时间为优化后时间,方案下发 if (!phaseTimeOptResultMap.isEmpty()) {
SchemeSendVO schemeSendVO = getSchemeSendVO(crossId, phaseMap, phaseTimeOptResultMap); // 修改原始方案绿灯时间为优化后时间,方案下发
JsonViewObject jsonViewObject = utcFeignClients.schemeSend(schemeSendVO); SchemeSendVO schemeSendVO = getSchemeSendVO(crossId, phaseMap, phaseTimeOptResultMap);
JsonViewObject jsonViewObject = utcFeignClients.schemeSend(schemeSendVO);
//todo test下发成功
jsonViewObject.success();
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
log.error("实时监控->路口优化方案下发远程调用异常!", jsonViewObject);
throw new OptServiceException("实时监控->下发优化方案调用UTC服务异常");
}
//todo test下发成功 // 将优化记录插入方案优化记录表
jsonViewObject.success(); insertCrossSchemeOptLog(phaseTimeOptResultMap, phaseMap, optType);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
log.error("实时监控->路口优化方案下发远程调用异常!", jsonViewObject);
throw new OptServiceException("实时监控->下发优化方案调用UTC服务异常");
} }
// 将优化记录插入方案优化记录表
insertCrossSchemeOptLog(phaseTimeOptResultMap, phaseMap, optType);
} }
/** /**
...@@ -454,27 +455,27 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService { ...@@ -454,27 +455,27 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
CrossSchemeOptLogPO crossSchemeOptLogPO = new CrossSchemeOptLogPO(); CrossSchemeOptLogPO crossSchemeOptLogPO = new CrossSchemeOptLogPO();
CrossPhaseDTO crossPhaseDTO = item.getValue(); CrossPhaseDTO crossPhaseDTO = item.getValue();
BeanUtils.copyProperties(crossPhaseDTO, crossSchemeOptLogPO);
crossSchemeOptLogPO.setSchemeId(crossPhaseDTO.getSchemeId());
crossSchemeOptLogPO.setPhaseOrderId(crossPhaseDTO.getSort());
crossSchemeOptLogPO.setStartTime(new Date());
crossSchemeOptLogPO.setOptType("1");// 自动优化
crossSchemeOptLogPO.setOptType(optType);
crossSchemeOptLogPO.setOptResult("1");
crossSchemeOptLogPO.setOptResultDesc(StatusCodeEnum.STATUS_00200.getDetail());
crossSchemeOptLogPO.setDataBatchTime((int) dataBatchTimeLong);
// todo 测试数据
crossSchemeOptLogPO.setDataExtend("{\"sceneName\": \"测试JSON\",\"strategyName\": \"测试JSON\",\"ideaName\": \"测试JSON\"}");// todo 需要通过场景策略方法
String phaseNo = crossPhaseDTO.getPhaseNo(); String phaseNo = crossPhaseDTO.getPhaseNo();
for (Map.Entry<String, Integer> entry : phaseTimeOptResultMap.entrySet()) { for (Map.Entry<String, Integer> entry : phaseTimeOptResultMap.entrySet()) {
if (Objects.equals(phaseNo, entry.getKey())) { if (Objects.equals(phaseNo, entry.getKey())) {
BeanUtils.copyProperties(crossPhaseDTO, crossSchemeOptLogPO);
crossSchemeOptLogPO.setSchemeId(crossPhaseDTO.getSchemeId());
crossSchemeOptLogPO.setPhaseOrderId(crossPhaseDTO.getSort());
crossSchemeOptLogPO.setStartTime(new Date());
crossSchemeOptLogPO.setOptType("1");// 自动优化
crossSchemeOptLogPO.setOptType(optType);
crossSchemeOptLogPO.setOptResult("1");
crossSchemeOptLogPO.setOptResultDesc(StatusCodeEnum.STATUS_00200.getDetail());
crossSchemeOptLogPO.setDataBatchTime((int) dataBatchTimeLong);
// todo 测试数据
crossSchemeOptLogPO.setDataExtend("{\"sceneName\": \"测试JSON\",\"strategyName\": \"测试JSON\",\"ideaName\": \"测试JSON\"}");// todo 需要通过场景策略方法
crossSchemeOptLogPO.setOptTime(entry.getValue()); crossSchemeOptLogPO.setOptTime(entry.getValue());
crossSchemeOptLogPO.setOriGreenTime(crossPhaseDTO.getGreenTime()); crossSchemeOptLogPO.setOriGreenTime(crossPhaseDTO.getGreenTime());
insertList.add(crossSchemeOptLogPO);
} }
} }
insertList.add(crossSchemeOptLogPO);
} }
crossSchemeOptLogMapper.insertBatch(insertList); crossSchemeOptLogMapper.insertBatch(insertList);
} }
...@@ -697,7 +698,7 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService { ...@@ -697,7 +698,7 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
} }
private Integer getRealOptGreenTime(Double passTime, CrossPhaseDTO crossPhaseDTO) { private Integer getRealOptGreenTime(Double passTime, CrossPhaseDTO crossPhaseDTO) {
int passTimeInt = passTime == null ? 0 : passTime.intValue(); Integer passTimeInt = passTime == null ? 0 : passTime.intValue();
if (passTimeInt <= crossPhaseDTO.getMinGreenTime()) { if (passTimeInt <= crossPhaseDTO.getMinGreenTime()) {
passTimeInt = crossPhaseDTO.getMinGreenTime(); passTimeInt = crossPhaseDTO.getMinGreenTime();
} }
......
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