Commit 18a930fdb2beba0027b3492eb8c2b88087b5df94

Authored by youxiw2000
1 parent 238e076d

获取最大IDBUG

src/main/java/com/bsth/controller/CarParkController.java
1 -package com.bsth.controller;  
2 -  
3 -import java.util.HashMap;  
4 -import java.util.List;  
5 -import java.util.Map;  
6 -  
7 -import com.bsth.entity.CarPark;  
8 -import com.bsth.service.CarParkService;  
9 -import com.bsth.util.GetUIDAndCode;  
10 -  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.web.bind.annotation.*;  
13 -  
14 -  
15 -@RestController  
16 -@RequestMapping("carpark")  
17 -public class CarParkController extends BaseController<CarPark, Integer> {  
18 - @Autowired  
19 - CarParkService service;  
20 -  
21 - /**  
22 - * @Description :TODO(查询停车场编码)  
23 - *  
24 - * @return int <carParkCode 停车场编码>  
25 - */  
26 - @RequestMapping(value="getCarParkCode" , method = RequestMethod.GET)  
27 - public Map<String, Object> getStationCode() {  
28 - Map<String, Object> resultMap = new HashMap<String, Object>();  
29 - resultMap.put("carParkCode", "FFFFFF" + GetUIDAndCode.getCarParkId());  
30 - return resultMap;  
31 - }  
32 - /**  
33 - * 新增停车场信息  
34 - *  
35 - *  
36 - * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;  
37 - *  
38 - * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;  
39 - *  
40 - * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;  
41 - *  
42 - * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>  
43 - *  
44 - * @return map <SUCCESS:成功;ERROR:失败>  
45 - *  
46 - */  
47 - @RequestMapping(value="carParkSave" , method = RequestMethod.POST)  
48 - public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) {  
49 - map.put("createBy", "");  
50 - map.put("updateBy", "");  
51 - return service.carParkSave(map);  
52 - }  
53 - @RequestMapping(value = "findCarParkInfoFormId",method = RequestMethod.GET)  
54 - public List<Map<String, Object>> findCarParkInfoFormId(@RequestParam Map<String, Object> map) {  
55 - return service.findCarParkInfoFormId(map);  
56 - }  
57 - /**  
58 - * 修改停车场信息  
59 - *  
60 - *  
61 - * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;  
62 - *  
63 - * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;  
64 - *  
65 - * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;  
66 - *  
67 - * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>  
68 - *  
69 - * @return map <SUCCESS:成功;ERROR:失败>  
70 - *  
71 - */  
72 - @RequestMapping(value="carParkUpdate" , method = RequestMethod.POST)  
73 - public Map<String, Object> carParkUpdate(@RequestParam Map<String, Object> map) {  
74 - map.put("updateBy", "");  
75 - return service.carParkUpdate(map);  
76 - }  
77 -  
78 - @RequestMapping(value="isHaveParkCode",method=RequestMethod.GET)  
79 - public boolean isHaveParkCode(@RequestParam Map<String,Object> map) {  
80 - return service.selectTccInfoByCode(map);  
81 - }  
82 -} 1 +package com.bsth.controller;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import com.bsth.entity.CarPark;
  8 +import com.bsth.service.CarParkService;
  9 +import com.bsth.util.GetUIDAndCode;
  10 +
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.web.bind.annotation.*;
  13 +
  14 +
  15 +@RestController
  16 +@RequestMapping("carpark")
  17 +public class CarParkController extends BaseController<CarPark, Integer> {
  18 + @Autowired
  19 + CarParkService service;
  20 +
  21 + /**
  22 + * @Description :TODO(查询停车场编码)
  23 + *
  24 + * @return int <carParkCode 停车场编码>
  25 + */
  26 + @RequestMapping(value="getCarParkCode" , method = RequestMethod.GET)
  27 + public Map<String, Object> getStationCode() {
  28 + Map<String, Object> resultMap = new HashMap<String, Object>();
  29 + resultMap.put("carParkCode", "FFFFFF" + service.carParkMaxId() + 1);
  30 + return resultMap;
  31 + }
  32 + /**
  33 + * 新增停车场信息
  34 + *
  35 + *
  36 + * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;
  37 + *
  38 + * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;
  39 + *
  40 + * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;
  41 + *
  42 + * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>
  43 + *
  44 + * @return map <SUCCESS:成功;ERROR:失败>
  45 + *
  46 + */
  47 + @RequestMapping(value="carParkSave" , method = RequestMethod.POST)
  48 + public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) {
  49 + map.put("createBy", "");
  50 + map.put("updateBy", "");
  51 + return service.carParkSave(map);
  52 + }
  53 + @RequestMapping(value = "findCarParkInfoFormId",method = RequestMethod.GET)
  54 + public List<Map<String, Object>> findCarParkInfoFormId(@RequestParam Map<String, Object> map) {
  55 + return service.findCarParkInfoFormId(map);
  56 + }
  57 + /**
  58 + * 修改停车场信息
  59 + *
  60 + *
  61 + * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;
  62 + *
  63 + * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;
  64 + *
  65 + * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;
  66 + *
  67 + * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>
  68 + *
  69 + * @return map <SUCCESS:成功;ERROR:失败>
  70 + *
  71 + */
  72 + @RequestMapping(value="carParkUpdate" , method = RequestMethod.POST)
  73 + public Map<String, Object> carParkUpdate(@RequestParam Map<String, Object> map) {
  74 + map.put("updateBy", "");
  75 + return service.carParkUpdate(map);
  76 + }
  77 +
  78 + @RequestMapping(value="isHaveParkCode",method=RequestMethod.GET)
  79 + public boolean isHaveParkCode(@RequestParam Map<String,Object> map) {
  80 + return service.selectTccInfoByCode(map);
  81 + }
  82 +}
src/main/java/com/bsth/controller/LineController.java
1 -package com.bsth.controller;  
2 -  
3 -import com.bsth.common.ResponseCode;  
4 -import com.bsth.entity.Line;  
5 -import com.bsth.entity.LineVersions;  
6 -import com.bsth.service.LineService;  
7 -import com.bsth.service.LineVersionsService;  
8 -import com.bsth.util.GetUIDAndCode;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.web.bind.annotation.RequestMapping;  
11 -import org.springframework.web.bind.annotation.RequestMethod;  
12 -import org.springframework.web.bind.annotation.RequestParam;  
13 -import org.springframework.web.bind.annotation.RestController;  
14 -  
15 -import java.text.ParseException;  
16 -import java.text.SimpleDateFormat;  
17 -import java.util.Date;  
18 -import java.util.HashMap;  
19 -import java.util.Map;  
20 -  
21 -/**  
22 - *  
23 - * @ClassName: LineController(线路控制器)  
24 - *  
25 - * @Extends : BaseController  
26 - *  
27 - * @Description: TODO(线路控制层)  
28 - *  
29 - * @Author bsth@lq  
30 - *  
31 - * @Date 2016年4月28日 上午9:21:17  
32 - *  
33 - * @Version 公交调度系统BS版 0.1  
34 - *  
35 - */  
36 -@RestController  
37 -@RequestMapping("line")  
38 -public class LineController extends BaseController<Line, Integer> {  
39 -  
40 - @Autowired  
41 - private LineService service;  
42 -  
43 - @Autowired  
44 - private LineVersionsService lineVersionsService;  
45 -  
46 - /**  
47 - * 获取线路编码与ID  
48 - *  
49 - * @return int <lineCode:线路编码>  
50 - */  
51 - @RequestMapping(value = "getLineCode", method = RequestMethod.GET)  
52 - public long getLineCode() {  
53 - return GetUIDAndCode.getLineId();  
54 - }  
55 -  
56 - /**  
57 - * 验证线路编码是否存在  
58 - *  
59 - * @return Map < {valid: true }:是否通过验证>  
60 - */  
61 - @RequestMapping(value = "lineCodeVerification", method = RequestMethod.GET)  
62 - public String lineCodeVerification(@RequestParam(defaultValue = "lineCode") String lineCode) {  
63 - return service.lineCodeVerification(lineCode);  
64 - }  
65 -  
66 - /**  
67 - *  
68 - * 保存  
69 - *  
70 - */  
71 - @RequestMapping(method = RequestMethod.POST)  
72 - public Map<String, Object> save(Line t){  
73 - Map<String, Object> map = new HashMap<>();  
74 - if(t.getId()==null) {  
75 -  
76 - t.setId(Integer.valueOf(t.getLineCode()));  
77 -  
78 - }  
79 - if( (t.getId().toString().length()) > 6 || service.lineCodeVerification(t.getLineCode()).equals("false") ) {  
80 -  
81 - map.put("status", ResponseCode.ERROR);  
82 - return map;  
83 - }  
84 - if(t.getDestroy() == 0){  
85 - t.setInUse(1);  
86 - } else  
87 - t.setInUse(0);  
88 - // 添加线路版本  
89 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
90 - try {  
91 - Date endDate = simpleDateFormat.parse("2088-08-08 00:00:00");  
92 - LineVersions lineVersions = new LineVersions();  
93 - lineVersions.setName("原始版本");  
94 - lineVersions.setLine(t);  
95 - lineVersions.setLineCode(t.getLineCode());  
96 - lineVersions.setStartDate(new java.sql.Date(new Date().getTime()));  
97 - lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00  
98 - lineVersions.setVersions(1);  
99 - lineVersions.setStatus(1);  
100 - // 先添加线路再添加版本  
101 - service.save(t);  
102 - return lineVersionsService.save(lineVersions);  
103 - } catch (ParseException e) {  
104 - // TODO Auto-generated catch block  
105 - e.printStackTrace();  
106 - map.put("status", ResponseCode.ERROR);  
107 - return map;  
108 - }  
109 - }  
110 -  
111 - /**  
112 - * 更改  
113 - */  
114 - @RequestMapping(value="/update", method = RequestMethod.POST)  
115 - public Map<String, Object> update(Line l){  
116 - Map<String, Object> map = new HashMap<>();  
117 - if((l.getId().toString().length()) > 6 || service.lineCodeVerification(l.getLineCode()).equals("true") ) {  
118 -  
119 - map.put("status", ResponseCode.ERROR);  
120 - return map;  
121 - }  
122 - return service.update(l);  
123 - }  
124 -  
125 - @RequestMapping(value ="/findById" , method = RequestMethod.GET)  
126 - Line findByID(@RequestParam(defaultValue = "id") Integer id){  
127 - return service.findById(id);  
128 - }  
129 -  
130 - /**  
131 - * 删除线路  
132 - * @param id  
133 - * @return  
134 - */  
135 - @RequestMapping(value ="/remove" , method = RequestMethod.POST)  
136 - public Map<String, Object> remove(Integer id){  
137 - return service.remove(id);  
138 - }  
139 -  
140 - /**  
141 - * 查询外部行业编码是否有更新  
142 - * @param id  
143 - * @return  
144 - */  
145 - @RequestMapping(value ="/getLineMatchStationIsUpdate" , method = RequestMethod.GET)  
146 - public Map<String, Object> getLineMatchStationIsUpdate(@RequestParam(defaultValue = "id") Integer id){  
147 - return service.getLineMatchStationIsUpdate(id);  
148 - }  
149 -} 1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.Line;
  5 +import com.bsth.entity.LineVersions;
  6 +import com.bsth.service.LineService;
  7 +import com.bsth.service.LineVersionsService;
  8 +import com.bsth.util.GetUIDAndCode;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestMethod;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import java.text.ParseException;
  16 +import java.text.SimpleDateFormat;
  17 +import java.util.Date;
  18 +import java.util.HashMap;
  19 +import java.util.Map;
  20 +
  21 +/**
  22 + *
  23 + * @ClassName: LineController(线路控制器)
  24 + *
  25 + * @Extends : BaseController
  26 + *
  27 + * @Description: TODO(线路控制层)
  28 + *
  29 + * @Author bsth@lq
  30 + *
  31 + * @Date 2016年4月28日 上午9:21:17
  32 + *
  33 + * @Version 公交调度系统BS版 0.1
  34 + *
  35 + */
  36 +@RestController
  37 +@RequestMapping("line")
  38 +public class LineController extends BaseController<Line, Integer> {
  39 +
  40 + @Autowired
  41 + private LineService service;
  42 +
  43 + @Autowired
  44 + private LineVersionsService lineVersionsService;
  45 +
  46 + /**
  47 + * 获取线路编码与ID
  48 + *
  49 + * @return int <lineCode:线路编码>
  50 + */
  51 + @RequestMapping(value = "getLineCode", method = RequestMethod.GET)
  52 + public long getLineCode() {
  53 + return service.selectMaxIdToLineCode() + 1;
  54 + }
  55 +
  56 + /**
  57 + * 验证线路编码是否存在
  58 + *
  59 + * @return Map < {valid: true }:是否通过验证>
  60 + */
  61 + @RequestMapping(value = "lineCodeVerification", method = RequestMethod.GET)
  62 + public String lineCodeVerification(@RequestParam(defaultValue = "lineCode") String lineCode) {
  63 + return service.lineCodeVerification(lineCode);
  64 + }
  65 +
  66 + /**
  67 + *
  68 + * 保存
  69 + *
  70 + */
  71 + @RequestMapping(method = RequestMethod.POST)
  72 + public Map<String, Object> save(Line t){
  73 + Map<String, Object> map = new HashMap<>();
  74 + if(t.getId()==null) {
  75 +
  76 + t.setId(Integer.valueOf(t.getLineCode()));
  77 +
  78 + }
  79 + if( (t.getId().toString().length()) > 6 || service.lineCodeVerification(t.getLineCode()).equals("false") ) {
  80 +
  81 + map.put("status", ResponseCode.ERROR);
  82 + return map;
  83 + }
  84 + if(t.getDestroy() == 0){
  85 + t.setInUse(1);
  86 + } else
  87 + t.setInUse(0);
  88 + // 添加线路版本
  89 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  90 + try {
  91 + Date endDate = simpleDateFormat.parse("2088-08-08 00:00:00");
  92 + LineVersions lineVersions = new LineVersions();
  93 + lineVersions.setName("原始版本");
  94 + lineVersions.setLine(t);
  95 + lineVersions.setLineCode(t.getLineCode());
  96 + lineVersions.setStartDate(new java.sql.Date(new Date().getTime()));
  97 + lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00
  98 + lineVersions.setVersions(1);
  99 + lineVersions.setStatus(1);
  100 + // 先添加线路再添加版本
  101 + service.save(t);
  102 + return lineVersionsService.save(lineVersions);
  103 + } catch (ParseException e) {
  104 + // TODO Auto-generated catch block
  105 + e.printStackTrace();
  106 + map.put("status", ResponseCode.ERROR);
  107 + return map;
  108 + }
  109 + }
  110 +
  111 + /**
  112 + * 更改
  113 + */
  114 + @RequestMapping(value="/update", method = RequestMethod.POST)
  115 + public Map<String, Object> update(Line l){
  116 + Map<String, Object> map = new HashMap<>();
  117 + if((l.getId().toString().length()) > 6 || service.lineCodeVerification(l.getLineCode()).equals("true") ) {
  118 +
  119 + map.put("status", ResponseCode.ERROR);
  120 + return map;
  121 + }
  122 + return service.update(l);
  123 + }
  124 +
  125 + @RequestMapping(value ="/findById" , method = RequestMethod.GET)
  126 + Line findByID(@RequestParam(defaultValue = "id") Integer id){
  127 + return service.findById(id);
  128 + }
  129 +
  130 + /**
  131 + * 删除线路
  132 + * @param id
  133 + * @return
  134 + */
  135 + @RequestMapping(value ="/remove" , method = RequestMethod.POST)
  136 + public Map<String, Object> remove(Integer id){
  137 + return service.remove(id);
  138 + }
  139 +
  140 + /**
  141 + * 查询外部行业编码是否有更新
  142 + * @param id
  143 + * @return
  144 + */
  145 + @RequestMapping(value ="/getLineMatchStationIsUpdate" , method = RequestMethod.GET)
  146 + public Map<String, Object> getLineMatchStationIsUpdate(@RequestParam(defaultValue = "id") Integer id){
  147 + return service.getLineMatchStationIsUpdate(id);
  148 + }
  149 +}
src/main/java/com/bsth/controller/SectionController.java
1 -package com.bsth.controller;  
2 -  
3 -import java.util.Map;  
4 -  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.web.bind.annotation.RequestMapping;  
7 -import org.springframework.web.bind.annotation.RequestMethod;  
8 -import org.springframework.web.bind.annotation.RequestParam;  
9 -import org.springframework.web.bind.annotation.RestController;  
10 -  
11 -import com.bsth.entity.Section;  
12 -import com.bsth.service.SectionService;  
13 -import com.bsth.util.GetUIDAndCode;  
14 -  
15 -/**  
16 - *  
17 - * @ClassName: SectionController(路段控制器)  
18 - *  
19 - * @Extends : BaseController  
20 - *  
21 - * @Description: TODO(路段控制层)  
22 - *  
23 - * @Author bsth@lq  
24 - *  
25 - * @Date 2016年05月03日 上午9:21:17  
26 - *  
27 - * @Version 公交调度系统BS版 0.1  
28 - *  
29 - */  
30 -  
31 -@RestController  
32 -@RequestMapping("section")  
33 -public class SectionController extends BaseController<Section, Integer> {  
34 -  
35 - @Autowired  
36 - SectionService service;  
37 -  
38 - /**  
39 - * 新增路段信息  
40 - *  
41 - * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID  
42 - *  
43 - * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;  
44 - *  
45 - * sectionrouteCode:路段序号;speedLimit:路段限速>  
46 - *  
47 - * @return map<SUCCESS:成功;ERROR:异常>  
48 - */  
49 - @RequestMapping(value="sectionSave" , method = RequestMethod.POST)  
50 - public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {  
51 - map.put("createBy", "");  
52 - map.put("updateBy", "");  
53 - return service.sectionSave(map);  
54 - }  
55 -  
56 - /**  
57 - * @Description :TODO(编辑线路走向)  
58 - *  
59 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
60 - *  
61 - * @return Map<String, Object> <SUCCESS ; ERROR>  
62 - */  
63 - @RequestMapping(value="sectionCut" , method = RequestMethod.POST)  
64 - public Map<String, Object> sectionCut(@RequestParam Map<String, Object> map) {  
65 -  
66 - map.put("updateBy", "");  
67 -  
68 - map.put("createBy", "");  
69 -  
70 - map.put("createDate", "");  
71 -  
72 - return service.sectionCut(map);  
73 -  
74 - }  
75 -  
76 - /**  
77 - * @Description :TODO(编辑线路走向保存到线路历史表)  
78 - *  
79 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
80 - *  
81 - * @return Map<String, Object> <SUCCESS ; ERROR>  
82 - */  
83 - @RequestMapping(value="sectionCutSaveLineLS" , method = RequestMethod.POST)  
84 - public Map<String, Object> sectionCutSaveLineLS(@RequestParam Map<String, Object> map) {  
85 -  
86 - map.put("updateBy", "");  
87 -  
88 - map.put("createBy", "");  
89 -  
90 - return service.sectionCutSaveLineLS(map);  
91 -  
92 - }  
93 -  
94 - /**  
95 - * @Description :TODO(编辑线路走向)  
96 - *  
97 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
98 - *  
99 - * @return Map<String, Object> <SUCCESS ; ERROR>  
100 - */  
101 - @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)  
102 - public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {  
103 -  
104 - map.put("updateBy", "");  
105 -  
106 - map.put("createBy", "");  
107 -  
108 - map.put("createDate", "");  
109 -  
110 - return service.sectionUpdate(map);  
111 -  
112 - }  
113 -  
114 - /**  
115 - * @Description :TODO(编辑缓存线路走向)  
116 - */  
117 - @RequestMapping(value="sectionCacheUpdate" , method = RequestMethod.POST)  
118 - public Map<String, Object> sectionCacheUpdate(@RequestParam Map<String, Object> map) {  
119 -  
120 - map.put("updateBy", "");  
121 -  
122 - map.put("createBy", "");  
123 -  
124 - map.put("createDate", "");  
125 -  
126 - return service.sectionCacheUpdate(map);  
127 -  
128 - }  
129 -  
130 - /**  
131 - * @Description :TODO(查询路段编码)  
132 - *  
133 - * @return int <sectionCode路段编码>  
134 - */  
135 - @RequestMapping(value="getSectionCode" , method = RequestMethod.GET)  
136 - public long getSectionCode() {  
137 - return GetUIDAndCode.getSectionId();  
138 - }  
139 -  
140 - /**  
141 - * @Description :TODO(把路段截取位双路名路段)  
142 - *  
143 - * @return int <sectionCode路段编码>  
144 - */  
145 - @RequestMapping(value="doubleName" , method = RequestMethod.POST)  
146 - public Map<String, Object> doubleName(@RequestParam Map<String, Object> map) {  
147 - return service.doubleName(map);  
148 - }  
149 -  
150 -} 1 +package com.bsth.controller;
  2 +
  3 +import java.util.Map;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import com.bsth.entity.Section;
  12 +import com.bsth.repository.SectionRepository;
  13 +import com.bsth.service.SectionService;
  14 +import com.bsth.util.GetUIDAndCode;
  15 +
  16 +/**
  17 + *
  18 + * @ClassName: SectionController(路段控制器)
  19 + *
  20 + * @Extends : BaseController
  21 + *
  22 + * @Description: TODO(路段控制层)
  23 + *
  24 + * @Author bsth@lq
  25 + *
  26 + * @Date 2016年05月03日 上午9:21:17
  27 + *
  28 + * @Version 公交调度系统BS版 0.1
  29 + *
  30 + */
  31 +
  32 +@RestController
  33 +@RequestMapping("section")
  34 +public class SectionController extends BaseController<Section, Integer> {
  35 +
  36 + @Autowired
  37 + SectionService service;
  38 +
  39 + @Autowired
  40 + SectionRepository sectionRepository;
  41 +
  42 + /**
  43 + * 新增路段信息
  44 + *
  45 + * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID
  46 + *
  47 + * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;
  48 + *
  49 + * sectionrouteCode:路段序号;speedLimit:路段限速>
  50 + *
  51 + * @return map<SUCCESS:成功;ERROR:异常>
  52 + */
  53 + @RequestMapping(value="sectionSave" , method = RequestMethod.POST)
  54 + public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {
  55 + map.put("createBy", "");
  56 + map.put("updateBy", "");
  57 + return service.sectionSave(map);
  58 + }
  59 +
  60 + /**
  61 + * @Description :TODO(编辑线路走向)
  62 + *
  63 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  64 + *
  65 + * @return Map<String, Object> <SUCCESS ; ERROR>
  66 + */
  67 + @RequestMapping(value="sectionCut" , method = RequestMethod.POST)
  68 + public Map<String, Object> sectionCut(@RequestParam Map<String, Object> map) {
  69 +
  70 + map.put("updateBy", "");
  71 +
  72 + map.put("createBy", "");
  73 +
  74 + map.put("createDate", "");
  75 +
  76 + return service.sectionCut(map);
  77 +
  78 + }
  79 +
  80 + /**
  81 + * @Description :TODO(编辑线路走向保存到线路历史表)
  82 + *
  83 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  84 + *
  85 + * @return Map<String, Object> <SUCCESS ; ERROR>
  86 + */
  87 + @RequestMapping(value="sectionCutSaveLineLS" , method = RequestMethod.POST)
  88 + public Map<String, Object> sectionCutSaveLineLS(@RequestParam Map<String, Object> map) {
  89 +
  90 + map.put("updateBy", "");
  91 +
  92 + map.put("createBy", "");
  93 +
  94 + return service.sectionCutSaveLineLS(map);
  95 +
  96 + }
  97 +
  98 + /**
  99 + * @Description :TODO(编辑线路走向)
  100 + *
  101 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  102 + *
  103 + * @return Map<String, Object> <SUCCESS ; ERROR>
  104 + */
  105 + @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)
  106 + public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {
  107 +
  108 + map.put("updateBy", "");
  109 +
  110 + map.put("createBy", "");
  111 +
  112 + map.put("createDate", "");
  113 +
  114 + return service.sectionUpdate(map);
  115 +
  116 + }
  117 +
  118 + /**
  119 + * @Description :TODO(编辑缓存线路走向)
  120 + */
  121 + @RequestMapping(value="sectionCacheUpdate" , method = RequestMethod.POST)
  122 + public Map<String, Object> sectionCacheUpdate(@RequestParam Map<String, Object> map) {
  123 +
  124 + map.put("updateBy", "");
  125 +
  126 + map.put("createBy", "");
  127 +
  128 + map.put("createDate", "");
  129 +
  130 + return service.sectionCacheUpdate(map);
  131 +
  132 + }
  133 +
  134 + /**
  135 + * @Description :TODO(查询路段编码)
  136 + *
  137 + * @return int <sectionCode路段编码>
  138 + */
  139 + @RequestMapping(value="getSectionCode" , method = RequestMethod.GET)
  140 + public long getSectionCode() {
  141 + return sectionRepository.sectionMaxId() + 1;
  142 + }
  143 +
  144 + /**
  145 + * @Description :TODO(把路段截取位双路名路段)
  146 + *
  147 + * @return int <sectionCode路段编码>
  148 + */
  149 + @RequestMapping(value="doubleName" , method = RequestMethod.POST)
  150 + public Map<String, Object> doubleName(@RequestParam Map<String, Object> map) {
  151 + return service.doubleName(map);
  152 + }
  153 +
  154 +}
src/main/java/com/bsth/controller/StationController.java
1 -package com.bsth.controller;  
2 -  
3 -import com.bsth.entity.Station;  
4 -import com.bsth.service.StationService;  
5 -import com.bsth.util.GetUIDAndCode;  
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory;  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.web.bind.annotation.RequestMapping;  
10 -import org.springframework.web.bind.annotation.RequestMethod;  
11 -import org.springframework.web.bind.annotation.RequestParam;  
12 -import org.springframework.web.bind.annotation.RestController;  
13 -  
14 -import java.util.Map;  
15 -  
16 -/**  
17 - *  
18 - * @ClassName: StationController(站点控制器)  
19 - *  
20 - * @Extends : BaseController  
21 - *  
22 - * @Description: TODO(站点控制层)  
23 - *  
24 - * @Author bsth@lq  
25 - *  
26 - * @Date 2016年05月03日 上午9:21:17  
27 - *  
28 - * @Version 公交调度系统BS版 0.1  
29 - *  
30 - */  
31 -  
32 -@RestController  
33 -@RequestMapping("station")  
34 -public class StationController extends BaseController<Station, Integer> {  
35 -  
36 - @Autowired  
37 - private StationService service;  
38 -  
39 - /** 日志记录器 */  
40 - private static final Logger LOGGER = LoggerFactory.getLogger(StationController.class);  
41 -  
42 - /**  
43 - * @Description :TODO(根据坐标点匹配数据库中的站点)  
44 - *  
45 - * @param map: <point:坐标点; name:站点名>  
46 - *  
47 - */  
48 - @RequestMapping(value="matchStation" , method = RequestMethod.GET)  
49 - public Map<String, Object> matchStation(@RequestParam Map<String, Object> map) {  
50 - return service.matchStation(map);  
51 - }  
52 -  
53 - /**  
54 - * @Description :TODO(系统规划保存数据)  
55 - *  
56 - * @param map <stationJSON:站点信息;  
57 - *  
58 - * - - - - - - sectionJSON:路段信息;  
59 - *  
60 - * - - - - - - dbType:坐标类型;  
61 - *  
62 - * - - - - - - destroy:是否撤销;  
63 - *  
64 - * - - - - - - directions:方向;  
65 - *  
66 - * - - - - - - lineId:线路ID;  
67 - *  
68 - * - - - - - - radius:圆半径  
69 - *  
70 - * - - - - - - shapesType:图形类型  
71 - *  
72 - * - - - - - - speedLimit:限速>  
73 - *  
74 - * @return Map<String, Object> <SUCCESS ; ERROR>  
75 - */  
76 - @RequestMapping(value="collectionSave" , method = RequestMethod.POST)  
77 - public Map<String, Object> collectionSave(@RequestParam Map<String, Object> map) {  
78 - return service.systemSaveStations(map);  
79 - }  
80 -  
81 - @RequestMapping(value="manualSave" , method = RequestMethod.POST)  
82 - public Map<String, Object> manualSave(@RequestParam Map<String, Object> map) {  
83 - return service.manualSave(map);  
84 - }  
85 -  
86 - @RequestMapping(value="cacheSave" , method = RequestMethod.POST)  
87 - public Map<String, Object> cacheSave(@RequestParam Map<String, Object> map) {  
88 - return service.cacheSave(map);  
89 - }  
90 -  
91 - /**  
92 - * @Description :TODO(新增站点保存)  
93 - *  
94 - * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;  
95 - *  
96 - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;  
97 - *  
98 - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;  
99 - *  
100 - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间  
101 - *  
102 - * versions:版本号;x:城建坐标x;y:城建坐标y>  
103 - *  
104 - * @return Map<String, Object> <SUCCESS ; ERROR>  
105 - */  
106 - @RequestMapping(value="stationSave" , method = RequestMethod.POST)  
107 - public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) {  
108 - map.put("createBy", "");  
109 - map.put("updateBy", "");  
110 - return service.stationSaveMap(map);  
111 - }  
112 -  
113 - /**  
114 - * @Description :TODO(更新站点保存)  
115 - *  
116 - * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;  
117 - *  
118 - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;  
119 - *  
120 - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;  
121 - *  
122 - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间  
123 - *  
124 - * versions:版本号;x:城建坐标x;y:城建坐标y>  
125 - *  
126 - * @return Map<String, Object> <SUCCESS ; ERROR>  
127 - */  
128 - @RequestMapping(value="stationUpdate" , method = RequestMethod.POST)  
129 - public Map<String, Object> stationUpdate(@RequestParam Map<String, Object> map) {  
130 - map.put("updateBy", ""); //??  
131 - return service.stationUpdate(map);  
132 - }  
133 -  
134 - /**  
135 - * @Description :TODO(更新缓存站点保存)  
136 - *  
137 - * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;  
138 - *  
139 - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;  
140 - *  
141 - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;  
142 - *  
143 - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间  
144 - *  
145 - * versions:版本号;x:城建坐标x;y:城建坐标y>  
146 - *  
147 - * @return Map<String, Object> <SUCCESS ; ERROR>  
148 - */  
149 - @RequestMapping(value="stationCacheUpdate" , method = RequestMethod.POST)  
150 - public Map<String, Object> stationCacheUpdate(@RequestParam Map<String, Object> map) {  
151 - map.put("updateBy", "");  
152 - return service.stationCacheUpdate(map);  
153 - }  
154 - /**  
155 - * @Description :TODO(更新内部编码)  
156 - * @param stationCount,sectionCount 更新数  
157 - */  
158 - @RequestMapping(value="updateStationAndSectionCode" , method = RequestMethod.GET)  
159 - public int updateStationAndSectionCode(@RequestParam Integer stationCount, Integer sectionCount) {  
160 - System.out.println(stationCount+" _ "+ sectionCount );  
161 - for(int i = 0; i < stationCount; i++) {  
162 -// System.out.println(i);  
163 - GetUIDAndCode.getStationId();  
164 - }  
165 - for(int j = 0; j < sectionCount; j++) {  
166 -// System.out.println(j);  
167 - GetUIDAndCode.getSectionId();  
168 - }  
169 - return 1;  
170 - }  
171 - /**  
172 - * @Description :TODO(查询站点编码)  
173 - *  
174 - * @return int <stationCode站点编码>  
175 - */  
176 - @RequestMapping(value="getStationCode" , method = RequestMethod.GET)  
177 - public long getStationCode() {  
178 - return GetUIDAndCode.getStationId();  
179 -  
180 - }  
181 - /**  
182 - * @Description :TODO(查询站点编码)  
183 - *  
184 - * @return int <stationCode站点编码>  
185 - */  
186 - @RequestMapping(value="stationCacheSave" , method = RequestMethod.POST)  
187 - public Map<String, Object> stationCacheSave(@RequestParam Map<String, Object> map) {  
188 - map.put("createBy", "");  
189 - map.put("updateBy", "");  
190 - return service.stationCacheSave(map);  
191 - }  
192 -} 1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.entity.Station;
  4 +import com.bsth.repository.StationRepository;
  5 +import com.bsth.service.StationService;
  6 +import com.bsth.util.GetUIDAndCode;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestMethod;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + *
  19 + * @ClassName: StationController(站点控制器)
  20 + *
  21 + * @Extends : BaseController
  22 + *
  23 + * @Description: TODO(站点控制层)
  24 + *
  25 + * @Author bsth@lq
  26 + *
  27 + * @Date 2016年05月03日 上午9:21:17
  28 + *
  29 + * @Version 公交调度系统BS版 0.1
  30 + *
  31 + */
  32 +
  33 +@RestController
  34 +@RequestMapping("station")
  35 +public class StationController extends BaseController<Station, Integer> {
  36 +
  37 + @Autowired
  38 + private StationService service;
  39 +
  40 + @Autowired
  41 + StationRepository stationRepository;
  42 +
  43 + /** 日志记录器 */
  44 + private static final Logger LOGGER = LoggerFactory.getLogger(StationController.class);
  45 +
  46 + /**
  47 + * @Description :TODO(根据坐标点匹配数据库中的站点)
  48 + *
  49 + * @param map: <point:坐标点; name:站点名>
  50 + *
  51 + */
  52 + @RequestMapping(value="matchStation" , method = RequestMethod.GET)
  53 + public Map<String, Object> matchStation(@RequestParam Map<String, Object> map) {
  54 + return service.matchStation(map);
  55 + }
  56 +
  57 + /**
  58 + * @Description :TODO(系统规划保存数据)
  59 + *
  60 + * @param map <stationJSON:站点信息;
  61 + *
  62 + * - - - - - - sectionJSON:路段信息;
  63 + *
  64 + * - - - - - - dbType:坐标类型;
  65 + *
  66 + * - - - - - - destroy:是否撤销;
  67 + *
  68 + * - - - - - - directions:方向;
  69 + *
  70 + * - - - - - - lineId:线路ID;
  71 + *
  72 + * - - - - - - radius:圆半径
  73 + *
  74 + * - - - - - - shapesType:图形类型
  75 + *
  76 + * - - - - - - speedLimit:限速>
  77 + *
  78 + * @return Map<String, Object> <SUCCESS ; ERROR>
  79 + */
  80 + @RequestMapping(value="collectionSave" , method = RequestMethod.POST)
  81 + public Map<String, Object> collectionSave(@RequestParam Map<String, Object> map) {
  82 + return service.systemSaveStations(map);
  83 + }
  84 +
  85 + @RequestMapping(value="manualSave" , method = RequestMethod.POST)
  86 + public Map<String, Object> manualSave(@RequestParam Map<String, Object> map) {
  87 + return service.manualSave(map);
  88 + }
  89 +
  90 + @RequestMapping(value="cacheSave" , method = RequestMethod.POST)
  91 + public Map<String, Object> cacheSave(@RequestParam Map<String, Object> map) {
  92 + return service.cacheSave(map);
  93 + }
  94 +
  95 + /**
  96 + * @Description :TODO(新增站点保存)
  97 + *
  98 + * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;
  99 + *
  100 + * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
  101 + *
  102 + * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
  103 + *
  104 + * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
  105 + *
  106 + * versions:版本号;x:城建坐标x;y:城建坐标y>
  107 + *
  108 + * @return Map<String, Object> <SUCCESS ; ERROR>
  109 + */
  110 + @RequestMapping(value="stationSave" , method = RequestMethod.POST)
  111 + public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) {
  112 + map.put("createBy", "");
  113 + map.put("updateBy", "");
  114 + return service.stationSaveMap(map);
  115 + }
  116 +
  117 + /**
  118 + * @Description :TODO(更新站点保存)
  119 + *
  120 + * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;
  121 + *
  122 + * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
  123 + *
  124 + * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
  125 + *
  126 + * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
  127 + *
  128 + * versions:版本号;x:城建坐标x;y:城建坐标y>
  129 + *
  130 + * @return Map<String, Object> <SUCCESS ; ERROR>
  131 + */
  132 + @RequestMapping(value="stationUpdate" , method = RequestMethod.POST)
  133 + public Map<String, Object> stationUpdate(@RequestParam Map<String, Object> map) {
  134 + map.put("updateBy", ""); //??
  135 + return service.stationUpdate(map);
  136 + }
  137 +
  138 + /**
  139 + * @Description :TODO(更新缓存站点保存)
  140 + *
  141 + * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;
  142 + *
  143 + * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;
  144 + *
  145 + * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;
  146 + *
  147 + * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间
  148 + *
  149 + * versions:版本号;x:城建坐标x;y:城建坐标y>
  150 + *
  151 + * @return Map<String, Object> <SUCCESS ; ERROR>
  152 + */
  153 + @RequestMapping(value="stationCacheUpdate" , method = RequestMethod.POST)
  154 + public Map<String, Object> stationCacheUpdate(@RequestParam Map<String, Object> map) {
  155 + map.put("updateBy", "");
  156 + return service.stationCacheUpdate(map);
  157 + }
  158 + /**
  159 + * @Description :TODO(更新内部编码)
  160 + * @param stationCount,sectionCount 更新数
  161 + */
  162 + @RequestMapping(value="updateStationAndSectionCode" , method = RequestMethod.GET)
  163 + public int updateStationAndSectionCode(@RequestParam Integer stationCount, Integer sectionCount) {
  164 +// System.out.println(stationCount+" _ "+ sectionCount );
  165 +// for(int i = 0; i < stationCount; i++) {
  166 +//// System.out.println(i);
  167 +// stationRepository.stationMaxId() + 1;
  168 +// }
  169 +// for(int j = 0; j < sectionCount; j++) {
  170 +//// System.out.println(j);
  171 +// sectionRepository.sectionMaxId() + 1;
  172 +// }
  173 + return 1;
  174 + }
  175 + /**
  176 + * @Description :TODO(查询站点编码)
  177 + *
  178 + * @return int <stationCode站点编码>
  179 + */
  180 + @RequestMapping(value="getStationCode" , method = RequestMethod.GET)
  181 + public long getStationCode() {
  182 + return stationRepository.stationMaxId() + 1;
  183 +
  184 + }
  185 + /**
  186 + * @Description :TODO(查询站点编码)
  187 + *
  188 + * @return int <stationCode站点编码>
  189 + */
  190 + @RequestMapping(value="stationCacheSave" , method = RequestMethod.POST)
  191 + public Map<String, Object> stationCacheSave(@RequestParam Map<String, Object> map) {
  192 + map.put("createBy", "");
  193 + map.put("updateBy", "");
  194 + return service.stationCacheSave(map);
  195 + }
  196 +}
src/main/java/com/bsth/repository/StationRouteRepository.java
1 -package com.bsth.repository;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
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 -import org.springframework.data.jpa.repository.Modifying;  
12 -import org.springframework.data.jpa.repository.Query;  
13 -import org.springframework.stereotype.Repository;  
14 -import org.springframework.transaction.annotation.Transactional;  
15 -  
16 -import com.bsth.entity.Line;  
17 -import com.bsth.entity.StationRoute;  
18 -  
19 -/**  
20 - *  
21 - * @Interface: StationRouteRepository(站点路由Repository数据持久层接口)  
22 - *  
23 - * @Extends : BaseRepository  
24 - *  
25 - * @Description: TODO(站点路由Repository数据持久层接口)  
26 - *  
27 - * @Author bsth@lq  
28 - *  
29 - * @Date 2016年5月03日 上午9:21:17  
30 - *  
31 - * @Version 公交调度系统BS版 0.1  
32 - *  
33 - */  
34 -  
35 -@Repository  
36 -public interface StationRouteRepository extends BaseRepository<StationRoute, Integer> {  
37 -  
38 - @Query(value = "SELECT a.`stationRoute.id`," +  
39 - "a.`stationRoute.line`," +  
40 - "a.`stationRoute.station`," +  
41 - "a.`stationRoute.stationName`," +  
42 - "a.`stationRoute.stationRouteCode`," +  
43 - "a.`stationRoute.lineCode`," +  
44 - "a.`stationRoute.stationMark`," +  
45 - "a.`stationRoute.outStationNmber`," +  
46 - "a.`stationRoute.directions`," +  
47 - "a.`stationRoute.distances`," +  
48 - "a.`stationRoute.toTime`," +  
49 - "a.`stationRoute.firstTime`," +  
50 - "a.`stationRoute.endTime`," +  
51 - "a.`stationRoute.descriptions`," +  
52 - "a.`stationRoute.versions`," +  
53 - "b.id AS 'station.id'," +  
54 - "b.station_cod AS 'station.stationCod'," +  
55 - "b.station_name AS 'station.stationName'," +  
56 - "b.road_coding AS 'station.roadCoding'," +  
57 - "b.db_type AS 'station.dbType'," +  
58 - "b.b_jwpoints AS 'station.bJwpoints'," +  
59 - "b.g_lonx AS 'station.gLonx'," +  
60 - "b.g_lonx AS 'station.gLaty'," +  
61 - "b.x AS 'station.x'," +  
62 - "b.y AS 'station.y'," +  
63 - "b.shapes_type AS 'station.shapesType'," +  
64 - "b.radius AS 'station.radius'," +  
65 - "ST_AsText(b.g_polygon_grid) AS 'station.gPolygonGrid'," +  
66 - "ST_AsText(b.b_polygon_grid) AS 'station.bPolygonGrid'," +  
67 - "b.destroy AS 'station.destroy'," +  
68 - "b.versions AS 'station.versions'," +  
69 - "b.descriptions AS 'station.descriptions', " +  
70 - "a.`stationRoute.industryCode` " +  
71 - " FROM (" +  
72 - "SELECT r.id AS 'stationRoute.id'," +  
73 - " r.line AS 'stationRoute.line'," +  
74 - "r.station AS 'stationRoute.station'," +  
75 - "r.station_name AS 'stationRoute.stationName'," +  
76 - "r.station_route_code as 'stationRoute.stationRouteCode'," +  
77 - "r.line_code AS 'stationRoute.lineCode'," +  
78 - "r.station_mark AS 'stationRoute.stationMark'," +  
79 - "r.out_station_nmber AS 'stationRoute.outStationNmber'," +  
80 - "r.directions AS 'stationRoute.directions'," +  
81 - "r.distances AS 'stationRoute.distances'," +  
82 - "r.to_time AS 'stationRoute.toTime'," +  
83 - "r.first_time AS 'stationRoute.firstTime'," +  
84 - "r.end_time AS 'stationRoute.endTime'," +  
85 - "r.descriptions AS 'stationRoute.descriptions'," +  
86 - "r.versions AS 'stationRoute.versions', " +  
87 - "r.industry_code AS 'stationRoute.industryCode' " +  
88 - " FROM bsth_c_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.destroy=0) a " +  
89 - "LEFT JOIN bsth_c_station b " +  
90 - "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true)  
91 - List<Object[]> findPoints(int line,int directions);  
92 -  
93 - @Query("select r from StationRoute r where r.line.id=?1 and r.destroy=0 order by r.directions ASC ,r.stationRouteCode ASC")  
94 - // @Query(value = "SELECT * from bsth_c_stationroute line = ?1 and destroy=0 bsth_c_station ORDER BY directions ASC, stationRouteCode ASC", nativeQuery=true)  
95 - List<StationRoute> findStationExport(int line);  
96 -  
97 - /**  
98 - * @Description :TODO(查询线路某方向下的站点序号与类型)  
99 - *  
100 - * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>  
101 - *  
102 - * @return List<Map<String, Object>>  
103 - */  
104 - @Query(value = "select t.station_route_code,t.station_mark from bsth_c_stationroute t where " +  
105 - " t.station_route_code =(" +  
106 - "select MAX(station_route_code) as stationRouteCode from bsth_c_stationroute r WHERE " +  
107 - "r.line=?1 and r.directions =?2 and station_route_code< ?3 and r.destroy = 0 ) and t.line=?1 and t.directions = ?2 AND t.destroy = 0", nativeQuery=true)  
108 - List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode);  
109 -  
110 - /**  
111 - * @Description :TODO(查询下个站点)  
112 - *  
113 - * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>  
114 - *  
115 - * @return List<Map<String, Object>>  
116 - */  
117 - @Query(value = "SELECT a.stationRouteLine," +  
118 - " a.stationRouteStation," +  
119 - " a.stationRouteCode," +  
120 - " a.stationRouteLIneCode," +  
121 - " a.stationRouteStationMark," +  
122 - " a.stationOutStationNmber," +  
123 - " a.stationRoutedirections," +  
124 - " a.stationRouteDistances," +  
125 - " a.stationRouteToTime," +  
126 - " a.staitonRouteFirstTime," +  
127 - " a.stationRouteEndTime," +  
128 - " a.stationRouteDescriptions," +  
129 - " a.stationRouteDestroy," +  
130 - " a.stationRouteVersions," +  
131 - " a.stationRouteCreateBy," +  
132 - " a.stationRouteCreateDate," +  
133 - " a.stationRouteUpdateBy," +  
134 - " a.stationRouteUpdateDate," +  
135 - " b.id AS stationId," +  
136 - " b.station_cod AS stationCode," +  
137 - " a.stationRouteName," +  
138 - " b.road_coding AS stationRoadCoding," +  
139 - " b.db_type AS stationDbType," +  
140 - " b.b_jwpoints AS stationJwpoints," +  
141 - " b.g_lonx AS stationGlonx," +  
142 - " b.g_laty AS stationGlaty," +  
143 - " b.x AS stationX," +  
144 - " b.y AS stationY," +  
145 - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +  
146 - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +  
147 - " b.destroy AS stationDestroy," +  
148 - " b.radius AS stationRadius," +  
149 - " b.shapes_type AS stationShapesType," +  
150 - " b.versions AS stationVersions," +  
151 - " b.descriptions AS sttationDescriptions," +  
152 - " b.create_by AS stationCreateBy," +  
153 - " b.create_date AS stationCreateDate," +  
154 - " b.update_by AS stationUpdateBy," +  
155 - " b.update_date AS stationUpdateDate," +  
156 - " a.stationRouteId, " +  
157 - " b.station_name as zdmc, " +  
158 - " a.industryCode"+  
159 - " FROM " +  
160 - "( SELECT s.id AS stationRouteId," +  
161 - " s.line AS stationRouteLine," +  
162 - " s.station as stationRouteStation," +  
163 - " s.station_name AS stationRouteName," +  
164 - " s.station_route_code as stationRouteCode," +  
165 - " s.industry_code as industryCode," +  
166 - " s.line_code AS stationRouteLIneCode," +  
167 - " s.station_mark AS stationRouteStationMark," +  
168 - " s.out_station_nmber AS stationOutStationNmber," +  
169 - " s.directions AS stationRoutedirections," +  
170 - " s.distances AS stationRouteDistances," +  
171 - " s.to_time AS stationRouteToTime," +  
172 - " s.first_time AS staitonRouteFirstTime," +  
173 - " s.end_time AS stationRouteEndTime," +  
174 - " s.descriptions AS stationRouteDescriptions," +  
175 - " s.destroy AS stationRouteDestroy," +  
176 - " s.versions AS stationRouteVersions," +  
177 - " s.create_by AS stationRouteCreateBy," +  
178 - " s.create_date AS stationRouteCreateDate," +  
179 - " s.update_by AS stationRouteUpdateBy," +  
180 - " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.station_route_code =(" +  
181 - "select MIN(station_route_code) as stationRouteCode from bsth_c_stationroute r WHERE " +  
182 - "r.line=?1 and r.directions =?2 and station_route_code > ?3 and r.destroy = 0 ) and s.line=?1 and s.directions = ?2 AND s.destroy = 0) a " +  
183 - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)  
184 - List<Object[]> findDownStationRoute(Integer id,Integer direction,Integer stationRouteCode);  
185 -  
186 - /**  
187 - * @Description :TODO(站点中心点坐标查询)  
188 - *  
189 - * @param map <lineId:线路ID; direction:方向>  
190 - *  
191 - * @return List<Object[]>  
192 - */  
193 - /*@Query(value = "SELECT s.b_jwpoints,s.station_name FROM (" +  
194 - "SELECT b.station FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " +  
195 - "LEFT JOIN bsth_c_station s on r.station = s.id", nativeQuery=true)*/  
196 - @Query(value = "SELECT s.b_jwpoints,r.station_name,r.station_route_code FROM (" +  
197 - "SELECT b.station,b.station_route_code,b.station_name FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " +  
198 - "LEFT JOIN bsth_c_station s on r.station = s.id order by r.station_route_code asc", nativeQuery=true)  
199 - List<Object[]> getSelectStationRouteCenterPoints(Integer lineId,Integer direction);  
200 -  
201 - /**  
202 - * @Description :TODO(撤销站点)  
203 - *  
204 - * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)>  
205 - *  
206 - */  
207 - @Transactional  
208 - @Modifying  
209 - @Query(value="UPDATE bsth_c_stationroute SET " +  
210 - "destroy = ?2 WHERE id = ?1", nativeQuery=true)  
211 - void stationRouteIsDestroyUpd(Integer stationRouteId, Integer destroy);  
212 -  
213 -  
214 - /**  
215 - * @Description : TODO(根据线路ID生成行单)  
216 - *  
217 - * @param lineId:线路ID  
218 - *  
219 - * @return List<Object[]>:{[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标)  
220 - *  
221 - * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码);  
222 - *  
223 - * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)}  
224 - */  
225 - @Query(value = "SELECT * FROM ("+  
226 - "SELECT b.g_lonx," +  
227 - "b.g_laty,b.b_jwpoints," +  
228 - "a.station_mark," +  
229 - "a.station_route_code," +  
230 - "b.station_cod," +  
231 - "a.distances,"+  
232 - "a.station_name," +  
233 - "a.directions FROM (SELECT " +  
234 - "s.station_mark," +  
235 - "s.station_route_code," +  
236 - "s.directions," +  
237 - "s.distances,"+  
238 - "s.station_name,"+  
239 - "s.station FROM bsth_c_stationroute s where s.line = ?1 and s.destroy=0) a " +  
240 - "LEFT JOIN bsth_c_station b " +  
241 - " on a.station = b.id ORDER BY a.directions ASC ) k ORDER BY k.directions,k.station_route_code ASC", nativeQuery=true)  
242 - List<Object[]> usingSingle(Integer lineId);  
243 -  
244 - /**  
245 - * @Description : TODO(根据站点路由Id查询详情)  
246 - *  
247 - * @param id:站点路由ID  
248 - *  
249 - * @return List<Object[]>  
250 - */  
251 - @Query(value = "SELECT a.stationRouteLine," +  
252 - " a.stationRouteStation," +  
253 - " a.stationRouteCode," +  
254 - " a.stationRouteLIneCode," +  
255 - " a.stationRouteStationMark," +  
256 - " a.stationOutStationNmber," +  
257 - " a.stationRoutedirections," +  
258 - " a.stationRouteDistances," +  
259 - " a.stationRouteToTime," +  
260 - " a.staitonRouteFirstTime," +  
261 - " a.stationRouteEndTime," +  
262 - " a.stationRouteDescriptions," +  
263 - " a.stationRouteDestroy," +  
264 - " a.stationRouteVersions," +  
265 - " a.stationRouteCreateBy," +  
266 - " a.stationRouteCreateDate," +  
267 - " a.stationRouteUpdateBy," +  
268 - " a.stationRouteUpdateDate," +  
269 - " b.id AS stationId," +  
270 - " b.station_cod AS stationCode," +  
271 - " a.stationRouteName," +  
272 - " b.road_coding AS stationRoadCoding," +  
273 - " b.db_type AS stationDbType," +  
274 - " b.b_jwpoints AS stationJwpoints," +  
275 - " b.g_lonx AS stationGlonx," +  
276 - " b.g_laty AS stationGlaty," +  
277 - " b.x AS stationX," +  
278 - " b.y AS stationY," +  
279 - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +  
280 - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +  
281 - " b.destroy AS stationDestroy," +  
282 - " b.radius AS stationRadius," +  
283 - " b.shapes_type AS stationShapesType," +  
284 - " b.versions AS stationVersions," +  
285 - " b.descriptions AS sttationDescriptions," +  
286 - " b.create_by AS stationCreateBy," +  
287 - " b.create_date AS stationCreateDate," +  
288 - " b.update_by AS stationUpdateBy," +  
289 - " b.update_date AS stationUpdateDate," +  
290 - " a.stationRouteId,b.station_name as zdmc, " +  
291 - " a.industryCode "+  
292 - " FROM " +  
293 - "( SELECT s.id AS stationRouteId," +  
294 - " s.line AS stationRouteLine," +  
295 - " s.station as stationRouteStation," +  
296 - " s.station_name AS stationRouteName," +  
297 - " s.station_route_code as stationRouteCode," +  
298 - " s.industry_code as industryCode," +  
299 - " s.line_code AS stationRouteLIneCode," +  
300 - " s.station_mark AS stationRouteStationMark," +  
301 - " s.out_station_nmber AS stationOutStationNmber," +  
302 - " s.directions AS stationRoutedirections," +  
303 - " s.distances AS stationRouteDistances," +  
304 - " s.to_time AS stationRouteToTime," +  
305 - " s.first_time AS staitonRouteFirstTime," +  
306 - " s.end_time AS stationRouteEndTime," +  
307 - " s.descriptions AS stationRouteDescriptions," +  
308 - " s.destroy AS stationRouteDestroy," +  
309 - " s.versions AS stationRouteVersions," +  
310 - " s.create_by AS stationRouteCreateBy," +  
311 - " s.create_date AS stationRouteCreateDate," +  
312 - " s.update_by AS stationRouteUpdateBy," +  
313 - " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " +  
314 - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)  
315 - List<Object[]> findStationRouteInfo(Integer id);  
316 -  
317 - /**  
318 - * @Description : TODO(根据站点路由Id查询详情)  
319 - *  
320 - * @param id:站点路由ID  
321 - *  
322 - * @return List<Object[]>  
323 - */  
324 - @Query(value = "SELECT a.stationRouteLine," +  
325 - " a.stationRouteStation," +  
326 - " a.stationRouteCode," +  
327 - " a.stationRouteLIneCode," +  
328 - " a.stationRouteStationMark," +  
329 - " a.stationOutStationNmber," +  
330 - " a.stationRoutedirections," +  
331 - " a.stationRouteDistances," +  
332 - " a.stationRouteToTime," +  
333 - " a.staitonRouteFirstTime," +  
334 - " a.stationRouteEndTime," +  
335 - " a.stationRouteDescriptions," +  
336 - " a.stationRouteDestroy," +  
337 - " a.stationRouteVersions," +  
338 - " a.stationRouteCreateBy," +  
339 - " a.stationRouteCreateDate," +  
340 - " a.stationRouteUpdateBy," +  
341 - " a.stationRouteUpdateDate," +  
342 - " b.id AS stationId," +  
343 - " b.station_cod AS stationCode," +  
344 - " a.stationRouteName," +  
345 - " b.road_coding AS stationRoadCoding," +  
346 - " b.db_type AS stationDbType," +  
347 - " b.b_jwpoints AS stationJwpoints," +  
348 - " b.g_lonx AS stationGlonx," +  
349 - " b.g_laty AS stationGlaty," +  
350 - " b.x AS stationX," +  
351 - " b.y AS stationY," +  
352 - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +  
353 - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +  
354 - " b.destroy AS stationDestroy," +  
355 - " b.radius AS stationRadius," +  
356 - " b.shapes_type AS stationShapesType," +  
357 - " b.versions AS stationVersions," +  
358 - " b.descriptions AS sttationDescriptions," +  
359 - " b.create_by AS stationCreateBy," +  
360 - " b.create_date AS stationCreateDate," +  
361 - " b.update_by AS stationUpdateBy," +  
362 - " b.update_date AS stationUpdateDate," +  
363 - " a.stationRouteId," +  
364 - "b.station_name as zdmc, "+  
365 - "a.industryCode "+  
366 - " FROM ( SELECT s.id AS stationRouteId," +  
367 - " s.line AS stationRouteLine," +  
368 - " s.station as stationRouteStation," +  
369 - " s.station_name AS stationRouteName," +  
370 - " s.station_route_code as stationRouteCode," +  
371 - " s.industry_code as industryCode," +  
372 - " s.line_code AS stationRouteLIneCode," +  
373 - " s.station_mark AS stationRouteStationMark," +  
374 - " s.out_station_nmber AS stationOutStationNmber," +  
375 - " s.directions AS stationRoutedirections," +  
376 - " s.distances AS stationRouteDistances," +  
377 - " s.to_time AS stationRouteToTime," +  
378 - " s.first_time AS staitonRouteFirstTime," +  
379 - " s.end_time AS stationRouteEndTime," +  
380 - " s.descriptions AS stationRouteDescriptions," +  
381 - " s.destroy AS stationRouteDestroy," +  
382 - " s.versions AS stationRouteVersions," +  
383 - " s.create_by AS stationRouteCreateBy," +  
384 - " s.create_date AS stationRouteCreateDate," +  
385 - " s.update_by AS stationRouteUpdateBy," +  
386 - " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.line = ?1 and s.directions = ?2 and s.destroy = 0) a " +  
387 - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id order by a.stationRouteCode", nativeQuery=true)  
388 - List<Object[]> getStationRouteList(Integer lineId, Integer dir);  
389 -  
390 - List<StationRoute> findByLine(Line line);  
391 -  
392 - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)  
393 - @Query("select s from StationRoute s where s.destroy=0")  
394 - List<StationRoute> findAllEffective();  
395 -  
396 - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)  
397 - @Override  
398 - Page<StationRoute> findAll(Specification<StationRoute> spec, Pageable pageable);  
399 -  
400 - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)  
401 - @Override  
402 - List<StationRoute> findAll(Specification<StationRoute> spec);  
403 -  
404 - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)  
405 - @Override  
406 - List<StationRoute> findAll(Specification<StationRoute> spec, Sort sort);  
407 -  
408 - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)  
409 - @Override  
410 - @Query(value = "select r from StationRoute r where r.destroy=0")  
411 - List<StationRoute> findAll();  
412 -  
413 - @Query("select new map(sr.station.id as stationid, sr.stationName as stationname) from StationRoute sr where sr.line.id=?1 and sr.directions=?2")  
414 - List<Map<String, Object>> findStations(Integer xlid, Integer xldir);  
415 -  
416 - @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")  
417 - List<StationRoute> findByLine(String lineCode, int updown);  
418 -  
419 - @Query("select r from StationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")  
420 - List<StationRoute> findByLine(Integer lineId, Integer dir);  
421 -  
422 - @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)  
423 - @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1")  
424 - List<StationRoute> findByLineCode(String lineCode);  
425 -  
426 - @Query("SELECT new map(" +  
427 - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +  
428 - "line.linePlayType as linePlayType,s.stationMark as stationMark) " +  
429 - "FROM " +  
430 - "StationRoute s " +  
431 - "WHERE " +  
432 - "s.destroy = 0 " +  
433 - "and s.lineCode in(select lineCode from Line where inUse = 1) " +  
434 - "ORDER BY " +  
435 - "lineCode,directions,stationRouteCode")  
436 - List<Map<String, String>> findLineWithYgcAndInuse();  
437 -  
438 - @Query("SELECT new map(" +  
439 - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +  
440 - "line.linePlayType as linePlayType,s.stationMark as stationMark) " +  
441 - "FROM " +  
442 - "StationRoute s " +  
443 - "WHERE " +  
444 - "s.destroy = 0 " +  
445 - "ORDER BY " +  
446 - "lineCode,directions,stationRouteCode")  
447 - List<Map<String, String>> findAllLineWithYgc();  
448 -  
449 - @Query("SELECT new map(" +  
450 - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +  
451 - "line.linePlayType as linePlayType,s.stationMark as stationMark) " +  
452 - "FROM " +  
453 - "StationRoute s " +  
454 - "WHERE " +  
455 - "s.destroy = 0 and s.lineCode = ?1 " +  
456 - "ORDER BY " +  
457 - "lineCode,directions,stationRouteCode")  
458 - List<Map<String, String>> findLineWithYgcByLine(String lineCode);  
459 -  
460 - @Modifying  
461 - @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true)  
462 - void stationRouteDir(Integer line);  
463 -  
464 - @Modifying  
465 - @Query(value="update bsth_c_stationroute set distances =?2 where id = ?1 ", nativeQuery=true)  
466 - void upddis(Integer id,Double dis);  
467 -  
468 - @Modifying  
469 - @Query(value="UPDATE bsth_c_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true)  
470 - void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod);  
471 -  
472 - /**  
473 - * 更新路线前撤销线路原有站点  
474 - *  
475 - * @param line  
476 - * @param dir  
477 - */  
478 - @Modifying  
479 - @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true)  
480 - void stationRouteUpdDestroy(Integer line,Integer dir);  
481 -  
482 - @Modifying  
483 - @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where id = ?1", nativeQuery=true)  
484 - void stationRouteIsDestroyUpdBatch(Integer ids);  
485 -  
486 - /**  
487 - *  
488 - *  
489 - * @param line  
490 - * @param dir  
491 - */  
492 - @Modifying  
493 - @Query(value="insert into (select * from bsth_c_stationroute_cache where line = ?1 and directions = ?2) bsth_c_stationroute", nativeQuery=true)  
494 - void stationRouteUpdate(Integer line,Integer dir);  
495 -  
496 - // 更具线路批量撤销  
497 - @Modifying  
498 - @Query(value="UPDATE StationRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2")  
499 - void batchUpdate(Integer lineId, String lineCode);  
500 -  
501 - // 批量删除  
502 - @Modifying  
503 - @Query(value="delete from StationRoute sr where sr.line.id = ?1 and sr.lineCode = ?2")  
504 - void batchDelete(Integer lineId, String lineCode);  
505 -  
506 -  
507 - // 批量修改站点行业编码  
508 - @Modifying  
509 - @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true)  
510 - void updIndustryCode(Integer id,String IndustryCode);  
511 -} 1 +package com.bsth.repository;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  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 +import org.springframework.data.jpa.repository.Modifying;
  12 +import org.springframework.data.jpa.repository.Query;
  13 +import org.springframework.stereotype.Repository;
  14 +import org.springframework.transaction.annotation.Transactional;
  15 +
  16 +import com.bsth.entity.Line;
  17 +import com.bsth.entity.StationRoute;
  18 +
  19 +/**
  20 + *
  21 + * @Interface: StationRouteRepository(站点路由Repository数据持久层接口)
  22 + *
  23 + * @Extends : BaseRepository
  24 + *
  25 + * @Description: TODO(站点路由Repository数据持久层接口)
  26 + *
  27 + * @Author bsth@lq
  28 + *
  29 + * @Date 2016年5月03日 上午9:21:17
  30 + *
  31 + * @Version 公交调度系统BS版 0.1
  32 + *
  33 + */
  34 +
  35 +@Repository
  36 +public interface StationRouteRepository extends BaseRepository<StationRoute, Integer> {
  37 +
  38 + @Query(value = "SELECT a.`stationRoute.id`," +
  39 + "a.`stationRoute.line`," +
  40 + "a.`stationRoute.station`," +
  41 + "a.`stationRoute.stationName`," +
  42 + "a.`stationRoute.stationRouteCode`," +
  43 + "a.`stationRoute.lineCode`," +
  44 + "a.`stationRoute.stationMark`," +
  45 + "a.`stationRoute.outStationNmber`," +
  46 + "a.`stationRoute.directions`," +
  47 + "a.`stationRoute.distances`," +
  48 + "a.`stationRoute.toTime`," +
  49 + "a.`stationRoute.firstTime`," +
  50 + "a.`stationRoute.endTime`," +
  51 + "a.`stationRoute.descriptions`," +
  52 + "a.`stationRoute.versions`," +
  53 + "b.id AS 'station.id'," +
  54 + "b.station_cod AS 'station.stationCod'," +
  55 + "b.station_name AS 'station.stationName'," +
  56 + "b.road_coding AS 'station.roadCoding'," +
  57 + "b.db_type AS 'station.dbType'," +
  58 + "b.b_jwpoints AS 'station.bJwpoints'," +
  59 + "b.g_lonx AS 'station.gLonx'," +
  60 + "b.g_lonx AS 'station.gLaty'," +
  61 + "b.x AS 'station.x'," +
  62 + "b.y AS 'station.y'," +
  63 + "b.shapes_type AS 'station.shapesType'," +
  64 + "b.radius AS 'station.radius'," +
  65 + "ST_AsText(b.g_polygon_grid) AS 'station.gPolygonGrid'," +
  66 + "ST_AsText(b.b_polygon_grid) AS 'station.bPolygonGrid'," +
  67 + "b.destroy AS 'station.destroy'," +
  68 + "b.versions AS 'station.versions'," +
  69 + "b.descriptions AS 'station.descriptions', " +
  70 + "a.`stationRoute.industryCode` " +
  71 + " FROM (" +
  72 + "SELECT r.id AS 'stationRoute.id'," +
  73 + " r.line AS 'stationRoute.line'," +
  74 + "r.station AS 'stationRoute.station'," +
  75 + "r.station_name AS 'stationRoute.stationName'," +
  76 + "r.station_route_code as 'stationRoute.stationRouteCode'," +
  77 + "r.line_code AS 'stationRoute.lineCode'," +
  78 + "r.station_mark AS 'stationRoute.stationMark'," +
  79 + "r.out_station_nmber AS 'stationRoute.outStationNmber'," +
  80 + "r.directions AS 'stationRoute.directions'," +
  81 + "r.distances AS 'stationRoute.distances'," +
  82 + "r.to_time AS 'stationRoute.toTime'," +
  83 + "r.first_time AS 'stationRoute.firstTime'," +
  84 + "r.end_time AS 'stationRoute.endTime'," +
  85 + "r.descriptions AS 'stationRoute.descriptions'," +
  86 + "r.versions AS 'stationRoute.versions', " +
  87 + "r.industry_code AS 'stationRoute.industryCode' " +
  88 + " FROM bsth_c_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.destroy=0) a " +
  89 + "LEFT JOIN bsth_c_station b " +
  90 + "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true)
  91 + List<Object[]> findPoints(int line,int directions);
  92 +
  93 + @Query("select r from StationRoute r where r.line.id=?1 and r.destroy=0 order by r.directions ASC ,r.stationRouteCode ASC")
  94 + // @Query(value = "SELECT * from bsth_c_stationroute line = ?1 and destroy=0 bsth_c_station ORDER BY directions ASC, stationRouteCode ASC", nativeQuery=true)
  95 + List<StationRoute> findStationExport(int line);
  96 +
  97 + /**
  98 + * @Description :TODO(查询线路某方向下的站点序号与类型)
  99 + *
  100 + * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>
  101 + *
  102 + * @return List<Map<String, Object>>
  103 + */
  104 + @Query(value = "select t.station_route_code,t.station_mark from bsth_c_stationroute t where " +
  105 + " t.station_route_code =(" +
  106 + "select MAX(station_route_code) as stationRouteCode from bsth_c_stationroute r WHERE " +
  107 + "r.line=?1 and r.directions =?2 and station_route_code< ?3 and r.destroy = 0 ) and t.line=?1 and t.directions = ?2 AND t.destroy = 0", nativeQuery=true)
  108 + List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode);
  109 +
  110 + /**
  111 + * @param version
  112 + * @Description :TODO(查询下个站点)
  113 + *
  114 + * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>
  115 + *
  116 + * @return List<Map<String, Object>>
  117 + */
  118 + @Query(value = "SELECT a.stationRouteLine," +
  119 + " a.stationRouteStation," +
  120 + " a.stationRouteCode," +
  121 + " a.stationRouteLIneCode," +
  122 + " a.stationRouteStationMark," +
  123 + " a.stationOutStationNmber," +
  124 + " a.stationRoutedirections," +
  125 + " a.stationRouteDistances," +
  126 + " a.stationRouteToTime," +
  127 + " a.staitonRouteFirstTime," +
  128 + " a.stationRouteEndTime," +
  129 + " a.stationRouteDescriptions," +
  130 + " a.stationRouteDestroy," +
  131 + " a.stationRouteVersions," +
  132 + " a.stationRouteCreateBy," +
  133 + " a.stationRouteCreateDate," +
  134 + " a.stationRouteUpdateBy," +
  135 + " a.stationRouteUpdateDate," +
  136 + " b.id AS stationId," +
  137 + " b.station_cod AS stationCode," +
  138 + " a.stationRouteName," +
  139 + " b.road_coding AS stationRoadCoding," +
  140 + " b.db_type AS stationDbType," +
  141 + " b.b_jwpoints AS stationJwpoints," +
  142 + " b.g_lonx AS stationGlonx," +
  143 + " b.g_laty AS stationGlaty," +
  144 + " b.x AS stationX," +
  145 + " b.y AS stationY," +
  146 + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
  147 + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
  148 + " b.destroy AS stationDestroy," +
  149 + " b.radius AS stationRadius," +
  150 + " b.shapes_type AS stationShapesType," +
  151 + " b.versions AS stationVersions," +
  152 + " b.descriptions AS sttationDescriptions," +
  153 + " b.create_by AS stationCreateBy," +
  154 + " b.create_date AS stationCreateDate," +
  155 + " b.update_by AS stationUpdateBy," +
  156 + " b.update_date AS stationUpdateDate," +
  157 + " a.stationRouteId, " +
  158 + " b.station_name as zdmc, " +
  159 + " a.industryCode"+
  160 + " FROM " +
  161 + "( SELECT s.id AS stationRouteId," +
  162 + " s.line AS stationRouteLine," +
  163 + " s.station as stationRouteStation," +
  164 + " s.station_name AS stationRouteName," +
  165 + " s.station_route_code as stationRouteCode," +
  166 + " s.industry_code as industryCode," +
  167 + " s.line_code AS stationRouteLIneCode," +
  168 + " s.station_mark AS stationRouteStationMark," +
  169 + " s.out_station_nmber AS stationOutStationNmber," +
  170 + " s.directions AS stationRoutedirections," +
  171 + " s.distances AS stationRouteDistances," +
  172 + " s.to_time AS stationRouteToTime," +
  173 + " s.first_time AS staitonRouteFirstTime," +
  174 + " s.end_time AS stationRouteEndTime," +
  175 + " s.descriptions AS stationRouteDescriptions," +
  176 + " s.destroy AS stationRouteDestroy," +
  177 + " s.versions AS stationRouteVersions," +
  178 + " s.create_by AS stationRouteCreateBy," +
  179 + " s.create_date AS stationRouteCreateDate," +
  180 + " s.update_by AS stationRouteUpdateBy," +
  181 + " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.versions = ?4 and s.station_route_code =(" +
  182 + "select MIN(station_route_code) as stationRouteCode from bsth_c_ls_stationroute r WHERE " +
  183 + "r.line=?1 and r.directions =?2 and station_route_code > ?3 and r.destroy = 0 and versions = ?4 ) and s.line=?1 and s.directions = ?2 AND s.destroy = 0) a " +
  184 + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)
  185 + List<Object[]> findDownStationRoute(Integer id,Integer direction,Integer stationRouteCode, Integer version);
  186 +
  187 + /**
  188 + * @Description :TODO(站点中心点坐标查询)
  189 + *
  190 + * @param map <lineId:线路ID; direction:方向>
  191 + *
  192 + * @return List<Object[]>
  193 + */
  194 + /*@Query(value = "SELECT s.b_jwpoints,s.station_name FROM (" +
  195 + "SELECT b.station FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " +
  196 + "LEFT JOIN bsth_c_station s on r.station = s.id", nativeQuery=true)*/
  197 + @Query(value = "SELECT s.b_jwpoints,r.station_name,r.station_route_code FROM (" +
  198 + "SELECT b.station,b.station_route_code,b.station_name FROM bsth_c_stationroute b where b.line =?1 and b.directions = ?2 and b.destroy=0) r " +
  199 + "LEFT JOIN bsth_c_station s on r.station = s.id order by r.station_route_code asc", nativeQuery=true)
  200 + List<Object[]> getSelectStationRouteCenterPoints(Integer lineId,Integer direction);
  201 +
  202 + /**
  203 + * @Description :TODO(撤销站点)
  204 + *
  205 + * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)>
  206 + *
  207 + */
  208 + @Transactional
  209 + @Modifying
  210 + @Query(value="UPDATE bsth_c_stationroute SET " +
  211 + "destroy = ?2 WHERE id = ?1", nativeQuery=true)
  212 + void stationRouteIsDestroyUpd(Integer stationRouteId, Integer destroy);
  213 +
  214 +
  215 + /**
  216 + * @Description : TODO(根据线路ID生成行单)
  217 + *
  218 + * @param lineId:线路ID
  219 + *
  220 + * @return List<Object[]>:{[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标)
  221 + *
  222 + * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码);
  223 + *
  224 + * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)}
  225 + */
  226 + @Query(value = "SELECT * FROM ("+
  227 + "SELECT b.g_lonx," +
  228 + "b.g_laty,b.b_jwpoints," +
  229 + "a.station_mark," +
  230 + "a.station_route_code," +
  231 + "b.station_cod," +
  232 + "a.distances,"+
  233 + "a.station_name," +
  234 + "a.directions FROM (SELECT " +
  235 + "s.station_mark," +
  236 + "s.station_route_code," +
  237 + "s.directions," +
  238 + "s.distances,"+
  239 + "s.station_name,"+
  240 + "s.station FROM bsth_c_stationroute s where s.line = ?1 and s.destroy=0) a " +
  241 + "LEFT JOIN bsth_c_station b " +
  242 + " on a.station = b.id ORDER BY a.directions ASC ) k ORDER BY k.directions,k.station_route_code ASC", nativeQuery=true)
  243 + List<Object[]> usingSingle(Integer lineId);
  244 +
  245 + /**
  246 + * @Description : TODO(根据站点路由Id查询详情)
  247 + *
  248 + * @param id:站点路由ID
  249 + *
  250 + * @return List<Object[]>
  251 + */
  252 + @Query(value = "SELECT a.stationRouteLine," +
  253 + " a.stationRouteStation," +
  254 + " a.stationRouteCode," +
  255 + " a.stationRouteLIneCode," +
  256 + " a.stationRouteStationMark," +
  257 + " a.stationOutStationNmber," +
  258 + " a.stationRoutedirections," +
  259 + " a.stationRouteDistances," +
  260 + " a.stationRouteToTime," +
  261 + " a.staitonRouteFirstTime," +
  262 + " a.stationRouteEndTime," +
  263 + " a.stationRouteDescriptions," +
  264 + " a.stationRouteDestroy," +
  265 + " a.stationRouteVersions," +
  266 + " a.stationRouteCreateBy," +
  267 + " a.stationRouteCreateDate," +
  268 + " a.stationRouteUpdateBy," +
  269 + " a.stationRouteUpdateDate," +
  270 + " b.id AS stationId," +
  271 + " b.station_cod AS stationCode," +
  272 + " a.stationRouteName," +
  273 + " b.road_coding AS stationRoadCoding," +
  274 + " b.db_type AS stationDbType," +
  275 + " b.b_jwpoints AS stationJwpoints," +
  276 + " b.g_lonx AS stationGlonx," +
  277 + " b.g_laty AS stationGlaty," +
  278 + " b.x AS stationX," +
  279 + " b.y AS stationY," +
  280 + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
  281 + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
  282 + " b.destroy AS stationDestroy," +
  283 + " b.radius AS stationRadius," +
  284 + " b.shapes_type AS stationShapesType," +
  285 + " b.versions AS stationVersions," +
  286 + " b.descriptions AS sttationDescriptions," +
  287 + " b.create_by AS stationCreateBy," +
  288 + " b.create_date AS stationCreateDate," +
  289 + " b.update_by AS stationUpdateBy," +
  290 + " b.update_date AS stationUpdateDate," +
  291 + " a.stationRouteId,b.station_name as zdmc, " +
  292 + " a.industryCode "+
  293 + " FROM " +
  294 + "( SELECT s.id AS stationRouteId," +
  295 + " s.line AS stationRouteLine," +
  296 + " s.station as stationRouteStation," +
  297 + " s.station_name AS stationRouteName," +
  298 + " s.station_route_code as stationRouteCode," +
  299 + " s.industry_code as industryCode," +
  300 + " s.line_code AS stationRouteLIneCode," +
  301 + " s.station_mark AS stationRouteStationMark," +
  302 + " s.out_station_nmber AS stationOutStationNmber," +
  303 + " s.directions AS stationRoutedirections," +
  304 + " s.distances AS stationRouteDistances," +
  305 + " s.to_time AS stationRouteToTime," +
  306 + " s.first_time AS staitonRouteFirstTime," +
  307 + " s.end_time AS stationRouteEndTime," +
  308 + " s.descriptions AS stationRouteDescriptions," +
  309 + " s.destroy AS stationRouteDestroy," +
  310 + " s.versions AS stationRouteVersions," +
  311 + " s.create_by AS stationRouteCreateBy," +
  312 + " s.create_date AS stationRouteCreateDate," +
  313 + " s.update_by AS stationRouteUpdateBy," +
  314 + " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " +
  315 + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)
  316 + List<Object[]> findStationRouteInfo(Integer id);
  317 +
  318 + /**
  319 + * @Description : TODO(根据站点路由Id查询详情)
  320 + *
  321 + * @param id:站点路由ID
  322 + *
  323 + * @return List<Object[]>
  324 + */
  325 + @Query(value = "SELECT a.stationRouteLine," +
  326 + " a.stationRouteStation," +
  327 + " a.stationRouteCode," +
  328 + " a.stationRouteLIneCode," +
  329 + " a.stationRouteStationMark," +
  330 + " a.stationOutStationNmber," +
  331 + " a.stationRoutedirections," +
  332 + " a.stationRouteDistances," +
  333 + " a.stationRouteToTime," +
  334 + " a.staitonRouteFirstTime," +
  335 + " a.stationRouteEndTime," +
  336 + " a.stationRouteDescriptions," +
  337 + " a.stationRouteDestroy," +
  338 + " a.stationRouteVersions," +
  339 + " a.stationRouteCreateBy," +
  340 + " a.stationRouteCreateDate," +
  341 + " a.stationRouteUpdateBy," +
  342 + " a.stationRouteUpdateDate," +
  343 + " b.id AS stationId," +
  344 + " b.station_cod AS stationCode," +
  345 + " a.stationRouteName," +
  346 + " b.road_coding AS stationRoadCoding," +
  347 + " b.db_type AS stationDbType," +
  348 + " b.b_jwpoints AS stationJwpoints," +
  349 + " b.g_lonx AS stationGlonx," +
  350 + " b.g_laty AS stationGlaty," +
  351 + " b.x AS stationX," +
  352 + " b.y AS stationY," +
  353 + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
  354 + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
  355 + " b.destroy AS stationDestroy," +
  356 + " b.radius AS stationRadius," +
  357 + " b.shapes_type AS stationShapesType," +
  358 + " b.versions AS stationVersions," +
  359 + " b.descriptions AS sttationDescriptions," +
  360 + " b.create_by AS stationCreateBy," +
  361 + " b.create_date AS stationCreateDate," +
  362 + " b.update_by AS stationUpdateBy," +
  363 + " b.update_date AS stationUpdateDate," +
  364 + " a.stationRouteId," +
  365 + "b.station_name as zdmc, "+
  366 + "a.industryCode "+
  367 + " FROM ( SELECT s.id AS stationRouteId," +
  368 + " s.line AS stationRouteLine," +
  369 + " s.station as stationRouteStation," +
  370 + " s.station_name AS stationRouteName," +
  371 + " s.station_route_code as stationRouteCode," +
  372 + " s.industry_code as industryCode," +
  373 + " s.line_code AS stationRouteLIneCode," +
  374 + " s.station_mark AS stationRouteStationMark," +
  375 + " s.out_station_nmber AS stationOutStationNmber," +
  376 + " s.directions AS stationRoutedirections," +
  377 + " s.distances AS stationRouteDistances," +
  378 + " s.to_time AS stationRouteToTime," +
  379 + " s.first_time AS staitonRouteFirstTime," +
  380 + " s.end_time AS stationRouteEndTime," +
  381 + " s.descriptions AS stationRouteDescriptions," +
  382 + " s.destroy AS stationRouteDestroy," +
  383 + " s.versions AS stationRouteVersions," +
  384 + " s.create_by AS stationRouteCreateBy," +
  385 + " s.create_date AS stationRouteCreateDate," +
  386 + " s.update_by AS stationRouteUpdateBy," +
  387 + " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.line = ?1 and s.directions = ?2 and s.destroy = 0) a " +
  388 + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id order by a.stationRouteCode", nativeQuery=true)
  389 + List<Object[]> getStationRouteList(Integer lineId, Integer dir);
  390 +
  391 + List<StationRoute> findByLine(Line line);
  392 +
  393 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  394 + @Query("select s from StationRoute s where s.destroy=0")
  395 + List<StationRoute> findAllEffective();
  396 +
  397 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  398 + @Override
  399 + Page<StationRoute> findAll(Specification<StationRoute> spec, Pageable pageable);
  400 +
  401 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  402 + @Override
  403 + List<StationRoute> findAll(Specification<StationRoute> spec);
  404 +
  405 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  406 + @Override
  407 + List<StationRoute> findAll(Specification<StationRoute> spec, Sort sort);
  408 +
  409 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  410 + @Override
  411 + @Query(value = "select r from StationRoute r where r.destroy=0")
  412 + List<StationRoute> findAll();
  413 +
  414 + @Query("select new map(sr.station.id as stationid, sr.stationName as stationname) from StationRoute sr where sr.line.id=?1 and sr.directions=?2")
  415 + List<Map<String, Object>> findStations(Integer xlid, Integer xldir);
  416 +
  417 + @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
  418 + List<StationRoute> findByLine(String lineCode, int updown);
  419 +
  420 + @Query("select r from StationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
  421 + List<StationRoute> findByLine(Integer lineId, Integer dir);
  422 +
  423 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  424 + @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1")
  425 + List<StationRoute> findByLineCode(String lineCode);
  426 +
  427 + @Query("SELECT new map(" +
  428 + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +
  429 + "line.linePlayType as linePlayType,s.stationMark as stationMark) " +
  430 + "FROM " +
  431 + "StationRoute s " +
  432 + "WHERE " +
  433 + "s.destroy = 0 " +
  434 + "and s.lineCode in(select lineCode from Line where inUse = 1) " +
  435 + "ORDER BY " +
  436 + "lineCode,directions,stationRouteCode")
  437 + List<Map<String, String>> findLineWithYgcAndInuse();
  438 +
  439 + @Query("SELECT new map(" +
  440 + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +
  441 + "line.linePlayType as linePlayType,s.stationMark as stationMark) " +
  442 + "FROM " +
  443 + "StationRoute s " +
  444 + "WHERE " +
  445 + "s.destroy = 0 " +
  446 + "ORDER BY " +
  447 + "lineCode,directions,stationRouteCode")
  448 + List<Map<String, String>> findAllLineWithYgc();
  449 +
  450 + @Query("SELECT new map(" +
  451 + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +
  452 + "line.linePlayType as linePlayType,s.stationMark as stationMark) " +
  453 + "FROM " +
  454 + "StationRoute s " +
  455 + "WHERE " +
  456 + "s.destroy = 0 and s.lineCode = ?1 " +
  457 + "ORDER BY " +
  458 + "lineCode,directions,stationRouteCode")
  459 + List<Map<String, String>> findLineWithYgcByLine(String lineCode);
  460 +
  461 + @Modifying
  462 + @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true)
  463 + void stationRouteDir(Integer line);
  464 +
  465 + @Modifying
  466 + @Query(value="update bsth_c_stationroute set distances =?2 where id = ?1 ", nativeQuery=true)
  467 + void upddis(Integer id,Double dis);
  468 +
  469 + @Modifying
  470 + @Query(value="UPDATE bsth_c_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true)
  471 + void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod);
  472 +
  473 + /**
  474 + * 更新路线前撤销线路原有站点
  475 + *
  476 + * @param line
  477 + * @param dir
  478 + */
  479 + @Modifying
  480 + @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true)
  481 + void stationRouteUpdDestroy(Integer line,Integer dir);
  482 +
  483 + @Modifying
  484 + @Query(value="UPDATE bsth_c_stationroute set destroy = 1 where id = ?1", nativeQuery=true)
  485 + void stationRouteIsDestroyUpdBatch(Integer ids);
  486 +
  487 + /**
  488 + *
  489 + *
  490 + * @param line
  491 + * @param dir
  492 + */
  493 + @Modifying
  494 + @Query(value="insert into (select * from bsth_c_stationroute_cache where line = ?1 and directions = ?2) bsth_c_stationroute", nativeQuery=true)
  495 + void stationRouteUpdate(Integer line,Integer dir);
  496 +
  497 + // 更具线路批量撤销
  498 + @Modifying
  499 + @Query(value="UPDATE StationRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2")
  500 + void batchUpdate(Integer lineId, String lineCode);
  501 +
  502 + // 批量删除
  503 + @Modifying
  504 + @Query(value="delete from StationRoute sr where sr.line.id = ?1 and sr.lineCode = ?2")
  505 + void batchDelete(Integer lineId, String lineCode);
  506 +
  507 +
  508 + // 批量修改站点行业编码
  509 + @Modifying
  510 + @Query(value="update bsth_c_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true)
  511 + void updIndustryCode(Integer id,String IndustryCode);
  512 +}
src/main/java/com/bsth/service/CarParkService.java
1 -package com.bsth.service;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import com.bsth.entity.CarPark;  
7 -  
8 -public interface CarParkService extends BaseService<CarPark, Integer> {  
9 -  
10 - Map<String, Object> carParkSave(Map<String, Object> map);  
11 -  
12 - List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map);  
13 -  
14 -  
15 - /**  
16 - * 修改停车场信息  
17 - *  
18 - *  
19 - * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;  
20 - *  
21 - * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;  
22 - *  
23 - * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;  
24 - *  
25 - * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>  
26 - *  
27 - * @return map <SUCCESS:成功;ERROR:失败>  
28 - *  
29 - */  
30 - Map<String, Object> carParkUpdate(Map<String, Object> map);  
31 -  
32 - boolean selectTccInfoByCode(Map<String, Object> map);  
33 -} 1 +package com.bsth.service;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.bsth.entity.CarPark;
  7 +
  8 +public interface CarParkService extends BaseService<CarPark, Integer> {
  9 +
  10 + Map<String, Object> carParkSave(Map<String, Object> map);
  11 +
  12 + List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map);
  13 +
  14 +
  15 + /**
  16 + * 修改停车场信息
  17 + *
  18 + *
  19 + * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;
  20 + *
  21 + * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;
  22 + *
  23 + * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;
  24 + *
  25 + * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>
  26 + *
  27 + * @return map <SUCCESS:成功;ERROR:失败>
  28 + *
  29 + */
  30 + Map<String, Object> carParkUpdate(Map<String, Object> map);
  31 +
  32 + boolean selectTccInfoByCode(Map<String, Object> map);
  33 +
  34 + long carParkMaxId();
  35 +}
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
1 -package com.bsth.service.geo_data.impl;  
2 -  
3 -import com.bsth.common.ResponseCode;  
4 -import com.bsth.entity.LineVersions;  
5 -import com.bsth.entity.geo_data.GeoLineVersionInfo;  
6 -import com.bsth.entity.geo_data.GeoRoad;  
7 -import com.bsth.entity.geo_data.GeoStation;  
8 -import com.bsth.service.geo_data.GeoDataService;  
9 -import com.bsth.service.geo_data.impl.dto.CascadeSaveRoad;  
10 -import com.bsth.service.geo_data.impl.dto.CascadeSaveStation;  
11 -import com.bsth.service.geo_data.impl.dto.SaveRoadRouteDTO;  
12 -import com.bsth.service.geo_data.impl.dto.SaveStationRouteDTO;  
13 -import com.bsth.util.GetUIDAndCode;  
14 -import com.bsth.util.TransGPS;  
15 -import com.google.common.base.Splitter;  
16 -import org.slf4j.Logger;  
17 -import org.slf4j.LoggerFactory;  
18 -import org.springframework.beans.factory.annotation.Autowired;  
19 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
20 -import org.springframework.jdbc.core.BeanPropertyRowMapper;  
21 -import org.springframework.jdbc.core.JdbcTemplate;  
22 -import org.springframework.jdbc.datasource.DataSourceTransactionManager;  
23 -import org.springframework.stereotype.Service;  
24 -import org.springframework.transaction.TransactionDefinition;  
25 -import org.springframework.transaction.TransactionStatus;  
26 -import org.springframework.transaction.support.DefaultTransactionDefinition;  
27 -  
28 -import java.sql.PreparedStatement;  
29 -import java.sql.SQLException;  
30 -import java.text.SimpleDateFormat;  
31 -import java.util.*;  
32 -  
33 -/**  
34 - * Created by panzhao on 2017/12/8.  
35 - */  
36 -@Service  
37 -public class GeoDataServiceImpl implements GeoDataService {  
38 -  
39 - @Autowired  
40 - JdbcTemplate jdbcTemplate;  
41 -  
42 - Logger logger = LoggerFactory.getLogger(this.getClass());  
43 -  
44 - @Override  
45 - public Map<String, Object> findGeoStations(String lineCode, Integer version) {  
46 -  
47 - Map<String, Object> map = new HashMap();  
48 - try {  
49 -  
50 - String sql = "select versions from bsth_c_line_versions where line='"+lineCode+"' and status=1";  
51 - //当前使用的线路版本  
52 - Integer currentVersion = jdbcTemplate.queryForObject(sql, Integer.class);  
53 -  
54 -  
55 - if(null == version)  
56 - version = currentVersion;  
57 -  
58 - sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and destroy=0 and versions="+version+") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod";  
59 -  
60 -  
61 - List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));  
62 -  
63 - for (GeoStation station : list) {  
64 - if (station.getShapesType().equals("d"))  
65 - station.setBdCoords(multiWgsToBd(station.getgPolygonGrid(), 9, 3));  
66 - }  
67 - map.put("status", ResponseCode.SUCCESS);  
68 - map.put("list", list);  
69 - map.put("currentVersion", currentVersion);  
70 - map.put("editVersion", version);  
71 - } catch (Exception e) {  
72 - logger.error("", e);  
73 - map.put("status", ResponseCode.ERROR);  
74 - map.put("msg", "服务器出现异常");  
75 - }  
76 - return map;  
77 - }  
78 -  
79 - @Override  
80 - public Map<String, Object> findGeoRoad(String lineCode,Integer version) {  
81 - Map<String, Object> map = new HashMap();  
82 - try {  
83 -  
84 - String sql = "select versions from bsth_c_line_versions where line='"+lineCode+"' and status=1";  
85 - //当前使用的线路版本  
86 - Integer currentVersion = jdbcTemplate.queryForObject(sql, Integer.class);  
87 -  
88 -  
89 - if(null == version)  
90 - version = currentVersion;  
91 -  
92 -  
93 - sql = "select t1.*,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector from (select id,sectionroute_code,directions,line_code,section_code,versions from bsth_c_ls_sectionroute where line=" + lineCode + " and destroy=0 and versions="+version+") t1 LEFT JOIN bsth_c_section t2 on t1.section_code=t2.section_code";  
94 -  
95 -  
96 - List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));  
97 -  
98 - for (GeoRoad road : list) {  
99 - road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));  
100 - }  
101 - map.put("status", ResponseCode.SUCCESS);  
102 - map.put("list", list);  
103 - } catch (Exception e) {  
104 - logger.error("", e);  
105 - map.put("status", ResponseCode.ERROR);  
106 - map.put("msg", "服务器出现异常");  
107 - }  
108 - return map;  
109 - }  
110 -  
111 - /**  
112 - * 编辑缓冲区信息  
113 - *  
114 - * @param station  
115 - * @return  
116 - */  
117 - @Override  
118 - public Map<String, Object> updateBufferInfo(GeoStation station) {  
119 - Map<String, Object> rs = new HashMap<>();  
120 - try {  
121 - //坐标转换  
122 - TransGPS.Location loc = TransGPS.LocationMake(station.getgLonx(), station.getgLaty());  
123 - loc = TransGPS.bd_decrypt(loc);  
124 - loc = TransGPS.transformFromGCJToWGS(loc);  
125 - station.setgLaty(Float.parseFloat(String.valueOf(loc.getLat())));  
126 - station.setgLonx(Float.parseFloat(String.valueOf(loc.getLng())));  
127 -  
128 - String sql;  
129 - String shapesType = station.getShapesType();  
130 - int rsCount = -1;  
131 - if (shapesType.equals("r")) {  
132 - sql = "update bsth_c_station set g_lonx=?, g_laty=?, radius=?,shapes_type='r' where station_cod=?";  
133 - rsCount = jdbcTemplate.update(sql, station.getgLonx(), station.getgLaty(), station.getRadius(), station.getStationCode());  
134 - } else if (shapesType.equals("d")) {  
135 - //多边形坐标转换  
136 - String bdPolygon = "POLYGON((" + station.getgPolygonGrid() + "))";  
137 - String wgsPolygon = "POLYGON((" + bdPolygon2Wgs(station.getgPolygonGrid()) + "))";  
138 - sql = "update bsth_c_station set g_lonx=?, g_laty=?,shapes_type='d', radius=null,b_polygon_grid=ST_GeomFromText('" + bdPolygon + "'),g_polygon_grid=ST_GeomFromText('" + wgsPolygon + "') where station_cod=?";  
139 -  
140 - rsCount = jdbcTemplate.update(sql, station.getgLonx(), station.getgLaty(), station.getStationCode());  
141 - }  
142 -  
143 - //从数据库里重新查询对象  
144 - if (rsCount > 0) {  
145 - rs.put("station", findOne(station.getId()));  
146 - rs.put("status", ResponseCode.SUCCESS);  
147 - }  
148 -  
149 - } catch (Exception e) {  
150 - logger.error("", e);  
151 - rs.put("status", ResponseCode.ERROR);  
152 - rs.put("msg", "服务器出现异常");  
153 - }  
154 - return rs;  
155 - }  
156 -  
157 - /**  
158 - * 修改站点路由和站点名称  
159 - *  
160 - * @param map  
161 - * @return  
162 - */  
163 - @Override  
164 - public Map<String, Object> updateStationName(Map<String, Object> map) {  
165 - Map<String, Object> rs = new HashMap<>();  
166 -  
167 - //编程式事务  
168 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
169 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
170 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
171 - TransactionStatus status = tran.getTransaction(def);  
172 - try {  
173 -  
174 - int id = Integer.parseInt(map.get("id").toString());  
175 - String name = map.get("stationName").toString();  
176 - String code = map.get("stationCode").toString();  
177 - String lineCode = map.get("lineCode").toString();  
178 - String versions = map.get("versions").toString();  
179 -  
180 - //更新历史站点路由  
181 - jdbcTemplate.update("update bsth_c_ls_stationroute set station_name=? where id=?", name, id);  
182 - //更新站点  
183 - jdbcTemplate.update("update bsth_c_station set station_name=? where station_cod=?", name, code);  
184 -  
185 - //写一条走向变更记录  
186 - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions);  
187 -  
188 - tran.commit(status);  
189 -  
190 - rs.put("station", findOne(id));  
191 - rs.put("status", ResponseCode.SUCCESS);  
192 - } catch (Exception e) {  
193 - tran.rollback(status);  
194 - logger.error("", e);  
195 - rs.put("status", ResponseCode.ERROR);  
196 - rs.put("msg", "服务器出现异常");  
197 - }  
198 - return rs;  
199 - }  
200 -  
201 - @Override  
202 - public Map<String, Object> addNewRoadRoute(String lineCode, int upDown, int versions, String sectionName, String crosesRoad, String coords, int prevRouteId) {  
203 - Map<String, Object> rs = new HashMap<>();  
204 -  
205 - //编程式事务  
206 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
207 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
208 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
209 - TransactionStatus status = tran.getTransaction(def);  
210 - try {  
211 - //根据线路编码,查询线路ID  
212 - int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);  
213 -  
214 - String sql = "select * from bsth_c_ls_sectionroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions;  
215 - List<SaveRoadRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveRoadRouteDTO.class));  
216 -  
217 - Collections.sort(routes, new RoadRouteComp());  
218 -  
219 - long sCode = GetUIDAndCode.getSectionId();  
220 - //转wgs  
221 - String wgsCoord = "LINESTRING(" + bdPolygon2Wgs(coords) + ")";  
222 - String bdCooed = "LINESTRING(" + coords + ")";  
223 - //insert 路段  
224 - sql = "insert into bsth_c_section(id, section_code, section_name, croses_road, bsection_vector, gsection_vector, create_date, update_date, versions) " +  
225 - " values(?,?,?,?,ST_GeomFromText('" + bdCooed + "'),ST_GeomFromText('" + wgsCoord + "'),sysdate(),sysdate(),?)";  
226 -  
227 - jdbcTemplate.update(sql, sCode, sCode, sectionName, crosesRoad, 1);  
228 -  
229 -  
230 - SaveRoadRouteDTO srr;  
231 - int currentNo = -1,  
232 - no = 100, step = 100;  
233 -  
234 - if (prevRouteId == -1) {  
235 - //起点站  
236 - currentNo = no;  
237 - no += step;  
238 - }  
239 - //重新排序路由  
240 - for (int i = 0, size = routes.size(); i < size; i++) {  
241 - srr = routes.get(i);  
242 - srr.setSectionrouteCode(no += step);  
243 - if (srr.getId().intValue() == prevRouteId) {  
244 - no += step;  
245 - currentNo = no;  
246 - }  
247 - }  
248 -  
249 - srr = new SaveRoadRouteDTO();  
250 - srr.setLine(lineId);  
251 - srr.setLineCode(lineCode);  
252 - srr.setDirections(upDown);  
253 - srr.setVersions(versions);  
254 -  
255 - srr.setSectionrouteCode(currentNo);  
256 - srr.setSection(sCode);  
257 - srr.setSectionCode(sCode + "");  
258 - srr.setIsRoadeSpeed(0);  
259 - srr.setDestroy(0);  
260 - Date d = new Date();  
261 - srr.setCreateDate(d);  
262 - srr.setUpdateDate(d);  
263 -  
264 - final List<SaveRoadRouteDTO> saveList = routes;  
265 - //insert 新路由 (ID自增)  
266 - jdbcTemplate.update("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed)" +  
267 - " values(?,?,?,?,?,?,?,?,?,?,?)", srr.getLineCode(), srr.getSectionCode(), srr.getSectionrouteCode(), srr.getDirections(), srr.getLine(), srr.getSection(), srr.getCreateDate(), srr.getUpdateDate(), versions, srr.getDestroy(), srr.getIsRoadeSpeed());  
268 -  
269 - // update 原路由  
270 - jdbcTemplate.batchUpdate("update bsth_c_ls_sectionroute set sectionroute_code=? where id=?"  
271 - , new BatchPreparedStatementSetter() {  
272 - @Override  
273 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
274 - SaveRoadRouteDTO srr = saveList.get(i);  
275 - ps.setInt(1, srr.getSectionrouteCode());  
276 - ps.setInt(2, srr.getId());  
277 - }  
278 -  
279 - @Override  
280 - public int getBatchSize() {  
281 - return saveList.size();  
282 - }  
283 - });  
284 -  
285 -  
286 - //写一条走向变更记录  
287 - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions);  
288 -  
289 - tran.commit(status);  
290 -  
291 - //返回更新之后的数据  
292 - List<GeoRoad> list = findRoadByUpdown(lineCode, upDown, versions);  
293 - rs.put("list", list);  
294 - rs.put("status", ResponseCode.SUCCESS);  
295 - } catch (Exception e) {  
296 - tran.rollback(status);  
297 - logger.error("", e);  
298 - rs.put("status", ResponseCode.ERROR);  
299 - rs.put("msg", "服务器出现异常");  
300 - }  
301 - return rs;  
302 - }  
303 -  
304 - /**  
305 - * 获取线路版本信息  
306 - *  
307 - * @param lineCode  
308 - * @return  
309 - */  
310 - @Override  
311 - public Map<String, Object> findVersionInfo(String lineCode) {  
312 - Map<String, Object> rs = new HashMap<>();  
313 -  
314 - try {  
315 - String sql = "select t1.*,t2.name as line_name from bsth_c_line_versions t1 LEFT JOIN bsth_c_line t2 on t1.line_code=t2.line_code where t1.line_code='" + lineCode + "'";  
316 -  
317 - List<GeoLineVersionInfo> list =  
318 - jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoLineVersionInfo.class));  
319 -  
320 - rs.put("list", list);  
321 - rs.put("status", ResponseCode.SUCCESS);  
322 - } catch (Exception e) {  
323 - logger.error("", e);  
324 - rs.put("status", ResponseCode.ERROR);  
325 - rs.put("msg", "服务器出现异常");  
326 - }  
327 - return rs;  
328 - }  
329 -  
330 - @Override  
331 - public Map<String, Object> addNewLineVersion(Map<String, Object> map) {  
332 - Map<String, Object> rs = new HashMap<>();  
333 -  
334 - //编程式事务  
335 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
336 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
337 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
338 - TransactionStatus status = tran.getTransaction(def);  
339 - try {  
340 -  
341 - String lineCode = map.get("lineCode").toString();  
342 - String remark = map.get("remark").toString();  
343 - String name = map.get("name").toString();  
344 - Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(map.get("startDate").toString());  
345 - int extendsVersion = Integer.parseInt(map.get("extendsVersion").toString());  
346 -  
347 - if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){  
348 - rs.put("status", ResponseCode.ERROR);  
349 - rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!");  
350 - return rs;  
351 - }  
352 -  
353 - int nameCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code=" + lineCode + " and name='"+name+"'", Integer.class);  
354 - if(nameCount > 0){  
355 - rs.put("status", ResponseCode.ERROR);  
356 - rs.put("msg", "你不能使用一个已经存在的版本名称!!");  
357 - return rs;  
358 - }  
359 -  
360 - //当前最大的版本号  
361 - int maxVersion = jdbcTemplate.queryForObject("select max(versions) as versions from bsth_c_line_versions where line_code=" + lineCode, Integer.class);  
362 - Date d = new Date();  
363 -  
364 - //根据线路编码,查询线路ID  
365 - int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);  
366 -  
367 - maxVersion += 1;  
368 - LineVersions lVersion = new LineVersions();  
369 - lVersion.setName(name);  
370 - lVersion.setVersions(maxVersion);  
371 - lVersion.setRemark(remark);  
372 - lVersion.setStartDate(startDate);  
373 - lVersion.setStatus(2);  
374 - lVersion.setCreateDate(d);  
375 - lVersion.setUpdateDate(d);  
376 - lVersion.setLineCode(lineCode);  
377 -  
378 - //如果有待启用的版本,设置为历史版本  
379 - jdbcTemplate.update("update bsth_c_line_versions set `status`=2, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=0");  
380 -  
381 - //入库线路版本  
382 - jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " +  
383 - " values(?,?,?,?,?,?,?,?,?,?)", lVersion.getName(), lineId, lVersion.getLineCode()  
384 - , lVersion.getVersions(), lVersion.getStartDate(), lVersion.getCreateDate(), lVersion.getUpdateDate(), lVersion.getRemark(), lVersion.getStatus(), lVersion.getIsupdate());  
385 -  
386 - if (extendsVersion != -1) {  
387 - //复制站点信息  
388 - String sql = "SELECT t1.id AS route_id,t1.line,t1.directions,t1.station,t1.station_name,t1.station_route_code,t1.line_code,t1.station_code,t1.station_mark,t1.distances,t1.to_time,t2.id AS station_id,t2.db_type,t2.b_jwpoints,t2.g_lonx,t2.g_laty,t2.radius,ST_AsText(t2.g_polygon_grid) as g_polygon_grid,t2.shapes_type FROM bsth_c_ls_stationroute t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod where t1.destroy=0 and t1.line_code='" + lineCode + "' and t1.versions="+extendsVersion+" order by t1.directions, t1.station_route_code";  
389 - List<CascadeSaveStation> cssList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveStation.class));  
390 -  
391 - //新的站点编码  
392 - long sCode;  
393 - for (CascadeSaveStation ss : cssList) {  
394 - sCode = GetUIDAndCode.getStationId();  
395 - ss.setRouteId(null);  
396 - ss.setStationCode(sCode + "");  
397 - ss.setStation((int) sCode);  
398 - }  
399 - //入库新版本的站点 和 路由  
400 - batchInsertStation(cssList, maxVersion);  
401 -  
402 - //复制路段信息  
403 - sql = "SELECT t1.id AS route_id,t1.line,t1.line_code,t1.directions,t1.section,t1.section_code,t1.sectionroute_code,t1.versions,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector,t2.db_type,t2.speed_limit FROM bsth_c_ls_sectionroute t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code WHERE t1.destroy = 0 AND t1.line_code = '"+lineCode+"' and t1.versions="+ extendsVersion +" ORDER BY t1.directions,t1.sectionroute_code";  
404 - List<CascadeSaveRoad> csrList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveRoad.class));  
405 - //新的路段编码  
406 - long cCode;  
407 - for(CascadeSaveRoad csr : csrList){  
408 - cCode = GetUIDAndCode.getSectionId();  
409 - csr.setRouteId(null);  
410 - csr.setSection((int) cCode);  
411 - csr.setSectionCode(cCode + "");  
412 - }  
413 - //入库新版本的路段 和 路段路由  
414 - batchInsertRoad(csrList, maxVersion);  
415 - }  
416 -  
417 - tran.commit(status);  
418 - rs.put("newVersion", maxVersion);  
419 - rs.put("status", ResponseCode.SUCCESS);  
420 - } catch (Exception e) {  
421 - tran.rollback(status);  
422 - logger.error("", e);  
423 - rs.put("status", ResponseCode.ERROR);  
424 - rs.put("msg", "服务器出现异常");  
425 - }  
426 - return rs;  
427 - }  
428 -  
429 - /**  
430 - * 删除一个线路走向版本  
431 - * @param lineCode  
432 - * @param version  
433 - * @return  
434 - */  
435 - @Override  
436 - public Map<String, Object> deleteLineVersion(String lineCode, int version) {  
437 - Map<String, Object> rs = new HashMap<>();  
438 -  
439 - //编程式事务  
440 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
441 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
442 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
443 - TransactionStatus status = tran.getTransaction(def);  
444 - try{  
445 - int enableVersion = jdbcTemplate.queryForObject("select versions from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=1", Integer.class);  
446 -  
447 - if(enableVersion==version){  
448 - rs.put("status", ResponseCode.ERROR);  
449 - rs.put("msg", "你不能删除当前正在启用的走向版本!");  
450 - return rs;  
451 - }  
452 - /*int versionCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code='"+lineCode+"'", Integer.class);  
453 - if(versionCount == 1){  
454 - rs.put("status", ResponseCode.ERROR);  
455 - rs.put("msg", "线路至少要保留一个走向版本!");  
456 - return rs;  
457 - }*/  
458 -  
459 - /* //要删除的站点ID(未被其他线路、版本引用的)  
460 - String sql = "select DISTINCT station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version+" and station not in(" +  
461 - "select station from bsth_c_ls_stationroute where (line!='"+lineCode+"' or versions!="+version+") and station in (" +  
462 - "select station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version +  
463 - "))";  
464 -  
465 - List<Integer> stationRemoves = jdbcTemplate.queryForList(sql, Integer.class);*/  
466 -  
467 - //删除站点路由  
468 - String sql = "delete from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions=" + version;  
469 - jdbcTemplate.update(sql);  
470 -  
471 - //删除路段路由  
472 - sql = "delete from bsth_c_ls_sectionroute where line_code='"+lineCode+"' and versions=" + version;  
473 - jdbcTemplate.update(sql);  
474 -  
475 - //删除版本信息  
476 - sql = "delete from bsth_c_line_versions where line_code='"+lineCode+"' and versions=" + version;  
477 - jdbcTemplate.update(sql);  
478 -  
479 - tran.commit(status);  
480 - rs.put("status", ResponseCode.SUCCESS);  
481 - }catch (Exception e){  
482 - tran.rollback(status);  
483 - logger.error("", e);  
484 - rs.put("status", ResponseCode.ERROR);  
485 - rs.put("msg", "服务器出现异常");  
486 - }  
487 - return rs;  
488 - }  
489 -  
490 - /**  
491 - * 获取线路的待更新版本信息  
492 - * @param lineCode  
493 - * @return  
494 - */  
495 - @Override  
496 - public Map<String, Object> findFutureVersion(String lineCode) {  
497 - Map<String, Object> rs = new HashMap();  
498 - try{  
499 - List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=2 order by start_date");  
500 -  
501 - rs.put("data", list);  
502 - rs.put("status", ResponseCode.SUCCESS);  
503 - }catch (Exception e){  
504 - logger.error("", e);  
505 - rs.put("status", ResponseCode.ERROR);  
506 - rs.put("msg", "服务器出现异常");  
507 - }  
508 - return rs;  
509 - }  
510 -  
511 - @Override  
512 - public Map<String, Object> addEnableInfo(String lineCode, int version, String enableTime) {  
513 - Map<String, Object> rs = new HashMap();  
514 - try{  
515 - Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(enableTime);  
516 - if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){  
517 - rs.put("status", ResponseCode.ERROR);  
518 - rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!");  
519 - return rs;  
520 - }  
521 -  
522 - jdbcTemplate.update("update bsth_c_line_versions set `status`=0 where line_code="+lineCode+" and versions=" + version);  
523 - jdbcTemplate.update("update bsth_c_line_versions set `status`=2 ,start_date=? where line_code=? and versions=?", startDate, lineCode, version);  
524 -  
525 - rs.put("status", ResponseCode.SUCCESS);  
526 - }catch (Exception e){  
527 - logger.error("", e);  
528 - rs.put("status", ResponseCode.ERROR);  
529 - rs.put("msg", "服务器出现异常");  
530 - }  
531 - return rs;  
532 - }  
533 -  
534 - /**  
535 - * 批量入库路段  
536 - * @param cssList  
537 - * @param version  
538 - */  
539 - private void batchInsertRoad(final List<CascadeSaveRoad> csrList, final int version){  
540 - final Date d = new Date();  
541 - jdbcTemplate.batchUpdate("insert into bsth_c_section(id, section_code, section_name, croses_road, gsection_vector, create_date, update_date, versions) " +  
542 - " values(?,?,?,?,ST_GeomFromText(?),?,?,?)", new BatchPreparedStatementSetter() {  
543 - @Override  
544 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
545 - CascadeSaveRoad csr = csrList.get(i);  
546 - ps.setInt(1, csr.getSection());  
547 - ps.setString(2, csr.getSectionCode());  
548 - ps.setString(3, csr.getSectionName());  
549 - ps.setString(4, csr.getCrosesRoad());  
550 - ps.setString(5, csr.getGsectionVector());  
551 - ps.setTimestamp(6, new java.sql.Timestamp(d.getTime()));  
552 - ps.setTimestamp(7, new java.sql.Timestamp(d.getTime()));  
553 - ps.setInt(8, version);  
554 - }  
555 -  
556 - @Override  
557 - public int getBatchSize() {  
558 - return csrList.size();  
559 - }  
560 - });  
561 -  
562 - //路由  
563 - jdbcTemplate.batchUpdate("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed) " +  
564 - " values(?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {  
565 - @Override  
566 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
567 - CascadeSaveRoad csr = csrList.get(i);  
568 - ps.setString(1, csr.getLineCode());  
569 - ps.setString(2, csr.getSectionCode());  
570 - ps.setInt(3, csr.getSectionrouteCode());  
571 - ps.setInt(4, csr.getDirections());  
572 - ps.setInt(5, csr.getLine());  
573 - ps.setInt(6, csr.getSection());  
574 - ps.setTimestamp(7, new java.sql.Timestamp(d.getTime()));  
575 - ps.setTimestamp(8, new java.sql.Timestamp(d.getTime()));  
576 - ps.setInt(9, version);  
577 - ps.setInt(10, 0);  
578 - ps.setInt(11, 0);  
579 - }  
580 -  
581 - @Override  
582 - public int getBatchSize() {  
583 - return csrList.size();  
584 - }  
585 - });  
586 - }  
587 -  
588 - /**  
589 - * 批量插入站点  
590 - *  
591 - * @param cssList  
592 - */  
593 - private void batchInsertStation(final List<CascadeSaveStation> cssList, final int version) {  
594 - //站点  
595 - jdbcTemplate.batchUpdate("insert into bsth_c_station(id, station_cod, station_name, db_type, b_jwpoints, g_lonx, g_laty, destroy, radius, shapes_type, versions, g_polygon_grid) " +  
596 - " values(?,?,?,?,?,?,?,?,?,?,?,ST_GeomFromText(?))", new BatchPreparedStatementSetter() {  
597 - @Override  
598 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
599 - CascadeSaveStation ss = cssList.get(i);  
600 - ps.setInt(1, ss.getStation());  
601 - ps.setString(2, ss.getStationCode());  
602 - ps.setString(3, ss.getStationName());  
603 - ps.setString(4, "b");  
604 - ps.setString(5, ss.getbJwpoints());  
605 - ps.setDouble(6, ss.getgLonx());  
606 - ps.setDouble(7, ss.getgLaty());  
607 - ps.setInt(8, 0);  
608 - ps.setInt(9, ss.getRadius()==null?0:ss.getRadius());  
609 - ps.setString(10, ss.getShapesType());  
610 - ps.setInt(11, version);  
611 - ps.setString(12, ss.getgPolygonGrid());  
612 - }  
613 -  
614 - @Override  
615 - public int getBatchSize() {  
616 - return cssList.size();  
617 - }  
618 - });  
619 -  
620 - final Date d = new Date();  
621 - //站点路由  
622 - jdbcTemplate.batchUpdate("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) " +  
623 - " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {  
624 - @Override  
625 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
626 - CascadeSaveStation ss = cssList.get(i);  
627 - ps.setInt(1, ss.getLine());  
628 - ps.setInt(2, ss.getStation());  
629 - ps.setString(3, ss.getStationName());  
630 - ps.setInt(4, ss.getStationRouteCode());  
631 - ps.setString(5, ss.getLineCode());  
632 - ps.setString(6, ss.getStationCode());  
633 - ps.setString(7, ss.getStationMark());  
634 - ps.setDouble(8, ss.getDistances());  
635 - ps.setDouble(9, ss.getToTime());  
636 - ps.setInt(10, 0);  
637 - ps.setInt(11, version);  
638 - ps.setTimestamp(12, new java.sql.Timestamp(d.getTime()));  
639 - ps.setTimestamp(13, new java.sql.Timestamp(d.getTime()));  
640 - ps.setInt(14, ss.getDirections());  
641 - }  
642 -  
643 - @Override  
644 - public int getBatchSize() {  
645 - return cssList.size();  
646 - }  
647 - });  
648 - }  
649 -  
650 - @Override  
651 - public Map<String, Object> addNewStationRoute(String lineCode, int upDown, int versions, String stationName, Float lat, Float lng, int prevRouteId) {  
652 - Map<String, Object> rs = new HashMap<>();  
653 -  
654 - //编程式事务  
655 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
656 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
657 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
658 - TransactionStatus status = tran.getTransaction(def);  
659 - try {  
660 - //根据线路编码,查询线路ID  
661 - int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);  
662 -  
663 - String sql = "select * from bsth_c_ls_stationroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions;  
664 - List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class));  
665 -  
666 - for (SaveStationRouteDTO s : routes) {  
667 - if (s.getStationName().equals(stationName)) {  
668 -  
669 - rs.put("status", ResponseCode.ERROR);  
670 - rs.put("msg", "重复的站点路由名称!");  
671 - return rs;  
672 - }  
673 - }  
674 - //按路由顺序排列  
675 - Collections.sort(routes, new StationRouteComp());  
676 -  
677 - //转WGS  
678 - TransGPS.Location wgsLoc = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(String.valueOf(lng)), Double.parseDouble(String.valueOf(lat)))));  
679 -  
680 - //insert 站点  
681 - long sCode = GetUIDAndCode.getStationId();  
682 - jdbcTemplate.update("insert into bsth_c_station(id, station_cod, station_name, db_type, b_jwpoints, g_lonx, g_laty, destroy, radius, shapes_type, versions) " +  
683 - " values(?,?,?,?,?,?,?,?,?,?,?)", sCode, sCode, stationName, "b", lng + " " + lat, wgsLoc.getLng(), wgsLoc.getLat(), 0, 88, "r", 1);  
684 -  
685 -  
686 - SaveStationRouteDTO sr;  
687 - int currentNo = -1,  
688 - no = 100, step = 100;  
689 -  
690 - if (prevRouteId == -1) {  
691 - //起点站  
692 - currentNo = no;  
693 - no += step;  
694 - }  
695 - //重新排序路由  
696 - for (int i = 0, size = routes.size(); i < size; i++) {  
697 - sr = routes.get(i);  
698 - sr.setStationRouteCode(no);  
699 - no += step;  
700 - if (sr.getId().intValue() == prevRouteId) {  
701 - currentNo = no;  
702 - no += step;  
703 - }  
704 - }  
705 -  
706 - SaveStationRouteDTO nsr = new SaveStationRouteDTO();  
707 - nsr.setLine(lineId);  
708 - nsr.setLineCode(lineCode);  
709 - nsr.setDirections(upDown);  
710 - nsr.setVersions(versions);  
711 - nsr.setStationRouteCode(currentNo);  
712 - nsr.setStation(sCode);  
713 - nsr.setStationCode(sCode + "");  
714 - nsr.setStationName(stationName);  
715 - nsr.setDistances(0d);  
716 - nsr.setToTime(0d);  
717 - Date d = new Date();  
718 - nsr.setCreateDate(d);  
719 - nsr.setUpdateDate(d);  
720 - nsr.setDestroy(0);  
721 - if (prevRouteId == -1)  
722 - nsr.setStationMark("B");  
723 - else if(routes.size()==1)  
724 - nsr.setStationMark("E");  
725 -  
726 - //routes.add(sr);  
727 -  
728 - //重新标记mark  
729 - Collections.sort(routes, new StationRouteComp());  
730 - for (int i = 0, size = routes.size(); i < size; i++) {  
731 - routes.get(i).setStationMark("Z");  
732 - }  
733 - if(routes.size() > 0 && prevRouteId!=-1)  
734 - routes.get(0).setStationMark("B");  
735 - if(routes.size() > 1)  
736 - routes.get(routes.size() - 1).setStationMark("E");  
737 -  
738 - final List<SaveStationRouteDTO> saveList = routes;  
739 - //insert 新路由 (ID自增)  
740 - jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"  
741 - , nsr.getLine(), nsr.getStation(), nsr.getStationName(), nsr.getStationRouteCode(), nsr.getLineCode(), nsr.getStationCode(), nsr.getStationMark()  
742 - , nsr.getDistances(), nsr.getToTime(), nsr.getDestroy(), nsr.getVersions(), nsr.getCreateDate(), nsr.getUpdateDate(), nsr.getDirections());  
743 -  
744 - // update 原路由  
745 - jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," +  
746 - "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" +  
747 - " where id=?"  
748 - , new BatchPreparedStatementSetter() {  
749 - @Override  
750 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
751 - SaveStationRouteDTO sr = saveList.get(i);  
752 - ps.setInt(1, sr.getLine());  
753 - ps.setLong(2, sr.getStation());  
754 - ps.setString(3, sr.getStationName());  
755 - ps.setInt(4, sr.getStationRouteCode());  
756 - ps.setString(5, sr.getLineCode());  
757 - ps.setString(6, sr.getStationCode());  
758 - ps.setString(7, sr.getStationMark());  
759 - ps.setDouble(8, sr.getDistances());  
760 - ps.setDouble(9, sr.getToTime());  
761 - ps.setInt(10, sr.getDestroy());  
762 - ps.setInt(11, sr.getVersions());  
763 - ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime()));  
764 - ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime()));  
765 - ps.setInt(14, sr.getDirections());  
766 - ps.setInt(15, sr.getId());  
767 - }  
768 -  
769 - @Override  
770 - public int getBatchSize() {  
771 - return saveList.size();  
772 - }  
773 - });  
774 -  
775 - //写一条走向变更记录  
776 - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions);  
777 -  
778 - tran.commit(status);  
779 -  
780 - //返回更新之后的数据  
781 - List<GeoStation> list = findByUpdown(lineCode, upDown, versions);  
782 -  
783 - rs.put("list", list);  
784 - rs.put("newStationRouteCode", currentNo);  
785 - rs.put("status", ResponseCode.SUCCESS);  
786 - } catch (Exception e) {  
787 - tran.rollback(status);  
788 - logger.error("", e);  
789 - rs.put("status", ResponseCode.ERROR);  
790 - rs.put("msg", "服务器出现异常");  
791 - }  
792 - return rs;  
793 - }  
794 -  
795 - private List<GeoStation> findByUpdown(String lineCode, int upDown, int versions) {  
796 - //返回更新之后的数据  
797 - String sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and directions=" + upDown + " and destroy=0 and versions=" + versions + ") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod";  
798 - List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));  
799 -  
800 - for (GeoStation station : list) {  
801 - if (station.getShapesType().equals("d"))  
802 - station.setBdCoords(multiWgsToBd(station.getgPolygonGrid(), 9, 3));  
803 - }  
804 - return list;  
805 - }  
806 -  
807 - private List<GeoRoad> findRoadByUpdown(String lineCode, int upDown, int versions) {  
808 - //返回更新之后的数据  
809 - String sql = "select t1.*,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector from (select id,sectionroute_code,directions,line_code,section_code,versions from bsth_c_ls_sectionroute where line='" + lineCode + "' and directions=" + upDown + " and destroy=0 and versions=" + versions + ") t1 LEFT JOIN bsth_c_section t2 on t1.section_code=t2.section_code";  
810 - List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));  
811 -  
812 - for (GeoRoad road : list) {  
813 - road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));  
814 - }  
815 - return list;  
816 - }  
817 -  
818 - @Override  
819 - public Map<String, Object> destroyStation(GeoStation station) {  
820 - Map<String, Object> rs = new HashMap<>();  
821 -  
822 - //编程式事务  
823 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
824 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
825 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
826 - TransactionStatus status = tran.getTransaction(def);  
827 - try {  
828 - String sql = "update bsth_c_ls_stationroute set destroy=1 where id=?";  
829 - jdbcTemplate.update(sql, station.getId());  
830 -  
831 - /**  
832 - * ########## 重新排序路由,标记mark #########  
833 - */  
834 - sql = "select * from bsth_c_ls_stationroute where line_code='" + station.getLineCode() + "' and directions=" + station.getDirections() + " and destroy=0 and versions=" + station.getVersions();  
835 - List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class));  
836 - Collections.sort(routes, new StationRouteComp());  
837 -  
838 - int no = 0,  
839 - step = 100;  
840 - SaveStationRouteDTO sr;  
841 - //重新排序路由  
842 - for (int i = 0, size = routes.size(); i < size; i++) {  
843 - sr = routes.get(i);  
844 - sr.setStationRouteCode(no += step);  
845 - }  
846 -  
847 - for (int i = 0, size = routes.size(); i < size; i++) {  
848 - routes.get(i).setStationMark("Z");  
849 - }  
850 - if(routes.size() > 0)  
851 - routes.get(0).setStationMark("B");  
852 - if(routes.size() > 1)  
853 - routes.get(routes.size() - 1).setStationMark("E");  
854 -  
855 - final List<SaveStationRouteDTO> saveList = routes;  
856 - // update 原路由  
857 - jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," +  
858 - "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" +  
859 - " where id=?"  
860 - , new BatchPreparedStatementSetter() {  
861 - @Override  
862 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
863 - SaveStationRouteDTO sr = saveList.get(i);  
864 - ps.setInt(1, sr.getLine());  
865 - ps.setLong(2, sr.getStation());  
866 - ps.setString(3, sr.getStationName());  
867 - ps.setInt(4, sr.getStationRouteCode());  
868 - ps.setString(5, sr.getLineCode());  
869 - ps.setString(6, sr.getStationCode());  
870 - ps.setString(7, sr.getStationMark());  
871 - ps.setDouble(8, sr.getDistances());  
872 - ps.setDouble(9, sr.getToTime());  
873 - ps.setInt(10, sr.getDestroy());  
874 - ps.setInt(11, sr.getVersions());  
875 - ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime()));  
876 - ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime()));  
877 - ps.setInt(14, sr.getDirections());  
878 - ps.setInt(15, sr.getId());  
879 - }  
880 -  
881 - @Override  
882 - public int getBatchSize() {  
883 - return saveList.size();  
884 - }  
885 - });  
886 -  
887 - //写一条走向变更记录  
888 - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), station.getLineCode(), station.getVersions());  
889 -  
890 - tran.commit(status);  
891 -  
892 - //返回更新之后的数据  
893 - List<GeoStation> list = findByUpdown(station.getLineCode(), station.getDirections(), station.getVersions());  
894 - rs.put("list", list);  
895 - rs.put("status", ResponseCode.SUCCESS);  
896 - } catch (Exception e) {  
897 - tran.rollback(status);  
898 - logger.error("", e);  
899 - rs.put("status", ResponseCode.ERROR);  
900 - rs.put("msg", "服务器出现异常");  
901 - }  
902 - return rs;  
903 - }  
904 -  
905 - @Override  
906 - public Map<String, Object> destroyRoad(GeoRoad road) {  
907 - Map<String, Object> rs = new HashMap<>();  
908 -  
909 - try {  
910 - String sql = "update bsth_c_ls_sectionroute set destroy=1 where id=?";  
911 - jdbcTemplate.update(sql, road.getId());  
912 -  
913 - //写一条走向变更记录  
914 - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), road.getLineCode(), road.getVersions());  
915 -  
916 - //返回更新之后的数据  
917 - List<GeoRoad> list = findRoadByUpdown(road.getLineCode(), road.getDirections(), road.getVersions());  
918 - rs.put("list", list);  
919 - rs.put("status", ResponseCode.SUCCESS);  
920 - } catch (Exception e) {  
921 - logger.error("", e);  
922 - rs.put("status", ResponseCode.ERROR);  
923 - rs.put("msg", "服务器出现异常");  
924 - }  
925 - return rs;  
926 - }  
927 -  
928 - @Override  
929 - public Map<String, Object> updateRoadInfo(GeoRoad road) {  
930 - Map<String, Object> rs = new HashMap<>();  
931 -  
932 - try {  
933 - //坐标转换  
934 - String bdPolyline = "LINESTRING(" + road.getGsectionVector() + ")";  
935 - String wgsPolyline = "LINESTRING(" + bdPolygon2Wgs(road.getGsectionVector()) + ")";  
936 -  
937 - String sql = "update bsth_c_section set section_name=?, croses_road=?, bsection_vector=ST_GeomFromText('" + bdPolyline + "'),gsection_vector=ST_GeomFromText('" + wgsPolyline + "'),update_date=sysdate() where section_code=?";  
938 -  
939 - int rsCount = jdbcTemplate.update(sql, road.getSectionName(), road.getCrosesRoad(), road.getSectionCode());  
940 -  
941 - //从数据库里重新查询对象  
942 - if (rsCount > 0) {  
943 - rs.put("road", findOneRoad(road.getId()));  
944 - rs.put("status", ResponseCode.SUCCESS);  
945 - }  
946 - } catch (Exception e) {  
947 - logger.error("", e);  
948 - rs.put("status", ResponseCode.ERROR);  
949 - rs.put("msg", "服务器出现异常");  
950 - }  
951 - return rs;  
952 - }  
953 -  
954 -  
955 - /**  
956 - * 根据路由ID 获取站点  
957 - *  
958 - * @param id  
959 - * @return  
960 - */  
961 - private GeoStation findOne(int id) {  
962 - String sql = "SELECT t1.*, t2.g_lonx,g_laty,ST_AsText (g_polygon_grid) AS g_polygon_grid,radius,shapes_type FROM (SELECT id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions FROM bsth_c_ls_stationroute WHERE id=" + id + " AND destroy = 0) t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod";  
963 - List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));  
964 -  
965 - GeoStation s = list.get(0);  
966 - if (s.getShapesType().equals("d"))  
967 - s.setBdCoords(multiWgsToBd(s.getgPolygonGrid(), 9, 3));  
968 -  
969 - return s;  
970 - }  
971 -  
972 - private GeoRoad findOneRoad(int id) {  
973 - String sql = "SELECT t1.*, t2.section_name,t2.croses_road,ST_AsText (t2.gsection_vector) AS gsection_vector FROM (SELECT id,sectionroute_code,directions,line_code,section_code,versions FROM bsth_c_ls_sectionroute WHERE id=" + id + ") t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code";  
974 - List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));  
975 -  
976 - for (GeoRoad road : list) {  
977 - road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));  
978 - }  
979 - return list.size() > 0 ? list.get(0) : null;  
980 - }  
981 -  
982 - private String bdPolygon2Wgs(String bdPolygon) {  
983 - StringBuilder wgsPolygon = new StringBuilder();  
984 - List<String> list = Splitter.on(",").splitToList(bdPolygon);  
985 - String[] array;  
986 -  
987 - TransGPS.Location location;  
988 - for (String p : list) {  
989 - array = p.split(" ");  
990 - location = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(array[0]), Double.parseDouble(array[1]))));  
991 -  
992 - wgsPolygon.append(location.getLng() + " " + location.getLat() + ",");  
993 - }  
994 -  
995 - if (wgsPolygon.length() > 0) {  
996 - wgsPolygon.deleteCharAt(wgsPolygon.length() - 1);  
997 - }  
998 - return wgsPolygon.toString();  
999 - }  
1000 -  
1001 - /**  
1002 - * wgs 坐标数组转 百度  
1003 - *  
1004 - * @return  
1005 - */  
1006 - private List<String> multiWgsToBd(String crdStr, int si, int ei) {  
1007 - List<String> bdList = new ArrayList<>();  
1008 -  
1009 - List<String> gList = Splitter.on(",").splitToList(crdStr.substring(si, crdStr.length() - ei));  
1010 - TransGPS.Location location;  
1011 - String[] cds;  
1012 - for (String gs : gList) {  
1013 - cds = gs.split(" ");  
1014 - location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(Double.parseDouble(cds[0]), Double.parseDouble(cds[1]))));  
1015 -  
1016 - bdList.add(location.getLng() + " " + location.getLat());  
1017 - }  
1018 - return bdList;  
1019 - }  
1020 -  
1021 - private static class StationRouteComp implements Comparator<SaveStationRouteDTO> {  
1022 -  
1023 - @Override  
1024 - public int compare(SaveStationRouteDTO s1, SaveStationRouteDTO s2) {  
1025 - return s1.getStationRouteCode() - s2.getStationRouteCode();  
1026 - }  
1027 - }  
1028 -  
1029 - private static class RoadRouteComp implements Comparator<SaveRoadRouteDTO> {  
1030 -  
1031 - @Override  
1032 - public int compare(SaveRoadRouteDTO s1, SaveRoadRouteDTO s2) {  
1033 - return s1.getSectionrouteCode() - s2.getSectionrouteCode();  
1034 - }  
1035 - } 1 +package com.bsth.service.geo_data.impl;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.LineVersions;
  5 +import com.bsth.entity.geo_data.GeoLineVersionInfo;
  6 +import com.bsth.entity.geo_data.GeoRoad;
  7 +import com.bsth.entity.geo_data.GeoStation;
  8 +import com.bsth.repository.SectionRepository;
  9 +import com.bsth.repository.StationRepository;
  10 +import com.bsth.service.geo_data.GeoDataService;
  11 +import com.bsth.service.geo_data.impl.dto.CascadeSaveRoad;
  12 +import com.bsth.service.geo_data.impl.dto.CascadeSaveStation;
  13 +import com.bsth.service.geo_data.impl.dto.SaveRoadRouteDTO;
  14 +import com.bsth.service.geo_data.impl.dto.SaveStationRouteDTO;
  15 +import com.bsth.util.GetUIDAndCode;
  16 +import com.bsth.util.TransGPS;
  17 +import com.google.common.base.Splitter;
  18 +import org.slf4j.Logger;
  19 +import org.slf4j.LoggerFactory;
  20 +import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  22 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  23 +import org.springframework.jdbc.core.JdbcTemplate;
  24 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  25 +import org.springframework.stereotype.Service;
  26 +import org.springframework.transaction.TransactionDefinition;
  27 +import org.springframework.transaction.TransactionStatus;
  28 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  29 +
  30 +import java.sql.PreparedStatement;
  31 +import java.sql.SQLException;
  32 +import java.text.SimpleDateFormat;
  33 +import java.util.*;
  34 +
  35 +/**
  36 + * Created by panzhao on 2017/12/8.
  37 + */
  38 +@Service
  39 +public class GeoDataServiceImpl implements GeoDataService {
  40 +
  41 + @Autowired
  42 + JdbcTemplate jdbcTemplate;
  43 +
  44 + @Autowired
  45 + SectionRepository sectionRepository;
  46 +
  47 + @Autowired
  48 + StationRepository stationRepository;
  49 +
  50 + Logger logger = LoggerFactory.getLogger(this.getClass());
  51 +
  52 + @Override
  53 + public Map<String, Object> findGeoStations(String lineCode, Integer version) {
  54 +
  55 + Map<String, Object> map = new HashMap();
  56 + try {
  57 +
  58 + String sql = "select versions from bsth_c_line_versions where line='"+lineCode+"' and status=1";
  59 + //当前使用的线路版本
  60 + Integer currentVersion = jdbcTemplate.queryForObject(sql, Integer.class);
  61 +
  62 +
  63 + if(null == version)
  64 + version = currentVersion;
  65 +
  66 + sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and destroy=0 and versions="+version+") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod";
  67 +
  68 +
  69 + List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));
  70 +
  71 + for (GeoStation station : list) {
  72 + if (station.getShapesType().equals("d"))
  73 + station.setBdCoords(multiWgsToBd(station.getgPolygonGrid(), 9, 3));
  74 + }
  75 + map.put("status", ResponseCode.SUCCESS);
  76 + map.put("list", list);
  77 + map.put("currentVersion", currentVersion);
  78 + map.put("editVersion", version);
  79 + } catch (Exception e) {
  80 + logger.error("", e);
  81 + map.put("status", ResponseCode.ERROR);
  82 + map.put("msg", "服务器出现异常");
  83 + }
  84 + return map;
  85 + }
  86 +
  87 + @Override
  88 + public Map<String, Object> findGeoRoad(String lineCode,Integer version) {
  89 + Map<String, Object> map = new HashMap();
  90 + try {
  91 +
  92 + String sql = "select versions from bsth_c_line_versions where line='"+lineCode+"' and status=1";
  93 + //当前使用的线路版本
  94 + Integer currentVersion = jdbcTemplate.queryForObject(sql, Integer.class);
  95 +
  96 +
  97 + if(null == version)
  98 + version = currentVersion;
  99 +
  100 +
  101 + sql = "select t1.*,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector from (select id,sectionroute_code,directions,line_code,section_code,versions from bsth_c_ls_sectionroute where line=" + lineCode + " and destroy=0 and versions="+version+") t1 LEFT JOIN bsth_c_section t2 on t1.section_code=t2.section_code";
  102 +
  103 +
  104 + List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));
  105 +
  106 + for (GeoRoad road : list) {
  107 + road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));
  108 + }
  109 + map.put("status", ResponseCode.SUCCESS);
  110 + map.put("list", list);
  111 + } catch (Exception e) {
  112 + logger.error("", e);
  113 + map.put("status", ResponseCode.ERROR);
  114 + map.put("msg", "服务器出现异常");
  115 + }
  116 + return map;
  117 + }
  118 +
  119 + /**
  120 + * 编辑缓冲区信息
  121 + *
  122 + * @param station
  123 + * @return
  124 + */
  125 + @Override
  126 + public Map<String, Object> updateBufferInfo(GeoStation station) {
  127 + Map<String, Object> rs = new HashMap<>();
  128 + try {
  129 + //坐标转换
  130 + TransGPS.Location loc = TransGPS.LocationMake(station.getgLonx(), station.getgLaty());
  131 + loc = TransGPS.bd_decrypt(loc);
  132 + loc = TransGPS.transformFromGCJToWGS(loc);
  133 + station.setgLaty(Float.parseFloat(String.valueOf(loc.getLat())));
  134 + station.setgLonx(Float.parseFloat(String.valueOf(loc.getLng())));
  135 +
  136 + String sql;
  137 + String shapesType = station.getShapesType();
  138 + int rsCount = -1;
  139 + if (shapesType.equals("r")) {
  140 + sql = "update bsth_c_station set g_lonx=?, g_laty=?, radius=?,shapes_type='r' where station_cod=?";
  141 + rsCount = jdbcTemplate.update(sql, station.getgLonx(), station.getgLaty(), station.getRadius(), station.getStationCode());
  142 + } else if (shapesType.equals("d")) {
  143 + //多边形坐标转换
  144 + String bdPolygon = "POLYGON((" + station.getgPolygonGrid() + "))";
  145 + String wgsPolygon = "POLYGON((" + bdPolygon2Wgs(station.getgPolygonGrid()) + "))";
  146 + sql = "update bsth_c_station set g_lonx=?, g_laty=?,shapes_type='d', radius=null,b_polygon_grid=ST_GeomFromText('" + bdPolygon + "'),g_polygon_grid=ST_GeomFromText('" + wgsPolygon + "') where station_cod=?";
  147 +
  148 + rsCount = jdbcTemplate.update(sql, station.getgLonx(), station.getgLaty(), station.getStationCode());
  149 + }
  150 +
  151 + //从数据库里重新查询对象
  152 + if (rsCount > 0) {
  153 + rs.put("station", findOne(station.getId()));
  154 + rs.put("status", ResponseCode.SUCCESS);
  155 + }
  156 +
  157 + } catch (Exception e) {
  158 + logger.error("", e);
  159 + rs.put("status", ResponseCode.ERROR);
  160 + rs.put("msg", "服务器出现异常");
  161 + }
  162 + return rs;
  163 + }
  164 +
  165 + /**
  166 + * 修改站点路由和站点名称
  167 + *
  168 + * @param map
  169 + * @return
  170 + */
  171 + @Override
  172 + public Map<String, Object> updateStationName(Map<String, Object> map) {
  173 + Map<String, Object> rs = new HashMap<>();
  174 +
  175 + //编程式事务
  176 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  177 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  178 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  179 + TransactionStatus status = tran.getTransaction(def);
  180 + try {
  181 +
  182 + int id = Integer.parseInt(map.get("id").toString());
  183 + String name = map.get("stationName").toString();
  184 + String code = map.get("stationCode").toString();
  185 + String lineCode = map.get("lineCode").toString();
  186 + String versions = map.get("versions").toString();
  187 +
  188 + //更新历史站点路由
  189 + jdbcTemplate.update("update bsth_c_ls_stationroute set station_name=? where id=?", name, id);
  190 + //更新站点
  191 + jdbcTemplate.update("update bsth_c_station set station_name=? where station_cod=?", name, code);
  192 +
  193 + //写一条走向变更记录
  194 + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions);
  195 +
  196 + tran.commit(status);
  197 +
  198 + rs.put("station", findOne(id));
  199 + rs.put("status", ResponseCode.SUCCESS);
  200 + } catch (Exception e) {
  201 + tran.rollback(status);
  202 + logger.error("", e);
  203 + rs.put("status", ResponseCode.ERROR);
  204 + rs.put("msg", "服务器出现异常");
  205 + }
  206 + return rs;
  207 + }
  208 +
  209 + @Override
  210 + public Map<String, Object> addNewRoadRoute(String lineCode, int upDown, int versions, String sectionName, String crosesRoad, String coords, int prevRouteId) {
  211 + Map<String, Object> rs = new HashMap<>();
  212 +
  213 + //编程式事务
  214 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  215 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  216 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  217 + TransactionStatus status = tran.getTransaction(def);
  218 + try {
  219 + //根据线路编码,查询线路ID
  220 + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);
  221 +
  222 + String sql = "select * from bsth_c_ls_sectionroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions;
  223 + List<SaveRoadRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveRoadRouteDTO.class));
  224 +
  225 + Collections.sort(routes, new RoadRouteComp());
  226 +
  227 + long sCode = sectionRepository.sectionMaxId() + 1;
  228 + //转wgs
  229 + String wgsCoord = "LINESTRING(" + bdPolygon2Wgs(coords) + ")";
  230 + String bdCooed = "LINESTRING(" + coords + ")";
  231 + //insert 路段
  232 + sql = "insert into bsth_c_section(id, section_code, section_name, croses_road, bsection_vector, gsection_vector, create_date, update_date, versions) " +
  233 + " values(?,?,?,?,ST_GeomFromText('" + bdCooed + "'),ST_GeomFromText('" + wgsCoord + "'),sysdate(),sysdate(),?)";
  234 +
  235 + jdbcTemplate.update(sql, sCode, sCode, sectionName, crosesRoad, 1);
  236 +
  237 +
  238 + SaveRoadRouteDTO srr;
  239 + int currentNo = -1,
  240 + no = 100, step = 100;
  241 +
  242 + if (prevRouteId == -1) {
  243 + //起点站
  244 + currentNo = no;
  245 + no += step;
  246 + }
  247 + //重新排序路由
  248 + for (int i = 0, size = routes.size(); i < size; i++) {
  249 + srr = routes.get(i);
  250 + srr.setSectionrouteCode(no += step);
  251 + if (srr.getId().intValue() == prevRouteId) {
  252 + no += step;
  253 + currentNo = no;
  254 + }
  255 + }
  256 +
  257 + srr = new SaveRoadRouteDTO();
  258 + srr.setLine(lineId);
  259 + srr.setLineCode(lineCode);
  260 + srr.setDirections(upDown);
  261 + srr.setVersions(versions);
  262 +
  263 + srr.setSectionrouteCode(currentNo);
  264 + srr.setSection(sCode);
  265 + srr.setSectionCode(sCode + "");
  266 + srr.setIsRoadeSpeed(0);
  267 + srr.setDestroy(0);
  268 + Date d = new Date();
  269 + srr.setCreateDate(d);
  270 + srr.setUpdateDate(d);
  271 +
  272 + final List<SaveRoadRouteDTO> saveList = routes;
  273 + //insert 新路由 (ID自增)
  274 + jdbcTemplate.update("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed)" +
  275 + " values(?,?,?,?,?,?,?,?,?,?,?)", srr.getLineCode(), srr.getSectionCode(), srr.getSectionrouteCode(), srr.getDirections(), srr.getLine(), srr.getSection(), srr.getCreateDate(), srr.getUpdateDate(), versions, srr.getDestroy(), srr.getIsRoadeSpeed());
  276 +
  277 + // update 原路由
  278 + jdbcTemplate.batchUpdate("update bsth_c_ls_sectionroute set sectionroute_code=? where id=?"
  279 + , new BatchPreparedStatementSetter() {
  280 + @Override
  281 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  282 + SaveRoadRouteDTO srr = saveList.get(i);
  283 + ps.setInt(1, srr.getSectionrouteCode());
  284 + ps.setInt(2, srr.getId());
  285 + }
  286 +
  287 + @Override
  288 + public int getBatchSize() {
  289 + return saveList.size();
  290 + }
  291 + });
  292 +
  293 +
  294 + //写一条走向变更记录
  295 + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions);
  296 +
  297 + tran.commit(status);
  298 +
  299 + //返回更新之后的数据
  300 + List<GeoRoad> list = findRoadByUpdown(lineCode, upDown, versions);
  301 + rs.put("list", list);
  302 + rs.put("status", ResponseCode.SUCCESS);
  303 + } catch (Exception e) {
  304 + tran.rollback(status);
  305 + logger.error("", e);
  306 + rs.put("status", ResponseCode.ERROR);
  307 + rs.put("msg", "服务器出现异常");
  308 + }
  309 + return rs;
  310 + }
  311 +
  312 + /**
  313 + * 获取线路版本信息
  314 + *
  315 + * @param lineCode
  316 + * @return
  317 + */
  318 + @Override
  319 + public Map<String, Object> findVersionInfo(String lineCode) {
  320 + Map<String, Object> rs = new HashMap<>();
  321 +
  322 + try {
  323 + String sql = "select t1.*,t2.name as line_name from bsth_c_line_versions t1 LEFT JOIN bsth_c_line t2 on t1.line_code=t2.line_code where t1.line_code='" + lineCode + "'";
  324 +
  325 + List<GeoLineVersionInfo> list =
  326 + jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoLineVersionInfo.class));
  327 +
  328 + rs.put("list", list);
  329 + rs.put("status", ResponseCode.SUCCESS);
  330 + } catch (Exception e) {
  331 + logger.error("", e);
  332 + rs.put("status", ResponseCode.ERROR);
  333 + rs.put("msg", "服务器出现异常");
  334 + }
  335 + return rs;
  336 + }
  337 +
  338 + @Override
  339 + public Map<String, Object> addNewLineVersion(Map<String, Object> map) {
  340 + Map<String, Object> rs = new HashMap<>();
  341 +
  342 + //编程式事务
  343 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  344 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  345 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  346 + TransactionStatus status = tran.getTransaction(def);
  347 + try {
  348 +
  349 + String lineCode = map.get("lineCode").toString();
  350 + String remark = map.get("remark").toString();
  351 + String name = map.get("name").toString();
  352 + Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(map.get("startDate").toString());
  353 + int extendsVersion = Integer.parseInt(map.get("extendsVersion").toString());
  354 +
  355 + if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){
  356 + rs.put("status", ResponseCode.ERROR);
  357 + rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!");
  358 + return rs;
  359 + }
  360 +
  361 + int nameCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code=" + lineCode + " and name='"+name+"'", Integer.class);
  362 + if(nameCount > 0){
  363 + rs.put("status", ResponseCode.ERROR);
  364 + rs.put("msg", "你不能使用一个已经存在的版本名称!!");
  365 + return rs;
  366 + }
  367 +
  368 + //当前最大的版本号
  369 + int maxVersion = jdbcTemplate.queryForObject("select max(versions) as versions from bsth_c_line_versions where line_code=" + lineCode, Integer.class);
  370 + Date d = new Date();
  371 +
  372 + //根据线路编码,查询线路ID
  373 + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);
  374 +
  375 + maxVersion += 1;
  376 + LineVersions lVersion = new LineVersions();
  377 + lVersion.setName(name);
  378 + lVersion.setVersions(maxVersion);
  379 + lVersion.setRemark(remark);
  380 + lVersion.setStartDate(startDate);
  381 + lVersion.setStatus(2);
  382 + lVersion.setCreateDate(d);
  383 + lVersion.setUpdateDate(d);
  384 + lVersion.setLineCode(lineCode);
  385 +
  386 + //如果有待启用的版本,设置为历史版本
  387 + jdbcTemplate.update("update bsth_c_line_versions set `status`=2, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=0");
  388 +
  389 + //入库线路版本
  390 + jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " +
  391 + " values(?,?,?,?,?,?,?,?,?,?)", lVersion.getName(), lineId, lVersion.getLineCode()
  392 + , lVersion.getVersions(), lVersion.getStartDate(), lVersion.getCreateDate(), lVersion.getUpdateDate(), lVersion.getRemark(), lVersion.getStatus(), lVersion.getIsupdate());
  393 +
  394 + if (extendsVersion != -1) {
  395 + //复制站点信息
  396 + String sql = "SELECT t1.id AS route_id,t1.line,t1.directions,t1.station,t1.station_name,t1.station_route_code,t1.line_code,t1.station_code,t1.station_mark,t1.distances,t1.to_time,t2.id AS station_id,t2.db_type,t2.b_jwpoints,t2.g_lonx,t2.g_laty,t2.radius,ST_AsText(t2.g_polygon_grid) as g_polygon_grid,t2.shapes_type FROM bsth_c_ls_stationroute t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod where t1.destroy=0 and t1.line_code='" + lineCode + "' and t1.versions="+extendsVersion+" order by t1.directions, t1.station_route_code";
  397 + List<CascadeSaveStation> cssList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveStation.class));
  398 +
  399 + //新的站点编码
  400 + long sCode;
  401 + for (CascadeSaveStation ss : cssList) {
  402 + sCode = stationRepository.stationMaxId() + 1;
  403 + ss.setRouteId(null);
  404 + ss.setStationCode(sCode + "");
  405 + ss.setStation((int) sCode);
  406 + }
  407 + //入库新版本的站点 和 路由
  408 + batchInsertStation(cssList, maxVersion);
  409 +
  410 + //复制路段信息
  411 + sql = "SELECT t1.id AS route_id,t1.line,t1.line_code,t1.directions,t1.section,t1.section_code,t1.sectionroute_code,t1.versions,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector,t2.db_type,t2.speed_limit FROM bsth_c_ls_sectionroute t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code WHERE t1.destroy = 0 AND t1.line_code = '"+lineCode+"' and t1.versions="+ extendsVersion +" ORDER BY t1.directions,t1.sectionroute_code";
  412 + List<CascadeSaveRoad> csrList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveRoad.class));
  413 + //新的路段编码
  414 + long cCode;
  415 + for(CascadeSaveRoad csr : csrList){
  416 + cCode = sectionRepository.sectionMaxId() + 1;
  417 + csr.setRouteId(null);
  418 + csr.setSection((int) cCode);
  419 + csr.setSectionCode(cCode + "");
  420 + }
  421 + //入库新版本的路段 和 路段路由
  422 + batchInsertRoad(csrList, maxVersion);
  423 + }
  424 +
  425 + tran.commit(status);
  426 + rs.put("newVersion", maxVersion);
  427 + rs.put("status", ResponseCode.SUCCESS);
  428 + } catch (Exception e) {
  429 + tran.rollback(status);
  430 + logger.error("", e);
  431 + rs.put("status", ResponseCode.ERROR);
  432 + rs.put("msg", "服务器出现异常");
  433 + }
  434 + return rs;
  435 + }
  436 +
  437 + /**
  438 + * 删除一个线路走向版本
  439 + * @param lineCode
  440 + * @param version
  441 + * @return
  442 + */
  443 + @Override
  444 + public Map<String, Object> deleteLineVersion(String lineCode, int version) {
  445 + Map<String, Object> rs = new HashMap<>();
  446 +
  447 + //编程式事务
  448 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  449 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  450 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  451 + TransactionStatus status = tran.getTransaction(def);
  452 + try{
  453 + int enableVersion = jdbcTemplate.queryForObject("select versions from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=1", Integer.class);
  454 +
  455 + if(enableVersion==version){
  456 + rs.put("status", ResponseCode.ERROR);
  457 + rs.put("msg", "你不能删除当前正在启用的走向版本!");
  458 + return rs;
  459 + }
  460 + /*int versionCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code='"+lineCode+"'", Integer.class);
  461 + if(versionCount == 1){
  462 + rs.put("status", ResponseCode.ERROR);
  463 + rs.put("msg", "线路至少要保留一个走向版本!");
  464 + return rs;
  465 + }*/
  466 +
  467 + /* //要删除的站点ID(未被其他线路、版本引用的)
  468 + String sql = "select DISTINCT station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version+" and station not in(" +
  469 + "select station from bsth_c_ls_stationroute where (line!='"+lineCode+"' or versions!="+version+") and station in (" +
  470 + "select station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version +
  471 + "))";
  472 +
  473 + List<Integer> stationRemoves = jdbcTemplate.queryForList(sql, Integer.class);*/
  474 +
  475 + //删除站点路由
  476 + String sql = "delete from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions=" + version;
  477 + jdbcTemplate.update(sql);
  478 +
  479 + //删除路段路由
  480 + sql = "delete from bsth_c_ls_sectionroute where line_code='"+lineCode+"' and versions=" + version;
  481 + jdbcTemplate.update(sql);
  482 +
  483 + //删除版本信息
  484 + sql = "delete from bsth_c_line_versions where line_code='"+lineCode+"' and versions=" + version;
  485 + jdbcTemplate.update(sql);
  486 +
  487 + tran.commit(status);
  488 + rs.put("status", ResponseCode.SUCCESS);
  489 + }catch (Exception e){
  490 + tran.rollback(status);
  491 + logger.error("", e);
  492 + rs.put("status", ResponseCode.ERROR);
  493 + rs.put("msg", "服务器出现异常");
  494 + }
  495 + return rs;
  496 + }
  497 +
  498 + /**
  499 + * 获取线路的待更新版本信息
  500 + * @param lineCode
  501 + * @return
  502 + */
  503 + @Override
  504 + public Map<String, Object> findFutureVersion(String lineCode) {
  505 + Map<String, Object> rs = new HashMap();
  506 + try{
  507 + List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=2 order by start_date");
  508 +
  509 + rs.put("data", list);
  510 + rs.put("status", ResponseCode.SUCCESS);
  511 + }catch (Exception e){
  512 + logger.error("", e);
  513 + rs.put("status", ResponseCode.ERROR);
  514 + rs.put("msg", "服务器出现异常");
  515 + }
  516 + return rs;
  517 + }
  518 +
  519 + @Override
  520 + public Map<String, Object> addEnableInfo(String lineCode, int version, String enableTime) {
  521 + Map<String, Object> rs = new HashMap();
  522 + try{
  523 + Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(enableTime);
  524 + if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){
  525 + rs.put("status", ResponseCode.ERROR);
  526 + rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!");
  527 + return rs;
  528 + }
  529 +
  530 + jdbcTemplate.update("update bsth_c_line_versions set `status`=0 where line_code="+lineCode+" and versions=" + version);
  531 + jdbcTemplate.update("update bsth_c_line_versions set `status`=2 ,start_date=? where line_code=? and versions=?", startDate, lineCode, version);
  532 +
  533 + rs.put("status", ResponseCode.SUCCESS);
  534 + }catch (Exception e){
  535 + logger.error("", e);
  536 + rs.put("status", ResponseCode.ERROR);
  537 + rs.put("msg", "服务器出现异常");
  538 + }
  539 + return rs;
  540 + }
  541 +
  542 + /**
  543 + * 批量入库路段
  544 + * @param cssList
  545 + * @param version
  546 + */
  547 + private void batchInsertRoad(final List<CascadeSaveRoad> csrList, final int version){
  548 + final Date d = new Date();
  549 + jdbcTemplate.batchUpdate("insert into bsth_c_section(id, section_code, section_name, croses_road, gsection_vector, create_date, update_date, versions) " +
  550 + " values(?,?,?,?,ST_GeomFromText(?),?,?,?)", new BatchPreparedStatementSetter() {
  551 + @Override
  552 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  553 + CascadeSaveRoad csr = csrList.get(i);
  554 + ps.setInt(1, csr.getSection());
  555 + ps.setString(2, csr.getSectionCode());
  556 + ps.setString(3, csr.getSectionName());
  557 + ps.setString(4, csr.getCrosesRoad());
  558 + ps.setString(5, csr.getGsectionVector());
  559 + ps.setTimestamp(6, new java.sql.Timestamp(d.getTime()));
  560 + ps.setTimestamp(7, new java.sql.Timestamp(d.getTime()));
  561 + ps.setInt(8, version);
  562 + }
  563 +
  564 + @Override
  565 + public int getBatchSize() {
  566 + return csrList.size();
  567 + }
  568 + });
  569 +
  570 + //路由
  571 + jdbcTemplate.batchUpdate("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed) " +
  572 + " values(?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {
  573 + @Override
  574 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  575 + CascadeSaveRoad csr = csrList.get(i);
  576 + ps.setString(1, csr.getLineCode());
  577 + ps.setString(2, csr.getSectionCode());
  578 + ps.setInt(3, csr.getSectionrouteCode());
  579 + ps.setInt(4, csr.getDirections());
  580 + ps.setInt(5, csr.getLine());
  581 + ps.setInt(6, csr.getSection());
  582 + ps.setTimestamp(7, new java.sql.Timestamp(d.getTime()));
  583 + ps.setTimestamp(8, new java.sql.Timestamp(d.getTime()));
  584 + ps.setInt(9, version);
  585 + ps.setInt(10, 0);
  586 + ps.setInt(11, 0);
  587 + }
  588 +
  589 + @Override
  590 + public int getBatchSize() {
  591 + return csrList.size();
  592 + }
  593 + });
  594 + }
  595 +
  596 + /**
  597 + * 批量插入站点
  598 + *
  599 + * @param cssList
  600 + */
  601 + private void batchInsertStation(final List<CascadeSaveStation> cssList, final int version) {
  602 + //站点
  603 + jdbcTemplate.batchUpdate("insert into bsth_c_station(id, station_cod, station_name, db_type, b_jwpoints, g_lonx, g_laty, destroy, radius, shapes_type, versions, g_polygon_grid) " +
  604 + " values(?,?,?,?,?,?,?,?,?,?,?,ST_GeomFromText(?))", new BatchPreparedStatementSetter() {
  605 + @Override
  606 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  607 + CascadeSaveStation ss = cssList.get(i);
  608 + ps.setInt(1, ss.getStation());
  609 + ps.setString(2, ss.getStationCode());
  610 + ps.setString(3, ss.getStationName());
  611 + ps.setString(4, "b");
  612 + ps.setString(5, ss.getbJwpoints());
  613 + ps.setDouble(6, ss.getgLonx());
  614 + ps.setDouble(7, ss.getgLaty());
  615 + ps.setInt(8, 0);
  616 + ps.setInt(9, ss.getRadius()==null?0:ss.getRadius());
  617 + ps.setString(10, ss.getShapesType());
  618 + ps.setInt(11, version);
  619 + ps.setString(12, ss.getgPolygonGrid());
  620 + }
  621 +
  622 + @Override
  623 + public int getBatchSize() {
  624 + return cssList.size();
  625 + }
  626 + });
  627 +
  628 + final Date d = new Date();
  629 + //站点路由
  630 + jdbcTemplate.batchUpdate("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) " +
  631 + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {
  632 + @Override
  633 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  634 + CascadeSaveStation ss = cssList.get(i);
  635 + ps.setInt(1, ss.getLine());
  636 + ps.setInt(2, ss.getStation());
  637 + ps.setString(3, ss.getStationName());
  638 + ps.setInt(4, ss.getStationRouteCode());
  639 + ps.setString(5, ss.getLineCode());
  640 + ps.setString(6, ss.getStationCode());
  641 + ps.setString(7, ss.getStationMark());
  642 + ps.setDouble(8, ss.getDistances());
  643 + ps.setDouble(9, ss.getToTime());
  644 + ps.setInt(10, 0);
  645 + ps.setInt(11, version);
  646 + ps.setTimestamp(12, new java.sql.Timestamp(d.getTime()));
  647 + ps.setTimestamp(13, new java.sql.Timestamp(d.getTime()));
  648 + ps.setInt(14, ss.getDirections());
  649 + }
  650 +
  651 + @Override
  652 + public int getBatchSize() {
  653 + return cssList.size();
  654 + }
  655 + });
  656 + }
  657 +
  658 + @Override
  659 + public Map<String, Object> addNewStationRoute(String lineCode, int upDown, int versions, String stationName, Float lat, Float lng, int prevRouteId) {
  660 + Map<String, Object> rs = new HashMap<>();
  661 +
  662 + //编程式事务
  663 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  664 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  665 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  666 + TransactionStatus status = tran.getTransaction(def);
  667 + try {
  668 + //根据线路编码,查询线路ID
  669 + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);
  670 +
  671 + String sql = "select * from bsth_c_ls_stationroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions;
  672 + List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class));
  673 +
  674 + for (SaveStationRouteDTO s : routes) {
  675 + if (s.getStationName().equals(stationName)) {
  676 +
  677 + rs.put("status", ResponseCode.ERROR);
  678 + rs.put("msg", "重复的站点路由名称!");
  679 + return rs;
  680 + }
  681 + }
  682 + //按路由顺序排列
  683 + Collections.sort(routes, new StationRouteComp());
  684 +
  685 + //转WGS
  686 + TransGPS.Location wgsLoc = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(String.valueOf(lng)), Double.parseDouble(String.valueOf(lat)))));
  687 +
  688 + //insert 站点
  689 + long sCode = stationRepository.stationMaxId() + 1;
  690 + jdbcTemplate.update("insert into bsth_c_station(id, station_cod, station_name, db_type, b_jwpoints, g_lonx, g_laty, destroy, radius, shapes_type, versions) " +
  691 + " values(?,?,?,?,?,?,?,?,?,?,?)", sCode, sCode, stationName, "b", lng + " " + lat, wgsLoc.getLng(), wgsLoc.getLat(), 0, 88, "r", 1);
  692 +
  693 +
  694 + SaveStationRouteDTO sr;
  695 + int currentNo = -1,
  696 + no = 100, step = 100;
  697 +
  698 + if (prevRouteId == -1) {
  699 + //起点站
  700 + currentNo = no;
  701 + no += step;
  702 + }
  703 + //重新排序路由
  704 + for (int i = 0, size = routes.size(); i < size; i++) {
  705 + sr = routes.get(i);
  706 + sr.setStationRouteCode(no);
  707 + no += step;
  708 + if (sr.getId().intValue() == prevRouteId) {
  709 + currentNo = no;
  710 + no += step;
  711 + }
  712 + }
  713 +
  714 + SaveStationRouteDTO nsr = new SaveStationRouteDTO();
  715 + nsr.setLine(lineId);
  716 + nsr.setLineCode(lineCode);
  717 + nsr.setDirections(upDown);
  718 + nsr.setVersions(versions);
  719 + nsr.setStationRouteCode(currentNo);
  720 + nsr.setStation(sCode);
  721 + nsr.setStationCode(sCode + "");
  722 + nsr.setStationName(stationName);
  723 + nsr.setDistances(0d);
  724 + nsr.setToTime(0d);
  725 + Date d = new Date();
  726 + nsr.setCreateDate(d);
  727 + nsr.setUpdateDate(d);
  728 + nsr.setDestroy(0);
  729 + if (prevRouteId == -1)
  730 + nsr.setStationMark("B");
  731 + else if(routes.size()==1)
  732 + nsr.setStationMark("E");
  733 +
  734 + //routes.add(sr);
  735 +
  736 + //重新标记mark
  737 + Collections.sort(routes, new StationRouteComp());
  738 + for (int i = 0, size = routes.size(); i < size; i++) {
  739 + routes.get(i).setStationMark("Z");
  740 + }
  741 + if(routes.size() > 0 && prevRouteId!=-1)
  742 + routes.get(0).setStationMark("B");
  743 + if(routes.size() > 1)
  744 + routes.get(routes.size() - 1).setStationMark("E");
  745 +
  746 + final List<SaveStationRouteDTO> saveList = routes;
  747 + //insert 新路由 (ID自增)
  748 + jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
  749 + , nsr.getLine(), nsr.getStation(), nsr.getStationName(), nsr.getStationRouteCode(), nsr.getLineCode(), nsr.getStationCode(), nsr.getStationMark()
  750 + , nsr.getDistances(), nsr.getToTime(), nsr.getDestroy(), nsr.getVersions(), nsr.getCreateDate(), nsr.getUpdateDate(), nsr.getDirections());
  751 +
  752 + // update 原路由
  753 + jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," +
  754 + "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" +
  755 + " where id=?"
  756 + , new BatchPreparedStatementSetter() {
  757 + @Override
  758 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  759 + SaveStationRouteDTO sr = saveList.get(i);
  760 + ps.setInt(1, sr.getLine());
  761 + ps.setLong(2, sr.getStation());
  762 + ps.setString(3, sr.getStationName());
  763 + ps.setInt(4, sr.getStationRouteCode());
  764 + ps.setString(5, sr.getLineCode());
  765 + ps.setString(6, sr.getStationCode());
  766 + ps.setString(7, sr.getStationMark());
  767 + ps.setDouble(8, sr.getDistances());
  768 + ps.setDouble(9, sr.getToTime());
  769 + ps.setInt(10, sr.getDestroy());
  770 + ps.setInt(11, sr.getVersions());
  771 + ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime()));
  772 + ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime()));
  773 + ps.setInt(14, sr.getDirections());
  774 + ps.setInt(15, sr.getId());
  775 + }
  776 +
  777 + @Override
  778 + public int getBatchSize() {
  779 + return saveList.size();
  780 + }
  781 + });
  782 +
  783 + //写一条走向变更记录
  784 + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions);
  785 +
  786 + tran.commit(status);
  787 +
  788 + //返回更新之后的数据
  789 + List<GeoStation> list = findByUpdown(lineCode, upDown, versions);
  790 +
  791 + rs.put("list", list);
  792 + rs.put("newStationRouteCode", currentNo);
  793 + rs.put("status", ResponseCode.SUCCESS);
  794 + } catch (Exception e) {
  795 + tran.rollback(status);
  796 + logger.error("", e);
  797 + rs.put("status", ResponseCode.ERROR);
  798 + rs.put("msg", "服务器出现异常");
  799 + }
  800 + return rs;
  801 + }
  802 +
  803 + private List<GeoStation> findByUpdown(String lineCode, int upDown, int versions) {
  804 + //返回更新之后的数据
  805 + String sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and directions=" + upDown + " and destroy=0 and versions=" + versions + ") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod";
  806 + List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));
  807 +
  808 + for (GeoStation station : list) {
  809 + if (station.getShapesType().equals("d"))
  810 + station.setBdCoords(multiWgsToBd(station.getgPolygonGrid(), 9, 3));
  811 + }
  812 + return list;
  813 + }
  814 +
  815 + private List<GeoRoad> findRoadByUpdown(String lineCode, int upDown, int versions) {
  816 + //返回更新之后的数据
  817 + String sql = "select t1.*,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector from (select id,sectionroute_code,directions,line_code,section_code,versions from bsth_c_ls_sectionroute where line='" + lineCode + "' and directions=" + upDown + " and destroy=0 and versions=" + versions + ") t1 LEFT JOIN bsth_c_section t2 on t1.section_code=t2.section_code";
  818 + List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));
  819 +
  820 + for (GeoRoad road : list) {
  821 + road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));
  822 + }
  823 + return list;
  824 + }
  825 +
  826 + @Override
  827 + public Map<String, Object> destroyStation(GeoStation station) {
  828 + Map<String, Object> rs = new HashMap<>();
  829 +
  830 + //编程式事务
  831 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  832 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  833 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  834 + TransactionStatus status = tran.getTransaction(def);
  835 + try {
  836 + String sql = "update bsth_c_ls_stationroute set destroy=1 where id=?";
  837 + jdbcTemplate.update(sql, station.getId());
  838 +
  839 + /**
  840 + * ########## 重新排序路由,标记mark #########
  841 + */
  842 + sql = "select * from bsth_c_ls_stationroute where line_code='" + station.getLineCode() + "' and directions=" + station.getDirections() + " and destroy=0 and versions=" + station.getVersions();
  843 + List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class));
  844 + Collections.sort(routes, new StationRouteComp());
  845 +
  846 + int no = 0,
  847 + step = 100;
  848 + SaveStationRouteDTO sr;
  849 + //重新排序路由
  850 + for (int i = 0, size = routes.size(); i < size; i++) {
  851 + sr = routes.get(i);
  852 + sr.setStationRouteCode(no += step);
  853 + }
  854 +
  855 + for (int i = 0, size = routes.size(); i < size; i++) {
  856 + routes.get(i).setStationMark("Z");
  857 + }
  858 + if(routes.size() > 0)
  859 + routes.get(0).setStationMark("B");
  860 + if(routes.size() > 1)
  861 + routes.get(routes.size() - 1).setStationMark("E");
  862 +
  863 + final List<SaveStationRouteDTO> saveList = routes;
  864 + // update 原路由
  865 + jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," +
  866 + "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" +
  867 + " where id=?"
  868 + , new BatchPreparedStatementSetter() {
  869 + @Override
  870 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  871 + SaveStationRouteDTO sr = saveList.get(i);
  872 + ps.setInt(1, sr.getLine());
  873 + ps.setLong(2, sr.getStation());
  874 + ps.setString(3, sr.getStationName());
  875 + ps.setInt(4, sr.getStationRouteCode());
  876 + ps.setString(5, sr.getLineCode());
  877 + ps.setString(6, sr.getStationCode());
  878 + ps.setString(7, sr.getStationMark());
  879 + ps.setDouble(8, sr.getDistances());
  880 + ps.setDouble(9, sr.getToTime());
  881 + ps.setInt(10, sr.getDestroy());
  882 + ps.setInt(11, sr.getVersions());
  883 + ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime()));
  884 + ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime()));
  885 + ps.setInt(14, sr.getDirections());
  886 + ps.setInt(15, sr.getId());
  887 + }
  888 +
  889 + @Override
  890 + public int getBatchSize() {
  891 + return saveList.size();
  892 + }
  893 + });
  894 +
  895 + //写一条走向变更记录
  896 + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), station.getLineCode(), station.getVersions());
  897 +
  898 + tran.commit(status);
  899 +
  900 + //返回更新之后的数据
  901 + List<GeoStation> list = findByUpdown(station.getLineCode(), station.getDirections(), station.getVersions());
  902 + rs.put("list", list);
  903 + rs.put("status", ResponseCode.SUCCESS);
  904 + } catch (Exception e) {
  905 + tran.rollback(status);
  906 + logger.error("", e);
  907 + rs.put("status", ResponseCode.ERROR);
  908 + rs.put("msg", "服务器出现异常");
  909 + }
  910 + return rs;
  911 + }
  912 +
  913 + @Override
  914 + public Map<String, Object> destroyRoad(GeoRoad road) {
  915 + Map<String, Object> rs = new HashMap<>();
  916 +
  917 + try {
  918 + String sql = "update bsth_c_ls_sectionroute set destroy=1 where id=?";
  919 + jdbcTemplate.update(sql, road.getId());
  920 +
  921 + //写一条走向变更记录
  922 + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), road.getLineCode(), road.getVersions());
  923 +
  924 + //返回更新之后的数据
  925 + List<GeoRoad> list = findRoadByUpdown(road.getLineCode(), road.getDirections(), road.getVersions());
  926 + rs.put("list", list);
  927 + rs.put("status", ResponseCode.SUCCESS);
  928 + } catch (Exception e) {
  929 + logger.error("", e);
  930 + rs.put("status", ResponseCode.ERROR);
  931 + rs.put("msg", "服务器出现异常");
  932 + }
  933 + return rs;
  934 + }
  935 +
  936 + @Override
  937 + public Map<String, Object> updateRoadInfo(GeoRoad road) {
  938 + Map<String, Object> rs = new HashMap<>();
  939 +
  940 + try {
  941 + //坐标转换
  942 + String bdPolyline = "LINESTRING(" + road.getGsectionVector() + ")";
  943 + String wgsPolyline = "LINESTRING(" + bdPolygon2Wgs(road.getGsectionVector()) + ")";
  944 +
  945 + String sql = "update bsth_c_section set section_name=?, croses_road=?, bsection_vector=ST_GeomFromText('" + bdPolyline + "'),gsection_vector=ST_GeomFromText('" + wgsPolyline + "'),update_date=sysdate() where section_code=?";
  946 +
  947 + int rsCount = jdbcTemplate.update(sql, road.getSectionName(), road.getCrosesRoad(), road.getSectionCode());
  948 +
  949 + //从数据库里重新查询对象
  950 + if (rsCount > 0) {
  951 + rs.put("road", findOneRoad(road.getId()));
  952 + rs.put("status", ResponseCode.SUCCESS);
  953 + }
  954 + } catch (Exception e) {
  955 + logger.error("", e);
  956 + rs.put("status", ResponseCode.ERROR);
  957 + rs.put("msg", "服务器出现异常");
  958 + }
  959 + return rs;
  960 + }
  961 +
  962 +
  963 + /**
  964 + * 根据路由ID 获取站点
  965 + *
  966 + * @param id
  967 + * @return
  968 + */
  969 + private GeoStation findOne(int id) {
  970 + String sql = "SELECT t1.*, t2.g_lonx,g_laty,ST_AsText (g_polygon_grid) AS g_polygon_grid,radius,shapes_type FROM (SELECT id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions FROM bsth_c_ls_stationroute WHERE id=" + id + " AND destroy = 0) t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod";
  971 + List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));
  972 +
  973 + GeoStation s = list.get(0);
  974 + if (s.getShapesType().equals("d"))
  975 + s.setBdCoords(multiWgsToBd(s.getgPolygonGrid(), 9, 3));
  976 +
  977 + return s;
  978 + }
  979 +
  980 + private GeoRoad findOneRoad(int id) {
  981 + String sql = "SELECT t1.*, t2.section_name,t2.croses_road,ST_AsText (t2.gsection_vector) AS gsection_vector FROM (SELECT id,sectionroute_code,directions,line_code,section_code,versions FROM bsth_c_ls_sectionroute WHERE id=" + id + ") t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code";
  982 + List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));
  983 +
  984 + for (GeoRoad road : list) {
  985 + road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));
  986 + }
  987 + return list.size() > 0 ? list.get(0) : null;
  988 + }
  989 +
  990 + private String bdPolygon2Wgs(String bdPolygon) {
  991 + StringBuilder wgsPolygon = new StringBuilder();
  992 + List<String> list = Splitter.on(",").splitToList(bdPolygon);
  993 + String[] array;
  994 +
  995 + TransGPS.Location location;
  996 + for (String p : list) {
  997 + array = p.split(" ");
  998 + location = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(array[0]), Double.parseDouble(array[1]))));
  999 +
  1000 + wgsPolygon.append(location.getLng() + " " + location.getLat() + ",");
  1001 + }
  1002 +
  1003 + if (wgsPolygon.length() > 0) {
  1004 + wgsPolygon.deleteCharAt(wgsPolygon.length() - 1);
  1005 + }
  1006 + return wgsPolygon.toString();
  1007 + }
  1008 +
  1009 + /**
  1010 + * wgs 坐标数组转 百度
  1011 + *
  1012 + * @return
  1013 + */
  1014 + private List<String> multiWgsToBd(String crdStr, int si, int ei) {
  1015 + List<String> bdList = new ArrayList<>();
  1016 +
  1017 + List<String> gList = Splitter.on(",").splitToList(crdStr.substring(si, crdStr.length() - ei));
  1018 + TransGPS.Location location;
  1019 + String[] cds;
  1020 + for (String gs : gList) {
  1021 + cds = gs.split(" ");
  1022 + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(Double.parseDouble(cds[0]), Double.parseDouble(cds[1]))));
  1023 +
  1024 + bdList.add(location.getLng() + " " + location.getLat());
  1025 + }
  1026 + return bdList;
  1027 + }
  1028 +
  1029 + private static class StationRouteComp implements Comparator<SaveStationRouteDTO> {
  1030 +
  1031 + @Override
  1032 + public int compare(SaveStationRouteDTO s1, SaveStationRouteDTO s2) {
  1033 + return s1.getStationRouteCode() - s2.getStationRouteCode();
  1034 + }
  1035 + }
  1036 +
  1037 + private static class RoadRouteComp implements Comparator<SaveRoadRouteDTO> {
  1038 +
  1039 + @Override
  1040 + public int compare(SaveRoadRouteDTO s1, SaveRoadRouteDTO s2) {
  1041 + return s1.getSectionrouteCode() - s2.getSectionrouteCode();
  1042 + }
  1043 + }
1036 } 1044 }
1037 \ No newline at end of file 1045 \ No newline at end of file
src/main/java/com/bsth/service/impl/CarParkServiceImpl.java
1 -package com.bsth.service.impl;  
2 -  
3 -import java.text.SimpleDateFormat;  
4 -import java.util.ArrayList;  
5 -import java.util.Date;  
6 -import java.util.HashMap;  
7 -import java.util.List;  
8 -import java.util.Map;  
9 -  
10 -import com.bsth.common.ResponseCode;  
11 -import com.bsth.entity.CarPark;  
12 -import com.bsth.repository.CarParkRepository;  
13 -import com.bsth.service.CarParkService;  
14 -import com.bsth.util.TransGPS;  
15 -import com.bsth.util.TransGPS.Location;  
16 -  
17 -import org.springframework.beans.factory.annotation.Autowired;  
18 -import org.springframework.stereotype.Service;  
19 -  
20 -  
21 -@Service  
22 -public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implements CarParkService {  
23 -  
24 - @Autowired  
25 - CarParkRepository carParkRepository;  
26 -  
27 - @Override  
28 - public Map<String, Object> carParkSave(Map<String, Object> map) {  
29 - Map<String, Object> resultMap = new HashMap<String, Object>();  
30 - try {  
31 - // 停车场编码  
32 - String parkCode = map.get("parkCode").equals("") ? null : map.get("parkCode").toString();  
33 - if (!selectTccInfoByCode(map)) {  
34 - resultMap.put("status", ResponseCode.ERROR);  
35 - return resultMap;  
36 - }  
37 - // 停车场名称  
38 - String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString();  
39 - // 地理位置(百度坐标集合)  
40 - String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString();  
41 - // 多边形WGS坐标点集合  
42 - String gParkPoint ="";  
43 - if(!bParkPoint.equals("")) {  
44 - String bPloygonGridArray[] = bParkPoint.split(",");  
45 - int bLen_ = bPloygonGridArray.length;  
46 - for(int b = 0 ;b<bLen_;b++) {  
47 - String tempArray[]= bPloygonGridArray[b].split(" ");  
48 - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);  
49 - if(b==0) {  
50 - gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat();  
51 - }else {  
52 - gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat();  
53 - }  
54 - }  
55 -  
56 - }  
57 - if(bParkPoint.equals(""))  
58 - bParkPoint = null;  
59 - else  
60 - bParkPoint = "POLYGON((" + bParkPoint +"))";  
61 -  
62 - if(gParkPoint.equals(""))  
63 - gParkPoint = null;  
64 - else  
65 - gParkPoint = "POLYGON((" + gParkPoint +"))";  
66 - // 地理位置中心点(百度坐标)  
67 - String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();  
68 - String bJwpointsArray[] =null;  
69 - if(bCenterPoint!=null) {  
70 - bJwpointsArray = bCenterPoint.split(" ");  
71 - }  
72 - String gCenterPoint = null;  
73 - if(bJwpointsArray.length>0) {  
74 - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);  
75 - gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());  
76 - }  
77 - // 坐标类型  
78 - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();  
79 - // 图形类型  
80 - String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();  
81 - // 半径  
82 - Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());  
83 - // 面积  
84 - Double area = map.get("area").equals("") ? 0.0 : Double.parseDouble(map.get("area").toString());  
85 - // 公司  
86 - String company = map.get("company").equals("") ? "" : map.get("company").toString();  
87 - // 分公司  
88 - String brancheCompany = map.get("brancheCompany").equals("") ? "" : map.get("brancheCompany").toString();  
89 - // 是否撤销  
90 - Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());  
91 - // 版本号  
92 - Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());  
93 - // 描述与说明  
94 - String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();  
95 - SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");  
96 - Date date = new Date();  
97 - // 创建日期  
98 - String createDate = formatter.format(date);  
99 - // 修改日期  
100 - String updateDate = formatter.format(date);  
101 - // 创建人  
102 - Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());  
103 - // 修改人  
104 - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());  
105 - carParkRepository.carParkSave(area, company, parkCode, parkName,  
106 - brancheCompany, createBy, createDate, descriptions, destroy,  
107 - updateBy, updateDate, versions, bCenterPoint, bParkPoint,  
108 - dbType, gCenterPoint, gParkPoint, radius, shapesType);  
109 - resultMap.put("status", ResponseCode.SUCCESS);  
110 - } catch (Exception e) {  
111 - resultMap.put("status", ResponseCode.ERROR);  
112 - logger.error("save erro.", e);  
113 - }  
114 - return resultMap;  
115 - }  
116 -  
117 - @Override  
118 - public List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map) {  
119 - // 获取线路ID  
120 - Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString());  
121 - List<Object[]> objects = carParkRepository.findCarParkInfoFormId(id);  
122 - List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();  
123 - int len = objects.size();  
124 - if(objects.size()>0) {  
125 - for(int i = 0 ; i < len; i++) {  
126 - Map<String, Object> tempM = new HashMap<String,Object>();  
127 - tempM.put("carParkId", objects.get(i)[0]);  
128 - tempM.put("carParkArea", objects.get(i)[1]);  
129 - tempM.put("carParkCompany", objects.get(i)[2]);  
130 - tempM.put("carParkCode", objects.get(i)[3]);  
131 - tempM.put("carParkName", objects.get(i)[4]);  
132 - tempM.put("carParkBrancheCompany", objects.get(i)[5]);  
133 - tempM.put("carParkCreateBy", objects.get(i)[6]);  
134 - tempM.put("carParkCreateDate", objects.get(i)[7]);  
135 - tempM.put("carParkDescriptions", objects.get(i)[8]);  
136 - tempM.put("carParkDestroy", objects.get(i)[9]);  
137 - tempM.put("carParkUpdate", objects.get(i)[10]);  
138 - tempM.put("carParkUpdateDate", objects.get(i)[11]);  
139 - tempM.put("carParkVersions", objects.get(i)[12]);  
140 - tempM.put("carParkBcenterPoint", objects.get(i)[13]);  
141 - tempM.put("carParkBparkPoint", objects.get(i)[14]);  
142 - tempM.put("carParkGcenterPoint", objects.get(i)[15]);  
143 - tempM.put("carParkGparkPoint", objects.get(i)[16]);  
144 - tempM.put("carParkDBtype", objects.get(i)[17]);  
145 - tempM.put("carParkRadius", objects.get(i)[18]);  
146 - tempM.put("carParkShapesType", objects.get(i)[19]);  
147 - resultList.add(tempM);  
148 - }  
149 - }  
150 - return resultList;  
151 - }  
152 - /**  
153 - * 修改停车场信息  
154 - *  
155 - *  
156 - * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;  
157 - *  
158 - * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;  
159 - *  
160 - * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;  
161 - *  
162 - * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>  
163 - *  
164 - * @return map <SUCCESS:成功;ERROR:失败>  
165 - *  
166 - */  
167 - @Override  
168 - public Map<String, Object> carParkUpdate(Map<String, Object> map) {  
169 - Map<String, Object> resultMap = new HashMap<String, Object>();  
170 - try {  
171 - // id  
172 - Integer id = map.get("id").equals("") ? null : Integer.parseInt(map.get("id").toString());  
173 - if(id!=null) {  
174 - // 面积  
175 - Double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString());  
176 - // 中心点(百度坐标)  
177 - String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();  
178 - // 图形坐标点集合(百度坐标)  
179 - String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString();  
180 - // 分公司  
181 - String brancheCompany = map.get("brancheCompany").equals("")? "" :map.get("brancheCompany").toString();  
182 - //String brancheCompany = "";  
183 - // 公司  
184 - String company = map.get("company").equals("") ? "" : map.get("company").toString();  
185 - // 坐标类型  
186 - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();  
187 - // 描述与说明  
188 - String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();  
189 - // 是否撤销  
190 - Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());  
191 - // 中心点(WGS坐标)  
192 - // String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString();  
193 - String bJwpointsArray[] =null;  
194 - if(bCenterPoint!=null) {  
195 - bJwpointsArray = bCenterPoint.split(" ");  
196 - }  
197 - String gCenterPoint =null;  
198 - if(bJwpointsArray.length>0) {  
199 - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);  
200 - gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());  
201 - }  
202 - // 图形坐标点集合(WGS坐标)  
203 - // String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString();  
204 - // 多边形WGS坐标点集合  
205 - String gParkPoint ="";  
206 - if(!bParkPoint.equals("")) {  
207 - String bPloygonGridArray[] = bParkPoint.split(",");  
208 - int bLen_ = bPloygonGridArray.length;  
209 - for(int b = 0 ;b<bLen_;b++) {  
210 - String tempArray[]= bPloygonGridArray[b].split(" ");  
211 - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);  
212 - if(b==0) {  
213 - gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat();  
214 - }else {  
215 - gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat();  
216 - }  
217 - }  
218 - }  
219 - if(bParkPoint.equals(""))  
220 - bParkPoint = null;  
221 - else  
222 - bParkPoint = "POLYGON((" + bParkPoint +"))";  
223 -  
224 - if(gParkPoint.equals(""))  
225 - gParkPoint = null;  
226 - else  
227 - gParkPoint = "POLYGON((" + gParkPoint +"))";  
228 - /*bParkPoint = "POLYGON((" + bParkPoint +"))";  
229 -  
230 - gParkPoint = "POLYGON((" + gParkPoint +"))";*/  
231 - // 编码  
232 - String parkCode = map.get("parkCode").equals("") ? "" : map.get("parkCode").toString();  
233 - // 名称  
234 - String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString();  
235 - // 半径  
236 - Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());  
237 - // 图形类型  
238 - String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();  
239 - // 版本  
240 - Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());  
241 - // 创建人  
242 - Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());  
243 - // 创建日期  
244 - String createDate = map.get("createDate").equals("") ? "" : map.get("createDate").toString();  
245 - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());  
246 - SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");  
247 - Date date = new Date();  
248 - // 修改日期  
249 - String updateDate = formatter.format(date);  
250 - carParkRepository.carParkUpdate(area, company, parkCode, parkName, brancheCompany, createBy, createDate, descriptions, destroy, updateBy, updateDate, versions, bCenterPoint, gCenterPoint, bParkPoint, gParkPoint, dbType, radius, shapesType, id);  
251 - }  
252 - resultMap.put("status", ResponseCode.SUCCESS);  
253 - } catch (Exception e) {  
254 - resultMap.put("status", ResponseCode.ERROR);  
255 - logger.error("save erro.", e);  
256 - }  
257 - return resultMap;  
258 - }  
259 - /** 百度坐标转WGS坐标 */  
260 - public Location FromBDPointToWGSPoint(String bLonx,String bLatx) {  
261 - double lng = Double.parseDouble(bLonx);  
262 - double lat = Double.parseDouble(bLatx);  
263 - Location bdLoc = TransGPS.LocationMake(lng, lat);  
264 - Location location = TransGPS.bd_decrypt(bdLoc);  
265 - Location WGSPoint = TransGPS.transformFromGCJToWGS(location);  
266 - return WGSPoint;  
267 - }  
268 -  
269 - @Override  
270 - public boolean selectTccInfoByCode(Map<String, Object> map) {  
271 - List<Object[]> arrayObj = carParkRepository.selectTccInfoByCode(map.get("parkCode").equals("") ? "" : map.get("parkCode").toString());  
272 - boolean tag = true;  
273 - if(arrayObj.size()>0) {  
274 - tag= false;  
275 - }  
276 - return tag;  
277 - }  
278 -} 1 +package com.bsth.service.impl;
  2 +
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.ArrayList;
  5 +import java.util.Date;
  6 +import java.util.HashMap;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +import com.bsth.common.ResponseCode;
  11 +import com.bsth.entity.CarPark;
  12 +import com.bsth.repository.CarParkRepository;
  13 +import com.bsth.service.CarParkService;
  14 +import com.bsth.util.TransGPS;
  15 +import com.bsth.util.TransGPS.Location;
  16 +
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.stereotype.Service;
  19 +
  20 +
  21 +@Service
  22 +public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implements CarParkService {
  23 +
  24 + @Autowired
  25 + CarParkRepository carParkRepository;
  26 +
  27 + @Override
  28 + public Map<String, Object> carParkSave(Map<String, Object> map) {
  29 + Map<String, Object> resultMap = new HashMap<String, Object>();
  30 + try {
  31 + // 停车场编码
  32 + String parkCode = map.get("parkCode").equals("") ? null : map.get("parkCode").toString();
  33 + if (!selectTccInfoByCode(map)) {
  34 + resultMap.put("status", ResponseCode.ERROR);
  35 + return resultMap;
  36 + }
  37 + // 停车场名称
  38 + String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString();
  39 + // 地理位置(百度坐标集合)
  40 + String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString();
  41 + // 多边形WGS坐标点集合
  42 + String gParkPoint ="";
  43 + if(!bParkPoint.equals("")) {
  44 + String bPloygonGridArray[] = bParkPoint.split(",");
  45 + int bLen_ = bPloygonGridArray.length;
  46 + for(int b = 0 ;b<bLen_;b++) {
  47 + String tempArray[]= bPloygonGridArray[b].split(" ");
  48 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
  49 + if(b==0) {
  50 + gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat();
  51 + }else {
  52 + gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
  53 + }
  54 + }
  55 +
  56 + }
  57 + if(bParkPoint.equals(""))
  58 + bParkPoint = null;
  59 + else
  60 + bParkPoint = "POLYGON((" + bParkPoint +"))";
  61 +
  62 + if(gParkPoint.equals(""))
  63 + gParkPoint = null;
  64 + else
  65 + gParkPoint = "POLYGON((" + gParkPoint +"))";
  66 + // 地理位置中心点(百度坐标)
  67 + String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();
  68 + String bJwpointsArray[] =null;
  69 + if(bCenterPoint!=null) {
  70 + bJwpointsArray = bCenterPoint.split(" ");
  71 + }
  72 + String gCenterPoint = null;
  73 + if(bJwpointsArray.length>0) {
  74 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
  75 + gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
  76 + }
  77 + // 坐标类型
  78 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  79 + // 图形类型
  80 + String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
  81 + // 半径
  82 + Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
  83 + // 面积
  84 + Double area = map.get("area").equals("") ? 0.0 : Double.parseDouble(map.get("area").toString());
  85 + // 公司
  86 + String company = map.get("company").equals("") ? "" : map.get("company").toString();
  87 + // 分公司
  88 + String brancheCompany = map.get("brancheCompany").equals("") ? "" : map.get("brancheCompany").toString();
  89 + // 是否撤销
  90 + Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
  91 + // 版本号
  92 + Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
  93 + // 描述与说明
  94 + String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
  95 + SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
  96 + Date date = new Date();
  97 + // 创建日期
  98 + String createDate = formatter.format(date);
  99 + // 修改日期
  100 + String updateDate = formatter.format(date);
  101 + // 创建人
  102 + Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
  103 + // 修改人
  104 + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
  105 + carParkRepository.carParkSave(area, company, parkCode, parkName,
  106 + brancheCompany, createBy, createDate, descriptions, destroy,
  107 + updateBy, updateDate, versions, bCenterPoint, bParkPoint,
  108 + dbType, gCenterPoint, gParkPoint, radius, shapesType);
  109 + resultMap.put("status", ResponseCode.SUCCESS);
  110 + } catch (Exception e) {
  111 + resultMap.put("status", ResponseCode.ERROR);
  112 + logger.error("save erro.", e);
  113 + }
  114 + return resultMap;
  115 + }
  116 +
  117 + @Override
  118 + public List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map) {
  119 + // 获取线路ID
  120 + Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString());
  121 + List<Object[]> objects = carParkRepository.findCarParkInfoFormId(id);
  122 + List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
  123 + int len = objects.size();
  124 + if(objects.size()>0) {
  125 + for(int i = 0 ; i < len; i++) {
  126 + Map<String, Object> tempM = new HashMap<String,Object>();
  127 + tempM.put("carParkId", objects.get(i)[0]);
  128 + tempM.put("carParkArea", objects.get(i)[1]);
  129 + tempM.put("carParkCompany", objects.get(i)[2]);
  130 + tempM.put("carParkCode", objects.get(i)[3]);
  131 + tempM.put("carParkName", objects.get(i)[4]);
  132 + tempM.put("carParkBrancheCompany", objects.get(i)[5]);
  133 + tempM.put("carParkCreateBy", objects.get(i)[6]);
  134 + tempM.put("carParkCreateDate", objects.get(i)[7]);
  135 + tempM.put("carParkDescriptions", objects.get(i)[8]);
  136 + tempM.put("carParkDestroy", objects.get(i)[9]);
  137 + tempM.put("carParkUpdate", objects.get(i)[10]);
  138 + tempM.put("carParkUpdateDate", objects.get(i)[11]);
  139 + tempM.put("carParkVersions", objects.get(i)[12]);
  140 + tempM.put("carParkBcenterPoint", objects.get(i)[13]);
  141 + tempM.put("carParkBparkPoint", objects.get(i)[14]);
  142 + tempM.put("carParkGcenterPoint", objects.get(i)[15]);
  143 + tempM.put("carParkGparkPoint", objects.get(i)[16]);
  144 + tempM.put("carParkDBtype", objects.get(i)[17]);
  145 + tempM.put("carParkRadius", objects.get(i)[18]);
  146 + tempM.put("carParkShapesType", objects.get(i)[19]);
  147 + resultList.add(tempM);
  148 + }
  149 + }
  150 + return resultList;
  151 + }
  152 + /**
  153 + * 修改停车场信息
  154 + *
  155 + *
  156 + * @param map<area:面积;bCenterPoint:中心点百度坐标;bParkPoint:多边形图形百度坐标点集合;
  157 + *
  158 + * brancheCompany:分公司;company:公司;createBy:创建人;createDate:创建日期;dbType:原坐标类型;descriptions:描述;
  159 + *
  160 + * destroy:是否撤销;gCenterPoint:WGS中心点坐标;gParkPoint:WGS多边形图形坐标集合;id:停车场ID;parkCode:停车场编码;
  161 + *
  162 + * parkName:停车名称;radius:圆半径;shapesType:图形类型;versions:版本号>
  163 + *
  164 + * @return map <SUCCESS:成功;ERROR:失败>
  165 + *
  166 + */
  167 + @Override
  168 + public Map<String, Object> carParkUpdate(Map<String, Object> map) {
  169 + Map<String, Object> resultMap = new HashMap<String, Object>();
  170 + try {
  171 + // id
  172 + Integer id = map.get("id").equals("") ? null : Integer.parseInt(map.get("id").toString());
  173 + if(id!=null) {
  174 + // 面积
  175 + Double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString());
  176 + // 中心点(百度坐标)
  177 + String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString();
  178 + // 图形坐标点集合(百度坐标)
  179 + String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString();
  180 + // 分公司
  181 + String brancheCompany = map.get("brancheCompany").equals("")? "" :map.get("brancheCompany").toString();
  182 + //String brancheCompany = "";
  183 + // 公司
  184 + String company = map.get("company").equals("") ? "" : map.get("company").toString();
  185 + // 坐标类型
  186 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  187 + // 描述与说明
  188 + String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
  189 + // 是否撤销
  190 + Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
  191 + // 中心点(WGS坐标)
  192 + // String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString();
  193 + String bJwpointsArray[] =null;
  194 + if(bCenterPoint!=null) {
  195 + bJwpointsArray = bCenterPoint.split(" ");
  196 + }
  197 + String gCenterPoint =null;
  198 + if(bJwpointsArray.length>0) {
  199 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
  200 + gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
  201 + }
  202 + // 图形坐标点集合(WGS坐标)
  203 + // String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString();
  204 + // 多边形WGS坐标点集合
  205 + String gParkPoint ="";
  206 + if(!bParkPoint.equals("")) {
  207 + String bPloygonGridArray[] = bParkPoint.split(",");
  208 + int bLen_ = bPloygonGridArray.length;
  209 + for(int b = 0 ;b<bLen_;b++) {
  210 + String tempArray[]= bPloygonGridArray[b].split(" ");
  211 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
  212 + if(b==0) {
  213 + gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat();
  214 + }else {
  215 + gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat();
  216 + }
  217 + }
  218 + }
  219 + if(bParkPoint.equals(""))
  220 + bParkPoint = null;
  221 + else
  222 + bParkPoint = "POLYGON((" + bParkPoint +"))";
  223 +
  224 + if(gParkPoint.equals(""))
  225 + gParkPoint = null;
  226 + else
  227 + gParkPoint = "POLYGON((" + gParkPoint +"))";
  228 + /*bParkPoint = "POLYGON((" + bParkPoint +"))";
  229 +
  230 + gParkPoint = "POLYGON((" + gParkPoint +"))";*/
  231 + // 编码
  232 + String parkCode = map.get("parkCode").equals("") ? "" : map.get("parkCode").toString();
  233 + // 名称
  234 + String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString();
  235 + // 半径
  236 + Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
  237 + // 图形类型
  238 + String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
  239 + // 版本
  240 + Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
  241 + // 创建人
  242 + Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
  243 + // 创建日期
  244 + String createDate = map.get("createDate").equals("") ? "" : map.get("createDate").toString();
  245 + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
  246 + SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
  247 + Date date = new Date();
  248 + // 修改日期
  249 + String updateDate = formatter.format(date);
  250 + carParkRepository.carParkUpdate(area, company, parkCode, parkName, brancheCompany, createBy, createDate, descriptions, destroy, updateBy, updateDate, versions, bCenterPoint, gCenterPoint, bParkPoint, gParkPoint, dbType, radius, shapesType, id);
  251 + }
  252 + resultMap.put("status", ResponseCode.SUCCESS);
  253 + } catch (Exception e) {
  254 + resultMap.put("status", ResponseCode.ERROR);
  255 + logger.error("save erro.", e);
  256 + }
  257 + return resultMap;
  258 + }
  259 + /** 百度坐标转WGS坐标 */
  260 + public Location FromBDPointToWGSPoint(String bLonx,String bLatx) {
  261 + double lng = Double.parseDouble(bLonx);
  262 + double lat = Double.parseDouble(bLatx);
  263 + Location bdLoc = TransGPS.LocationMake(lng, lat);
  264 + Location location = TransGPS.bd_decrypt(bdLoc);
  265 + Location WGSPoint = TransGPS.transformFromGCJToWGS(location);
  266 + return WGSPoint;
  267 + }
  268 +
  269 + @Override
  270 + public boolean selectTccInfoByCode(Map<String, Object> map) {
  271 + List<Object[]> arrayObj = carParkRepository.selectTccInfoByCode(map.get("parkCode").equals("") ? "" : map.get("parkCode").toString());
  272 + boolean tag = true;
  273 + if(arrayObj.size()>0) {
  274 + tag= false;
  275 + }
  276 + return tag;
  277 + }
  278 +
  279 + @Override
  280 + public long carParkMaxId() {
  281 + return carParkRepository.carParkMaxId();
  282 + }
  283 +}
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
@@ -283,7 +283,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -283,7 +283,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
283 283
284 LsSectionRoute oldData = sectionList.get(i); 284 LsSectionRoute oldData = sectionList.get(i);
285 285
286 - long sectionCode = GetUIDAndCode.getSectionId(); 286 + long sectionCode = sectionRepository.sectionMaxId() + 1;
287 287
288 sectionRepository.autoCopy(versions, (int)sectionCode, oldData.getSection().getId()); 288 sectionRepository.autoCopy(versions, (int)sectionCode, oldData.getSection().getId());
289 Section section = sectionRepository.findById((int)sectionCode).get(); 289 Section section = sectionRepository.findById((int)sectionCode).get();
@@ -311,7 +311,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -311,7 +311,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
311 311
312 Station newStation = stationRepository.findById(stationList.get(i).getStation().getId()).get(); 312 Station newStation = stationRepository.findById(stationList.get(i).getStation().getId()).get();
313 Station oldStation = new Station(); 313 Station oldStation = new Station();
314 - long stationCode = GetUIDAndCode.getStationId(); 314 + long stationCode = stationRepository.stationMaxId() + 1;
315 oldStation.setStationCod(String.valueOf(stationCode)); 315 oldStation.setStationCod(String.valueOf(stationCode));
316 oldStation.setId((int)stationCode); 316 oldStation.setId((int)stationCode);
317 oldStation.setAddr(newStation.getAddr()); 317 oldStation.setAddr(newStation.getAddr());
src/main/java/com/bsth/service/impl/SectionRouteServiceImpl.java
@@ -368,7 +368,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl&lt;SectionRoute, Integ @@ -368,7 +368,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl&lt;SectionRoute, Integ
368 * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) 368 * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId()))
369 * + 1 ; 369 * + 1 ;
370 */ 370 */
371 - long sectionMaxId = GetUIDAndCode.getSectionId(); 371 + long sectionMaxId = repository2.sectionMaxId() + 1;
372 String sectionCode = String.valueOf(sectionMaxId); 372 String sectionCode = String.valueOf(sectionMaxId);
373 int sectionId = (int) sectionMaxId; 373 int sectionId = (int) sectionMaxId;
374 String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString(); 374 String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString();
@@ -423,7 +423,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl&lt;SectionRoute, Integ @@ -423,7 +423,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl&lt;SectionRoute, Integ
423 * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) 423 * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId()))
424 * + 1 ; 424 * + 1 ;
425 */ 425 */
426 - long sectionMaxId = GetUIDAndCode.getSectionId(); 426 + long sectionMaxId = repository2.sectionMaxId() + 1;
427 String sectionCode = String.valueOf(sectionMaxId); 427 String sectionCode = String.valueOf(sectionMaxId);
428 int sectionId = (int) sectionMaxId; 428 int sectionId = (int) sectionMaxId;
429 String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString(); 429 String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString();
src/main/java/com/bsth/service/impl/SectionServiceImpl.java
@@ -152,7 +152,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem @@ -152,7 +152,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem
152 routeRepository.sectionRouteUpdDestroy(sectionRouteLine,directions); 152 routeRepository.sectionRouteUpdDestroy(sectionRouteLine,directions);
153 // 路段保存 153 // 路段保存
154 for (int i = 0; i < sectionArrayList.size(); i++) { 154 for (int i = 0; i < sectionArrayList.size(); i++) {
155 - long sectionMaxId = GetUIDAndCode.getSectionId(); 155 + long sectionMaxId = repository.sectionMaxId() + 1;
156 // 路段编码 156 // 路段编码
157 String sectionCode = String.valueOf(sectionMaxId); 157 String sectionCode = String.valueOf(sectionMaxId);
158 // 路段ID 158 // 路段ID
@@ -286,7 +286,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem @@ -286,7 +286,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem
286 lsRouteRepository.batchDelete(sectionRouteLine,directions,versions); 286 lsRouteRepository.batchDelete(sectionRouteLine,directions,versions);
287 // 路段保存 287 // 路段保存
288 for (int i = 0; i < sectionArrayList.size(); i++) { 288 for (int i = 0; i < sectionArrayList.size(); i++) {
289 - long sectionMaxId = GetUIDAndCode.getSectionId(); 289 + long sectionMaxId = repository.sectionMaxId() + 1;
290 // 路段编码 290 // 路段编码
291 String sectionCode = String.valueOf(sectionMaxId); 291 String sectionCode = String.valueOf(sectionMaxId);
292 // 路段ID 292 // 路段ID
@@ -437,7 +437,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem @@ -437,7 +437,7 @@ public class SectionServiceImpl extends BaseServiceImpl&lt;Section, Integer&gt; implem
437 } 437 }
438 } 438 }
439 // 获取当前最大Id 439 // 获取当前最大Id
440 - long sectionMaxId = GetUIDAndCode.getSectionId(); 440 + long sectionMaxId = repository.sectionMaxId() + 1;
441 // 路段编码 441 // 路段编码
442 String sectionCode = String.valueOf(sectionMaxId); 442 String sectionCode = String.valueOf(sectionMaxId);
443 // 路段ID 443 // 路段ID
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
@@ -578,7 +578,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -578,7 +578,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
578 Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); 578 Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString());
579 Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); 579 Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString());
580 Integer stationRouteCode = map.get("stationRouteCode").equals("") ? null : Integer.parseInt(map.get("stationRouteCode").toString()); 580 Integer stationRouteCode = map.get("stationRouteCode").equals("") ? null : Integer.parseInt(map.get("stationRouteCode").toString());
581 - List<Object[]> objects = repository.findDownStationRoute(lineId, direction, stationRouteCode); 581 + Integer version = map.get("version").equals("") ? null : Integer.parseInt(map.get("version").toString());
  582 + List<Object[]> objects = repository.findDownStationRoute(lineId, direction, stationRouteCode,version);
582 List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); 583 List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
583 584
584 int len = objects.size(); 585 int len = objects.size();
src/main/java/com/bsth/service/impl/StationServiceImpl.java
@@ -324,7 +324,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -324,7 +324,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
324 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); 324 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
325 Station station = stationlist.get(0); 325 Station station = stationlist.get(0);
326 // 站点编码 326 // 站点编码
327 - long stationCode = GetUIDAndCode.getStationId(); 327 + long stationCode = repository.stationMaxId() + 1;
328 station.setStationCod(String.valueOf(stationCode)); 328 station.setStationCod(String.valueOf(stationCode));
329 station.setId((int) stationCode); 329 station.setId((int) stationCode);
330 station.setCreateDate(null); 330 station.setCreateDate(null);
@@ -339,7 +339,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -339,7 +339,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
339 } 339 }
340 } else { 340 } else {
341 // 站点编码 341 // 站点编码
342 - long stationCode = GetUIDAndCode.getStationId(); 342 + long stationCode = repository.stationMaxId() + 1 ;
343 arg0.setStationCod(String.valueOf(stationCode)); 343 arg0.setStationCod(String.valueOf(stationCode));
344 arg0.setId((int) stationCode); 344 arg0.setId((int) stationCode);
345 arg0.setStationName(stationName); 345 arg0.setStationName(stationName);
@@ -689,7 +689,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -689,7 +689,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
689 689
690 } 690 }
691 691
692 - long sectionMaxId = GetUIDAndCode.getSectionId(); 692 + long sectionMaxId = sectionRepository.sectionMaxId() + 1;
693 693
694 String sectionCode = String.valueOf(sectionMaxId); 694 String sectionCode = String.valueOf(sectionMaxId);
695 695
@@ -1493,7 +1493,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1493,7 +1493,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1493 } 1493 }
1494 } 1494 }
1495 } 1495 }
1496 - long sectionMaxId = GetUIDAndCode.getSectionId(); 1496 + long sectionMaxId = sectionRepository.sectionMaxId() + 1;
1497 String sectionCode = String.valueOf(sectionMaxId); 1497 String sectionCode = String.valueOf(sectionMaxId);
1498 int sectionId = (int) (sectionMaxId); 1498 int sectionId = (int) (sectionMaxId);
1499 // 交出路 1499 // 交出路
@@ -1745,7 +1745,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1745,7 +1745,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1745 // 初始化站点对象 1745 // 初始化站点对象
1746 Station arg0 = new Station(); 1746 Station arg0 = new Station();
1747 // 站点编码 1747 // 站点编码
1748 - long stationCode = GetUIDAndCode.getStationId(); 1748 + long stationCode = repository.stationMaxId() + 1;
1749 arg0.setStationCod(String.valueOf(stationCode)); 1749 arg0.setStationCod(String.valueOf(stationCode));
1750 arg0.setId((int) stationCode); 1750 arg0.setId((int) stationCode);
1751 // 存在的点就不添加到数据库(起终点站重新添加站点) 1751 // 存在的点就不添加到数据库(起终点站重新添加站点)
@@ -1981,7 +1981,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1981,7 +1981,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1981 } 1981 }
1982 } 1982 }
1983 } 1983 }
1984 - long sectionMaxId = GetUIDAndCode.getSectionId(); 1984 + long sectionMaxId = sectionRepository.sectionMaxId() + 1;
1985 String sectionCode = String.valueOf(sectionMaxId); 1985 String sectionCode = String.valueOf(sectionMaxId);
1986 int sectionId = (int) (sectionMaxId); 1986 int sectionId = (int) (sectionMaxId);
1987 // 交出路 1987 // 交出路
src/main/java/com/bsth/util/GetUIDAndCode.java
1 -package com.bsth.util;  
2 -  
3 -import java.util.Timer;  
4 -import java.util.TimerTask;  
5 -  
6 -import org.springframework.beans.factory.annotation.Autowired;  
7 -import org.springframework.stereotype.Component;  
8 -  
9 -import com.bsth.repository.CarParkRepository;  
10 -import com.bsth.repository.LineRepository;  
11 -import com.bsth.repository.SectionRepository;  
12 -import com.bsth.repository.StationRepository;  
13 -  
14 -/**  
15 - *  
16 - * @ClassName: GetUIDAndCode(自定义ID)  
17 - *  
18 - * @Description: TODO(自定义ID)  
19 - *  
20 - * @Author bsth@lq  
21 - *  
22 - * @Date 2016年4月28日 上午9:21:17  
23 - *  
24 - * @Version 公交调度系统BS版 0.1  
25 - *  
26 - */  
27 -@Component  
28 -public class GetUIDAndCode {  
29 - @Autowired  
30 - private LineRepository lineRepository;  
31 - @Autowired  
32 - private StationRepository stationRepository;  
33 - @Autowired  
34 - private SectionRepository sectionRepository;  
35 - @Autowired  
36 - private CarParkRepository carParkRepository;  
37 - /** 线路ID */  
38 - private static long lineId = 0L;  
39 - /** 站点ID */  
40 - private static long stationId = 0L;  
41 - /** 路段ID */  
42 - private static long sectionId = 0L;  
43 - /** 停车长ID*/  
44 - private static long carParkId = 0L;  
45 - public GetUIDAndCode() {  
46 - new Timer().schedule(new TimerTask() {  
47 - @Override  
48 - public void run() {  
49 - lineId = lineRepository.selectMaxIdToLineCode();  
50 - stationId = stationRepository.stationMaxId();  
51 - sectionId = sectionRepository.sectionMaxId();  
52 - carParkId = carParkRepository.carParkMaxId();  
53 - }  
54 - }, 1000 * 30);  
55 - }  
56 - public static synchronized long getLineId() {  
57 - ++lineId;  
58 - return lineId;  
59 - }  
60 - public static synchronized long getStationId() {  
61 - ++stationId;  
62 - return stationId;  
63 - }  
64 - public static synchronized long getSectionId() {  
65 - ++sectionId;  
66 - return sectionId;  
67 - }  
68 - public static synchronized long getCarParkId() {  
69 - ++carParkId;  
70 - return carParkId;  
71 - } 1 +package com.bsth.util;
  2 +
  3 +import java.util.Timer;
  4 +import java.util.TimerTask;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import com.bsth.repository.CarParkRepository;
  10 +import com.bsth.repository.LineRepository;
  11 +import com.bsth.repository.SectionRepository;
  12 +import com.bsth.repository.StationRepository;
  13 +
  14 +/**
  15 + *
  16 + * @ClassName: GetUIDAndCode(自定义ID)
  17 + *
  18 + * @Description: TODO(自定义ID)
  19 + *
  20 + * @Author bsth@lq
  21 + *
  22 + * @Date 2016年4月28日 上午9:21:17
  23 + *
  24 + * @Version 公交调度系统BS版 0.1
  25 + *
  26 + */
  27 +@Component
  28 +public class GetUIDAndCode {
  29 + @Autowired
  30 + private LineRepository lineRepository;
  31 + @Autowired
  32 + private StationRepository stationRepository;
  33 + @Autowired
  34 + private SectionRepository sectionRepository;
  35 + @Autowired
  36 + private CarParkRepository carParkRepository;
  37 + /** 线路ID */
  38 + private static long lineId = 0L;
  39 + /** 站点ID */
  40 + private static long stationId = 0L;
  41 + /** 路段ID */
  42 + private static long sectionId = 0L;
  43 + /** 停车长ID*/
  44 + private static long carParkId = 0L;
  45 +
  46 + public GetUIDAndCode() {
  47 +// new Timer().schedule(new TimerTask() {
  48 +// @Override
  49 +// public void run() {
  50 +// lineId = lineRepository.selectMaxIdToLineCode();
  51 +// stationId = stationRepository.stationMaxId();
  52 +// sectionId = sectionRepository.sectionMaxId();
  53 +// carParkId = carParkRepository.carParkMaxId();
  54 +// }
  55 +// }, 1000 * 30);
  56 + }
  57 + public synchronized long getLineId() {
  58 + return lineRepository.selectMaxIdToLineCode() + 1;
  59 + }
  60 + public synchronized long getStationId() {
  61 + return stationRepository.stationMaxId() + 1;
  62 + }
  63 + public synchronized long getSectionId() {
  64 + return sectionRepository.sectionMaxId() + 1;
  65 + }
  66 + public synchronized long getCarParkId() {
  67 + return carParkRepository.carParkMaxId() + 1;
  68 + }
72 } 69 }
73 \ No newline at end of file 70 \ No newline at end of file
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
1 -/**  
2 - * 百度地图  
3 - *  
4 - * - - - - - -》init:地图初始化  
5 - *  
6 - * - - - - - -》lineInfoPanl:从百度地图抓去站点与路段数据  
7 - *  
8 - * - - - - - -》getDistanceAndDuration:获取距离与时间  
9 - *  
10 - * - - - - - -》pointsPolygon:地图画多边行  
11 - *  
12 - * - - - - - -》pointsCircle:画圆  
13 - *  
14 - * - - - - - -》localSearchFromAdreesToPoint:根据地理名称获取百度经纬度坐标  
15 - *  
16 - * - - - - - -》drawingUpline:在地图上画出上行线路走向  
17 - *  
18 - * - - - - - -》stationsNameToPoints:站点名称获取百度坐标(手动规划)  
19 - *  
20 - * - - - - - -》getDistanceAndTotime:根据坐标点获取两点之间的时间与距离(手动规划)  
21 - *  
22 - * - - - - - -》getSectionListPlonly:根据坐标点获取两点之间的折线路段(手动规划)  
23 - */  
24 -  
25 -window.WorldsBMap = function () {  
26 -  
27 - /** WorldsBMap 全局变量定义 mapBValue:地图对象; road_win_show_p:信息窗口打开状态的路段,  
28 - * sectionArray: 路段集合,stationArray: 站点集合  
29 - * map_status:地图编辑状态,drawingManager:绘画工具, topOverlay:置顶视图*/  
30 - var mapBValue = '', iseditStatus = false, road_win_show_p = '', editPolyline = '', matchStation = '',dir = 0,  
31 - sectionArray = [], stationArray = new Map(),  
32 - map_status = 0,drawingManager,topOverlay;  
33 -  
34 - /**  
35 - * 编辑缓冲区  
36 - * stationMarkers: 站点图标集合  
37 - */  
38 - var editCircle, editPolygon, dragMarker, stationMarkers = new Map(),centerPoint;  
39 -  
40 - var styleOptions = {  
41 - strokeColor:"blue", //边线颜色。  
42 - fillColor:"blue", //填充颜色。当参数为空时,圆形将没有填充效果。  
43 - strokeWeight: 6, //边线的宽度,以像素为单位。  
44 - strokeOpacity: 0.7, //边线透明度,取值范围0 - 1。  
45 - fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。  
46 - strokeStyle: 'solid' //边线的样式,solid或dashed。  
47 - };  
48 -  
49 - // 覆盖物置顶  
50 - var setTop = function(overlay) {  
51 - if (topOverlay)  
52 - topOverlay.setTop(false);  
53 - overlay.setTop(true);  
54 - topOverlay = overlay;  
55 - };  
56 -  
57 - var setDragMarker = function (marker) {  
58 - marker.enableDragging();  
59 - dragMarker = marker;  
60 - dragMarker._old_point = dragMarker._position;  
61 - centerPoint = dragMarker._position;  
62 - //监听拖拽事件 dragging  
63 - dragMarker.addEventListener('dragging', dragMarkerDragEvent);  
64 - };  
65 -  
66 - var dragMarkerDragEvent = function (e) {  
67 - if (editPolygon) {  
68 - // 中心点是否超出多边形  
69 - // if (!BMapLib.GeoUtils.isPointInPolygon(e.target._position, editPolygon)) {  
70 - // dragMarker.setPosition(dragMarker._old_point);//还原位置  
71 - // }  
72 - centerPoint = e.target._position;  
73 - }  
74 - else if (editCircle) {  
75 - editCircle.disableEditing();  
76 - //缓冲区跟随点位运动  
77 - editCircle.setCenter(e.target._position);  
78 - editCircle.enableEditing();  
79 - centerPoint = e.target._position;  
80 - }  
81 - };  
82 -  
83 - var Bmap = {  
84 -  
85 - init: function () {  
86 - // 设置中心点,  
87 - var CENTER_POINT = {lng: 121.528733, lat: 31.237425};  
88 - // 百度API Key  
89 - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT';  
90 - // 初始化百度地图  
91 - mapBValue = new BMap.Map("bmap_basic" , {enableMapClick: false});  
92 - //中心点和缩放级别  
93 - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng, CENTER_POINT.lat), 14);  
94 - //启用地图拖拽事件,默认启用(可不写)  
95 - mapBValue.enableDragging();  
96 - //启用地图滚轮放大缩小  
97 - mapBValue.enableScrollWheelZoom();  
98 - //禁用鼠标双击放大  
99 - mapBValue.disableDoubleClickZoom();  
100 - //启用键盘上下左右键移动地图  
101 - mapBValue.enableKeyboard();  
102 - return mapBValue;  
103 - },  
104 -  
105 - /** 获取地图对象 @return 地图对象map */  
106 - getmapBValue: function () {  
107 - return mapBValue;  
108 - },  
109 - getDir:function(){  
110 - return dir;  
111 - },  
112 - setDir:function (dirx) {  
113 - dir = dirx;  
114 - },  
115 - setMap_status : function (i) {  
116 - map_status = i;  
117 - },  
118 - getIsEditStatus: function () {  
119 - return iseditStatus;  
120 - },  
121 - setIsEditStatus: function (v) {  
122 - iseditStatus = v;  
123 - },  
124 - getStationArray: function () {  
125 - return stationArray;  
126 - },  
127 - setStationArray : function (s) {  
128 - stationArray = s;  
129 - },  
130 - /*initDrawingManager: function (map, styleOptions) {  
131 - },*/  
132 - getDrawingManagerObj: function () {  
133 - return drawingManagerInitV;  
134 - },  
135 -  
136 - // 从百度地图抓去站点与路段数据  
137 - lineInfoPanl: function (lineNameValue, i, cb) {  
138 -  
139 - /** 根据线路名称与方向从百度地图获取站点与路段 @param lineNameValue:线路名称;i:方向<0:上行;1:下行> */  
140 - WorldsBMap.getBmapStationNames(lineNameValue, i, function (BusLine) {  
141 -  
142 - return cb && cb(BusLine);  
143 -  
144 - });  
145 -  
146 - },  
147 -  
148 - /** 获取距离与时间 @param <points:坐标点集合> */  
149 - getDistanceAndDuration: function (points, callback) {  
150 - // 获取长度  
151 - var len = points.length;  
152 - (function () {  
153 - if (!arguments.callee.count) {  
154 - arguments.callee.count = 0;  
155 - }  
156 - arguments.callee.count++;  
157 - var index = parseInt(arguments.callee.count) - 1;  
158 - if (index >= len - 1) {  
159 - callback && callback(points);  
160 - return;  
161 - }  
162 - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。)  
163 - var f = arguments.callee;  
164 - // 起点坐标 <坐标格式:40.056878,116.30815>  
165 - var origin = points[index].potion.lat + ',' + points[index].potion.lng;  
166 - // 终点坐标 <坐标格式:40.056878,116.30815>  
167 - var destination = points[index + 1].potion.lat + ',' + points[index + 1].potion.lng;  
168 - var region = '上海';  
169 - var origin_region = '上海';  
170 - var destination_region = '上海';  
171 - var output = 'json';  
172 - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk';  
173 - /**  
174 - * origin:起点名称或经纬度;  
175 - * destination:终点名称或经纬度;  
176 - * origin_region:起始点所在城市,驾车导航时必填。  
177 - * destination_region:终点所在城市,驾车导航时必填。  
178 - * output :表示输出类型,可设置为xml或json,默认为xml。  
179 - **/  
180 - var paramsB = {  
181 - origin: origin,  
182 - destination: destination,  
183 - region: region,  
184 - origin_region: origin_region,  
185 - destination_region: destination_region,  
186 - output: output,  
187 - ak: ak_My  
188 - };  
189 -  
190 - /** @description :未认证开发者默认配额为:2000次/天。 */  
191 - $.ajax({  
192 - // 百度地图根据坐标获取两点之间的时间与距离  
193 - url: 'http://api.map.baidu.com/direction/v1?mode=transit',  
194 - data: paramsB,  
195 - dataType: 'jsonp',  
196 - success: function (r) {  
197 - if (r) {  
198 - if (r.message == 'ok') {  
199 - if (r.result.taxi == null) {  
200 - // 获取距离(单位:米)  
201 - points[index + 1].distance = 0;  
202 - // 获取时间(单位:秒)  
203 - points[index + 1].duration = 0;  
204 - } else {  
205 - // 获取距离(单位:米)  
206 - points[index + 1].distance = r.result.taxi.distance;  
207 - // 获取时间(单位:秒)  
208 - points[index + 1].duration = r.result.taxi.duration;  
209 - }  
210 - }  
211 - }  
212 - f();  
213 - }  
214 - });  
215 - })();  
216 - },  
217 -  
218 - // 打开站点信息窗口  
219 - openStationInfoWin : function (objStation) {  
220 - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)  
221 - if (objStation) {  
222 - // 站点形状  
223 - var shapes = objStation.stationShapesType;  
224 - // 获取中心坐标点字符串分割  
225 - var BJwpoints = objStation.stationJwpoints.split(' ');  
226 - // 中心坐标点  
227 - var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);  
228 - var width = WorldsBMap.strGetLength(objStation.stationRouteName) * 11;  
229 - // 信息窗口参数属性  
230 - var opts = {  
231 - // 信息窗口宽度  
232 - width: (width < 240 ? 240 : width),  
233 - // 信息窗口高度  
234 - // height: shapes=="r" ?380:350,  
235 - // 信息窗位置偏移值。  
236 - offset: new BMap.Size(10,-20),  
237 - //设置不允许信窗发送短息  
238 - enableMessage: false,  
239 - //是否开启点击地图关闭信息窗口  
240 - enableCloseOnClick: false,  
241 - // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)  
242 - enableAutoPan: false  
243 - };  
244 -  
245 - var markTypeStr = '';  
246 - if (objStation.stationRouteStationMark == 'B') {  
247 - markTypeStr = '起点站';  
248 - } else if (objStation.stationRouteStationMark == 'Z') {  
249 - markTypeStr = '中途站';  
250 - } else if (objStation.stationRouteStationMark == 'E') {  
251 - markTypeStr = '终点站';  
252 - }  
253 - var htm = '<span style="color: #ff8355;font-size: 20px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis;display: -webkit-box; -webkit-box-orient: vertical;">' + objStation.stationRouteName + '</span>' +  
254 - '<span class="help-block" >站点编码:' + objStation.stationCode + '</span>' +  
255 - '<span class="help-block" >行业编号:' + (objStation.industryCode == null ? "":objStation.industryCode)+ '</span>' +  
256 - '<span class="help-block" >站点序号:' + objStation.stationRouteCode + '</span>' +  
257 - '<span class="help-block" >站点类型:' + markTypeStr + '</span>' +  
258 - '<span class="help-block" >经度:&nbsp&nbsp' + BJwpoints[0] + '</span>' +  
259 - '<span class="help-block" >纬度:&nbsp&nbsp' + BJwpoints[1] + '</span>' +  
260 - '<span class="help-block" >到站时间:' + objStation.stationRouteToTime + '&nbsp;分钟</span>' +  
261 - '<span class="help-block" >到站距离:' + objStation.stationRouteDistances + '&nbsp;公里</span>' +  
262 - '<span class="help-block" >缓冲区形状:' + (shapes == "r" ? "圆形" : "多边形") + '</span>' +  
263 - (shapes=="r" ? ("<span class='help-block' >半径&nbsp&nbsp:" + objStation.stationRadius + "</span>") : " ")+  
264 - '<span class="help-block" >版本号&nbsp&nbsp:' + objStation.stationRouteVersions + '</span>';  
265 -  
266 - if($($("#versions").find("option:selected")[0]).attr("status") > 0){  
267 - htm += '<div>' +  
268 - '<button class="info_win_btn" id="editStation" onclick="WorldsBMap.editStation(' + objStation.stationRouteId+','+objStation.stationRoutedirections + ')">修改</button>' +  
269 - '<button class="info_win_btn" onclick="WorldsBMap.destroyStation('+ objStation.stationRouteId + ','+objStation.stationRouteLine+','+objStation.stationRoutedirections+')">撤销</button>' +  
270 - '<button class="info_win_btn" id="addBetweenStationRoad" onclick="WorldsBMap.addBetweenStationRoad(' + objStation.stationRouteId + ')">添加站点间路段</button>' +  
271 - '<button class="info_win_btn" id="editIndustryCode" onclick="WorldsBMap.editIndustryCode(' + objStation.stationRouteId + ')">匹配周边站点行业编码</button>' +  
272 - '</div>';  
273 - }  
274 - // 创建信息窗口  
275 - var infoWindow_target = new BMap.InfoWindow(htm, opts);  
276 - setTimeout(function () {  
277 - //开启信息窗口  
278 - mapBValue.openInfoWindow(infoWindow_target, point);  
279 - }, 100);  
280 - // 将地图的中心点更改为给定的点。  
281 - mapBValue.panTo(point);  
282 - }  
283 - },  
284 -  
285 - // 打开匹配博协站点信息窗口  
286 - openMatchStationInfoWin : function (objStation) {  
287 - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)  
288 - if (objStation) {  
289 - matchStation = objStation;  
290 - // 获取中心坐标点字符串分割  
291 - var BJwpoints = objStation.bJwpoints.split(' ');  
292 - // 中心坐标点  
293 - var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);  
294 - var width = WorldsBMap.strGetLength(objStation.stationName) * 11;  
295 - // 信息窗口参数属性  
296 - var opts = {  
297 - // 信息窗口宽度  
298 - width: (width < 240 ? 240 : width),  
299 - // 信息窗口高度  
300 - // height: shapes=="r" ?380:350,  
301 - // 信息窗位置偏移值。  
302 - offset: new BMap.Size(10,-20),  
303 - //设置不允许信窗发送短息  
304 - enableMessage: false,  
305 - //是否开启点击地图关闭信息窗口  
306 - enableCloseOnClick: false,  
307 - // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)  
308 - enableAutoPan: false  
309 - };  
310 -  
311 - var htm = '<span style="color: #ff8355;font-size: 20px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis;display: -webkit-box; -webkit-box-orient: vertical;">' + objStation.stationName + '</span>' +  
312 - '<span class="help-block" >行业编号:' + (objStation.stationStandardCode == null ? "":objStation.stationStandardCode)+ '</span>' +  
313 - '<span class="help-block" >经过线路:' + objStation.lineList + '</span>' +  
314 - // '<div>' + '<button class="info_win_btn" onclick="WorldsBMap.citeIndustryCode(' + objStation + ')">应用此站点行业编码</button>' +  
315 - '<div>' + '<button class="info_win_btn" onclick="WorldsBMap.citeIndustryCode(' + objStation.stationRouteId + ')">应用此站点行业编码</button>' +  
316 - '</div>';  
317 -  
318 - // 创建信息窗口  
319 - var infoWindow_target = new BMap.InfoWindow(htm, opts);  
320 - setTimeout(function () {  
321 - //开启信息窗口  
322 - mapBValue.openInfoWindow(infoWindow_target, point);  
323 - }, 100);  
324 - // 将地图的中心点更改为给定的点。  
325 - mapBValue.panTo(point);  
326 - }  
327 - },  
328 -  
329 - // 根据地理名称获取百度经纬度坐标  
330 - localSearchFromAdreesToPoint: function (Address, callback) {  
331 - // 创建一个搜索类实例  
332 - var localSearch = new BMap.LocalSearch(mapBValue);  
333 - // 检索完成后的回调函数。  
334 - localSearch.setSearchCompleteCallback(function (searchResult) {  
335 - var resultPoints = '';  
336 - if (searchResult) {  
337 - // 返回索引指定的结果。索引0表示第1条结果  
338 - var poi = searchResult.getPoi(0);  
339 - if (poi) {  
340 - //获取经度和纬度  
341 - resultPoints = poi.point.lng + ' ' + poi.point.lat;  
342 - callback && callback(resultPoints);  
343 - } else {  
344 - callback && callback(false);  
345 - }  
346 - } else {  
347 - callback && callback(false);  
348 - }  
349 - });  
350 - // 根据检索词发起检索。  
351 - localSearch.search(Address);  
352 - },  
353 -  
354 - // 站点编辑  
355 - editShapes: function (obj) {  
356 - // 关闭信息窗口  
357 - mapBValue.closeInfoWindow();  
358 - // 清除marker  
359 - // mapBValue.removeOverlay(marker);  
360 - var station = obj.getEitdStation();  
361 - var stationShapesTypeV = station.stationShapesType;  
362 - setDragMarker(stationMarkers[station.stationRouteId]);  
363 - // 编辑圆  
364 - if (stationShapesTypeV == 'r') {  
365 - // 获取中心坐标点字符串分割  
366 - var BJwpoints = station.stationJwpoints.split(' ');  
367 - // 中心坐标点  
368 - var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);  
369 - //创建圆  
370 - var circle = new BMap.Circle(point, station.stationRadius, {  
371 - strokeColor: "blue",  
372 - strokeWeight: 2,  
373 - strokeOpacity: 0.7  
374 - });  
375 - mapBValue.centerAndZoom(point, 18);  
376 - editCircle = circle;  
377 - // 允许覆盖物在map.clearOverlays方法中被清除  
378 - // circle.enableMassClear();  
379 - // 百度地图添加覆盖物圆  
380 - mapBValue.addOverlay(circle);  
381 - // 开启编辑功能  
382 - circle.enableEditing();  
383 - // 编辑圆监听事件  
384 - circle.addEventListener('dblclick', function () {  
385 - // 返回圆形的半径,单位为米。  
386 - var newRadius = circle.getRadius();  
387 - // 返回圆形的中心点坐标。  
388 - var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat;  
389 - // var centre_points = [{potion: {lng: circle.getCenter().lng, lat: circle.getCenter().lat}}];  
390 - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */  
391 - EditStationObj.setEitdStationJwpoints(newCenter);  
392 - /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */  
393 - EditStationObj.setEitdStationShapesType('r');  
394 - /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */  
395 - EditStationObj.setEitdStationRadius(Math.round(newRadius));  
396 - /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */  
397 - EditStationObj.setEitdBPolygonGrid('');  
398 - // 清除正在编辑的站点  
399 - editCircle = null;  
400 - // 加载编辑页面  
401 - $.get('edit.html', function (m) {  
402 - $(pjaxContainer).append(m);  
403 - $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]);  
404 - });  
405 - });  
406 - // 编辑多边行  
407 - } else if (stationShapesTypeV == 'd') {  
408 - // 获取中心点坐标字符串  
409 - var testpointStr = station.stationJwpoints;  
410 - // 按空格切割中心点坐标字符串  
411 - var BJwpointsPolygon = testpointStr.split(' ');  
412 - // 中心点坐标  
413 - var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]);  
414 - // 获取多边形坐标字符串  
415 - var stationBPolygonGrid = station.stationBPolyonGrid;  
416 - // 截取多边形坐标字符串  
417 - var stationBPolygonGridStr = stationBPolygonGrid.substring(9, stationBPolygonGrid.length - 2);  
418 - // 按逗号切割  
419 - var pointPolygonArray = stationBPolygonGridStr.split(',');  
420 - // 多边形坐标集合  
421 - var polygonP = [];  
422 - for (var v = 0; v < pointPolygonArray.length; v++) {  
423 - polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0], pointPolygonArray[v].split(" ")[1]));  
424 - }  
425 - // 画多边形  
426 - var polygon = new BMap.Polygon(polygonP, {  
427 - // 线条显色  
428 - strokeColor: "blue",  
429 - // 边线的宽度,以像素为单位。  
430 - strokeWeight: 2,  
431 - // 边线透明度,取值范围0 - 1。  
432 - strokeOpacity: 0.7  
433 - });  
434 - mapBValue.centerAndZoom(pointPolygon, 18);  
435 - editPolygon = polygon;  
436 - // 增加地图覆盖物多边形  
437 - mapBValue.addOverlay(polygon);  
438 - // 开启编辑功能(自 1.1 新增)  
439 - polygon.enableEditing();  
440 - //禁止覆盖物在map.clearOverlays方法中被清除  
441 - // polygon.disableMassClear();  
442 - // 添加多边形编辑事件  
443 - polygon.addEventListener('dblclick', function (e) {  
444 - // 获取编辑的多边形对象  
445 - var edit_pointE = polygon;  
446 - var edit_bPloygonGrid = "";  
447 - var editPolyGonLen_ = edit_pointE.getPath().length;  
448 - for (var k = 0; k < editPolyGonLen_; k++) {  
449 - if (k == 0) {  
450 - edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat;  
451 - } else {  
452 - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat;  
453 - }  
454 - }  
455 - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat;  
456 - // 多边形中心点  
457 - // var centre = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat;  
458 - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) centerPoint可拖动点 */  
459 - EditStationObj.setEitdStationJwpoints(centerPoint.lng+' '+centerPoint.lat);  
460 - /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */  
461 - EditStationObj.setEitdStationShapesType('d');  
462 - /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */  
463 - EditStationObj.setEitdStationRadius('');  
464 - /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */  
465 - EditStationObj.setEitdBPolygonGrid(edit_bPloygonGrid);  
466 - // 清除正在编辑的站点  
467 - editPolygon = null;  
468 - $.get('edit.html', function (m) {  
469 - $(pjaxContainer).append(m);  
470 - $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]);  
471 - });  
472 - });  
473 - }  
474 - },  
475 -  
476 - // 画路段走向  
477 - drawingUpline01: function (datas) {  
478 - // drawingUpline01: function (polyline_center, datas) {  
479 - if (datas) {  
480 - // if (polyline_center && datas) {  
481 - // 编辑路段数据  
482 - sectionArray = [];  
483 - for (var d = 0; d < datas.length; d++) {  
484 - var data = datas[d];  
485 - // 地图折线坐标点集合  
486 - var polylineArray = [];  
487 - // 获取路段折线坐标字符串  
488 - var sectionBsectionVectorStr = data.sectionBsectionVector;  
489 - if (sectionBsectionVectorStr == null)  
490 - continue;  
491 - // 切割段折线坐标字符串  
492 - var tempStr = sectionBsectionVectorStr.substring(11, sectionBsectionVectorStr.length - 1);  
493 - // 分割折线坐标字符串  
494 - var lineArray = tempStr.split(',');  
495 - for (var i = 0; i < lineArray.length; i++) {  
496 - polylineArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1]));  
497 - }  
498 - var polyUpline01 = 'polyline' + '_' + data.sectionrouteId;  
499 - // 创建线路走向  
500 - polyUpline01 = new BMap.Polyline(polylineArray, {  
501 - strokeColor: "red",  
502 - strokeWeight: 6,  
503 - strokeOpacity: 0.7  
504 - });  
505 - polyUpline01.data = data;  
506 - polyUpline01.ct_source = '1';  
507 - // 把折线添加到地图上  
508 - mapBValue.addOverlay(polyUpline01);  
509 - // 聚焦事件  
510 - polyUpline01.addEventListener('mousemove', function (e) {  
511 - if (this != editPolyline)  
512 - this.setStrokeColor("#20bd26");  
513 - });  
514 - // 失去焦点  
515 - polyUpline01.addEventListener('mouseout', function (e) {  
516 - if (this != editPolyline && this != road_win_show_p)  
517 - this.setStrokeColor("red");  
518 - });  
519 - // 添加单击事件  
520 - polyUpline01.addEventListener('onclick', function (e) {  
521 - // 打开信息窗口  
522 - if (map_status != 1)  
523 - WorldsBMap.openSectionInfoWin(this);  
524 - });  
525 - sectionArray.push(polyUpline01);  
526 - }  
527 - // mapBValue.setCenter(polyline_center);  
528 - // mapBValue.panTo(polyline_center);  
529 - // mapBValue.setZoom(14);  
530 - // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增)  
531 - // polyUpline01.disableMassClear();  
532 - }  
533 - },  
534 -  
535 - /** 在地图上画点 @param:<point_center:中心坐标点> */  
536 - drawingUpStationPoint: function (station, s) {  
537 - // 中心点坐标字符串  
538 - var bJwpointsStr = station.stationJwpoints;  
539 - var stationName = station.stationRouteName;  
540 - // 起个中心点坐标字符串  
541 - var bJwpointsArray = bJwpointsStr.split(' ');  
542 - // 设置中心点  
543 - var point_center = new BMap.Point(bJwpointsArray[0],bJwpointsArray[1]);  
544 - // 自定义标注物图片  
545 - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png', new BMap.Size(10, 10));  
546 -  
547 - var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">'  
548 - + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">'  
549 - + '</div>'  
550 - + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">' + s + '</span>' + stationName + '</label>';  
551 -  
552 - var myRichMarker1 = new BMapLib.RichMarker(html2, point_center, {  
553 - "title": stationName,  
554 - "anchor": new BMap.Size(-10, 8),  
555 - "enableDragging": true  
556 - });  
557 - myRichMarker1.disableDragging();  
558 - myRichMarker1.ct_source = '1';  
559 - mapBValue.addOverlay(myRichMarker1);  
560 - myRichMarker1.addEventListener('click', function () {  
561 - if(map_status != 1)  
562 - WorldsBMap.openStationInfoWin(station);  
563 - });  
564 - stationArray[station.stationRouteId] = station;  
565 - stationMarkers[station.stationRouteId] = myRichMarker1;  
566 - },  
567 -  
568 - // 站点名称获取百度坐标(手动规划)  
569 - stationsNameToPoints: function (arra, callback) {  
570 - // 获取长度  
571 - var len = arra.length;  
572 - var stationList = [];  
573 - (function () {  
574 - if (!arguments.callee.count) {  
575 - arguments.callee.count = 0;  
576 - }  
577 - arguments.callee.count++;  
578 - var index = parseInt(arguments.callee.count) - 1;  
579 - if (index >= len) {  
580 - callback && callback(stationList);  
581 - return;  
582 - }  
583 - var f = arguments.callee;  
584 - if (arra[index].name != '') {  
585 - var localSearch = new BMap.LocalSearch(mapBValue);  
586 - localSearch.search(arra[index].name);  
587 - localSearch.setSearchCompleteCallback(function (searchResult) {  
588 - var poi = searchResult.getPoi(0);  
589 - if (poi) {  
590 - stationList.push({  
591 - name: arra[index].name.replace('公交车站', ''),  
592 - wgs: arra[index].wgs,  
593 - potion: {lng: poi.point.lng, lat: poi.point.lat}  
594 - });  
595 - } else {  
596 - stationList.push({  
597 - name: arra[index].name.replace('公交车站', ''),  
598 - wgs: arra[index].wgs,  
599 - potion: {lng: arra[index].wgs.x, lat: arra[index].wgs.y}  
600 - });  
601 - }  
602 - f();  
603 - });  
604 - } else {  
605 - f();  
606 - }  
607 - })();  
608 - },  
609 -  
610 - // 根据坐标点获取两点之间的时间与距离(手动规划)  
611 - getDistanceAndTotime: function (stationList, cb) {  
612 - stationList[0].distance = '';  
613 - stationList[0].duration = '';  
614 - // var sectionList = [];  
615 - // 获取长度  
616 - var len = stationList.length;  
617 - (function () {  
618 - if (!arguments.callee.count) {  
619 - arguments.callee.count = 0;  
620 - }  
621 - arguments.callee.count++;  
622 - var index = parseInt(arguments.callee.count) - 1;  
623 - if (index >= len - 1) {  
624 - // cb && cb(stationList,sectionList);  
625 - cb && cb(stationList);  
626 - return;  
627 - }  
628 - var f = arguments.callee;  
629 - var poiOne = new BMap.Point(stationList[index].potion.lng, stationList[index].potion.lat);  
630 - var poiTwo = new BMap.Point(stationList[index + 1].potion.lng, stationList[index + 1].potion.lat);  
631 - var transit = new BMap.TransitRoute(mapBValue, {  
632 - renderOptions: {map: mapBValue},  
633 - onSearchComplete: searchComplete  
634 - });  
635 -  
636 - transit.search(poiOne, poiTwo);  
637 - function searchComplete(results) {  
638 - var plan = results.getPlan(0);  
639 - if (transit.getStatus() != BMAP_STATUS_SUCCESS) {  
640 - stationList[index + 1].distance = '';  
641 - stationList[index + 1].duration = '';  
642 - // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:''});  
643 - } else {  
644 - stationList[index + 1].distance = plan.getDistance(true);  
645 - stationList[index + 1].duration = plan.getDuration(true);  
646 - // var line = plan.getRoute(0);  
647 - // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:line.getPath()});  
648 - }  
649 - f();  
650 - }  
651 - })();  
652 - },  
653 -  
654 - // 根据坐标点获取两点之间的折线路段(手动规划)  
655 - getSectionListPlonly: function (stationsPoint, cb) {  
656 - var len = stationsPoint.length;  
657 - var sectionList = [];  
658 - (function () {  
659 - if (!arguments.callee.count) {  
660 - arguments.callee.count = 0;  
661 - }  
662 - arguments.callee.count++;  
663 - var index = parseInt(arguments.callee.count) - 1;  
664 - if (index >= len - 1) {  
665 - cb && cb(sectionList);  
666 - return;  
667 - }  
668 - var f = arguments.callee;  
669 - var poiOne = new BMap.Point(stationsPoint[index].potion.lng, stationsPoint[index].potion.lat);  
670 - var poiTwo = new BMap.Point(stationsPoint[index + 1].potion.lng, stationsPoint[index + 1].potion.lat);  
671 - /* var transit = new BMap.TransitRoute(mapB, {renderOptions: {map: mapB},onPolylinesSet: searchPolylinesSet});*/  
672 - var transit = new BMap.DrivingRoute(mapBValue, {  
673 - renderOptions: {map: mapBValue},  
674 - onPolylinesSet: searchPolylinesSet  
675 - });  
676 - function searchPolylinesSet(results) {  
677 - if (transit.getStatus() != BMAP_STATUS_SUCCESS) {  
678 - } else {  
679 - var sectionArrayList = [];  
680 - for (i = 0; i < results.length; i++) {  
681 - // console.log(results[i].getPolyline().getPath());  
682 - sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath());  
683 - }  
684 - var sectionName = stationsPoint[index].name + '至' + stationsPoint[index + 1].name;  
685 - sectionList.push({sectionName: sectionName, points: sectionArrayList});  
686 - }  
687 - f();  
688 - }  
689 - transit.search(poiOne, poiTwo);  
690 - })();  
691 - },  
692 -  
693 - localtionPoint: function (stationNameV) {  
694 - // 关闭信息窗口  
695 - mapBValue.closeInfoWindow();  
696 - WorldsBMap.localSearchFromAdreesToPoint(stationNameV, function (Points) {  
697 - if (Points) {  
698 - var BJwpointsArray = Points.split(' ');  
699 - var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]);  
700 - var marker_stargt2 = new BMap.Marker(stationNameChangePoint);  
701 - mapBValue.panTo(stationNameChangePoint);  
702 - // 将标注添加到地图中  
703 - mapBValue.addOverlay(marker_stargt2);  
704 - //跳动的动画  
705 - marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE);  
706 - }  
707 - });  
708 - },  
709 -  
710 - /** 系统规划抓去数据 @param lineNameValue:线路名称;i:方向*/  
711 - getBmapStationNames: function (lineNameValue, i, callback) {  
712 - var busline = new BMap.BusLineSearch(mapBValue, {  
713 - // 设置公交列表查询后的回调函数。参数:rs: BusListResult类型  
714 - onGetBusListComplete: function (BusListResult) {  
715 - // 如果不为空  
716 - if (BusListResult) {  
717 - //获取第一个公交列表显示到map上  
718 - var fstLine = BusListResult.getBusListItem(i);  
719 - if (fstLine == undefined) {  
720 - callback && callback(null);  
721 - }  
722 - busline.getBusLine(fstLine);  
723 - }  
724 - },  
725 - //设置公交线路查询后的回调函数.参数:rs: BusLine类型  
726 - onGetBusLineComplete: function (BusLine) {  
727 - // 如果不为空  
728 - if (BusLine) {  
729 - callback && callback(BusLine);  
730 - }  
731 - }  
732 - });  
733 - busline.getBusList(lineNameValue);  
734 - },  
735 - // 修改站点  
736 - editStation: function (stationRouteId) {  
737 - // $.get("/stationroute/findStationRouteInfo",{"id":stationRouteId},function (route) {  
738 - $.get('edit_select.html', function (m) {  
739 - $(pjaxContainer).append(m);  
740 - $('#edit_select_mobal').trigger('editSelectMobal_show', [WorldsBMap, DrawingManagerObj, GetAjaxData, EditStationObj, LineObj, PublicFunctions, stationArray[stationRouteId]]);  
741 - });  
742 - // });  
743 - },  
744 - addBetweenStationRoad: function (stationRouteId) {  
745 - // 关闭信息窗口  
746 - mapBValue.closeInfoWindow();  
747 - $.get("/stationroute/findStationRouteInfo", {"id": stationRouteId}, function (route) {  
748 - var stationRouteBegin = route[0];  
749 - // 查询下一个站点  
750 - $.get("/stationroute/findDownStationRoute", {  
751 - "lineId": stationRouteBegin.stationRouteLine,  
752 - "direction": stationRouteBegin.stationRoutedirections,  
753 - "stationRouteCode": stationRouteBegin.stationRouteCode  
754 - }, function (stationRoute) {  
755 - var stationRouteFinish = stationRoute[0];  
756 -  
757 - if (stationRouteFinish) {  
758 - var pointBegin = stationRouteBegin.stationJwpoints.split(" ");  
759 - var pointFinish = stationRouteFinish.stationJwpoints.split(" ")  
760 - var sectionList = [];  
761 - // 两个站点的坐标  
762 - var poiOne = new BMap.Point(pointBegin[0], pointBegin[1]);  
763 - var poiTwo = new BMap.Point(pointFinish[0], pointFinish[1]);  
764 - // 路径规划保存按钮  
765 - var label = new BMap.Label("保存路段", {  
766 - offset: new BMap.Size(13, -53)  
767 - });  
768 - label.setStyle({  
769 - color: '#fff',  
770 - background: "url(/pages/base/stationroute/css/img/bg.png)",  
771 - border: '0px solid',  
772 - textAlign: "center",  
773 - height: "28px",  
774 - lineHeight: "26px",  
775 - width: "80px",  
776 - maxWidth: "none"  
777 - });  
778 - label.addEventListener('click', function () {  
779 - var params = {};  
780 - params.lineId = stationRouteBegin.stationRouteLine;  
781 - params.lineCode = stationRouteBegin.stationRouteLIneCode;  
782 - params.directions = stationRouteBegin.stationRoutedirections;  
783 - params.stationRouteBegin = stationRouteBegin.stationRouteName;  
784 - params.stationRouteFinish = stationRouteFinish.stationRouteName;  
785 - layer.confirm('确定保存', {  
786 - btn : [ '路段调整好了','继续调整','退出'], icon: 3, title:'提示'  
787 - ,btn3: function(index, layero){  
788 - PublicFunctions.resjtreeDate(params.lineId,params.directions);  
789 - PublicFunctions.editAChangeCssRemoveDisabled();  
790 -// GetAjaxData.getSectionRouteInfo(params.lineId,params.directions,function(data) {  
791 -// PublicFunctions.linePanlThree(params.lineId,data,params.directions);  
792 -// });  
793 - PublicFunctions.editMapStatusRemove();  
794 - }  
795 - }, function(index, layero){  
796 - layer.close(index);  
797 - params.route = $("#routePlanning").val();  
798 - $.get('doublename_road.html', function (m) {  
799 - $(pjaxContainer).append(m);  
800 - $('#doublename_road_mobal').trigger('doubleNameRoadMobal_show', [params, WorldsBMap, GetAjaxData, PublicFunctions]);  
801 - });  
802 - PublicFunctions.editMapStatusRemove();  
803 - });  
804 - });  
805 - // 路径规划  
806 - var transit = new BMap.DrivingRoute(mapBValue, {  
807 - renderOptions: {  
808 - map: mapBValue,  
809 - enableDragging: true  
810 - },  
811 - onPolylinesSet: searchPolylinesSet  
812 - });  
813 -  
814 - function searchPolylinesSet(results) {  
815 - if (transit.getStatus() == BMAP_STATUS_SUCCESS) {  
816 - var sectionArrayList = [];  
817 - for (i = 0; i < results.length; i++) {  
818 - sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath());  
819 - }  
820 - sectionList = sectionArrayList;//JSON.stringify()  
821 - $("#routePlanning").val(JSON.stringify(sectionArrayList));  
822 - var pointMap = new Map();  
823 - pointMap = sectionArrayList[sectionArrayList.length - 1];  
824 - var pointLabel = new BMap.Point(pointMap.lng, pointMap.lat);  
825 - label.enableMassClear();  
826 - label.setPosition(pointLabel);  
827 - mapBValue.addOverlay(label);  
828 - }  
829 - }  
830 - transit.search(poiOne, poiTwo);  
831 - transit.disableAutoViewport();  
832 - // 地图编辑状态  
833 - PublicFunctions.editMapStatus(stationRouteFinish.stationRoutedirections);  
834 - } else {  
835 - layer.msg("您选择的站点后没有站点了,不能生成站点间路段!")  
836 - }  
837 -  
838 - });  
839 - });  
840 -  
841 - },  
842 - // 匹配外部站点行业编码  
843 - editIndustryCode: function (stationId) {  
844 - var station = stationArray[stationId];  
845 - $.get('/stationroute/matchNearbyStation',station,function (data) {  
846 - if(data.status == "SUCCESS"){  
847 - // 关闭信息窗口  
848 - mapBValue.closeInfoWindow();  
849 - var list = data.matchList,  
850 - i = 1;  
851 - // for (var s in list) {  
852 - if(list.length <= 0){  
853 - layer.msg("很遗憾没有匹配到站点!!!");  
854 - return;  
855 - }  
856 -  
857 - // 进入编辑状态  
858 - PublicFunctions.editMapStatus(station.stationRoutedirections);  
859 - list.forEach(function (s) {  
860 - s.stationRouteId = station.stationRouteId;  
861 - s.directions = station.stationRoutedirections;  
862 - s.lineId = station.stationRouteLine;  
863 - var BJwpointsArray = s.bJwpoints.split(' ');  
864 - var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]);  
865 - var marker_stargt2 = new BMap.Marker(stationNameChangePoint);  
866 -  
867 - var label = new BMap.Label(i++,{offset:new BMap.Size(i>9?0:4,0)});  
868 - label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});  
869 - marker_stargt2.setLabel(label);  
870 - marker_stargt2.addEventListener('click', function () {  
871 - WorldsBMap.openMatchStationInfoWin(s);  
872 - });  
873 -  
874 - // 将标注添加到地图中  
875 - mapBValue.addOverlay(marker_stargt2);  
876 - });  
877 - var BJwpoints = station.stationJwpoints.split(' ');  
878 - mapBValue.centerAndZoom(new BMap.Point(BJwpoints[0], BJwpoints[1]), 18);  
879 - layer.msg("为您匹配到"+list.length+"个站点,选择红点标记的点,进行匹配!");  
880 - }  
881 - });  
882 - },  
883 - // 应用行业编码  
884 - citeIndustryCode: function (stationRouteId) {  
885 - if(matchStation.stationRouteId == stationRouteId){  
886 - var station = matchStation;  
887 - var keys = "dis_"+station.stationRouteId;  
888 - var params = {status:$($("#versions").find("option:selected")[0]).attr("status")};  
889 - // var params = new Map();  
890 - params[keys] = station.stationStandardCode;  
891 - // params.set(keys,station.stationStandardCode);  
892 - $.post('/stationroute/updIndustryCode',params,function (data) {  
893 - Bmap.closeMobleSetClean(station);  
894 - if(data.status == "SUCCESS"){  
895 - layer.msg("应用成功!!")  
896 - }else {  
897 - layer.msg("应用失败....")  
898 - }  
899 - });  
900 - }  
901 - },  
902 - // 清楚覆盖物,定位站点  
903 - closeMobleSetClean: function(station) {  
904 - var dir = station.directions;  
905 - var lineId = station.lineId; // map.clearMarkAndOverlays();  
906 -  
907 - Bmap.clearMarkAndOverlays();  
908 - // 刷新左边树  
909 - PublicFunctions.resjtreeDate(lineId,dir,$("#versions").val());  
910 - /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:路段数据 */  
911 -// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data1) {  
912 -// /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */  
913 -// PublicFunctions.linePanlThree(lineId,data1,dir);  
914 -// });  
915 -  
916 - // 退出编辑状态  
917 - PublicFunctions.editMapStatusRemove();  
918 - },  
919 - // 定位路段  
920 - focusSection: function(sectionRoudId) {  
921 - for (var i = 0, p; p = sectionArray[i++];) {  
922 - if (p.data.sectionrouteId == sectionRoudId) {  
923 - WorldsBMap.openSectionInfoWin(p);  
924 - break;  
925 - }  
926 - }  
927 - },  
928 - // 路段编辑  
929 - editSection : function(sectionRoudId,dir) {  
930 - layer.confirm('进入编辑状态', {  
931 - btn : [ '确定','返回' ], icon: 3, title:'提示'  
932 - }, function() {  
933 - PublicFunctions.editMapStatus(dir);  
934 - layer.msg('双击保存路段');  
935 - var p;  
936 - for (var i = 0; p = sectionArray[i++];) {  
937 - if (p.data.sectionrouteId == sectionRoudId) {  
938 - mapBValue.closeInfoWindow();//关闭infoWindow  
939 - p.enableEditing();  
940 - p.setStrokeColor('blue');  
941 - editPolyline = p;  
942 - break;  
943 - }  
944 - }  
945 - // 路段中间点为中心  
946 - var section = p.data;  
947 - var sectionStr = section.sectionBsectionVector.substring(11, section.sectionBsectionVector.length - 1);  
948 - // 分割折线坐标字符串  
949 - var lineArray = sectionStr.split(',');  
950 - var sectionPointArray = [];  
951 - for (var i = 0; i < lineArray.length; i++) {  
952 - sectionPointArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1]));  
953 - }  
954 - // 计算中间点  
955 - var index = parseInt(sectionPointArray.length / 2);  
956 - var centerPoint = sectionPointArray[index];  
957 - mapBValue.centerAndZoom(centerPoint, 17);  
958 - // var c = p.ia[Math.floor(p.ia.length/2)];  
959 - // mapBValue.centerAndZoom(new BMap.Point(c.lng, c.lat), 18);  
960 - p.addEventListener('dblclick', function () {  
961 - /** 设置修改路段集合对象为空 */  
962 - editPolyline = '';  
963 - PublicFunctions.editMapStatusRemove();  
964 - $.get('editsection.html', function(m){  
965 - $('body').append(m);  
966 - $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap,GetAjaxData,p,PublicFunctions]);  
967 - });  
968 - });  
969 - });  
970 - },  
971 - // 添加第一个路段  
972 - addSection : function(stecion) {  
973 - PublicFunctions.editMapStatus();  
974 - // 把数据填充到模版中  
975 - var addSectionHTML = template('add_draw_polyline-temp');  
976 - $('body .mian-portlet-body').append(addSectionHTML);  
977 - //暂停和开始绘制  
978 - $('.draw_polyline_switch>a').on('click', function () {  
979 - var t = $(this).text();  
980 - if(t=='暂停绘制'){  
981 - WorldsBMap.exitDrawStatus();  
982 - $(this).text('开始绘制');  
983 - }  
984 - else{  
985 - WorldsBMap.openDrawStatus();  
986 - $(this).text('暂停绘制');  
987 - }  
988 - });  
989 - // 开启绘制事件  
990 - WorldsBMap.showAddSectionPanel(stecion);  
991 -  
992 - //取消  
993 - $('#addSectionCancelBtn').on('click', function () {  
994 - $('.main_left_panel_m_layer').hide();  
995 - $(this).parents('.buffer_edit_body').parent().remove();  
996 - WorldsBMap.exitDrawStatus();  
997 - PublicFunctions.editMapStatusRemove();  
998 - });  
999 -  
1000 - //确定  
1001 - $('#addSectionSbmintBtn').on('click', function () {  
1002 - var btn = this;  
1003 - $('#addSectionSbmintBtn').addClass("disabled");  
1004 - var sectionName = $('#sectionNameInput').val();  
1005 - var bsectionVector = $('#bsectionVectorInput').val();  
1006 - var params = {};  
1007 - if(sectionName && bsectionVector) {  
1008 - WorldsBMap.exitDrawStatus();  
1009 - GetAjaxData.getSectionCode(function(sectionCode) {  
1010 - var lineId = stecion.lineId;  
1011 - var dir = stecion.dir;  
1012 - params.lineId = lineId;  
1013 - params.lineCode = stecion.lineCode;  
1014 - params.sectionCode = sectionCode;// 设值路段编码.  
1015 - params.sectionName = sectionName;  
1016 - params.roadCoding = '';  
1017 - params.dbType = 'b';  
1018 - params.bsectionVector = bsectionVector;  
1019 - params.sectionrouteCode = 1;  
1020 - params.sectionTime = 0;  
1021 - params.sectionDistance = 60;  
1022 - params.speedLimit = 0;  
1023 - params.versions = stecion.versions;  
1024 - params.destroy = 0;  
1025 - params.directions = dir;  
1026 - params.descriptions = '';  
1027 -  
1028 - params.status=$($("#versions").find("option:selected")[0]).attr("status");  
1029 - GetAjaxData.sectionSave(params, function (result) {  
1030 - if(result.status =="SUCCESS"){  
1031 - $('.main_left_panel_m_layer').hide();  
1032 - $(btn).parents('.buffer_edit_body').parent().remove();  
1033 - PublicFunctions.editMapStatusRemove();  
1034 - PublicFunctions.resjtreeDate(lineId,dir,$("#versions").val());  
1035 - PublicFunctions.editAChangeCssRemoveDisabled();  
1036 -// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {  
1037 -// PublicFunctions.linePanlThree(lineId,data,dir);  
1038 -// });  
1039 - layer.msg("添加成功!");  
1040 - } else if(result.status =="ERROR") {  
1041 - layer.msg("添加失败!");  
1042 - }  
1043 - });  
1044 - });  
1045 - } else if(!sectionName){  
1046 - layer.msg('请填写路段名字!');  
1047 - } else if(!bsectionVector){  
1048 - layer.msg('请先绘制路段!');  
1049 - }  
1050 - setTimeout(function () {  
1051 - $("#addSectionSbmintBtn").removeClass("disabled");  
1052 - },1000);  
1053 - });  
1054 - },  
1055 - // 添加在路段之后  
1056 - addSectionAfter : function(sectionRoudId) {  
1057 - //order = after before;  
1058 - var beforeSection;  
1059 - // 关闭信息窗口  
1060 - mapBValue.closeInfoWindow();  
1061 - PublicFunctions.editMapStatus();  
1062 - // 把数据填充到模版中  
1063 - var addSectionHTML = template('add_draw_polyline-temp',{ 'id': sectionRoudId});  
1064 - $('body .mian-portlet-body').append(addSectionHTML);  
1065 - //暂停和开始绘制  
1066 - $('.draw_polyline_switch>a').on('click', function () {  
1067 - var t = $(this).text();  
1068 - if(t=='暂停绘制'){  
1069 - WorldsBMap.exitDrawStatus();  
1070 - $(this).text('开始绘制');  
1071 - }  
1072 - else{  
1073 - WorldsBMap.openDrawStatus();  
1074 - $(this).text('暂停绘制');  
1075 - }  
1076 - });  
1077 -  
1078 - //取消  
1079 - $('#addSectionCancelBtn').on('click', function () {  
1080 - $('.main_left_panel_m_layer').hide();  
1081 - $(this).parents('.buffer_edit_body').parent().remove();  
1082 - WorldsBMap.exitDrawStatus();  
1083 - PublicFunctions.editMapStatusRemove();  
1084 - });  
1085 - GetAjaxData.getSectionRouteInfoById(sectionRoudId, function(data){  
1086 - WorldsBMap.showAddSectionPanel(data[0]);  
1087 - beforeSection = data[0];  
1088 - });  
1089 -  
1090 - //确定  
1091 - $('#addSectionSbmintBtn').on('click', function () {  
1092 - var btn = this;  
1093 - $('#addSectionSbmintBtn').addClass("disabled");  
1094 - var sectionName = $('#sectionNameInput').val();  
1095 - var bsectionVector = $('#bsectionVectorInput').val();  
1096 - var params = {};  
1097 - if(sectionName && bsectionVector) {  
1098 - WorldsBMap.exitDrawStatus();  
1099 - GetAjaxData.getSectionCode(function(sectionCode) {  
1100 - var lineId = beforeSection.sectionRouteLine  
1101 - var dir = beforeSection.sectionRouteDirections  
1102 - params.lineId = lineId;  
1103 - params.lineCode = beforeSection.sectionRouteLineCode;  
1104 - params.sectionCode = sectionCode;// 设值路段编码.  
1105 - params.sectionName = sectionName;  
1106 - params.roadCoding = '';  
1107 - params.dbType = 'b';  
1108 - params.bsectionVector = bsectionVector;  
1109 - params.sectionrouteCode = beforeSection.sectionRouteCode+"_0";  
1110 - params.sectionTime = 0;  
1111 - params.sectionDistance = 60;  
1112 - params.speedLimit = 0;  
1113 - params.versions = beforeSection.sectionRouteVersions;  
1114 - params.destroy = 0;  
1115 - params.directions = dir;  
1116 - params.descriptions = '';  
1117 - params.status=$($("#versions").find("option:selected")[0]).attr("status");  
1118 -  
1119 - GetAjaxData.sectionSave(params, function (result) {  
1120 - if(result.status =="SUCCESS"){  
1121 - $('.main_left_panel_m_layer').hide();  
1122 - $(btn).parents('.buffer_edit_body').parent().remove();  
1123 - PublicFunctions.editMapStatusRemove();  
1124 - PublicFunctions.resjtreeDate(lineId,dir,$("#versions").val());  
1125 - PublicFunctions.editAChangeCssRemoveDisabled();  
1126 -// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {  
1127 -// PublicFunctions.linePanlThree(lineId,data,dir);  
1128 -// });  
1129 - layer.msg("添加成功!");  
1130 - } else if(result.status =="ERROR") {  
1131 - layer.msg("添加失败!");  
1132 - }  
1133 - });  
1134 - });  
1135 - } else if(!sectionName){  
1136 - layer.msg('请填写路段名字!');  
1137 - } else if(!bsectionVector)  
1138 - layer.msg('请先绘制路段!');  
1139 - setTimeout(function () {  
1140 - $("#addSectionSbmintBtn").removeClass("disabled");  
1141 - },1000);  
1142 - });  
1143 - },  
1144 - // 撤销站点  
1145 - destroyStation : function(stationRouteId,lineId,dir) {  
1146 - layer.confirm('你确定要撤销此站点吗?', {  
1147 - btn : [ '撤销','返回' ], icon: 3, title:'提示'  
1148 - }, function(){  
1149 -  
1150 - var status = $($("#versions").find("option:selected")[0]).attr("status");  
1151 -  
1152 - $.post('/stationroute/stationRouteIsDestroy',{'stationRouteId':stationRouteId,destroy:'1',status:status},function(resuntDate) {  
1153 - if (resuntDate.status == 'SUCCESS') {  
1154 - // 弹出添加成功提示消息  
1155 - layer.msg('撤销成功!');  
1156 - } else {  
1157 - // 弹出添加失败提示消息  
1158 - layer.msg('撤销失败!');  
1159 - }  
1160 - // 刷新左边树  
1161 - var version = $("#verions").val();  
1162 - PublicFunctions.resjtreeDate(lineId,dir,version);  
1163 - /** 查询路段信息 @param:<Line.id:线路Id;delBatch.dir:方向> @return:data:路段数据 */  
1164 -// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {  
1165 -// /** 在地图上画出线路走向 @param:<Line.id:线路Id;delBatch.dir:方向;data:路段数据> */  
1166 -// PublicFunctions.linePanlThree(lineId,data,dir);  
1167 -// });  
1168 - });  
1169 - });  
1170 - },  
1171 - // 撤销路段  
1172 - destroySection : function(sectionRoudId,lineId,dir) {  
1173 - layer.confirm('你确定要撤销此路段吗?', {  
1174 - btn : [ '撤销','返回' ], icon: 3, title:'提示'  
1175 - }, function(){  
1176 - var status = $($("#versions").find("option:selected")[0]).attr("status");  
1177 - $.post('/sectionroute/destroy',{'id': sectionRoudId,status:status},function(resuntDate) {  
1178 - if (resuntDate.status == 'SUCCESS') {  
1179 - // 弹出添加成功提示消息  
1180 - layer.msg('撤销成功!');  
1181 - } else {  
1182 - // 弹出添加失败提示消息  
1183 - layer.msg('撤销失败!');  
1184 - }  
1185 - // 刷新左边树  
1186 - var version = $("#verions").val();  
1187 - PublicFunctions.resjtreeDate(lineId,dir,version);  
1188 - /** 查询路段信息 @param:<Line.id:线路Id;delBatch.dir:方向> @return:data:路段数据 */  
1189 -// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {  
1190 -// /** 在地图上画出线路走向 @param:<Line.id:线路Id;delBatch.dir:方向;data:路段数据> */  
1191 -// PublicFunctions.linePanlThree(lineId,data,dir);  
1192 -// });  
1193 - });  
1194 - });  
1195 - },  
1196 - // 打开路段信息窗口  
1197 - openSectionInfoWin : function(p) {  
1198 - var section = p.data;  
1199 - var dir = section.sectionrouteDirections;  
1200 - var width = WorldsBMap.strGetLength(section.sectionName) * 10;  
1201 - // 信息窗口参数属性  
1202 - var opts = {  
1203 - // 信息窗口宽度  
1204 - width: (width < 200 ? 200 : width),  
1205 - // 信息窗口高度  
1206 - height: 150,  
1207 - //设置不允许信窗发送短息  
1208 - enableMessage: false,  
1209 - //是否开启点击地图关闭信息窗口  
1210 - enableCloseOnClick: false,  
1211 - // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)  
1212 - enableAutoPan: false  
1213 - };  
1214 - var htm = '<span style="color: #ff8355;font-size: 18px;">' + section.sectionName + '</span>' +  
1215 - '<span class="help-block" >路段编码:' + section.sectionCode + '</span>' +  
1216 - '<span class="help-block" >路段序号:' + section.sectionrouteCode + '</span>' +  
1217 - '<span class="help-block" >版本号&nbsp&nbsp:' + section.versions + '</span>' +  
1218 - '<div >';  
1219 -  
1220 - if($($("#versions").find("option:selected")[0]).attr("status") > 0){  
1221 - htm += '<button class="info_win_btn" id="editStation" onclick="WorldsBMap.editSection(' + section.sectionrouteId +','+dir+ ')">修改</button>' +  
1222 - '<button class="info_win_btn" id="addBetweenStationRoad" onclick="WorldsBMap.destroySection('+ section.sectionrouteId + ','+section.sectionrouteLine+','+section.sectionrouteDirections+')">撤销</button>' +  
1223 - '<button class="info_win_btn" id="addSectionAfter" onclick="WorldsBMap.addSectionAfter('+section.sectionrouteId+')">添加路段(之后)</button>' +  
1224 - '</div>';  
1225 - }  
1226 -  
1227 - // 创建信息窗口  
1228 - var infoWindow_target = new BMap.InfoWindow(htm, opts);  
1229 - // 切割段折线坐标字符串  
1230 - var sectionStr = section.sectionBsectionVector.substring(11, section.sectionBsectionVector.length - 1);  
1231 - // 分割折线坐标字符串  
1232 - var lineArray = sectionStr.split(',');  
1233 - var sectionArray = [];  
1234 - for (var i = 0; i < lineArray.length; i++) {  
1235 - sectionArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1]));  
1236 - }  
1237 - // 计算中间点  
1238 - var index = parseInt(sectionArray.length / 2);  
1239 - var centerPoint = sectionArray[index];  
1240 - //close event  
1241 - infoWindow_target.addEventListener('close', function (e) {  
1242 - p.setStrokeColor("red");  
1243 - road_win_show_p = null;  
1244 - });  
1245 - //open event  
1246 - infoWindow_target.addEventListener('open', function (e) {  
1247 - p.setStrokeColor("#20bd26");  
1248 - road_win_show_p = p;  
1249 - });  
1250 - //开启信息窗口  
1251 - mapBValue.openInfoWindow(infoWindow_target, centerPoint);  
1252 - mapBValue.panTo(centerPoint);  
1253 - },  
1254 - /**  
1255 - * 绘制新增路段  
1256 - * @param section  
1257 - */  
1258 - showAddSectionPanel : function (section) {  
1259 - var point;  
1260 - if(section){  
1261 - var sectionBsectionVectorStr = section.sectionBsectionVector;  
1262 - var line = sectionBsectionVectorStr.substring(11, sectionBsectionVectorStr.length - 1),  
1263 - points = line.split(','),  
1264 - pointStr = points[points.length-1].split(' ');  
1265 -  
1266 - point = new BMap.Point(pointStr[0], pointStr[1]);  
1267 - }  
1268 -  
1269 - mapBValue.centerAndZoom(point, 18);  
1270 -  
1271 - //开启鼠标绘制  
1272 - drawingManager = new BMapLib.DrawingManager(mapBValue, {  
1273 - polylineOptions: styleOptions  
1274 - });  
1275 -  
1276 - drawingManager.open();  
1277 - //drawingManager.enableCalculate();  
1278 - drawingManager.setDrawingMode('polyline');  
1279 -  
1280 - //绘制完成  
1281 - drawingManager.addEventListener('polylinecomplete', function (e) {  
1282 - console.log('eee', e, e.getPath());  
1283 - drawingManager.close();  
1284 -  
1285 - var polyline = new BMap.Polyline(e.getPath(), {strokeWeight: 7, strokeColor: 'blue', strokeOpacity: 0.7});  
1286 -  
1287 - mapBValue.removeOverlay(e);  
1288 - mapBValue.addOverlay(polyline);  
1289 - polyline.enableEditing();  
1290 -  
1291 - editPolyline = polyline;  
1292 - var sectionData = e.getPath();// 获取折线坐标集合  
1293 - $('#bsectionVectorInput').val(JSON.stringify(sectionData));  
1294 - });  
1295 - },  
1296 - exitDrawStatus : function () {  
1297 - if (drawingManager) {  
1298 - $('#bsectionVectorInput').val("");  
1299 - WorldsBMap.clearOtherOverlay();  
1300 - drawingManager.close();  
1301 - }  
1302 - },  
1303 - openDrawStatus : function () {  
1304 - if (drawingManager) {  
1305 - $('#bsectionVectorInput').val("");  
1306 - WorldsBMap.clearOtherOverlay();  
1307 - drawingManager.open();  
1308 - }  
1309 - },  
1310 - /** 清楚无需要的覆盖物(非站点/路段数据源)*/  
1311 - clearOtherOverlay : function () {  
1312 - var all = mapBValue.getOverlays();  
1313 - for (var i = 0, obj; obj = all[i++];) {  
1314 - if (obj.ct_source && obj.ct_source == '1')  
1315 - continue;  
1316 - mapBValue.removeOverlay(obj);  
1317 - }  
1318 - },  
1319 - clearMarkAndOverlays: function () {  
1320 - // 清楚地图覆盖物  
1321 - mapBValue.clearOverlays();  
1322 - mapBValue.removeOverlay();  
1323 - },  
1324 - clearMark: function () {  
1325 - // 清楚地图覆盖物  
1326 - mapBValue.removeOverlay();  
1327 - },  
1328 - strGetLength: function (str) {  
1329 - return str.replace(/[\u0391-\uFFE5]/g, "aa").length; //先把中文替换成两个字节的英文,在计算长度  
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 - },  
1459 - };  
1460 -  
1461 - return Bmap;  
1462 - 1 +/**
  2 + * 百度地图
  3 + *
  4 + * - - - - - -》init:地图初始化
  5 + *
  6 + * - - - - - -》lineInfoPanl:从百度地图抓去站点与路段数据
  7 + *
  8 + * - - - - - -》getDistanceAndDuration:获取距离与时间
  9 + *
  10 + * - - - - - -》pointsPolygon:地图画多边行
  11 + *
  12 + * - - - - - -》pointsCircle:画圆
  13 + *
  14 + * - - - - - -》localSearchFromAdreesToPoint:根据地理名称获取百度经纬度坐标
  15 + *
  16 + * - - - - - -》drawingUpline:在地图上画出上行线路走向
  17 + *
  18 + * - - - - - -》stationsNameToPoints:站点名称获取百度坐标(手动规划)
  19 + *
  20 + * - - - - - -》getDistanceAndTotime:根据坐标点获取两点之间的时间与距离(手动规划)
  21 + *
  22 + * - - - - - -》getSectionListPlonly:根据坐标点获取两点之间的折线路段(手动规划)
  23 + */
  24 +
  25 +window.WorldsBMap = function () {
  26 +
  27 + /** WorldsBMap 全局变量定义 mapBValue:地图对象; road_win_show_p:信息窗口打开状态的路段,
  28 + * sectionArray: 路段集合,stationArray: 站点集合
  29 + * map_status:地图编辑状态,drawingManager:绘画工具, topOverlay:置顶视图*/
  30 + var mapBValue = '', iseditStatus = false, road_win_show_p = '', editPolyline = '', matchStation = '',dir = 0,
  31 + sectionArray = [], stationArray = new Map(),
  32 + map_status = 0,drawingManager,topOverlay;
  33 +
  34 + /**
  35 + * 编辑缓冲区
  36 + * stationMarkers: 站点图标集合
  37 + */
  38 + var editCircle, editPolygon, dragMarker, stationMarkers = new Map(),centerPoint;
  39 +
  40 + var styleOptions = {
  41 + strokeColor:"blue", //边线颜色。
  42 + fillColor:"blue", //填充颜色。当参数为空时,圆形将没有填充效果。
  43 + strokeWeight: 6, //边线的宽度,以像素为单位。
  44 + strokeOpacity: 0.7, //边线透明度,取值范围0 - 1。
  45 + fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
  46 + strokeStyle: 'solid' //边线的样式,solid或dashed。
  47 + };
  48 +
  49 + // 覆盖物置顶
  50 + var setTop = function(overlay) {
  51 + if (topOverlay)
  52 + topOverlay.setTop(false);
  53 + overlay.setTop(true);
  54 + topOverlay = overlay;
  55 + };
  56 +
  57 + var setDragMarker = function (marker) {
  58 + marker.enableDragging();
  59 + dragMarker = marker;
  60 + dragMarker._old_point = dragMarker._position;
  61 + centerPoint = dragMarker._position;
  62 + //监听拖拽事件 dragging
  63 + dragMarker.addEventListener('dragging', dragMarkerDragEvent);
  64 + };
  65 +
  66 + var dragMarkerDragEvent = function (e) {
  67 + if (editPolygon) {
  68 + // 中心点是否超出多边形
  69 + // if (!BMapLib.GeoUtils.isPointInPolygon(e.target._position, editPolygon)) {
  70 + // dragMarker.setPosition(dragMarker._old_point);//还原位置
  71 + // }
  72 + centerPoint = e.target._position;
  73 + }
  74 + else if (editCircle) {
  75 + editCircle.disableEditing();
  76 + //缓冲区跟随点位运动
  77 + editCircle.setCenter(e.target._position);
  78 + editCircle.enableEditing();
  79 + centerPoint = e.target._position;
  80 + }
  81 + };
  82 +
  83 + var Bmap = {
  84 +
  85 + init: function () {
  86 + // 设置中心点,
  87 + var CENTER_POINT = {lng: 121.528733, lat: 31.237425};
  88 + // 百度API Key
  89 + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT';
  90 + // 初始化百度地图
  91 + mapBValue = new BMap.Map("bmap_basic" , {enableMapClick: false});
  92 + //中心点和缩放级别
  93 + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng, CENTER_POINT.lat), 14);
  94 + //启用地图拖拽事件,默认启用(可不写)
  95 + mapBValue.enableDragging();
  96 + //启用地图滚轮放大缩小
  97 + mapBValue.enableScrollWheelZoom();
  98 + //禁用鼠标双击放大
  99 + mapBValue.disableDoubleClickZoom();
  100 + //启用键盘上下左右键移动地图
  101 + mapBValue.enableKeyboard();
  102 + return mapBValue;
  103 + },
  104 +
  105 + /** 获取地图对象 @return 地图对象map */
  106 + getmapBValue: function () {
  107 + return mapBValue;
  108 + },
  109 + getDir:function(){
  110 + return dir;
  111 + },
  112 + setDir:function (dirx) {
  113 + dir = dirx;
  114 + },
  115 + setMap_status : function (i) {
  116 + map_status = i;
  117 + },
  118 + getIsEditStatus: function () {
  119 + return iseditStatus;
  120 + },
  121 + setIsEditStatus: function (v) {
  122 + iseditStatus = v;
  123 + },
  124 + getStationArray: function () {
  125 + return stationArray;
  126 + },
  127 + setStationArray : function (s) {
  128 + stationArray = s;
  129 + },
  130 + /*initDrawingManager: function (map, styleOptions) {
  131 + },*/
  132 + getDrawingManagerObj: function () {
  133 + return drawingManagerInitV;
  134 + },
  135 +
  136 + // 从百度地图抓去站点与路段数据
  137 + lineInfoPanl: function (lineNameValue, i, cb) {
  138 +
  139 + /** 根据线路名称与方向从百度地图获取站点与路段 @param lineNameValue:线路名称;i:方向<0:上行;1:下行> */
  140 + WorldsBMap.getBmapStationNames(lineNameValue, i, function (BusLine) {
  141 +
  142 + return cb && cb(BusLine);
  143 +
  144 + });
  145 +
  146 + },
  147 +
  148 + /** 获取距离与时间 @param <points:坐标点集合> */
  149 + getDistanceAndDuration: function (points, callback) {
  150 + // 获取长度
  151 + var len = points.length;
  152 + (function () {
  153 + if (!arguments.callee.count) {
  154 + arguments.callee.count = 0;
  155 + }
  156 + arguments.callee.count++;
  157 + var index = parseInt(arguments.callee.count) - 1;
  158 + if (index >= len - 1) {
  159 + callback && callback(points);
  160 + return;
  161 + }
  162 + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。)
  163 + var f = arguments.callee;
  164 + // 起点坐标 <坐标格式:40.056878,116.30815>
  165 + var origin = points[index].potion.lat + ',' + points[index].potion.lng;
  166 + // 终点坐标 <坐标格式:40.056878,116.30815>
  167 + var destination = points[index + 1].potion.lat + ',' + points[index + 1].potion.lng;
  168 + var region = '上海';
  169 + var origin_region = '上海';
  170 + var destination_region = '上海';
  171 + var output = 'json';
  172 + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk';
  173 + /**
  174 + * origin:起点名称或经纬度;
  175 + * destination:终点名称或经纬度;
  176 + * origin_region:起始点所在城市,驾车导航时必填。
  177 + * destination_region:终点所在城市,驾车导航时必填。
  178 + * output :表示输出类型,可设置为xml或json,默认为xml。
  179 + **/
  180 + var paramsB = {
  181 + origin: origin,
  182 + destination: destination,
  183 + region: region,
  184 + origin_region: origin_region,
  185 + destination_region: destination_region,
  186 + output: output,
  187 + ak: ak_My
  188 + };
  189 +
  190 + /** @description :未认证开发者默认配额为:2000次/天。 */
  191 + $.ajax({
  192 + // 百度地图根据坐标获取两点之间的时间与距离
  193 + url: 'http://api.map.baidu.com/direction/v1?mode=transit',
  194 + data: paramsB,
  195 + dataType: 'jsonp',
  196 + success: function (r) {
  197 + if (r) {
  198 + if (r.message == 'ok') {
  199 + if (r.result.taxi == null) {
  200 + // 获取距离(单位:米)
  201 + points[index + 1].distance = 0;
  202 + // 获取时间(单位:秒)
  203 + points[index + 1].duration = 0;
  204 + } else {
  205 + // 获取距离(单位:米)
  206 + points[index + 1].distance = r.result.taxi.distance;
  207 + // 获取时间(单位:秒)
  208 + points[index + 1].duration = r.result.taxi.duration;
  209 + }
  210 + }
  211 + }
  212 + f();
  213 + }
  214 + });
  215 + })();
  216 + },
  217 +
  218 + // 打开站点信息窗口
  219 + openStationInfoWin : function (objStation) {
  220 + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)
  221 + if (objStation) {
  222 + // 站点形状
  223 + var shapes = objStation.stationShapesType;
  224 + // 获取中心坐标点字符串分割
  225 + var BJwpoints = objStation.stationJwpoints.split(' ');
  226 + // 中心坐标点
  227 + var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);
  228 + var width = WorldsBMap.strGetLength(objStation.stationRouteName) * 11;
  229 + // 信息窗口参数属性
  230 + var opts = {
  231 + // 信息窗口宽度
  232 + width: (width < 240 ? 240 : width),
  233 + // 信息窗口高度
  234 + // height: shapes=="r" ?380:350,
  235 + // 信息窗位置偏移值。
  236 + offset: new BMap.Size(10,-20),
  237 + //设置不允许信窗发送短息
  238 + enableMessage: false,
  239 + //是否开启点击地图关闭信息窗口
  240 + enableCloseOnClick: false,
  241 + // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)
  242 + enableAutoPan: false
  243 + };
  244 +
  245 + var markTypeStr = '';
  246 + if (objStation.stationRouteStationMark == 'B') {
  247 + markTypeStr = '起点站';
  248 + } else if (objStation.stationRouteStationMark == 'Z') {
  249 + markTypeStr = '中途站';
  250 + } else if (objStation.stationRouteStationMark == 'E') {
  251 + markTypeStr = '终点站';
  252 + }
  253 + var htm = '<span style="color: #ff8355;font-size: 20px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis;display: -webkit-box; -webkit-box-orient: vertical;">' + objStation.stationRouteName + '</span>' +
  254 + '<span class="help-block" >站点编码:' + objStation.stationCode + '</span>' +
  255 + '<span class="help-block" >行业编号:' + (objStation.industryCode == null ? "":objStation.industryCode)+ '</span>' +
  256 + '<span class="help-block" >站点序号:' + objStation.stationRouteCode + '</span>' +
  257 + '<span class="help-block" >站点类型:' + markTypeStr + '</span>' +
  258 + '<span class="help-block" >经度:&nbsp&nbsp' + BJwpoints[0] + '</span>' +
  259 + '<span class="help-block" >纬度:&nbsp&nbsp' + BJwpoints[1] + '</span>' +
  260 + '<span class="help-block" >到站时间:' + objStation.stationRouteToTime + '&nbsp;分钟</span>' +
  261 + '<span class="help-block" >到站距离:' + objStation.stationRouteDistances + '&nbsp;公里</span>' +
  262 + '<span class="help-block" >缓冲区形状:' + (shapes == "r" ? "圆形" : "多边形") + '</span>' +
  263 + (shapes=="r" ? ("<span class='help-block' >半径&nbsp&nbsp:" + objStation.stationRadius + "</span>") : " ")+
  264 + '<span class="help-block" >版本号&nbsp&nbsp:' + objStation.stationRouteVersions + '</span>';
  265 +
  266 + if($($("#versions").find("option:selected")[0]).attr("status") > 0){
  267 + htm += '<div>' +
  268 + '<button class="info_win_btn" id="editStation" onclick="WorldsBMap.editStation(' + objStation.stationRouteId+','+objStation.stationRoutedirections + ')">修改</button>' +
  269 + '<button class="info_win_btn" onclick="WorldsBMap.destroyStation('+ objStation.stationRouteId + ','+objStation.stationRouteLine+','+objStation.stationRoutedirections+')">撤销</button>' +
  270 + '<button class="info_win_btn" id="addBetweenStationRoad" onclick="WorldsBMap.addBetweenStationRoad(' + objStation.stationRouteId + ')">添加站点间路段</button>' +
  271 + '<button class="info_win_btn" id="editIndustryCode" onclick="WorldsBMap.editIndustryCode(' + objStation.stationRouteId + ')">匹配周边站点行业编码</button>' +
  272 + '</div>';
  273 + }
  274 + // 创建信息窗口
  275 + var infoWindow_target = new BMap.InfoWindow(htm, opts);
  276 + setTimeout(function () {
  277 + //开启信息窗口
  278 + mapBValue.openInfoWindow(infoWindow_target, point);
  279 + }, 100);
  280 + // 将地图的中心点更改为给定的点。
  281 + mapBValue.panTo(point);
  282 + }
  283 + },
  284 +
  285 + // 打开匹配博协站点信息窗口
  286 + openMatchStationInfoWin : function (objStation) {
  287 + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)
  288 + if (objStation) {
  289 + matchStation = objStation;
  290 + // 获取中心坐标点字符串分割
  291 + var BJwpoints = objStation.bJwpoints.split(' ');
  292 + // 中心坐标点
  293 + var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);
  294 + var width = WorldsBMap.strGetLength(objStation.stationName) * 11;
  295 + // 信息窗口参数属性
  296 + var opts = {
  297 + // 信息窗口宽度
  298 + width: (width < 240 ? 240 : width),
  299 + // 信息窗口高度
  300 + // height: shapes=="r" ?380:350,
  301 + // 信息窗位置偏移值。
  302 + offset: new BMap.Size(10,-20),
  303 + //设置不允许信窗发送短息
  304 + enableMessage: false,
  305 + //是否开启点击地图关闭信息窗口
  306 + enableCloseOnClick: false,
  307 + // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)
  308 + enableAutoPan: false
  309 + };
  310 +
  311 + var htm = '<span style="color: #ff8355;font-size: 20px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis;display: -webkit-box; -webkit-box-orient: vertical;">' + objStation.stationName + '</span>' +
  312 + '<span class="help-block" >行业编号:' + (objStation.stationStandardCode == null ? "":objStation.stationStandardCode)+ '</span>' +
  313 + '<span class="help-block" >经过线路:' + objStation.lineList + '</span>' +
  314 + // '<div>' + '<button class="info_win_btn" onclick="WorldsBMap.citeIndustryCode(' + objStation + ')">应用此站点行业编码</button>' +
  315 + '<div>' + '<button class="info_win_btn" onclick="WorldsBMap.citeIndustryCode(' + objStation.stationRouteId + ')">应用此站点行业编码</button>' +
  316 + '</div>';
  317 +
  318 + // 创建信息窗口
  319 + var infoWindow_target = new BMap.InfoWindow(htm, opts);
  320 + setTimeout(function () {
  321 + //开启信息窗口
  322 + mapBValue.openInfoWindow(infoWindow_target, point);
  323 + }, 100);
  324 + // 将地图的中心点更改为给定的点。
  325 + mapBValue.panTo(point);
  326 + }
  327 + },
  328 +
  329 + // 根据地理名称获取百度经纬度坐标
  330 + localSearchFromAdreesToPoint: function (Address, callback) {
  331 + // 创建一个搜索类实例
  332 + var localSearch = new BMap.LocalSearch(mapBValue);
  333 + // 检索完成后的回调函数。
  334 + localSearch.setSearchCompleteCallback(function (searchResult) {
  335 + var resultPoints = '';
  336 + if (searchResult) {
  337 + // 返回索引指定的结果。索引0表示第1条结果
  338 + var poi = searchResult.getPoi(0);
  339 + if (poi) {
  340 + //获取经度和纬度
  341 + resultPoints = poi.point.lng + ' ' + poi.point.lat;
  342 + callback && callback(resultPoints);
  343 + } else {
  344 + callback && callback(false);
  345 + }
  346 + } else {
  347 + callback && callback(false);
  348 + }
  349 + });
  350 + // 根据检索词发起检索。
  351 + localSearch.search(Address);
  352 + },
  353 +
  354 + // 站点编辑
  355 + editShapes: function (obj) {
  356 + // 关闭信息窗口
  357 + mapBValue.closeInfoWindow();
  358 + // 清除marker
  359 + // mapBValue.removeOverlay(marker);
  360 + var station = obj.getEitdStation();
  361 + var stationShapesTypeV = station.stationShapesType;
  362 + setDragMarker(stationMarkers[station.stationRouteId]);
  363 + // 编辑圆
  364 + if (stationShapesTypeV == 'r') {
  365 + // 获取中心坐标点字符串分割
  366 + var BJwpoints = station.stationJwpoints.split(' ');
  367 + // 中心坐标点
  368 + var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);
  369 + //创建圆
  370 + var circle = new BMap.Circle(point, station.stationRadius, {
  371 + strokeColor: "blue",
  372 + strokeWeight: 2,
  373 + strokeOpacity: 0.7
  374 + });
  375 + mapBValue.centerAndZoom(point, 18);
  376 + editCircle = circle;
  377 + // 允许覆盖物在map.clearOverlays方法中被清除
  378 + // circle.enableMassClear();
  379 + // 百度地图添加覆盖物圆
  380 + mapBValue.addOverlay(circle);
  381 + // 开启编辑功能
  382 + circle.enableEditing();
  383 + // 编辑圆监听事件
  384 + circle.addEventListener('dblclick', function () {
  385 + // 返回圆形的半径,单位为米。
  386 + var newRadius = circle.getRadius();
  387 + // 返回圆形的中心点坐标。
  388 + var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat;
  389 + // var centre_points = [{potion: {lng: circle.getCenter().lng, lat: circle.getCenter().lat}}];
  390 + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */
  391 + EditStationObj.setEitdStationJwpoints(newCenter);
  392 + /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */
  393 + EditStationObj.setEitdStationShapesType('r');
  394 + /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */
  395 + EditStationObj.setEitdStationRadius(Math.round(newRadius));
  396 + /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */
  397 + EditStationObj.setEitdBPolygonGrid('');
  398 + // 清除正在编辑的站点
  399 + editCircle = null;
  400 + // 加载编辑页面
  401 + $.get('edit.html', function (m) {
  402 + $(pjaxContainer).append(m);
  403 + $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]);
  404 + });
  405 + });
  406 + // 编辑多边行
  407 + } else if (stationShapesTypeV == 'd') {
  408 + // 获取中心点坐标字符串
  409 + var testpointStr = station.stationJwpoints;
  410 + // 按空格切割中心点坐标字符串
  411 + var BJwpointsPolygon = testpointStr.split(' ');
  412 + // 中心点坐标
  413 + var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]);
  414 + // 获取多边形坐标字符串
  415 + var stationBPolygonGrid = station.stationBPolyonGrid;
  416 + // 截取多边形坐标字符串
  417 + var stationBPolygonGridStr = stationBPolygonGrid.substring(9, stationBPolygonGrid.length - 2);
  418 + // 按逗号切割
  419 + var pointPolygonArray = stationBPolygonGridStr.split(',');
  420 + // 多边形坐标集合
  421 + var polygonP = [];
  422 + for (var v = 0; v < pointPolygonArray.length; v++) {
  423 + polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0], pointPolygonArray[v].split(" ")[1]));
  424 + }
  425 + // 画多边形
  426 + var polygon = new BMap.Polygon(polygonP, {
  427 + // 线条显色
  428 + strokeColor: "blue",
  429 + // 边线的宽度,以像素为单位。
  430 + strokeWeight: 2,
  431 + // 边线透明度,取值范围0 - 1。
  432 + strokeOpacity: 0.7
  433 + });
  434 + mapBValue.centerAndZoom(pointPolygon, 18);
  435 + editPolygon = polygon;
  436 + // 增加地图覆盖物多边形
  437 + mapBValue.addOverlay(polygon);
  438 + // 开启编辑功能(自 1.1 新增)
  439 + polygon.enableEditing();
  440 + //禁止覆盖物在map.clearOverlays方法中被清除
  441 + // polygon.disableMassClear();
  442 + // 添加多边形编辑事件
  443 + polygon.addEventListener('dblclick', function (e) {
  444 + // 获取编辑的多边形对象
  445 + var edit_pointE = polygon;
  446 + var edit_bPloygonGrid = "";
  447 + var editPolyGonLen_ = edit_pointE.getPath().length;
  448 + for (var k = 0; k < editPolyGonLen_; k++) {
  449 + if (k == 0) {
  450 + edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat;
  451 + } else {
  452 + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat;
  453 + }
  454 + }
  455 + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat;
  456 + // 多边形中心点
  457 + // var centre = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat;
  458 + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) centerPoint可拖动点 */
  459 + EditStationObj.setEitdStationJwpoints(centerPoint.lng+' '+centerPoint.lat);
  460 + /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */
  461 + EditStationObj.setEitdStationShapesType('d');
  462 + /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */
  463 + EditStationObj.setEitdStationRadius('');
  464 + /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */
  465 + EditStationObj.setEitdBPolygonGrid(edit_bPloygonGrid);
  466 + // 清除正在编辑的站点
  467 + editPolygon = null;
  468 + $.get('edit.html', function (m) {
  469 + $(pjaxContainer).append(m);
  470 + $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]);
  471 + });
  472 + });
  473 + }
  474 + },
  475 +
  476 + // 画路段走向
  477 + drawingUpline01: function (datas) {
  478 + // drawingUpline01: function (polyline_center, datas) {
  479 + if (datas) {
  480 + // if (polyline_center && datas) {
  481 + // 编辑路段数据
  482 + sectionArray = [];
  483 + for (var d = 0; d < datas.length; d++) {
  484 + var data = datas[d];
  485 + // 地图折线坐标点集合
  486 + var polylineArray = [];
  487 + // 获取路段折线坐标字符串
  488 + var sectionBsectionVectorStr = data.sectionBsectionVector;
  489 + if (sectionBsectionVectorStr == null)
  490 + continue;
  491 + // 切割段折线坐标字符串
  492 + var tempStr = sectionBsectionVectorStr.substring(11, sectionBsectionVectorStr.length - 1);
  493 + // 分割折线坐标字符串
  494 + var lineArray = tempStr.split(',');
  495 + for (var i = 0; i < lineArray.length; i++) {
  496 + polylineArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1]));
  497 + }
  498 + var polyUpline01 = 'polyline' + '_' + data.sectionrouteId;
  499 + // 创建线路走向
  500 + polyUpline01 = new BMap.Polyline(polylineArray, {
  501 + strokeColor: "red",
  502 + strokeWeight: 6,
  503 + strokeOpacity: 0.7
  504 + });
  505 + polyUpline01.data = data;
  506 + polyUpline01.ct_source = '1';
  507 + // 把折线添加到地图上
  508 + mapBValue.addOverlay(polyUpline01);
  509 + // 聚焦事件
  510 + polyUpline01.addEventListener('mousemove', function (e) {
  511 + if (this != editPolyline)
  512 + this.setStrokeColor("#20bd26");
  513 + });
  514 + // 失去焦点
  515 + polyUpline01.addEventListener('mouseout', function (e) {
  516 + if (this != editPolyline && this != road_win_show_p)
  517 + this.setStrokeColor("red");
  518 + });
  519 + // 添加单击事件
  520 + polyUpline01.addEventListener('onclick', function (e) {
  521 + // 打开信息窗口
  522 + if (map_status != 1)
  523 + WorldsBMap.openSectionInfoWin(this);
  524 + });
  525 + sectionArray.push(polyUpline01);
  526 + }
  527 + // mapBValue.setCenter(polyline_center);
  528 + // mapBValue.panTo(polyline_center);
  529 + // mapBValue.setZoom(14);
  530 + // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增)
  531 + // polyUpline01.disableMassClear();
  532 + }
  533 + },
  534 +
  535 + /** 在地图上画点 @param:<point_center:中心坐标点> */
  536 + drawingUpStationPoint: function (station, s) {
  537 + // 中心点坐标字符串
  538 + var bJwpointsStr = station.stationJwpoints;
  539 + var stationName = station.stationRouteName;
  540 + // 起个中心点坐标字符串
  541 + var bJwpointsArray = bJwpointsStr.split(' ');
  542 + // 设置中心点
  543 + var point_center = new BMap.Point(bJwpointsArray[0],bJwpointsArray[1]);
  544 + // 自定义标注物图片
  545 + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png', new BMap.Size(10, 10));
  546 +
  547 + var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">'
  548 + + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">'
  549 + + '</div>'
  550 + + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">' + s + '</span>' + stationName + '</label>';
  551 +
  552 + var myRichMarker1 = new BMapLib.RichMarker(html2, point_center, {
  553 + "title": stationName,
  554 + "anchor": new BMap.Size(-10, 8),
  555 + "enableDragging": true
  556 + });
  557 + myRichMarker1.disableDragging();
  558 + myRichMarker1.ct_source = '1';
  559 + mapBValue.addOverlay(myRichMarker1);
  560 + myRichMarker1.addEventListener('click', function () {
  561 + if(map_status != 1)
  562 + WorldsBMap.openStationInfoWin(station);
  563 + });
  564 + stationArray[station.stationRouteId] = station;
  565 + stationMarkers[station.stationRouteId] = myRichMarker1;
  566 + },
  567 +
  568 + // 站点名称获取百度坐标(手动规划)
  569 + stationsNameToPoints: function (arra, callback) {
  570 + // 获取长度
  571 + var len = arra.length;
  572 + var stationList = [];
  573 + (function () {
  574 + if (!arguments.callee.count) {
  575 + arguments.callee.count = 0;
  576 + }
  577 + arguments.callee.count++;
  578 + var index = parseInt(arguments.callee.count) - 1;
  579 + if (index >= len) {
  580 + callback && callback(stationList);
  581 + return;
  582 + }
  583 + var f = arguments.callee;
  584 + if (arra[index].name != '') {
  585 + var localSearch = new BMap.LocalSearch(mapBValue);
  586 + localSearch.search(arra[index].name);
  587 + localSearch.setSearchCompleteCallback(function (searchResult) {
  588 + var poi = searchResult.getPoi(0);
  589 + if (poi) {
  590 + stationList.push({
  591 + name: arra[index].name.replace('公交车站', ''),
  592 + wgs: arra[index].wgs,
  593 + potion: {lng: poi.point.lng, lat: poi.point.lat}
  594 + });
  595 + } else {
  596 + stationList.push({
  597 + name: arra[index].name.replace('公交车站', ''),
  598 + wgs: arra[index].wgs,
  599 + potion: {lng: arra[index].wgs.x, lat: arra[index].wgs.y}
  600 + });
  601 + }
  602 + f();
  603 + });
  604 + } else {
  605 + f();
  606 + }
  607 + })();
  608 + },
  609 +
  610 + // 根据坐标点获取两点之间的时间与距离(手动规划)
  611 + getDistanceAndTotime: function (stationList, cb) {
  612 + stationList[0].distance = '';
  613 + stationList[0].duration = '';
  614 + // var sectionList = [];
  615 + // 获取长度
  616 + var len = stationList.length;
  617 + (function () {
  618 + if (!arguments.callee.count) {
  619 + arguments.callee.count = 0;
  620 + }
  621 + arguments.callee.count++;
  622 + var index = parseInt(arguments.callee.count) - 1;
  623 + if (index >= len - 1) {
  624 + // cb && cb(stationList,sectionList);
  625 + cb && cb(stationList);
  626 + return;
  627 + }
  628 + var f = arguments.callee;
  629 + var poiOne = new BMap.Point(stationList[index].potion.lng, stationList[index].potion.lat);
  630 + var poiTwo = new BMap.Point(stationList[index + 1].potion.lng, stationList[index + 1].potion.lat);
  631 + var transit = new BMap.TransitRoute(mapBValue, {
  632 + renderOptions: {map: mapBValue},
  633 + onSearchComplete: searchComplete
  634 + });
  635 +
  636 + transit.search(poiOne, poiTwo);
  637 + function searchComplete(results) {
  638 + var plan = results.getPlan(0);
  639 + if (transit.getStatus() != BMAP_STATUS_SUCCESS) {
  640 + stationList[index + 1].distance = '';
  641 + stationList[index + 1].duration = '';
  642 + // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:''});
  643 + } else {
  644 + stationList[index + 1].distance = plan.getDistance(true);
  645 + stationList[index + 1].duration = plan.getDuration(true);
  646 + // var line = plan.getRoute(0);
  647 + // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:line.getPath()});
  648 + }
  649 + f();
  650 + }
  651 + })();
  652 + },
  653 +
  654 + // 根据坐标点获取两点之间的折线路段(手动规划)
  655 + getSectionListPlonly: function (stationsPoint, cb) {
  656 + var len = stationsPoint.length;
  657 + var sectionList = [];
  658 + (function () {
  659 + if (!arguments.callee.count) {
  660 + arguments.callee.count = 0;
  661 + }
  662 + arguments.callee.count++;
  663 + var index = parseInt(arguments.callee.count) - 1;
  664 + if (index >= len - 1) {
  665 + cb && cb(sectionList);
  666 + return;
  667 + }
  668 + var f = arguments.callee;
  669 + var poiOne = new BMap.Point(stationsPoint[index].potion.lng, stationsPoint[index].potion.lat);
  670 + var poiTwo = new BMap.Point(stationsPoint[index + 1].potion.lng, stationsPoint[index + 1].potion.lat);
  671 + /* var transit = new BMap.TransitRoute(mapB, {renderOptions: {map: mapB},onPolylinesSet: searchPolylinesSet});*/
  672 + var transit = new BMap.DrivingRoute(mapBValue, {
  673 + renderOptions: {map: mapBValue},
  674 + onPolylinesSet: searchPolylinesSet
  675 + });
  676 + function searchPolylinesSet(results) {
  677 + if (transit.getStatus() != BMAP_STATUS_SUCCESS) {
  678 + } else {
  679 + var sectionArrayList = [];
  680 + for (i = 0; i < results.length; i++) {
  681 + // console.log(results[i].getPolyline().getPath());
  682 + sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath());
  683 + }
  684 + var sectionName = stationsPoint[index].name + '至' + stationsPoint[index + 1].name;
  685 + sectionList.push({sectionName: sectionName, points: sectionArrayList});
  686 + }
  687 + f();
  688 + }
  689 + transit.search(poiOne, poiTwo);
  690 + })();
  691 + },
  692 +
  693 + localtionPoint: function (stationNameV) {
  694 + // 关闭信息窗口
  695 + mapBValue.closeInfoWindow();
  696 + WorldsBMap.localSearchFromAdreesToPoint(stationNameV, function (Points) {
  697 + if (Points) {
  698 + var BJwpointsArray = Points.split(' ');
  699 + var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]);
  700 + var marker_stargt2 = new BMap.Marker(stationNameChangePoint);
  701 + mapBValue.panTo(stationNameChangePoint);
  702 + // 将标注添加到地图中
  703 + mapBValue.addOverlay(marker_stargt2);
  704 + //跳动的动画
  705 + marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE);
  706 + }
  707 + });
  708 + },
  709 +
  710 + /** 系统规划抓去数据 @param lineNameValue:线路名称;i:方向*/
  711 + getBmapStationNames: function (lineNameValue, i, callback) {
  712 + var busline = new BMap.BusLineSearch(mapBValue, {
  713 + // 设置公交列表查询后的回调函数。参数:rs: BusListResult类型
  714 + onGetBusListComplete: function (BusListResult) {
  715 + // 如果不为空
  716 + if (BusListResult) {
  717 + //获取第一个公交列表显示到map上
  718 + var fstLine = BusListResult.getBusListItem(i);
  719 + if (fstLine == undefined) {
  720 + callback && callback(null);
  721 + }
  722 + busline.getBusLine(fstLine);
  723 + }
  724 + },
  725 + //设置公交线路查询后的回调函数.参数:rs: BusLine类型
  726 + onGetBusLineComplete: function (BusLine) {
  727 + // 如果不为空
  728 + if (BusLine) {
  729 + callback && callback(BusLine);
  730 + }
  731 + }
  732 + });
  733 + busline.getBusList(lineNameValue);
  734 + },
  735 + // 修改站点
  736 + editStation: function (stationRouteId) {
  737 + // $.get("/stationroute/findStationRouteInfo",{"id":stationRouteId},function (route) {
  738 + $.get('edit_select.html', function (m) {
  739 + $(pjaxContainer).append(m);
  740 + $('#edit_select_mobal').trigger('editSelectMobal_show', [WorldsBMap, DrawingManagerObj, GetAjaxData, EditStationObj, LineObj, PublicFunctions, stationArray[stationRouteId]]);
  741 + });
  742 + // });
  743 + },
  744 + addBetweenStationRoad: function (stationRouteId) {
  745 + var version = $("#versions").val();
  746 + // 关闭信息窗口
  747 + mapBValue.closeInfoWindow();
  748 + $.get("/stationroute/findStationRouteInfo", {"id": stationRouteId,"version":version}, function (route) {
  749 + var stationRouteBegin = route[0];
  750 + // 查询下一个站点
  751 + $.get("/stationroute/findDownStationRoute", {
  752 + "lineId": stationRouteBegin.stationRouteLine,
  753 + "direction": stationRouteBegin.stationRoutedirections,
  754 + "stationRouteCode": stationRouteBegin.stationRouteCode,
  755 + "version":version
  756 + }, function (stationRoute) {
  757 + var stationRouteFinish = stationRoute[0];
  758 +
  759 + if (stationRouteFinish) {
  760 + var pointBegin = stationRouteBegin.stationJwpoints.split(" ");
  761 + var pointFinish = stationRouteFinish.stationJwpoints.split(" ")
  762 + var sectionList = [];
  763 + // 两个站点的坐标
  764 + var poiOne = new BMap.Point(pointBegin[0], pointBegin[1]);
  765 + var poiTwo = new BMap.Point(pointFinish[0], pointFinish[1]);
  766 + // 路径规划保存按钮
  767 + var label = new BMap.Label("保存路段", {
  768 + offset: new BMap.Size(13, -53)
  769 + });
  770 + label.setStyle({
  771 + color: '#fff',
  772 + background: "url(/pages/base/stationroute/css/img/bg.png)",
  773 + border: '0px solid',
  774 + textAlign: "center",
  775 + height: "28px",
  776 + lineHeight: "26px",
  777 + width: "80px",
  778 + maxWidth: "none"
  779 + });
  780 + label.addEventListener('click', function () {
  781 + var params = {};
  782 + params.lineId = stationRouteBegin.stationRouteLine;
  783 + params.lineCode = stationRouteBegin.stationRouteLIneCode;
  784 + params.directions = stationRouteBegin.stationRoutedirections;
  785 + params.stationRouteBegin = stationRouteBegin.stationRouteName;
  786 + params.stationRouteFinish = stationRouteFinish.stationRouteName;
  787 + layer.confirm('确定保存', {
  788 + btn : [ '路段调整好了','继续调整','退出'], icon: 3, title:'提示'
  789 + ,btn3: function(index, layero){
  790 + PublicFunctions.resjtreeDate(params.lineId,params.directions);
  791 + PublicFunctions.editAChangeCssRemoveDisabled();
  792 +// GetAjaxData.getSectionRouteInfo(params.lineId,params.directions,function(data) {
  793 +// PublicFunctions.linePanlThree(params.lineId,data,params.directions);
  794 +// });
  795 + PublicFunctions.editMapStatusRemove();
  796 + }
  797 + }, function(index, layero){
  798 + layer.close(index);
  799 + params.route = $("#routePlanning").val();
  800 + $.get('doublename_road.html', function (m) {
  801 + $(pjaxContainer).append(m);
  802 + $('#doublename_road_mobal').trigger('doubleNameRoadMobal_show', [params, WorldsBMap, GetAjaxData, PublicFunctions]);
  803 + });
  804 + PublicFunctions.editMapStatusRemove();
  805 + });
  806 + });
  807 + // 路径规划
  808 + var transit = new BMap.DrivingRoute(mapBValue, {
  809 + renderOptions: {
  810 + map: mapBValue,
  811 + enableDragging: true
  812 + },
  813 + onPolylinesSet: searchPolylinesSet
  814 + });
  815 +
  816 + function searchPolylinesSet(results) {
  817 + if (transit.getStatus() == BMAP_STATUS_SUCCESS) {
  818 + var sectionArrayList = [];
  819 + for (i = 0; i < results.length; i++) {
  820 + sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath());
  821 + }
  822 + sectionList = sectionArrayList;//JSON.stringify()
  823 + $("#routePlanning").val(JSON.stringify(sectionArrayList));
  824 + var pointMap = new Map();
  825 + pointMap = sectionArrayList[sectionArrayList.length - 1];
  826 + var pointLabel = new BMap.Point(pointMap.lng, pointMap.lat);
  827 + label.enableMassClear();
  828 + label.setPosition(pointLabel);
  829 + mapBValue.addOverlay(label);
  830 + }
  831 + }
  832 + transit.search(poiOne, poiTwo);
  833 + transit.disableAutoViewport();
  834 + // 地图编辑状态
  835 + PublicFunctions.editMapStatus(stationRouteFinish.stationRoutedirections);
  836 + } else {
  837 + layer.msg("您选择的站点后没有站点了,不能生成站点间路段!")
  838 + }
  839 +
  840 + });
  841 + });
  842 +
  843 + },
  844 + // 匹配外部站点行业编码
  845 + editIndustryCode: function (stationId) {
  846 + var station = stationArray[stationId];
  847 + $.get('/stationroute/matchNearbyStation',station,function (data) {
  848 + if(data.status == "SUCCESS"){
  849 + // 关闭信息窗口
  850 + mapBValue.closeInfoWindow();
  851 + var list = data.matchList,
  852 + i = 1;
  853 + // for (var s in list) {
  854 + if(list.length <= 0){
  855 + layer.msg("很遗憾没有匹配到站点!!!");
  856 + return;
  857 + }
  858 +
  859 + // 进入编辑状态
  860 + PublicFunctions.editMapStatus(station.stationRoutedirections);
  861 + list.forEach(function (s) {
  862 + s.stationRouteId = station.stationRouteId;
  863 + s.directions = station.stationRoutedirections;
  864 + s.lineId = station.stationRouteLine;
  865 + var BJwpointsArray = s.bJwpoints.split(' ');
  866 + var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]);
  867 + var marker_stargt2 = new BMap.Marker(stationNameChangePoint);
  868 +
  869 + var label = new BMap.Label(i++,{offset:new BMap.Size(i>9?0:4,0)});
  870 + label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});
  871 + marker_stargt2.setLabel(label);
  872 + marker_stargt2.addEventListener('click', function () {
  873 + WorldsBMap.openMatchStationInfoWin(s);
  874 + });
  875 +
  876 + // 将标注添加到地图中
  877 + mapBValue.addOverlay(marker_stargt2);
  878 + });
  879 + var BJwpoints = station.stationJwpoints.split(' ');
  880 + mapBValue.centerAndZoom(new BMap.Point(BJwpoints[0], BJwpoints[1]), 18);
  881 + layer.msg("为您匹配到"+list.length+"个站点,选择红点标记的点,进行匹配!");
  882 + }
  883 + });
  884 + },
  885 + // 应用行业编码
  886 + citeIndustryCode: function (stationRouteId) {
  887 + if(matchStation.stationRouteId == stationRouteId){
  888 + var station = matchStation;
  889 + var keys = "dis_"+station.stationRouteId;
  890 + var params = {status:$($("#versions").find("option:selected")[0]).attr("status")};
  891 + // var params = new Map();
  892 + params[keys] = station.stationStandardCode;
  893 + // params.set(keys,station.stationStandardCode);
  894 + $.post('/stationroute/updIndustryCode',params,function (data) {
  895 + Bmap.closeMobleSetClean(station);
  896 + if(data.status == "SUCCESS"){
  897 + layer.msg("应用成功!!")
  898 + }else {
  899 + layer.msg("应用失败....")
  900 + }
  901 + });
  902 + }
  903 + },
  904 + // 清楚覆盖物,定位站点
  905 + closeMobleSetClean: function(station) {
  906 + var dir = station.directions;
  907 + var lineId = station.lineId; // map.clearMarkAndOverlays();
  908 +
  909 + Bmap.clearMarkAndOverlays();
  910 + // 刷新左边树
  911 + PublicFunctions.resjtreeDate(lineId,dir,$("#versions").val());
  912 + /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:路段数据 */
  913 +// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data1) {
  914 +// /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
  915 +// PublicFunctions.linePanlThree(lineId,data1,dir);
  916 +// });
  917 +
  918 + // 退出编辑状态
  919 + PublicFunctions.editMapStatusRemove();
  920 + },
  921 + // 定位路段
  922 + focusSection: function(sectionRoudId) {
  923 + for (var i = 0, p; p = sectionArray[i++];) {
  924 + if (p.data.sectionrouteId == sectionRoudId) {
  925 + WorldsBMap.openSectionInfoWin(p);
  926 + break;
  927 + }
  928 + }
  929 + },
  930 + // 路段编辑
  931 + editSection : function(sectionRoudId,dir) {
  932 + layer.confirm('进入编辑状态', {
  933 + btn : [ '确定','返回' ], icon: 3, title:'提示'
  934 + }, function() {
  935 + PublicFunctions.editMapStatus(dir);
  936 + layer.msg('双击保存路段');
  937 + var p;
  938 + for (var i = 0; p = sectionArray[i++];) {
  939 + if (p.data.sectionrouteId == sectionRoudId) {
  940 + mapBValue.closeInfoWindow();//关闭infoWindow
  941 + p.enableEditing();
  942 + p.setStrokeColor('blue');
  943 + editPolyline = p;
  944 + break;
  945 + }
  946 + }
  947 + // 路段中间点为中心
  948 + var section = p.data;
  949 + var sectionStr = section.sectionBsectionVector.substring(11, section.sectionBsectionVector.length - 1);
  950 + // 分割折线坐标字符串
  951 + var lineArray = sectionStr.split(',');
  952 + var sectionPointArray = [];
  953 + for (var i = 0; i < lineArray.length; i++) {
  954 + sectionPointArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1]));
  955 + }
  956 + // 计算中间点
  957 + var index = parseInt(sectionPointArray.length / 2);
  958 + var centerPoint = sectionPointArray[index];
  959 + mapBValue.centerAndZoom(centerPoint, 17);
  960 + // var c = p.ia[Math.floor(p.ia.length/2)];
  961 + // mapBValue.centerAndZoom(new BMap.Point(c.lng, c.lat), 18);
  962 + p.addEventListener('dblclick', function () {
  963 + /** 设置修改路段集合对象为空 */
  964 + editPolyline = '';
  965 + PublicFunctions.editMapStatusRemove();
  966 + $.get('editsection.html', function(m){
  967 + $('body').append(m);
  968 + $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap,GetAjaxData,p,PublicFunctions]);
  969 + });
  970 + });
  971 + });
  972 + },
  973 + // 添加第一个路段
  974 + addSection : function(stecion) {
  975 + PublicFunctions.editMapStatus();
  976 + // 把数据填充到模版中
  977 + var addSectionHTML = template('add_draw_polyline-temp');
  978 + $('body .mian-portlet-body').append(addSectionHTML);
  979 + //暂停和开始绘制
  980 + $('.draw_polyline_switch>a').on('click', function () {
  981 + var t = $(this).text();
  982 + if(t=='暂停绘制'){
  983 + WorldsBMap.exitDrawStatus();
  984 + $(this).text('开始绘制');
  985 + }
  986 + else{
  987 + WorldsBMap.openDrawStatus();
  988 + $(this).text('暂停绘制');
  989 + }
  990 + });
  991 + // 开启绘制事件
  992 + WorldsBMap.showAddSectionPanel(stecion);
  993 +
  994 + //取消
  995 + $('#addSectionCancelBtn').on('click', function () {
  996 + $('.main_left_panel_m_layer').hide();
  997 + $(this).parents('.buffer_edit_body').parent().remove();
  998 + WorldsBMap.exitDrawStatus();
  999 + PublicFunctions.editMapStatusRemove();
  1000 + });
  1001 +
  1002 + //确定
  1003 + $('#addSectionSbmintBtn').on('click', function () {
  1004 + var btn = this;
  1005 + $('#addSectionSbmintBtn').addClass("disabled");
  1006 + var sectionName = $('#sectionNameInput').val();
  1007 + var bsectionVector = $('#bsectionVectorInput').val();
  1008 + var params = {};
  1009 + if(sectionName && bsectionVector) {
  1010 + WorldsBMap.exitDrawStatus();
  1011 + GetAjaxData.getSectionCode(function(sectionCode) {
  1012 + var lineId = stecion.lineId;
  1013 + var dir = stecion.dir;
  1014 + params.lineId = lineId;
  1015 + params.lineCode = stecion.lineCode;
  1016 + params.sectionCode = sectionCode;// 设值路段编码.
  1017 + params.sectionName = sectionName;
  1018 + params.roadCoding = '';
  1019 + params.dbType = 'b';
  1020 + params.bsectionVector = bsectionVector;
  1021 + params.sectionrouteCode = 1;
  1022 + params.sectionTime = 0;
  1023 + params.sectionDistance = 60;
  1024 + params.speedLimit = 0;
  1025 + params.versions = stecion.versions;
  1026 + params.destroy = 0;
  1027 + params.directions = dir;
  1028 + params.descriptions = '';
  1029 +
  1030 + params.status=$($("#versions").find("option:selected")[0]).attr("status");
  1031 + GetAjaxData.sectionSave(params, function (result) {
  1032 + if(result.status =="SUCCESS"){
  1033 + $('.main_left_panel_m_layer').hide();
  1034 + $(btn).parents('.buffer_edit_body').parent().remove();
  1035 + PublicFunctions.editMapStatusRemove();
  1036 + PublicFunctions.resjtreeDate(lineId,dir,$("#versions").val());
  1037 + PublicFunctions.editAChangeCssRemoveDisabled();
  1038 +// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {
  1039 +// PublicFunctions.linePanlThree(lineId,data,dir);
  1040 +// });
  1041 + layer.msg("添加成功!");
  1042 + } else if(result.status =="ERROR") {
  1043 + layer.msg("添加失败!");
  1044 + }
  1045 + });
  1046 + });
  1047 + } else if(!sectionName){
  1048 + layer.msg('请填写路段名字!');
  1049 + } else if(!bsectionVector){
  1050 + layer.msg('请先绘制路段!');
  1051 + }
  1052 + setTimeout(function () {
  1053 + $("#addSectionSbmintBtn").removeClass("disabled");
  1054 + },1000);
  1055 + });
  1056 + },
  1057 + // 添加在路段之后
  1058 + addSectionAfter : function(sectionRoudId) {
  1059 + //order = after before;
  1060 + var beforeSection;
  1061 + // 关闭信息窗口
  1062 + mapBValue.closeInfoWindow();
  1063 + PublicFunctions.editMapStatus();
  1064 + // 把数据填充到模版中
  1065 + var addSectionHTML = template('add_draw_polyline-temp',{ 'id': sectionRoudId});
  1066 + $('body .mian-portlet-body').append(addSectionHTML);
  1067 + //暂停和开始绘制
  1068 + $('.draw_polyline_switch>a').on('click', function () {
  1069 + var t = $(this).text();
  1070 + if(t=='暂停绘制'){
  1071 + WorldsBMap.exitDrawStatus();
  1072 + $(this).text('开始绘制');
  1073 + }
  1074 + else{
  1075 + WorldsBMap.openDrawStatus();
  1076 + $(this).text('暂停绘制');
  1077 + }
  1078 + });
  1079 +
  1080 + //取消
  1081 + $('#addSectionCancelBtn').on('click', function () {
  1082 + $('.main_left_panel_m_layer').hide();
  1083 + $(this).parents('.buffer_edit_body').parent().remove();
  1084 + WorldsBMap.exitDrawStatus();
  1085 + PublicFunctions.editMapStatusRemove();
  1086 + });
  1087 + GetAjaxData.getSectionRouteInfoById(sectionRoudId, function(data){
  1088 + WorldsBMap.showAddSectionPanel(data[0]);
  1089 + beforeSection = data[0];
  1090 + });
  1091 +
  1092 + //确定
  1093 + $('#addSectionSbmintBtn').on('click', function () {
  1094 + var btn = this;
  1095 + $('#addSectionSbmintBtn').addClass("disabled");
  1096 + var sectionName = $('#sectionNameInput').val();
  1097 + var bsectionVector = $('#bsectionVectorInput').val();
  1098 + var params = {};
  1099 + if(sectionName && bsectionVector) {
  1100 + WorldsBMap.exitDrawStatus();
  1101 + GetAjaxData.getSectionCode(function(sectionCode) {
  1102 + var lineId = beforeSection.sectionRouteLine
  1103 + var dir = beforeSection.sectionRouteDirections
  1104 + params.lineId = lineId;
  1105 + params.lineCode = beforeSection.sectionRouteLineCode;
  1106 + params.sectionCode = sectionCode;// 设值路段编码.
  1107 + params.sectionName = sectionName;
  1108 + params.roadCoding = '';
  1109 + params.dbType = 'b';
  1110 + params.bsectionVector = bsectionVector;
  1111 + params.sectionrouteCode = beforeSection.sectionRouteCode+"_0";
  1112 + params.sectionTime = 0;
  1113 + params.sectionDistance = 60;
  1114 + params.speedLimit = 0;
  1115 + params.versions = beforeSection.sectionRouteVersions;
  1116 + params.destroy = 0;
  1117 + params.directions = dir;
  1118 + params.descriptions = '';
  1119 + params.status=$($("#versions").find("option:selected")[0]).attr("status");
  1120 +
  1121 + GetAjaxData.sectionSave(params, function (result) {
  1122 + if(result.status =="SUCCESS"){
  1123 + $('.main_left_panel_m_layer').hide();
  1124 + $(btn).parents('.buffer_edit_body').parent().remove();
  1125 + PublicFunctions.editMapStatusRemove();
  1126 + PublicFunctions.resjtreeDate(lineId,dir,$("#versions").val());
  1127 + PublicFunctions.editAChangeCssRemoveDisabled();
  1128 +// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {
  1129 +// PublicFunctions.linePanlThree(lineId,data,dir);
  1130 +// });
  1131 + layer.msg("添加成功!");
  1132 + } else if(result.status =="ERROR") {
  1133 + layer.msg("添加失败!");
  1134 + }
  1135 + });
  1136 + });
  1137 + } else if(!sectionName){
  1138 + layer.msg('请填写路段名字!');
  1139 + } else if(!bsectionVector)
  1140 + layer.msg('请先绘制路段!');
  1141 + setTimeout(function () {
  1142 + $("#addSectionSbmintBtn").removeClass("disabled");
  1143 + },1000);
  1144 + });
  1145 + },
  1146 + // 撤销站点
  1147 + destroyStation : function(stationRouteId,lineId,dir) {
  1148 + layer.confirm('你确定要撤销此站点吗?', {
  1149 + btn : [ '撤销','返回' ], icon: 3, title:'提示'
  1150 + }, function(){
  1151 +
  1152 + var status = $($("#versions").find("option:selected")[0]).attr("status");
  1153 +
  1154 + $.post('/stationroute/stationRouteIsDestroy',{'stationRouteId':stationRouteId,destroy:'1',status:status},function(resuntDate) {
  1155 + if (resuntDate.status == 'SUCCESS') {
  1156 + // 弹出添加成功提示消息
  1157 + layer.msg('撤销成功!');
  1158 + } else {
  1159 + // 弹出添加失败提示消息
  1160 + layer.msg('撤销失败!');
  1161 + }
  1162 + // 刷新左边树
  1163 + var version = $("#verions").val();
  1164 + PublicFunctions.resjtreeDate(lineId,dir,version);
  1165 + /** 查询路段信息 @param:<Line.id:线路Id;delBatch.dir:方向> @return:data:路段数据 */
  1166 +// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {
  1167 +// /** 在地图上画出线路走向 @param:<Line.id:线路Id;delBatch.dir:方向;data:路段数据> */
  1168 +// PublicFunctions.linePanlThree(lineId,data,dir);
  1169 +// });
  1170 + });
  1171 + });
  1172 + },
  1173 + // 撤销路段
  1174 + destroySection : function(sectionRoudId,lineId,dir) {
  1175 + layer.confirm('你确定要撤销此路段吗?', {
  1176 + btn : [ '撤销','返回' ], icon: 3, title:'提示'
  1177 + }, function(){
  1178 + var status = $($("#versions").find("option:selected")[0]).attr("status");
  1179 + $.post('/sectionroute/destroy',{'id': sectionRoudId,status:status},function(resuntDate) {
  1180 + if (resuntDate.status == 'SUCCESS') {
  1181 + // 弹出添加成功提示消息
  1182 + layer.msg('撤销成功!');
  1183 + } else {
  1184 + // 弹出添加失败提示消息
  1185 + layer.msg('撤销失败!');
  1186 + }
  1187 + // 刷新左边树
  1188 + var version = $("#verions").val();
  1189 + PublicFunctions.resjtreeDate(lineId,dir,version);
  1190 + /** 查询路段信息 @param:<Line.id:线路Id;delBatch.dir:方向> @return:data:路段数据 */
  1191 +// GetAjaxData.getSectionRouteInfo(lineId,dir,function(data) {
  1192 +// /** 在地图上画出线路走向 @param:<Line.id:线路Id;delBatch.dir:方向;data:路段数据> */
  1193 +// PublicFunctions.linePanlThree(lineId,data,dir);
  1194 +// });
  1195 + });
  1196 + });
  1197 + },
  1198 + // 打开路段信息窗口
  1199 + openSectionInfoWin : function(p) {
  1200 + var section = p.data;
  1201 + var dir = section.sectionrouteDirections;
  1202 + var width = WorldsBMap.strGetLength(section.sectionName) * 10;
  1203 + // 信息窗口参数属性
  1204 + var opts = {
  1205 + // 信息窗口宽度
  1206 + width: (width < 200 ? 200 : width),
  1207 + // 信息窗口高度
  1208 + height: 150,
  1209 + //设置不允许信窗发送短息
  1210 + enableMessage: false,
  1211 + //是否开启点击地图关闭信息窗口
  1212 + enableCloseOnClick: false,
  1213 + // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)
  1214 + enableAutoPan: false
  1215 + };
  1216 + var htm = '<span style="color: #ff8355;font-size: 18px;">' + section.sectionName + '</span>' +
  1217 + '<span class="help-block" >路段编码:' + section.sectionCode + '</span>' +
  1218 + '<span class="help-block" >路段序号:' + section.sectionrouteCode + '</span>' +
  1219 + '<span class="help-block" >版本号&nbsp&nbsp:' + section.versions + '</span>' +
  1220 + '<div >';
  1221 +
  1222 + if($($("#versions").find("option:selected")[0]).attr("status") > 0){
  1223 + htm += '<button class="info_win_btn" id="editStation" onclick="WorldsBMap.editSection(' + section.sectionrouteId +','+dir+ ')">修改</button>' +
  1224 + '<button class="info_win_btn" id="addBetweenStationRoad" onclick="WorldsBMap.destroySection('+ section.sectionrouteId + ','+section.sectionrouteLine+','+section.sectionrouteDirections+')">撤销</button>' +
  1225 + '<button class="info_win_btn" id="addSectionAfter" onclick="WorldsBMap.addSectionAfter('+section.sectionrouteId+')">添加路段(之后)</button>' +
  1226 + '</div>';
  1227 + }
  1228 +
  1229 + // 创建信息窗口
  1230 + var infoWindow_target = new BMap.InfoWindow(htm, opts);
  1231 + // 切割段折线坐标字符串
  1232 + var sectionStr = section.sectionBsectionVector.substring(11, section.sectionBsectionVector.length - 1);
  1233 + // 分割折线坐标字符串
  1234 + var lineArray = sectionStr.split(',');
  1235 + var sectionArray = [];
  1236 + for (var i = 0; i < lineArray.length; i++) {
  1237 + sectionArray.push(new BMap.Point(lineArray[i].split(' ')[0], lineArray[i].split(' ')[1]));
  1238 + }
  1239 + // 计算中间点
  1240 + var index = parseInt(sectionArray.length / 2);
  1241 + var centerPoint = sectionArray[index];
  1242 + //close event
  1243 + infoWindow_target.addEventListener('close', function (e) {
  1244 + p.setStrokeColor("red");
  1245 + road_win_show_p = null;
  1246 + });
  1247 + //open event
  1248 + infoWindow_target.addEventListener('open', function (e) {
  1249 + p.setStrokeColor("#20bd26");
  1250 + road_win_show_p = p;
  1251 + });
  1252 + //开启信息窗口
  1253 + mapBValue.openInfoWindow(infoWindow_target, centerPoint);
  1254 + mapBValue.panTo(centerPoint);
  1255 + },
  1256 + /**
  1257 + * 绘制新增路段
  1258 + * @param section
  1259 + */
  1260 + showAddSectionPanel : function (section) {
  1261 + var point;
  1262 + if(section){
  1263 + var sectionBsectionVectorStr = section.sectionBsectionVector;
  1264 + var line = sectionBsectionVectorStr.substring(11, sectionBsectionVectorStr.length - 1),
  1265 + points = line.split(','),
  1266 + pointStr = points[points.length-1].split(' ');
  1267 +
  1268 + point = new BMap.Point(pointStr[0], pointStr[1]);
  1269 + }
  1270 +
  1271 + mapBValue.centerAndZoom(point, 18);
  1272 +
  1273 + //开启鼠标绘制
  1274 + drawingManager = new BMapLib.DrawingManager(mapBValue, {
  1275 + polylineOptions: styleOptions
  1276 + });
  1277 +
  1278 + drawingManager.open();
  1279 + //drawingManager.enableCalculate();
  1280 + drawingManager.setDrawingMode('polyline');
  1281 +
  1282 + //绘制完成
  1283 + drawingManager.addEventListener('polylinecomplete', function (e) {
  1284 + console.log('eee', e, e.getPath());
  1285 + drawingManager.close();
  1286 +
  1287 + var polyline = new BMap.Polyline(e.getPath(), {strokeWeight: 7, strokeColor: 'blue', strokeOpacity: 0.7});
  1288 +
  1289 + mapBValue.removeOverlay(e);
  1290 + mapBValue.addOverlay(polyline);
  1291 + polyline.enableEditing();
  1292 +
  1293 + editPolyline = polyline;
  1294 + var sectionData = e.getPath();// 获取折线坐标集合
  1295 + $('#bsectionVectorInput').val(JSON.stringify(sectionData));
  1296 + });
  1297 + },
  1298 + exitDrawStatus : function () {
  1299 + if (drawingManager) {
  1300 + $('#bsectionVectorInput').val("");
  1301 + WorldsBMap.clearOtherOverlay();
  1302 + drawingManager.close();
  1303 + }
  1304 + },
  1305 + openDrawStatus : function () {
  1306 + if (drawingManager) {
  1307 + $('#bsectionVectorInput').val("");
  1308 + WorldsBMap.clearOtherOverlay();
  1309 + drawingManager.open();
  1310 + }
  1311 + },
  1312 + /** 清楚无需要的覆盖物(非站点/路段数据源)*/
  1313 + clearOtherOverlay : function () {
  1314 + var all = mapBValue.getOverlays();
  1315 + for (var i = 0, obj; obj = all[i++];) {
  1316 + if (obj.ct_source && obj.ct_source == '1')
  1317 + continue;
  1318 + mapBValue.removeOverlay(obj);
  1319 + }
  1320 + },
  1321 + clearMarkAndOverlays: function () {
  1322 + // 清楚地图覆盖物
  1323 + mapBValue.clearOverlays();
  1324 + mapBValue.removeOverlay();
  1325 + },
  1326 + clearMark: function () {
  1327 + // 清楚地图覆盖物
  1328 + mapBValue.removeOverlay();
  1329 + },
  1330 + strGetLength: function (str) {
  1331 + return str.replace(/[\u0391-\uFFE5]/g, "aa").length; //先把中文替换成两个字节的英文,在计算长度
  1332 + },
  1333 + stationsPointsToLibraryPoint : function(arra,callback) {
  1334 + // 获取长度
  1335 + var len = arra.length;
  1336 + var station = {};
  1337 + var stationList = [];
  1338 + (function(){
  1339 + if (!arguments.callee.count) {
  1340 + arguments.callee.count = 0;
  1341 + }
  1342 + arguments.callee.count++;
  1343 + var index = parseInt(arguments.callee.count) - 1;
  1344 + if (index >= len) {
  1345 + callback && callback(stationList);
  1346 + return ;
  1347 + }
  1348 + var f = arguments.callee;
  1349 + station = arra[index];
  1350 + if(arra[index].name!=''){
  1351 +
  1352 + $.get('/station/matchStation',station,function(resultStation) {
  1353 + stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id});
  1354 + f();
  1355 + });
  1356 + }else {
  1357 + f();
  1358 + }
  1359 + })()
  1360 + },
  1361 + /** 获取距离与时间 @param <points:坐标点集合> */
  1362 + getDistanceAndDuration : function(points,callback){
  1363 +
  1364 + // 获取长度
  1365 + var len = points.length;
  1366 + (function(){
  1367 +
  1368 + if (!arguments.callee.count) {
  1369 +
  1370 + arguments.callee.count = 0;
  1371 +
  1372 + }
  1373 +
  1374 + arguments.callee.count++;
  1375 +
  1376 + var index = parseInt(arguments.callee.count) - 1;
  1377 +
  1378 + if (index >= len-1) {
  1379 + callback && callback(points);
  1380 +
  1381 + return;
  1382 + }
  1383 +
  1384 + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。)
  1385 + var f = arguments.callee;
  1386 + // 起点坐标 <坐标格式:40.056878,116.30815>
  1387 + var origin = points[index].potion.lat + ',' + points[index].potion.lng;
  1388 +
  1389 + // 终点坐标 <坐标格式:40.056878,116.30815>
  1390 + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng;
  1391 + var region = '上海';
  1392 +
  1393 + var origin_region = '上海';
  1394 +
  1395 + var destination_region = '上海';
  1396 +
  1397 + var output = 'json';
  1398 +
  1399 + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk';
  1400 +
  1401 + /**
  1402 + * origin:起点名称或经纬度;
  1403 + *
  1404 + * destination:终点名称或经纬度;
  1405 + *
  1406 + * origin_region:起始点所在城市,驾车导航时必填。
  1407 + *
  1408 + * destination_region:终点所在城市,驾车导航时必填。
  1409 + *
  1410 + * output :表示输出类型,可设置为xml或json,默认为xml。
  1411 + *
  1412 + **/
  1413 + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My};
  1414 +
  1415 + /** @description :未认证开发者默认配额为:2000次/天。 */
  1416 + $.ajax({
  1417 +
  1418 + // 百度地图根据坐标获取两点之间的时间与距离
  1419 + url: 'http://api.map.baidu.com/direction/v1?mode=transit',
  1420 +
  1421 + data: paramsB,
  1422 +
  1423 + dataType: 'jsonp',
  1424 +
  1425 + success: function(r){
  1426 +
  1427 + if(r) {
  1428 +
  1429 + if(r.message=='ok') {
  1430 +
  1431 + if(r.result.taxi==null) {
  1432 +
  1433 + // 获取距离(单位:米)
  1434 + points[index+1].distance = 0;
  1435 +
  1436 + // 获取时间(单位:秒)
  1437 + points[index+1].duration = 0;
  1438 +
  1439 + }else {
  1440 +
  1441 + // 获取距离(单位:米)
  1442 + points[index+1].distance = r.result.taxi.distance;
  1443 +
  1444 + // 获取时间(单位:秒)
  1445 + points[index+1].duration = r.result.taxi.duration;
  1446 +
  1447 + }
  1448 +
  1449 +
  1450 + }
  1451 +
  1452 + }
  1453 +
  1454 + f();
  1455 + }
  1456 + });
  1457 +
  1458 + })();
  1459 +
  1460 + },
  1461 + };
  1462 +
  1463 + return Bmap;
  1464 +
1463 }(); 1465 }();
1464 \ No newline at end of file 1466 \ No newline at end of file