Commit 35716e72 authored by hanbing's avatar hanbing

[update] 诊断优化,处理缺少数据异常

parent 0b165ee2
...@@ -162,9 +162,7 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -162,9 +162,7 @@ public class DiagnoServiceImpl implements DiagnoService {
schemeOptVO.setCrossId(crossId); schemeOptVO.setCrossId(crossId);
// 选择数据批次时间最大的记录 // 选择数据批次时间最大的记录
List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId); List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId);
if (CollectionUtil.isEmpty(maxList)) { if (CollectionUtil.isNotEmpty(maxList)) {
throw new RuntimeException("没有该路口优化日志数据");
}
// 根据相位去重 // 根据相位去重
TreeSet<CrossSchemeOptLogPO> collect = maxList.stream() TreeSet<CrossSchemeOptLogPO> collect = maxList.stream()
.collect(Collectors.toCollection( .collect(Collectors.toCollection(
...@@ -174,12 +172,15 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -174,12 +172,15 @@ public class DiagnoServiceImpl implements DiagnoService {
schemeOptVO.setOptType(Integer.parseInt(optType)); schemeOptVO.setOptType(Integer.parseInt(optType));
Integer schemeId = crossSchemeOptLogPO.getSchemeId(); Integer schemeId = crossSchemeOptLogPO.getSchemeId();
CrossSchemePO crossSchemePO = crossSchemeMapper.selectById(schemeId); CrossSchemePO crossSchemePO = crossSchemeMapper.selectById(schemeId);
if (crossSchemePO != null) {
schemeOptVO.setCycle(crossSchemePO.getCycle()); schemeOptVO.setCycle(crossSchemePO.getCycle());
schemeOptVO.setSchemeId(crossSchemePO.getId()); schemeOptVO.setSchemeId(crossSchemePO.getId());
schemeOptVO.setOffset(crossSchemeOptLogPO.getOffset()); schemeOptVO.setOffset(crossSchemeOptLogPO.getOffset());
}
// 构造调整时间列表 // 构造调整时间列表
List<SchemeOptVO.PhaseOptTime> phaseOptTimeList = buildPhaseOptTimeList(collect, schemeId); List<SchemeOptVO.PhaseOptTime> phaseOptTimeList = buildPhaseOptTimeList(collect, schemeId);
schemeOptVO.setPhaseOptTimeList(phaseOptTimeList); schemeOptVO.setPhaseOptTimeList(phaseOptTimeList);
}
return schemeOptVO; return schemeOptVO;
} }
...@@ -245,9 +246,7 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -245,9 +246,7 @@ public class DiagnoServiceImpl implements DiagnoService {
String crossId = sendManualDTO.getSendCrossId(); String crossId = sendManualDTO.getSendCrossId();
// 选择数据批次时间最大的记录 // 选择数据批次时间最大的记录
List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId); List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId);
if (CollectionUtil.isEmpty(maxList)) { if (CollectionUtil.isNotEmpty(maxList)) {
throw new RuntimeException("没有该路口优化日志数据");
}
CrossSchemeOptLogPO crossSchemeOptLogPO = maxList.get(0); CrossSchemeOptLogPO crossSchemeOptLogPO = maxList.get(0);
String dataExtend = crossSchemeOptLogPO.getDataExtend(); String dataExtend = crossSchemeOptLogPO.getDataExtend();
OptDataExtend optDataExtendOld = gson.fromJson(dataExtend, OptDataExtend.class); OptDataExtend optDataExtendOld = gson.fromJson(dataExtend, OptDataExtend.class);
...@@ -258,6 +257,8 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -258,6 +257,8 @@ public class DiagnoServiceImpl implements DiagnoService {
optDataExtendNew.setIdeaName("手动干预"); optDataExtendNew.setIdeaName("手动干预");
return gson.toJson(optDataExtendNew); return gson.toJson(optDataExtendNew);
} }
return null;
}
private List<SchemeSendVO.Pattern> buildPatternList(String sendCrossId, Integer schemeId, private List<SchemeSendVO.Pattern> buildPatternList(String sendCrossId, Integer schemeId,
Map<String, Integer> phaseOffsetTimeMap) { Map<String, Integer> phaseOffsetTimeMap) {
...@@ -343,12 +344,8 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -343,12 +344,8 @@ public class DiagnoServiceImpl implements DiagnoService {
CrossInfoPO crossInfoPO = crossInfoMapper.selectById(crossId); CrossInfoPO crossInfoPO = crossInfoMapper.selectById(crossId);
optEffectVO.setCrossName(crossInfoPO.getName()); optEffectVO.setCrossName(crossInfoPO.getName());
List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId); List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId);
CrossSchemeOptLogPO crossSchemeOptLogPO = null; if (maxList != null) {
try { CrossSchemeOptLogPO crossSchemeOptLogPO = maxList.get(0);
crossSchemeOptLogPO = maxList.get(0);
} catch (IndexOutOfBoundsException e) {
throw new RuntimeException("没有该路口优化日志数据");
}
optEffectVO.setOptStartTime(crossSchemeOptLogPO.getStartTime()); optEffectVO.setOptStartTime(crossSchemeOptLogPO.getStartTime());
Date endTime = crossSchemeOptLogPO.getEndTime(); Date endTime = crossSchemeOptLogPO.getEndTime();
if (ObjectUtil.isEmpty(endTime)) { if (ObjectUtil.isEmpty(endTime)) {
...@@ -356,7 +353,7 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -356,7 +353,7 @@ public class DiagnoServiceImpl implements DiagnoService {
} else { } else {
optEffectVO.setStatus(1); optEffectVO.setStatus(1);
} }
}
Integer dir = crossIdAndDirDTO.getDir(); Integer dir = crossIdAndDirDTO.getDir();
// 获取当前时间之前45分钟的10位时间戳 // 获取当前时间之前45分钟的10位时间戳
long currentSeconds = DateUtil.currentSeconds(); long currentSeconds = DateUtil.currentSeconds();
...@@ -367,19 +364,23 @@ public class DiagnoServiceImpl implements DiagnoService { ...@@ -367,19 +364,23 @@ public class DiagnoServiceImpl implements DiagnoService {
// 获取路口历史数据 // 获取路口历史数据
List<CrossDataHistPO> crossDataHistPOList = List<CrossDataHistPO> crossDataHistPOList =
crossDataHistMapper.selectByCrossIdAndTimestamp(crossId, preSeconds); crossDataHistMapper.selectByCrossIdAndTimestamp(crossId, preSeconds);
if (CollectionUtil.isNotEmpty(crossDataHistPOList)) {
List<OptEffectVO.IndexDelay> indexDelayList = buildIndexDelayList(crossDataHistPOList); List<OptEffectVO.IndexDelay> indexDelayList = buildIndexDelayList(crossDataHistPOList);
optEffectVO.setIndexDelayList(indexDelayList); optEffectVO.setIndexDelayList(indexDelayList);
List<OptEffectVO.QueueStop> queueStopList = buildQueueStopList(crossDataHistPOList); List<OptEffectVO.QueueStop> queueStopList = buildQueueStopList(crossDataHistPOList);
optEffectVO.setQueueStopList(queueStopList); optEffectVO.setQueueStopList(queueStopList);
}
} else { } else {
// 获取路口方向历史数据 // 获取路口方向历史数据
List<CrossDirDataHistPO> crossDirDataHistPOList = List<CrossDirDataHistPO> crossDirDataHistPOList =
crossDirDataHistMapper.selectByCrossIdDirAndTimestamp(crossId, dir, preSeconds); crossDirDataHistMapper.selectByCrossIdDirAndTimestamp(crossId, dir, preSeconds);
if (CollectionUtil.isNotEmpty(crossDirDataHistPOList)) {
List<OptEffectVO.IndexDelay> indexDelayList = buildIndexDelayListDir(crossDirDataHistPOList); List<OptEffectVO.IndexDelay> indexDelayList = buildIndexDelayListDir(crossDirDataHistPOList);
optEffectVO.setIndexDelayList(indexDelayList); optEffectVO.setIndexDelayList(indexDelayList);
List<OptEffectVO.QueueStop> queueStopList = buildQueueStopListDir(crossDirDataHistPOList); List<OptEffectVO.QueueStop> queueStopList = buildQueueStopListDir(crossDirDataHistPOList);
optEffectVO.setQueueStopList(queueStopList); optEffectVO.setQueueStopList(queueStopList);
} }
}
return optEffectVO; return optEffectVO;
} }
......
...@@ -67,9 +67,7 @@ public class EvaluateServiceImpl implements EvaluateService { ...@@ -67,9 +67,7 @@ public class EvaluateServiceImpl implements EvaluateService {
private void fillOptData(EvaluateCrossDetailVO evaluateCrossDetailVO, String crossId) { private void fillOptData(EvaluateCrossDetailVO evaluateCrossDetailVO, String crossId) {
// 选择数据批次时间最大的记录 // 选择数据批次时间最大的记录
List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId); List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId);
if (CollectionUtil.isEmpty(maxList)) { if (CollectionUtil.isNotEmpty(maxList)) {
throw new RuntimeException("没有该路口优化日志数据");
}
CrossSchemeOptLogPO crossSchemeOptLogPO = maxList.get(0); CrossSchemeOptLogPO crossSchemeOptLogPO = maxList.get(0);
// 解析dataExtend // 解析dataExtend
String dataExtend = crossSchemeOptLogPO.getDataExtend(); String dataExtend = crossSchemeOptLogPO.getDataExtend();
...@@ -85,4 +83,5 @@ public class EvaluateServiceImpl implements EvaluateService { ...@@ -85,4 +83,5 @@ public class EvaluateServiceImpl implements EvaluateService {
evaluateCrossDetailVO.setOptStatus(1); evaluateCrossDetailVO.setOptStatus(1);
} }
} }
}
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from t_base_cross_scheme_opt_log from t_base_cross_scheme_opt_log
where cross_id = #{crossId} where cross_id = #{crossId}
and data_batch_time=(SELECT MAX(ABS(data_batch_time)) FROM t_base_cross_scheme_opt_log); and data_batch_time=(SELECT MAX(ABS(data_batch_time)) FROM t_base_cross_scheme_opt_log WHERE cross_id = #{crossId});
</select> </select>
<insert id="insertOne" parameterType="net.wanji.opt.po.base.CrossSchemeOptLogPO"> <insert id="insertOne" parameterType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
......
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