Commit 18a930fdb2beba0027b3492eb8c2b88087b5df94
1 parent
238e076d
获取最大IDBUG
Showing
12 changed files
with
2463 additions
and
2438 deletions
Too many changes to show.
To preserve performance only 12 of 15 files are displayed.
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 | 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<LineVersions, Integ |
| 283 | 283 | |
| 284 | 284 | LsSectionRoute oldData = sectionList.get(i); |
| 285 | 285 | |
| 286 | - long sectionCode = GetUIDAndCode.getSectionId(); | |
| 286 | + long sectionCode = sectionRepository.sectionMaxId() + 1; | |
| 287 | 287 | |
| 288 | 288 | sectionRepository.autoCopy(versions, (int)sectionCode, oldData.getSection().getId()); |
| 289 | 289 | Section section = sectionRepository.findById((int)sectionCode).get(); |
| ... | ... | @@ -311,7 +311,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 311 | 311 | |
| 312 | 312 | Station newStation = stationRepository.findById(stationList.get(i).getStation().getId()).get(); |
| 313 | 313 | Station oldStation = new Station(); |
| 314 | - long stationCode = GetUIDAndCode.getStationId(); | |
| 314 | + long stationCode = stationRepository.stationMaxId() + 1; | |
| 315 | 315 | oldStation.setStationCod(String.valueOf(stationCode)); |
| 316 | 316 | oldStation.setId((int)stationCode); |
| 317 | 317 | oldStation.setAddr(newStation.getAddr()); | ... | ... |
src/main/java/com/bsth/service/impl/SectionRouteServiceImpl.java
| ... | ... | @@ -368,7 +368,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 368 | 368 | * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) |
| 369 | 369 | * + 1 ; |
| 370 | 370 | */ |
| 371 | - long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 371 | + long sectionMaxId = repository2.sectionMaxId() + 1; | |
| 372 | 372 | String sectionCode = String.valueOf(sectionMaxId); |
| 373 | 373 | int sectionId = (int) sectionMaxId; |
| 374 | 374 | String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString(); |
| ... | ... | @@ -423,7 +423,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 423 | 423 | * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) |
| 424 | 424 | * + 1 ; |
| 425 | 425 | */ |
| 426 | - long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 426 | + long sectionMaxId = repository2.sectionMaxId() + 1; | |
| 427 | 427 | String sectionCode = String.valueOf(sectionMaxId); |
| 428 | 428 | int sectionId = (int) sectionMaxId; |
| 429 | 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<Section, Integer> implem |
| 152 | 152 | routeRepository.sectionRouteUpdDestroy(sectionRouteLine,directions); |
| 153 | 153 | // 路段保存 |
| 154 | 154 | for (int i = 0; i < sectionArrayList.size(); i++) { |
| 155 | - long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 155 | + long sectionMaxId = repository.sectionMaxId() + 1; | |
| 156 | 156 | // 路段编码 |
| 157 | 157 | String sectionCode = String.valueOf(sectionMaxId); |
| 158 | 158 | // 路段ID |
| ... | ... | @@ -286,7 +286,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem |
| 286 | 286 | lsRouteRepository.batchDelete(sectionRouteLine,directions,versions); |
| 287 | 287 | // 路段保存 |
| 288 | 288 | for (int i = 0; i < sectionArrayList.size(); i++) { |
| 289 | - long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 289 | + long sectionMaxId = repository.sectionMaxId() + 1; | |
| 290 | 290 | // 路段编码 |
| 291 | 291 | String sectionCode = String.valueOf(sectionMaxId); |
| 292 | 292 | // 路段ID |
| ... | ... | @@ -437,7 +437,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | // 获取当前最大Id |
| 440 | - long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 440 | + long sectionMaxId = repository.sectionMaxId() + 1; | |
| 441 | 441 | // 路段编码 |
| 442 | 442 | String sectionCode = String.valueOf(sectionMaxId); |
| 443 | 443 | // 路段ID | ... | ... |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -578,7 +578,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 578 | 578 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 579 | 579 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 580 | 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 | 583 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 583 | 584 | |
| 584 | 585 | int len = objects.size(); | ... | ... |