Commit 8a873aff1c9bdab98061ddff3fcb96fd34aa8eba
1 parent
8186365c
update...
Showing
2 changed files
with
20 additions
and
8 deletions
src/main/java/com/bsth/data/history/HistoryConsumeTimeDataHandler.java
| ... | ... | @@ -119,11 +119,13 @@ public class HistoryConsumeTimeDataHandler { |
| 119 | 119 | long timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 60) - System.currentTimeMillis(); |
| 120 | 120 | if (timeDiff < 0) |
| 121 | 121 | timeDiff += (1000 * 60 * 60 * 24); |
| 122 | + | |
| 122 | 123 | //从数据库加载上周的数据,做当天的预测用 |
| 124 | + logger.info(timeDiff / 1000 / 60 + "分钟之后加载历史数据"); | |
| 123 | 125 | Application.mainServices.scheduleAtFixedRate(consumeTimeLoadThread |
| 124 | - , timeDiff, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 126 | + , timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 125 | 127 | |
| 126 | - if (timeDiff > 1000 * 60 * 30) | |
| 128 | + if (timeDiff > 1000 * 60 * 10) | |
| 127 | 129 | consumeTimeLoadThread.run(); |
| 128 | 130 | } |
| 129 | 131 | |
| ... | ... | @@ -236,12 +238,12 @@ public class HistoryConsumeTimeDataHandler { |
| 236 | 238 | */ |
| 237 | 239 | Collection<Line> ls = BasicCacheData.code2LineMap.values(); |
| 238 | 240 | for (Line line : ls) { |
| 239 | - multimap.putAll(line.getLineCode() + "_0_0", new ArrayList<>()); | |
| 240 | - multimap.putAll(line.getLineCode() + "_0_1", new ArrayList<>()); | |
| 241 | - multimap.putAll(line.getLineCode() + "_0_2", new ArrayList<>()); | |
| 242 | - multimap.putAll(line.getLineCode() + "_1_0", new ArrayList<>()); | |
| 243 | - multimap.putAll(line.getLineCode() + "_1_1", new ArrayList<>()); | |
| 244 | - multimap.putAll(line.getLineCode() + "_1_2", new ArrayList<>()); | |
| 241 | + multimap.put(line.getLineCode() + "_0_0", StationConsumeTime.getPlaceholder(line.getLineCode(), 0)); | |
| 242 | + multimap.put(line.getLineCode() + "_0_1", StationConsumeTime.getPlaceholder(line.getLineCode(), 0)); | |
| 243 | + multimap.put(line.getLineCode() + "_0_2", StationConsumeTime.getPlaceholder(line.getLineCode(), 0)); | |
| 244 | + multimap.put(line.getLineCode() + "_1_0", StationConsumeTime.getPlaceholder(line.getLineCode(), 1)); | |
| 245 | + multimap.put(line.getLineCode() + "_1_1", StationConsumeTime.getPlaceholder(line.getLineCode(), 1)); | |
| 246 | + multimap.put(line.getLineCode() + "_1_2", StationConsumeTime.getPlaceholder(line.getLineCode(), 1)); | |
| 245 | 247 | } |
| 246 | 248 | |
| 247 | 249 | //按线路、走向、早晚高峰分组 |
| ... | ... | @@ -292,6 +294,8 @@ public class HistoryConsumeTimeDataHandler { |
| 292 | 294 | //按 key 分组数据 |
| 293 | 295 | ArrayListMultimap<String, StationConsumeTime> multimap = ArrayListMultimap.create(); |
| 294 | 296 | for (StationConsumeTime sct : list) { |
| 297 | + if (sct.getRq() == 0) | |
| 298 | + continue; | |
| 295 | 299 | multimap.put(sct.getKey1(), sct); |
| 296 | 300 | } |
| 297 | 301 | ... | ... |
src/main/java/com/bsth/data/history/entity/StationConsumeTime.java
| ... | ... | @@ -88,6 +88,14 @@ public class StationConsumeTime { |
| 88 | 88 | return sct; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | + public static StationConsumeTime getPlaceholder(String lineCode, int upDown) { | |
| 92 | + StationConsumeTime sct = new StationConsumeTime(); | |
| 93 | + sct.setRq(0); | |
| 94 | + sct.setLineCode(lineCode); | |
| 95 | + sct.setUpDown(upDown); | |
| 96 | + return sct; | |
| 97 | + } | |
| 98 | + | |
| 91 | 99 | public String getLineCode() { |
| 92 | 100 | return lineCode; |
| 93 | 101 | } | ... | ... |