Commit e7f03570 authored by duanruiming's avatar duanruiming

[add] 优化绿波干线优化时间-逻辑优化版本

parent 4b0f54cf
...@@ -475,6 +475,13 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -475,6 +475,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
for (Map.Entry<Integer, List<StrategyGreenOptHistEntity>> entry : listMap.entrySet()) { for (Map.Entry<Integer, List<StrategyGreenOptHistEntity>> entry : listMap.entrySet()) {
Integer greenId = entry.getKey(); Integer greenId = entry.getKey();
List<StrategyGreenOptHistEntity> value = entry.getValue(); List<StrategyGreenOptHistEntity> value = entry.getValue();
// 策略正常结束
StrategyGreenOptHistEntity last = value.get(0);
if (Objects.nonNull(last) && Objects.equals(-1, last.getControlMethod())) {
Date parse = DateUtil.parse(last.getControlTime(), "yyyy-MM-dd HH:mm:ss");
long controlLong = parse.getTime();
endTime = controlLong;
}
for (StrategyGreenOptHistEntity entity : value) { for (StrategyGreenOptHistEntity entity : value) {
if (Objects.equals(0 , entity.getDirType())) { if (Objects.equals(0 , entity.getDirType())) {
continue; continue;
...@@ -483,24 +490,14 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -483,24 +490,14 @@ public class StrategyControlServiceImpl implements StrategyControlService {
Integer controlMethod = entity.getControlMethod(); Integer controlMethod = entity.getControlMethod();
Date parse = DateUtil.parse(controlTime, "yyyy-MM-dd HH:mm:ss"); Date parse = DateUtil.parse(controlTime, "yyyy-MM-dd HH:mm:ss");
long controlLong = parse.getTime(); long controlLong = parse.getTime();
// 优化次数:去掉-1, 剩余记录总数 // 优化次数:去掉-1, 剩余记录总数 当前情况未考虑多次启动停止
long temp = endTime; if (!Objects.equals(-1, controlMethod)) {
if (Objects.equals(-1, controlMethod)) {
endTime = parse.getTime();
continue;
} else {
greenOptCount += 1; greenOptCount += 1;
// 最新数据与当前数据比较,小于30min long temp = endTime;
if (endTime - controlLong < 30 * 60 * 1000) { int offset = (int) ((temp - controlLong) / 1000);
temp = endTime; greenOptTime += offset;
endTime = current;
} else {
temp = endTime;
endTime = controlLong;
}
} }
int offset = (int) ((temp - controlLong) / 1000); endTime = controlLong;
greenOptTime += offset;
} }
} }
} }
......
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