Commit 077cdedabbc37ee623213aebab182efe34aac054
1 parent
de957a9b
update...
Showing
9 changed files
with
80 additions
and
62 deletions
src/main/java/com/bsth/controller/XmlInfoPublishController.java
| ... | ... | @@ -140,6 +140,7 @@ public class XmlInfoPublishController { |
| 140 | 140 | List<GpsEntity> list = GpsCacheData.findList(lineid, upDown); |
| 141 | 141 | |
| 142 | 142 | Map<String, Double> disMap = new HashMap<>(); |
| 143 | + Map<String, Integer> snMap = new HashMap<>(); | |
| 143 | 144 | List<StationRoute> srs = GeoCacheData.find(lineid, upDown); |
| 144 | 145 | |
| 145 | 146 | StationRoute es = GeoCacheData.findByCode(lineid, upDown, stopid), s = null; |
| ... | ... | @@ -147,6 +148,7 @@ public class XmlInfoPublishController { |
| 147 | 148 | List<GpsEntity> vs = new ArrayList<>(); |
| 148 | 149 | ScheduleRealInfo sch = null; |
| 149 | 150 | double sum; |
| 151 | + int sn; | |
| 150 | 152 | |
| 151 | 153 | int serialNo = es.getSerialNo(); |
| 152 | 154 | for (GpsEntity gps : list) { |
| ... | ... | @@ -155,8 +157,17 @@ public class XmlInfoPublishController { |
| 155 | 157 | if (null == s || s.getSerialNo() > serialNo) |
| 156 | 158 | continue; |
| 157 | 159 | |
| 160 | + if ("B".equals(s.getMark()) && gps.getInOut() == 1) | |
| 161 | + continue;//起点站 站内车辆 | |
| 162 | + | |
| 158 | 163 | sch = gps.getSch(); |
| 159 | 164 | if (null != sch) {//有班次 |
| 165 | + if ("ldks".equals(sch.getBcType()) | |
| 166 | + || "venting".equals(sch.getBcType()) | |
| 167 | + || "in".equals(sch.getBcType()) | |
| 168 | + || "out".equals(sch.getBcType())) | |
| 169 | + continue;//非营运班次 | |
| 170 | + | |
| 160 | 171 | if (serialNo > sch.getQdzNo() && serialNo < sch.getZdzNo()) |
| 161 | 172 | vs.add(gps); |
| 162 | 173 | } else { |
| ... | ... | @@ -164,15 +175,18 @@ public class XmlInfoPublishController { |
| 164 | 175 | } |
| 165 | 176 | |
| 166 | 177 | sum = 0; |
| 178 | + sn = 1; | |
| 167 | 179 | |
| 168 | 180 | for (StationRoute sr : srs) { |
| 169 | 181 | if (sr.getSerialNo() < serialNo |
| 170 | 182 | && sr.getSerialNo() > gps.getStationNo()) { |
| 171 | 183 | sum += sr.getLength(); |
| 184 | + sn++; | |
| 172 | 185 | } |
| 173 | 186 | } |
| 174 | 187 | |
| 175 | 188 | disMap.put(gps.getDeviceId(), sum); |
| 189 | + snMap.put(gps.getDeviceId(), sn); | |
| 176 | 190 | } |
| 177 | 191 | |
| 178 | 192 | |
| ... | ... | @@ -187,7 +201,8 @@ public class XmlInfoPublishController { |
| 187 | 201 | for (GpsEntity v : vs) { |
| 188 | 202 | sb.append("<car>"); |
| 189 | 203 | sb.append("<terminal>" + BasicCacheData.device2plateMap.get(v.getDeviceId()) + "</terminal>"); |
| 190 | - sb.append("<stopdis>" + df.format(v.getStopDis()) + "</stopdis>"); | |
| 204 | + //sb.append("<terminal>" + v.getNbbm() + "</terminal>"); | |
| 205 | + sb.append("<stopdis>" + snMap.get(v.getDeviceId()) + "</stopdis>"); | |
| 191 | 206 | sb.append("<distance>" + df.format((disMap.get(v.getDeviceId()) + v.getDistance())) + "</distance>"); |
| 192 | 207 | sb.append("<time>" + forecast.get(v.getDeviceId()) + "</time>"); |
| 193 | 208 | sb.append("</car>"); | ... | ... |
src/main/java/com/bsth/data/gps/process/DataMainProcessor.java
| ... | ... | @@ -52,7 +52,7 @@ public class DataMainProcessor { |
| 52 | 52 | |
| 53 | 53 | public void start() { |
| 54 | 54 | Application.mainServices.scheduleWithFixedDelay(dataLoaderThread |
| 55 | - , 40, 10, TimeUnit.SECONDS); | |
| 55 | + , 40, 5, TimeUnit.SECONDS); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public void process(ArrayListMultimap<String, GpsEntity> data) { | ... | ... |
src/main/java/com/bsth/data/gps/process/chains/InOutStationProcess.java
| ... | ... | @@ -112,7 +112,7 @@ public class InOutStationProcess { |
| 112 | 112 | continue; |
| 113 | 113 | |
| 114 | 114 | for (int i = 1, size = ps.size(); i < size; i++) { |
| 115 | - distance = GeoUtils.getDistanceFromLine(p, ps.get(i - 1), ps.get(i)); | |
| 115 | + distance = GeoUtils.getDistanceFromLine(ps.get(i - 1), ps.get(i), p); | |
| 116 | 116 | |
| 117 | 117 | if (Double.isNaN(distance)) |
| 118 | 118 | continue; | ... | ... |
src/main/java/com/bsth/data/history/HistoryConsumeTimeDataHandler.java
| 1 | 1 | package com.bsth.data.history; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.Application; |
| 4 | +import com.bsth.data.BasicCacheData; | |
| 4 | 5 | import com.bsth.data.geo.GeoCacheData; |
| 5 | 6 | import com.bsth.data.history.entity.LineConsumeTime; |
| 6 | 7 | import com.bsth.data.history.entity.StationConsumeTime; |
| 7 | 8 | import com.bsth.entity.GpsEntity; |
| 9 | +import com.bsth.entity.Line; | |
| 8 | 10 | import com.bsth.entity.StationRoute; |
| 9 | 11 | import com.bsth.util.DateUtils; |
| 10 | 12 | import com.bsth.util.db_utils.DBUtils_InfoPublish; |
| ... | ... | @@ -59,7 +61,7 @@ public class HistoryConsumeTimeDataHandler { |
| 59 | 61 | */ |
| 60 | 62 | private static ConcurrentMap<String, LineConsumeTime> lctMaps; |
| 61 | 63 | |
| 62 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 64 | + static Logger logger = LoggerFactory.getLogger(HistoryConsumeTimeDataHandler.class); | |
| 63 | 65 | |
| 64 | 66 | static { |
| 65 | 67 | lastInStationMap = new ConcurrentHashMap(); |
| ... | ... | @@ -109,8 +111,8 @@ public class HistoryConsumeTimeDataHandler { |
| 109 | 111 | |
| 110 | 112 | public void start() { |
| 111 | 113 | //将到离站数据入库 |
| 112 | - //Application.mainServices.scheduleWithFixedDelay(consumeTimePstThread | |
| 113 | - // , 60, 30, TimeUnit.SECONDS); | |
| 114 | + Application.mainServices.scheduleWithFixedDelay(consumeTimePstThread | |
| 115 | + , 30, 30, TimeUnit.SECONDS); | |
| 114 | 116 | |
| 115 | 117 | |
| 116 | 118 | //凌晨一点 |
| ... | ... | @@ -226,8 +228,23 @@ public class HistoryConsumeTimeDataHandler { |
| 226 | 228 | jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(StationConsumeTime.class)); |
| 227 | 229 | |
| 228 | 230 | logger.info("select end,, " + list.size()); |
| 229 | - //按线路、走向、早晚高峰分组 | |
| 230 | 231 | ArrayListMultimap<String, StationConsumeTime> multimap = ArrayListMultimap.create(); |
| 232 | + | |
| 233 | + /** | |
| 234 | + * 初始化key | |
| 235 | + * 保证即使某时段缺少历史数据的时候,仍然可以根据 key ,用实时距离初始化一份耗时数据 | |
| 236 | + */ | |
| 237 | + Collection<Line> ls = BasicCacheData.code2LineMap.values(); | |
| 238 | + 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<>()); | |
| 245 | + } | |
| 246 | + | |
| 247 | + //按线路、走向、早晚高峰分组 | |
| 231 | 248 | int peakVal, v; |
| 232 | 249 | for (StationConsumeTime sct : list) { |
| 233 | 250 | peakVal = 1; |
| ... | ... | @@ -244,7 +261,7 @@ public class HistoryConsumeTimeDataHandler { |
| 244 | 261 | LineConsumeTime lct; |
| 245 | 262 | Set<String> ks = multimap.keySet(); |
| 246 | 263 | for (String k : ks) { |
| 247 | - lct = buildLineConsumeData(multimap.get(k)); | |
| 264 | + lct = buildLineConsumeData(multimap.get(k), k); | |
| 248 | 265 | map.put(k, lct); |
| 249 | 266 | } |
| 250 | 267 | |
| ... | ... | @@ -256,9 +273,10 @@ public class HistoryConsumeTimeDataHandler { |
| 256 | 273 | } |
| 257 | 274 | } |
| 258 | 275 | |
| 259 | - private LineConsumeTime buildLineConsumeData(List<StationConsumeTime> list) { | |
| 260 | - String lineCode = list.get(0).getLineCode(); | |
| 261 | - int upDown = list.get(0).getUpDown(); | |
| 276 | + private LineConsumeTime buildLineConsumeData(List<StationConsumeTime> list, String k) { | |
| 277 | + String[] arr = k.split("_"); | |
| 278 | + String lineCode = arr[0]; | |
| 279 | + int upDown = Integer.parseInt(arr[1]); | |
| 262 | 280 | |
| 263 | 281 | LineConsumeTime lct = new LineConsumeTime(); |
| 264 | 282 | lct.setLineCode(lineCode); |
| ... | ... | @@ -425,30 +443,34 @@ public class HistoryConsumeTimeDataHandler { |
| 425 | 443 | */ |
| 426 | 444 | public static void batchSaveConsumeData(List<StationConsumeTime> list) { |
| 427 | 445 | //写入数据 |
| 428 | - JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_InfoPublish.getDataSource()); | |
| 429 | - jdbcTemplate.batchUpdate("insert into bsth_h_consume_time(rq,line_code,up_down,key1,key2,in_d1,in_d2,distance,seconds,time_str,nbbm) " + | |
| 430 | - " values (?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 431 | - | |
| 432 | - @Override | |
| 433 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 434 | - StationConsumeTime sct = list.get(i); | |
| 435 | - ps.setInt(1, sct.getRq()); | |
| 436 | - ps.setString(2, sct.getLineCode()); | |
| 437 | - ps.setInt(3, sct.getUpDown()); | |
| 438 | - ps.setString(4, sct.getKey1()); | |
| 439 | - ps.setString(5, sct.getKey2()); | |
| 440 | - ps.setDouble(6, sct.getInD1()); | |
| 441 | - ps.setDouble(7, sct.getInD2()); | |
| 442 | - ps.setDouble(8, sct.getDistance()); | |
| 443 | - ps.setInt(9, sct.getSeconds()); | |
| 444 | - ps.setString(10, sct.getTimeStr()); | |
| 445 | - ps.setString(11, sct.getNbbm()); | |
| 446 | - } | |
| 446 | + try { | |
| 447 | + JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_InfoPublish.getDataSource()); | |
| 448 | + jdbcTemplate.batchUpdate("insert into bsth_h_consume_time(rq,line_code,up_down,key1,key2,in_d1,in_d2,distance,seconds,time_str,nbbm) " + | |
| 449 | + " values (?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 450 | + | |
| 451 | + @Override | |
| 452 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 453 | + StationConsumeTime sct = list.get(i); | |
| 454 | + ps.setInt(1, sct.getRq()); | |
| 455 | + ps.setString(2, sct.getLineCode()); | |
| 456 | + ps.setInt(3, sct.getUpDown()); | |
| 457 | + ps.setString(4, sct.getKey1()); | |
| 458 | + ps.setString(5, sct.getKey2()); | |
| 459 | + ps.setDouble(6, sct.getInD1()); | |
| 460 | + ps.setDouble(7, sct.getInD2()); | |
| 461 | + ps.setDouble(8, sct.getDistance()); | |
| 462 | + ps.setInt(9, sct.getSeconds()); | |
| 463 | + ps.setString(10, sct.getTimeStr()); | |
| 464 | + ps.setString(11, sct.getNbbm()); | |
| 465 | + } | |
| 447 | 466 | |
| 448 | - @Override | |
| 449 | - public int getBatchSize() { | |
| 450 | - return list.size(); | |
| 451 | - } | |
| 452 | - }); | |
| 467 | + @Override | |
| 468 | + public int getBatchSize() { | |
| 469 | + return list.size(); | |
| 470 | + } | |
| 471 | + }); | |
| 472 | + } catch (Exception e) { | |
| 473 | + logger.error("", e); | |
| 474 | + } | |
| 453 | 475 | } |
| 454 | 476 | } | ... | ... |
src/main/java/com/bsth/entity/GpsEntity.java
| ... | ... | @@ -50,10 +50,6 @@ public class GpsEntity implements Serializable { |
| 50 | 50 | private String stationCode; |
| 51 | 51 | private String stationName; |
| 52 | 52 | private int stationNo; |
| 53 | - /** | |
| 54 | - * 当前站点站距信息 | |
| 55 | - */ | |
| 56 | - private double stopDis; | |
| 57 | 53 | |
| 58 | 54 | /** |
| 59 | 55 | * 0: 站外 1: 站内 2:场内 |
| ... | ... | @@ -147,14 +143,12 @@ public class GpsEntity implements Serializable { |
| 147 | 143 | this.stationCode = s.getStationCode(); |
| 148 | 144 | this.stationName = s.getName(); |
| 149 | 145 | this.stationNo = s.getSerialNo(); |
| 150 | - this.stopDis = s.getLength(); | |
| 151 | 146 | } |
| 152 | 147 | |
| 153 | 148 | public void setStationInfo(GpsEntity prev){ |
| 154 | 149 | this.stationCode = prev.stationCode; |
| 155 | 150 | this.stationName = prev.stationName; |
| 156 | 151 | this.stationNo = prev.stationNo; |
| 157 | - this.stopDis = prev.stopDis; | |
| 158 | 152 | } |
| 159 | 153 | |
| 160 | 154 | public Point getPoint(){ |
| ... | ... | @@ -369,11 +363,4 @@ public class GpsEntity implements Serializable { |
| 369 | 363 | this.release = release; |
| 370 | 364 | } |
| 371 | 365 | |
| 372 | - public double getStopDis() { | |
| 373 | - return stopDis; | |
| 374 | - } | |
| 375 | - | |
| 376 | - public void setStopDis(double stopDis) { | |
| 377 | - this.stopDis = stopDis; | |
| 378 | - } | |
| 379 | 366 | } | ... | ... |
src/main/java/com/bsth/util/geo/GeoUtils.java
src/main/resources/static/index.html
| ... | ... | @@ -54,23 +54,17 @@ |
| 54 | 54 | </a> |
| 55 | 55 | </li> |
| 56 | 56 | <li class="nav-item "> |
| 57 | - <a class="nav-link" href="../examples/typography.html"> | |
| 58 | - <i class="material-icons">history</i> | |
| 59 | - <p>历史查询</p> | |
| 60 | - </a> | |
| 61 | - </li> | |
| 62 | - <li class="nav-item "> | |
| 63 | 57 | <a class="nav-link" href="/pages/interface_test/iTest.html"> |
| 64 | 58 | <i class="material-icons">info</i> |
| 65 | 59 | <p>信息发布接口测试</p> |
| 66 | 60 | </a> |
| 67 | - </li> | |
| 61 | + </li><!-- | |
| 68 | 62 | <li class="nav-item "> |
| 69 | 63 | <a class="nav-link" href="../examples/maps.html"> |
| 70 | 64 | <i class="material-icons">bar_chart</i> |
| 71 | 65 | <p>统计分析</p> |
| 72 | 66 | </a> |
| 73 | - </li> | |
| 67 | + </li>--> | |
| 74 | 68 | </ul> |
| 75 | 69 | </div> |
| 76 | 70 | </div> |
| ... | ... | @@ -152,7 +146,7 @@ |
| 152 | 146 | $('.left_menus ul>li.nav-item.active').removeClass('active'); |
| 153 | 147 | $(this).parents('li.nav-item').addClass('active'); |
| 154 | 148 | return false; |
| 155 | - }).eq(5).trigger('click'); | |
| 149 | + }).eq(4).trigger('click'); | |
| 156 | 150 | |
| 157 | 151 | |
| 158 | 152 | $('body').bootstrapMaterialDesign(); | ... | ... |
src/main/resources/static/pages/h_consume/list.html
| ... | ... | @@ -71,7 +71,7 @@ |
| 71 | 71 | <div class="form-group"> |
| 72 | 72 | <label class="bmd-label-floating">日期</label> |
| 73 | 73 | <input type="text" name="rq" required class="form-control flatpickr_date" |
| 74 | - value="2018-06-14"> | |
| 74 | + value="2018-06-20"> | |
| 75 | 75 | </div> |
| 76 | 76 | </div> |
| 77 | 77 | <div class="col-md-2"> |
| ... | ... | @@ -85,13 +85,13 @@ |
| 85 | 85 | <div class="col-md-2" style="padding-right: 0"> |
| 86 | 86 | <div class="form-group"> |
| 87 | 87 | <label class="bmd-label-floating">时间</label> |
| 88 | - <input type="time" name="st" required class="form-control flatpickr_time" value="00:00"> | |
| 88 | + <input type="time" name="st" required class="form-control flatpickr_time" value="05:00"> | |
| 89 | 89 | </div> |
| 90 | 90 | </div> |
| 91 | 91 | <div class="col-md-2" style="padding-left: 0"> |
| 92 | 92 | <div class="form-group"> |
| 93 | 93 | <label class="bmd-label-floating">至</label> |
| 94 | - <input type="time" name="et" required class="form-control flatpickr_time" value="23:59"> | |
| 94 | + <input type="time" name="et" required class="form-control flatpickr_time" value="10:00"> | |
| 95 | 95 | </div> |
| 96 | 96 | </div> |
| 97 | 97 | <div class="col-md-2"> | ... | ... |
src/main/resources/static/pages/interface_test/iTest.html
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | <div class="col-md-2 field" style="margin-top: 5px;"> |
| 61 | 61 | <div class="form-group"> |
| 62 | 62 | <label class="bmd-label-floating">时间(t)</label> |
| 63 | - <input type="text" name="t" class="form-control" value="2018-06-25 12:10"> | |
| 63 | + <input type="text" name="t" class="form-control" value=""> | |
| 64 | 64 | </div> |
| 65 | 65 | </div> |
| 66 | 66 | <div class="col-md-1"> | ... | ... |