Commit bb7d840df59c2d4be3edb9332babb2797d5fe20b
Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang
Showing
9 changed files
with
150 additions
and
14 deletions
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
| ... | ... | @@ -59,4 +59,14 @@ public class RealMapController { |
| 59 | 59 | public Map<String, Object> findRouteAndStationByLine(@RequestParam String lineCode){ |
| 60 | 60 | return realMapService.findRouteAndStationByLine(lineCode); |
| 61 | 61 | } |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 获取多个线路的路段信息(为前端越界计算提供数据) | |
| 65 | + * @param codeIdx | |
| 66 | + * @return | |
| 67 | + */ | |
| 68 | + @RequestMapping(value = "/multiSectionRoute") | |
| 69 | + public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx){ | |
| 70 | + return realMapService.multiSectionRoute(codeIdx); | |
| 71 | + } | |
| 62 | 72 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/RealMapService.java
src/main/java/com/bsth/service/realcontrol/impl/RealMapServiceImpl.java
| ... | ... | @@ -122,7 +122,7 @@ public class RealMapServiceImpl implements RealMapService { |
| 122 | 122 | rs.put("section", secList); |
| 123 | 123 | |
| 124 | 124 | //查询站点信息 |
| 125 | - sql="select r.STATION_NAME,r.STATION_ROUTE_CODE,r.LINE_CODE,r.STATION_CODE,r.STATION_MARK,s.G_LONX,s.G_LATY, r.DIRECTIONS from bsth_c_stationroute r INNER JOIN bsth_c_station s on r.station=s.id and r.line_code=? and r.destroy=0"; | |
| 125 | + sql = "select r.STATION_NAME,r.STATION_ROUTE_CODE,r.LINE_CODE,r.STATION_CODE,r.STATION_MARK,s.G_LONX,s.G_LATY, r.DIRECTIONS from bsth_c_stationroute r INNER JOIN bsth_c_station s on r.station=s.id and r.line_code=? and r.destroy=0"; | |
| 126 | 126 | List<Map<String, Object>> stationList = jdbcTemplate.queryForList(sql, lineCode); |
| 127 | 127 | rs.put("station", stationList); |
| 128 | 128 | |
| ... | ... | @@ -134,6 +134,31 @@ public class RealMapServiceImpl implements RealMapService { |
| 134 | 134 | return rs; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | + @Override | |
| 138 | + public Map<String, Object> multiSectionRoute(String codeIdx) { | |
| 139 | + Map<String, Object> rs = new HashMap<>(); | |
| 140 | + try { | |
| 141 | + List<String> idArray = Splitter.on(",").splitToList(codeIdx); | |
| 142 | + //拼接in语句 | |
| 143 | + String inStr = ""; | |
| 144 | + for (String code : idArray) { | |
| 145 | + inStr += (",'" + code + "'"); | |
| 146 | + } | |
| 147 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 148 | + | |
| 149 | + String sql = "SELECT r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText (s.GSECTION_VECTOR) AS GSECTION_VECTOR,r.DIRECTIONS FROM bsth_c_sectionroute r INNER JOIN bsth_c_section s ON r.section = s.id WHERE r.line_code in " + inStr + " AND r.destroy = 0 order by r.line_code, r.directions,r.sectionroute_code"; | |
| 150 | + | |
| 151 | + List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql); | |
| 152 | + rs.put("section", secList); | |
| 153 | + rs.put("status", ResponseCode.SUCCESS); | |
| 154 | + } catch (DataAccessException e) { | |
| 155 | + logger.error("", e); | |
| 156 | + rs.put("status", ResponseCode.ERROR); | |
| 157 | + } | |
| 158 | + | |
| 159 | + return rs; | |
| 160 | + } | |
| 161 | + | |
| 137 | 162 | /** |
| 138 | 163 | * wgs 坐标数组转 百度 |
| 139 | 164 | * | ... | ... |
src/main/resources/static/real_control_v2/js/data/gps_abnormal.js
0 → 100644
| 1 | +/** gps 信号异常状态,无效 | 越界 | 超速 */ | |
| 2 | + | |
| 3 | +var gb_gps_abnormal = (function () { | |
| 4 | + | |
| 5 | + //按线路分组的路段数据 | |
| 6 | + var allRoads; | |
| 7 | + | |
| 8 | + //gps无效 | |
| 9 | + var gpsInvalid = function (gps) { | |
| 10 | + return gps.lat == 0 || gps.lon == 0; | |
| 11 | + }; | |
| 12 | + | |
| 13 | + //越界 | |
| 14 | + var gpsOutOfBounds = function (gps) { | |
| 15 | + var roads = allRoads[gps.lineId + '_' + gps.upDown]; | |
| 16 | + if (!roads) | |
| 17 | + return; | |
| 18 | + | |
| 19 | + //最短距离 | |
| 20 | + var min, distance; | |
| 21 | + $.each(roads, function () { | |
| 22 | + distance = minDistanceFromRoad(this.pos, gps); | |
| 23 | + if(!min || min > distance) | |
| 24 | + min = distance; | |
| 25 | + }); | |
| 26 | + | |
| 27 | + //console.log('最短距离', min, gps); | |
| 28 | + }; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 初始化数据 | |
| 32 | + */ | |
| 33 | + var initData = function () { | |
| 34 | + //获取线路路段数据 | |
| 35 | + gb_common.$get('/realMap/multiSectionRoute', {codeIdx: gb_data_basic.line_idx}, function (rs) { | |
| 36 | + var list = []; | |
| 37 | + $.each(rs.section, function () { | |
| 38 | + list.push({ | |
| 39 | + line: this['LINE_CODE'], | |
| 40 | + updown: this['DIRECTIONS'], | |
| 41 | + pos: parseCoords(this['GSECTION_VECTOR']), | |
| 42 | + route_code: this['SECTIONROUTE_CODE'], | |
| 43 | + code: this['SECTION_CODE'], | |
| 44 | + name: this['SECTION_NAME'] | |
| 45 | + }); | |
| 46 | + }); | |
| 47 | + //按线路_走向 分组数据 | |
| 48 | + allRoads = groupByLineAndUpdown(list); | |
| 49 | + console.log('路段数据', allRoads); | |
| 50 | + }); | |
| 51 | + }; | |
| 52 | + | |
| 53 | + function minDistanceFromRoad(pos, gps){ | |
| 54 | + var distance, min; | |
| 55 | + var len = pos.length - 1; | |
| 56 | + for(var i = 0; i < len; i ++){ | |
| 57 | + distance = geolib.getDistanceFromLine({ | |
| 58 | + latitude: gps.lat, | |
| 59 | + longitude: gps.lon | |
| 60 | + }, pos[i], pos[i + 1]); | |
| 61 | + | |
| 62 | + if(!min || min > distance) | |
| 63 | + min = distance; | |
| 64 | + } | |
| 65 | + | |
| 66 | + return min; | |
| 67 | + } | |
| 68 | + | |
| 69 | + function groupByLineAndUpdown(list) { | |
| 70 | + var rs = {}, | |
| 71 | + key; | |
| 72 | + $.each(list, function () { | |
| 73 | + key = this.line + '_' + this.updown; | |
| 74 | + if (!rs[key]) | |
| 75 | + rs[key] = []; | |
| 76 | + | |
| 77 | + rs[key].push(this); | |
| 78 | + }); | |
| 79 | + | |
| 80 | + return rs; | |
| 81 | + } | |
| 82 | + | |
| 83 | + function parseCoords(str) { | |
| 84 | + var array = str.substr(11, str.length - 2).split(','), rs = [], temps; | |
| 85 | + $.each(array, function (i, coords) { | |
| 86 | + temps = coords.split(' '); | |
| 87 | + rs.push({ | |
| 88 | + latitude: parseFloat(temps[1]), | |
| 89 | + longitude: parseFloat(temps[0]) | |
| 90 | + }); | |
| 91 | + }); | |
| 92 | + | |
| 93 | + return rs; | |
| 94 | + } | |
| 95 | + | |
| 96 | + return { | |
| 97 | + initData: initData, | |
| 98 | + check: function (gps) { | |
| 99 | + if(!allRoads){ | |
| 100 | + return; | |
| 101 | + } | |
| 102 | + | |
| 103 | + gpsOutOfBounds(gps); | |
| 104 | + } | |
| 105 | + } | |
| 106 | +})(); | |
| 0 | 107 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/js/data/gps_signal_state.js deleted
100644 → 0
src/main/resources/static/real_control_v2/js/main.js
| ... | ... | @@ -42,10 +42,13 @@ var gb_main_ep = new EventProxy(), |
| 42 | 42 | gb_signal_state.init(); |
| 43 | 43 | }); |
| 44 | 44 | |
| 45 | + //初始化gps异常判定 | |
| 46 | + //gb_gps_abnormal.initData(); | |
| 47 | + | |
| 45 | 48 | //嵌入地图页面 |
| 46 | 49 | $('li.map-panel', '#main-tab-content').load('/real_control_v2/mapmonitor/real.html'); |
| 47 | 50 | //弹出更新说明 |
| 48 | - showUpdateDescription(); | |
| 51 | + //showUpdateDescription(); | |
| 49 | 52 | }); |
| 50 | 53 | |
| 51 | 54 | function g_emit(id) { | ... | ... |
src/main/resources/static/real_control_v2/js/signal_state/signal_state.js
src/main/resources/static/real_control_v2/js/utils/dispatch_pattern.js
src/main/resources/static/real_control_v2/main.html
| ... | ... | @@ -107,6 +107,7 @@ |
| 107 | 107 | <!-- 数据 --> |
| 108 | 108 | <script src="/real_control_v2/js/data/data_basic.js"></script> |
| 109 | 109 | <script src="/real_control_v2/js/data/data_gps.js"></script> |
| 110 | + <script src="/real_control_v2/js/data/gps_abnormal.js"></script> | |
| 110 | 111 | <!-- 线路模拟图 --> |
| 111 | 112 | <script src="/real_control_v2/js/utils/svg_chart.js"></script> |
| 112 | 113 | <script src="/real_control_v2/js/utils/svg_data_convert.js"></script> | ... | ... |