Commit 86e4375edc19dc1071bd80e0222da02932b6aff7

Authored by 李强
1 parent dd6977d1

基础数据撤销站点功能

src/main/java/com/bsth/controller/SectionRouteController.java
... ... @@ -40,4 +40,9 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer
40 40 return routeService.getSectionRoute(map);
41 41 }
42 42  
  43 + @RequestMapping(value = "/stationRouteIsDestroy" , method = RequestMethod.POST)
  44 + public Map<String, Object> stationRouteIsDestroy(@RequestParam Map<String, Object> map) {
  45 + return routeService.stationRouteIsDestroy(map);
  46 + }
  47 +
43 48 }
... ...
src/main/java/com/bsth/controller/StationRouteController.java
... ... @@ -59,8 +59,4 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
59 59 return service.getStationRouteCenterPoints(map);
60 60 }
61 61  
62   - @RequestMapping(value = "/stationRouteIsDestroy" , method = RequestMethod.POST)
63   - public Map<String, Object> stationRouteIsDestroy(@RequestParam Map<String, Object> map) {
64   - return service.stationRouteIsDestroy(map);
65   - }
66 62 }
... ...
src/main/java/com/bsth/repository/SectionRouteRepository.java
... ... @@ -2,8 +2,10 @@ package com.bsth.repository;
2 2  
3 3 import java.util.List;
4 4  
  5 +import org.springframework.data.jpa.repository.Modifying;
5 6 import org.springframework.data.jpa.repository.Query;
6 7 import org.springframework.stereotype.Repository;
  8 +import org.springframework.transaction.annotation.Transactional;
7 9  
8 10 import com.bsth.entity.SectionRoute;
9 11  
... ... @@ -60,4 +62,10 @@ public interface SectionRouteRepository extends BaseRepository&lt;SectionRoute, Int
60 62 " LEFT JOIN bsth_c_section b ON a.sectionrouteSection = b.id", nativeQuery=true)
61 63 List<Object[]> getSectionRoute(int lineId, int directions);
62 64  
  65 + @Transactional
  66 + @Modifying
  67 + @Query(value="UPDATE bsth_c_stationroute SET " +
  68 + "destroy = ?2 WHERE id = ?1", nativeQuery=true)
  69 + public void stationRouteIsDestroyUpd(Integer stationRouteId, Integer destroy);
  70 +
63 71 }
... ...
src/main/java/com/bsth/repository/StationRouteRepository.java
... ... @@ -74,7 +74,7 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
74 74 "r.first_time AS 'stationRoute.firstTime'," +
75 75 "r.end_time AS 'stationRoute.endTime'," +
76 76 "r.descriptions AS 'stationRoute.descriptions'," +
77   - "r.versions AS 'stationRoute.versions' FROM bsth_c_stationroute r WHERE r.line = ?1 and r.directions = ?2) a " +
  77 + "r.versions AS 'stationRoute.versions' FROM bsth_c_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.destroy=0) a " +
78 78 "LEFT JOIN bsth_c_station b " +
79 79 "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true)
80 80 List<Object[]> findPoints(int line,int directions);
... ... @@ -92,9 +92,4 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
92 92 "LEFT JOIN bsth_c_station s on r.station = s.id", nativeQuery=true)
93 93 List<Object[]> getSelectStationRouteCenterPoints(Integer lineId,Integer direction);
94 94  
95   - @Transactional
96   - @Modifying
97   - @Query(value="UPDATE bsth_c_stationroute SET " +
98   - "destroy = ?2 WHERE id = ?1", nativeQuery=true)
99   - public void stationRouteIsDestroyUpd(Integer stationRouteId, Integer destroy);
100 95 }
... ...
src/main/java/com/bsth/service/SectionRouteService.java
... ... @@ -23,4 +23,6 @@ import com.bsth.entity.SectionRoute;
23 23 public interface SectionRouteService extends BaseService<SectionRoute, Integer> {
24 24  
25 25 List<Map<String, Object>> getSectionRoute(Map<String, Object> map);
  26 +
  27 + Map<String, Object> stationRouteIsDestroy(Map<String, Object> map);
26 28 }
... ...
src/main/java/com/bsth/service/StationRouteService.java
... ... @@ -29,6 +29,4 @@ public interface StationRouteService extends BaseService&lt;StationRoute, Integer&gt;
29 29 List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map);
30 30  
31 31 List<Map<String, Object>> getStationRouteCenterPoints(Map<String, Object> map);
32   -
33   - Map<String, Object> stationRouteIsDestroy(Map<String, Object> map);
34 32 }
... ...
src/main/java/com/bsth/service/impl/SectionRouteServiceImpl.java
... ... @@ -8,6 +8,7 @@ import java.util.Map;
8 8 import org.springframework.beans.factory.annotation.Autowired;
9 9 import org.springframework.stereotype.Service;
10 10  
  11 +import com.bsth.common.ResponseCode;
11 12 import com.bsth.entity.SectionRoute;
12 13 import com.bsth.repository.SectionRouteRepository;
13 14 import com.bsth.service.SectionRouteService;
... ... @@ -82,5 +83,30 @@ public class SectionRouteServiceImpl extends BaseServiceImpl&lt;SectionRoute, Integ
82 83  
83 84 return resultList;
84 85 }
  86 +
  87 + @Override
  88 + public Map<String, Object> stationRouteIsDestroy(Map<String, Object> map) {
  89 + Map<String, Object> resultMap = new HashMap<String,Object>();
  90 +
  91 + try {
  92 +
  93 + Integer stationRouteId = map.get("stationRouteId").equals("") ? 0 : Integer.parseInt(map.get("stationRouteId").toString());
  94 +
  95 + Integer destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
  96 +
  97 + repository.stationRouteIsDestroyUpd(stationRouteId, destroy);
  98 +
  99 + resultMap.put("status", ResponseCode.SUCCESS);
  100 +
  101 + } catch (Exception e) {
  102 +
  103 + resultMap.put("status", ResponseCode.ERROR);
  104 +
  105 + logger.error("save erro.", e);
  106 +
  107 + }
  108 +
  109 + return resultMap;
  110 + }
85 111  
86 112 }
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
... ... @@ -373,30 +373,4 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
373 373  
374 374 return resultList;
375 375 }
376   -
377   - @Override
378   - public Map<String, Object> stationRouteIsDestroy(Map<String, Object> map) {
379   - Map<String, Object> resultMap = new HashMap<String,Object>();
380   -
381   - try {
382   -
383   - Integer stationRouteId = map.get("stationRouteId").equals("") ? 0 : Integer.parseInt(map.get("stationRouteId").toString());
384   -
385   - Integer destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString());
386   -
387   - repository.stationRouteIsDestroyUpd(stationRouteId, destroy);
388   -
389   - resultMap.put("status", ResponseCode.SUCCESS);
390   -
391   - } catch (Exception e) {
392   -
393   - resultMap.put("status", ResponseCode.ERROR);
394   -
395   - logger.error("save erro.", e);
396   -
397   - }
398   -
399   - return resultMap;
400   - }
401   -
402 376 }
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-ajax-getdata.js
... ... @@ -134,6 +134,11 @@ var GetAjaxData = function(){
134 134  
135 135 stationRouteIsDestroy : function(stationRoute,callback) {
136 136  
  137 + $post('/sectionroute/stationRouteIsDestroy',stationRoute,function(data) {
  138 +
  139 + callback && callback(data);
  140 +
  141 + })
137 142  
138 143 },
139 144  
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-events.js
... ... @@ -466,13 +466,15 @@ $(function(){
466 466 layer.msg('请先选择要删除的站点!');
467 467 return;
468 468 }
469   -
  469 + console.log(obj);
470 470 layer.confirm('你确定要撤销【'+obj[0].text+'】站点吗?', {btn : [ '确定撤销','返回' ],icon: 3, title:'提示' }, function(index){
471 471  
472 472 var stationRouteId = obj[0].original.stationRouteId;
473 473  
474 474 var params = {stationRouteId:stationRouteId,destroy:'1'};
475 475  
  476 + var stationRouteDirections = obj[0].original.stationRouteDirections;
  477 +
476 478 GetAjaxData.stationRouteIsDestroy(params,function(result) {
477 479  
478 480 layer.close(index);
... ... @@ -480,6 +482,17 @@ $(function(){
480 482 if(result.status=='SUCCESS'){
481 483  
482 484 layer.msg('撤销上行站点【'+obj[0].text+'】成功!');
  485 +
  486 + mapB.clearOverlays();
  487 + GetAjaxData.getSectionRouteInfo(id,stationRouteDirections,function(data) {
  488 +
  489 + // 刷新树
  490 + resjtreeDate(id,stationRouteDirections);
  491 +
  492 + // linePanlThree(data,stationRouteDirections);
  493 +
  494 + });
  495 +
483 496  
484 497 }else{
485 498  
... ...