Commit f3a485b31b2d2939cc61a1820c406a9c60df5e4d

Authored by 潘钊
1 parent f7c126c5

update...

src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
... ... @@ -47,7 +47,7 @@ public class GeoDataServiceImpl implements GeoDataService {
47 47 Map<String, Object> map = new HashMap();
48 48 try {
49 49  
50   - String sql = "select DISTINCT versions from bsth_c_stationroute where line=" + lineCode + " and destroy=0";
  50 + String sql = "select versions from bsth_c_line_versions where line='"+lineCode+"' and status=1";
51 51 //当前使用的线路版本
52 52 Integer currentVersion = jdbcTemplate.queryForObject(sql, Integer.class);
53 53  
... ... @@ -67,6 +67,7 @@ public class GeoDataServiceImpl implements GeoDataService {
67 67 map.put("status", ResponseCode.SUCCESS);
68 68 map.put("list", list);
69 69 map.put("currentVersion", currentVersion);
  70 + map.put("editVersion", version);
70 71 } catch (Exception e) {
71 72 logger.error("", e);
72 73 map.put("status", ResponseCode.ERROR);
... ... @@ -80,7 +81,7 @@ public class GeoDataServiceImpl implements GeoDataService {
80 81 Map<String, Object> map = new HashMap();
81 82 try {
82 83  
83   - String sql = "select DISTINCT versions from bsth_c_stationroute where line=" + lineCode + " and destroy=0";
  84 + String sql = "select versions from bsth_c_line_versions where line='"+lineCode+"' and status=1";
84 85 //当前使用的线路版本
85 86 Integer currentVersion = jdbcTemplate.queryForObject(sql, Integer.class);
86 87  
... ... @@ -419,6 +420,13 @@ public class GeoDataServiceImpl implements GeoDataService {
419 420 def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
420 421 TransactionStatus status = tran.getTransaction(def);
421 422 try{
  423 + int versionCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code='"+lineCode+"'", Integer.class);
  424 + if(versionCount == 1){
  425 + rs.put("status", ResponseCode.ERROR);
  426 + rs.put("msg", "线路至少要保留一个走向版本!");
  427 + return rs;
  428 + }
  429 +
422 430 /* //要删除的站点ID(未被其他线路、版本引用的)
423 431 String sql = "select DISTINCT station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version+" and station not in(" +
424 432 "select station from bsth_c_ls_stationroute where (line!='"+lineCode+"' or versions!="+version+") and station in (" +
... ... @@ -644,8 +652,10 @@ public class GeoDataServiceImpl implements GeoDataService {
644 652 for (int i = 0, size = routes.size(); i < size; i++) {
645 653 routes.get(i).setStationMark("Z");
646 654 }
647   - routes.get(0).setStationMark("B");
648   - routes.get(routes.size() - 1).setStationMark("E");
  655 + if(routes.size() > 1){
  656 + routes.get(0).setStationMark("B");
  657 + routes.get(routes.size() - 1).setStationMark("E");
  658 + }
649 659  
650 660 final List<SaveStationRouteDTO> saveList = routes;
651 661 //insert 新路由 (ID自增)
... ...
src/main/resources/static/pages/base/geo_data_edit/css/mian.css
... ... @@ -627,4 +627,33 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root {
627 627  
628 628 .rt_show_version_txt{
629 629 display: none;
  630 +}
  631 +
  632 +.add_station_icon{
  633 + width: 140px;
  634 + border: 1px dashed #e2e2e2 !important;
  635 + text-align: center;
  636 + padding: 5px 0;
  637 + margin-left: 57px;
  638 + cursor: pointer;
  639 +}
  640 +
  641 +.add_station_icon:hover{
  642 + border: 1px solid #e2e2e2;
  643 +}
  644 +
  645 +.add_station_icon>span.uk-icon{
  646 + vertical-align: top;
  647 + margin-top: 3px;
  648 +}
  649 +
  650 +.add_station_icon>a{
  651 + color: grey !important;
  652 + display: inline-block !important;
  653 + width: auto !important;
  654 + padding-left: 0 !important;
  655 +}
  656 +
  657 +.road_route>ul.empty{
  658 + border-left: none;
630 659 }
631 660 \ No newline at end of file
... ...
src/main/resources/static/pages/base/geo_data_edit/fragments/f_road_route.html
1 1 <div>
2 2 <script id="geo_d_e_road_route-temp" type="text/html">
3   - <ul class="uk-list">
  3 + <ul class="uk-list {{if list.length==0}}empty{{/if}}">
4 4 {{each list as subArr i}}
5 5 <li class="r_r_item f_r_a" data-id="{{subArr[0].id}}" data-code="{{subArr[0].sectionCode}}">
6 6 <a data-code="{{subArr[0].sectionCode}}" data-updown="{{subArr[0].directions}}">{{subArr[0].sectionName}}<span class="sub_name">{{subArr[0].crosesRoad}}</span></a>
... ... @@ -17,6 +17,15 @@
17 17 {{/if}}
18 18 </li>
19 19 {{/each}}
  20 +
  21 + {{if list.length==0}}
  22 + <li class="r_r_item">
  23 + <div class="add_station_icon">
  24 + <span uk-icon="icon: plus;ratio:.8"></span>
  25 + <a data-updown="{{updown}}">添加路段</a>
  26 + </div>
  27 + </li>
  28 + {{/if}}
20 29 </ul>
21 30 </script>
22 31  
... ...
src/main/resources/static/pages/base/geo_data_edit/fragments/f_station_route.html
... ... @@ -10,6 +10,15 @@
10 10 <a data-code="{{s.stationCode}}" data-updown="{{s.directions}}">{{s.stationName}}</a>
11 11 </li>
12 12 {{/each}}
  13 +
  14 + {{if list.length==0}}
  15 + <li class="s_r_item">
  16 + <div class="add_station_icon">
  17 + <span uk-icon="icon: plus;ratio:.8"></span>
  18 + <a data-updown="{{updown}}">添加站点</a>
  19 + </div>
  20 + </li>
  21 + {{/if}}
13 22 </ul>
14 23 </script>
15 24  
... ...
src/main/resources/static/pages/base/geo_data_edit/js/map.js
... ... @@ -44,7 +44,7 @@ var gb_ct_map = function () {
44 44 stCtrl.setOffset(new BMap.Size(20, 20));
45 45 map.addControl(stCtrl);//添加全景控件
46 46  
47   - var roadPolylines = [], stationMarkers = [];
  47 + var roadPolylines = {0:[],1:[]}, stationMarkers = {0:[],1:[]};
48 48 var _render = function (cb) {
49 49 //绘制路段
50 50 _renderRoads(gb_road_route.getData());
... ... @@ -55,8 +55,10 @@ var gb_ct_map = function () {
55 55  
56 56 //居中至上行中间站点
57 57 if(!initFlag){
58   - var cm = stationMarkers[0][parseInt(stationMarkers[0].length / 2)];
59   - map.setCenter(cm.point);
  58 + if(stationMarkers[0].length>0){
  59 + var cm = stationMarkers[0][parseInt(stationMarkers[0].length / 2)];
  60 + map.setCenter(cm.point);
  61 + }
60 62 initFlag=true;
61 63 }
62 64  
... ... @@ -67,11 +69,15 @@ var gb_ct_map = function () {
67 69 return updown == 0 ? 'blue' : 'red';
68 70 };
69 71 var _renderRoads = function (data) {
  72 + if(data[0].length==0)
  73 + return;
70 74 _renderPolyline(data[0], updownColor(0));//上行路段
71 75 _renderPolyline(data[1], updownColor(1));//下行路段
72 76 };
73 77  
74 78 var _renderStation = function (data) {
  79 + if(data[0].length==0)
  80 + return;
75 81 _renderStationMarket(data[0]);//上行站点
76 82 _renderStationMarket(data[1]);//下行站点
77 83 };
... ...
src/main/resources/static/pages/base/geo_data_edit/js/road_route.js
... ... @@ -36,7 +36,10 @@ var gb_road_route = function () {
36 36 this.cp = geolib.getCenter(_pos);
37 37 this.len = geolib.getPathLength(_pos);
38 38 });
39   - ep.emit('data', gb_common.groupBy(rs.list, 'directions'));
  39 + var data = {0:[],1:[]};
  40 + if(rs.list.length > 0)
  41 + data = gb_common.groupBy(rs.list, 'directions');
  42 + ep.emit('data', data);
40 43 });
41 44  
42 45 //加载模板片段
... ...
src/main/resources/static/pages/base/geo_data_edit/js/station_route.js
... ... @@ -10,12 +10,11 @@ var gb_station_route = function () {
10 10 var ep = EventProxy.create("data", "temp", function (data, temp) {
11 11 station_maps = data;
12 12 temps = temp;
13   - //当前编辑的线路版本
14   - storage.setItem("geo_data_edit_line_version" , data[0][0].versions);
  13 +
15 14 //渲染页面
16   - var upHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[0]});
  15 + var upHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[0],updown:0});
17 16 $('.up_down_route_list>li:first>.station_route').html(upHtmlStr);
18   - var downHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[1]});
  17 + var downHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[1],updown:1});
19 18 $('.up_down_route_list>li:last>.station_route').html(downHtmlStr);
20 19  
21 20 cb && cb();
... ... @@ -30,7 +29,13 @@ var gb_station_route = function () {
30 29  
31 30 //线路当前启用的线路版本
32 31 storage.setItem("geo_data_enable_version" , rs['currentVersion']);
33   - ep.emit('data', gb_common.groupBy(rs.list, 'directions'));
  32 + //当前编辑的线路版本
  33 + storage.setItem("geo_data_edit_line_version" , rs['editVersion']);
  34 +
  35 + var data = {0:[],1:[]};
  36 + if(rs.list.length > 0)
  37 + data = gb_common.groupBy(rs.list, 'directions');
  38 + ep.emit('data', data);
34 39 });
35 40  
36 41 //加载模板片段
... ... @@ -170,13 +175,14 @@ var gb_station_route = function () {
170 175 prev = $(that).prev();
171 176  
172 177 if(prev.length == 0)
173   - return null;
  178 + return [];
174 179  
175 180 if(prev.hasClass(clazz))
176 181 return prev;
177 182  
178 183 that = prev;
179 184 }
  185 + return [];
180 186 };
181 187  
182 188 /**
... ... @@ -246,6 +252,19 @@ var gb_station_route = function () {
246 252 }
247 253 });
248 254  
  255 + /**
  256 + * 新线路 添加第一个站点
  257 + */
  258 + $(document).on('click', '.add_station_icon', function () {
  259 + //在之后插入站点
  260 + var cell = $(this);
  261 +
  262 + var addCell = $(temps['geo_d_e_add_station_panel-temp']());
  263 + cell.after(addCell);
  264 +
  265 + add_station(addCell);
  266 + });
  267 +
249 268 var showEditPanel = function (s) {
250 269 var htmlStr = temps['geo_d_e_map_edit_buffer_panel-temp'](s);
251 270 $('.ct_page').append(htmlStr);
... ...