Commit cf84f448 authored by duanruiming's avatar duanruiming

[update] 实时监控优化可加可减时间,转向枚举类大小写优化

parent ac63a849
......@@ -458,7 +458,7 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
* @return
*/
private SchemeSendVO getSchemeSendVO(String crossId, Map<String, CrossPhaseDTO> phaseMap, Map<String, Integer> phaseTimeOptResultMap) {
String key = String.join(Constants.SystemParam.SEPARATOR_UNDER_LINE, crossId, "1", "S");
String key = String.join(Constants.SystemParam.SEPARATOR_UNDER_LINE, crossId, "1", "s");
CrossPhaseDTO crossPhaseDTO = phaseMap.get(key);
Integer schemeId = crossPhaseDTO.getSchemeId();
......@@ -533,7 +533,7 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
for (Map.Entry<String, Integer> entry : timeOffsetPhaseMap.entrySet()) {
Integer offsetTime = entry.getValue() == null ? 0 : entry.getValue();
String phaseNo = entry.getKey();
if (timeOffsetPhaseMap.containsValue(phaseNo)) {
if (phaseOffsetTimeSetMap.containsKey(phaseNo)) {
Integer currentOffsetTime = phaseOffsetTimeSetMap.get(phaseNo);
if (Math.abs(offsetTime) > Math.abs(currentOffsetTime)) {
phaseOffsetTimeSetMap.put(phaseNo, offsetTime);
......@@ -545,26 +545,46 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
}
}
List<Integer> subTimeList = phaseOffsetTimeSetMap.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList()).stream().filter(i -> i < 0).collect(Collectors.toList());
List<Integer> addTimeList = phaseOffsetTimeSetMap.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList()).stream().filter(i -> i > 0).collect(Collectors.toList());
int subTimeSum = subTimeList.stream().mapToInt(Integer::intValue).sum();
int lastAddTimeSum = 0;
int addTimeSum = addTimeList.stream().mapToInt(Integer::intValue).sum();
int countOffsetAdd = Math.abs(subTimeSum) >= addTimeSum ? addTimeSum : Math.abs(subTimeSum);
int countOffsetSub = countOffsetAdd;
// 可加可减时间为0,不需要计算相位时间
if (countOffsetAdd == 0) {
return null;
}
// 对可加相位进行操作
for (Map.Entry<String, Integer> entry : phaseOffsetTimeSetMap.entrySet()) {
String phaseNo = entry.getKey();
Integer offsetTime = entry.getValue();
if (offsetTime > 0 && subTimeSum + offsetTime <= 0) {
if (offsetTime <= 0 || countOffsetAdd <= 0) { // 不需要修改相位时间或者没有可加时间
continue;
}
String phaseNo = entry.getKey();
countOffsetAdd -= offsetTime;
if (countOffsetAdd >= 0) {
// 当前相位可加时间就是最大可加时间,可加时间有可减时间
subTimeSum += offsetTime;
lastAddTimeSum += offsetTime;
phaseTimeOptResultMap.put(phaseNo, offsetTime);
} else {
phaseTimeOptResultMap.put(phaseNo, countOffsetAdd);
}
if (offsetTime < 0) {
if (lastAddTimeSum <= Math.abs(offsetTime)) {
phaseTimeOptResultMap.put(phaseNo, lastAddTimeSum < 0 ? lastAddTimeSum : -lastAddTimeSum);
} else {
lastAddTimeSum += offsetTime;
phaseTimeOptResultMap.put(phaseNo, offsetTime);
}
}
// 对可减相位进行操作
for (Map.Entry<String, Integer> entry : phaseOffsetTimeSetMap.entrySet()) {
Integer offsetTime = entry.getValue();
if (offsetTime >= 0 || countOffsetSub <= 0) { // 不需要修改相位时间或者没有可加时间
continue;
}
String phaseNo = entry.getKey();
countOffsetSub += offsetTime;
if (countOffsetSub >= 0) {
// 可减时间有可加时间
phaseTimeOptResultMap.put(phaseNo, offsetTime);
} else {
phaseTimeOptResultMap.put(phaseNo, countOffsetSub);
}
}
return phaseTimeOptResultMap;
}
......
......@@ -12,22 +12,22 @@ public enum TurnConvertEnum {
* 车道转向:0未知;1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;
* 9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头
*/
UNKNOWN(0, "UNKNOWN", "未知"),
L(1, "L", "左转"),
S(2, "S", "直行"),
R(3, "R", "右转"),
U(4, "U", "掉头"),
L_S(5, "L_S", "左转+直行"),
S_R(6, "S_R", "直行+右转"),
L_S_R(7, "L_S_R", "左转+直行+右转"),
L_R(8, "L_R", "左转+右转"),
L_U(9, "L_U", "左转+掉头"),
S_U(10, "S_U", "直行+掉头"),
R_U(11, "R_U", "右转+掉头"),
L_S_U(12, "L_S_U", "左转+直行+掉头"),
U_S_R(13, "U_S_R", "直行+右转+掉头"),
L_S_R_U(14, "L_S_R_U", "左转+直行+右转+掉头"),
L_R_U(15, "L_R_U", "左转+右转+掉头");
UNKNOWN(0, "unknown", "未知"),
L(1, "l", "左转"),
S(2, "s", "直行"),
R(3, "r", "右转"),
U(4, "u", "掉头"),
L_S(5, "l_s", "左转+直行"),
S_R(6, "s_r", "直行+右转"),
L_S_R(7, "l_s_r", "左转+直行+右转"),
L_R(8, "l_r", "左转+右转"),
L_U(9, "l_u", "左转+掉头"),
S_U(10, "s_u", "直行+掉头"),
R_U(11, "r_u", "右转+掉头"),
L_S_U(12, "l_s_u", "左转+直行+掉头"),
U_S_R(13, "u_s_r", "直行+右转+掉头"),
L_S_R_U(14, "l_s_r_u", "左转+直行+右转+掉头"),
L_R_U(15, "l_r_u", "左转+右转+掉头");
private Integer key;
private String code;
......
......@@ -35,16 +35,21 @@ import static net.wanji.common.framework.Constants.DATE_FORMAT.E_DATE_FORMAT_SEC
@Component
public class LogAspectHandler {
@Value("${service.name: }")
@Value("${spring.application.name}")
private String serverName;
/**
*
* @AspectLog自定义注解标记的controller
*/
@Pointcut("@annotation(net.wanji.common.annotation.aspect.AspectLog)")
public void controllerAspect() {
}
/**
* 执行切点controller之前执行的逻辑
*
* @param joinPoint
*/
@Before("controllerAspect()")
public void executeBefore(JoinPoint joinPoint) {
try {
......@@ -67,6 +72,12 @@ public class LogAspectHandler {
}
}
/**
* MVC返回结果处理逻辑
*
* @param joinPoint
* @param jsonViewObject
*/
@AfterReturning(value = "controllerAspect()", returning = "jsonViewObject")
public void afterReturning(JoinPoint joinPoint, JsonViewObject jsonViewObject) {
HttpServletRequest request = ((ServletRequestAttributes)
......@@ -89,7 +100,7 @@ public class LogAspectHandler {
operateLog.setStatus(jsonViewObject.getStatus());
operateLog.setResult(JSON.toJSONString(jsonViewObject));
operateLog.setCreateTime(new Date());
log.info("\n 外部系统调用本地接口,请求IP = {} || 接口 = {} || 地址 = {} || 响应状态 = {}", ip, map.get("description").toString(), uri, jsonViewObject.getStatus());
log.info("\n外部系统调用本地接口,请求IP = {} || 接口 = {} || 地址 = {} || 响应状态 = {}", ip, map.get("description").toString(), uri, jsonViewObject.getStatus());
} catch (Exception e) {
//记录本地异常日志
log.error("记录本地接口响应日志异常,异常信息:{}", e);
......@@ -97,7 +108,10 @@ public class LogAspectHandler {
}
private String consoleLogTemplate = "\r\n " +
/**
* 日志打印模板
*/
private String consoleLogTemplate = "\r\n" +
"系统:%s\r\n" +
"URL:%s\r\n" +
"操作类型:%s\r\n" +
......
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