Commit 8dc696a2d2de932294d4480b9bfda46802f0e0de

Authored by YRF
1 parent 791171c6

站点新增不引用

src/main/java/com/bsth/controller/LineVersionsController.java
1 1 package com.bsth.controller;
2 2  
3   -import java.text.ParseException;
4   -import java.text.SimpleDateFormat;
5   -import java.util.Date;
6 3 import java.util.List;
7 4 import java.util.Map;
8 5  
... ... @@ -12,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
12 9 import org.springframework.web.bind.annotation.RequestParam;
13 10 import org.springframework.web.bind.annotation.RestController;
14 11  
15   -import com.bsth.entity.Line;
16 12 import com.bsth.entity.LineVersions;
17 13 import com.bsth.repository.LineRepository;
18 14 import com.bsth.service.LineVersionsService;
... ... @@ -80,4 +76,13 @@ public class LineVersionsController extends BaseController<LineVersions, Integer
80 76 return service.add(map);
81 77 }
82 78  
  79 + /**
  80 + * 根据线路id获取当前版本号
  81 + *
  82 + */
  83 + @RequestMapping(value = "findCurrentVersion", method = RequestMethod.GET)
  84 + public Integer findCurrentVersion(@RequestParam(defaultValue = "lineId") int lineId) {
  85 + return service.findCurrentVersion(lineId);
  86 + }
  87 +
83 88 }
... ...
src/main/java/com/bsth/repository/LineVersionsRepository.java
... ... @@ -73,4 +73,10 @@ public interface LineVersionsRepository extends BaseRepository<LineVersions, Int
73 73 @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")")
74 74 public LineVersions findBylineIdAndVersions(Integer id, Integer versions);
75 75  
  76 +
  77 + /**
  78 + * 获取线路版本的上一个版本
  79 + */
  80 + @Query(value = " SELECT lv.versions FROM LineVersions lv where lv.line.id = ?1 and lv.status=1")
  81 + public Integer findCurrentVersion(Integer id);
76 82 }
... ...
src/main/java/com/bsth/service/LineVersionsService.java
... ... @@ -33,6 +33,9 @@ public interface LineVersionsService extends BaseService<LineVersions, Integer>
33 33 List<LineVersions> lineUpdate();
34 34  
35 35 LineVersions findLineVersionsMax(int lineId);
  36 +
  37 + // 返回当前线路版本
  38 + Integer findCurrentVersion(int lineId);
36 39  
37 40 Map<String, Object> add(Map<String, Object> map);
38 41  
... ...
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
... ... @@ -250,5 +250,13 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
250 250 }
251 251 return resultMap;
252 252 }
  253 +
  254 + /**
  255 + * 获取当前线路版本号
  256 + */
  257 + @Override
  258 + public Integer findCurrentVersion(int lineId) {
  259 + return repository.findCurrentVersion(lineId);
  260 + }
253 261  
254 262 }
... ...
src/main/java/com/bsth/service/impl/StationServiceImpl.java
... ... @@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
18 18 import com.bsth.common.ResponseCode;
19 19 import com.bsth.entity.Line;
20 20 import com.bsth.entity.LineInformation;
  21 +import com.bsth.entity.LineVersions;
21 22 import com.bsth.entity.Section;
22 23 import com.bsth.entity.SectionRoute;
23 24 import com.bsth.entity.SectionRouteCache;
... ... @@ -26,12 +27,14 @@ import com.bsth.entity.StationRoute;
26 27 import com.bsth.entity.StationRouteCache;
27 28 import com.bsth.repository.LineInformationRepository;
28 29 import com.bsth.repository.LineRepository;
  30 +import com.bsth.repository.LineVersionsRepository;
29 31 import com.bsth.repository.SectionRepository;
30 32 import com.bsth.repository.SectionRouteCacheRepository;
31 33 import com.bsth.repository.SectionRouteRepository;
32 34 import com.bsth.repository.StationRepository;
33 35 import com.bsth.repository.StationRouteCacheRepository;
34 36 import com.bsth.repository.StationRouteRepository;
  37 +import com.bsth.service.LineVersionsService;
35 38 import com.bsth.service.StationService;
36 39 import com.bsth.util.GetUIDAndCode;
37 40 import com.bsth.util.TransGPS;
... ... @@ -83,6 +86,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
83 86 @Autowired
84 87 private SectionRouteCacheRepository sectionRouteCacheRepository;
85 88  
  89 + @Autowired
  90 + LineVersionsRepository lineVersionsRepository;
  91 +
86 92 private GeoUtils geoUtils;
87 93  
88 94 Logger logger = LoggerFactory.getLogger(this.getClass());
... ... @@ -293,20 +299,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
293 299 Integer stationId = Integer.parseInt(isHaveMap.get("id").toString());
294 300 arg0 = repository.findOne(stationId);
295 301  
296   - if ((i==0 || i==stationsArray.size()-1) && resultLine.getLinePlayType() != 1) {// (起终点站)
297   - List<Station> list = new ArrayList<>();
298   - list.add(arg0);
299   - List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
300   - Station station = stationlist.get(0);
301   - // 站点编码
302   - long stationCode = GetUIDAndCode.getStationId();
303   - station.setStationCod(String.valueOf(stationCode));
304   - station.setId((int)stationCode);
305   - station.setCreateDate(null);
306   - station.setUpdateDate(null);
307   - repository.save(station);
308   - arg0 = station;
309   - } else if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  302 + if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  303 + arg0 = loopStartStation;
  304 + } else {
310 305 List<Station> list = new ArrayList<>();
311 306 list.add(arg0);
312 307 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
... ... @@ -318,12 +313,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
318 313 station.setCreateDate(null);
319 314 station.setUpdateDate(null);
320 315 repository.save(station);
321   - arg0 = station;
322   - loopStartStation = arg0;
323   - repository.save(arg0);
324   - } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
325   - arg0 = loopStartStation;
326   - }
  316 + arg0 = station;
  317 + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  318 + loopStartStation = arg0;
  319 + }
  320 + }
327 321 }else {
328 322 // 站点编码
329 323 long stationCode = GetUIDAndCode.getStationId();
... ... @@ -417,8 +411,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
417 411 // 中途站
418 412 route.setStationMark("Z");
419 413 }
420   - // 版本号
421   - route.setVersions(versions);
  414 + // 版本号(获取线路当前版本)
  415 + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
  416 + route.setVersions(version);
422 417 // 站点ID
423 418 route.setStation(arg0);
424 419 // 方向
... ... @@ -782,68 +777,65 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
782 777 Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
783 778 // 说明
784 779 String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
785   - if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) {
786   - stationId = Integer.parseInt(isHaveMap.get("id").toString());
787   - }else {
788   - // 站点编码
789   - stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
790   - // 站点ID
791   - stationId = Integer.valueOf(stationCod);
792   - // 圆半径
793   - Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
794   - // 图形类型
795   - String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
796   - // 创建人
797   - Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
798   - // 修改人
799   - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
800   - // 城建坐标经度
801   - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
802   - // 城建坐标纬度
803   - Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
804   - // 道路编码
805   - String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
806   - // 原坐标类型
807   - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
808   - // WGS经纬度
809   - Float gLonx = null;
810   - // WGS纬度
811   - Float gLaty = null;
812   - if(bJwpointsArray.length>0) {
813   - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
814   - gLonx = (float)resultPoint.getLng();
815   - gLaty = (float)resultPoint.getLat();
816   - }
817   - // 多边形原坐标点集合
818   - String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
819   - // 多边形WGS坐标点集合
820   - String gPloygonGrid ="";
821   - if(!bPloygonGrid.equals("")) {
822   - String bPloygonGridArray[] = bPloygonGrid.split(",");
823   - int bLen_ = bPloygonGridArray.length;
824   - for(int b = 0 ;b<bLen_;b++) {
825   - String tempArray[]= bPloygonGridArray[b].split(" ");
826   - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
827   - if(b==0) {
828   - gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
829   - }else {
830   - gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
831   - }
832   - }
  780 + // 站点编码
  781 + stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
  782 + // 站点ID
  783 + stationId = Integer.valueOf(stationCod);
  784 + // 圆半径
  785 + Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
  786 + // 图形类型
  787 + String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
  788 + // 创建人
  789 + Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
  790 + // 修改人
  791 + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
  792 + // 城建坐标经度
  793 + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
  794 + // 城建坐标纬度
  795 + Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
  796 + // 道路编码
  797 + String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
  798 + // 原坐标类型
  799 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  800 + // WGS经纬度
  801 + Float gLonx = null;
  802 + // WGS纬度
  803 + Float gLaty = null;
  804 + if(bJwpointsArray.length>0) {
  805 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
  806 + gLonx = (float)resultPoint.getLng();
  807 + gLaty = (float)resultPoint.getLat();
  808 + }
  809 + // 多边形原坐标点集合
  810 + String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
  811 + // 多边形WGS坐标点集合
  812 + String gPloygonGrid ="";
  813 + if(!bPloygonGrid.equals("")) {
  814 + String bPloygonGridArray[] = bPloygonGrid.split(",");
  815 + int bLen_ = bPloygonGridArray.length;
  816 + for(int b = 0 ;b<bLen_;b++) {
  817 + String tempArray[]= bPloygonGridArray[b].split(" ");
  818 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
  819 + if(b==0) {
  820 + gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
  821 + }else {
  822 + gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
  823 + }
833 824 }
834   - if(bPloygonGrid.equals(""))
835   - bPloygonGrid = null;
836   - else
837   - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
838   - if(gPloygonGrid.equals(""))
839   - gPloygonGrid = null;
840   - else
841   - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
842   - // 保存站点
843   - repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints,
844   - gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius,
845   - shapesType, versions, descriptions, createBy, updateBy,stationId);
846 825 }
  826 + if(bPloygonGrid.equals(""))
  827 + bPloygonGrid = null;
  828 + else
  829 + bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
  830 + if(gPloygonGrid.equals(""))
  831 + gPloygonGrid = null;
  832 + else
  833 + gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
  834 + // 保存站点
  835 + repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints,
  836 + gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius,
  837 + shapesType, versions, descriptions, createBy, updateBy,stationId);
  838 +
847 839 Station station = repository.findOne(stationId);
848 840 StationRoute arg0 = new StationRoute();
849 841 // 距离
... ... @@ -1200,8 +1192,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1200 1192 sectionRoute.setLine(resultLine);
1201 1193 // 路段编码
1202 1194 sectionRoute.setSectionCode(sectionCode);
1203   - // 版本
1204   - sectionRoute.setVersions(versions);
  1195 + // 版本号(获取线路当前版本)
  1196 + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
  1197 + sectionRoute.setVersions(version);
1205 1198 sectionRoute.setDestroy(destroy);
1206 1199 // 方向
1207 1200 sectionRoute.setDirections(directions);
... ... @@ -1229,8 +1222,8 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1229 1222 String libraryPointstr = s.getbJwpoints();
1230 1223 String points[] = libraryPointstr.toString().split(" ");
1231 1224 Point center = new Point(Double.parseDouble(points[0]), Double.parseDouble(points[1]));
1232   - // 在100m内认为是同一个站点
1233   - Circle circle = new Circle(center, 100);
  1225 + // 在40m内认为是同一个站点
  1226 + Circle circle = new Circle(center, 40);
1234 1227 // 匹配到了用数据库中的点替换
1235 1228 if (geoUtils.isPointInCircle(point, circle)) {
1236 1229 map.put("name", s.getStationName().toString());
... ... @@ -1372,20 +1365,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1372 1365 Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString());
1373 1366 arg0 = repository.findOne(stationId);
1374 1367  
1375   - if ((i==0 || i==stationsArray.size()-1) && resultLine.getLinePlayType() != 1) {// (起终点站)
1376   - List<Station> list = new ArrayList<>();
1377   - list.add(arg0);
1378   - List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
1379   - Station station = stationlist.get(0);
1380   - // 站点编码
1381   - long stationCode = GetUIDAndCode.getStationId();
1382   - station.setStationCod(String.valueOf(stationCode));
1383   - station.setId((int)stationCode);
1384   - station.setCreateDate(null);
1385   - station.setUpdateDate(null);
1386   - repository.save(station);
1387   - arg0 = station;
1388   - } else if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1368 + if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1369 + arg0 = loopStartStation;
  1370 + } else {
1389 1371 List<Station> list = new ArrayList<>();
1390 1372 list.add(arg0);
1391 1373 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
... ... @@ -1397,12 +1379,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1397 1379 station.setCreateDate(null);
1398 1380 station.setUpdateDate(null);
1399 1381 repository.save(station);
1400   - arg0 = station;
1401   - loopStartStation = arg0;
1402   - repository.save(arg0);
1403   - } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1404   - arg0 = loopStartStation;
1405   - }
  1382 + arg0 = station;
  1383 + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1384 + loopStartStation = arg0;
  1385 + }
  1386 + }
1406 1387 }else {
1407 1388 // 站点编码
1408 1389 long stationCode = GetUIDAndCode.getStationId();
... ...
src/main/resources/static/pages/base/line/css/bmap_base.css
... ... @@ -190,12 +190,10 @@ ul li a:hover:not(.active) {
190 190 .radio_label {
191 191 display:block;
192 192 color: white;
193   - float: left;
194 193 cursor: pointer;
195 194 margin-left: 50px;
196 195 font-size: 20px;
197 196 margin-top: 5px;
198   - text-align: center;
199 197 }
200 198 .radioclass {
201 199 margin-top: 6px !important;
... ... @@ -207,7 +205,4 @@ ul li a:hover:not(.active) {
207 205 }
208 206 .on {
209 207 background-position: 0 0;
210   -}
211   -
212   -
213   -
  208 +}
214 209 \ No newline at end of file
... ...
src/main/resources/static/pages/base/line/map.html
... ... @@ -196,12 +196,12 @@ $(function(){
196 196 params.lineId=line.id;
197 197 params.dir = line.dir;
198 198 $.get('/stationroute/findCachePoint',params,function(data){
199   - var station_radio_html = '<div id="station_radio">';
  199 + var station_radio_html = '<div id="station_radio" >';
200 200 var cont = 1;
201 201 var check = 'checked="checked"';
202 202 $.each(data,function(){
203 203 stationRouteMap[this.stationRouteId] = this;
204   - station_radio_html += '<div class="radio"><label class="radio_label on"><input name="stationRadio" type="radio" class="radioclass" value="'+this.stationRouteId+'" '+(cont==1?check:"")+' />'+this.stationRouteStationName+"</label></div>";
  204 + station_radio_html += '<div class="radio" ><label class="radio_label on"><input name="stationRadio" type="radio" class="radioclass" value="'+this.stationRouteId+'" '+(cont==1?check:"")+' />'+this.stationRouteStationName+"</label></div>";
205 205 cont++;
206 206 });
207 207 station_radio_html += '</div>';
... ...
src/main/resources/static/pages/base/section/js/add-form-events.js
... ... @@ -22,12 +22,8 @@ $(function(){
22 22 $('#lineIdInput').val(lineSelectValueArray[0]);// 设值线路编码.
23 23 $('#lineCodeInput').val(lineSelectValueArray[1]);// 设值线路ID.
24 24 // 版本号赋值
25   - $.get('/lineVersions/findByLineId',{'lineId':lineSelectValueArray[0]},function(lineVersions){
26   - $.each(lineVersions,function(){
27   - if (this.status == 1) {
28   - $('#versionsInput').val(this.versions);
29   - }
30   - })
  25 + $.get('/lineVersions/findCurrentVersion',{'lineId':lineSelectValueArray[0]},function(versions){
  26 + $('#versionsInput').val(versions);
31 27 });
32 28 // 获取该线路下的路段路由.
33 29 PublicFunctions.getSectionRouteInfo(lineSelectValueArray[0],function(array) {
... ...
src/main/resources/static/pages/base/station/js/add-form-events.js
... ... @@ -24,12 +24,8 @@ $(function(){
24 24 $('#lineCodeInput').val(lineSelectValueArray[1]);
25 25 var params = {'lineCode_eq':lineSelectValueArray[1],'destroy_eq':0,'directions_eq':dir};
26 26 // 版本号赋值
27   - $.get('/lineVersions/findByLineId',{'lineId':lineSelectValueArray[0]},function(lineVersions){
28   - $.each(lineVersions,function(){
29   - if (this.status == 1) {
30   - $('#versionsInput').val(this.versions);
31   - }
32   - })
  27 + $.get('/lineVersions/findCurrentVersion',{'lineId':lineSelectValueArray[0]},function(versions){
  28 + $('#versionsInput').val(versions);
33 29 });
34 30 initSelect(params);
35 31 }
... ...
src/main/resources/static/pages/base/stationroute/add.html
... ... @@ -237,12 +237,8 @@ $(&#39;#add_station_mobal&#39;).on(&#39;AddStationMobal.show&#39;, function(e, addMap,ajaxd,stao
237 237 // 是否撤销
238 238 $('#destroySelect').val(0);
239 239 // 版本号
240   - $.get('/lineVersions/findByLineId',{'lineId':Line.id},function(lineVersions){
241   - $.each(lineVersions,function(){
242   - if (this.status == 1) {
243   - $('#versionsInput').val(this.versions);
244   - }
245   - })
  240 + $.get('/lineVersions/findCurrentVersion',{'lineId':Line.id},function(versions){
  241 + $('#versionsInput').val(versions);
246 242 });
247 243  
248 244 var initzdlyP = {'line.id_eq':Line.id,'destroy_eq':0,'directions_eq':Station.dir};
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
... ... @@ -216,7 +216,6 @@ var WorldsBMap = function () {
216 216  
217 217 // 地图画多边形
218 218 pointsPolygon : function(objStation) {
219   - debugger
220 219  
221 220 // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)
222 221 mapBValue.setZoom(15);
... ... @@ -374,7 +373,6 @@ var WorldsBMap = function () {
374 373  
375 374 // 画圆
376 375 pointsCircle : function(objStation) {
377   - debugger
378 376  
379 377 // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)
380 378 mapBValue.setZoom(16);
... ...