Commit 70a83926351be224a79e19e4d4fb7d9f6c48ed09

Authored by youxiw2000
1 parent 0584c239

更新基础信息维护: 测点导入 历史版本创建 修改

src/main/java/com/bsth/controller/LineVersionsController.java
1 1 package com.bsth.controller;
2 2  
3 3 import com.bsth.entity.LineVersions;
  4 +import com.bsth.entity.LsSectionRoute;
  5 +import com.bsth.entity.LsStationRoute;
4 6 import com.bsth.repository.LineRepository;
  7 +import com.bsth.repository.LsSectionRouteRepository;
  8 +import com.bsth.repository.LsStationRouteRepository;
5 9 import com.bsth.service.LineVersionsService;
6 10 import org.springframework.beans.factory.annotation.Autowired;
7 11 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -32,6 +36,13 @@ public class LineVersionsController extends BaseController<LineVersions, Integer
32 36 @Autowired
33 37 private LineVersionsService service;
34 38  
  39 +
  40 + @Autowired
  41 + private LsStationRouteRepository lsStationRouteRepository;
  42 +
  43 + @Autowired
  44 + private LsSectionRouteRepository lsSectionRouteRepository;
  45 +
35 46 @Autowired
36 47 LineRepository lineRepository;
37 48  
... ... @@ -79,9 +90,11 @@ public class LineVersionsController extends BaseController<LineVersions, Integer
79 90 public Map<String, Object> add(@RequestParam Map<String, Object> map) {
80 91 return service.add(map);
81 92 }
  93 +
82 94 @RequestMapping(value = "delete", method = RequestMethod.POST)
83 95 public Map<String, Object> delete(@RequestParam (defaultValue = "id") int id) {
84   - return service.delete(id);
  96 +
  97 + return service.deleteAllData(id);
85 98 }
86 99  
87 100 /**
... ...
src/main/java/com/bsth/entity/Section.java
... ... @@ -25,7 +25,7 @@ import javax.persistence.Table;
25 25  
26 26 @Entity
27 27 @Table(name = "bsth_c_section")
28   -public class Section {
  28 +public class Section{
29 29  
30 30 @Id
31 31 /*@GeneratedValue(strategy = GenerationType.IDENTITY)*/
... ... @@ -271,4 +271,5 @@ public class Section {
271 271 public void setUpdateDate(Date updateDate) {
272 272 this.updateDate = updateDate;
273 273 }
  274 +
274 275 }
... ...
src/main/java/com/bsth/repository/LsSectionRouteRepository.java
... ... @@ -5,6 +5,7 @@ import java.util.List;
5 5 import org.springframework.data.jpa.repository.Modifying;
6 6 import org.springframework.data.jpa.repository.Query;
7 7 import org.springframework.stereotype.Repository;
  8 +import org.springframework.transaction.annotation.Transactional;
8 9  
9 10 import com.bsth.entity.Line;
10 11 import com.bsth.entity.LsSectionRoute;
... ... @@ -131,6 +132,7 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute,
131 132 * 更新路线前删除线路版本下历史原有路段路由
132 133 */
133 134 @Modifying
  135 + @Transactional
134 136 @Query(value="DELETE from bsth_c_ls_sectionroute where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true)
135 137 public void batchDelete(Integer line, Integer dir, Integer versions);
136 138  
... ...
src/main/java/com/bsth/repository/LsStationRouteRepository.java
... ... @@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.EntityGraph;
8 8 import org.springframework.data.jpa.repository.Modifying;
9 9 import org.springframework.data.jpa.repository.Query;
10 10 import org.springframework.stereotype.Repository;
  11 +import org.springframework.transaction.annotation.Transactional;
11 12  
12 13 import com.bsth.entity.LsStationRoute;
13 14 import com.bsth.entity.StationRoute;
... ... @@ -164,6 +165,7 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute,
164 165 * @param dir
165 166 */
166 167 @Modifying
  168 + @Transactional
167 169 @Query(value="DELETE from bsth_c_ls_stationroute where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true)
168 170 public void batchDelete(Integer line,Integer dir, Integer versions);
169 171  
... ...
src/main/java/com/bsth/repository/SectionRepository.java
... ... @@ -73,6 +73,59 @@ public interface SectionRepository extends BaseRepository&lt;Section, Integer&gt; {
73 73  
74 74 String descriptions, int versions,int id);
75 75  
  76 +
  77 + @Transactional
  78 + @Modifying
  79 + @Query(value="insert into bsth_c_section(" +
  80 + "id," +
  81 + "section_code," +
  82 + "section_name," +
  83 + "croses_road," +
  84 + "end_node," +
  85 + "start_node," +
  86 + "middle_node," +
  87 + "section_type," +
  88 + "csection_vector," +
  89 + "bsection_vector," +
  90 + "gsection_vector," +
  91 + "road_coding," +
  92 + "section_distance," +
  93 + "section_time," +
  94 + "db_type," +
  95 + "speed_limit," +
  96 + "descriptions," +
  97 + "create_by," +
  98 + "create_date," +
  99 + "update_by," +
  100 + "update_date," +
  101 + "versions)" +
  102 + "(select" +
  103 + " ?2," +
  104 + " ?2," +
  105 + "section_name," +
  106 + "croses_road," +
  107 + "end_node," +
  108 + "start_node," +
  109 + "middle_node," +
  110 + "section_type," +
  111 + "csection_vector," +
  112 + "bsection_vector," +
  113 + "gsection_vector," +
  114 + "road_coding," +
  115 + "section_distance," +
  116 + "section_time," +
  117 + "db_type," +
  118 + "speed_limit," +
  119 + "descriptions," +
  120 + "create_by," +
  121 + "create_date," +
  122 + "update_by," +
  123 + "update_date," +
  124 + "?1" +
  125 + " from bsth_c_section where id = ?3)", nativeQuery=true)
  126 + public void autoCopy(int versions,int id,int s_id);
  127 +
  128 +
76 129 /**
77 130 * @Description :TODO(编辑线路走向)
78 131 *
... ...
src/main/java/com/bsth/service/LineVersionsService.java
... ... @@ -43,5 +43,7 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt;
43 43  
44 44 Map<String, Object> issueVersion(int id);
45 45  
  46 + Map<String, Object> deleteAllData(int id);
  47 +
46 48  
47 49 }
... ...
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
... ... @@ -22,6 +22,7 @@ import com.bsth.entity.Line;
22 22 import com.bsth.entity.LineVersions;
23 23 import com.bsth.entity.LsSectionRoute;
24 24 import com.bsth.entity.LsStationRoute;
  25 +import com.bsth.entity.Section;
25 26 import com.bsth.entity.SectionRoute;
26 27 import com.bsth.entity.Station;
27 28 import com.bsth.entity.StationRoute;
... ... @@ -29,6 +30,7 @@ import com.bsth.repository.LineRepository;
29 30 import com.bsth.repository.LineVersionsRepository;
30 31 import com.bsth.repository.LsSectionRouteRepository;
31 32 import com.bsth.repository.LsStationRouteRepository;
  33 +import com.bsth.repository.SectionRepository;
32 34 import com.bsth.repository.StationRepository;
33 35 import com.bsth.service.LineVersionsService;
34 36 import com.bsth.service.SectionRouteService;
... ... @@ -67,6 +69,9 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
67 69 @Autowired
68 70 StationRepository stationRepository;
69 71  
  72 + @Autowired
  73 + SectionRepository sectionRepository;
  74 +
70 75  
71 76 @Autowired
72 77 com.bsth.repository.SectionRouteRepository sectionRouteRepository ;
... ... @@ -269,38 +274,32 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
269 274 upLineVersions.setEndDate(new java.sql.Date(startDate.getTime()));
270 275 repository.save(upLineVersions);
271 276  
272   - //// 先查询待更新版本 如果有需要就删除 预留..
273   -// List<LsSectionRoute> needDelete = lsSectionRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),versions);
274   -//
275   -// lsSectionRouteRepository.deleteAll(needDelete);
276   -//
277   -// List<LsStationRoute> needDelete2 = lsStationRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),versions);
278   -//
279   -// lsStationRouteRepository.deleteAll(needDelete2);
280   -
281   -
282 277 if(map.get("hisVersions") != null && !map.get("hisVersions").toString().isEmpty()) {
283 278 Integer hisVersion = Integer.valueOf(map.get("hisVersions").toString());
284 279  
285 280 List<LsSectionRoute> sectionList = lsSectionRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),hisVersion);
286 281  
287   -
288 282 for(int i =0;i<sectionList.size();i++) {
  283 +
289 284 LsSectionRoute oldData = sectionList.get(i);
290 285  
291   - LsSectionRoute newData = new LsSectionRoute();
  286 + long sectionCode = GetUIDAndCode.getSectionId();
  287 +
  288 + sectionRepository.autoCopy(versions, (int)sectionCode, oldData.getSection().getId());
  289 + Section section = sectionRepository.findById((int)sectionCode).get();
  290 +
292 291  
  292 + LsSectionRoute newData = new LsSectionRoute();
293 293 newData.setIsRoadeSpeed(oldData.getIsRoadeSpeed());
294 294 newData.setDescriptions(oldData.getDescriptions());
295 295 newData.setLine(oldData.getLine());
296 296 newData.setLineCode(oldData.getLineCode());
297 297 newData.setDirections(oldData.getDirections());
298   - newData.setSection(oldData.getSection());
299   - newData.setSectionCode(oldData.getSectionCode());
  298 + newData.setSection(section);
  299 + newData.setSectionCode(String.valueOf(sectionCode));
300 300 newData.setSectionrouteCode(oldData.getSectionrouteCode());
301 301 newData.setDestroy(0);
302 302 newData.setVersions(versions);
303   -
304 303 lsSectionRouteRepository.save(newData);
305 304  
306 305 }
... ... @@ -310,13 +309,11 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
310 309 for(int i =0;i<stationList.size();i++) {
311 310  
312 311  
313   - Station newStation = stationRepository.findByIdReturnMojo(stationList.get(i).getStation().getId());
  312 + Station newStation = stationRepository.findById(stationList.get(i).getStation().getId()).get();
314 313 Station oldStation = new Station();
315 314 long stationCode = GetUIDAndCode.getStationId();
316 315 oldStation.setStationCod(String.valueOf(stationCode));
317   - oldStation.setId((int)stationCode);
318   -// oldStation.setStationCod(newStation.getStationCod());
319   -
  316 + oldStation.setId((int)stationCode);
320 317 oldStation.setAddr(newStation.getAddr());
321 318 oldStation.setbJwpoints(newStation.getbJwpoints());
322 319 oldStation.setbPolygonGrid(newStation.getbPolygonGrid());
... ... @@ -340,7 +337,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
340 337  
341 338 stationRepository.save(oldStation);
342 339  
343   -
344 340 LsStationRoute oldData = stationList.get(i);
345 341  
346 342 LsStationRoute newData = new LsStationRoute();
... ... @@ -367,34 +363,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
367 363 lsStationRouteRepository.save(newData);
368 364 }
369 365  
370   -
371   -// for(int i =0;i<stationList.size();i++) {
372   -// LsStationRoute oldData = stationList.get(i);
373   -//
374   -// LsStationRoute newData = new LsStationRoute();
375   -//
376   -// newData.setLine(oldData.getLine());
377   -// newData.setStation(oldData.getStation());
378   -// newData.setStationName(oldData.getStationName());
379   -// newData.setStationRouteCode(oldData.getStationRouteCode());
380   -// newData.setLineCode(oldData.getLineCode());
381   -// newData.setStationCode(oldData.getStationCode());
382   -// newData.setStationMark(oldData.getStationMark());
383   -// newData.setOutStationNmber(oldData.getOutStationNmber());
384   -// newData.setDirections(oldData.getDirections());
385   -// newData.setDistances(oldData.getDistances());
386   -// newData.setToTime(oldData.getToTime());
387   -// newData.setFirstTime(oldData.getFirstTime());
388   -// newData.setEndTime(oldData.getEndTime());
389   -// newData.setEndTime(oldData.getEndTime());
390   -// newData.setDescriptions(oldData.getDescriptions());
391   -// newData.setIndustryCode(oldData.getIndustryCode());
392   -// newData.setDestroy(0);
393   -// newData.setVersions(versions);
394   -//
395   -// lsStationRouteRepository.save(newData);
396   -// }
397   -
398 366 }
399 367 resultMap.put("status", ResponseCode.SUCCESS);
400 368 } catch (ParseException e) {
... ... @@ -424,4 +392,17 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
424 392 resultMap.put("status", ResponseCode.ERROR);
425 393 return resultMap;
426 394 }
  395 +
  396 + @Override
  397 + @Transactional
  398 + public Map<String, Object> deleteAllData(int id) {
  399 + LineVersions version = repository.findById(id).get();
  400 +
  401 + lsSectionRouteRepository.batchDelete(version.getLine().getId(),0,version.getVersions());
  402 + lsSectionRouteRepository.batchDelete(version.getLine().getId(),1,version.getVersions());
  403 + lsStationRouteRepository.batchDelete(version.getLine().getId(),0,version.getVersions());
  404 + lsStationRouteRepository.batchDelete(version.getLine().getId(),1,version.getVersions());
  405 +
  406 + return delete(id);
  407 + }
427 408 }
... ...
src/main/java/com/bsth/service/impl/SectionServiceImpl.java
... ... @@ -660,8 +660,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem
660 660 // 路段时长
661 661 Double sectionTime = map.get("sectionTime").equals("") ? null : Double.valueOf(map.get("sectionTime").toString());
662 662 // 路段路由
663   - Integer sectionrouteCode = map.get("sectionrouteCode").equals("") ? null : Integer.valueOf(map.get("sectionrouteCode").toString());
664   -
  663 + Integer sectionrouteCode = "".equals(map.get("sectionrouteCode")) ? null : Integer.valueOf(map.get("sectionrouteCode").toString());
665 664 // 限速
666 665 Double speedLimit = map.get("speedLimit").equals("") ? null : Double.valueOf(map.get("speedLimit").toString());
667 666 // 版本
... ...
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.LsSectionRoute;
21 22 import com.bsth.entity.LsStationRoute;
22 23 import com.bsth.entity.Section;
23 24 import com.bsth.entity.SectionRoute;
... ... @@ -28,6 +29,7 @@ import com.bsth.entity.StationRouteCache;
28 29 import com.bsth.repository.LineInformationRepository;
29 30 import com.bsth.repository.LineRepository;
30 31 import com.bsth.repository.LineVersionsRepository;
  32 +import com.bsth.repository.LsSectionRouteRepository;
31 33 import com.bsth.repository.LsStationRouteRepository;
32 34 import com.bsth.repository.SectionRepository;
33 35 import com.bsth.repository.SectionRouteCacheRepository;
... ... @@ -60,57 +62,61 @@ import com.bsth.util.Geo.Point;
60 62 */
61 63  
62 64 @Service
63   -public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implements StationService{
64   -
  65 +public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implements StationService {
  66 +
65 67 @Autowired
66 68 private StationRepository repository;
67   -
  69 +
68 70 @Autowired
69 71 private StationRouteRepository routeRepository;
70 72  
71 73 @Autowired
72 74 private LsStationRouteRepository lsStationRouteRepository;
73   -
  75 +
74 76 @Autowired
75 77 private StationRouteCacheRepository routeCacheRepository;
76 78  
77 79 @Autowired
78 80 private LineInformationRepository informationRepository;
79   -
80   - @Autowired
  81 +
  82 + @Autowired
81 83 private LineRepository lineRepository;
82   -
  84 +
83 85 @Autowired
84 86 private SectionRepository sectionRepository;
85   -
  87 +
86 88 @Autowired
87 89 private SectionRouteRepository sectionRouteRepository;
88   -
  90 +
  91 + @Autowired
  92 + private LsSectionRouteRepository lsSectionRouteRepository;
  93 +
89 94 @Autowired
90 95 private SectionRouteCacheRepository sectionRouteCacheRepository;
91   -
  96 +
92 97 @Autowired
93 98 LineVersionsRepository lineVersionsRepository;
94   -
  99 +
95 100 Logger logger = LoggerFactory.getLogger(this.getClass());
96   -
  101 +
97 102 /**
98 103 * @Description :TODO(系统规划保存数据)
99 104 *
100   - * @param map <stationJSON:站点信息; sectionJSON:路段信息;dbType:坐标类型; destroy:是否撤销; directions:方向;lineId:线路ID;
  105 + * @param map <stationJSON:站点信息; sectionJSON:路段信息;dbType:坐标类型; destroy:是否撤销;
  106 + * directions:方向;lineId:线路ID;
101 107 *
102   - * radius:圆半径;shapesType:图形类型;speedLimit:限速>
  108 + * radius:圆半径;shapesType:图形类型;speedLimit:限速>
103 109 *
104 110 * @return Map<String, Object> <SUCCESS ; ERROR>
105 111 */
106 112 @Override
107 113 public Map<String, Object> systemSaveStations(Map<String, Object> map) {
108   - Map<String, Object> resultMap = new HashMap<String,Object>();
  114 + Map<String, Object> resultMap = new HashMap<String, Object>();
109 115 try {
110 116 // 站点信息字符传
111   - String stationJSON = map.get("stationJSON").toString().equals("") ? "" : map.get("stationJSON").toString();
  117 + String stationJSON = map.get("stationJSON").toString().equals("") ? "" : map.get("stationJSON").toString();
112 118 // 路段信息字符串
113   - String sectionJSON = map.get("sectionJSON").toString().equals("") ? "" : map.get("sectionJSON").toString();
  119 + String sectionJSON = map.get("sectionJSON").toString().equals("") ? "" : map.get("sectionJSON").toString();
114 120 // 方向
115 121 int directions = Integer.parseInt(map.get("directions").toString());
116 122 // 是否撤销
... ... @@ -118,13 +124,13 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
118 124 // 版本
119 125 int versions = map.get("versions").equals("") ? 0 : Integer.parseInt(map.get("versions").toString());
120 126 // 坐标类型
121   - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  127 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
122 128 // 限速
123 129 String speedLimitStr = map.get("speedLimit").equals("") ? "" : map.get("speedLimit").toString();
124 130 // 线路ID
125 131 int lineId = map.get("lineId").toString().equals("") ? 0 : Integer.parseInt(map.get("lineId").toString());
126 132 // 半径
127   - int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
  133 + int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
128 134 // 图形类型
129 135 String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
130 136 // 路段距离
... ... @@ -135,112 +141,114 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
135 141 double sumUpOrDownMileage = 0.0d;
136 142 // 线路信息
137 143 Line resultLine = lineRepository.findById(lineId).get();
138   - Map<String, Object> resultSaveMapm = new HashMap<String,Object>();
  144 + Map<String, Object> resultSaveMapm = new HashMap<String, Object>();
139 145 String baseRes = map.get("baseRes").equals("") ? "" : map.get("baseRes").toString();
140   - if(!stationJSON.equals("")) {
  146 + if (!stationJSON.equals("")) {
141 147 // 保存前先撤销原有站点
142   -
  148 +
143 149 // 保存站点与站点路由信息
144   - resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine,baseRes);
  150 + resultSaveMapm = savaStationAndStationRouteInfo(stationJSON, sectionDistance, sectionDuration, dbType,
  151 + radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine, baseRes);
145 152 }
146   -
  153 +
147 154 // 路段长度
148 155 sectionDistance = Double.valueOf(resultSaveMapm.get("sectionDistance").toString());
149   -
  156 +
150 157 // 路段时长
151   - sectionDuration= Double.valueOf(resultSaveMapm.get("sectionDuration").toString());
152   -
  158 + sectionDuration = Double.valueOf(resultSaveMapm.get("sectionDuration").toString());
  159 +
153 160 // 如果路段信息JSON字符串不为空
154   - if(!sectionJSON.equals("")) {
155   -
  161 + if (!sectionJSON.equals("")) {
  162 +
156 163 // 保存路段与路段路由信息
157   - saveSectionAndSectionRouteInfo( sectionJSON, directions, resultLine, speedLimitStr,sectionDistance, sectionDuration, dbType, versions, destroy);
  164 + saveSectionAndSectionRouteInfo(sectionJSON, directions, resultLine, speedLimitStr, sectionDistance,
  165 + sectionDuration, dbType, versions, destroy);
158 166 }
159   -
  167 +
160 168 // 里程
161 169 sumUpOrDownMileage = Double.valueOf(resultSaveMapm.get("sumUpOrDownMileage").toString());
162   -
  170 +
163 171 BigDecimal s = new BigDecimal(sumUpOrDownMileage);
164   -
  172 +
165 173 sumUpOrDownMileage = s.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
166   -
  174 +
167 175 // 更新里程
168   - updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
169   -
170   - if(directions==0) {
171   -
  176 + updateLineInfoUpOrDownMileage(resultLine, directions, sumUpOrDownMileage);
  177 +
  178 + if (directions == 0) {
  179 +
172 180 lineUpdateStationName(resultLine);
173   -
  181 +
174 182 }
175 183 resultMap.put("status", ResponseCode.SUCCESS);
176   -
  184 +
177 185 } catch (Exception e) {
178   -
  186 +
179 187 resultMap.put("status", ResponseCode.ERROR);
180   -
  188 +
181 189 logger.error("save erro.", e);
182   -
  190 +
183 191 }
184   -
  192 +
185 193 return resultMap;
186 194 }
187   -
188   -
  195 +
189 196 public void lineUpdateStationName(Line resultLine) {
190   -
  197 +
191 198 List<StationRoute> stationRoutes = routeRepository.findByLine(resultLine);
192   -
  199 +
193 200 int sizeL = stationRoutes.size();
194   -
195   - if(sizeL<0) {
196   -
  201 +
  202 + if (sizeL < 0) {
  203 +
197 204 return;
198   -
  205 +
199 206 }
200   -
201   - if(resultLine.getStartStationName().equals("")){
202   -
203   - for(int k =0;k<sizeL;k++) {
204   -
  207 +
  208 + if (resultLine.getStartStationName().equals("")) {
  209 +
  210 + for (int k = 0; k < sizeL; k++) {
  211 +
205 212 StationRoute tempS = stationRoutes.get(k);
206   -
207   - if(tempS.getStationMark().equals("B") && tempS.getDirections()==0) {
208   -
  213 +
  214 + if (tempS.getStationMark().equals("B") && tempS.getDirections() == 0) {
  215 +
209 216 resultLine.setStartStationName(tempS.getStationName());
210   -
  217 +
211 218 lineRepository.save(resultLine);
212   -
  219 +
213 220 }
214 221 }
215 222  
216   - };
217   -
218   - if(resultLine.getEndStationName().equals("")) {
219   -
220   - for(int k =0;k<sizeL;k++) {
221   -
  223 + }
  224 + ;
  225 +
  226 + if (resultLine.getEndStationName().equals("")) {
  227 +
  228 + for (int k = 0; k < sizeL; k++) {
  229 +
222 230 StationRoute tempS = stationRoutes.get(k);
223   -
224   - if(tempS.getStationMark().equals("E") && tempS.getDirections()==0) {
225   -
  231 +
  232 + if (tempS.getStationMark().equals("E") && tempS.getDirections() == 0) {
  233 +
226 234 resultLine.setEndStationName(tempS.getStationName());
227   -
  235 +
228 236 lineRepository.save(resultLine);
229   -
  237 +
230 238 }
231 239 }
232   -
  240 +
233 241 }
234 242 }
235   -
  243 +
236 244 /**
237 245 * @Description :保存站点和站点路由信息(系统规划)
238 246 *
239 247 * @param stationJSON:站点和站点路由json数据
240 248 *
241   - * @param sectionDistance: 总距离
  249 + * @param sectionDistance: 总距离
242 250 *
243   - * @param sectionDuration: 总时长
  251 + * @param sectionDuration: 总时长
244 252 *
245 253 * @param dbType:原坐标类型
246 254 *
... ... @@ -262,110 +270,124 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
262 270 *
263 271 * @throws Exception
264 272 */
265   - public Map<String, Object> savaStationAndStationRouteInfo(String stationJSON,double sectionDistance,double sectionDuration,String dbType,
266   - int radius,String shapesType,int destroy,int versions,double sumUpOrDownMileage,int directions,Line resultLine,String baseRes) throws Exception{
267   - Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String,Object>();
  273 + public Map<String, Object> savaStationAndStationRouteInfo(String stationJSON, double sectionDistance,
  274 + double sectionDuration, String dbType, int radius, String shapesType, int destroy, int versions,
  275 + double sumUpOrDownMileage, int directions, Line resultLine, String baseRes) throws Exception {
  276 + Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String, Object>();
268 277 JSONArray stationsArray = JSONArray.parseArray(stationJSON);
269   - if(stationsArray.size()>0) {
  278 + if (stationsArray.size() > 0) {
270 279 Station loopStartStation = new Station();
271   - for(int i = 0;i <stationsArray.size();i++) {
  280 + for (int i = 0; i < stationsArray.size(); i++) {
272 281 // 站点名称
273   - String stationName = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("name").toString();
274   - Double distance = stationsArray.getJSONObject(i).get("distance").equals("") ? 0.0d : Double.parseDouble(stationsArray.getJSONObject(i).get("distance").toString());
  282 + String stationName = stationsArray.getJSONObject(i).equals("") ? ""
  283 + : stationsArray.getJSONObject(i).get("name").toString();
  284 + Double distance = stationsArray.getJSONObject(i).get("distance").equals("") ? 0.0d
  285 + : Double.parseDouble(stationsArray.getJSONObject(i).get("distance").toString());
275 286 // 转成公里
276   - distance = distance/1000;
  287 + distance = distance / 1000;
277 288 BigDecimal d = new BigDecimal(distance);
278 289 distance = d.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
279   - sectionDistance= distance + sectionDistance;
280   - Double duration = stationsArray.getJSONObject(i).get("duration").equals("") ? 0.0d : Double.parseDouble(stationsArray.getJSONObject(i).get("duration").toString());
  290 + sectionDistance = distance + sectionDistance;
  291 + Double duration = stationsArray.getJSONObject(i).get("duration").equals("") ? 0.0d
  292 + : Double.parseDouble(stationsArray.getJSONObject(i).get("duration").toString());
281 293 // 转成分钟
282   - duration = duration/60;
  294 + duration = duration / 60;
283 295 BigDecimal t = new BigDecimal(duration);
284 296 duration = t.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
285 297 sectionDuration = duration + sectionDuration;
286 298 // 百度经纬度坐标
287 299 String bJwpoints = "";
288 300 // 百度坐标经度
289   - String bLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lng").toString();
290   - bLonx = bLonx==null || bLonx.equals("") ? "0" : bLonx;
  301 + String bLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString())
  302 + .get("lng").toString();
  303 + bLonx = bLonx == null || bLonx.equals("") ? "0" : bLonx;
291 304 // 百度坐标纬度
292   - String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString();
293   - bLatx = bLatx==null || bLatx.equals("") ? "0" : bLatx;
294   - List<Object[]> stationNameList = repository.findStationName(directions,stationName);
295   - Map<String, Object> isHaveMap = isHaveStationname(bLonx,bLatx,stationNameList);
  305 + String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString())
  306 + .get("lat").toString();
  307 + bLatx = bLatx == null || bLatx.equals("") ? "0" : bLatx;
  308 + List<Object[]> stationNameList = repository.findStationName(directions, stationName);
  309 + Map<String, Object> isHaveMap = isHaveStationname(bLonx, bLatx, stationNameList);
296 310 // 初始化站点对象
297   - Station arg0 = new Station();
298   - if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) {
299   - /*Integer stationId = Integer.parseInt(stationNameList.get(0)[1].toString());*/
  311 + Station arg0 = new Station();
  312 + if (Boolean.parseBoolean(isHaveMap.get("isHave").toString())) {
  313 + /*
  314 + * Integer stationId = Integer.parseInt(stationNameList.get(0)[1].toString());
  315 + */
300 316 Integer stationId = Integer.parseInt(isHaveMap.get("id").toString());
301 317 arg0 = repository.findById(stationId).get();
302 318  
303   - if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  319 + if (i == stationsArray.size() - 1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
304 320 arg0 = loopStartStation;
305 321 } else {
306 322 List<Station> list = new ArrayList<>();
307 323 list.add(arg0);
308   - List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
  324 + List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
309 325 Station station = stationlist.get(0);
310 326 // 站点编码
311 327 long stationCode = GetUIDAndCode.getStationId();
312 328 station.setStationCod(String.valueOf(stationCode));
313   - station.setId((int)stationCode);
  329 + station.setId((int) stationCode);
314 330 station.setCreateDate(null);
315 331 station.setUpdateDate(null);
316 332 station.setShapesType("r");
317 333 station.setRadius(80);
318 334 repository.save(station);
319 335 arg0 = station;
320   - if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  336 + if (i == 0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
321 337 loopStartStation = arg0;
322 338 }
323 339 }
324   - }else {
  340 + } else {
325 341 // 站点编码
326 342 long stationCode = GetUIDAndCode.getStationId();
327 343 arg0.setStationCod(String.valueOf(stationCode));
328   - arg0.setId((int)stationCode);
  344 + arg0.setId((int) stationCode);
329 345 arg0.setStationName(stationName);
330 346 // 原坐标类型
331 347 arg0.setDbType(dbType);
332   - String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").toString();
333   - String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").toString();
  348 + String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  349 + .get("x").equals("") ? null
  350 + : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  351 + .get("x").toString();
  352 + String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  353 + .get("y").equals("") ? null
  354 + : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  355 + .get("y").toString();
334 356 float gLonx = 0.0f;
335 357 float gLaty = 0.0f;
336 358 Location resultPoint = null;
337   - if(baseRes.equals("No")){
  359 + if (baseRes.equals("No")) {
338 360 /** BD to WGS坐标 */
339   - resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
340   - if(gLonxStr==null)
341   - gLonx = (float)resultPoint.getLng();
  361 + resultPoint = FromBDPointToWGSPoint(bLonx, bLatx);
  362 + if (gLonxStr == null)
  363 + gLonx = (float) resultPoint.getLng();
342 364 else
343   - gLonx = Float.valueOf(gLonxStr);
344   - if(gLatyStr==null)
345   - gLaty = (float)resultPoint.getLat();
  365 + gLonx = Float.valueOf(gLonxStr);
  366 + if (gLatyStr == null)
  367 + gLaty = (float) resultPoint.getLat();
346 368 else
347   - gLaty = Float.valueOf(gLatyStr);
  369 + gLaty = Float.valueOf(gLatyStr);
348 370 arg0.setgLonx(gLonx);
349 371 arg0.setgLaty(gLaty);
350 372 // 百度经纬度
351 373 bJwpoints = bLonx + " " + bLatx;
352 374 arg0.setbJwpoints(bJwpoints);
353   - }else if(baseRes.equals("GCJ02")){
  375 + } else if (baseRes.equals("GCJ02")) {
354 376 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
355 377 Location location = TransGPS.bd_encrypt(bdLoc);
356 378 String GCJLng = String.valueOf(location.getLng());
357 379 String GCJLat = String.valueOf(location.getLat());
358   - resultPoint = FromBDPointToWGSPoint(GCJLng,GCJLat);
359   - bJwpoints = GCJLng + " " +GCJLat;
360   - arg0.setgLonx((float)location.getLng());
361   - arg0.setgLaty((float)location.getLat());
  380 + resultPoint = FromBDPointToWGSPoint(GCJLng, GCJLat);
  381 + bJwpoints = GCJLng + " " + GCJLat;
  382 + arg0.setgLonx((float) location.getLng());
  383 + arg0.setgLaty((float) location.getLat());
362 384 arg0.setbJwpoints(bJwpoints);
363   - }else if(baseRes.equals("BD09")){
  385 + } else if (baseRes.equals("BD09")) {
364 386 resultPoint = FromBDPointToWGSPoint(gLonxStr, gLatyStr);
365   - bJwpoints = gLonxStr+ " " + gLatyStr;
366   - arg0.setgLonx((float)resultPoint.getLng());
367   - arg0.setgLaty((float)resultPoint.getLat());
368   - }else if(baseRes.equals("WGS84")){
  387 + bJwpoints = gLonxStr + " " + gLatyStr;
  388 + arg0.setgLonx((float) resultPoint.getLng());
  389 + arg0.setgLaty((float) resultPoint.getLat());
  390 + } else if (baseRes.equals("WGS84")) {
369 391 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
370 392 Location gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
371 393 Location bdEn = TransGPS.bd_encrypt(gcjLoc);
... ... @@ -382,62 +404,102 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
382 404 arg0.setVersions(versions);
383 405 arg0.setbJwpoints(bJwpoints);
384 406 // 插入站点信息
385   - if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  407 + if (i == 0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
386 408 loopStartStation = arg0;
387 409 repository.save(arg0);
388   - } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  410 + } else if (i == stationsArray.size() - 1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
389 411 arg0 = loopStartStation;
390 412 } else {
391 413 repository.save(arg0);
392 414 }
393 415  
394 416 }
395   - // 站点路由对象
396   - StationRoute route = new StationRoute();
397   - // 站点名称
398   - route.setStationName(stationName);
399   - route.setDistances(distance);
400   - sumUpOrDownMileage = sumUpOrDownMileage + distance;
401   - route.setToTime(duration);
402   - // 站点编码
403   - route.setStationCode(arg0.getStationCod());
404   - // 站点序号
405   - route.setStationRouteCode((i+1)*100);
406   - // 站点类型
407   - if(i==0) {
408   - // 起始站
409   - route.setStationMark("B");
410   - }else if(i==stationsArray.size()-1) {
411   - // 终点站
412   - route.setStationMark("E");
413   - }else {
414   - // 中途站
415   - route.setStationMark("Z");
  417 +
  418 + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
  419 +
  420 + if (versions == version) {
  421 + // 站点路由对象
  422 + StationRoute route = new StationRoute();
  423 + // 站点名称
  424 + route.setStationName(stationName);
  425 + route.setDistances(distance);
  426 + sumUpOrDownMileage = sumUpOrDownMileage + distance;
  427 + route.setToTime(duration);
  428 + // 站点编码
  429 + route.setStationCode(arg0.getStationCod());
  430 + // 站点序号
  431 + route.setStationRouteCode((i + 1) * 100);
  432 + // 站点类型
  433 + if (i == 0) {
  434 + // 起始站
  435 + route.setStationMark("B");
  436 + } else if (i == stationsArray.size() - 1) {
  437 + // 终点站
  438 + route.setStationMark("E");
  439 + } else {
  440 + // 中途站
  441 + route.setStationMark("Z");
  442 + }
  443 + // 版本号(获取线路当前版本)
  444 + route.setVersions(versions);
  445 + // 站点ID
  446 + route.setStation(arg0);
  447 + // 方向
  448 + route.setDirections(directions);
  449 + // 线路ID
  450 + route.setLine(resultLine);
  451 + // 线路编码
  452 + route.setLineCode(resultLine.getLineCode());
  453 + route.setDestroy(destroy);
  454 + // 插入站点路由信息
  455 + routeRepository.save(route);
  456 + } else {
  457 +
  458 + LsStationRoute route = new LsStationRoute();
  459 + // 站点名称
  460 + route.setStationName(stationName);
  461 + route.setDistances(distance);
  462 + sumUpOrDownMileage = sumUpOrDownMileage + distance;
  463 + route.setToTime(duration);
  464 + // 站点编码
  465 + route.setStationCode(arg0.getStationCod());
  466 + // 站点序号
  467 + route.setStationRouteCode((i + 1) * 100);
  468 + // 站点类型
  469 + if (i == 0) {
  470 + // 起始站
  471 + route.setStationMark("B");
  472 + } else if (i == stationsArray.size() - 1) {
  473 + // 终点站
  474 + route.setStationMark("E");
  475 + } else {
  476 + // 中途站
  477 + route.setStationMark("Z");
  478 + }
  479 + // 版本号(获取线路当前版本)
  480 + route.setVersions(versions);
  481 + // 站点ID
  482 + route.setStation(arg0);
  483 + // 方向
  484 + route.setDirections(directions);
  485 + // 线路ID
  486 + route.setLine(resultLine);
  487 + // 线路编码
  488 + route.setLineCode(resultLine.getLineCode());
  489 + route.setDestroy(destroy);
  490 + // 插入站点路由信息
  491 + lsStationRouteRepository.save(route);
416 492 }
417   - // 版本号(获取线路当前版本)
418   - Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
419   - route.setVersions(version);
420   - // 站点ID
421   - route.setStation(arg0);
422   - // 方向
423   - route.setDirections(directions);
424   - // 线路ID
425   - route.setLine(resultLine);
426   - // 线路编码
427   - route.setLineCode(resultLine.getLineCode());
428   - route.setDestroy(destroy);
429   - // 插入站点路由信息
430   - routeRepository.save(route);
431   -
  493 +
432 494 }
433 495 paramsMeleageAndDistncDura.put("sumUpOrDownMileage", sumUpOrDownMileage);
434 496 paramsMeleageAndDistncDura.put("sectionDistance", sectionDistance);
435 497 paramsMeleageAndDistncDura.put("sectionDuration", sectionDuration);
436   - paramsMeleageAndDistncDura.put("stationdata",stationsArray);
  498 + paramsMeleageAndDistncDura.put("stationdata", stationsArray);
437 499 }
438 500 return paramsMeleageAndDistncDura;
439 501 }
440   -
  502 +
441 503 /**
442 504 *
443 505 *
... ... @@ -447,93 +509,91 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
447 509 *
448 510 * @param sumUpOrDownMileage:里程(上或者下)
449 511 */
450   - public void updateLineInfoUpOrDownMileage(Line resultLine ,int directions,double sumUpOrDownMileage) {
451   -
  512 + public void updateLineInfoUpOrDownMileage(Line resultLine, int directions, double sumUpOrDownMileage) {
  513 +
452 514 List<LineInformation> listLineInfo = informationRepository.findByLine(resultLine);
453   -
  515 +
454 516 int listLineSize = listLineInfo.size();
455   -
  517 +
456 518 // 不存在线路标准信息则插入
457   - if(listLineSize==0) {
458   -
  519 + if (listLineSize == 0) {
  520 +
459 521 LineInformation paramInfo = new LineInformation();
460   -
  522 +
461 523 // 上行
462   - if(directions==0) {
463   -
  524 + if (directions == 0) {
  525 +
464 526 paramInfo.setUpMileage(sumUpOrDownMileage);
465   -
  527 +
466 528 paramInfo.setDownMileage(0.0d);
467   -
468   - paramInfo.setTotalMileage(sumUpOrDownMileage+0.0d);
469   -
  529 +
  530 + paramInfo.setTotalMileage(sumUpOrDownMileage + 0.0d);
  531 +
470 532 paramInfo.setType("zc");
471   -
  533 +
472 534 paramInfo.setLine(resultLine);
473   -
474   - // 下行
475   - }else if(directions==1) {
476   -
  535 +
  536 + // 下行
  537 + } else if (directions == 1) {
  538 +
477 539 paramInfo.setUpMileage(0.0d);
478   -
  540 +
479 541 paramInfo.setDownMileage(sumUpOrDownMileage);
480   -
481   - paramInfo.setTotalMileage(sumUpOrDownMileage+0.0d);
482   -
  542 +
  543 + paramInfo.setTotalMileage(sumUpOrDownMileage + 0.0d);
  544 +
483 545 paramInfo.setType("zc");
484   -
  546 +
485 547 paramInfo.setLine(resultLine);
486   -
  548 +
487 549 }
488   -
  550 +
489 551 informationRepository.save(paramInfo);
490   -
491   - // 存在则更新
492   - }else if(listLineSize>0) {
493   -
494   - for(int s =0;s<listLineSize;s++) {
495   -
  552 +
  553 + // 存在则更新
  554 + } else if (listLineSize > 0) {
  555 +
  556 + for (int s = 0; s < listLineSize; s++) {
  557 +
496 558 LineInformation lineInformation = listLineInfo.get(s);
497   -
  559 +
498 560 double tempUp = lineInformation.getUpMileage();
499   -
  561 +
500 562 double tempDown = lineInformation.getDownMileage();
501   -
  563 +
502 564 // 上行
503   - if(directions==0) {
504   -
505   - if(tempUp>0.0d){
506   -
  565 + if (directions == 0) {
  566 +
  567 + if (tempUp > 0.0d) {
  568 +
507 569 continue;
508 570 }
509   -
510   -
  571 +
511 572 lineInformation.setUpMileage(sumUpOrDownMileage);
512   -
513   - lineInformation.setTotalMileage(sumUpOrDownMileage+tempDown);
514   -
515   -
516   - }else if(directions==1) {
517   -
518   - if(tempDown>0.0d){
519   -
  573 +
  574 + lineInformation.setTotalMileage(sumUpOrDownMileage + tempDown);
  575 +
  576 + } else if (directions == 1) {
  577 +
  578 + if (tempDown > 0.0d) {
  579 +
520 580 continue;
521 581 }
522   -
  582 +
523 583 lineInformation.setDownMileage(sumUpOrDownMileage);
524   -
525   - lineInformation.setTotalMileage(sumUpOrDownMileage+tempUp);
526   -
  584 +
  585 + lineInformation.setTotalMileage(sumUpOrDownMileage + tempUp);
  586 +
527 587 }
528   -
  588 +
529 589 informationRepository.save(lineInformation);
530   -
  590 +
531 591 }
532   -
  592 +
533 593 }
534   -
  594 +
535 595 }
536   -
  596 +
537 597 /**
538 598 * @Description 保存路段与路段路由信息
539 599 *
... ... @@ -556,141 +616,142 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
556 616 * @param destroy:是否撤销
557 617 *
558 618 */
559   - public void saveSectionAndSectionRouteInfo(String sectionJSON,int directions,Line resultLine,String speedLimitStr,
560   -
561   - double sectionDistance,double sectionDuration,String dbType,int versions,int destroy) throws Exception{
562   -
  619 + public void saveSectionAndSectionRouteInfo(String sectionJSON, int directions, Line resultLine,
  620 + String speedLimitStr,
  621 +
  622 + double sectionDistance, double sectionDuration, String dbType, int versions, int destroy) throws Exception {
  623 +
563 624 BigDecimal t = new BigDecimal(sectionDistance);
564   -
  625 +
565 626 sectionDistance = t.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
566   -
567   -
  627 +
568 628 BigDecimal d = new BigDecimal(sectionDuration);
569   -
  629 +
570 630 sectionDuration = d.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
571   -
  631 +
572 632 // 转换成JSON数组
573 633 JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);
574   -
  634 +
575 635 // 原始线状图形坐标集合
576 636 String sectionsBpoints = "";
577   -
  637 +
578 638 // WGS线状图形坐标集合
579 639 String sectionsWJPpoints = "";
580   -
  640 +
581 641 // 遍历
582   - for(int s = 0 ;s<sectionsArray.size();s++) {
583   -
  642 + for (int s = 0; s < sectionsArray.size(); s++) {
  643 +
584 644 String pointsLngStr = sectionsArray.getJSONObject(s).get("lng").toString();
585   -
  645 +
586 646 String pointsLatStr = sectionsArray.getJSONObject(s).get("lat").toString();
587   -
  647 +
588 648 String WGSLngStr = "";
589   -
  649 +
590 650 String WGSLatStr = "";
591   -
592   - Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);
593   -
  651 +
  652 + Location resultPoint = FromBDPointToWGSPoint(pointsLngStr, pointsLatStr);
  653 +
594 654 WGSLngStr = String.valueOf(resultPoint.getLng());
595   -
596   - WGSLatStr = String.valueOf(resultPoint.getLat());
  655 +
  656 + WGSLatStr = String.valueOf(resultPoint.getLat());
597 657 /** to WGS坐标 */
598   - /*double lng = Double.parseDouble(WGSLngStr);
599   -
600   - double lat = Double.parseDouble(WGSLatStr);
601   -
602   - Location bdLoc = TransGPS.LocationMake(lng, lat);
603   -
604   - Location location = TransGPS.bd_decrypt(bdLoc);
605   -
606   - Location WGSPoint = TransGPS.transformFromGCJToWGS(location);*/
607   -
608   - // String WGSLngStr = JSONObject.parseObject(sectionsArray.getJSONObject(s).get("WGSpotion").toString()).get("Lng").toString();
609   -
610   - // String WGSLatStr = JSONObject.parseObject(sectionsArray.getJSONObject(s).get("WGSpotion").toString()).get("Lat").toString();
611   -
612   - if(s==0) {
613   -
  658 + /*
  659 + * double lng = Double.parseDouble(WGSLngStr);
  660 + *
  661 + * double lat = Double.parseDouble(WGSLatStr);
  662 + *
  663 + * Location bdLoc = TransGPS.LocationMake(lng, lat);
  664 + *
  665 + * Location location = TransGPS.bd_decrypt(bdLoc);
  666 + *
  667 + * Location WGSPoint = TransGPS.transformFromGCJToWGS(location);
  668 + */
  669 +
  670 + // String WGSLngStr =
  671 + // JSONObject.parseObject(sectionsArray.getJSONObject(s).get("WGSpotion").toString()).get("Lng").toString();
  672 +
  673 + // String WGSLatStr =
  674 + // JSONObject.parseObject(sectionsArray.getJSONObject(s).get("WGSpotion").toString()).get("Lat").toString();
  675 +
  676 + if (s == 0) {
  677 +
614 678 sectionsBpoints = pointsLngStr + " " + pointsLatStr;
615   -
  679 +
616 680 sectionsWJPpoints = WGSLngStr + " " + WGSLatStr;
617   -
618   - }else {
619   -
620   - sectionsBpoints = sectionsBpoints + "," + pointsLngStr + " " + pointsLatStr;
621   -
622   - sectionsWJPpoints = sectionsWJPpoints + "," + WGSLngStr + " " + WGSLatStr;
623   -
  681 +
  682 + } else {
  683 +
  684 + sectionsBpoints = sectionsBpoints + "," + pointsLngStr + " " + pointsLatStr;
  685 +
  686 + sectionsWJPpoints = sectionsWJPpoints + "," + WGSLngStr + " " + WGSLatStr;
  687 +
624 688 }
625   -
626   -
  689 +
627 690 }
628   -
  691 +
629 692 long sectionMaxId = GetUIDAndCode.getSectionId();
630   -
  693 +
631 694 String sectionCode = String.valueOf(sectionMaxId);
632   -
633   - int sectionid = (int)sectionMaxId;
634   -
  695 +
  696 + int sectionid = (int) sectionMaxId;
  697 +
635 698 String upOrDownStr = "";
636   -
637   - if(directions==0){
638   -
  699 +
  700 + if (directions == 0) {
  701 +
639 702 upOrDownStr = "上行路段";
640   -
641   - }else if(directions==1){
642   -
  703 +
  704 + } else if (directions == 1) {
  705 +
643 706 upOrDownStr = "下行路段";
644   -
  707 +
645 708 }
646   -
647   - // 路段名称
648   - String sectionName = resultLine.getName()+upOrDownStr;
649   -
  709 +
  710 + // 路段名称
  711 + String sectionName = resultLine.getName() + upOrDownStr;
  712 +
650 713 // 交出路
651 714 String crosesRoad = "";
652   -
  715 +
653 716 // 终止节点
654 717 String endNode = "";
655   -
  718 +
656 719 // 开始节点
657 720 String startNode = "";
658   -
  721 +
659 722 // 中间节点
660 723 String middleNode = "";
661   -
  724 +
662 725 // WGS坐标点集合
663   - String gsectionVector = "LINESTRING(" + sectionsWJPpoints +")";
664   -
  726 + String gsectionVector = "LINESTRING(" + sectionsWJPpoints + ")";
  727 +
665 728 // 原坐标点集合
666 729 String bsectionVector = "LINESTRING(" + sectionsBpoints + ")";
667   -
  730 +
668 731 // 城建坐标点集合
669 732 String csectionVector = null;
670   -
  733 +
671 734 // 路段类型
672 735 String sectionType = "";
673   -
  736 +
674 737 // 道路编码
675 738 String roadCoding = "";
676   -
  739 +
677 740 // 限速
678 741 double speedLimit = Double.parseDouble(speedLimitStr);
679   -
  742 +
680 743 // 说明
681 744 String descriptions = "";
682   -
  745 +
683 746 // 路段保存
684   - sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode,
685   -
686   - middleNode, gsectionVector, bsectionVector, sectionType, csectionVector,
687   -
688   - roadCoding, sectionDistance, sectionDuration, dbType, speedLimit,
689   -
690   - descriptions, versions,sectionid);
691   -
692   -
693   -
  747 + sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode,
  748 +
  749 + middleNode, gsectionVector, bsectionVector, sectionType, csectionVector,
  750 +
  751 + roadCoding, sectionDistance, sectionDuration, dbType, speedLimit,
  752 +
  753 + descriptions, versions, sectionid);
  754 +
694 755 Section section = sectionRepository.findById(sectionid).get();
695 756 // 路段路由
696 757 SectionRoute sectionRoute = new SectionRoute();
... ... @@ -711,45 +772,46 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
711 772 sectionRoute.setDirections(directions);
712 773 // 路段路由保存
713 774 sectionRouteRepository.save(sectionRoute);
714   -
  775 +
715 776 }
716   - public Map<String, Object> isHaveStationname(String jd,String wd,List<Object[]> stationNameList) {
717   - Map<String, Object> rsM = new HashMap<String ,Object>();
  777 +
  778 + public Map<String, Object> isHaveStationname(String jd, String wd, List<Object[]> stationNameList) {
  779 + Map<String, Object> rsM = new HashMap<String, Object>();
718 780 boolean temp = false;
719   - if(stationNameList.size()>0) {
720   - if(jd.equals("0") || wd.equals("0")) {
  781 + if (stationNameList.size() > 0) {
  782 + if (jd.equals("0") || wd.equals("0")) {
721 783 rsM.put("id", stationNameList.get(0)[1]);
722 784 temp = true;
723   - }else{
724   - Point p1 = new Point(Double.parseDouble(jd),Double.parseDouble(wd));
725   - for(int k = 0 ; k <stationNameList.size();k++) {
  785 + } else {
  786 + Point p1 = new Point(Double.parseDouble(jd), Double.parseDouble(wd));
  787 + for (int k = 0; k < stationNameList.size(); k++) {
726 788 String bJwpoints[] = stationNameList.get(k)[0].toString().split(" ");
727   - Point p2 = new Point(Double.parseDouble(bJwpoints[0]),Double.parseDouble(bJwpoints[1]));
  789 + Point p2 = new Point(Double.parseDouble(bJwpoints[0]), Double.parseDouble(bJwpoints[1]));
728 790 double jl = GeoUtils.getDistance(p1, p2);
729   - if(jl<=60d) {
  791 + if (jl <= 60d) {
730 792 rsM.put("id", stationNameList.get(k)[1]);
731 793 temp = true;
732 794 break;
733 795 }
734 796 }
735 797 }
736   - }
  798 + }
737 799 rsM.put("isHave", temp);
738 800 return rsM;
739 801 }
740   -
  802 +
741 803 /**
742 804 * @Description :TODO(新增站点保存)
743 805 *
744 806 * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;
745 807 *
746   - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
  808 + * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
747 809 *
748   - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
  810 + * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
749 811 *
750   - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
751   - *
752   - * versions:版本号;x:城建坐标x;y:城建坐标y>
  812 + * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
  813 + *
  814 + * versions:版本号;x:城建坐标x;y:城建坐标y>
753 815 *
754 816 * @return Map<String, Object> <SUCCESS ; ERROR>
755 817 */
... ... @@ -767,15 +829,16 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
767 829 // 行业编码
768 830 String industryCode = map.get("industryCode").equals("") ? "" : map.get("industryCode").toString();
769 831 // 方向
770   - Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
  832 + Integer directions = map.get("directions").equals("") ? null
  833 + : Integer.parseInt(map.get("directions").toString());
771 834 // 原坐标点
772 835 String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString();
773 836 String bJwpointsArray[] = null;
774   - if(bJwpoints!=null) {
  837 + if (bJwpoints != null) {
775 838 bJwpointsArray = bJwpoints.split(" ");
776 839 }
777   - List<Object[]> stationNameList = repository.findStationName(directions,zdmc);
778   - Map<String, Object> isHaveMap = isHaveStationname(bJwpointsArray[0],bJwpointsArray[1],stationNameList);
  840 + List<Object[]> stationNameList = repository.findStationName(directions, zdmc);
  841 + Map<String, Object> isHaveMap = isHaveStationname(bJwpointsArray[0], bJwpointsArray[1], stationNameList);
779 842 // 是否撤销
780 843 Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
781 844 // 版本
... ... @@ -793,9 +856,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
793 856 // 创建人
794 857 Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
795 858 // 修改人
796   - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
  859 + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
797 860 // 城建坐标经度
798   - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
  861 + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
799 862 // 城建坐标纬度
800 863 Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
801 864 // 道路编码
... ... @@ -806,46 +869,48 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
806 869 Float gLonx = null;
807 870 // WGS纬度
808 871 Float gLaty = null;
809   - if(bJwpointsArray.length>0) {
810   - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
811   - gLonx = (float)resultPoint.getLng();
812   - gLaty = (float)resultPoint.getLat();
  872 + if (bJwpointsArray.length > 0) {
  873 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0], bJwpointsArray[1]);
  874 + gLonx = (float) resultPoint.getLng();
  875 + gLaty = (float) resultPoint.getLat();
813 876 }
814 877 // 多边形原坐标点集合
815 878 String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
816 879 // 多边形WGS坐标点集合
817   - String gPloygonGrid ="";
818   - if(!bPloygonGrid.equals("")) {
  880 + String gPloygonGrid = "";
  881 + if (!bPloygonGrid.equals("")) {
819 882 String bPloygonGridArray[] = bPloygonGrid.split(",");
820 883 int bLen_ = bPloygonGridArray.length;
821   - for(int b = 0 ;b<bLen_;b++) {
822   - String tempArray[]= bPloygonGridArray[b].split(" ");
823   - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
824   - if(b==0) {
825   - gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
826   - }else {
827   - gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
828   - }
  884 + for (int b = 0; b < bLen_; b++) {
  885 + String tempArray[] = bPloygonGridArray[b].split(" ");
  886 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0], tempArray[1]);
  887 + if (b == 0) {
  888 + gPloygonGrid = String.valueOf(resultPoint.getLng()) + " "
  889 + + String.valueOf(resultPoint.getLat());
  890 + } else {
  891 + gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " "
  892 + + String.valueOf(resultPoint.getLat());
  893 + }
829 894 }
830 895 }
831   - if(bPloygonGrid.equals(""))
  896 + if (bPloygonGrid.equals(""))
832 897 bPloygonGrid = null;
833 898 else
834   - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
835   - if(gPloygonGrid.equals(""))
  899 + bPloygonGrid = "POLYGON((" + bPloygonGrid + "))";
  900 + if (gPloygonGrid.equals(""))
836 901 gPloygonGrid = null;
837 902 else
838   - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
  903 + gPloygonGrid = "POLYGON((" + gPloygonGrid + "))";
839 904 // 保存站点
840   - repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints,
841   - gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius,
842   - shapesType, versions, descriptions, createBy, updateBy,stationId);
  905 + repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, gPloygonGrid,
  906 + bPloygonGrid, destroy, radius, shapesType, versions, descriptions, createBy, updateBy, stationId);
843 907 Station station = repository.findById(stationId).get();
844   -
845   - if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) {
  908 +
  909 + if (map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) {
846 910 StationRoute arg0 = new StationRoute();
847 911 // 距离
848   - Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString());
  912 + Double distances = map.get("distances").equals("") ? 0.0d
  913 + : Double.parseDouble(map.get("distances").toString());
849 914 // 时间
850 915 Double toTime = map.get("toTime").equals("") ? 0.0d : Double.parseDouble(map.get("toTime").toString());
851 916 // 站点路由名称
... ... @@ -855,14 +920,15 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
855 920 // 线路信息
856 921 Line resultLine = lineRepository.findById(line).get();
857 922 // 站点路由序号
858   - String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? "" : map.get("stationRouteCode").toString();
  923 + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? ""
  924 + : map.get("stationRouteCode").toString();
859 925 // 站点类型
860 926 String stationMark = map.get("stationMark").equals("") ? "" : map.get("stationMark").toString();
861 927 Integer stationRouteCode = null;
862   - if(stationRouteCodeStr!="") {
863   - String stationRouteCodeArray [] = stationRouteCodeStr.split("_");
864   - stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString())+1;
865   - }else {
  928 + if (stationRouteCodeStr != "") {
  929 + String stationRouteCodeArray[] = stationRouteCodeStr.split("_");
  930 + stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString()) + 1;
  931 + } else {
866 932 stationRouteCode = 100;
867 933 }
868 934 // 线路
... ... @@ -893,10 +959,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
893 959 arg0.setDescriptions(descriptions);
894 960 routeRepository.stationUpdStationRouteCode(line, directions, stationRouteCode);
895 961 routeRepository.save(arg0);
896   - }else {
  962 + } else {
897 963 LsStationRoute arg0 = new LsStationRoute();
898 964 // 距离
899   - Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString());
  965 + Double distances = map.get("distances").equals("") ? 0.0d
  966 + : Double.parseDouble(map.get("distances").toString());
900 967 // 时间
901 968 Double toTime = map.get("toTime").equals("") ? 0.0d : Double.parseDouble(map.get("toTime").toString());
902 969 // 站点路由名称
... ... @@ -906,14 +973,15 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
906 973 // 线路信息
907 974 Line resultLine = lineRepository.findById(line).get();
908 975 // 站点路由序号
909   - String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? "" : map.get("stationRouteCode").toString();
  976 + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? ""
  977 + : map.get("stationRouteCode").toString();
910 978 // 站点类型
911 979 String stationMark = map.get("stationMark").equals("") ? "" : map.get("stationMark").toString();
912 980 Integer stationRouteCode = null;
913   - if(stationRouteCodeStr!="") {
914   - String stationRouteCodeArray [] = stationRouteCodeStr.split("_");
915   - stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString())+1;
916   - }else {
  981 + if (stationRouteCodeStr != "") {
  982 + String stationRouteCodeArray[] = stationRouteCodeStr.split("_");
  983 + stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString()) + 1;
  984 + } else {
917 985 stationRouteCode = 100;
918 986 }
919 987 // 线路
... ... @@ -945,9 +1013,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
945 1013 lsStationRouteRepository.stationUpdStationRouteCode(line, directions, stationRouteCode);
946 1014 lsStationRouteRepository.save(arg0);
947 1015 }
948   -
949   -
950   -
  1016 +
951 1017 resultMap.put("status", ResponseCode.SUCCESS);
952 1018 } catch (Exception e) {
953 1019 resultMap.put("status", ResponseCode.ERROR);
... ... @@ -955,7 +1021,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
955 1021 }
956 1022 return resultMap;
957 1023 }
958   -
  1024 +
959 1025 /**
960 1026 * @Description :TODO(新增缓存站点保存)
961 1027 */
... ... @@ -965,30 +1031,31 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
965 1031 Map<String, Object> resultMap = new HashMap<String, Object>();
966 1032 try {
967 1033 // 站点编码 , 行业编码
968   - String stationCod = "",industryCode = "";
  1034 + String stationCod = "", industryCode = "";
969 1035 // 站点ID
970 1036 Integer stationId = null;
971 1037 // 站点名称
972 1038 String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString();
973 1039 // 方向
974   - Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
  1040 + Integer directions = map.get("directions").equals("") ? null
  1041 + : Integer.parseInt(map.get("directions").toString());
975 1042 // 原坐标点
976 1043 String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString();
977 1044 String bJwpointsArray[] = null;
978   - if(bJwpoints!=null) {
  1045 + if (bJwpoints != null) {
979 1046 bJwpointsArray = bJwpoints.split(" ");
980 1047 }
981   - List<Object[]> stationNameList = repository.findStationName(directions,zdmc);
982   - Map<String, Object> isHaveMap = isHaveStationname(bJwpointsArray[0],bJwpointsArray[1],stationNameList);
  1048 + List<Object[]> stationNameList = repository.findStationName(directions, zdmc);
  1049 + Map<String, Object> isHaveMap = isHaveStationname(bJwpointsArray[0], bJwpointsArray[1], stationNameList);
983 1050 // 是否撤销
984 1051 Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
985 1052 // 版本
986 1053 Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
987 1054 // 说明
988 1055 String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
989   - if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) {
  1056 + if (Boolean.parseBoolean(isHaveMap.get("isHave").toString())) {
990 1057 stationId = Integer.parseInt(isHaveMap.get("id").toString());
991   - }else {
  1058 + } else {
992 1059 // 站点编码
993 1060 stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
994 1061 // 站点ID
... ... @@ -998,11 +1065,13 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
998 1065 // 图形类型
999 1066 String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
1000 1067 // 创建人
1001   - Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
  1068 + Integer createBy = map.get("createBy").equals("") ? null
  1069 + : Integer.parseInt(map.get("createBy").toString());
1002 1070 // 修改人
1003   - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
  1071 + Integer updateBy = map.get("updateBy").equals("") ? null
  1072 + : Integer.parseInt(map.get("updateBy").toString());
1004 1073 // 城建坐标经度
1005   - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
  1074 + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
1006 1075 // 城建坐标纬度
1007 1076 Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
1008 1077 // 道路编码
... ... @@ -1013,47 +1082,50 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1013 1082 Float gLonx = null;
1014 1083 // WGS纬度
1015 1084 Float gLaty = null;
1016   - if(bJwpointsArray.length>0) {
1017   - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
1018   - gLonx = (float)resultPoint.getLng();
1019   - gLaty = (float)resultPoint.getLat();
  1085 + if (bJwpointsArray.length > 0) {
  1086 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0], bJwpointsArray[1]);
  1087 + gLonx = (float) resultPoint.getLng();
  1088 + gLaty = (float) resultPoint.getLat();
1020 1089 }
1021 1090 // 多边形原坐标点集合
1022 1091 String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
1023 1092 // 多边形WGS坐标点集合
1024   - String gPloygonGrid ="";
1025   - if(!bPloygonGrid.equals("")) {
  1093 + String gPloygonGrid = "";
  1094 + if (!bPloygonGrid.equals("")) {
1026 1095 String bPloygonGridArray[] = bPloygonGrid.split(",");
1027 1096 int bLen_ = bPloygonGridArray.length;
1028   - for(int b = 0 ;b<bLen_;b++) {
1029   - String tempArray[]= bPloygonGridArray[b].split(" ");
1030   - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
1031   - if(b==0) {
1032   - gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
1033   - }else {
1034   - gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
1035   - }
  1097 + for (int b = 0; b < bLen_; b++) {
  1098 + String tempArray[] = bPloygonGridArray[b].split(" ");
  1099 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0], tempArray[1]);
  1100 + if (b == 0) {
  1101 + gPloygonGrid = String.valueOf(resultPoint.getLng()) + " "
  1102 + + String.valueOf(resultPoint.getLat());
  1103 + } else {
  1104 + gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " "
  1105 + + String.valueOf(resultPoint.getLat());
  1106 + }
1036 1107 }
1037 1108 }
1038   - if(bPloygonGrid.equals(""))
  1109 + if (bPloygonGrid.equals(""))
1039 1110 bPloygonGrid = null;
1040 1111 else
1041   - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
1042   - if(gPloygonGrid.equals(""))
  1112 + bPloygonGrid = "POLYGON((" + bPloygonGrid + "))";
  1113 + if (gPloygonGrid.equals(""))
1043 1114 gPloygonGrid = null;
1044 1115 else
1045   - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
  1116 + gPloygonGrid = "POLYGON((" + gPloygonGrid + "))";
1046 1117 // 保存站点
1047   - repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints,
1048   - gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius,
1049   - shapesType, versions, descriptions, createBy, updateBy,stationId);
  1118 + repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y,
  1119 + gPloygonGrid, bPloygonGrid, destroy, radius, shapesType, versions, descriptions, createBy,
  1120 + updateBy, stationId);
1050 1121 }
1051 1122 Station station = repository.findById(stationId).get();
1052 1123 StationRouteCache arg0 = new StationRouteCache();
1053 1124 // 行业编码
1054 1125 industryCode = map.get("industryCode").equals("") ? "" : map.get("industryCode").toString();
1055 1126 // 距离
1056   - Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString());
  1127 + Double distances = map.get("distances").equals("") ? 0.0d
  1128 + : Double.parseDouble(map.get("distances").toString());
1057 1129 // 时间
1058 1130 Double toTime = map.get("toTime").equals("") ? 0.0d : Double.parseDouble(map.get("toTime").toString());
1059 1131 // 站点路由名称
... ... @@ -1063,14 +1135,15 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1063 1135 // 线路信息
1064 1136 Line resultLine = lineRepository.findById(line).get();
1065 1137 // 站点路由序号
1066   - String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? "" : map.get("stationRouteCode").toString();
  1138 + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? ""
  1139 + : map.get("stationRouteCode").toString();
1067 1140 // 站点类型
1068 1141 String stationMark = map.get("stationMark").equals("") ? "" : map.get("stationMark").toString();
1069 1142 Integer stationRouteCode = null;
1070   - if(stationRouteCodeStr!="") {
1071   - String stationRouteCodeArray [] = stationRouteCodeStr.split("_");
1072   - stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString())+1;
1073   - }else {
  1143 + if (stationRouteCodeStr != "") {
  1144 + String stationRouteCodeArray[] = stationRouteCodeStr.split("_");
  1145 + stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString()) + 1;
  1146 + } else {
1074 1147 stationRouteCode = 100;
1075 1148 }
1076 1149 // 线路
... ... @@ -1109,19 +1182,19 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1109 1182 }
1110 1183 return resultMap;
1111 1184 }
1112   -
  1185 +
1113 1186 /**
1114 1187 * @Description :TODO(更新站点保存)
1115 1188 *
1116 1189 * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;
1117 1190 *
1118   - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
  1191 + * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
1119 1192 *
1120   - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
  1193 + * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
1121 1194 *
1122   - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
1123   - *
1124   - * versions:版本号;x:城建坐标x;y:城建坐标y>
  1195 + * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
  1196 + *
  1197 + * versions:版本号;x:城建坐标x;y:城建坐标y>
1125 1198 *
1126 1199 * @return Map<String, Object> <SUCCESS ; ERROR>
1127 1200 */
... ... @@ -1130,7 +1203,8 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1130 1203 Map<String, Object> resultMap = new HashMap<String, Object>();
1131 1204 try {
1132 1205 // 站点Id
1133   - Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString());
  1206 + Integer stationId = map.get("stationId").equals("") ? null
  1207 + : Integer.parseInt(map.get("stationId").toString());
1134 1208 String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
1135 1209 String industryCode = map.get("industryCode").equals("") ? "" : map.get("industryCode").toString();
1136 1210 String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString();
... ... @@ -1138,22 +1212,22 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1138 1212 String stationRouteName = map.get("stationName").equals("") ? "" : map.get("stationName").toString();
1139 1213 // 所在道路编码
1140 1214 String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
1141   - // 经纬坐标类型
  1215 + // 经纬坐标类型
1142 1216 String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
1143 1217 // 百度经纬度坐标
1144 1218 String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString();
1145   - String bJwpointsArray[] =null;
1146   - if(bJwpoints!=null) {
  1219 + String bJwpointsArray[] = null;
  1220 + if (bJwpoints != null) {
1147 1221 bJwpointsArray = bJwpoints.split(" ");
1148 1222 }
1149 1223 // WGS经纬度
1150 1224 Float gLonx = null;
1151 1225 // WGS纬度
1152 1226 Float gLaty = null;
1153   - if(bJwpointsArray.length>0) {
1154   - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
1155   - gLonx = (float)resultPoint.getLng();
1156   - gLaty = (float)resultPoint.getLat();
  1227 + if (bJwpointsArray.length > 0) {
  1228 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0], bJwpointsArray[1]);
  1229 + gLonx = (float) resultPoint.getLng();
  1230 + gLaty = (float) resultPoint.getLat();
1157 1231 }
1158 1232 // 图形类型
1159 1233 String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
... ... @@ -1162,69 +1236,75 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1162 1236 // 多边形空间原坐标坐标点集合
1163 1237 String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
1164 1238 // 多边形WGS坐标点集合
1165   - String gPloygonGrid ="";
1166   - if(!bPloygonGrid.equals("")) {
  1239 + String gPloygonGrid = "";
  1240 + if (!bPloygonGrid.equals("")) {
1167 1241 String bPloygonGridArray[] = bPloygonGrid.split(",");
1168 1242 int bLen_ = bPloygonGridArray.length;
1169   - for(int b = 0 ;b<bLen_;b++) {
1170   - String tempArray[]= bPloygonGridArray[b].split(" ");
1171   - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
1172   - if(b==0) {
1173   - gPloygonGrid = resultPoint.getLng() + " " + resultPoint.getLat();
1174   - }else {
1175   - gPloygonGrid = gPloygonGrid + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
1176   - }
  1243 + for (int b = 0; b < bLen_; b++) {
  1244 + String tempArray[] = bPloygonGridArray[b].split(" ");
  1245 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0], tempArray[1]);
  1246 + if (b == 0) {
  1247 + gPloygonGrid = resultPoint.getLng() + " " + resultPoint.getLat();
  1248 + } else {
  1249 + gPloygonGrid = gPloygonGrid + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
  1250 + }
1177 1251 }
1178 1252 }
1179   - if(bPloygonGrid.equals(""))
  1253 + if (bPloygonGrid.equals(""))
1180 1254 bPloygonGrid = null;
1181 1255 else
1182   - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
1183   -
1184   - if(gPloygonGrid.equals(""))
  1256 + bPloygonGrid = "POLYGON((" + bPloygonGrid + "))";
  1257 +
  1258 + if (gPloygonGrid.equals(""))
1185 1259 gPloygonGrid = null;
1186 1260 else
1187   - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
  1261 + gPloygonGrid = "POLYGON((" + gPloygonGrid + "))";
1188 1262 // 是否撤销
1189 1263 Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
1190 1264 // 版本号
1191 1265 Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
1192 1266 // 描述与说明
1193 1267 String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
1194   - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
1195   - Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
  1268 + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
  1269 + Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
1196 1270 // 更新
1197   - repository.stationUpdate(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPloygonGrid, gPloygonGrid, destroy, radius, shapesType, versions, descriptions, stationId);
  1271 + repository.stationUpdate(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPloygonGrid,
  1272 + gPloygonGrid, destroy, radius, shapesType, versions, descriptions, stationId);
1198 1273 // 站点路由Id
1199   - Integer stationRouteId = map.get("stationRouteId").equals("") ? null : Integer.parseInt(map.get("stationRouteId").toString());
  1274 + Integer stationRouteId = map.get("stationRouteId").equals("") ? null
  1275 + : Integer.parseInt(map.get("stationRouteId").toString());
1200 1276  
1201   - Integer LineId = map.get("stationRouteLine").equals("") ? null : Integer.parseInt(map.get("stationRouteLine").toString());
  1277 + Integer LineId = map.get("stationRouteLine").equals("") ? null
  1278 + : Integer.parseInt(map.get("stationRouteLine").toString());
1202 1279 String stationMark = map.get("stationMark").equals("") ? null : map.get("stationMark").toString();
1203   - Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString());
  1280 + Double distances = map.get("distances").equals("") ? 0.0d
  1281 + : Double.parseDouble(map.get("distances").toString());
1204 1282 Double toTime = map.get("toTime").equals("") ? 0.0d : Double.parseDouble(map.get("toTime").toString());
1205   - Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
  1283 + Integer directions = map.get("directions").equals("") ? null
  1284 + : Integer.parseInt(map.get("directions").toString());
1206 1285 Station station = repository.findById(stationId).get();
1207 1286 Line line = lineRepository.findById(LineId).get();
1208   -
1209   - if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) {
  1287 +
  1288 + if (map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) {
1210 1289 StationRoute resultS = routeRepository.findById(stationRouteId).get();
1211 1290 // 站点路由序号
1212   - String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null : map.get("stationRouteCode").toString();
  1291 + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null
  1292 + : map.get("stationRouteCode").toString();
1213 1293 Integer stationRouteCode = null;
1214   - if(stationRouteCodeStr!=null) {
1215   - String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
1216   - int old_code = resultS.getStationRouteCode();
1217   - int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString())+100;
1218   - if(new_code==old_code){
1219   - stationRouteCode = new_code;
1220   - }else {
1221   - stationRouteCode = new_code-100+1;
1222   - }
1223   - }else {
  1294 + if (stationRouteCodeStr != null) {
  1295 + String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
  1296 + int old_code = resultS.getStationRouteCode();
  1297 + int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString()) + 100;
  1298 + if (new_code == old_code) {
  1299 + stationRouteCode = new_code;
  1300 + } else {
  1301 + stationRouteCode = new_code - 100 + 1;
  1302 + }
  1303 + } else {
1224 1304 stationRouteCode = resultS.getStationRouteCode();
1225 1305 }
1226 1306 stationRouteCode = stationRouteCode == null ? 100 : stationRouteCode;
1227   -
  1307 +
1228 1308 StationRoute stationRoute = new StationRoute();
1229 1309 stationRoute.setStationName(stationRouteName);
1230 1310 stationRoute.setId(stationRouteId);
... ... @@ -1242,26 +1322,27 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1242 1322 stationRoute.setDestroy(destroy);
1243 1323 stationRoute.setDescriptions(descriptions);
1244 1324 routeRepository.save(stationRoute);
1245   - }else if(Integer.parseInt(map.get("status").toString()) == 2){
1246   -
  1325 + } else if (Integer.parseInt(map.get("status").toString()) == 2) {
  1326 +
1247 1327 LsStationRoute resultS = lsStationRouteRepository.findById(stationRouteId).get();
1248 1328 // 站点路由序号
1249   - String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null : map.get("stationRouteCode").toString();
  1329 + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null
  1330 + : map.get("stationRouteCode").toString();
1250 1331 Integer stationRouteCode = null;
1251   - if(stationRouteCodeStr!=null) {
1252   - String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
1253   - int old_code = resultS.getStationRouteCode();
1254   - int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString())+100;
1255   - if(new_code==old_code){
1256   - stationRouteCode = new_code;
1257   - }else {
1258   - stationRouteCode = new_code-100+1;
1259   - }
1260   - }else {
  1332 + if (stationRouteCodeStr != null) {
  1333 + String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
  1334 + int old_code = resultS.getStationRouteCode();
  1335 + int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString()) + 100;
  1336 + if (new_code == old_code) {
  1337 + stationRouteCode = new_code;
  1338 + } else {
  1339 + stationRouteCode = new_code - 100 + 1;
  1340 + }
  1341 + } else {
1261 1342 stationRouteCode = resultS.getStationRouteCode();
1262 1343 }
1263 1344 stationRouteCode = stationRouteCode == null ? 100 : stationRouteCode;
1264   -
  1345 +
1265 1346 LsStationRoute stationRoute = new LsStationRoute();
1266 1347 stationRoute.setStationName(stationRouteName);
1267 1348 stationRoute.setId(stationRouteId);
... ... @@ -1280,8 +1361,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1280 1361 stationRoute.setDescriptions(descriptions);
1281 1362 lsStationRouteRepository.save(stationRoute);
1282 1363 }
1283   -
1284   -
  1364 +
1285 1365 resultMap.put("status", ResponseCode.SUCCESS);
1286 1366 } catch (Exception e) {
1287 1367 resultMap.put("status", ResponseCode.ERROR);
... ... @@ -1290,47 +1370,46 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1290 1370 return resultMap;
1291 1371 }
1292 1372  
1293   -
1294 1373 /** 百度坐标转WGS坐标 */
1295   - public Location FromBDPointToWGSPoint(String bLonx,String bLatx) {
1296   -
  1374 + public Location FromBDPointToWGSPoint(String bLonx, String bLatx) {
  1375 +
1297 1376 double lng = Double.parseDouble(bLonx);
1298   -
  1377 +
1299 1378 double lat = Double.parseDouble(bLatx);
1300   -
  1379 +
1301 1380 Location bdLoc = TransGPS.LocationMake(lng, lat);
1302   -
  1381 +
1303 1382 Location location = TransGPS.bd_decrypt(bdLoc);
1304   -
  1383 +
1305 1384 Location WGSPoint = TransGPS.transformFromGCJToWGS(location);
1306   -
  1385 +
1307 1386 return WGSPoint;
1308   -
  1387 +
1309 1388 }
1310   -
  1389 +
1311 1390 @Transactional
1312 1391 @Override
1313 1392 public Map<String, Object> manualSave(Map<String, Object> map) {
1314   - Map<String, Object> resultMap = new HashMap<String,Object>();
  1393 + Map<String, Object> resultMap = new HashMap<String, Object>();
1315 1394 try {
1316 1395 // 站点信息字符传
1317   - String stationJSON = map.get("stationJSON").equals("") ? "" : map.get("stationJSON").toString();
1318   - // 路段信息字符串
1319   - String sectionJSON = map.get("sectionJSON").equals("") ? "" : map.get("sectionJSON").toString();
1320   - // 方向
1321   - int directions = Integer.parseInt(map.get("directions").toString());
1322   - // 是否撤销
1323   - int destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
1324   - // 版本
1325   - int versions = map.get("versions").equals("") ? 0 : Integer.parseInt(map.get("versions").toString());
  1396 + String stationJSON = map.get("stationJSON").equals("") ? "" : map.get("stationJSON").toString();
  1397 + // 路段信息字符串
  1398 + String sectionJSON = map.get("sectionJSON").equals("") ? "" : map.get("sectionJSON").toString();
  1399 + // 方向
  1400 + int directions = Integer.parseInt(map.get("directions").toString());
  1401 + // 是否撤销
  1402 + int destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
  1403 + // 版本
  1404 + int versions = map.get("versions").equals("") ? 0 : Integer.parseInt(map.get("versions").toString());
1326 1405 // 坐标类型
1327   - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  1406 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
1328 1407 // 限速
1329 1408 String speedLimitStr = map.get("speedLimit").equals("") ? "" : map.get("speedLimit").toString();
1330 1409 // 线路ID
1331 1410 int lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString());
1332 1411 // 半径
1333   - int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
  1412 + int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
1334 1413 // 图形类型
1335 1414 String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
1336 1415 // 线路信息
... ... @@ -1341,19 +1420,21 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1341 1420 Double sectionDuration = 0.0d;
1342 1421 // 里程(上或者下)
1343 1422 double sumUpOrDownMileage = 0.0d;
1344   - Map<String, Object> resultSaveMapm = new HashMap<String,Object>();
  1423 + Map<String, Object> resultSaveMapm = new HashMap<String, Object>();
1345 1424 String baseRes = map.get("baseRes").equals("") ? "" : map.get("baseRes").toString();
1346   - if(!stationJSON.equals("")) {
  1425 + if (!stationJSON.equals("")) {
1347 1426 // 保存站点与站点路由信息
1348   - resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine,baseRes);
  1427 + resultSaveMapm = savaStationAndStationRouteInfo(stationJSON, sectionDistance, sectionDuration, dbType,
  1428 + radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine, baseRes);
1349 1429 }
1350 1430 // 路段长度
1351 1431 sectionDistance = Double.valueOf(resultSaveMapm.get("sectionDistance").toString());
1352 1432 // 路段时长
1353 1433 sectionDuration = Double.valueOf(resultSaveMapm.get("sectionDuration").toString());
1354 1434 // 如果路段信息JSON字符串不为空
1355   - if(!sectionJSON.equals("")) {
1356   - manualSaveSectionAndSectionRoute(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType, versions, resultLine, destroy, directions);
  1435 + if (!sectionJSON.equals("")) {
  1436 + manualSaveSectionAndSectionRoute(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType,
  1437 + versions, resultLine, destroy, directions);
1357 1438 }
1358 1439 // 里程
1359 1440 sumUpOrDownMileage = Double.valueOf(resultSaveMapm.get("sumUpOrDownMileage").toString());
... ... @@ -1361,7 +1442,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1361 1442 sumUpOrDownMileage = s.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
1362 1443 // 更新里程
1363 1444 // updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
1364   - if(directions==0) {
  1445 + if (directions == 0) {
1365 1446 // lineUpdateStationName(resultLine);
1366 1447 }
1367 1448 resultMap.put("status", ResponseCode.SUCCESS);
... ... @@ -1370,98 +1451,127 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1370 1451 resultMap.put("status", ResponseCode.ERROR);
1371 1452 logger.error("save erro.", e);
1372 1453 }
1373   -
  1454 +
1374 1455 return resultMap;
1375 1456 }
1376   -
1377   - public void manualSaveSectionAndSectionRoute(String sectionJSON,String speedLimitStr,double sectionDistance,
1378   -
1379   - double sectionTime,String dbType,Integer versions,Line resultLine,
1380   -
1381   - Integer destroy,Integer directions) {
1382   - // 转换成JSON数组
  1457 +
  1458 + public void manualSaveSectionAndSectionRoute(String sectionJSON, String speedLimitStr, double sectionDistance,
  1459 +
  1460 + double sectionTime, String dbType, Integer versions, Line resultLine,
  1461 +
  1462 + Integer destroy, Integer directions) {
  1463 +// 转换成JSON数组
1383 1464 JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);
1384   - // 更新路线前撤销线路原有路段
1385   - sectionRouteRepository.sectionRouteUpdDestroy(Integer.parseInt(resultLine.getLineCode()),directions);
1386   - // 遍历
1387   - for(int s = 0 ;s<sectionsArray.size();s++) {
1388   - // 站点名称
1389   - String sectionName = sectionsArray.getJSONObject(s).equals("") ? "" : sectionsArray.getJSONObject(s).get("sectionName").toString();
1390   - String pointsStr = sectionsArray.getJSONObject(s).equals("") ? "" : sectionsArray.getJSONObject(s).get("points").toString();
1391   - // 原始线状图形坐标集合
  1465 +// 更新路线前撤销线路原有路段
  1466 +// sectionRouteRepository.sectionRouteUpdDestroy(Integer.parseInt(resultLine.getLineCode()), directions);
  1467 +// 遍历
  1468 + for (int s = 0; s < sectionsArray.size(); s++) {
  1469 +// 站点名称
  1470 + String sectionName = sectionsArray.getJSONObject(s).equals("") ? ""
  1471 + : sectionsArray.getJSONObject(s).get("sectionName").toString();
  1472 + String pointsStr = sectionsArray.getJSONObject(s).equals("") ? ""
  1473 + : sectionsArray.getJSONObject(s).get("points").toString();
  1474 +// 原始线状图形坐标集合
1392 1475 String sectionsBpoints = "";
1393   - // WGS线状图形坐标集合
  1476 +// WGS线状图形坐标集合
1394 1477 String sectionsWJPpoints = "";
1395   - if(!pointsStr.equals("")){
  1478 + if (!pointsStr.equals("")) {
1396 1479 JSONArray pointsArray = JSONArray.parseArray(pointsStr);
1397   - for(int p =0;p<pointsArray.size();p++){
  1480 + for (int p = 0; p < pointsArray.size(); p++) {
1398 1481 String pointsLngStr = pointsArray.getJSONObject(p).get("lng").toString();
1399 1482 String pointsLatStr = pointsArray.getJSONObject(p).get("lat").toString();
1400   - Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);
  1483 + Location resultPoint = FromBDPointToWGSPoint(pointsLngStr, pointsLatStr);
1401 1484 String WGSLngStr = String.valueOf(resultPoint.getLng());
1402 1485 String WGSLatStr = String.valueOf(resultPoint.getLat());
1403   - if(p==pointsArray.size()-1){
  1486 + if (p == pointsArray.size() - 1) {
1404 1487 sectionsBpoints = sectionsBpoints + pointsLngStr + " " + pointsLatStr;
1405   - sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr;
1406   - }else {
1407   - sectionsBpoints = sectionsBpoints + pointsArray.getJSONObject(p).get("lng").toString() + " " +pointsArray.getJSONObject(p).get("lat").toString()+",";
1408   - sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr + ",";
  1488 + sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr;
  1489 + } else {
  1490 + sectionsBpoints = sectionsBpoints + pointsArray.getJSONObject(p).get("lng").toString() + " "
  1491 + + pointsArray.getJSONObject(p).get("lat").toString() + ",";
  1492 + sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr + ",";
1409 1493 }
1410 1494 }
1411 1495 }
1412 1496 long sectionMaxId = GetUIDAndCode.getSectionId();
1413 1497 String sectionCode = String.valueOf(sectionMaxId);
1414 1498 int sectionId = (int) (sectionMaxId);
1415   - // 交出路
  1499 +// 交出路
1416 1500 String crosesRoad = "";
1417   - // 终止节点
  1501 +// 终止节点
1418 1502 String endNode = "";
1419   - // 开始节点
  1503 +// 开始节点
1420 1504 String startNode = "";
1421   - // 中间节点
  1505 +// 中间节点
1422 1506 String middleNode = "";
1423   - // WGS坐标点集合
1424   - String gsectionVector = "LINESTRING(" + sectionsWJPpoints +")";
1425   - // 原坐标点集合
  1507 +// WGS坐标点集合
  1508 + String gsectionVector = "LINESTRING(" + sectionsWJPpoints + ")";
  1509 +// 原坐标点集合
1426 1510 String bsectionVector = "LINESTRING(" + sectionsBpoints + ")";
1427   - // 城建坐标点集合
  1511 +// 城建坐标点集合
1428 1512 String csectionVector = null;
1429   - // 路段类型
  1513 +// 路段类型
1430 1514 String sectionType = "";
1431   - // 道路编码
  1515 +// 道路编码
1432 1516 String roadCoding = "";
1433   - // 限速
  1517 +// 限速
1434 1518 double speedLimit = Double.parseDouble(speedLimitStr);
1435   - // 说明
  1519 +// 说明
1436 1520 String descriptions = "";
1437   - sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode,
1438   -
1439   - middleNode, gsectionVector, bsectionVector, sectionType, csectionVector,
1440   -
1441   - roadCoding, sectionDistance, sectionTime, dbType, speedLimit,
1442   -
1443   - descriptions, versions,sectionId);
  1521 + sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode,
  1522 +
  1523 + middleNode, gsectionVector, bsectionVector, sectionType, csectionVector,
  1524 +
  1525 + roadCoding, sectionDistance, sectionTime, dbType, speedLimit,
  1526 +
  1527 + descriptions, versions, sectionId);
  1528 +
  1529 +// 版本号(获取线路当前版本)
  1530 + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
  1531 +
1444 1532 Section section = sectionRepository.findById(Integer.parseInt(sectionCode)).get();
1445   - // 路段路由
1446   - SectionRoute sectionRoute = new SectionRoute();
1447   - // 路段序号
1448   - sectionRoute.setSectionrouteCode((s+1)*100);
1449   - // 线路编码
1450   - sectionRoute.setLineCode(resultLine.getLineCode());
1451   - // 路段ID
1452   - sectionRoute.setSection(section);
1453   - // 线路ID
1454   - sectionRoute.setLine(resultLine);
1455   - // 路段编码
1456   - sectionRoute.setSectionCode(sectionCode);
1457   - // 版本号(获取线路当前版本)
1458   - Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
1459   - sectionRoute.setVersions(version);
1460   - sectionRoute.setDestroy(destroy);
1461   - // 方向
1462   - sectionRoute.setDirections(directions);
1463   - // 保存路段
1464   - sectionRouteRepository.save(sectionRoute);
  1533 +
  1534 + if (versions == version) {
  1535 +
  1536 +// 路段路由
  1537 + SectionRoute sectionRoute = new SectionRoute();
  1538 +// 路段序号
  1539 + sectionRoute.setSectionrouteCode((s + 1) * 100);
  1540 +// 线路编码
  1541 + sectionRoute.setLineCode(resultLine.getLineCode());
  1542 +// 路段ID
  1543 + sectionRoute.setSection(section);
  1544 +// 线路ID
  1545 + sectionRoute.setLine(resultLine);
  1546 +// 路段编码
  1547 + sectionRoute.setSectionCode(sectionCode);
  1548 + sectionRoute.setVersions(versions);
  1549 + sectionRoute.setDestroy(destroy);
  1550 +// 方向
  1551 + sectionRoute.setDirections(directions);
  1552 +// 保存路段
  1553 + sectionRouteRepository.save(sectionRoute);
  1554 + } else {
  1555 +// 路段路由
  1556 + LsSectionRoute sectionRoute = new LsSectionRoute();
  1557 +// 路段序号
  1558 + sectionRoute.setSectionrouteCode((s + 1) * 100);
  1559 +// 线路编码
  1560 + sectionRoute.setLineCode(resultLine.getLineCode());
  1561 +// 路段ID
  1562 + sectionRoute.setSection(section);
  1563 +// 线路ID
  1564 + sectionRoute.setLine(resultLine);
  1565 +// 路段编码
  1566 + sectionRoute.setSectionCode(sectionCode);
  1567 + sectionRoute.setVersions(versions);
  1568 + sectionRoute.setDestroy(destroy);
  1569 +// 方向
  1570 + sectionRoute.setDirections(directions);
  1571 +// 保存路段
  1572 + lsSectionRouteRepository.save(sectionRoute);
  1573 + }
  1574 +
1465 1575 }
1466 1576 }
1467 1577  
... ... @@ -1477,10 +1587,10 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1477 1587 boolean isMatch = false;
1478 1588 double lat = Double.parseDouble(map.get("potion[lat]").toString());
1479 1589 double lon = Double.parseDouble(map.get("potion[lng]").toString());
1480   - Point point = new Point(lon, lat);
  1590 + Point point = new Point(lon, lat);
1481 1591 Iterable<Station> Stations = repository.findAll();
1482 1592 for (Station s : Stations) {
1483   - String libraryPointstr = s.getbJwpoints();
  1593 + String libraryPointstr = s.getbJwpoints();
1484 1594 String points[] = libraryPointstr.toString().split(" ");
1485 1595 Point center = new Point(Double.parseDouble(points[0]), Double.parseDouble(points[1]));
1486 1596 // 在60m内认为是同一个站点
... ... @@ -1508,7 +1618,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1508 1618 }
1509 1619 return map;
1510 1620 }
1511   -
  1621 +
1512 1622 /**
1513 1623 * @Description :TODO(把上传Gps生成的路线放到缓存表中)
1514 1624 *
... ... @@ -1518,26 +1628,26 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1518 1628 @Transactional
1519 1629 @Override
1520 1630 public Map<String, Object> cacheSave(Map<String, Object> map) {
1521   - Map<String, Object> resultMap = new HashMap<String,Object>();
  1631 + Map<String, Object> resultMap = new HashMap<String, Object>();
1522 1632 try {
1523 1633 // 站点信息字符传
1524   - String stationJSON = map.get("stationJSON").equals("") ? "" : map.get("stationJSON").toString();
1525   - // 路段信息字符串
1526   - String sectionJSON = map.get("sectionJSON").equals("") ? "" : map.get("sectionJSON").toString();
1527   - // 方向
1528   - int directions = Integer.parseInt(map.get("directions").toString());
1529   - // 是否撤销
1530   - int destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
1531   - // 版本
1532   - int versions = map.get("versions").equals("") ? 0 : Integer.parseInt(map.get("versions").toString());
  1634 + String stationJSON = map.get("stationJSON").equals("") ? "" : map.get("stationJSON").toString();
  1635 + // 路段信息字符串
  1636 + String sectionJSON = map.get("sectionJSON").equals("") ? "" : map.get("sectionJSON").toString();
  1637 + // 方向
  1638 + int directions = Integer.parseInt(map.get("directions").toString());
  1639 + // 是否撤销
  1640 + int destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
  1641 + // 版本
  1642 + int versions = map.get("versions").equals("") ? 0 : Integer.parseInt(map.get("versions").toString());
1533 1643 // 坐标类型
1534   - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  1644 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
1535 1645 // 限速
1536 1646 String speedLimitStr = map.get("speedLimit").equals("") ? "" : map.get("speedLimit").toString();
1537 1647 // 线路ID
1538 1648 int lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString());
1539 1649 // 半径
1540   - int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
  1650 + int radius = map.get("radius").equals("") ? 0 : Integer.parseInt(map.get("radius").toString());
1541 1651 // 图形类型
1542 1652 String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
1543 1653 // 线路信息
... ... @@ -1548,20 +1658,23 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1548 1658 Double sectionDuration = 0.0d;
1549 1659 // 里程(上或者下)
1550 1660 double sumUpOrDownMileage = 0.0d;
1551   - Map<String, Object> resultSaveMapm = new HashMap<String,Object>();
  1661 + Map<String, Object> resultSaveMapm = new HashMap<String, Object>();
1552 1662 String baseRes = map.get("baseRes").equals("") ? "" : map.get("baseRes").toString();
1553   -
1554   - if(!stationJSON.equals("")) {
  1663 +
  1664 + if (!stationJSON.equals("")) {
1555 1665 // 保存站点与站点路由信息
1556   - resultSaveMapm = savaStationAndStationRouteCacheInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine,baseRes);
  1666 + resultSaveMapm = savaStationAndStationRouteCacheInfo(stationJSON, sectionDistance, sectionDuration,
  1667 + dbType, radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine,
  1668 + baseRes);
1557 1669 }
1558 1670 // 路段长度
1559 1671 sectionDistance = Double.valueOf(resultSaveMapm.get("sectionDistance").toString());
1560 1672 // 路段时长
1561 1673 sectionDuration = Double.valueOf(resultSaveMapm.get("sectionDuration").toString());
1562 1674 // 如果路段信息JSON字符串不为空
1563   - if(!sectionJSON.equals("")) {
1564   - SaveSectionAndSectionRouteCache(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType, versions, resultLine, destroy, directions);
  1675 + if (!sectionJSON.equals("")) {
  1676 + SaveSectionAndSectionRouteCache(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType,
  1677 + versions, resultLine, destroy, directions);
1565 1678 }
1566 1679 // 里程
1567 1680 sumUpOrDownMileage = Double.valueOf(resultSaveMapm.get("sumUpOrDownMileage").toString());
... ... @@ -1569,7 +1682,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1569 1682 sumUpOrDownMileage = s.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
1570 1683 // 更新里程
1571 1684 // updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
1572   - if(directions==0) {
  1685 + if (directions == 0) {
1573 1686 // lineUpdateStationName(resultLine);
1574 1687 }
1575 1688 resultMap.put("status", ResponseCode.SUCCESS);
... ... @@ -1578,98 +1691,111 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1578 1691 resultMap.put("status", ResponseCode.ERROR);
1579 1692 logger.error("save erro.", e);
1580 1693 }
1581   -
  1694 +
1582 1695 return resultMap;
1583 1696 }
1584   -
  1697 +
1585 1698 /**
1586 1699 * @param isHaveId 存在站点的id
1587   - * @param isHave 是否存在站点
  1700 + * @param isHave 是否存在站点
1588 1701 * @Description :TODO(保存站点和缓存站点路由信息)
1589 1702 *
1590 1703 */
1591   - public Map<String, Object> savaStationAndStationRouteCacheInfo(String stationJSON,double sectionDistance,double sectionDuration,String dbType,
1592   - int radius,String shapesType,int destroy,int versions,double sumUpOrDownMileage,int directions,Line resultLine,String baseRes) throws Exception{
1593   - Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String,Object>();
  1704 + public Map<String, Object> savaStationAndStationRouteCacheInfo(String stationJSON, double sectionDistance,
  1705 + double sectionDuration, String dbType, int radius, String shapesType, int destroy, int versions,
  1706 + double sumUpOrDownMileage, int directions, Line resultLine, String baseRes) throws Exception {
  1707 + Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String, Object>();
1594 1708 JSONArray stationsArray = JSONArray.parseArray(stationJSON);
1595   - if(stationsArray.size()>0) {
  1709 + if (stationsArray.size() > 0) {
1596 1710 // 环线起点站
1597   - Station loopStartStation = new Station();
  1711 + Station loopStartStation = new Station();
1598 1712 // 更新路线前删除线路缓存站点
1599   - routeCacheRepository.stationRouteCacheDel(resultLine.getLineCode(),directions);
1600   - for(int i = 0;i <stationsArray.size();i++) {
  1713 + routeCacheRepository.stationRouteCacheDel(resultLine.getLineCode(), directions);
  1714 + for (int i = 0; i < stationsArray.size(); i++) {
1601 1715 // 站点名称
1602   - String stationName = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("name").toString();
1603   - Double distance = stationsArray.getJSONObject(i).get("distance").equals("") ? 0.0d : Double.parseDouble(stationsArray.getJSONObject(i).get("distance").toString());
  1716 + String stationName = stationsArray.getJSONObject(i).equals("") ? ""
  1717 + : stationsArray.getJSONObject(i).get("name").toString();
  1718 + Double distance = stationsArray.getJSONObject(i).get("distance").equals("") ? 0.0d
  1719 + : Double.parseDouble(stationsArray.getJSONObject(i).get("distance").toString());
1604 1720 // 转成公里
1605   - distance = distance/1000;
  1721 + distance = distance / 1000;
1606 1722 BigDecimal d = new BigDecimal(distance);
1607 1723 distance = d.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
1608   - sectionDistance= distance + sectionDistance;
1609   - Double duration = stationsArray.getJSONObject(i).get("duration").equals("") ? 0.0d : Double.parseDouble(stationsArray.getJSONObject(i).get("duration").toString());
  1724 + sectionDistance = distance + sectionDistance;
  1725 + Double duration = stationsArray.getJSONObject(i).get("duration").equals("") ? 0.0d
  1726 + : Double.parseDouble(stationsArray.getJSONObject(i).get("duration").toString());
1610 1727 // 转成分钟
1611   - duration = duration/60;
  1728 + duration = duration / 60;
1612 1729 BigDecimal t = new BigDecimal(duration);
1613 1730 duration = t.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
1614 1731 sectionDuration = duration + sectionDuration;
1615 1732 // 百度经纬度坐标
1616 1733 String bJwpoints = "";
1617 1734 // 百度坐标经度
1618   - String bLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lng").toString();
1619   - bLonx = bLonx==null || bLonx.equals("") ? "0" : bLonx;
  1735 + String bLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString())
  1736 + .get("lng").toString();
  1737 + bLonx = bLonx == null || bLonx.equals("") ? "0" : bLonx;
1620 1738 // 百度坐标纬度
1621   - String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString();
1622   - bLatx = bLatx==null || bLatx.equals("") ? "0" : bLatx;
  1739 + String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString())
  1740 + .get("lat").toString();
  1741 + bLatx = bLatx == null || bLatx.equals("") ? "0" : bLatx;
1623 1742 // List<Object[]> stationNameList = repository.findStationName(directions,stationName);
1624   - //Map<String, Object> isHaveMap = isHaveStationname(bLonx,bLatx,stationNameList);
  1743 + // Map<String, Object> isHaveMap =
  1744 + // isHaveStationname(bLonx,bLatx,stationNameList);
1625 1745 // 初始化站点对象
1626   - Station arg0 = new Station();
  1746 + Station arg0 = new Station();
1627 1747 // 站点编码
1628 1748 long stationCode = GetUIDAndCode.getStationId();
1629 1749 arg0.setStationCod(String.valueOf(stationCode));
1630   - arg0.setId((int)stationCode);
  1750 + arg0.setId((int) stationCode);
1631 1751 // 存在的点就不添加到数据库(起终点站重新添加站点)
1632   - if(Boolean.parseBoolean(stationsArray.getJSONObject(i).get("isHave").toString())) {
  1752 + if (Boolean.parseBoolean(stationsArray.getJSONObject(i).get("isHave").toString())) {
1633 1753 Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString());
1634 1754 Station station = repository.findById(stationId).get();
1635 1755 arg0.setDbType(dbType);
1636   - String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").toString();
1637   - String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").toString();
  1756 + String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1757 + .get("x").equals("") ? null
  1758 + : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1759 + .get("x").toString();
  1760 + String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1761 + .get("y").equals("") ? null
  1762 + : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1763 + .get("y").toString();
1638 1764 float gLonx = 0.0f;
1639 1765 float gLaty = 0.0f;
1640 1766 Location resultPoint = null;
1641   - if(baseRes.equals("No")){
  1767 + if (baseRes.equals("No")) {
1642 1768 /** BD to WGS坐标 */
1643   - resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
1644   - if(gLonxStr==null)
1645   - gLonx = (float)resultPoint.getLng();
  1769 + resultPoint = FromBDPointToWGSPoint(bLonx, bLatx);
  1770 + if (gLonxStr == null)
  1771 + gLonx = (float) resultPoint.getLng();
1646 1772 else
1647   - gLonx = Float.valueOf(gLonxStr);
1648   - if(gLatyStr==null)
1649   - gLaty = (float)resultPoint.getLat();
  1773 + gLonx = Float.valueOf(gLonxStr);
  1774 + if (gLatyStr == null)
  1775 + gLaty = (float) resultPoint.getLat();
1650 1776 else
1651   - gLaty = Float.valueOf(gLatyStr);
  1777 + gLaty = Float.valueOf(gLatyStr);
1652 1778 arg0.setgLonx(gLonx);
1653 1779 arg0.setgLaty(gLaty);
1654 1780 // 百度经纬度
1655 1781 bJwpoints = bLonx + " " + bLatx;
1656 1782 arg0.setbJwpoints(bJwpoints);
1657   - }else if(baseRes.equals("GCJ02")){
  1783 + } else if (baseRes.equals("GCJ02")) {
1658 1784 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
1659 1785 Location location = TransGPS.bd_encrypt(bdLoc);
1660 1786 String GCJLng = String.valueOf(location.getLng());
1661 1787 String GCJLat = String.valueOf(location.getLat());
1662   - resultPoint = FromBDPointToWGSPoint(GCJLng,GCJLat);
1663   - bJwpoints = GCJLng + " " +GCJLat;
1664   - arg0.setgLonx((float)location.getLng());
1665   - arg0.setgLaty((float)location.getLat());
  1788 + resultPoint = FromBDPointToWGSPoint(GCJLng, GCJLat);
  1789 + bJwpoints = GCJLng + " " + GCJLat;
  1790 + arg0.setgLonx((float) location.getLng());
  1791 + arg0.setgLaty((float) location.getLat());
1666 1792 arg0.setbJwpoints(bJwpoints);
1667   - }else if(baseRes.equals("BD09")){
  1793 + } else if (baseRes.equals("BD09")) {
1668 1794 resultPoint = FromBDPointToWGSPoint(gLonxStr, gLatyStr);
1669   - bJwpoints = gLonxStr+ " " + gLatyStr;
1670   - arg0.setgLonx((float)resultPoint.getLng());
1671   - arg0.setgLaty((float)resultPoint.getLat());
1672   - }else if(baseRes.equals("WGS84")){
  1795 + bJwpoints = gLonxStr + " " + gLatyStr;
  1796 + arg0.setgLonx((float) resultPoint.getLng());
  1797 + arg0.setgLaty((float) resultPoint.getLat());
  1798 + } else if (baseRes.equals("WGS84")) {
1673 1799 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
1674 1800 Location gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
1675 1801 Location bdEn = TransGPS.bd_encrypt(gcjLoc);
... ... @@ -1687,59 +1813,65 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1687 1813 arg0.setbJwpoints(bJwpoints);
1688 1814 // 引用查到站点的名字
1689 1815 arg0.setStationName(station.getStationName());
1690   - if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1816 + if (i == stationsArray.size() - 1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1691 1817 arg0 = loopStartStation;
1692 1818 } else {
1693 1819 repository.save(arg0);
1694   - if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1820 + if (i == 0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1695 1821 loopStartStation = arg0;
1696 1822 }
1697 1823 }
1698   - }else {
  1824 + } else {
1699 1825 arg0.setStationName(stationName);
1700 1826 // 原坐标类型
1701 1827 arg0.setDbType(dbType);
1702   - String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").toString();
1703   - String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").toString();
  1828 + String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1829 + .get("x").equals("") ? null
  1830 + : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1831 + .get("x").toString();
  1832 + String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1833 + .get("y").equals("") ? null
  1834 + : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString())
  1835 + .get("y").toString();
1704 1836 float gLonx = 0.0f;
1705 1837 float gLaty = 0.0f;
1706 1838 Location resultPoint = null;
1707   - if(baseRes.equals("No")){
  1839 + if (baseRes.equals("No")) {
1708 1840 /** BD to WGS坐标 */
1709   - resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
1710   - if(gLonxStr==null)
1711   - gLonx = (float)resultPoint.getLng();
1712   - else
1713   - gLonx = Float.valueOf(gLonxStr);
1714   - if(gLatyStr==null)
1715   - gLaty = (float)resultPoint.getLat();
1716   - else
1717   - gLaty = Float.valueOf(gLatyStr);
  1841 + resultPoint = FromBDPointToWGSPoint(bLonx, bLatx);
  1842 + if (gLonxStr == null)
  1843 + gLonx = (float) resultPoint.getLng();
  1844 + else
  1845 + gLonx = Float.valueOf(gLonxStr);
  1846 + if (gLatyStr == null)
  1847 + gLaty = (float) resultPoint.getLat();
  1848 + else
  1849 + gLaty = Float.valueOf(gLatyStr);
1718 1850 arg0.setgLonx(gLonx);
1719 1851 arg0.setgLaty(gLaty);
1720 1852 // 百度经纬度
1721 1853 bJwpoints = bLonx + " " + bLatx;
1722 1854 arg0.setbJwpoints(bJwpoints);
1723   - }else if(baseRes.equals("GCJ02")){
  1855 + } else if (baseRes.equals("GCJ02")) {
1724 1856 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
1725 1857 Location location = TransGPS.bd_encrypt(bdLoc);
1726 1858 String GCJLng = String.valueOf(location.getLng());
1727 1859 String GCJLat = String.valueOf(location.getLat());
1728   - resultPoint = FromBDPointToWGSPoint(GCJLng,GCJLat);
1729   - bJwpoints = GCJLng + " " +GCJLat;
1730   - arg0.setgLonx((float)location.getLng());
1731   - arg0.setgLaty((float)location.getLat());
  1860 + resultPoint = FromBDPointToWGSPoint(GCJLng, GCJLat);
  1861 + bJwpoints = GCJLng + " " + GCJLat;
  1862 + arg0.setgLonx((float) location.getLng());
  1863 + arg0.setgLaty((float) location.getLat());
1732 1864 arg0.setbJwpoints(bJwpoints);
1733   - }else if(baseRes.equals("BD09")){
  1865 + } else if (baseRes.equals("BD09")) {
1734 1866 resultPoint = FromBDPointToWGSPoint(gLonxStr, gLatyStr);
1735   - bJwpoints = gLonxStr+ " " + gLatyStr;
1736   - arg0.setgLonx((float)resultPoint.getLng());
1737   - arg0.setgLaty((float)resultPoint.getLat());
1738   - }else if(baseRes.equals("WGS84")){
  1867 + bJwpoints = gLonxStr + " " + gLatyStr;
  1868 + arg0.setgLonx((float) resultPoint.getLng());
  1869 + arg0.setgLaty((float) resultPoint.getLat());
  1870 + } else if (baseRes.equals("WGS84")) {
1739 1871 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
1740 1872 Location gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
1741 1873 Location bdEn = TransGPS.bd_encrypt(gcjLoc);
1742   - bJwpoints = String.valueOf(bdEn.getLng()) + " " + String.valueOf(bdEn.getLat());
  1874 + bJwpoints = String.valueOf(bdEn.getLng()) + " " + String.valueOf(bdEn.getLat());
1743 1875 arg0.setbJwpoints(bJwpoints);
1744 1876 arg0.setgLonx(Float.valueOf(gLonxStr));
1745 1877 arg0.setgLaty(Float.valueOf(gLatyStr));
... ... @@ -1752,38 +1884,38 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1752 1884 arg0.setVersions(versions);
1753 1885 arg0.setbJwpoints(bJwpoints);
1754 1886 // 插入站点信息
1755   - if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1887 + if (i == 0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1756 1888 loopStartStation = arg0;
1757 1889 repository.save(arg0);
1758   - } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1890 + } else if (i == stationsArray.size() - 1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1759 1891 arg0 = loopStartStation;
1760 1892 } else {
1761 1893 repository.save(arg0);
1762 1894 }
1763   -
  1895 +
1764 1896 }
1765 1897 // 站点路由对象
1766 1898 StationRouteCache route = new StationRouteCache();
1767 1899 // 站点名称
1768   - if(i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1)
  1900 + if (i == stationsArray.size() - 1 && resultLine.getLinePlayType() == 1)
1769 1901 route.setStationName(loopStartStation.getStationName());
1770 1902 else
1771 1903 route.setStationName(stationName);
1772 1904 route.setDistances(distance);
1773   - sumUpOrDownMileage = sumUpOrDownMileage + distance;
  1905 + sumUpOrDownMileage = sumUpOrDownMileage + distance;
1774 1906 route.setToTime(duration);
1775 1907 // 站点编码
1776 1908 route.setStationCode(arg0.getStationCod());
1777 1909 // 站点序号
1778   - route.setStationRouteCode((i+1)*100);
  1910 + route.setStationRouteCode((i + 1) * 100);
1779 1911 // 站点类型
1780   - if(i==0) {
  1912 + if (i == 0) {
1781 1913 // 起始站
1782 1914 route.setStationMark("B");
1783   - }else if(i==stationsArray.size()-1) {
  1915 + } else if (i == stationsArray.size() - 1) {
1784 1916 // 终点站
1785 1917 route.setStationMark("E");
1786   - }else {
  1918 + } else {
1787 1919 // 中途站
1788 1920 route.setStationMark("Z");
1789 1921 }
... ... @@ -1798,51 +1930,54 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1798 1930 // 线路编码
1799 1931 route.setLineCode(resultLine.getLineCode());
1800 1932 route.setDestroy(destroy);
1801   - // 插入站点路由信息
  1933 + // 插入站点路由信息
1802 1934 routeCacheRepository.save(route);
1803   -
  1935 +
1804 1936 }
1805 1937 paramsMeleageAndDistncDura.put("sumUpOrDownMileage", sumUpOrDownMileage);
1806 1938 paramsMeleageAndDistncDura.put("sectionDistance", sectionDistance);
1807 1939 paramsMeleageAndDistncDura.put("sectionDuration", sectionDuration);
1808   - paramsMeleageAndDistncDura.put("stationdata",stationsArray);
  1940 + paramsMeleageAndDistncDura.put("stationdata", stationsArray);
1809 1941 }
1810 1942 return paramsMeleageAndDistncDura;
1811 1943 }
1812   -
  1944 +
1813 1945 /**
1814 1946 * @Description :TODO(保存路段和缓存路段路由信息)
1815 1947 *
1816 1948 */
1817   - public void SaveSectionAndSectionRouteCache(String sectionJSON,String speedLimitStr,double sectionDistance, double sectionTime,
1818   - String dbType,Integer versions,Line resultLine,Integer destroy,Integer directions) {
  1949 + public void SaveSectionAndSectionRouteCache(String sectionJSON, String speedLimitStr, double sectionDistance,
  1950 + double sectionTime, String dbType, Integer versions, Line resultLine, Integer destroy, Integer directions) {
1819 1951 // 转换成JSON数组
1820 1952 JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);
1821 1953 // 更新路线前删除线路缓存路段
1822   - sectionRouteCacheRepository.sectionRouteCacheDel(resultLine.getLineCode(),directions);
  1954 + sectionRouteCacheRepository.sectionRouteCacheDel(resultLine.getLineCode(), directions);
1823 1955 // 遍历
1824   - for(int s = 0 ;s<sectionsArray.size();s++) {
  1956 + for (int s = 0; s < sectionsArray.size(); s++) {
1825 1957 // 站点名称
1826   - String sectionName = sectionsArray.getJSONObject(s).equals("") ? "" : sectionsArray.getJSONObject(s).get("sectionName").toString();
1827   - String pointsStr = sectionsArray.getJSONObject(s).equals("") ? "" : sectionsArray.getJSONObject(s).get("points").toString();
  1958 + String sectionName = sectionsArray.getJSONObject(s).equals("") ? ""
  1959 + : sectionsArray.getJSONObject(s).get("sectionName").toString();
  1960 + String pointsStr = sectionsArray.getJSONObject(s).equals("") ? ""
  1961 + : sectionsArray.getJSONObject(s).get("points").toString();
1828 1962 // 原始线状图形坐标集合
1829 1963 String sectionsBpoints = "";
1830 1964 // WGS线状图形坐标集合
1831 1965 String sectionsWJPpoints = "";
1832   - if(!pointsStr.equals("")){
  1966 + if (!pointsStr.equals("")) {
1833 1967 JSONArray pointsArray = JSONArray.parseArray(pointsStr);
1834   - for(int p =0;p<pointsArray.size();p++){
  1968 + for (int p = 0; p < pointsArray.size(); p++) {
1835 1969 String pointsLngStr = pointsArray.getJSONObject(p).get("lng").toString();
1836 1970 String pointsLatStr = pointsArray.getJSONObject(p).get("lat").toString();
1837   - Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);
  1971 + Location resultPoint = FromBDPointToWGSPoint(pointsLngStr, pointsLatStr);
1838 1972 String WGSLngStr = String.valueOf(resultPoint.getLng());
1839 1973 String WGSLatStr = String.valueOf(resultPoint.getLat());
1840   - if(p==pointsArray.size()-1){
  1974 + if (p == pointsArray.size() - 1) {
1841 1975 sectionsBpoints = sectionsBpoints + pointsLngStr + " " + pointsLatStr;
1842   - sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr;
1843   - }else {
1844   - sectionsBpoints = sectionsBpoints + pointsArray.getJSONObject(p).get("lng").toString() + " " +pointsArray.getJSONObject(p).get("lat").toString()+",";
1845   - sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr + ",";
  1976 + sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr;
  1977 + } else {
  1978 + sectionsBpoints = sectionsBpoints + pointsArray.getJSONObject(p).get("lng").toString() + " "
  1979 + + pointsArray.getJSONObject(p).get("lat").toString() + ",";
  1980 + sectionsWJPpoints = sectionsWJPpoints + WGSLngStr + " " + WGSLatStr + ",";
1846 1981 }
1847 1982 }
1848 1983 }
... ... @@ -1858,7 +1993,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1858 1993 // 中间节点
1859 1994 String middleNode = "";
1860 1995 // WGS坐标点集合
1861   - String gsectionVector = "LINESTRING(" + sectionsWJPpoints +")";
  1996 + String gsectionVector = "LINESTRING(" + sectionsWJPpoints + ")";
1862 1997 // 原坐标点集合
1863 1998 String bsectionVector = "LINESTRING(" + sectionsBpoints + ")";
1864 1999 // 城建坐标点集合
... ... @@ -1871,18 +2006,18 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1871 2006 double speedLimit = Double.parseDouble(speedLimitStr);
1872 2007 // 说明
1873 2008 String descriptions = "";
1874   - sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode,
1875   -
1876   - middleNode, gsectionVector, bsectionVector, sectionType, csectionVector,
1877   -
1878   - roadCoding, sectionDistance, sectionTime, dbType, speedLimit,
1879   -
1880   - descriptions, versions,sectionId);
  2009 + sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode,
  2010 +
  2011 + middleNode, gsectionVector, bsectionVector, sectionType, csectionVector,
  2012 +
  2013 + roadCoding, sectionDistance, sectionTime, dbType, speedLimit,
  2014 +
  2015 + descriptions, versions, sectionId);
1881 2016 Section section = sectionRepository.findById(Integer.parseInt(sectionCode)).get();
1882 2017 // 路段路由
1883 2018 SectionRouteCache sectionRoute = new SectionRouteCache();
1884 2019 // 路段序号
1885   - sectionRoute.setSectionrouteCode((s+1)*100);
  2020 + sectionRoute.setSectionrouteCode((s + 1) * 100);
1886 2021 // 线路编码
1887 2022 sectionRoute.setLineCode(resultLine.getLineCode());
1888 2023 // 路段ID
... ... @@ -1895,13 +2030,13 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1895 2030 sectionRoute.setVersions(versions);
1896 2031 sectionRoute.setDestroy(destroy);
1897 2032 // 方向
1898   - sectionRoute.setDirections(directions);
  2033 + sectionRoute.setDirections(directions);
1899 2034 // 保存路段
1900 2035 sectionRouteCacheRepository.save(sectionRoute);
1901 2036 }
1902   -
  2037 +
1903 2038 }
1904   -
  2039 +
1905 2040 /**
1906 2041 * @Description :TODO(更新缓存站点路由)
1907 2042 */
... ... @@ -1910,7 +2045,8 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1910 2045 Map<String, Object> resultMap = new HashMap<String, Object>();
1911 2046 try {
1912 2047 // 站点Id
1913   - Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString());
  2048 + Integer stationId = map.get("stationId").equals("") ? null
  2049 + : Integer.parseInt(map.get("stationId").toString());
1914 2050 String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
1915 2051 String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString();
1916 2052 // 行业编码
... ... @@ -1919,22 +2055,22 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1919 2055 String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString();
1920 2056 // 所在道路编码
1921 2057 String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
1922   - // 经纬坐标类型
  2058 + // 经纬坐标类型
1923 2059 String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
1924 2060 // 百度经纬度坐标
1925 2061 String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString();
1926   - String bJwpointsArray[] =null;
1927   - if(bJwpoints!=null) {
  2062 + String bJwpointsArray[] = null;
  2063 + if (bJwpoints != null) {
1928 2064 bJwpointsArray = bJwpoints.split(" ");
1929 2065 }
1930 2066 // WGS经纬度
1931 2067 Float gLonx = null;
1932 2068 // WGS纬度
1933 2069 Float gLaty = null;
1934   - if(bJwpointsArray.length>0) {
1935   - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
1936   - gLonx = (float)resultPoint.getLng();
1937   - gLaty = (float)resultPoint.getLat();
  2070 + if (bJwpointsArray.length > 0) {
  2071 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0], bJwpointsArray[1]);
  2072 + gLonx = (float) resultPoint.getLng();
  2073 + gLaty = (float) resultPoint.getLat();
1938 2074 }
1939 2075 // 图形类型
1940 2076 String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
... ... @@ -1943,63 +2079,69 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1943 2079 // 多边形空间原坐标坐标点集合
1944 2080 String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
1945 2081 // 多边形WGS坐标点集合
1946   - String gPloygonGrid ="";
1947   - if(!bPloygonGrid.equals("")) {
  2082 + String gPloygonGrid = "";
  2083 + if (!bPloygonGrid.equals("")) {
1948 2084 String bPloygonGridArray[] = bPloygonGrid.split(",");
1949 2085 int bLen_ = bPloygonGridArray.length;
1950   - for(int b = 0 ;b<bLen_;b++) {
1951   - String tempArray[]= bPloygonGridArray[b].split(" ");
1952   - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
1953   - if(b==0) {
1954   - gPloygonGrid = resultPoint.getLng() + " " + resultPoint.getLat();
1955   - }else {
1956   - gPloygonGrid = gPloygonGrid + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
1957   - }
  2086 + for (int b = 0; b < bLen_; b++) {
  2087 + String tempArray[] = bPloygonGridArray[b].split(" ");
  2088 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0], tempArray[1]);
  2089 + if (b == 0) {
  2090 + gPloygonGrid = resultPoint.getLng() + " " + resultPoint.getLat();
  2091 + } else {
  2092 + gPloygonGrid = gPloygonGrid + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
  2093 + }
1958 2094 }
1959 2095 }
1960   - if(bPloygonGrid.equals(""))
  2096 + if (bPloygonGrid.equals(""))
1961 2097 bPloygonGrid = null;
1962 2098 else
1963   - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
1964   -
1965   - if(gPloygonGrid.equals(""))
  2099 + bPloygonGrid = "POLYGON((" + bPloygonGrid + "))";
  2100 +
  2101 + if (gPloygonGrid.equals(""))
1966 2102 gPloygonGrid = null;
1967 2103 else
1968   - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
  2104 + gPloygonGrid = "POLYGON((" + gPloygonGrid + "))";
1969 2105 // 是否撤销
1970 2106 Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
1971 2107 // 版本号
1972 2108 Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
1973 2109 // 描述与说明
1974 2110 String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
1975   - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
1976   - Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
  2111 + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
  2112 + Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
1977 2113 // 更新
1978   - repository.stationUpdate(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPloygonGrid, gPloygonGrid, destroy, radius, shapesType, versions, descriptions, stationId);
  2114 + repository.stationUpdate(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPloygonGrid,
  2115 + gPloygonGrid, destroy, radius, shapesType, versions, descriptions, stationId);
1979 2116 // 站点路由Id
1980   - Integer stationRouteId = map.get("stationRouteId").equals("") ? null : Integer.parseInt(map.get("stationRouteId").toString());
  2117 + Integer stationRouteId = map.get("stationRouteId").equals("") ? null
  2118 + : Integer.parseInt(map.get("stationRouteId").toString());
1981 2119 StationRouteCache resultS = routeCacheRepository.findById(stationRouteId).get();
1982 2120 // 站点路由序号
1983   - String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null : map.get("stationRouteCode").toString();
  2121 + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null
  2122 + : map.get("stationRouteCode").toString();
1984 2123 Integer stationRouteCode = null;
1985   - if(stationRouteCodeStr!=null) {
1986   - String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
1987   - int old_code = resultS.getStationRouteCode();
1988   - int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString())+100;
1989   - if(new_code==old_code){
1990   - stationRouteCode = new_code;
1991   - }else {
1992   - stationRouteCode = new_code-100+1;
1993   - }
1994   - }else {
  2124 + if (stationRouteCodeStr != null) {
  2125 + String stationRouteCodeAraay[] = stationRouteCodeStr.split("_");
  2126 + int old_code = resultS.getStationRouteCode();
  2127 + int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString()) + 100;
  2128 + if (new_code == old_code) {
  2129 + stationRouteCode = new_code;
  2130 + } else {
  2131 + stationRouteCode = new_code - 100 + 1;
  2132 + }
  2133 + } else {
1995 2134 stationRouteCode = resultS.getStationRouteCode();
1996 2135 }
1997 2136 stationRouteCode = stationRouteCode == null ? 100 : stationRouteCode;
1998   - Integer LineId = map.get("stationRouteLine").equals("") ? null : Integer.parseInt(map.get("stationRouteLine").toString());
  2137 + Integer LineId = map.get("stationRouteLine").equals("") ? null
  2138 + : Integer.parseInt(map.get("stationRouteLine").toString());
1999 2139 String stationMark = map.get("stationMark").equals("") ? null : map.get("stationMark").toString();
2000   - Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString());
  2140 + Double distances = map.get("distances").equals("") ? 0.0d
  2141 + : Double.parseDouble(map.get("distances").toString());
2001 2142 Double toTime = map.get("toTime").equals("") ? 0.0d : Double.parseDouble(map.get("toTime").toString());
2002   - Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
  2143 + Integer directions = map.get("directions").equals("") ? null
  2144 + : Integer.parseInt(map.get("directions").toString());
2003 2145 Station station = repository.findById(stationId).get();
2004 2146 Line line = lineRepository.findById(LineId).get();
2005 2147 StationRouteCache stationRoute = new StationRouteCache();
... ... @@ -2043,12 +2185,14 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
2043 2185 routeCacheRepository.stationRouteCacheDel(lineId, dir);
2044 2186 sectionRouteCacheRepository.sectionRouteCacheDel(lineId, dir);
2045 2187 // 当前版本路由保存到缓存路由
2046   - List<StationRouteCache> stationRouteCaches = JSONArray.parseArray(JSON.toJSONString(stationRoutes), StationRouteCache.class);
2047   - List<SectionRouteCache> sectionRouteCaches = JSONArray.parseArray(JSON.toJSONString(sectionRoutes), SectionRouteCache.class);
2048   - for(StationRouteCache sr:stationRouteCaches) {
  2188 + List<StationRouteCache> stationRouteCaches = JSONArray.parseArray(JSON.toJSONString(stationRoutes),
  2189 + StationRouteCache.class);
  2190 + List<SectionRouteCache> sectionRouteCaches = JSONArray.parseArray(JSON.toJSONString(sectionRoutes),
  2191 + SectionRouteCache.class);
  2192 + for (StationRouteCache sr : stationRouteCaches) {
2049 2193 routeCacheRepository.save(sr);
2050 2194 }
2051   - for(SectionRouteCache sr:sectionRouteCaches) {
  2195 + for (SectionRouteCache sr : sectionRouteCaches) {
2052 2196 sectionRouteCacheRepository.save(sr);
2053 2197 }
2054 2198 resultMap.put("status", ResponseCode.SUCCESS);
... ...
src/main/resources/static/pages/base/lineversions/js/lineversions-add-from.js
... ... @@ -44,7 +44,7 @@
44 44 // get请求获取公司
45 45 $get('/business/all', {upCode_eq: '88'}, function(compD){
46 46 var len_ = array.length,paramsD = new Array();
47   - paramsD.push({'id':'请选择...','text':'请选择...'});
  47 + paramsD.push({'id':'','text':'请选择...'});
48 48 if(len_>0) {
49 49 $.each(array, function(i, g){
50 50 if(g.name!='' || g.name != null) {
... ... @@ -57,7 +57,7 @@
57 57  
58 58  
59 59 initPinYinSelect2($('#lineSelect'),paramsD,function(selector) {
60   - selector.select2("val", "请选择...");
  60 +// selector.select2("val", "请选择...");
61 61 });
62 62 }
63 63 });
... ... @@ -93,20 +93,18 @@
93 93 }
94 94  
95 95 var paramsD = new Array();
96   -
97   - paramsD.push({'id':"",'text':"新版本"});
  96 +
  97 + paramsD.push({'id':"",'text':""});
98 98  
99 99 for(var i = 0; i < lineVersions.length;i++){
100 100 var g = lineVersions[i];
101 101 paramsD.push({'id':g.versions,'text':g.name + '(' + g.versions + ")"});
102   - }
103   - console.log(paramsD);
104   -
  102 + }
105 103  
106 104  
107   -
108 105 initPinYinSelect2($('#hisVersionsInput'),paramsD,function(selector) {
109   -// selector.select2("val", "请选择...");
  106 +// console.log("123123312");
  107 + selector.select2("", "");
110 108 });
111 109 });
112 110  
... ...
src/main/resources/static/pages/base/lineversions/js/lineversions-list-table.js
... ... @@ -319,6 +319,18 @@
319 319 if(result.status=='SUCCESS') {
320 320 // 弹出添加成功提示消息
321 321 layer.msg('删除成功...');
  322 +
  323 +
  324 +
  325 + var params = getParams();
  326 + if(params['line.name_like']!='' && params['line.name_like'] != null) {
  327 + storage.setItem('xlName_AgursData',params['line.name_like']);
  328 + }
  329 + params['line.name_like'] = splitxlName(params['line.name_like']);
  330 + page = 0;
  331 + /** 表格数据分页加载 @param:<params:搜索参数;true:是否重新分页> */
  332 + loadTableDate(params,true);
  333 +
322 334 } else if(result.status=='ERROR') {
323 335 // 弹出添加失败提示消息
324 336 layer.msg('删除失败...');
... ...
src/main/resources/static/pages/base/stationroute/addstationstemplate.html
... ... @@ -51,7 +51,15 @@
51 51 </div>
52 52 </div>
53 53 </div>
54   -
  54 + <!-- 版本号 -->
  55 + <div class="form-body">
  56 + <div class="form-group">
  57 + <label class="col-md-3 control-label">版本号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</label>
  58 + <div class="col-md-6">
  59 + <input type="text" class="form-control" name="versions" id='versionsInput' Readonly>
  60 + </div>
  61 + </div>
  62 + </div>
55 63 <div class="form-group">
56 64 <div class="alert alert-info font-blue-chambray" style="background-color: #2C3E50">
57 65 <h5 class="block"><span class="help-block" style="color:#1bbc9b;"> * 手动添加站点规划说明: </span></h5>
... ... @@ -87,12 +95,14 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
87 95 // 获取表单元素
88 96 var form = $('#save_station_template_form');
89 97  
  98 + $('#versionsInput').val($("#versions").val());
  99 +
90 100 // 获取错误提示信息元素
91 101 var error = $('.alert-danger', form);
92 102  
93 103 // 提交数据点击事件
94 104 $('.modal-footer #templateSaveData').on('click',function() {
95   -
  105 +
96 106 // 表单提交
97 107 form.submit();
98 108  
... ... @@ -260,6 +270,10 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
260 270 }
261 271  
262 272 function addSave(params,lineid,directionData) {
  273 +
  274 +
  275 + var version = $("#versions").val();
  276 + params.versions = version;
263 277 // 保存
264 278 ajaxd.manualSave(params,function(rd) {
265 279 // 关闭弹出层
... ... @@ -283,7 +297,6 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
283 297 }
284 298 // 清除地图覆盖物
285 299 map.clearMarkAndOverlays();
286   - var version = $("#versions").val();
287 300 // 刷新树
288 301 fun.resjtreeDate(lineid,directionData,version);
289 302  
... ...
src/main/resources/static/pages/base/stationroute/doublename_road.html
... ... @@ -44,7 +44,9 @@
44 44 // 方向
45 45 var dir = params.directions;
46 46 var lineId = params.lineId;
47   - var version = params.versions;
  47 + var version = $("#versions").val();
  48 +
  49 + console.log(version);
48 50  
49 51 // 获取路段号元素,并添加下拉属性值
50 52 ajaxd.getStation(lineId,dir,version,function(treeData) {
... ... @@ -126,8 +128,9 @@
126 128 params.sectionrouteCode = data.sectionrouteCode;
127 129 }
128 130 // 获取版本
129   - $.get("/lineVersions/findCurrentVersion", {"lineId" : lineId}, function (versions) {
130   - params.versions = versions;
  131 + //$.get("/lineVersions/findCurrentVersion", {"lineId" : lineId}, function (versions) {
  132 + //params.versions = versions;
  133 + params.versions = $("#versions").val();
131 134 // 生成路段
132 135 $.post('/section/doubleName',params,function (resuntDate) {
133 136 if(resuntDate.status=='SUCCESS') {
... ... @@ -145,7 +148,7 @@
145 148 fun.resjtreeDate(lineId,dir,$("#versions").val());
146 149 closeMobleSetClean();
147 150 });
148   - });
  151 + //});
149 152  
150 153 }
151 154 });
... ...
src/main/resources/static/pages/base/stationroute/editRoute.html 0 → 100644
  1 +<!-- 手动添加站点 -->
  2 +<div class="modal fade" id="edit_route_mobal" tabindex="-1" role="basic"
  3 + aria-hidden="true">
  4 +
  5 + <div class="modal-dialog">
  6 +
  7 + <div class="modal-content" >
  8 +
  9 + <div class="modal-header">
  10 + <button type="button" class="close" data-dismiss="modal"
  11 + aria-hidden="true"></button>
  12 + <h4 class="modal-title">生成路线(站点和路段)</h4>
  13 + </div>
  14 +
  15 + <div class="modal-body">
  16 +
  17 + <form class="form-horizontal" role="form"
  18 + id="save_route_template_form" action="" method="">
  19 +
  20 + <div class="alert alert-danger display-hide">
  21 + <button class="close" data-close="alert"></button>
  22 + 您的输入有误,请检查下面的输入项
  23 + </div>
  24 +
  25 + <!-- 站点名称 -->
  26 + <div class="form-body">
  27 +
  28 + <div class="form-group">
  29 + <label class="control-label col-md-2"> <span
  30 + class="required"> * </span> 坐标:
  31 + </label>
  32 + <div class="col-md-10">
  33 + <textarea class="form-control" rows="12" name="points"
  34 + id="pointInput" placeholder="坐标点"></textarea>
  35 + </div>
  36 + </div>
  37 + </div>
  38 + <div class="form-group">
  39 + <label class="col-md-3 control-label">选择文本类型:</label>
  40 + <div class="col-md-3">
  41 + <div class="icheck-list">
  42 + <label> <input type="radio" class="icheck"
  43 + name="typeCheck" value='0' checked> txt
  44 + </label> <label> <input type="radio" class="icheck"
  45 + name="typeCheck" value='1'> xml
  46 + </label>
  47 + </div>
  48 + </div>
  49 + <label class="col-md-3 control-label">选择方向:</label>
  50 + <div class="col-md-3">
  51 + <div class="icheck-list">
  52 + <label> <input type="radio" class="icheck"
  53 + name="dirCheck" value='0' checked> 上行
  54 + </label> <label> <input type="radio" class="icheck"
  55 + name="dirCheck" value='1'> 下行
  56 + </label>
  57 + </div>
  58 + </div>
  59 + </div>
  60 + <div class="form-group">
  61 + <div class="alert alert-info font-blue-chambray"
  62 + style="background-color: #2C3E50">
  63 + <h5 class="block">
  64 + <span class="help-block" style="color: #1bbc9b;"> *
  65 + 坐标生成路线规划说明: </span>
  66 + </h5>
  67 + <p>
  68 +
  69 + <span class="help-block" style="color: #1bbc9b;">
  70 + 1.txt格式
  71 + <br>&nbsp;请在文本域中按顺序依次输坐标点,每行中的数据之间用【Tab】键隔开(如果是站点,请将在坐标后面加 stop;没有
  72 + stop默认是路段点,连续带stop的坐标认为是同一个站点),每输入完一个坐标时请按回车键【Enter】换行. 例如:
  73 + <br>121.511870 31.180638 043703.000
  74 + <br>121.511870 31.180643 043705.000
  75 + <br>121.511870 31.180648 043706.000 Stop
  76 + <br>121.511872 31.180653 043707.000
  77 + </span>
  78 + </p>
  79 + <p>
  80 +
  81 + <span class="help-block" style="color: #1bbc9b;">
  82 + 2.xml格式
  83 + <br>用gps生成工具,生成的kml文件里的数据
  84 + </span>
  85 + </p>
  86 + </div>
  87 + </div>
  88 + </form>
  89 + </div>
  90 + <div class="modal-footer">
  91 + <button type="button" class="btn default" data-dismiss="modal"
  92 + id="addMobalHiden">取消</button>
  93 +<!-- <button type="button" class="btn btn-primary hidden" id="referenceCurrentVersion">引用当前版本</button> -->
  94 + <button type="button" class="btn btn-primary" id="templateSaveData">提交数据</button>
  95 + </div>
  96 + </div>
  97 + </div>
  98 +</div>
  99 +
  100 +
  101 +<script src="/pages/base/line/js/map.js"></script>
  102 +<script src="/pages/base/line/js/transGPS.js"></script>
  103 +
  104 +<script type="text/javascript">
  105 +
  106 +$('#edit_route_mobal').on('editRouteMobal.show', function(e,WorldsBMap,GetAjaxData,line,PublicFunctions){
  107 + // 延迟加载显示mobal
  108 + setTimeout(function(){$('#edit_route_mobal').modal({show : true,backdrop: 'static', keyboard: false});},200);
  109 + // 获取表单元素
  110 + var form = $('#save_route_template_form');
  111 +
  112 + // 获取错误提示信息元素
  113 + var error = $('.alert-danger', form);
  114 +
  115 + // 提交数据点击事件
  116 + $('.modal-footer #templateSaveData').on('click',function() {
  117 + form.submit();
  118 + });
  119 +
  120 +
  121 + //从xml中获取节点内容
  122 + function getXmlNode(str){
  123 + //创建文档对象
  124 + var parser=new DOMParser();
  125 + var xmlDoc=parser.parseFromString(str,"text/xml");
  126 +
  127 + //提取数据
  128 + var countrys = xmlDoc.getElementsByTagName('coordinates');
  129 + //var countrys = xmlDoc.getElementsByTagName('DataSource');
  130 +
  131 + var arr = [];
  132 +
  133 + for (var i = 0; i < countrys.length; i++) {
  134 + arr.push(countrys[i].textContent);
  135 + };
  136 + // console.log(arr);
  137 + return arr;
  138 +
  139 + }
  140 +
  141 + // xml方式上传是,处理转成txt格式的方法
  142 + var getXmlSection = function (xml) {
  143 + // var xml = $("#xmlText").val();
  144 + var stationPointList = getXmlNode(xml);
  145 + var sListSize = stationPointList.length;
  146 + var sectionPointListStr = stationPointList[stationPointList.length - 1];
  147 + var sectionPointList = sectionPointListStr.split(" ");
  148 + var index = 0;
  149 +
  150 + // var sectionStr = "";
  151 + var sections = [];
  152 + for (var i = 0; i < sectionPointList.length; i++) {
  153 + var pointStr = sectionPointList[i],
  154 + point = pointStr.split(",");
  155 +
  156 + if (index < sListSize - 1 && point == stationPointList[index]) {
  157 + sections.push(point[0] + " " + point[1] + " " + point[2] + " Stop");
  158 + index++;
  159 + } else {
  160 + sections.push(point[0] + " " + point[1] + " " + point[2]);
  161 + }
  162 + }
  163 + return sections;
  164 + };
  165 +
  166 +
  167 + // 表单验证
  168 + form.validate({
  169 +
  170 + errorElement : 'span',
  171 +
  172 + errorClass : 'help-block help-block-error',
  173 +
  174 + focusInvalid : false,
  175 +
  176 + rules : {
  177 +
  178 + 'points' : {
  179 +
  180 + required : true,
  181 +
  182 + }
  183 +
  184 + },
  185 +
  186 + invalidHandler : function(event, validator) {
  187 +
  188 + error.show();
  189 +
  190 + App.scrollTo(error, -200);
  191 +
  192 + },
  193 +
  194 + highlight : function(element) {
  195 +
  196 + $(element).closest('.form-group').addClass('has-error');
  197 +
  198 + },
  199 +
  200 + unhighlight : function(element) {
  201 +
  202 + $(element).closest('.form-group').removeClass('has-error');
  203 +
  204 + },
  205 +
  206 + success : function(label) {
  207 +
  208 + label.closest('.form-group').removeClass('has-error');
  209 +
  210 + },
  211 + submitHandler : function(f) {
  212 + // 隐藏弹出层
  213 + $('#edit_route_mobal').modal('hide');
  214 +
  215 + // 原坐标类型
  216 + var baseRes = "WGS84";
  217 + // 定义线路名称
  218 + var lineNameV = $('.portlet-title .caption').text();
  219 + var dirStr = '';
  220 + // 路线方向
  221 + var directionData = $("input[name='dirCheck']:checked").val();
  222 + /**
  223 + * 添加类型0(txt)/1(xml)
  224 + * txt方式路段需要30个点取一个
  225 + * xml路段取所有点
  226 + */
  227 + var type = $("input[name='typeCheck']:checked").val();
  228 + //editRoute.setLineDir(directionData);
  229 + // 设置线路对象生成方式
  230 + //editRoute.setLineGenerationType('uploadGPS');
  231 + // 弹出正在加载层
  232 + var i = layer.load(2);
  233 + // 表单序列化
  234 + var paramsForm = form.serializeJSON();
  235 +
  236 +
  237 + var array = [];
  238 + if(type == 1){
  239 + array = getXmlSection(paramsForm.points);
  240 + } else {
  241 + // 切割坐标点
  242 + array = paramsForm.points.split('\r\n');
  243 + }
  244 +
  245 +
  246 +
  247 + // 把坐标点转换为站点或路段
  248 + var arrayFormat = inputStationValueFormat(array);
  249 + var stationList = arrayFormat.stationList;
  250 + var sectionListTemp = arrayFormat.sectionList;
  251 + var sectionList = [];
  252 + // 隔30个取一个点(相当于30s)
  253 + var typeNum = type == 0 ? 30:1;
  254 + for(var i = 0; i*typeNum < sectionListTemp.length; i++) {
  255 + sectionList[i] = sectionListTemp[i*typeNum];
  256 + }
  257 + sectionList[sectionList.length] = sectionListTemp[sectionListTemp.length-1];
  258 +
  259 + var sectionListFinal = [];
  260 + sectionListFinal.push({sectionName : lineNameV, points : sectionList});
  261 + // 根据站点名称获取百度坐标
  262 + WorldsBMap.stationsPointsToLibraryPoint(stationList,function(resultJson) {
  263 + // 根据坐标点获取两点之间的时间与距离
  264 + WorldsBMap.getDistanceAndDuration(resultJson,function(stationdataList) {
  265 + // 设置第一个站的距离
  266 + stationdataList[0].distance = '';
  267 + // 设置第一个站的时间
  268 + stationdataList[0].duration = '';
  269 + // 定义站点信息JSON字符串
  270 + var stationJSON = JSON.stringify(stationdataList);
  271 + // 参数集合
  272 + var params = {};
  273 + params.baseRes = baseRes;
  274 + // 是否添加该站点
  275 +
  276 + // 站点信息JSON字符串
  277 + params.stationJSON = stationJSON;
  278 + // 线路ID
  279 + params.lineId = line.id;
  280 + // 方向
  281 + params.directions = directionData;
  282 + // 原始坐标类型
  283 + params.dbType = 'b';
  284 + // 圆形半径
  285 + params.radius = '80';
  286 + // 限速
  287 + params.speedLimit = '60';
  288 + // 图形类型(r:圆形;p:多边形)
  289 + params.shapesType = 'r';
  290 + // destroy:是否撤销
  291 + params.destroy = '0';
  292 + // versions:版本号
  293 + params.versions = '1';
  294 + // 定义路段信息字符串
  295 + var sectionJSON = JSON.stringify(sectionListFinal);
  296 + // 路段信息JSON字符串
  297 + params.sectionJSON = sectionJSON;
  298 + addSave(params,line.id,directionData);
  299 + });
  300 +
  301 + });
  302 + },
  303 +
  304 + });
  305 +
  306 + function inputStationValueFormat(paramsStationsArray) {
  307 + var stationList = [];
  308 + var sectionList = [];
  309 + var routeList = {"stationList":stationList, "sectionList":sectionList};
  310 + var len = paramsStationsArray.length;
  311 + // 处理相同站点判断值
  312 + var isPush = true;
  313 + for(var k =0;k<len;k++) {
  314 + if(paramsStationsArray[k]=="")
  315 + continue;
  316 + var tempStr = paramsStationsArray[k].split('\t');
  317 + var tempPoint = transGpsLoc(tempStr[0],tempStr[1]);
  318 + var point = {lng:tempPoint.lng, lat:tempPoint.lat};
  319 + if(tempStr.length < 4){
  320 + sectionList[k] = point;
  321 + isPush = true;
  322 + }else {
  323 + if(isPush) {
  324 + sectionList[k] = point;
  325 + stationList.push({name:tempStr[3], potion:{lng:tempPoint.lng, lat:tempPoint.lat} , wgs:{x:tempStr[0], y:tempStr[1]}});
  326 + }
  327 + isPush = false;
  328 + }
  329 + }
  330 + for(var i = 0 ;i<sectionList.length;i++) {
  331 + if(sectionList[i] == "" || typeof(sectionList[i]) == "undefined" || sectionList[i] == null) {
  332 + sectionList.splice(i,1);//删除数组中下表i-i+1之间的值
  333 + i= i-1;
  334 + }
  335 +
  336 + }
  337 + return routeList;
  338 + }
  339 +
  340 + function transGpsLoc(lng,lat) {
  341 + var bdLoc = TransGPS.locationMake(lng, lat);
  342 + var gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
  343 + var bdEn = TransGPS.bd_encrypt(gcjLoc);
  344 + return bdEn;
  345 + }
  346 +
  347 + /** 引用当前版本站点和走向*/
  348 + /* $("#referenceCurrentVersion").on('click',function() {
  349 + // 获取线路对象
  350 + var line = editRoute.getLineObj();
  351 + // 路线方向
  352 + var direction = $("input[name='dirCheck']:checked").val();
  353 + // 设置线路对象方向
  354 + editRoute.setLineDir(direction);
  355 + // 设置线路对象生成方式
  356 + editRoute.setLineGenerationType('cite');
  357 + $.post("/station/referenceCurrentVersion",{'lineId' : line.id , 'directions' : direction},function(rd){
  358 + // 隐藏弹出层
  359 + $('#edit_route_mobal').modal('hide');
  360 + // 关闭弹出层
  361 + layer.closeAll();
  362 + if(rd.status='SUCCESS') {
  363 + // 清除地图覆盖物
  364 + map.clearMarkAndOverlays();
  365 + // 查询路段信息
  366 + var params = {};
  367 + params.lineId=line.id;
  368 + params.dir = direction;
  369 + // 查询路段信息
  370 + $get('/sectionroute/findCacheSection',params,function(data) {
  371 + // 在地图上画出线路走向
  372 + fun.linePanlThree(line.id,data,direction);
  373 + });
  374 + $('#route_show').removeClass('hidden');
  375 + $('#generationRoute_div').addClass('hidden');
  376 + // 刷新路段列表
  377 + $('#section').click();
  378 + layer.msg('引用当前版本成功!');
  379 + }else {
  380 + layer.msg('引用当前版本失败,请重新引用或选择其他方式!');
  381 + }
  382 + })
  383 + }); */
  384 +
  385 + function addSave(params,lineid,directionData) {
  386 +
  387 +
  388 + params.versions = $("#versions").val();
  389 +
  390 + // 保存
  391 + $post("/station/manualSave",params,function(rd) {
  392 + // 关闭弹出层
  393 + layer.closeAll();
  394 + if(rd.status='SUCCESS') {
  395 + var stationD = rd.stationData,isNullStr = '';
  396 + for(var t = 0 ;t<stationD.length;t++) {
  397 + if(stationD[t].potion.lat =='' || stationD[t].potion.lat ==null ||
  398 + stationD[t].potion.lng =='' || stationD[t].potion.lng ==null)
  399 + isNullStr = isNullStr + stationD[t].name + ' , ';
  400 + }
  401 + if(isNullStr!='') {
  402 + layer.open({
  403 + title: '提示',
  404 + content:'【' + isNullStr + '】' + '地址系统无法解析!,请手动调整位置!'
  405 + });
  406 + }
  407 + // 清除地图覆盖物
  408 + WorldsBMap.clearMarkAndOverlays();
  409 + var params = {};
  410 + params.lineId = lineid;
  411 + params.dir = directionData;
  412 + // 查询路段信息
  413 +
  414 + PublicFunctions.resjtreeDate(lineid,directionData,params.versions);
  415 +
  416 + $('#route_show').removeClass('hidden');
  417 + $('#generationRoute_div').addClass('hidden');
  418 + // 刷新路段列表
  419 + $('#section').click();
  420 + layer.open({title: '友情提示'
  421 + ,content: '生成路线成功,生成的线路可能会有误差。请先单击路段,拖动编辑、然后双击保存!'});
  422 + }else {
  423 + layer.msg('生成路线失败!');
  424 + }
  425 + });
  426 + }
  427 +});
  428 +</script>
0 429 \ No newline at end of file
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-events.js
... ... @@ -33,7 +33,15 @@ $(function(){
33 33 });*/
34 34  
35 35 });
36   -
  36 + $('.gpsRoute').on('click',function() {
  37 + var Line = LineObj.getLineObj();
  38 + // 加载其它规划选择弹出层mobal页面
  39 + $.get('editRoute.html', function(m){
  40 + $(pjaxContainer).append(m);
  41 + $('#edit_route_mobal').trigger('editRouteMobal.show', [WorldsBMap,GetAjaxData,Line,PublicFunctions]);
  42 + });
  43 + });
  44 +
37 45 // 上行站点新增事件
38 46 $('.module_tools #addUpStation').on('click', function() {
39 47 /** 设置新增站点对象方向属性值 @param:<directionUpValue:方向(0:上行;1:下行)> */
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
... ... @@ -479,7 +479,6 @@ window.WorldsBMap = function () {
479 479 if (datas) {
480 480 // if (polyline_center && datas) {
481 481 // 编辑路段数据
482   - debugger;
483 482 sectionArray = [];
484 483 for (var d = 0; d < datas.length; d++) {
485 484 var data = datas[d];
... ... @@ -1328,7 +1327,135 @@ window.WorldsBMap = function () {
1328 1327 },
1329 1328 strGetLength: function (str) {
1330 1329 return str.replace(/[\u0391-\uFFE5]/g, "aa").length; //先把中文替换成两个字节的英文,在计算长度
1331   - }
  1330 + },
  1331 + stationsPointsToLibraryPoint : function(arra,callback) {
  1332 + // 获取长度
  1333 + var len = arra.length;
  1334 + var station = {};
  1335 + var stationList = [];
  1336 + (function(){
  1337 + if (!arguments.callee.count) {
  1338 + arguments.callee.count = 0;
  1339 + }
  1340 + arguments.callee.count++;
  1341 + var index = parseInt(arguments.callee.count) - 1;
  1342 + if (index >= len) {
  1343 + callback && callback(stationList);
  1344 + return ;
  1345 + }
  1346 + var f = arguments.callee;
  1347 + station = arra[index];
  1348 + if(arra[index].name!=''){
  1349 +
  1350 + $.get('/station/matchStation',station,function(resultStation) {
  1351 + stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id});
  1352 + f();
  1353 + });
  1354 + }else {
  1355 + f();
  1356 + }
  1357 + })()
  1358 + },
  1359 + /** 获取距离与时间 @param <points:坐标点集合> */
  1360 + getDistanceAndDuration : function(points,callback){
  1361 +
  1362 + // 获取长度
  1363 + var len = points.length;
  1364 + (function(){
  1365 +
  1366 + if (!arguments.callee.count) {
  1367 +
  1368 + arguments.callee.count = 0;
  1369 +
  1370 + }
  1371 +
  1372 + arguments.callee.count++;
  1373 +
  1374 + var index = parseInt(arguments.callee.count) - 1;
  1375 +
  1376 + if (index >= len-1) {
  1377 + callback && callback(points);
  1378 +
  1379 + return;
  1380 + }
  1381 +
  1382 + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。)
  1383 + var f = arguments.callee;
  1384 + // 起点坐标 <坐标格式:40.056878,116.30815>
  1385 + var origin = points[index].potion.lat + ',' + points[index].potion.lng;
  1386 +
  1387 + // 终点坐标 <坐标格式:40.056878,116.30815>
  1388 + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng;
  1389 + var region = '上海';
  1390 +
  1391 + var origin_region = '上海';
  1392 +
  1393 + var destination_region = '上海';
  1394 +
  1395 + var output = 'json';
  1396 +
  1397 + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk';
  1398 +
  1399 + /**
  1400 + * origin:起点名称或经纬度;
  1401 + *
  1402 + * destination:终点名称或经纬度;
  1403 + *
  1404 + * origin_region:起始点所在城市,驾车导航时必填。
  1405 + *
  1406 + * destination_region:终点所在城市,驾车导航时必填。
  1407 + *
  1408 + * output :表示输出类型,可设置为xml或json,默认为xml。
  1409 + *
  1410 + **/
  1411 + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My};
  1412 +
  1413 + /** @description :未认证开发者默认配额为:2000次/天。 */
  1414 + $.ajax({
  1415 +
  1416 + // 百度地图根据坐标获取两点之间的时间与距离
  1417 + url: 'http://api.map.baidu.com/direction/v1?mode=transit',
  1418 +
  1419 + data: paramsB,
  1420 +
  1421 + dataType: 'jsonp',
  1422 +
  1423 + success: function(r){
  1424 +
  1425 + if(r) {
  1426 +
  1427 + if(r.message=='ok') {
  1428 +
  1429 + if(r.result.taxi==null) {
  1430 +
  1431 + // 获取距离(单位:米)
  1432 + points[index+1].distance = 0;
  1433 +
  1434 + // 获取时间(单位:秒)
  1435 + points[index+1].duration = 0;
  1436 +
  1437 + }else {
  1438 +
  1439 + // 获取距离(单位:米)
  1440 + points[index+1].distance = r.result.taxi.distance;
  1441 +
  1442 + // 获取时间(单位:秒)
  1443 + points[index+1].duration = r.result.taxi.duration;
  1444 +
  1445 + }
  1446 +
  1447 +
  1448 + }
  1449 +
  1450 + }
  1451 +
  1452 + f();
  1453 + }
  1454 + });
  1455 +
  1456 + })();
  1457 +
  1458 + },
1332 1459 };
1333 1460  
1334 1461 return Bmap;
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-reload.js
... ... @@ -218,17 +218,21 @@ $(function() {
218 218 yes : function(index) {
219 219  
220 220 // 刷新左边树
221   - // PublicFunctions.resjtreeDate(Line.id,dir);
  221 +
  222 +
222 223 var dir = WorldsBMap.getDir();
  224 +
  225 + PublicFunctions.resjtreeDate(Line.id,dir,$("#versions").val());
  226 + // PublicFunctions.resjtreeDate(Line.id,dir);
223 227 // 查询路段信息 @param:<Line.id:线路Id;delBatch.dir:方向>
224 228 // @return:data:路段数据
225   - GetAjaxData.getSectionRouteInfo(Line.id, dir,
226   - function(data) {
227   - // 在地图上画出线路走向
228   - // @param:<Line.id:线路Id;delBatch.dir:方向;data:路段数据>
229   - PublicFunctions.linePanlThree(
230   - Line.id, data, dir);
231   - });
  229 +// GetAjaxData.getSectionRouteInfo(Line.id, dir,
  230 +// function(data) {
  231 +// // 在地图上画出线路走向
  232 +// // @param:<Line.id:线路Id;delBatch.dir:方向;data:路段数据>
  233 +// PublicFunctions.linePanlThree(
  234 +// Line.id, data, dir);
  235 +// });
232 236 PublicFunctions.editMapStatusRemove();
233 237 layer.msg("已退出编辑模式!");
234 238 layer.close(index);
... ...
src/main/resources/static/pages/base/stationroute/list.html
... ... @@ -154,6 +154,10 @@
154 154 <li>
155 155 <a class="upSystem" href="javascript:;" data-direction="0" data-pjax><i class="fa fa-wrench"></i> 系统规划</a>
156 156 </li>
  157 + <li class="divider"> </li>
  158 + <li>
  159 + <a class="gpsRoute" href="javascript:;" data-direction="0" data-pjax><i class="fa fa-wrench"></i> 测点生成</a>
  160 + </li>
157 161 </ul>
158 162 </div>
159 163 </div>
... ... @@ -258,6 +262,10 @@
258 262 <li>
259 263 <a class="downSystem" href="javascript:;" data-direction="1" data-pjax><i class="fa fa-wrench"></i> 系统规划</a>
260 264 </li>
  265 + <li class="divider"> </li>
  266 + <li>
  267 + <a class="gpsRoute" href="javascript:;" data-direction="1" data-pjax><i class="fa fa-wrench"></i> 测点生成</a>
  268 + </li>
261 269 </ul>
262 270 </div>
263 271 </div>
... ...