Commit b611c3d147b822f3abd1eb5663e27a6c9830e318
1 parent
6df5f7ab
1.
Showing
6 changed files
with
21 additions
and
18 deletions
src/main/java/com/bsth/service/impl/LsStationRouteServiceImpl.java
| ... | ... | @@ -130,10 +130,10 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl<LsStationRoute, I |
| 130 | 130 | if (line == null) { |
| 131 | 131 | throw new RuntimeException(String.format("未找到ID为%d的线路信息", lineId)); |
| 132 | 132 | } |
| 133 | - stationRoutesHandle(line, versions, directions, stationRoutes); | |
| 133 | + List<Station> stations = stationRoutesHandle(line, versions, directions, stationRoutes); | |
| 134 | 134 | List<Section> sections = sectionRoutesHandle(line, versions, directions, sectionRoutes); |
| 135 | 135 | |
| 136 | - //stationRepository.saveAll(stations); | |
| 136 | + stationRepository.saveAll(stations); | |
| 137 | 137 | sectionRepository.saveAll(sections); |
| 138 | 138 | lsStationRouteRepository.saveAll(stationRoutes); |
| 139 | 139 | lsSectionRouteRepository.saveAll(sectionRoutes); |
| ... | ... | @@ -144,8 +144,9 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl<LsStationRoute, I |
| 144 | 144 | return result; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - private void stationRoutesHandle(Line line, Integer versions, Integer directions, List<LsStationRoute> stationRoutes) { | |
| 148 | - int count = 0; | |
| 147 | + private List<Station> stationRoutesHandle(Line line, Integer versions, Integer directions, List<LsStationRoute> stationRoutes) { | |
| 148 | + List<Station> stations = new ArrayList<>(); | |
| 149 | + int currentId = stationRepository.findLatestStationId(), count = 0; | |
| 149 | 150 | for (int len = stationRoutes.size();count < len;) { |
| 150 | 151 | LsStationRoute stationRoute = stationRoutes.get(count); |
| 151 | 152 | stationRoute.setStationMark(count == 0 ? "B" : count == len - 1 ? "E" : "Z"); |
| ... | ... | @@ -156,7 +157,18 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl<LsStationRoute, I |
| 156 | 157 | stationRoute.setLineCode(line.getLineCode()); |
| 157 | 158 | stationRoute.setStationRouteCode(100 * count); |
| 158 | 159 | stationRoute.setStationCode(stationRoute.getStation().getStationCode()); |
| 160 | + | |
| 161 | + Station station = stationRoute.getStation(); | |
| 162 | + if (station.getId() == null) { | |
| 163 | + station.setId(currentId + count); | |
| 164 | + station.setStationCode(station.getId().toString()); | |
| 165 | + stationRoute.setStationCode(station.getStationCode()); | |
| 166 | + centerPoint(station); | |
| 167 | + stations.add(station); | |
| 168 | + } | |
| 159 | 169 | } |
| 170 | + | |
| 171 | + return stations; | |
| 160 | 172 | } |
| 161 | 173 | |
| 162 | 174 | private List<Section> sectionRoutesHandle(Line line, Integer versions, Integer directions, List<LsSectionRoute> sectionRoutes) { | ... | ... |
src/main/java/com/bsth/service/impl/StationServiceImpl.java
| ... | ... | @@ -106,23 +106,18 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 106 | 106 | for (Station s : stations) { |
| 107 | 107 | Location location = CoordinateConverter.LocationMake(s.getCenterPointWkt()); |
| 108 | 108 | Point point = new Point(location.getLng(), location.getLat()); |
| 109 | - double minDistance = Double.MAX_VALUE, matchDistance = 60; | |
| 110 | - Station target = null; | |
| 109 | + double matchDistance = 60; | |
| 111 | 110 | for (Station s1 : stations1) { |
| 112 | 111 | Location location1 = CoordinateConverter.LocationMake(s1.getCenterPoint().toString()); |
| 113 | 112 | Point point1 = new Point(location1.getLng(), location1.getLat()); |
| 114 | 113 | double distance = GeoUtils.getDistance(point, point1); |
| 115 | 114 | if (distance <= matchDistance) { |
| 116 | - target = s1; | |
| 115 | + s.setId(s1.getId()); | |
| 116 | + s.setStationCode(s1.getStationCode()); | |
| 117 | + s.setStationName(s1.getStationName()); | |
| 117 | 118 | break; |
| 118 | 119 | } |
| 119 | - if (distance < minDistance) { | |
| 120 | - target = s1; | |
| 121 | - } | |
| 122 | 120 | } |
| 123 | - s.setId(target.getId()); | |
| 124 | - s.setStationCode(target.getStationCode()); | |
| 125 | - s.setStationName(target.getStationName()); | |
| 126 | 121 | } |
| 127 | 122 | } |
| 128 | 123 | ... | ... |
src/main/resources/static/pages/base/stationroute/add_routes_template.html
| ... | ... | @@ -226,7 +226,7 @@ $('#add_routes_template_modal').on('modal.show', function(e,_WorldsBMap,_GetAjax |
| 226 | 226 | let sectionListTemp = arrayFormat.sectionList; |
| 227 | 227 | let sectionList = []; |
| 228 | 228 | // 隔30个取一个点(相当于30s) |
| 229 | - let typeNum = type == 0 ? 30:1; | |
| 229 | + let typeNum = 1; | |
| 230 | 230 | for(let i = 0; i * typeNum < sectionListTemp.length; i++) { |
| 231 | 231 | sectionList[i] = sectionListTemp[i * typeNum]; |
| 232 | 232 | } | ... | ... |
src/main/resources/static/pages/base/stationroute/destroy_stationroute.html
| ... | ... | @@ -215,7 +215,6 @@ $('#delete_station_mobal').on('deleteStationMobal.show',function(e, ajaxd, line, |
| 215 | 215 | var i = layer.load(2); |
| 216 | 216 | // 异步请求获取表格数据 |
| 217 | 217 | $.get('/api/lsstationroute/findPageByParams', params, function(result) { |
| 218 | - debugger | |
| 219 | 218 | // 添加序号 |
| 220 | 219 | if (!result.content) { |
| 221 | 220 | result.content = new Array(); | ... | ... |
src/main/resources/static/pages/base/stationroute/js/stationroute-list-events.js
| ... | ... | @@ -148,7 +148,6 @@ $(function(){ |
| 148 | 148 | var Line = LineObj.getLineObj(); |
| 149 | 149 | console.log($($("#versions").find("option:selected")[0]).attr("status")); |
| 150 | 150 | var params = {lineId: Line.id, version: $('#versions').val(), direction: 1, otherDirection: 0}; |
| 151 | - debugger | |
| 152 | 151 | quote(params,index); |
| 153 | 152 | }); |
| 154 | 153 | ... | ... |
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
| ... | ... | @@ -643,9 +643,7 @@ window.WorldsBMap = function () { |
| 643 | 643 | localtionRoad: function (sectionName, callback) { |
| 644 | 644 | // 关闭信息窗口 |
| 645 | 645 | mapBValue.closeInfoWindow(); |
| 646 | - debugger | |
| 647 | 646 | GetAjaxData.findSectionByName(sectionName, function (sections) { |
| 648 | - debugger | |
| 649 | 647 | var marker; |
| 650 | 648 | if (sections.length > 0) { |
| 651 | 649 | var points = new Array(); | ... | ... |