Commit 1dd23a0f2b25adf96ad6287477279077ce4d2546

Authored by YRF
1 parent df2151cf

线路整条录入的两个功能,起终点站新增

src/main/java/com/bsth/controller/StationController.java
... ... @@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
8 8 import org.springframework.web.bind.annotation.RequestParam;
9 9 import org.springframework.web.bind.annotation.RestController;
10 10  
11   -import antlr.collections.List;
12   -
13 11 import com.bsth.entity.Station;
14 12 import com.bsth.service.StationService;
15 13 import com.bsth.util.GetUIDAndCode;
... ...
src/main/java/com/bsth/entity/Station.java
... ... @@ -6,6 +6,8 @@ import javax.persistence.Column;
6 6 import javax.persistence.Entity;
7 7 import javax.persistence.Id;
8 8 import javax.persistence.Table;
  9 +
  10 +import java.util.Arrays;
9 11 import java.util.Date;
10 12  
11 13  
... ... @@ -323,4 +325,17 @@ public class Station {
323 325 public void setUpdateDate(Date updateDate) {
324 326 this.updateDate = updateDate;
325 327 }
  328 +
  329 + @Override
  330 + public String toString() {
  331 + return "Station [id=" + id + ", stationCod=" + stationCod + ", stationName=" + stationName + ", roadCoding="
  332 + + roadCoding + ", addr=" + addr + ", dbType=" + dbType + ", bJwpoints=" + bJwpoints + ", gLonx=" + gLonx
  333 + + ", gLaty=" + gLaty + ", x=" + x + ", y=" + y + ", shapesType=" + shapesType + ", radius=" + radius
  334 + + ", gPolygonGrid=" + Arrays.toString(gPolygonGrid) + ", bPolygonGrid=" + Arrays.toString(bPolygonGrid)
  335 + + ", destroy=" + destroy + ", versions=" + versions + ", isHaveLed=" + isHaveLed + ", isHaveShelter="
  336 + + isHaveShelter + ", isHarbourStation=" + isHarbourStation + ", descriptions=" + descriptions
  337 + + ", createBy=" + createBy + ", updateBy=" + updateBy + ", createDate=" + createDate + ", updateDate="
  338 + + updateDate + "]";
  339 + }
  340 +
326 341 }
... ...
src/main/java/com/bsth/repository/SectionRouteCacheRepository.java
... ... @@ -5,9 +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;
9 8  
10   -import com.bsth.entity.SectionRoute;
11 9 import com.bsth.entity.SectionRouteCache;
12 10  
13 11 /**
... ... @@ -139,6 +137,6 @@ public interface SectionRouteCacheRepository extends BaseRepository<SectionRoute
139 137 * @param dir
140 138 */
141 139 @Modifying
142   - @Query(value="delete from bsth_c_sectionroute_cache where line = ?1 and directions = ?2", nativeQuery=true)
143   - public void sectionRouteCacheDel(Integer line,Integer dir);
  140 + @Query(value="delete from bsth_c_sectionroute_cache where line_code = ?1 and directions = ?2", nativeQuery=true)
  141 + public void sectionRouteCacheDel(String lineCode,Integer dir);
144 142 }
... ...
src/main/java/com/bsth/repository/StationRouteCacheRepository.java
1 1 package com.bsth.repository;
2 2  
3 3 import java.util.List;
4   -import java.util.Map;
5 4  
6   -import org.springframework.data.domain.Page;
7   -import org.springframework.data.domain.Pageable;
8   -import org.springframework.data.domain.Sort;
9   -import org.springframework.data.jpa.domain.Specification;
10   -import org.springframework.data.jpa.repository.EntityGraph;
11 5 import org.springframework.data.jpa.repository.Modifying;
12 6 import org.springframework.data.jpa.repository.Query;
13 7 import org.springframework.stereotype.Repository;
14   -import org.springframework.transaction.annotation.Transactional;
15 8  
16   -import com.bsth.entity.Line;
17   -import com.bsth.entity.StationRoute;
18 9 import com.bsth.entity.StationRouteCache;
19 10  
20 11 /**
... ... @@ -64,7 +55,7 @@ public interface StationRouteCacheRepository extends BaseRepository<StationRoute
64 55 * @param dir
65 56 */
66 57 @Modifying
67   - @Query(value="delete from bsth_c_stationroute_cache where line = ?1 and directions = ?2 ", nativeQuery=true)
68   - public void stationRouteCacheDel(Integer line,Integer dir);
  58 + @Query(value="delete from bsth_c_stationroute_cache where line_code = ?1 and directions = ?2 ", nativeQuery=true)
  59 + public void stationRouteCacheDel(String lineCode,Integer dir);
69 60  
70 61 }
... ...
src/main/java/com/bsth/service/impl/SectionServiceImpl.java
... ... @@ -190,7 +190,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem
190 190 routeRepository.save(route);
191 191 }
192 192 // 删除缓存路段
193   - routeCacheRepository.sectionRouteCacheDel(sectionRouteLine,directions);
  193 + routeCacheRepository.sectionRouteCacheDel(lineCode,directions);
194 194 // 撤销原有站点路由
195 195 stationRouteRepository.stationRouteUpdDestroy(sectionRouteLine,directions);
196 196 // 站点保存
... ... @@ -221,7 +221,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem
221 221 stationRouteRepository.save(stationRoute);
222 222 }
223 223 // 删除缓存站点
224   - stationRouteCacheRepository.stationRouteCacheDel(sectionRouteLine,directions);
  224 + stationRouteCacheRepository.stationRouteCacheDel(lineCode,directions);
225 225  
226 226 resultMap.put("status", ResponseCode.SUCCESS);
227 227 } catch (Exception e) {
... ... @@ -324,7 +324,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem
324 324 lsRouteRepository.save(route);
325 325 }
326 326 // 删除缓存路段
327   - routeCacheRepository.sectionRouteCacheDel(sectionRouteLine,directions);
  327 + routeCacheRepository.sectionRouteCacheDel(lineCode,directions);
328 328 // 删除原有历史表站点路由
329 329 lsStationRouteRepository.batchDelete(sectionRouteLine,directions,versions);
330 330 // 站点保存
... ... @@ -355,7 +355,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem
355 355 lsStationRouteRepository.save(stationRoute);
356 356 }
357 357 // 删除缓存站点
358   - stationRouteCacheRepository.stationRouteCacheDel(sectionRouteLine,directions);
  358 + stationRouteCacheRepository.stationRouteCacheDel(lineCode,directions);
359 359 resultMap.put("status", ResponseCode.SUCCESS);
360 360 } catch (Exception e) {
361 361 resultMap.put("status", ResponseCode.ERROR);
... ...
src/main/java/com/bsth/service/impl/StationServiceImpl.java
1 1 package com.bsth.service.impl;
2 2  
3 3 import java.math.BigDecimal;
  4 +import java.util.ArrayList;
4 5 import java.util.HashMap;
5   -import java.util.Iterator;
6 6 import java.util.List;
7 7 import java.util.Map;
8 8  
... ... @@ -12,8 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
12 12 import org.springframework.stereotype.Service;
13 13 import org.springframework.transaction.annotation.Transactional;
14 14  
15   -
16   -
  15 +import com.alibaba.fastjson.JSON;
17 16 import com.alibaba.fastjson.JSONArray;
18 17 import com.alibaba.fastjson.JSONObject;
19 18 import com.bsth.common.ResponseCode;
... ... @@ -261,6 +260,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem
261 260 Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String,Object>();
262 261 JSONArray stationsArray = JSONArray.parseArray(stationJSON);
263 262 if(stationsArray.size()>0) {
  263 + Station loopStartStation = new Station();
264 264 for(int i = 0;i <stationsArray.size();i++) {
265 265 // 站点名称
266 266 String stationName = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("name").toString();
... ... @@ -292,6 +292,38 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
292 292 /*Integer stationId = Integer.parseInt(stationNameList.get(0)[1].toString());*/
293 293 Integer stationId = Integer.parseInt(isHaveMap.get("id").toString());
294 294 arg0 = repository.findOne(stationId);
  295 +
  296 + if ((i==0 || i==stationsArray.size()-1) && resultLine.getLinePlayType() != 1) {// (起终点站)
  297 + List<Station> list = new ArrayList<>();
  298 + list.add(arg0);
  299 + List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
  300 + Station station = stationlist.get(0);
  301 + // 站点编码
  302 + long stationCode = GetUIDAndCode.getStationId();
  303 + station.setStationCod(String.valueOf(stationCode));
  304 + station.setId((int)stationCode);
  305 + station.setCreateDate(null);
  306 + station.setUpdateDate(null);
  307 + repository.save(station);
  308 + arg0 = station;
  309 + } else if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  310 + List<Station> list = new ArrayList<>();
  311 + list.add(arg0);
  312 + List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
  313 + Station station = stationlist.get(0);
  314 + // 站点编码
  315 + long stationCode = GetUIDAndCode.getStationId();
  316 + station.setStationCod(String.valueOf(stationCode));
  317 + station.setId((int)stationCode);
  318 + station.setCreateDate(null);
  319 + station.setUpdateDate(null);
  320 + repository.save(station);
  321 + arg0 = station;
  322 + loopStartStation = arg0;
  323 + repository.save(arg0);
  324 + } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  325 + arg0 = loopStartStation;
  326 + }
295 327 }else {
296 328 // 站点编码
297 329 long stationCode = GetUIDAndCode.getStationId();
... ... @@ -353,7 +385,14 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
353 385 arg0.setVersions(versions);
354 386 arg0.setbJwpoints(bJwpoints);
355 387 // 插入站点信息
356   - repository.save(arg0);
  388 + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  389 + loopStartStation = arg0;
  390 + repository.save(arg0);
  391 + } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  392 + arg0 = loopStartStation;
  393 + } else {
  394 + repository.save(arg0);
  395 + }
357 396  
358 397 }
359 398 // 站点路由对象
... ... @@ -1297,8 +1336,10 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1297 1336 Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String,Object>();
1298 1337 JSONArray stationsArray = JSONArray.parseArray(stationJSON);
1299 1338 if(stationsArray.size()>0) {
  1339 + // 环线起点站
  1340 + Station loopStartStation = new Station();
1300 1341 // 更新路线前删除线路缓存站点
1301   - routeCacheRepository.stationRouteCacheDel(Integer.parseInt(resultLine.getLineCode()),directions);
  1342 + routeCacheRepository.stationRouteCacheDel(resultLine.getLineCode(),directions);
1302 1343 for(int i = 0;i <stationsArray.size();i++) {
1303 1344 // 站点名称
1304 1345 String stationName = stationsArray.getJSONObject(i).equals("") ? "" : stationsArray.getJSONObject(i).get("name").toString();
... ... @@ -1322,14 +1363,46 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1322 1363 // 百度坐标纬度
1323 1364 String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString();
1324 1365 bLatx = bLatx==null || bLatx.equals("") ? "0" : bLatx;
1325   - List<Object[]> stationNameList = repository.findStationName(directions,stationName);
  1366 +// List<Object[]> stationNameList = repository.findStationName(directions,stationName);
1326 1367 //Map<String, Object> isHaveMap = isHaveStationname(bLonx,bLatx,stationNameList);
1327 1368 // 初始化站点对象
1328 1369 Station arg0 = new Station();
1329   - // 存在的点就不添加到数据库
  1370 + // 存在的点就不添加到数据库(起终点站重新添加站点)
1330 1371 if(Boolean.parseBoolean(stationsArray.getJSONObject(i).get("isHave").toString())) {
1331 1372 Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString());
1332 1373 arg0 = repository.findOne(stationId);
  1374 +
  1375 + if ((i==0 || i==stationsArray.size()-1) && resultLine.getLinePlayType() != 1) {// (起终点站)
  1376 + List<Station> list = new ArrayList<>();
  1377 + list.add(arg0);
  1378 + List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
  1379 + Station station = stationlist.get(0);
  1380 + // 站点编码
  1381 + long stationCode = GetUIDAndCode.getStationId();
  1382 + station.setStationCod(String.valueOf(stationCode));
  1383 + station.setId((int)stationCode);
  1384 + station.setCreateDate(null);
  1385 + station.setUpdateDate(null);
  1386 + repository.save(station);
  1387 + arg0 = station;
  1388 + } else if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1389 + List<Station> list = new ArrayList<>();
  1390 + list.add(arg0);
  1391 + List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
  1392 + Station station = stationlist.get(0);
  1393 + // 站点编码
  1394 + long stationCode = GetUIDAndCode.getStationId();
  1395 + station.setStationCod(String.valueOf(stationCode));
  1396 + station.setId((int)stationCode);
  1397 + station.setCreateDate(null);
  1398 + station.setUpdateDate(null);
  1399 + repository.save(station);
  1400 + arg0 = station;
  1401 + loopStartStation = arg0;
  1402 + repository.save(arg0);
  1403 + } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1404 + arg0 = loopStartStation;
  1405 + }
1333 1406 }else {
1334 1407 // 站点编码
1335 1408 long stationCode = GetUIDAndCode.getStationId();
... ... @@ -1391,13 +1464,23 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1391 1464 arg0.setVersions(versions);
1392 1465 arg0.setbJwpoints(bJwpoints);
1393 1466 // 插入站点信息
1394   - repository.save(arg0);
  1467 + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1468 + loopStartStation = arg0;
  1469 + repository.save(arg0);
  1470 + } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1471 + arg0 = loopStartStation;
  1472 + } else {
  1473 + repository.save(arg0);
  1474 + }
1395 1475  
1396 1476 }
1397 1477 // 站点路由对象
1398 1478 StationRouteCache route = new StationRouteCache();
1399 1479 // 站点名称
1400   - route.setStationName(stationName);
  1480 + if(i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1)
  1481 + route.setStationName(loopStartStation.getStationName());
  1482 + else
  1483 + route.setStationName(stationName);
1401 1484 route.setDistances(distance);
1402 1485 sumUpOrDownMileage = sumUpOrDownMileage + distance;
1403 1486 route.setToTime(duration);
... ... @@ -1448,7 +1531,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1448 1531 // 转换成JSON数组
1449 1532 JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);
1450 1533 // 更新路线前删除线路缓存路段
1451   - sectionRouteCacheRepository.sectionRouteCacheDel(Integer.parseInt(resultLine.getLineCode()),directions);
  1534 + sectionRouteCacheRepository.sectionRouteCacheDel(resultLine.getLineCode(),directions);
1452 1535 // 遍历
1453 1536 for(int s = 0 ;s<sectionsArray.size();s++) {
1454 1537 // 站点名称
... ... @@ -1530,4 +1613,4 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1530 1613 }
1531 1614  
1532 1615 }
1533   -}
  1616 +}
1534 1617 \ No newline at end of file
... ...
src/main/resources/static/pages/base/line/map.html
... ... @@ -125,27 +125,6 @@ $(function(){
125 125 $(pjaxContainer).append(m);
126 126 $('#submit_select_mobal').trigger('submitSelectMobal.show',[section,EditRoute]);
127 127 });
128   - /* layer.confirm('提交会把原有的站点和路段覆盖,您确定要提交吗?', {
129   - btn: ['提交','取消'] //按钮
130   - }, function(){
131   - var sectionList = WorldsBMapLine.getSectionList();
132   - var data = {};
133   - var section = EditSectionObj.getEitdSection();
134   - var josnSectionList = JSON.stringify(sectionList);
135   - section.cutSectionList = josnSectionList;
136   - $.post('/section/sectionCut', section, function(resuntDate){
137   - if(resuntDate.status=='SUCCESS') {
138   - // 弹出添加成功提示消息
139   - layer.msg('提交成功,跳转到线路详情页面!');
140   - window.location.href = "/pages/base/stationroute/list.html?no="+id+","+EditRoute.getLineObj().dir;
141   - WorldsBMapLine.initCutSectionPoint();
142   - WorldsBMapLine.setPointIndex(0);
143   - }else {
144   - // 弹出添加失败提示消息
145   - layer.msg('提交失败...');
146   - }
147   - });
148   - }); */
149 128 } else {
150 129 layer.msg("请先截取路段!!!");
151 130 }
... ...
src/main/resources/static/pages/base/station/edit_select.html
... ... @@ -22,7 +22,7 @@
22 22 <div class="form-group" id="formRequ">
23 23 <label class="col-md-3 control-label"><span class="required"> * </span>站点名称:</label>
24 24 <div class="col-md-9" id="errorInfo">
25   - <input type="text" class="form-control input-medium" id="stationNamebootboxInput" name="stationNamebootbox">
  25 + <input type="text" class="form-control input-medium" id="stationNamebootboxInput" name="stationNamebootbox" readonly="readonly">
26 26 </div>
27 27 </div>
28 28 <!-- 修改方式容器 -->
... ...