Commit 56af947d7ff24d1833e0f026b6e5a96f89ea7cba
1 parent
c4167f3d
update...
Showing
5 changed files
with
35 additions
and
25 deletions
src/main/java/com/bsth/StartCommand.java
| ... | ... | @@ -63,7 +63,7 @@ public class StartCommand implements CommandLineRunner { |
| 63 | 63 | logger.info("load geo data start..."); |
| 64 | 64 | fixedLoadCacheThread.run(); |
| 65 | 65 | logger.info("load geo data end..."); |
| 66 | - sexec.scheduleWithFixedDelay(fixedLoadCacheThread, 60 * 300, 60 * 300, TimeUnit.SECONDS); | |
| 66 | + sexec.scheduleWithFixedDelay(fixedLoadCacheThread, 60 * 10, 60 * 10, TimeUnit.SECONDS); | |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | /**/ //定时刷新班次信息 | ... | ... |
src/main/java/com/bsth/data/geo/loader/DataLoader.java
| ... | ... | @@ -33,6 +33,7 @@ public class DataLoader { |
| 33 | 33 | |
| 34 | 34 | public void load(List<String> codes) { |
| 35 | 35 | try { |
| 36 | + logger.info("load geo data, codes: " + codes); | |
| 36 | 37 | String inCond = null; |
| 37 | 38 | if (null != codes && codes.size() > 0) { |
| 38 | 39 | StringBuilder sb = new StringBuilder(); |
| ... | ... | @@ -56,7 +57,7 @@ public class DataLoader { |
| 56 | 57 | //计算空间属性 |
| 57 | 58 | fullSections = GeoCalculator.calc(stationMaps.get(k), sectionMaps.get(k)); |
| 58 | 59 | |
| 59 | - if(null != fullSections) | |
| 60 | + if (null != fullSections) | |
| 60 | 61 | fullSectionMaps.putAll(k, fullSections); |
| 61 | 62 | } |
| 62 | 63 | |
| ... | ... | @@ -75,7 +76,7 @@ public class DataLoader { |
| 75 | 76 | |
| 76 | 77 | List<CarPark> cps = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CarPark.class)); |
| 77 | 78 | Polygon polygon; |
| 78 | - for(CarPark cp : cps){ | |
| 79 | + for (CarPark cp : cps) { | |
| 79 | 80 | polygon = GeoUtils.parsePolygon(cp.getPolygonStr()); |
| 80 | 81 | cp.setPolygon(polygon); |
| 81 | 82 | } |
| ... | ... | @@ -96,7 +97,7 @@ public class DataLoader { |
| 96 | 97 | " FROM" + |
| 97 | 98 | " ( SELECT line_code, station_code, station_name AS NAME, station_route_code AS serial_no, directions AS up_down FROM bsth_c_stationroute WHERE destroy = 0 ) a" + |
| 98 | 99 | " LEFT JOIN bsth_c_station b ON a.station_code = b.station_cod" |
| 99 | - + (inCont == null ? "" : " where a.line_code in (" + inCont + ")"); | |
| 100 | + + (inCont == null ? "" : " where a.line_code in (" + inCont + ")") + " order by serial_no"; | |
| 100 | 101 | |
| 101 | 102 | List<StationRoute> srs = jdbcTemplate.query(sql |
| 102 | 103 | , BeanPropertyRowMapper.newInstance(StationRoute.class)); |
| ... | ... | @@ -123,7 +124,7 @@ public class DataLoader { |
| 123 | 124 | " FROM " + |
| 124 | 125 | " ( SELECT line_code, directions, sectionroute_code AS i, section_code FROM bsth_c_sectionroute WHERE destroy = 0 ) a " + |
| 125 | 126 | " LEFT JOIN bsth_c_section b ON a.section_code = b.section_code " |
| 126 | - + (inCont == null ? "" : " where a.line_code in (" + inCont + ")"); | |
| 127 | + + (inCont == null ? "" : " where a.line_code in (" + inCont + ")") + " order by i"; | |
| 127 | 128 | |
| 128 | 129 | List<SectionRoute> srs = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SectionRoute.class)); |
| 129 | 130 | ... | ... |
src/main/java/com/bsth/data/geo/loader/thread/DataLoadThread.java
| ... | ... | @@ -36,20 +36,19 @@ public class DataLoadThread extends Thread { |
| 36 | 36 | public void run() { |
| 37 | 37 | |
| 38 | 38 | try { |
| 39 | - t = System.currentTimeMillis(); | |
| 40 | 39 | if (firstLoadFlag) { |
| 41 | 40 | cacheLoader.load(null); |
| 42 | 41 | firstLoadFlag = false; |
| 43 | 42 | } else { |
| 44 | 43 | |
| 45 | - String timeStr = fmtyyyyMMddHHmm.print(t), | |
| 46 | - sql = "select DISTINCT line_code from bsth_c_sectionroute where section_code in (select section_code from bsth_c_section where update_date>='" + timeStr + "') " + | |
| 47 | - " UNION" + | |
| 48 | - " select DISTINCT line_code from bsth_c_stationroute where station_code in ( select station_cod from bsth_c_station where update_date>='" + timeStr + "') " + | |
| 49 | - " UNION" + | |
| 50 | - " select DISTINCT line_code from bsth_c_stationroute where update_date>='" + timeStr + "' " + | |
| 51 | - " UNION" + | |
| 52 | - " select DISTINCT line_code from bsth_c_sectionroute where update_date>='" + timeStr + "'"; | |
| 44 | + String timeStr = fmtyyyyMMddHHmm.print(t - 1000 * 20); | |
| 45 | + String sql = "select DISTINCT line_code from bsth_c_sectionroute where section_code in (select section_code from bsth_c_section where update_date>='" + timeStr + "') " + | |
| 46 | + " UNION" + | |
| 47 | + " select DISTINCT line_code from bsth_c_stationroute where station_code in ( select station_cod from bsth_c_station where update_date>='" + timeStr + "') " + | |
| 48 | + " UNION" + | |
| 49 | + " select DISTINCT line_code from bsth_c_stationroute where update_date>='" + timeStr + "' " + | |
| 50 | + " UNION" + | |
| 51 | + " select DISTINCT line_code from bsth_c_sectionroute where update_date>='" + timeStr + "'"; | |
| 53 | 52 | |
| 54 | 53 | |
| 55 | 54 | List<String> codes = jdbcTemplate.queryForList(sql, String.class); |
| ... | ... | @@ -57,6 +56,8 @@ public class DataLoadThread extends Thread { |
| 57 | 56 | if (codes.size() > 0) |
| 58 | 57 | cacheLoader.load(codes); |
| 59 | 58 | } |
| 59 | + | |
| 60 | + t = System.currentTimeMillis(); | |
| 60 | 61 | } catch (Exception e) { |
| 61 | 62 | logger.error("", e); |
| 62 | 63 | } | ... | ... |
src/main/java/com/bsth/data/geo/loader/util/GeoCalculator.java
| ... | ... | @@ -162,10 +162,10 @@ public class GeoCalculator { |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | //路段倒着画 |
| 165 | - double d1 = GeoUtils.getDistance(all.get(0), sections.get(0)); | |
| 165 | + | |
| 166 | + double d4 = GeoUtils.getDistance(all.get(size - 1), sections.get(size2 - 1));double d1 = GeoUtils.getDistance(all.get(0), sections.get(0)); | |
| 166 | 167 | double d2 = GeoUtils.getDistance(all.get(0), sections.get(size2 - 1)); |
| 167 | 168 | double d3 = GeoUtils.getDistance(all.get(size - 1), sections.get(0)); |
| 168 | - double d4 = GeoUtils.getDistance(all.get(size - 1), sections.get(size2 - 1)); | |
| 169 | 169 | |
| 170 | 170 | int dt = 10; |
| 171 | 171 | if (d1 < dt && d1 < d2) | ... | ... |
src/main/java/com/bsth/data/history/HistoryConsumeTimeDataHandler.java
| ... | ... | @@ -131,8 +131,9 @@ public class HistoryConsumeTimeDataHandler { |
| 131 | 131 | Application.mainServices.scheduleAtFixedRate(consumeTimeLoadThread |
| 132 | 132 | , timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); |
| 133 | 133 | |
| 134 | - if (timeDiff > 1000 * 60 * 10) | |
| 135 | - consumeTimeLoadThread.run(); | |
| 134 | + consumeTimeLoadThread.run(); | |
| 135 | + //if (timeDiff > 1000 * 60 * 10) | |
| 136 | + // consumeTimeLoadThread.run(); | |
| 136 | 137 | } |
| 137 | 138 | |
| 138 | 139 | public static LineConsumeTime getLct(String lineCode, int upDown) { |
| ... | ... | @@ -230,7 +231,7 @@ public class HistoryConsumeTimeDataHandler { |
| 230 | 231 | dt.minusDays(7);//减7天 |
| 231 | 232 | String rq = dt.toString("yyyyMMdd "); |
| 232 | 233 | |
| 233 | - rq = "20180625"; | |
| 234 | + rq = "20180626"; | |
| 234 | 235 | String sql = "select * from bsth_h_consume_time where rq=" + rq; |
| 235 | 236 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_InfoPublish.getDataSource()); |
| 236 | 237 | List<StationConsumeTime> list = |
| ... | ... | @@ -276,7 +277,7 @@ public class HistoryConsumeTimeDataHandler { |
| 276 | 277 | |
| 277 | 278 | if (map.size() > 0) |
| 278 | 279 | lctMaps = map; |
| 279 | - logger.info("calc end..."); | |
| 280 | + logger.info("load ConsumeTime end..."); | |
| 280 | 281 | } catch (Exception e) { |
| 281 | 282 | logger.error("", e); |
| 282 | 283 | } |
| ... | ... | @@ -343,12 +344,19 @@ public class HistoryConsumeTimeDataHandler { |
| 343 | 344 | return null; |
| 344 | 345 | List<Integer> ns = new ArrayList<>(list.size()); |
| 345 | 346 | //把进站距离部分 均算成耗时 |
| 346 | - double inD; | |
| 347 | - int normal = 40; | |
| 347 | + double ad; | |
| 348 | + int normal = 20; | |
| 348 | 349 | for (StationConsumeTime sct : list) { |
| 349 | - inD = sct.getInD1() + sct.getInD2(); | |
| 350 | - if (inD > normal) | |
| 351 | - sct.setSeconds((int) (sct.getSeconds() + ((inD - normal) / IN_STATION_SPEED))); | |
| 350 | + | |
| 351 | + //加进距2 | |
| 352 | + if (sct.getInD2() > normal) { | |
| 353 | + sct.setSeconds((int) (sct.getSeconds() + ((sct.getInD2() - normal) / IN_STATION_SPEED))); | |
| 354 | + } | |
| 355 | + | |
| 356 | + //减进距1 | |
| 357 | + if (sct.getInD1() > normal) { | |
| 358 | + sct.setSeconds((int) (sct.getSeconds() - ((sct.getInD1() - normal) / IN_STATION_SPEED))); | |
| 359 | + } | |
| 352 | 360 | |
| 353 | 361 | ns.add(sct.getSeconds()); |
| 354 | 362 | } | ... | ... |