Commit b070e462a803ee0ff866fa1bf446a0e813bbcc18

Authored by 王通
1 parent dd0cd89f

1.

Showing 57 changed files with 1374 additions and 2284 deletions

Too many changes to show.

To preserve performance only 57 of 150 files are displayed.

src/main/java/com/bsth/Application.java
1 package com.bsth; 1 package com.bsth;
2 2
  3 +import com.fasterxml.jackson.annotation.JsonInclude;
3 import com.fasterxml.jackson.databind.ObjectMapper; 4 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.fasterxml.jackson.databind.SerializationFeature; 5 import com.fasterxml.jackson.databind.SerializationFeature;
5 import org.springframework.boot.SpringApplication; 6 import org.springframework.boot.SpringApplication;
@@ -7,12 +8,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,12 +8,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
7 import org.springframework.boot.builder.SpringApplicationBuilder; 8 import org.springframework.boot.builder.SpringApplicationBuilder;
8 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 9 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
9 import org.springframework.context.annotation.Bean; 10 import org.springframework.context.annotation.Bean;
  11 +import org.springframework.context.annotation.EnableAspectJAutoProxy;
10 import org.springframework.context.annotation.Primary; 12 import org.springframework.context.annotation.Primary;
11 import org.springframework.transaction.annotation.EnableTransactionManagement; 13 import org.springframework.transaction.annotation.EnableTransactionManagement;
12 14
13 import java.util.concurrent.Executors; 15 import java.util.concurrent.Executors;
14 import java.util.concurrent.ScheduledExecutorService; 16 import java.util.concurrent.ScheduledExecutorService;
15 17
  18 +@EnableAspectJAutoProxy
16 @EnableTransactionManagement 19 @EnableTransactionManagement
17 @SpringBootApplication 20 @SpringBootApplication
18 public class Application extends SpringBootServletInitializer { 21 public class Application extends SpringBootServletInitializer {
@@ -27,10 +30,11 @@ public class Application extends SpringBootServletInitializer { @@ -27,10 +30,11 @@ public class Application extends SpringBootServletInitializer {
27 @Bean 30 @Bean
28 @Primary 31 @Primary
29 public ObjectMapper objectMapper() { 32 public ObjectMapper objectMapper() {
30 - ObjectMapper objectMapper = new ObjectMapper();  
31 - objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); 33 + ObjectMapper mapper = new ObjectMapper();
  34 + mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
  35 + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
32 36
33 - return objectMapper; 37 + return mapper;
34 } 38 }
35 39
36 public static void main(String[] args) throws Exception { 40 public static void main(String[] args) throws Exception {
src/main/java/com/bsth/annotation/BusinessDescription.java 0 → 100644
  1 +package com.bsth.annotation;
  2 +
  3 +import java.lang.annotation.ElementType;
  4 +import java.lang.annotation.Retention;
  5 +import java.lang.annotation.RetentionPolicy;
  6 +import java.lang.annotation.Target;
  7 +
  8 +/**
  9 + * @author Hill
  10 + */
  11 +@Retention(RetentionPolicy.RUNTIME)
  12 +@Target(ElementType.METHOD)
  13 +public @interface BusinessDescription {
  14 +
  15 + /**
  16 + * 业务描述内容
  17 + * @return
  18 + */
  19 + String value();
  20 +}
src/main/java/com/bsth/controller/BaseController.java
1 -package com.bsth.controller;  
2 -  
3 -import com.bsth.service.BaseService;  
4 -import com.google.common.base.Splitter;  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.data.domain.Page;  
7 -import org.springframework.data.domain.PageRequest;  
8 -import org.springframework.data.domain.Sort;  
9 -import org.springframework.data.domain.Sort.Direction;  
10 -import org.springframework.web.bind.annotation.PathVariable;  
11 -import org.springframework.web.bind.annotation.RequestMapping;  
12 -import org.springframework.web.bind.annotation.RequestMethod;  
13 -import org.springframework.web.bind.annotation.RequestParam;  
14 -  
15 -import java.io.Serializable;  
16 -import java.util.ArrayList;  
17 -import java.util.List;  
18 -import java.util.Map;  
19 -  
20 -/**  
21 - * @param <T>  
22 - * @param <ID> 主键类型  
23 - * @author PanZhao  
24 - * @ClassName: BaseController  
25 - * @Description: TODO(基础的Controller实现)  
26 - * @date 2016年3月17日 下午12:44:06  
27 - */  
28 -public class BaseController<T, ID extends Serializable> {  
29 -  
30 - @Autowired  
31 - protected BaseService<T, ID> baseService;  
32 -  
33 - /**  
34 - * @param @param map 查询条件  
35 - * @param @param page 页码  
36 - * @param @param size 每页显示数量  
37 - * @throws  
38 - * @Title: list  
39 - * @Description: TODO(多条件分页查询)  
40 - */  
41 - @RequestMapping(method = RequestMethod.GET)  
42 - public Page<T> list(@RequestParam Map<String, Object> map,  
43 - @RequestParam(defaultValue = "0") int page,  
44 - @RequestParam(defaultValue = "10") int size,  
45 - @RequestParam(defaultValue = "id") String order,  
46 - @RequestParam(defaultValue = "DESC") String direction) {  
47 -  
48 - // 允许多个字段排序,order可以写单个字段,也可以写多个字段  
49 - // 多个字段格式:{col1},{col2},{col3},....,{coln}  
50 - List<String> order_columns = Splitter.on(",").trimResults().splitToList(order);  
51 - // 多字段排序:DESC,ASC...  
52 - List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction);  
53 -  
54 - if (order_dirs.size() == 1) { // 所有字段采用一种排序  
55 - if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) {  
56 - return baseService.list(map, new PageRequest(page, size, new Sort(Direction.ASC, order_columns)));  
57 - } else {  
58 - return baseService.list(map, new PageRequest(page, size, new Sort(Direction.DESC, order_columns)));  
59 - }  
60 - } else if (order_columns.size() == order_dirs.size()) {  
61 - List<Sort.Order> orderList = new ArrayList<>();  
62 - for (int i = 0; i < order_columns.size(); i++) {  
63 - if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) {  
64 - orderList.add(new Sort.Order(Direction.ASC, order_columns.get(i)));  
65 - } else {  
66 - orderList.add(new Sort.Order(Direction.DESC, order_columns.get(i)));  
67 - }  
68 - }  
69 - return baseService.list(map, new PageRequest(page, size, new Sort(orderList)));  
70 - } else {  
71 - throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致");  
72 - }  
73 - }  
74 -  
75 - /**  
76 - * @param @param map  
77 - * @throws  
78 - * @Title: list  
79 - * @Description: TODO(多条件查询)  
80 - */  
81 - @RequestMapping(value = "/all", method = RequestMethod.GET)  
82 - public Iterable<T> list(@RequestParam Map<String, Object> map) {  
83 - return baseService.list(map);  
84 - }  
85 -  
86 - /**  
87 - * @param @param t  
88 - * @param @return 设定文件  
89 - * @return Map<String,Object> {status: 1(成功),-1(失败)}  
90 - * @throws  
91 - * @Title: save  
92 - * @Description: TODO(持久化对象)  
93 - */  
94 - @RequestMapping(method = RequestMethod.POST)  
95 - public Map<String, Object> save(T t) {  
96 - return baseService.save(t);  
97 - }  
98 -  
99 - /**  
100 - * @param @param id  
101 - * @throws  
102 - * @Title: findById  
103 - * @Description: TODO(根据主键获取单个对象)  
104 - */  
105 - @RequestMapping(value = "/{id}", method = RequestMethod.GET)  
106 - public T findById(@PathVariable("id") ID id) {  
107 - return baseService.findById(id);  
108 - }  
109 -  
110 - /**  
111 - * @param @param id  
112 - * @throws  
113 - * @Title: delete  
114 - * @Description: TODO(根据主键删除对象)  
115 - */  
116 - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)  
117 - public Map<String, Object> delete(@PathVariable("id") ID id) {  
118 - return baseService.delete(id);  
119 - }  
120 -  
121 -} 1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.service.BaseService;
  4 +import com.google.common.base.Splitter;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.data.domain.Page;
  7 +import org.springframework.data.domain.PageRequest;
  8 +import org.springframework.data.domain.Sort;
  9 +import org.springframework.data.domain.Sort.Direction;
  10 +import org.springframework.web.bind.annotation.PathVariable;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.RequestMethod;
  13 +import org.springframework.web.bind.annotation.RequestParam;
  14 +
  15 +import java.io.Serializable;
  16 +import java.util.ArrayList;
  17 +import java.util.Arrays;
  18 +import java.util.List;
  19 +import java.util.Map;
  20 +
  21 +/**
  22 + * @param <T>
  23 + * @param <ID> 主键类型
  24 + * @author PanZhao
  25 + * @ClassName: BaseController
  26 + * @Description: TODO(基础的Controller实现)
  27 + * @date 2016年3月17日 下午12:44:06
  28 + */
  29 +public class BaseController<T, ID extends Serializable> {
  30 +
  31 + @Autowired
  32 + protected BaseService<T, ID> baseService;
  33 +
  34 + /**
  35 + * @param @param map 查询条件
  36 + * @param @param page 页码
  37 + * @param @param size 每页显示数量
  38 + * @throws
  39 + * @Title: list
  40 + * @Description: TODO(多条件分页查询)
  41 + */
  42 + @RequestMapping(method = RequestMethod.GET)
  43 + public Page<T> list(@RequestParam Map<String, Object> map,
  44 + @RequestParam(defaultValue = "0") int page,
  45 + @RequestParam(defaultValue = "10") int size,
  46 + @RequestParam(defaultValue = "id") String order,
  47 + @RequestParam(defaultValue = "DESC") String direction) {
  48 +
  49 + // 允许多个字段排序,order可以写单个字段,也可以写多个字段
  50 + // 多个字段格式:{col1},{col2},{col3},....,{coln}
  51 + List<String> order_columns = Splitter.on(",").trimResults().splitToList(order);
  52 + // 多字段排序:DESC,ASC...
  53 + List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction);
  54 +
  55 + if (order_dirs.size() == 1) { // 所有字段采用一种排序
  56 + if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) {
  57 + return baseService.list(map, new PageRequest(page, size, new Sort(Direction.ASC, order_columns)));
  58 + } else {
  59 + return baseService.list(map, new PageRequest(page, size, new Sort(Direction.DESC, order_columns)));
  60 + }
  61 + } else if (order_columns.size() == order_dirs.size()) {
  62 + List<Sort.Order> orderList = new ArrayList<>();
  63 + for (int i = 0; i < order_columns.size(); i++) {
  64 + if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) {
  65 + orderList.add(new Sort.Order(Direction.ASC, order_columns.get(i)));
  66 + } else {
  67 + orderList.add(new Sort.Order(Direction.DESC, order_columns.get(i)));
  68 + }
  69 + }
  70 + return baseService.list(map, new PageRequest(page, size, new Sort(orderList)));
  71 + } else {
  72 + throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致");
  73 + }
  74 + }
  75 +
  76 + /**
  77 + * @param @param map
  78 + * @throws
  79 + * @Title: list
  80 + * @Description: TODO(多条件查询)
  81 + */
  82 + @RequestMapping(value = "/all", method = RequestMethod.GET)
  83 + public Iterable<T> list(@RequestParam Map<String, Object> map) {
  84 + return baseService.list(map);
  85 + }
  86 +
  87 + /**
  88 + * @param @param map
  89 + * @throws
  90 + * @Title: list
  91 + * @Description: TODO(多条件查询)
  92 + */
  93 + @RequestMapping(value = "/findAll", method = RequestMethod.GET)
  94 + public List<T> findAll(@RequestParam Map<String, Object> map,
  95 + @RequestParam(defaultValue = "id") String order,
  96 + @RequestParam(defaultValue = "DESC") String direction) {
  97 + String[] columns = order.split(","), directions = direction.split(",");
  98 + if (columns.length != directions.length) {
  99 + throw new IllegalArgumentException("不合法的排序参数");
  100 + }
  101 +
  102 + List<Sort.Order> orders = new ArrayList<>();
  103 + for (int i = 0;i < columns.length;i++) {
  104 + String column = columns[i], direction1 = directions[i];
  105 + if ("DESC".equals(direction1)) {
  106 + orders.add(Sort.Order.desc(column));
  107 + } else if ("ASC".equals(direction1)) {
  108 + orders.add(Sort.Order.asc(column));
  109 + } else {
  110 + throw new IllegalArgumentException("不合法的排序参数");
  111 + }
  112 + }
  113 +
  114 + return baseService.findAll(map, Sort.by(orders));
  115 + }
  116 +
  117 + /**
  118 + * @param @param t
  119 + * @param @return 设定文件
  120 + * @return Map<String,Object> {status: 1(成功),-1(失败)}
  121 + * @throws
  122 + * @Title: save
  123 + * @Description: TODO(持久化对象)
  124 + */
  125 + @RequestMapping(method = RequestMethod.POST)
  126 + public Map<String, Object> save(T t) {
  127 + return baseService.save(t);
  128 + }
  129 +
  130 + /**
  131 + * @param @param id
  132 + * @throws
  133 + * @Title: findById
  134 + * @Description: TODO(根据主键获取单个对象)
  135 + */
  136 + @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  137 + public T findById(@PathVariable("id") ID id) {
  138 + return baseService.findById(id);
  139 + }
  140 +
  141 + /**
  142 + * @param @param id
  143 + * @throws
  144 + * @Title: delete
  145 + * @Description: TODO(根据主键删除对象)
  146 + */
  147 + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  148 + public Map<String, Object> delete(@PathVariable("id") ID id) {
  149 + return baseService.delete(id);
  150 + }
  151 +
  152 +}
src/main/java/com/bsth/controller/LineController.java
@@ -136,14 +136,4 @@ public class LineController extends BaseController&lt;Line, Integer&gt; { @@ -136,14 +136,4 @@ public class LineController extends BaseController&lt;Line, Integer&gt; {
136 public Map<String, Object> remove(Integer id){ 136 public Map<String, Object> remove(Integer id){
137 return service.remove(id); 137 return service.remove(id);
138 } 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 } 139 }
src/main/java/com/bsth/controller/LsSectionRouteController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.LsSectionRoute;
  5 +import com.bsth.entity.LsStationRoute;
4 import com.bsth.entity.SectionRoute; 6 import com.bsth.entity.SectionRoute;
5 import com.bsth.service.LsSectionRouteService; 7 import com.bsth.service.LsSectionRouteService;
6 import org.slf4j.Logger; 8 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
8 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.data.domain.Page;
9 import org.springframework.web.bind.annotation.RequestMapping; 12 import org.springframework.web.bind.annotation.RequestMapping;
10 import org.springframework.web.bind.annotation.RequestMethod; 13 import org.springframework.web.bind.annotation.RequestMethod;
11 import org.springframework.web.bind.annotation.RequestParam; 14 import org.springframework.web.bind.annotation.RequestParam;
@@ -34,13 +37,22 @@ import java.util.Map; @@ -34,13 +37,22 @@ import java.util.Map;
34 37
35 @RestController 38 @RestController
36 @RequestMapping("/api/lssectionroute") 39 @RequestMapping("/api/lssectionroute")
37 -public class LsSectionRouteController extends BaseController<SectionRoute, Integer> { 40 +public class LsSectionRouteController extends BaseController<LsSectionRoute, Integer> {
38 41
39 private final static Logger log = LoggerFactory.getLogger(LsSectionRouteController.class); 42 private final static Logger log = LoggerFactory.getLogger(LsSectionRouteController.class);
40 43
41 @Autowired 44 @Autowired
42 private LsSectionRouteService lsSectionRouteService; 45 private LsSectionRouteService lsSectionRouteService;
43 46
  47 + @RequestMapping(value = "/findPageByParams", method = RequestMethod.GET)
  48 + public Page<LsSectionRoute> findPageByParams(@RequestParam Map<String, Object> params) {
  49 + int page = params.get("page") == null ? 0 : Integer.parseInt(params.get("page").toString());
  50 + int size = params.get("size") == null ? 10 : Integer.parseInt(params.get("size").toString());
  51 + String order = params.get("order").toString(), direction = params.get("direction").toString();
  52 +
  53 + return super.list(params, page, size, order, direction);
  54 + }
  55 +
44 /** 56 /**
45 * @param id 57 * @param id
46 * @throws 58 * @throws
@@ -78,4 +90,56 @@ public class LsSectionRouteController extends BaseController&lt;SectionRoute, Integ @@ -78,4 +90,56 @@ public class LsSectionRouteController extends BaseController&lt;SectionRoute, Integ
78 90
79 return result; 91 return result;
80 } 92 }
  93 +
  94 + /**
  95 + * @param lineId
  96 + * @param version
  97 + * @param direction
  98 + * @param otherDirection
  99 + * @throws
  100 + * @Description: 引用另一上下行路段
  101 + */
  102 + @RequestMapping(value = "/quoteOtherSide", method = RequestMethod.POST)
  103 + public Map<String, Object> quoteOtherSide(int lineId, int version, int direction, int otherDirection) {
  104 + Map<String, Object> result = new HashMap<>();
  105 + try {
  106 + lsSectionRouteService.quoteOtherSide(lineId, version, direction, otherDirection);
  107 + result.put("status", ResponseCode.SUCCESS);
  108 + } catch (Exception e) {
  109 + result.put("status", ResponseCode.ERROR);
  110 + log.error("", e);
  111 + }
  112 +
  113 + return result;
  114 + }
  115 +
  116 + @RequestMapping(value = "/add", method = RequestMethod.POST)
  117 + public Map<String, Object> add(LsSectionRoute sectionRoute) {
  118 + Map<String, Object> result = new HashMap<>();
  119 + try {
  120 + lsSectionRouteService.add(sectionRoute);
  121 + result.put("status", ResponseCode.SUCCESS);
  122 + } catch (Exception e) {
  123 + result.put("status", ResponseCode.ERROR);
  124 + result.put("msg", e.getMessage());
  125 + log.error("", e);
  126 + }
  127 +
  128 + return result;
  129 + }
  130 +
  131 + @RequestMapping(value = "/modify", method = RequestMethod.POST)
  132 + public Map<String, Object> modify(LsSectionRoute sectionRoute) {
  133 + Map<String, Object> result = new HashMap<>();
  134 + try {
  135 + lsSectionRouteService.modify(sectionRoute);
  136 + result.put("status", ResponseCode.SUCCESS);
  137 + } catch (Exception e) {
  138 + result.put("status", ResponseCode.ERROR);
  139 + result.put("msg", e.getMessage());
  140 + log.error("", e);
  141 + }
  142 +
  143 + return result;
  144 + }
81 } 145 }
src/main/java/com/bsth/controller/LsStationRouteController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.LsSectionRoute;
4 import com.bsth.entity.LsStationRoute; 5 import com.bsth.entity.LsStationRoute;
5 -import com.bsth.entity.StationRoute;  
6 import com.bsth.service.LsStationRouteService; 6 import com.bsth.service.LsStationRouteService;
  7 +import com.fasterxml.jackson.databind.ObjectMapper;
7 import org.slf4j.Logger; 8 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 10 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; 11 +import org.springframework.data.domain.Page;
  12 +import org.springframework.web.bind.annotation.*;
14 13
15 -import java.util.Arrays;  
16 -import java.util.HashMap;  
17 -import java.util.List;  
18 -import java.util.Map; 14 +import java.util.*;
19 15
20 /** 16 /**
21 * @author Hill 17 * @author Hill
@@ -23,18 +19,37 @@ import java.util.Map; @@ -23,18 +19,37 @@ import java.util.Map;
23 @RestController 19 @RestController
24 @RequestMapping("/api/lsstationroute") 20 @RequestMapping("/api/lsstationroute")
25 public class LsStationRouteController extends BaseController<LsStationRoute, Integer> { 21 public class LsStationRouteController extends BaseController<LsStationRoute, Integer> {
26 -  
27 - @Autowired  
28 - private LsStationRouteService lsStationRouteService;  
29 22
30 - private static final Logger log = LoggerFactory.getLogger(LsStationRouteController.class); 23 + private static final Logger log = LoggerFactory.getLogger(LsStationRouteController.class);
  24 +
  25 + @Autowired
  26 + private LsStationRouteService lsStationRouteService;
  27 +
  28 + @Autowired
  29 + private ObjectMapper mapper;
31 30
32 -  
33 @RequestMapping(value = "/findAllByParams", method = RequestMethod.GET) 31 @RequestMapping(value = "/findAllByParams", method = RequestMethod.GET)
34 public Iterable<LsStationRoute> findAllByParams(@RequestParam Map<String, Object> params) { 32 public Iterable<LsStationRoute> findAllByParams(@RequestParam Map<String, Object> params) {
35 return lsStationRouteService.findAllByParams(params); 33 return lsStationRouteService.findAllByParams(params);
36 } 34 }
37 35
  36 + @RequestMapping(value = "/findPageByParams", method = RequestMethod.GET)
  37 + public Page<LsStationRoute> findPageByParams(@RequestParam Map<String, Object> params) {
  38 + int page = params.get("page") == null ? 0 : Integer.parseInt(params.get("page").toString());
  39 + int size = params.get("size") == null ? 10 : Integer.parseInt(params.get("size").toString());
  40 + String order = params.get("order").toString(), direction = params.get("direction").toString();
  41 +
  42 + return super.list(params, page, size, order, direction);
  43 + }
  44 +
  45 + /**
  46 + * @Description :TODO(查询站点的下一个缓存站点)
  47 + */
  48 + @RequestMapping(value = "/findCurrentAndNext" , method = RequestMethod.GET)
  49 + public List<LsStationRoute> findCurrentAndNext(Integer id) {
  50 + return lsStationRouteService.findCurrentAndNext(id);
  51 + }
  52 +
38 /** 53 /**
39 * @param id 54 * @param id
40 * @throws 55 * @throws
@@ -75,6 +90,33 @@ public class LsStationRouteController extends BaseController&lt;LsStationRoute, Int @@ -75,6 +90,33 @@ public class LsStationRouteController extends BaseController&lt;LsStationRoute, Int
75 return result; 90 return result;
76 } 91 }
77 92
  93 + /**
  94 + * 保存线路某个版本下单行的站点和路段路由
  95 + * 常规使用在根据百度地图生成数据或者模板导入的批量保存
  96 + * @param map
  97 + * @return
  98 + */
  99 + @RequestMapping(value="addRoutes" , method = RequestMethod.POST)
  100 + public Map<String, Object> addRoutes(@RequestBody Map<String, Object> map) {
  101 + Map<String, Object> result = new HashMap<>();
  102 + try {
  103 + if (map.get("lineId") == null || map.get("versions") == null || map.get("directions") == null) {
  104 + throw new IllegalArgumentException("需正确传入线路、方向、版本参数");
  105 + }
  106 + Integer versions = Integer.parseInt(map.get("versions").toString()), directions = Integer.parseInt(map.get("directions").toString()), lineId = Integer.parseInt(map.get("lineId").toString());
  107 + List<LsStationRoute> stationRoutes = mapper.convertValue(map.get("stationRoutes"), mapper.constructType(mapper.getTypeFactory().constructParametricType(List.class, LsStationRoute.class)));
  108 + List<LsSectionRoute> sectionRoutes = mapper.convertValue(map.get("sectionRoutes"), mapper.constructType(mapper.getTypeFactory().constructParametricType(List.class, LsSectionRoute.class)));
  109 +
  110 + result.putAll(lsStationRouteService.addRoutes(lineId, versions, directions, stationRoutes, sectionRoutes));
  111 + result.put("status", ResponseCode.SUCCESS);
  112 + } catch (Exception e) {
  113 + result.put("status", ResponseCode.ERROR);
  114 + log.error("", e);
  115 + }
  116 +
  117 + return result;
  118 + }
  119 +
78 @RequestMapping(value = "/add", method = RequestMethod.POST) 120 @RequestMapping(value = "/add", method = RequestMethod.POST)
79 public Map<String, Object> add(LsStationRoute stationRoute) { 121 public Map<String, Object> add(LsStationRoute stationRoute) {
80 Map<String, Object> result = new HashMap<>(); 122 Map<String, Object> result = new HashMap<>();
@@ -104,4 +146,59 @@ public class LsStationRouteController extends BaseController&lt;LsStationRoute, Int @@ -104,4 +146,59 @@ public class LsStationRouteController extends BaseController&lt;LsStationRoute, Int
104 146
105 return result; 147 return result;
106 } 148 }
  149 +
  150 + @RequestMapping(value = "/exchangeDirection", method = RequestMethod.POST)
  151 + public Map<String, Object> exchangeDirection(int lineId, int version) {
  152 + Map<String, Object> result = new HashMap<>();
  153 + try {
  154 + lsStationRouteService.exchangeDirection(lineId, version);
  155 + result.put("status", ResponseCode.SUCCESS);
  156 + } catch (Exception e) {
  157 + result.put("status", ResponseCode.ERROR);
  158 + result.put("msg", e.getMessage());
  159 + log.error("", e);
  160 + }
  161 +
  162 + return result;
  163 + }
  164 +
  165 + @RequestMapping(value = "/modifyDistance", method = RequestMethod.POST)
  166 + public Map<String, Object> modifyDistance(@RequestParam Map<String, Object> params) {
  167 + Map<String, Object> result = new HashMap<>();
  168 + try {
  169 + List<Integer> ids = new ArrayList<>();
  170 + List<Double> distances = new ArrayList<>();
  171 + for (Map.Entry<String, Object> entry : params.entrySet()) {
  172 + String key = entry.getKey(), value = String.valueOf(entry.getValue());
  173 + ids.add(Integer.parseInt(key.split("_")[1]));
  174 + distances.add(Double.parseDouble(value) / 1000);
  175 + }
  176 + if (ids.size() == 0) {
  177 + throw new IllegalArgumentException("不合法的参数");
  178 + }
  179 + lsStationRouteService.modifyDistance(ids, distances);
  180 + result.put("status", ResponseCode.SUCCESS);
  181 + } catch (Exception e) {
  182 + result.put("status", ResponseCode.ERROR);
  183 + result.put("msg", e.getMessage());
  184 + log.error("", e);
  185 + }
  186 +
  187 + return result;
  188 + }
  189 +
  190 + @RequestMapping(value = "/circularRouteHandle", method = RequestMethod.POST)
  191 + public Map<String, Object> circularRouteHandle(Integer lineId, Integer version) {
  192 + Map<String, Object> result = new HashMap<>();
  193 + try {
  194 + lsStationRouteService.circularRouteHandle(lineId, version);
  195 + result.put("status", ResponseCode.SUCCESS);
  196 + } catch (Exception e) {
  197 + result.put("status", ResponseCode.ERROR);
  198 + result.put("msg", e.getMessage());
  199 + log.error("", e);
  200 + }
  201 +
  202 + return result;
  203 + }
107 } 204 }
src/main/java/com/bsth/controller/RoadSpeedController.java deleted 100644 → 0
1 -package com.bsth.controller;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import org.springframework.beans.factory.annotation.Autowired;  
7 -import org.springframework.web.bind.annotation.RequestMapping;  
8 -import org.springframework.web.bind.annotation.RequestMethod;  
9 -import org.springframework.web.bind.annotation.RequestParam;  
10 -import org.springframework.web.bind.annotation.RestController;  
11 -  
12 -import com.bsth.entity.RoadSpeed;  
13 -import com.bsth.service.RoadSpeedService;  
14 -  
15 -/**  
16 - *  
17 - * @ClassName: RoadSpeedController(路段限速控制器)  
18 - *  
19 - * @Extends : BaseController  
20 - *  
21 - * @Description: TODO(路段限速控制层)  
22 - *  
23 - * @Author bsth@lq  
24 - *  
25 - * @Version 公交调度系统BS版 0.1  
26 - *  
27 - */  
28 -@RestController  
29 -@RequestMapping("roadSpeed")  
30 -public class RoadSpeedController extends BaseController<RoadSpeed, Integer> {  
31 -  
32 - @Autowired  
33 - private RoadSpeedService service;  
34 -  
35 - /*@RequestMapping(value="all", method = RequestMethod.GET)  
36 - public List<RoadSpeed> allRoadSpeed(){  
37 - return service.allRoadSpeed();  
38 - }*/  
39 -  
40 - @RequestMapping(value="save", method = RequestMethod.POST)  
41 - public Map<String, Object> save(@RequestParam Map<String, Object> map){  
42 - return service.roadSpeedSave(map);  
43 - }  
44 -  
45 - @RequestMapping(value="update", method = RequestMethod.POST)  
46 - public Map<String, Object> update(@RequestParam Map<String, Object> map){  
47 - return service.update(map);  
48 - }  
49 -  
50 - @RequestMapping(value="findById", method = RequestMethod.GET)  
51 - public RoadSpeed findById(@RequestParam(defaultValue = "id") Integer id){  
52 - return service.findId(id);  
53 - }  
54 -}  
src/main/java/com/bsth/controller/SectionController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
  3 +import com.bsth.common.ResponseCode;
3 import com.bsth.entity.Section; 4 import com.bsth.entity.Section;
  5 +import com.bsth.entity.Station;
4 import com.bsth.repository.SectionRepository; 6 import com.bsth.repository.SectionRepository;
5 import com.bsth.service.SectionService; 7 import com.bsth.service.SectionService;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
6 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.web.bind.annotation.RequestMapping; 11 import org.springframework.web.bind.annotation.RequestMapping;
8 import org.springframework.web.bind.annotation.RequestMethod; 12 import org.springframework.web.bind.annotation.RequestMethod;
9 import org.springframework.web.bind.annotation.RequestParam; 13 import org.springframework.web.bind.annotation.RequestParam;
10 import org.springframework.web.bind.annotation.RestController; 14 import org.springframework.web.bind.annotation.RestController;
11 15
  16 +import javax.servlet.http.HttpServletRequest;
  17 +import java.util.HashMap;
  18 +import java.util.List;
12 import java.util.Map; 19 import java.util.Map;
13 20
14 /** 21 /**
@@ -30,50 +37,14 @@ import java.util.Map; @@ -30,50 +37,14 @@ import java.util.Map;
30 @RestController 37 @RestController
31 @RequestMapping("section") 38 @RequestMapping("section")
32 public class SectionController extends BaseController<Section, Integer> { 39 public class SectionController extends BaseController<Section, Integer> {
  40 +
  41 + private final static Logger log = LoggerFactory.getLogger(SectionController.class);
33 42
34 @Autowired 43 @Autowired
35 - SectionService service; 44 + SectionService sectionService;
36 45
37 @Autowired 46 @Autowired
38 SectionRepository sectionRepository; 47 SectionRepository sectionRepository;
39 -  
40 - /**  
41 - * 新增路段信息  
42 - *  
43 - * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID  
44 - *  
45 - * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;  
46 - *  
47 - * sectionrouteCode:路段序号;speedLimit:路段限速>  
48 - *  
49 - * @return map<SUCCESS:成功;ERROR:异常>  
50 - */  
51 - @RequestMapping(value="sectionSave" , method = RequestMethod.POST)  
52 - public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {  
53 - map.put("createBy", "");  
54 - map.put("updateBy", "");  
55 - return service.sectionSave(map);  
56 - }  
57 -  
58 - /**  
59 - * @Description :TODO(编辑线路走向)  
60 - *  
61 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
62 - *  
63 - * @return Map<String, Object> <SUCCESS ; ERROR>  
64 - */  
65 - @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)  
66 - public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {  
67 -  
68 - map.put("updateBy", "");  
69 -  
70 - map.put("createBy", "");  
71 -  
72 - map.put("createDate", "");  
73 -  
74 - return service.sectionUpdate(map);  
75 -  
76 - }  
77 48
78 /** 49 /**
79 * @Description :TODO(查询路段编码) 50 * @Description :TODO(查询路段编码)
@@ -82,7 +53,7 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; { @@ -82,7 +53,7 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; {
82 */ 53 */
83 @RequestMapping(value="getSectionCode" , method = RequestMethod.GET) 54 @RequestMapping(value="getSectionCode" , method = RequestMethod.GET)
84 public long getSectionCode() { 55 public long getSectionCode() {
85 - return sectionRepository.sectionMaxId() + 1; 56 + return sectionRepository.findLatestSectionId() + 1;
86 } 57 }
87 58
88 /** 59 /**
@@ -92,7 +63,44 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; { @@ -92,7 +63,44 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; {
92 */ 63 */
93 @RequestMapping(value="doubleName" , method = RequestMethod.POST) 64 @RequestMapping(value="doubleName" , method = RequestMethod.POST)
94 public Map<String, Object> doubleName(@RequestParam Map<String, Object> map) { 65 public Map<String, Object> doubleName(@RequestParam Map<String, Object> map) {
95 - return service.doubleName(map); 66 + return sectionService.doubleName(map);
  67 + }
  68 +
  69 + @RequestMapping(value="add" , method = RequestMethod.POST)
  70 + public Map<String, Object> add(Section section) {
  71 + Map<String, Object> result = new HashMap<>();
  72 + try {
  73 + sectionService.add(section);
  74 + result.put("status", ResponseCode.SUCCESS);
  75 + } catch (Exception e) {
  76 + result.put("status", ResponseCode.ERROR);
  77 + log.error("", e);
  78 + }
  79 +
  80 + return result;
96 } 81 }
97 82
  83 + @RequestMapping(value="modify" , method = RequestMethod.POST)
  84 + public Map<String, Object> modify(Section section) {
  85 + Map<String, Object> result = new HashMap<>();
  86 + try {
  87 + sectionService.modify(section);
  88 + result.put("status", ResponseCode.SUCCESS);
  89 + } catch (Exception e) {
  90 + result.put("status", ResponseCode.ERROR);
  91 + log.error("", e);
  92 + }
  93 +
  94 + return result;
  95 + }
  96 +
  97 + /**
  98 + * 根据路段名模糊搜索路段信息
  99 + * @param sectionName
  100 + * @return 站点列表
  101 + */
  102 + @RequestMapping(value="findSectionByName" , method = RequestMethod.GET)
  103 + public List<Section> findSectionByName(String sectionName) {
  104 + return sectionService.findSectionByName(sectionName);
  105 + }
98 } 106 }
src/main/java/com/bsth/controller/SectionRouteController.java
@@ -35,23 +35,6 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer @@ -35,23 +35,6 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer
35 @Autowired 35 @Autowired
36 SectionRouteService routeService; 36 SectionRouteService routeService;
37 37
38 - @RequestMapping(value = "/allls", method = RequestMethod.GET)  
39 - public Map allls(@RequestParam Map<String, Object> map) {  
40 -  
41 - return routeService.pageLs(map);  
42 - }  
43 -  
44 -  
45 - /**  
46 - * @param map  
47 - * @throws  
48 - * @Description: TODO(批量撤销路段)  
49 - */  
50 - @RequestMapping(value = "/batchDestroy", method = RequestMethod.POST)  
51 - public Map<String, Object> updateBatch(@RequestParam Map<String, Object> map) {  
52 - return routeService.updateSectionRouteInfoFormId(map);  
53 - }  
54 -  
55 /** 38 /**
56 * @param @param map 39 * @param @param map
57 * @throws 40 * @throws
@@ -76,18 +59,6 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer @@ -76,18 +59,6 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer
76 } 59 }
77 60
78 /** 61 /**
79 - * @Description : TODO(根据路段路由Id查询详情)  
80 - *  
81 - * @param map <id:路段路由ID>  
82 - *  
83 - * @return List<Map<String, Object>>  
84 - */  
85 - @RequestMapping(value = "/findSectionRouteInfoFormId",method = RequestMethod.GET)  
86 - public List<Map<String, Object>> findSectionRouteInfoFormId(@RequestParam Map<String, Object> map) {  
87 - return routeService.findSectionRouteInfoFormId(map);  
88 - }  
89 -  
90 - /**  
91 * @Description :TODO(查询线路某方向下的上一个路段序号) 62 * @Description :TODO(查询线路某方向下的上一个路段序号)
92 * 63 *
93 * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码> 64 * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码>
@@ -98,14 +69,4 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer @@ -98,14 +69,4 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer
98 public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) { 69 public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {
99 return routeService.findUpSectionRouteCode(map); 70 return routeService.findUpSectionRouteCode(map);
100 } 71 }
101 -  
102 - /**  
103 - * @Description :TODO(引用路段)  
104 - *  
105 - * @return List<Map<String, Object>>  
106 - */  
107 - @RequestMapping(value = "/quoteSection" , method = RequestMethod.POST)  
108 - public Map<String, Object> quoteSection(@RequestParam Map<String, Object> map) {  
109 - return routeService.quoteSection(map);  
110 - }  
111 } 72 }
src/main/java/com/bsth/controller/SectionSpeedController.java deleted 100644 → 0
1 -package com.bsth.controller;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import com.bsth.entity.SectionSpeed;  
7 -import com.bsth.service.SectionSpeedService;  
8 -  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.web.bind.annotation.*;  
11 -  
12 -  
13 -@RestController  
14 -@RequestMapping("sectionspeed")  
15 -public class SectionSpeedController extends BaseController<SectionSpeed, Integer> {  
16 -  
17 - @Autowired  
18 - private SectionSpeedService sectionSpeedService;  
19 -  
20 - /**@description TODO(新增路段限速) */  
21 - @RequestMapping(value="add" , method = RequestMethod.POST)  
22 - public Map<String, Object> collectionSave(@RequestParam Map<String, Object> map) {  
23 - return sectionSpeedService.add(map);  
24 - }  
25 -  
26 - /**@description TODO(修改路段) */  
27 - @RequestMapping(value="roadUpd" , method = RequestMethod.POST)  
28 - public Map<String, Object> roadUpd(@RequestParam Map<String, Object> map) {  
29 - return sectionSpeedService.roadUpd(map);  
30 - }  
31 -  
32 - /** @description TODO(根据线路ID与编码及方向查询路段限速信息) */  
33 - @RequestMapping(value="getSectionSpeedInfoList",method=RequestMethod.GET)  
34 - public List<Map<String, Object>> getSectionSpeedInfoList(@RequestParam Map<String, Object> map){  
35 - return sectionSpeedService.getSectionSpeedInfo(map);  
36 - }  
37 -  
38 - /**  
39 - * @Description :TODO(查询路段信息)  
40 - *  
41 - * @param map <line.id_eq:线路ID; directions_eq:方向>  
42 - *  
43 - * @return Map<String, Object>  
44 - */  
45 - @RequestMapping(value = "/analyticSection" , method = RequestMethod.GET)  
46 - public List<Map<String, Object>> findPoints(@RequestParam Map<String, Object> map) {  
47 - return sectionSpeedService.analyticSection(map);  
48 - }  
49 -  
50 -}  
src/main/java/com/bsth/controller/StationController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
4 -import com.bsth.entity.Line;  
5 import com.bsth.entity.LsSectionRoute; 4 import com.bsth.entity.LsSectionRoute;
6 import com.bsth.entity.LsStationRoute; 5 import com.bsth.entity.LsStationRoute;
7 import com.bsth.entity.Station; 6 import com.bsth.entity.Station;
8 import com.bsth.repository.StationRepository; 7 import com.bsth.repository.StationRepository;
9 import com.bsth.service.StationService; 8 import com.bsth.service.StationService;
10 -import com.bsth.util.GetUIDAndCode;  
11 import com.fasterxml.jackson.databind.ObjectMapper; 9 import com.fasterxml.jackson.databind.ObjectMapper;
12 import org.slf4j.Logger; 10 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
15 -import org.springframework.util.StringUtils;  
16 import org.springframework.web.bind.annotation.*; 13 import org.springframework.web.bind.annotation.*;
17 14
18 -import java.util.*; 15 +import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.Map;
19 18
20 /** 19 /**
21 * 20 *
@@ -38,12 +37,10 @@ import java.util.*; @@ -38,12 +37,10 @@ import java.util.*;
38 public class StationController extends BaseController<Station, Integer> { 37 public class StationController extends BaseController<Station, Integer> {
39 38
40 @Autowired 39 @Autowired
41 - private StationService service; 40 + private StationService stationService;
42 41
43 @Autowired 42 @Autowired
44 - StationRepository stationRepository;  
45 -  
46 - private ObjectMapper mapper = new ObjectMapper(); 43 + private ObjectMapper mapper;
47 44
48 /** 日志记录器 */ 45 /** 日志记录器 */
49 private static final Logger log = LoggerFactory.getLogger(StationController.class); 46 private static final Logger log = LoggerFactory.getLogger(StationController.class);
@@ -55,7 +52,7 @@ public class StationController extends BaseController&lt;Station, Integer&gt; { @@ -55,7 +52,7 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
55 public Map<String, Object> matchStation(@RequestBody List<Station> stations) { 52 public Map<String, Object> matchStation(@RequestBody List<Station> stations) {
56 Map<String, Object> result = new HashMap<>(); 53 Map<String, Object> result = new HashMap<>();
57 try { 54 try {
58 - service.matchStation(stations); 55 + stationService.matchStation(stations);
59 result.put("status", ResponseCode.SUCCESS); 56 result.put("status", ResponseCode.SUCCESS);
60 result.put("data", stations); 57 result.put("data", stations);
61 } catch (Exception e) { 58 } catch (Exception e) {
@@ -67,26 +64,19 @@ public class StationController extends BaseController&lt;Station, Integer&gt; { @@ -67,26 +64,19 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
67 } 64 }
68 65
69 /** 66 /**
70 - * 保存线路某个版本下单行的站点和路段路由  
71 - * 常规使用在根据百度地图生成数据或者模板导入的批量保存  
72 - * @param map 67 + * 新增站点
  68 + * @param station
73 * @return 69 * @return
74 */ 70 */
75 - @RequestMapping(value="saveRoutes" , method = RequestMethod.POST)  
76 - public Map<String, Object> saveRoutes(@RequestBody Map<String, Object> map) { 71 + @RequestMapping(value = "/add", method = RequestMethod.POST)
  72 + public Map<String, Object> add(Station station) {
77 Map<String, Object> result = new HashMap<>(); 73 Map<String, Object> result = new HashMap<>();
78 try { 74 try {
79 - if (map.get("lineId") == null || map.get("versions") == null || map.get("directions") == null) {  
80 - throw new IllegalArgumentException("需正确传入线路、方向、版本参数");  
81 - }  
82 - Integer versions = Integer.parseInt(map.get("versions").toString()), directions = Integer.parseInt(map.get("directions").toString()), lineId = Integer.parseInt(map.get("lineId").toString());  
83 - List<LsStationRoute> stationRoutes = mapper.convertValue(map.get("stationRoutes"), mapper.constructType(mapper.getTypeFactory().constructParametricType(List.class, LsStationRoute.class)));  
84 - List<LsSectionRoute> sectionRoutes = mapper.convertValue(map.get("sectionRoutes"), mapper.constructType(mapper.getTypeFactory().constructParametricType(List.class, LsSectionRoute.class)));  
85 -  
86 - result.putAll(service.saveRoutes(lineId, versions, directions, stationRoutes, sectionRoutes)); 75 + stationService.add(station);
87 result.put("status", ResponseCode.SUCCESS); 76 result.put("status", ResponseCode.SUCCESS);
88 } catch (Exception e) { 77 } catch (Exception e) {
89 result.put("status", ResponseCode.ERROR); 78 result.put("status", ResponseCode.ERROR);
  79 + result.put("msg", e.getMessage());
90 log.error("", e); 80 log.error("", e);
91 } 81 }
92 82
@@ -95,14 +85,14 @@ public class StationController extends BaseController&lt;Station, Integer&gt; { @@ -95,14 +85,14 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
95 85
96 /** 86 /**
97 * 更新站点、站点路由信息 87 * 更新站点、站点路由信息
98 - * @param stationRoute 88 + * @param station
99 * @return 89 * @return
100 */ 90 */
101 - @RequestMapping(value="stationUpdate" , method = RequestMethod.POST)  
102 - public Map<String, Object> stationUpdate(LsStationRoute stationRoute) { 91 + @RequestMapping(value="modify" , method = RequestMethod.POST)
  92 + public Map<String, Object> modify(Station station) {
103 Map<String, Object> result = new HashMap<>(); 93 Map<String, Object> result = new HashMap<>();
104 try { 94 try {
105 - service.stationUpdate(stationRoute); 95 + stationService.modify(station);
106 result.put("status", ResponseCode.SUCCESS); 96 result.put("status", ResponseCode.SUCCESS);
107 } catch (Exception e) { 97 } catch (Exception e) {
108 result.put("status", ResponseCode.ERROR); 98 result.put("status", ResponseCode.ERROR);
@@ -117,9 +107,9 @@ public class StationController extends BaseController&lt;Station, Integer&gt; { @@ -117,9 +107,9 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
117 * 107 *
118 * @return int <stationCode站点编码> 108 * @return int <stationCode站点编码>
119 */ 109 */
120 - @RequestMapping(value="getStationCode" , method = RequestMethod.GET)  
121 - public long getStationCode() {  
122 - return stationRepository.stationMaxId() + 1; 110 + @RequestMapping(value="findStationCode" , method = RequestMethod.GET)
  111 + public long findStationCode() {
  112 + return stationService.findLatestStationId() + 1;
123 } 113 }
124 114
125 /** 115 /**
@@ -127,8 +117,8 @@ public class StationController extends BaseController&lt;Station, Integer&gt; { @@ -127,8 +117,8 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
127 * @param stationName 117 * @param stationName
128 * @return 站点列表 118 * @return 站点列表
129 */ 119 */
130 - @RequestMapping(value="getStationByName" , method = RequestMethod.GET)  
131 - public List<Station> getStationByName(String stationName) {  
132 - return service.getStationByName(stationName); 120 + @RequestMapping(value="findStationByName" , method = RequestMethod.GET)
  121 + public List<Station> findStationByName(String stationName) {
  122 + return stationService.findStationByName(stationName);
133 } 123 }
134 } 124 }
src/main/java/com/bsth/controller/StationRouteController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
  3 +import com.bsth.entity.LsStationRoute;
3 import com.bsth.entity.StationRoute; 4 import com.bsth.entity.StationRoute;
4 import com.bsth.repository.StationRouteRepository; 5 import com.bsth.repository.StationRouteRepository;
5 import com.bsth.service.StationRouteService; 6 import com.bsth.service.StationRouteService;
@@ -33,19 +34,14 @@ import java.util.Map; @@ -33,19 +34,14 @@ import java.util.Map;
33 public class StationRouteController extends BaseController<StationRoute, Integer> { 34 public class StationRouteController extends BaseController<StationRoute, Integer> {
34 35
35 @Autowired 36 @Autowired
36 - StationRouteService service; 37 + StationRouteService stationRouteService;
37 @Autowired 38 @Autowired
38 StationRouteRepository stationRouteRepository; 39 StationRouteRepository stationRouteRepository;
39 -  
40 - @RequestMapping(value = "/allls", method = RequestMethod.GET)  
41 - public Map allls(@RequestParam Map<String, Object> map) {  
42 -  
43 - return service.pageLs(map);  
44 - }  
45 40
46 @RequestMapping(value = "/all", method = RequestMethod.GET) 41 @RequestMapping(value = "/all", method = RequestMethod.GET)
  42 + @Override
47 public Iterable<StationRoute> list(@RequestParam Map<String, Object> map) { 43 public Iterable<StationRoute> list(@RequestParam Map<String, Object> map) {
48 - return service.list(map); 44 + return stationRouteService.list(map);
49 } 45 }
50 46
51 /** 47 /**
@@ -57,7 +53,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer @@ -57,7 +53,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
57 */ 53 */
58 @RequestMapping(value = "/export" , method = RequestMethod.GET) 54 @RequestMapping(value = "/export" , method = RequestMethod.GET)
59 public Map<String, Object> export(@RequestParam Integer id, HttpServletResponse resp) { 55 public Map<String, Object> export(@RequestParam Integer id, HttpServletResponse resp) {
60 - return service.getSectionRouteExport(id, resp); 56 + return stationRouteService.getSectionRouteExport(id, resp);
61 } 57 }
62 58
63 /** 59 /**
@@ -68,33 +64,30 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer @@ -68,33 +64,30 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
68 * @return List<Map<String, Object>> 64 * @return List<Map<String, Object>>
69 */ 65 */
70 @RequestMapping(value = "/findStations" , method = RequestMethod.GET) 66 @RequestMapping(value = "/findStations" , method = RequestMethod.GET)
71 - public List<Map<String, Object>> findStations(@RequestParam Map<String, Object> map) {  
72 - return service.findPoints(map); 67 + public Map<String, Object> findStations(@RequestParam Map<String, Object> map) {
  68 + map.put("destroy_eq", 0);
  69 + if (map.get("line.id_eq") == null || map.get("directions_eq") == null || map.get("versions_eq") == null) {
  70 + throw new IllegalArgumentException("需正确传入线路、方向、版本参数");
  71 + }
  72 +
  73 + return stationRouteService.findPoints(map);
73 } 74 }
74 75
75 @RequestMapping(value = "/systemQuote" , method = RequestMethod.POST) 76 @RequestMapping(value = "/systemQuote" , method = RequestMethod.POST)
76 public Map<String, Object> systemQuote(@RequestParam Map<String, Object> map) { 77 public Map<String, Object> systemQuote(@RequestParam Map<String, Object> map) {
77 - return service.systemQuote(map); 78 + return stationRouteService.systemQuote(map);
78 } 79 }
79 - 80 +
80 /** 81 /**
81 * @Description :TODO(查询线路某方向下的站点序号与类型) 82 * @Description :TODO(查询线路某方向下的站点序号与类型)
82 - * 83 + *
83 * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> 84 * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>
84 - *  
85 - * @return List<Map<String, Object>> 85 + *
  86 + * @return List<Map<String, Object>>
86 */ 87 */
87 @RequestMapping(value = "/findUpStationRouteCode" , method = RequestMethod.GET) 88 @RequestMapping(value = "/findUpStationRouteCode" , method = RequestMethod.GET)
88 public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) { 89 public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {
89 - return service.findUpStationRouteCode(map);  
90 - }  
91 -  
92 - /**  
93 - * @Description :TODO(查询站点的下一个缓存站点)  
94 - */  
95 - @RequestMapping(value = "/findDownStationRoute" , method = RequestMethod.GET)  
96 - public List<Map<String, Object>> findDownStationRoute(@RequestParam Map<String, Object> map) {  
97 - return service.findDownStationRoute(map); 90 + return stationRouteService.findUpStationRouteCode(map);
98 } 91 }
99 92
100 /** 93 /**
@@ -106,7 +99,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer @@ -106,7 +99,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
106 */ 99 */
107 @RequestMapping(value = "/getStationRouteCenterPoints" , method = RequestMethod.GET) 100 @RequestMapping(value = "/getStationRouteCenterPoints" , method = RequestMethod.GET)
108 public List<Map<String, Object>> getStationRouteCenterPoints(@RequestParam Map<String, Object> map) { 101 public List<Map<String, Object>> getStationRouteCenterPoints(@RequestParam Map<String, Object> map) {
109 - return service.getStationRouteCenterPoints(map); 102 + return stationRouteService.getStationRouteCenterPoints(map);
110 } 103 }
111 104
112 /** 105 /**
@@ -118,7 +111,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer @@ -118,7 +111,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
118 */ 111 */
119 @RequestMapping(value = "/getStationRouteList" , method = RequestMethod.GET) 112 @RequestMapping(value = "/getStationRouteList" , method = RequestMethod.GET)
120 public List<Map<String, Object>> getStationRouteList(@RequestParam Map<String, Object> map) { 113 public List<Map<String, Object>> getStationRouteList(@RequestParam Map<String, Object> map) {
121 - return service.getStationRouteList(map); 114 + return stationRouteService.getStationRouteList(map);
122 } 115 }
123 116
124 /** 117 /**
@@ -130,20 +123,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer @@ -130,20 +123,7 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
130 */ 123 */
131 @RequestMapping(value = "/usingSingle",method = RequestMethod.POST) 124 @RequestMapping(value = "/usingSingle",method = RequestMethod.POST)
132 public Map<String, Object> usingSingle(@RequestParam Map<String, Object> map) { 125 public Map<String, Object> usingSingle(@RequestParam Map<String, Object> map) {
133 - return service.usingSingle(map);  
134 - }  
135 -  
136 -  
137 - /**  
138 - * @Description : TODO(根据站点路由Id查询详情)  
139 - *  
140 - * @param map <id:站点路由ID>  
141 - *  
142 - * @return List<Map<String, Object>>  
143 - */  
144 - @RequestMapping(value = "/findStationRouteInfo",method = RequestMethod.GET)  
145 - public List<Map<String, Object>> findStationRouteInfo(@RequestParam Map<String, Object> map) {  
146 - return service.findStationRouteInfo(map); 126 + return stationRouteService.usingSingle(map);
147 } 127 }
148 128
149 @RequestMapping(value = "/stations", method = RequestMethod.GET) 129 @RequestMapping(value = "/stations", method = RequestMethod.GET)
@@ -158,65 +138,6 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer @@ -158,65 +138,6 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
158 */ 138 */
159 @RequestMapping(value = "/multiLine", method = RequestMethod.GET) 139 @RequestMapping(value = "/multiLine", method = RequestMethod.GET)
160 public Map<String, Object> findByMultiLine(@RequestParam String lineIds){ 140 public Map<String, Object> findByMultiLine(@RequestParam String lineIds){
161 - return service.findByMultiLine(lineIds);  
162 - }  
163 -  
164 - /**  
165 - *  
166 - * @Title: updSwitchDir  
167 - * @Description: TODO(上下行切换)  
168 - */  
169 - @RequestMapping(value = "/updSwitchDir", method = RequestMethod.POST)  
170 - public Map<String, Object> updSwitchDir(@RequestParam String lineIds, @RequestParam(value = "status", required = false)int status){  
171 - return service.updSwitchDir(lineIds,status); 141 + return stationRouteService.findByMultiLine(lineIds);
172 } 142 }
173 -  
174 - /**  
175 - *  
176 - * @Title: upddis  
177 - * @Description: TODO(更新站距)  
178 - */  
179 - @RequestMapping(value = "/upddis",method = RequestMethod.POST)  
180 - public Map<String, Object> upddis(@RequestParam Map<String, Object> map) {  
181 - return service.upddis(map);  
182 - }  
183 -  
184 - /**  
185 - * 查询博协站点  
186 - * @param map  
187 - * @return  
188 - */  
189 - @RequestMapping(value = "/findMatchStation", method = RequestMethod.GET)  
190 - public Map<String, Object> findMatchStation(@RequestParam Map<String, Object> map){  
191 - return service.findMatchStation(map);  
192 - }  
193 -  
194 - /**  
195 - * 批量修改行业编码  
196 - * @param map  
197 - * @return  
198 - */  
199 - @RequestMapping(value = "/updIndustryCode",method = RequestMethod.POST)  
200 - public Map<String, Object> updIndustryCode(@RequestParam Map<String, Object> map) {  
201 - return service.updIndustryCode(map);  
202 - }  
203 -  
204 - /**  
205 - * 匹配外部站点行业编码  
206 - * @param map  
207 - * @return  
208 - */  
209 - @RequestMapping(value = "/matchIndustryCode",method = RequestMethod.POST)  
210 - public Map<String, Object> matchIndustryCode(@RequestParam Map<String, Object> map) {  
211 - return service.matchIndustryCode(map);  
212 - }  
213 - /**  
214 - * 匹配附近站点行业编码  
215 - * @param map  
216 - * @return  
217 - */  
218 - @RequestMapping(value = "/matchNearbyStation",method = RequestMethod.GET)  
219 - public Map<String, Object> matchNearbyStation(@RequestParam Map<String, Object> map) {  
220 - return service.matchNearbyStation(map);  
221 - }  
222 } 143 }
src/main/java/com/bsth/controller/test/GpsTestController.java
1 -package com.bsth.controller.test;  
2 -  
3 -import java.util.HashMap;  
4 -import java.util.List;  
5 -import java.util.Map;  
6 -  
7 -import org.springframework.beans.factory.annotation.Autowired;  
8 -import org.springframework.web.bind.annotation.RequestMapping;  
9 -import org.springframework.web.bind.annotation.RequestParam;  
10 -import org.springframework.web.bind.annotation.RestController;  
11 -  
12 -import com.bsth.service.StationRouteService;  
13 -  
14 -@RestController  
15 -@RequestMapping("/test/gps")  
16 -public class GpsTestController {  
17 -  
18 - @Autowired  
19 - StationRouteService stationRouteService;  
20 -  
21 - @RequestMapping(value = "/route")  
22 - public List<Map<String, Object>> findRouteByLineId(@RequestParam int xl,@RequestParam int directions){  
23 - Map<String, Object> map = new HashMap<>();  
24 - map.put("line.id_eq", xl);  
25 - map.put("directions_eq", directions);  
26 -  
27 - List<Map<String, Object>> list = stationRouteService.findPoints(map);  
28 - return list;  
29 - }  
30 -} 1 +package com.bsth.controller.test;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.service.StationRouteService;
  13 +
  14 +@RestController
  15 +@RequestMapping("/test/gps")
  16 +public class GpsTestController {
  17 +
  18 + @Autowired
  19 + StationRouteService stationRouteService;
  20 +
  21 + @RequestMapping(value = "/route")
  22 + public Map<String, Object> findRouteByLineId(@RequestParam int xl,@RequestParam int directions){
  23 + Map<String, Object> map = new HashMap<>();
  24 + map.put("line.id_eq", xl);
  25 + map.put("directions_eq", directions);
  26 +
  27 + return stationRouteService.findPoints(map);
  28 + }
  29 +}
src/main/java/com/bsth/entity/Line.java
@@ -170,6 +170,12 @@ public class Line implements Serializable { @@ -170,6 +170,12 @@ public class Line implements Serializable {
170 * 逻辑删除标记 为 1:标识已删除 170 * 逻辑删除标记 为 1:标识已删除
171 */ 171 */
172 private Integer remove = 0; 172 private Integer remove = 0;
  173 +
  174 + /**
  175 + * 线路撤销时间
  176 + */
  177 + @DateTimeFormat(pattern ="yyyy-MM-dd")
  178 + private Date revokeDate;
173 179
174 public Integer getSpacGrade() { 180 public Integer getSpacGrade() {
175 return spacGrade; 181 return spacGrade;
@@ -526,5 +532,12 @@ public class Line implements Serializable { @@ -526,5 +532,12 @@ public class Line implements Serializable {
526 public void setTicketPrice(String ticketPrice) { 532 public void setTicketPrice(String ticketPrice) {
527 this.ticketPrice = ticketPrice; 533 this.ticketPrice = ticketPrice;
528 } 534 }
529 - 535 +
  536 + public Date getRevokeDate() {
  537 + return revokeDate;
  538 + }
  539 +
  540 + public void setRevokeDate(Date revokeDate) {
  541 + this.revokeDate = revokeDate;
  542 + }
530 } 543 }
src/main/java/com/bsth/entity/LsStationRoute.java
@@ -355,6 +355,10 @@ public class LsStationRoute { @@ -355,6 +355,10 @@ public class LsStationRoute {
355 } 355 }
356 356
357 public String getBufferPolygonWkt() { 357 public String getBufferPolygonWkt() {
  358 + if (bufferPolygonWkt == null && bufferPolygon != null) {
  359 + bufferPolygonWkt = bufferPolygon.toString();
  360 + }
  361 +
358 return bufferPolygonWkt; 362 return bufferPolygonWkt;
359 } 363 }
360 364
@@ -371,6 +375,10 @@ public class LsStationRoute { @@ -371,6 +375,10 @@ public class LsStationRoute {
371 } 375 }
372 376
373 public String getBufferPolygonWgsWkt() { 377 public String getBufferPolygonWgsWkt() {
  378 + if (bufferPolygonWgsWkt == null && bufferPolygonWgs != null) {
  379 + bufferPolygonWgsWkt = bufferPolygonWgs.toString();
  380 + }
  381 +
374 return bufferPolygonWgsWkt; 382 return bufferPolygonWgsWkt;
375 } 383 }
376 384
src/main/java/com/bsth/entity/Road.java deleted 100644 → 0
1 -package com.bsth.entity;  
2 -  
3 -import javax.persistence.Entity;  
4 -import javax.persistence.Id;  
5 -import javax.persistence.Table;  
6 -  
7 -@Entity  
8 -@Table(name = "bsth_c_road")  
9 -public class Road {  
10 -  
11 - @Id  
12 - /*@GeneratedValue(strategy = GenerationType.IDENTITY)*/  
13 - private Integer id;  
14 -  
15 - // 路段编码  
16 - private String roadCode;  
17 -  
18 - // 路段名称  
19 - private String roadName;  
20 -  
21 - // 路段矢量(空间坐标点集合)--百度原始坐标坐标点  
22 - private String broadVector;  
23 -  
24 - // 路段矢量(空间坐标点集合)--GPS坐标点  
25 - private String groadVector;  
26 -  
27 - // 限速  
28 - private Double speed;  
29 -  
30 - public Integer getId() {  
31 - return id;  
32 - }  
33 -  
34 - public void setId(Integer id) {  
35 - this.id = id;  
36 - }  
37 -  
38 - public String getRoadCode() {  
39 - return roadCode;  
40 - }  
41 -  
42 - public void setRoadCode(String roadCode) {  
43 - this.roadCode = roadCode;  
44 - }  
45 -  
46 - public String getRoadName() {  
47 - return roadName;  
48 - }  
49 -  
50 - public void setRoadName(String roadName) {  
51 - this.roadName = roadName;  
52 - }  
53 -  
54 - public String getBroadVector() {  
55 - return broadVector;  
56 - }  
57 -  
58 - public void setBroadVector(String broadVector) {  
59 - this.broadVector = broadVector;  
60 - }  
61 -  
62 - public String getGroadVector() {  
63 - return groadVector;  
64 - }  
65 -  
66 - public void setGroadVector(String groadVector) {  
67 - this.groadVector = groadVector;  
68 - }  
69 -  
70 - public Double getSpeed() {  
71 - return speed;  
72 - }  
73 -  
74 - public void setSpeed(Double speed) {  
75 - this.speed = speed;  
76 - }  
77 -}  
src/main/java/com/bsth/entity/RoadSpeed.java deleted 100644 → 0
1 -package com.bsth.entity;  
2 -  
3 -import java.util.Date;  
4 -  
5 -import javax.persistence.Column;  
6 -import javax.persistence.Entity;  
7 -import javax.persistence.GeneratedValue;  
8 -import javax.persistence.GenerationType;  
9 -import javax.persistence.Id;  
10 -import javax.persistence.Table;  
11 -  
12 -@Entity  
13 -@Table(name = "bsth_c_road_speed")  
14 -public class RoadSpeed {  
15 -  
16 - @Id  
17 - @GeneratedValue(strategy = GenerationType.IDENTITY)  
18 - private Integer id;  
19 -  
20 - // 路段名称  
21 - private String name;  
22 -  
23 - // 路段矢量(空间坐标点集合)--GPS坐标点  
24 - private String bRoadVector;  
25 -  
26 - // 路段矢量(空间坐标点集合)--百度坐标点  
27 - private String gRoadVector;  
28 -  
29 - // 限速 (km/h)  
30 - private Double speed;  
31 -  
32 - // 限速开始时间  
33 - private String speedStartDate;  
34 -  
35 - // 限速结束时间  
36 - private String speedEndDate;  
37 -  
38 - // 是否启用限速(0:启用、1:未启用)  
39 - private int isStart;  
40 -  
41 - // 预留字段(限速的线路)  
42 - private String line;  
43 -  
44 - // 创建日期 timestamp  
45 - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")  
46 - private Date createDate;  
47 -  
48 - // 修改日期 timestamp  
49 - @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")  
50 - private Date updateDate;  
51 -  
52 - public Integer getId() {  
53 - return id;  
54 - }  
55 -  
56 - public String getName() {  
57 - return name;  
58 - }  
59 -  
60 - public String getbRoadVector() {  
61 - return bRoadVector;  
62 - }  
63 -  
64 - public String getgRoadVector() {  
65 - return gRoadVector;  
66 - }  
67 -  
68 - public Double getSpeed() {  
69 - return speed;  
70 - }  
71 -  
72 - public String getSpeedStartDate() {  
73 - return speedStartDate;  
74 - }  
75 -  
76 - public String getSpeedEndDate() {  
77 - return speedEndDate;  
78 - }  
79 -  
80 - public int getIsStart() {  
81 - return isStart;  
82 - }  
83 -  
84 - public String getLine() {  
85 - return line;  
86 - }  
87 -  
88 - public Date getCreateDate() {  
89 - return createDate;  
90 - }  
91 -  
92 - public Date getUpdateDate() {  
93 - return updateDate;  
94 - }  
95 -  
96 - public void setId(Integer id) {  
97 - this.id = id;  
98 - }  
99 -  
100 - public void setName(String name) {  
101 - this.name = name;  
102 - }  
103 -  
104 - public void setbRoadVector(String bRoadVector) {  
105 - this.bRoadVector = bRoadVector;  
106 - }  
107 -  
108 - public void setgRoadVector(String gRoadVector) {  
109 - this.gRoadVector = gRoadVector;  
110 - }  
111 -  
112 - public void setSpeed(Double speed) {  
113 - this.speed = speed;  
114 - }  
115 -  
116 - public void setSpeedStartDate(String speedStartDate) {  
117 - this.speedStartDate = speedStartDate;  
118 - }  
119 -  
120 - public void setSpeedEndDate(String speedEndDate) {  
121 - this.speedEndDate = speedEndDate;  
122 - }  
123 -  
124 - public void setIsStart(int isStart) {  
125 - this.isStart = isStart;  
126 - }  
127 -  
128 - public void setLine(String line) {  
129 - this.line = line;  
130 - }  
131 -  
132 - public void setCreateDate(Date createDate) {  
133 - this.createDate = createDate;  
134 - }  
135 -  
136 - public void setUpdateDate(Date updateDate) {  
137 - this.updateDate = updateDate;  
138 - }  
139 -  
140 - @Override  
141 - public String toString() {  
142 - return "RoadSpeed [id=" + id + ", name=" + name + ", bRoadVector=" + bRoadVector + ", gRoadVector="  
143 - + gRoadVector + ", speed=" + speed + ", speedStartDate=" + speedStartDate + ", speedEndDate="  
144 - + speedEndDate + ", isStart=" + isStart + ", line=" + line + ", createDate=" + createDate  
145 - + ", updateDate=" + updateDate + "]";  
146 - }  
147 -  
148 -  
149 -}  
src/main/java/com/bsth/entity/Section.java
@@ -151,6 +151,10 @@ public class Section{ @@ -151,6 +151,10 @@ public class Section{
151 @Column(insertable = false, name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") 151 @Column(insertable = false, name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
152 private Date updateDate; 152 private Date updateDate;
153 153
  154 + private Integer ewDirection;
  155 +
  156 + private Integer snDirection;
  157 +
154 public Integer getId() { 158 public Integer getId() {
155 return id; 159 return id;
156 } 160 }
@@ -362,5 +366,20 @@ public class Section{ @@ -362,5 +366,20 @@ public class Section{
362 public void setUpdateDate(Date updateDate) { 366 public void setUpdateDate(Date updateDate) {
363 this.updateDate = updateDate; 367 this.updateDate = updateDate;
364 } 368 }
365 - 369 +
  370 + public Integer getEwDirection() {
  371 + return ewDirection;
  372 + }
  373 +
  374 + public void setEwDirection(Integer ewDirection) {
  375 + this.ewDirection = ewDirection;
  376 + }
  377 +
  378 + public Integer getSnDirection() {
  379 + return snDirection;
  380 + }
  381 +
  382 + public void setSnDirection(Integer snDirection) {
  383 + this.snDirection = snDirection;
  384 + }
366 } 385 }
src/main/java/com/bsth/entity/SectionSpeed.java deleted 100644 → 0
1 -package com.bsth.entity;  
2 -  
3 -import javax.persistence.Entity;  
4 -import javax.persistence.GeneratedValue;  
5 -import javax.persistence.GenerationType;  
6 -import javax.persistence.Id;  
7 -import javax.persistence.ManyToOne;  
8 -import javax.persistence.Table;  
9 -  
10 -/**  
11 - * @description TODO(路段限速)  
12 - *  
13 - * @author bsth@lq  
14 - *  
15 - * @date 2016年9月14日 14:15:42  
16 - */  
17 -  
18 -  
19 -@Entity  
20 -@Table(name = "bsth_c_sectionspeed")  
21 -public class SectionSpeed {  
22 -  
23 - @Id  
24 - @GeneratedValue(strategy = GenerationType.IDENTITY)  
25 - private Integer id;  
26 -  
27 - // 线路信息  
28 - @ManyToOne  
29 - private Line line;  
30 -  
31 - @ManyToOne  
32 - private Road road;  
33 -  
34 - /** 线路编码 */  
35 - private String lineCode;  
36 -  
37 - private String roadCode;  
38 -  
39 - /** 方向*/  
40 - private Integer directions;  
41 -  
42 - /** 序号*/  
43 - private Integer code;  
44 -  
45 - /** 路段名称 */  
46 - private String sName;  
47 -  
48 - public String getRoadCode() {  
49 - return roadCode;  
50 - }  
51 -  
52 - public void setRoadCode(String roadCode) {  
53 - this.roadCode = roadCode;  
54 - }  
55 -  
56 - public Road getRoad() {  
57 - return road;  
58 - }  
59 -  
60 - public void setRoad(Road road) {  
61 - this.road = road;  
62 - }  
63 -  
64 - public Integer getDirections() {  
65 - return directions;  
66 - }  
67 -  
68 - public void setDirections(Integer directions) {  
69 - this.directions = directions;  
70 - }  
71 -  
72 - public Integer getCode() {  
73 - return code;  
74 - }  
75 -  
76 - public void setCode(Integer code) {  
77 - this.code = code;  
78 - }  
79 -  
80 - public Integer getId() {  
81 - return id;  
82 - }  
83 -  
84 - public void setId(Integer id) {  
85 - this.id = id;  
86 - }  
87 -  
88 - public Line getLine() {  
89 - return line;  
90 - }  
91 -  
92 - public void setLine(Line line) {  
93 - this.line = line;  
94 - }  
95 -  
96 - public String getLineCode() {  
97 - return lineCode;  
98 - }  
99 -  
100 - public void setLineCode(String lineCode) {  
101 - this.lineCode = lineCode;  
102 - }  
103 -  
104 - public String getsName() {  
105 - return sName;  
106 - }  
107 -  
108 - public void setsName(String sName) {  
109 - this.sName = sName;  
110 - }  
111 -  
112 -}  
src/main/java/com/bsth/entity/Station.java
@@ -36,7 +36,7 @@ import java.util.Date; @@ -36,7 +36,7 @@ import java.util.Date;
36 public class Station { 36 public class Station {
37 37
38 @Id 38 @Id
39 -// @GeneratedValue(strategy = GenerationType.IDENTITY) 39 + @GeneratedValue(strategy = GenerationType.IDENTITY)
40 private Integer id; 40 private Integer id;
41 41
42 /** 42 /**
@@ -128,9 +128,14 @@ public class Station { @@ -128,9 +128,14 @@ public class Station {
128 /** 128 /**
129 * 途经线路 129 * 途经线路
130 */ 130 */
131 - @Transient  
132 private String passLines; 131 private String passLines;
133 132
  133 + private Integer ewDirection;
  134 +
  135 + private Integer snDirection;
  136 +
  137 + private String standardStationCode;
  138 +
134 public Integer getId() { 139 public Integer getId() {
135 return id; 140 return id;
136 } 141 }
@@ -298,4 +303,28 @@ public class Station { @@ -298,4 +303,28 @@ public class Station {
298 public void setPassLines(String passLines) { 303 public void setPassLines(String passLines) {
299 this.passLines = passLines; 304 this.passLines = passLines;
300 } 305 }
  306 +
  307 + public Integer getEwDirection() {
  308 + return ewDirection;
  309 + }
  310 +
  311 + public void setEwDirection(Integer ewDirection) {
  312 + this.ewDirection = ewDirection;
  313 + }
  314 +
  315 + public Integer getSnDirection() {
  316 + return snDirection;
  317 + }
  318 +
  319 + public void setSnDirection(Integer snDirection) {
  320 + this.snDirection = snDirection;
  321 + }
  322 +
  323 + public String getStandardStationCode() {
  324 + return standardStationCode;
  325 + }
  326 +
  327 + public void setStandardStationCode(String standardStationCode) {
  328 + this.standardStationCode = standardStationCode;
  329 + }
301 } 330 }
src/main/java/com/bsth/entity/StationRoute.java
@@ -390,6 +390,10 @@ public class StationRoute { @@ -390,6 +390,10 @@ public class StationRoute {
390 } 390 }
391 391
392 public String getBufferPolygonWkt() { 392 public String getBufferPolygonWkt() {
  393 + if (bufferPolygonWkt == null && bufferPolygon != null) {
  394 + bufferPolygonWkt = bufferPolygon.toString();
  395 + }
  396 +
393 return bufferPolygonWkt; 397 return bufferPolygonWkt;
394 } 398 }
395 399
@@ -406,6 +410,10 @@ public class StationRoute { @@ -406,6 +410,10 @@ public class StationRoute {
406 } 410 }
407 411
408 public String getBufferPolygonWgsWkt() { 412 public String getBufferPolygonWgsWkt() {
  413 + if (bufferPolygonWgsWkt == null && bufferPolygonWgs != null) {
  414 + bufferPolygonWgsWkt = bufferPolygonWgs.toString();
  415 + }
  416 +
409 return bufferPolygonWgsWkt; 417 return bufferPolygonWgsWkt;
410 } 418 }
411 419
src/main/java/com/bsth/entity/sys/OperationLog.java 0 → 100644
  1 +package com.bsth.entity.sys;
  2 +
  3 +import java.util.Date;
  4 +
  5 +/**
  6 + * @author Hill
  7 + */
  8 +public class OperationLog {
  9 +
  10 + /**
  11 + *
  12 + */
  13 + private Integer id;
  14 +
  15 + /**
  16 + * 日期 yyyy-MM-dd
  17 + */
  18 + private String rq;
  19 +
  20 + /**
  21 + * 业务
  22 + */
  23 + private String business;
  24 +
  25 + /**
  26 + * 操作人
  27 + */
  28 + private String operateUser;
  29 +
  30 + /**
  31 + * 操作时间
  32 + */
  33 + private Date operateDate;
  34 +
  35 + /**
  36 + * 操作参数 json
  37 + */
  38 + private String params;
  39 +
  40 + public Integer getId() {
  41 + return id;
  42 + }
  43 +
  44 + public void setId(Integer id) {
  45 + this.id = id;
  46 + }
  47 +
  48 + public String getRq() {
  49 + return rq;
  50 + }
  51 +
  52 + public void setRq(String rq) {
  53 + this.rq = rq;
  54 + }
  55 +
  56 + public String getBusiness() {
  57 + return business;
  58 + }
  59 +
  60 + public void setBusiness(String business) {
  61 + this.business = business;
  62 + }
  63 +
  64 + public String getOperateUser() {
  65 + return operateUser;
  66 + }
  67 +
  68 + public void setOperateUser(String operateUser) {
  69 + this.operateUser = operateUser;
  70 + }
  71 +
  72 + public Date getOperateDate() {
  73 + return operateDate;
  74 + }
  75 +
  76 + public void setOperateDate(Date operateDate) {
  77 + this.operateDate = operateDate;
  78 + }
  79 +
  80 + public String getParams() {
  81 + return params;
  82 + }
  83 +
  84 + public void setParams(String params) {
  85 + this.params = params;
  86 + }
  87 +}
src/main/java/com/bsth/message/handler/MessageHandler.java
@@ -28,7 +28,7 @@ public class MessageHandler { @@ -28,7 +28,7 @@ public class MessageHandler {
28 @Autowired 28 @Autowired
29 private ObjectMapper mapper; 29 private ObjectMapper mapper;
30 30
31 - @KafkaListener(topics="schedule-mainsys-carerrorstop") 31 + @KafkaListener(topics="schedule-main-carerrorstop")
32 public void receivedCarErrorStop(Message<String> message) { 32 public void receivedCarErrorStop(Message<String> message) {
33 try { 33 try {
34 List<CarErrorStop> carErrorStopList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarErrorStop.class)); 34 List<CarErrorStop> carErrorStopList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarErrorStop.class));
@@ -40,7 +40,7 @@ public class MessageHandler { @@ -40,7 +40,7 @@ public class MessageHandler {
40 } 40 }
41 } 41 }
42 42
43 - @KafkaListener(topics="schedule-mainsys-carenergy") 43 + @KafkaListener(topics="schedule-main-carenergy")
44 public void receivedCarEnergy(Message<String> message) { 44 public void receivedCarEnergy(Message<String> message) {
45 try { 45 try {
46 List<CarEnergy> carEnergyList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarEnergy.class)); 46 List<CarEnergy> carEnergyList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarEnergy.class));
@@ -52,7 +52,7 @@ public class MessageHandler { @@ -52,7 +52,7 @@ public class MessageHandler {
52 } 52 }
53 } 53 }
54 54
55 - @KafkaListener(topics="schedule-mainsys-inoutpark") 55 + @KafkaListener(topics="schedule-main-inoutpark")
56 public void receivedInoutPark(Message<String> message) { 56 public void receivedInoutPark(Message<String> message) {
57 try { 57 try {
58 List<InoutPark> inoutParkList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, InoutPark.class)); 58 List<InoutPark> inoutParkList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, InoutPark.class));
src/main/java/com/bsth/oplog/Level.java deleted 100644 → 0
1 -package com.bsth.oplog;  
2 -  
3 -public enum Level {  
4 -  
5 - ERROR,WARN,INFO,ACCESS;  
6 -}  
src/main/java/com/bsth/oplog/Log.java deleted 100644 → 0
1 -package com.bsth.oplog;  
2 -  
3 -import java.util.Date;  
4 -  
5 -public class Log {  
6 -  
7 - private String userName;  
8 -  
9 - private Long timestamp;  
10 -  
11 - private String type;  
12 -  
13 - private String level;  
14 -  
15 - private String path;  
16 -  
17 - private String serverIp;  
18 -  
19 - private String clientIp;  
20 -  
21 - private String httpData;  
22 -  
23 - private Date month;  
24 -  
25 - private String callerClass;  
26 -  
27 - private String callerMethod;  
28 -  
29 - private Integer lineNumber;  
30 -  
31 - public String getPath() {  
32 - return path;  
33 - }  
34 -  
35 - public void setPath(String path) {  
36 - this.path = path;  
37 - }  
38 -  
39 - public String getServerIp() {  
40 - return serverIp;  
41 - }  
42 -  
43 - public void setServerIp(String serverIp) {  
44 - this.serverIp = serverIp;  
45 - }  
46 -  
47 - public String getHttpData() {  
48 - return httpData;  
49 - }  
50 -  
51 - public void setHttpData(String httpData) {  
52 - this.httpData = httpData;  
53 - }  
54 -  
55 - public Date getMonth() {  
56 - return month;  
57 - }  
58 -  
59 - public void setMonth(Date month) {  
60 - this.month = month;  
61 - }  
62 -  
63 - public String getType() {  
64 - return type;  
65 - }  
66 -  
67 - public void setType(String type) {  
68 - this.type = type;  
69 - }  
70 -  
71 - public String getLevel() {  
72 - return level;  
73 - }  
74 -  
75 - public void setLevel(String level) {  
76 - this.level = level;  
77 - }  
78 -  
79 - public String getCallerClass() {  
80 - return callerClass;  
81 - }  
82 -  
83 - public void setCallerClass(String callerClass) {  
84 - this.callerClass = callerClass;  
85 - }  
86 -  
87 - public String getCallerMethod() {  
88 - return callerMethod;  
89 - }  
90 -  
91 - public void setCallerMethod(String callerMethod) {  
92 - this.callerMethod = callerMethod;  
93 - }  
94 -  
95 - public String getClientIp() {  
96 - return clientIp;  
97 - }  
98 -  
99 - public void setClientIp(String clientIp) {  
100 - this.clientIp = clientIp;  
101 - }  
102 -  
103 - public String getUserName() {  
104 - return userName;  
105 - }  
106 -  
107 - public void setUserName(String userName) {  
108 - this.userName = userName;  
109 - }  
110 -  
111 - public Long getTimestamp() {  
112 - return timestamp;  
113 - }  
114 -  
115 - public void setTimestamp(Long timestamp) {  
116 - this.timestamp = timestamp;  
117 - }  
118 -  
119 - public Integer getLineNumber() {  
120 - return lineNumber;  
121 - }  
122 -  
123 - public void setLineNumber(Integer lineNumber) {  
124 - this.lineNumber = lineNumber;  
125 - }  
126 -}  
src/main/java/com/bsth/oplog/OperationLogger.java 0 → 100644
  1 +package com.bsth.oplog;
  2 +
  3 +import com.bsth.annotation.BusinessDescription;
  4 +import com.bsth.entity.sys.OperationLog;
  5 +import com.bsth.entity.sys.SysUser;
  6 +import com.bsth.security.util.SecurityUtils;
  7 +import com.fasterxml.jackson.core.JsonProcessingException;
  8 +import com.fasterxml.jackson.databind.ObjectMapper;
  9 +import org.aspectj.lang.JoinPoint;
  10 +import org.aspectj.lang.annotation.After;
  11 +import org.aspectj.lang.annotation.Aspect;
  12 +import org.aspectj.lang.reflect.MethodSignature;
  13 +import org.joda.time.DateTime;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  18 +import org.springframework.kafka.core.KafkaTemplate;
  19 +import org.springframework.kafka.support.SendResult;
  20 +import org.springframework.scheduling.annotation.EnableScheduling;
  21 +import org.springframework.scheduling.annotation.Scheduled;
  22 +import org.springframework.stereotype.Component;
  23 +import org.springframework.util.concurrent.ListenableFuture;
  24 +import org.springframework.util.concurrent.ListenableFutureCallback;
  25 +
  26 +import java.util.*;
  27 +import java.util.concurrent.ConcurrentLinkedQueue;
  28 +
  29 +/**
  30 + * @author Hill
  31 + */
  32 +@EnableScheduling
  33 +@Aspect
  34 +@Component
  35 +@ConditionalOnProperty("kafka.use")
  36 +public class OperationLogger {
  37 +
  38 + private final static Logger logger = LoggerFactory.getLogger(OperationLogger.class);
  39 +
  40 + @Autowired
  41 + private KafkaTemplate kafkaTemplate;
  42 +
  43 + @Autowired
  44 + private ObjectMapper mapper;
  45 +
  46 + private Queue<OperationLog> queue = new ConcurrentLinkedQueue<>();
  47 +
  48 + @After(value = "execution(public * com.bsth.service.impl.*.add*(..)) || execution(public * com.bsth.service.impl.*.modify*(..)) || execution(public * com.bsth.service.impl.*.remove*(..)) || execution(public * com.bsth.service.impl.*.batch*(..))")
  49 + public void recordParams(JoinPoint point) {
  50 + OperationLog operationLog = new OperationLog();
  51 + DateTime dateTime = new DateTime();
  52 + SysUser user = SecurityUtils.getCurrentUser();
  53 + MethodSignature signature = (MethodSignature) point.getSignature();
  54 + BusinessDescription description = signature.getMethod().getAnnotation(BusinessDescription.class);
  55 + operationLog.setRq(dateTime.toString("yyyy-MM-dd"));
  56 + operationLog.setOperateDate(dateTime.toDate());
  57 + if (user != null) {
  58 + operationLog.setOperateUser(user.getUserName());
  59 + }
  60 + if (description != null) {
  61 + operationLog.setBusiness(description.value());
  62 + }
  63 + try {
  64 + operationLog.setParams(mapper.writeValueAsString(point.getArgs()));
  65 + } catch (JsonProcessingException e) {
  66 + e.printStackTrace();
  67 + }
  68 + queue.add(operationLog);
  69 + }
  70 +
  71 + @Scheduled(cron = "0/10 * * * * ?")
  72 + public void sendMessage() {
  73 + String message = null;
  74 + Map<String, Object> map = new HashMap<>();
  75 + List<OperationLog> logs = new ArrayList<>();
  76 + OperationLog log = null;
  77 + map.put("type", "operate");
  78 + map.put("data", logs);
  79 + while ((log = queue.poll()) != null) {
  80 + logs.add(log);
  81 + }
  82 + if (logs.size() < 1) {
  83 + return;
  84 + }
  85 + try {
  86 + message = mapper.writeValueAsString(map);
  87 + } catch (JsonProcessingException e) {
  88 + e.printStackTrace();
  89 + }
  90 + if (message != null) {
  91 + ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("schedule-main-log", message);
  92 + future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
  93 +
  94 + @Override
  95 + public void onSuccess(SendResult<String, String> result) {
  96 +
  97 + }
  98 +
  99 + @Override
  100 + public void onFailure(Throwable ex) {
  101 + logger.error("kafka发送系统日志异常", ex);
  102 + }
  103 + });
  104 + }
  105 + }
  106 +}
src/main/java/com/bsth/oplog/db/DBHelper.java deleted 100644 → 0
1 -package com.bsth.oplog.db;  
2 -  
3 -import java.util.LinkedList;  
4 -import java.util.concurrent.TimeUnit;  
5 -  
6 -import org.springframework.beans.factory.annotation.Autowired;  
7 -import org.springframework.boot.CommandLineRunner;  
8 -import org.springframework.stereotype.Component;  
9 -  
10 -import com.bsth.Application;  
11 -import com.bsth.oplog.Log;  
12 -import com.bsth.oplog.db.mysql.DBPersistence;  
13 -  
14 -@Component  
15 -public class DBHelper implements CommandLineRunner{  
16 -  
17 - private final static int maxBufSize = 1000;  
18 - private final static int fixedMinute = 10;  
19 -  
20 - private static LinkedList<Log> buffer = new LinkedList<>();  
21 -  
22 - @Autowired  
23 - private FixedTimePersistenceThread fixedTimeThread;  
24 -  
25 - public void save(Log log){  
26 - buffer.add(log);  
27 -  
28 - if(buffer.size() >= maxBufSize)  
29 - fixedTimeThread.start();  
30 - }  
31 -  
32 - @Component  
33 - public static class FixedTimePersistenceThread extends Thread{  
34 -  
35 - @Autowired  
36 - DBPersistence persistence;  
37 -  
38 - @Override  
39 - public void run() {  
40 - persistence.batchSave(buffer);  
41 - }  
42 - }  
43 -  
44 - @Override  
45 - public void run(String... arg0) throws Exception {  
46 - //Application.mainServices.scheduleWithFixedDelay(fixedTimeThread, fixedMinute, fixedMinute, TimeUnit.MINUTES);  
47 - }  
48 -}  
src/main/java/com/bsth/oplog/db/mysql/DBPersistence.java deleted 100644 → 0
1 -package com.bsth.oplog.db.mysql;  
2 -  
3 -import java.sql.Date;  
4 -import java.sql.PreparedStatement;  
5 -import java.sql.SQLException;  
6 -import java.util.ArrayList;  
7 -import java.util.LinkedList;  
8 -import java.util.List;  
9 -  
10 -import org.slf4j.Logger;  
11 -import org.slf4j.LoggerFactory;  
12 -import org.springframework.beans.factory.annotation.Autowired;  
13 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
14 -import org.springframework.jdbc.core.JdbcTemplate;  
15 -import org.springframework.stereotype.Component;  
16 -  
17 -import com.bsth.oplog.Log;  
18 -  
19 -/**  
20 - *  
21 - * @ClassName: DBPersistence  
22 - * @Description: TODO(mysql 批量入库)  
23 - * @author PanZhao  
24 - * @date 2016年10月20日 上午9:44:00  
25 - *  
26 - */  
27 -@Component  
28 -public class DBPersistence {  
29 -  
30 - @Autowired  
31 - JdbcTemplate jdbcTemplate;  
32 -  
33 - Logger logger = LoggerFactory.getLogger(DBPersistence.class);  
34 -  
35 - public void batchSave(LinkedList<Log> list){  
36 - String sql = "insert into bsth_c_sys_op_log"  
37 - + "(timestamp, path, type,level, caller_class, caller_method, user_name, client_ip, server_ip, month, http_data, line_number)"  
38 - + " values(?,?,?,?,?,?,?,?,?,?,?,?)";  
39 -  
40 -  
41 - List<Log> saveList = new ArrayList<>(list.size());  
42 - Log log;  
43 - while(true){  
44 - log = list.poll();  
45 - if(log != null)  
46 - saveList.add(log);  
47 - else  
48 - break;  
49 - }  
50 -  
51 - Date month = new Date(System.currentTimeMillis());  
52 -  
53 - try {  
54 - jdbcTemplate.batchUpdate(sql, new LogBatchPreparedStatementSetter(saveList, month));  
55 - } catch (Exception e) {  
56 - logger.error("操作日志入库失败", e);  
57 - }  
58 - }  
59 -  
60 - private class LogBatchPreparedStatementSetter implements BatchPreparedStatementSetter{  
61 -  
62 - List<Log> temList;  
63 - Date month;  
64 -  
65 - public LogBatchPreparedStatementSetter(final List<Log> list, Date month){  
66 - this.temList = list;  
67 - this.month = month;  
68 - }  
69 -  
70 - @Override  
71 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
72 - Log log = temList.get(i);  
73 - ps.setLong(1, log.getTimestamp());  
74 - ps.setString(2, log.getPath());  
75 - ps.setString(3, log.getType());  
76 - ps.setString(4, log.getLevel());  
77 - ps.setString(5, log.getCallerClass());  
78 - ps.setString(6, log.getCallerMethod());  
79 - ps.setString(7, log.getUserName());  
80 - ps.setString(8, log.getClientIp());  
81 - ps.setString(9, log.getServerIp());  
82 - ps.setDate(10, month);  
83 - ps.setString(11, log.getHttpData());  
84 - ps.setObject(12, log.getLineNumber());  
85 - }  
86 -  
87 - @Override  
88 - public int getBatchSize() {  
89 - return temList.size();  
90 - }  
91 - }  
92 -}  
src/main/java/com/bsth/oplog/db/mysql/db.sql deleted 100644 → 0
1 -CREATE TABLE `bsth_c_sys_op_log` (  
2 -`timestamp` bigint(20) NOT NULL ,  
3 -`user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
4 -`caller_class` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
5 -`caller_method` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
6 -`client_ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
7 -`http_data` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,  
8 -`level` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
9 -`month` date NOT NULL ,  
10 -`path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
11 -`server_ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,  
12 -`type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,  
13 -`line_number` int(11) NULL DEFAULT NULL  
14 -)  
15 -ENGINE=InnoDB  
16 -DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci  
17 -ROW_FORMAT=DYNAMIC  
18 -  
19 -PARTITION BY RANGE(TO_DAYS (month))  
20 -(  
21 -PARTITION p201610 VALUES LESS THAN (TO_DAYS('2016-11-01')),  
22 -PARTITION p201611 VALUES LESS THAN (TO_DAYS('2016-12-01')),  
23 -PARTITION p201612 VALUES LESS THAN (TO_DAYS('2017-01-01')),  
24 -  
25 -PARTITION p201701 VALUES LESS THAN (TO_DAYS('2017-02-01')),  
26 -PARTITION p201702 VALUES LESS THAN (TO_DAYS('2017-03-01')),  
27 -PARTITION p201703 VALUES LESS THAN (TO_DAYS('2017-04-01')),  
28 -PARTITION p201704 VALUES LESS THAN (TO_DAYS('2017-05-01')),  
29 -PARTITION p201705 VALUES LESS THAN (TO_DAYS('2017-06-01')),  
30 -PARTITION p201706 VALUES LESS THAN (TO_DAYS('2017-07-01')),  
31 -PARTITION p201707 VALUES LESS THAN (TO_DAYS('2017-08-01')),  
32 -PARTITION p201708 VALUES LESS THAN (TO_DAYS('2017-09-01')),  
33 -PARTITION p201709 VALUES LESS THAN (TO_DAYS('2017-10-01')),  
34 -PARTITION p201710 VALUES LESS THAN (TO_DAYS('2017-11-01')),  
35 -PARTITION p201711 VALUES LESS THAN (TO_DAYS('2017-12-01')),  
36 -PARTITION p201712 VALUES LESS THAN (TO_DAYS('2018-01-01')),  
37 -  
38 -  
39 -PARTITION p201801 VALUES LESS THAN (TO_DAYS('2018-02-01')),  
40 -PARTITION p201802 VALUES LESS THAN (TO_DAYS('2018-03-01')),  
41 -PARTITION p201803 VALUES LESS THAN (TO_DAYS('2018-04-01')),  
42 -PARTITION p201804 VALUES LESS THAN (TO_DAYS('2018-05-01')),  
43 -PARTITION p201805 VALUES LESS THAN (TO_DAYS('2018-06-01')),  
44 -PARTITION p201806 VALUES LESS THAN (TO_DAYS('2018-07-01')),  
45 -PARTITION p201807 VALUES LESS THAN (TO_DAYS('2018-08-01')),  
46 -PARTITION p201808 VALUES LESS THAN (TO_DAYS('2018-09-01')),  
47 -PARTITION p201809 VALUES LESS THAN (TO_DAYS('2018-10-01')),  
48 -PARTITION p201810 VALUES LESS THAN (TO_DAYS('2018-11-01')),  
49 -PARTITION p201811 VALUES LESS THAN (TO_DAYS('2018-12-01')),  
50 -PARTITION p201812 VALUES LESS THAN (TO_DAYS('2019-01-01')),  
51 -  
52 -PARTITION p201901 VALUES LESS THAN (TO_DAYS('2019-02-01')),  
53 -PARTITION p201902 VALUES LESS THAN (TO_DAYS('2019-03-01')),  
54 -PARTITION p201903 VALUES LESS THAN (TO_DAYS('2019-04-01')),  
55 -PARTITION p201904 VALUES LESS THAN (TO_DAYS('2019-05-01')),  
56 -PARTITION p201905 VALUES LESS THAN (TO_DAYS('2019-06-01')),  
57 -PARTITION p201906 VALUES LESS THAN (TO_DAYS('2019-07-01')),  
58 -PARTITION p201907 VALUES LESS THAN (TO_DAYS('2019-08-01')),  
59 -PARTITION p201908 VALUES LESS THAN (TO_DAYS('2019-09-01')),  
60 -PARTITION p201909 VALUES LESS THAN (TO_DAYS('2019-10-01')),  
61 -PARTITION p201910 VALUES LESS THAN (TO_DAYS('2019-11-01')),  
62 -PARTITION p201911 VALUES LESS THAN (TO_DAYS('2019-12-01')),  
63 -PARTITION p201912 VALUES LESS THAN (TO_DAYS('2020-01-01'))  
64 -  
65 -  
66 -);  
67 -  
src/main/java/com/bsth/oplog/http/HttpOpLogInterceptor.java deleted 100644 → 0
1 -package com.bsth.oplog.http;  
2 -  
3 -import javax.servlet.http.HttpServletRequest;  
4 -import javax.servlet.http.HttpServletResponse;  
5 -  
6 -import com.bsth.common.Constants;  
7 -import org.springframework.beans.factory.annotation.Autowired;  
8 -import org.springframework.util.AntPathMatcher;  
9 -import org.springframework.util.PathMatcher;  
10 -import org.springframework.web.method.HandlerMethod;  
11 -import org.springframework.web.servlet.HandlerInterceptor;  
12 -import org.springframework.web.servlet.ModelAndView;  
13 -  
14 -/**  
15 - *  
16 - * @ClassName: HttpOpLogger  
17 - * @Description: TODO(HTTP 接口日志拦截器)  
18 - * @author PanZhao  
19 - * @date 2016年10月20日 上午12:03:11  
20 - *  
21 - */  
22 -//@Component  
23 -public class HttpOpLogInterceptor implements HandlerInterceptor {  
24 -  
25 - private final PathMatcher pathMatcher = new AntPathMatcher();  
26 -  
27 - // GET 白名单  
28 - private String[] httpGetWhiteList = { "/user/login/**", "/user/currentUser","/dictionary/**", "/module/findByCurrentUser", "/gps/**", "/error/**", Constants.XD_CHILD_PAGES};  
29 -  
30 - // POST 白名单  
31 - private String[] httpPostWhiteList = {  
32 - "/control/upstream"  
33 - };  
34 -  
35 - @Autowired  
36 - HttpRecorder httpRecorder;  
37 -  
38 - @Override  
39 - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3)  
40 - throws Exception {  
41 -  
42 - }  
43 -  
44 - @Override  
45 - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object arg2, ModelAndView arg3)  
46 - throws Exception {  
47 -  
48 - String method = request.getMethod(), path = request.getRequestURI();  
49 - // white list  
50 - String[] whiteList = method == "GET" ? httpGetWhiteList : httpPostWhiteList;  
51 -  
52 - if (!isWhiteURL(whiteList, path))  
53 - httpRecorder.record(request, (HandlerMethod)arg2);  
54 - }  
55 -  
56 - @Override  
57 - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {  
58 -  
59 - return true;  
60 - }  
61 -  
62 - private boolean isWhiteURL(String[] whiteList, String currentURL) {  
63 - for (String whiteURL : whiteList) {  
64 - if (pathMatcher.match(whiteURL, currentURL)) {  
65 - return true;  
66 - }  
67 - }  
68 - return false;  
69 - }  
70 -}  
src/main/java/com/bsth/oplog/http/HttpRecorder.java deleted 100644 → 0
1 -package com.bsth.oplog.http;  
2 -  
3 -import java.lang.reflect.Method;  
4 -import java.net.InetAddress;  
5 -import java.net.UnknownHostException;  
6 -  
7 -import javax.servlet.http.HttpServletRequest;  
8 -  
9 -import org.slf4j.Logger;  
10 -import org.slf4j.LoggerFactory;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.stereotype.Component;  
13 -import org.springframework.web.method.HandlerMethod;  
14 -  
15 -import com.alibaba.fastjson.JSON;  
16 -import com.bsth.entity.sys.SysUser;  
17 -import com.bsth.oplog.Level;  
18 -import com.bsth.oplog.Log;  
19 -import com.bsth.oplog.db.DBHelper;  
20 -import com.bsth.security.util.SecurityUtils;  
21 -import com.bsth.util.IpUtils;  
22 -  
23 -/**  
24 - *  
25 - * @ClassName: HttpRecorder  
26 - * @Description: TODO(HTTP 日志记录器)  
27 - * @author PanZhao  
28 - * @date 2016年10月20日 下午12:56:56  
29 - *  
30 - */  
31 -@Component  
32 -public class HttpRecorder {  
33 -  
34 - Logger logger = LoggerFactory.getLogger(HttpRecorder.class);  
35 -  
36 - private final static int httpDataMaxLen = 500;  
37 -  
38 - @Autowired  
39 - DBHelper persistenceBuff;  
40 -  
41 - public void record(HttpServletRequest request, HandlerMethod method){  
42 - Log log = new Log();  
43 -  
44 - log.setType(request.getMethod().toUpperCase());  
45 - log.setLevel(Level.INFO.toString());  
46 - try {  
47 - log.setServerIp(InetAddress.getLocalHost().getHostAddress());  
48 - } catch (UnknownHostException e) {  
49 - e.printStackTrace();  
50 - }  
51 -  
52 - log.setPath(request.getRequestURI());  
53 - //Caller  
54 - Method refMethod = method.getMethod();  
55 - log.setCallerClass(refMethod.getDeclaringClass().getName());  
56 - log.setCallerMethod(refMethod.getName());  
57 -  
58 - //Primary Key  
59 - log.setTimestamp(System.currentTimeMillis());  
60 -  
61 - SysUser user = SecurityUtils.getCurrentUser();  
62 - if(user != null)  
63 - log.setUserName(user.getUserName());  
64 - //request  
65 - log.setClientIp(IpUtils.getIpAddr(request));  
66 - log.setHttpData(httpData(request));  
67 -  
68 - //save  
69 - persistenceBuff.save(log);  
70 - }  
71 -  
72 - private String httpData(HttpServletRequest request){  
73 - String rs = JSON.toJSONString(request.getParameterMap());  
74 -  
75 - if(rs.length() > httpDataMaxLen)  
76 - rs = rs.substring(0, httpDataMaxLen);  
77 -  
78 - return rs.replaceAll("\"", "‘");  
79 - }  
80 -}  
src/main/java/com/bsth/oplog/normal/OpLogger.java deleted 100644 → 0
1 -package com.bsth.oplog.normal;  
2 -  
3 -import java.net.InetAddress;  
4 -import java.net.UnknownHostException;  
5 -  
6 -import javax.servlet.http.HttpServletRequest;  
7 -  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.stereotype.Component;  
10 -  
11 -import com.bsth.entity.sys.SysUser;  
12 -import com.bsth.oplog.Log;  
13 -import com.bsth.oplog.db.DBHelper;  
14 -import com.bsth.security.util.SecurityUtils;  
15 -import com.bsth.util.IpUtils;  
16 -  
17 -/**  
18 - *  
19 - * @ClassName: OpLogger  
20 - * @Description: TODO(常规的操作日志记录器)  
21 - * @author PanZhao  
22 - * @date 2016年10月21日 上午12:52:30  
23 - *  
24 - */  
25 -@Component  
26 -public class OpLogger {  
27 -  
28 - @Autowired  
29 - DBHelper dbHelper;  
30 -  
31 - public void info(String path){  
32 - save(getInitLog(path));  
33 - }  
34 -  
35 - public void info(String path, HttpServletRequest request){  
36 - Log log = getInitLog(path);  
37 -  
38 - if(request != null){  
39 - SysUser user = SecurityUtils.getCurrentUser();  
40 - if(user != null)  
41 - log.setUserName(user.getUserName());  
42 -  
43 - log.setClientIp(IpUtils.getIpAddr(request));  
44 - }  
45 -  
46 - save(log);  
47 - }  
48 -  
49 - public void info(String path, HttpServletRequest request, String description){  
50 -  
51 - }  
52 -  
53 - public static Log getInitLog(String path){  
54 - Log log = new Log();  
55 - log.setTimestamp(System.currentTimeMillis());  
56 - log.setPath(path);  
57 - log.setType("NORMAL");  
58 -  
59 - //get caller  
60 - StackTraceElement[] stack = (new Throwable()).getStackTrace();  
61 - //注意调用链的顺序,此时2为实际调用者  
62 - StackTraceElement caller = stack[2];  
63 -  
64 - log.setCallerClass(caller.getClassName());  
65 - log.setCallerMethod(caller.getMethodName());  
66 - log.setLineNumber(caller.getLineNumber());  
67 -  
68 - try {  
69 - log.setServerIp(InetAddress.getLocalHost().getHostAddress());  
70 - } catch (UnknownHostException e) {  
71 - e.printStackTrace();  
72 - }  
73 -  
74 - return log;  
75 - }  
76 -  
77 - public void save(Log log){  
78 - dbHelper.save(log);  
79 - }  
80 -}  
src/main/java/com/bsth/repository/CarParkRepository.java
@@ -106,7 +106,7 @@ public interface CarParkRepository extends BaseRepository&lt;CarPark, Integer&gt;{ @@ -106,7 +106,7 @@ public interface CarParkRepository extends BaseRepository&lt;CarPark, Integer&gt;{
106 String gParkPoint,String dbType,Integer radius,String shapesType,Integer id ); 106 String gParkPoint,String dbType,Integer radius,String shapesType,Integer id );
107 107
108 @Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name from bsth_c_car_park where park_code=?1", nativeQuery = true) 108 @Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name from bsth_c_car_park where park_code=?1", nativeQuery = true)
109 - public Object[][] bufferAera(String parkCode); 109 + public Object[][] findBufferArea(String parkCode);
110 110
111 @Query(value ="SELECT p.park_name,p.park_code from bsth_c_car_park p where p.park_code = ?1", nativeQuery=true) 111 @Query(value ="SELECT p.park_name,p.park_code from bsth_c_car_park p where p.park_code = ?1", nativeQuery=true)
112 List<Object[]> selectTccInfoByCode(String parkCode); 112 List<Object[]> selectTccInfoByCode(String parkCode);
src/main/java/com/bsth/repository/LsSectionRouteRepository.java
@@ -35,12 +35,6 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute, @@ -35,12 +35,6 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute,
35 @Modifying 35 @Modifying
36 @Query(value = "UPDATE LsSectionRoute lsr set lsr.destroy = 1 where lsr.id in (?1)") 36 @Query(value = "UPDATE LsSectionRoute lsr set lsr.destroy = 1 where lsr.id in (?1)")
37 void batchDestroy(List<Integer> ids); 37 void batchDestroy(List<Integer> ids);
38 -  
39 - /**  
40 - * 查询待更新线路的路段路由  
41 - */  
42 - @Query(value = "SELECT sr FROM LsSectionRoute sr where sr.line.id =?1 and sr.lineCode=?2 and sr.versions=?3 and sr.destroy=0")  
43 - public List<LsSectionRoute> findupdated(Integer lineId,String lineCode,Integer versions);  
44 38
45 @Query(value ="SELECT a.sectionrouteId," + 39 @Query(value ="SELECT a.sectionrouteId," +
46 "a.sectionrouteLine," + 40 "a.sectionrouteLine," +
@@ -78,64 +72,7 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute, @@ -78,64 +72,7 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute,
78 " FROM bsth_c_ls_sectionroute r where r.line = ?1 and r.directions = ?2 and r.versions=?3 and r.destroy=0 ) a " + 72 " FROM bsth_c_ls_sectionroute r where r.line = ?1 and r.directions = ?2 and r.versions=?3 and r.destroy=0 ) a " +
79 " LEFT JOIN bsth_c_section b ON a.sectionrouteSection = b.id order by a.sectionrouteCode asc", nativeQuery=true) 73 " LEFT JOIN bsth_c_section b ON a.sectionrouteSection = b.id order by a.sectionrouteCode asc", nativeQuery=true)
80 List<Object[]> getSectionRoute(int lineId, int directions,int version); 74 List<Object[]> getSectionRoute(int lineId, int directions,int version);
81 -  
82 - /**  
83 - * @Description :TODO(查询路段信息)  
84 - *  
85 - * @param map <id:路段路由ID>  
86 - *  
87 - * @return List<Object[]>  
88 - */  
89 - @Query(value ="SELECT a.sectionRouteId," +  
90 - "a.sectionRouteLineCode," +  
91 - "a.sectionRouteCode," +  
92 - "a.sectionRouteDirections," +  
93 - "a.sectionRouteLine," +  
94 - "a.sectionRouteSection," +  
95 - "a.sectionRouteDescriptions," +  
96 - "a.sectionRouteCreateBy," +  
97 - "a.sectionRouteCreateDate," +  
98 - "a.sectionRouteUpdateBy," +  
99 - "a.sectionRouteUpdateDate," +  
100 - "a.sectionRouteVersions," +  
101 - "a.sectionRouteDestroy," +  
102 - "b.id AS sectionId," +  
103 - "b.section_code AS sectionCode," +  
104 - "b.section_name AS sectionName," +  
105 - "b.road_coding AS sectionRoadCoding," +  
106 - "b.end_node AS sectionEndCode," +  
107 - "b.start_node AS sectionStartNode," +  
108 - "b.middle_node AS sectionMiddleNode," +  
109 - "b.section_type AS sectionType," +  
110 - "ST_AsText(b.csection_vector) AS sectionCsectionVector," +  
111 - "ST_AsText(b.bsection_vector) AS sectionBsectionVector," +  
112 - "ST_AsText(b.gsection_vector) AS sectionGsectionVector," +  
113 - "b.section_distance AS sectionDistance," +  
114 - "b.section_time AS sectionTime," +  
115 - "b.db_type AS sectionDbtype," +  
116 - "b.speed_limit AS sectionSpeedLimit," +  
117 - "b.descriptions AS sectionDescriptions," +  
118 - "b.create_by AS sectionCreateBy," +  
119 - "b.create_date AS sectionCreateDate," +  
120 - "b.update_by AS sectionUpdateBy," +  
121 - "b.update_date AS sectionUpdateDate," +  
122 - "b.versions AS sectionVersion , a.isRoadeSpeed FROM (" +  
123 - " SELECT s.id AS sectionRouteId," +  
124 - "s.line_code AS sectionRouteLineCode," +  
125 - "s.sectionroute_code AS sectionRouteCode," +  
126 - "s.directions AS sectionRouteDirections," +  
127 - "s.line AS sectionRouteLine," +  
128 - "s.section AS sectionRouteSection," +  
129 - "s.descriptions AS sectionRouteDescriptions," +  
130 - "s.create_by AS sectionRouteCreateBy," +  
131 - "s.create_date AS sectionRouteCreateDate," +  
132 - "s.update_by AS sectionRouteUpdateBy," +  
133 - "s.update_date AS sectionRouteUpdateDate," +  
134 - "s.versions AS sectionRouteVersions," +  
135 - "s.destroy AS sectionRouteDestroy, s.is_roade_speed AS isRoadeSpeed " +  
136 - " FROM bsth_c_ls_sectionroute s where s.id =?1) a " +  
137 - " LEFT JOIN bsth_c_section b on a.sectionRouteSection = b.id", nativeQuery=true)  
138 - List<Object[]> findSectionRouteInfoFormId(int id); 75 +
139 /** 76 /**
140 * 更新路线前删除线路版本下历史原有路段路由 77 * 更新路线前删除线路版本下历史原有路段路由
141 */ 78 */
@@ -144,20 +81,23 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute, @@ -144,20 +81,23 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute,
144 @Query(value="DELETE from bsth_c_ls_sectionroute where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true) 81 @Query(value="DELETE from bsth_c_ls_sectionroute where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true)
145 public void batchDelete(Integer line, Integer dir, Integer versions); 82 public void batchDelete(Integer line, Integer dir, Integer versions);
146 83
147 - /**  
148 - * 更新路线前撤销线路版本下历史原有路段路由  
149 - */  
150 - @Modifying  
151 - @Query(value="UPDATE bsth_c_ls_sectionroute set destroy = 1 where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true)  
152 - public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions);  
153 - 84 + /**
  85 + * 在站点路由更新时(站点路由可能改变路由编号,如起点、改变上一站点)
  86 + * 将当前路由编号及以后的编号批量递增10
  87 + * @param lsSectionRoute
  88 + */
154 @Modifying 89 @Modifying
155 - @Query(value="UPDATE bsth_c_ls_sectionroute set sectionroute_code = (sectionroute_code+1) where line_code = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true)  
156 - public void sectionUpdSectionRouteCode(String lineCode, Integer directions, Integer sectionrouteCode);  
157 - 90 + @Query(value="UPDATE bsth_c_ls_sectionroute set sectionroute_code = (sectionroute_code + 10) where line = :#{#lsSectionRoute.line.id} and destroy = 0 and versions = :#{#lsSectionRoute.versions} and directions = :#{#lsSectionRoute.directions} and sectionroute_code >= :#{#lsSectionRoute.sectionrouteCode}", nativeQuery=true)
  91 + void updateSectiouRouteCode(LsSectionRoute lsSectionRoute);
  92 +
  93 + /**
  94 + * 交换历史站点路由指定版本的上下行站点路由
  95 + * @param lineId
  96 + * @param version
  97 + */
158 @Modifying 98 @Modifying
159 - @Query(value="update bsth_c_ls_sectionroute set directions = case directions when 1 then 0 when 0 then 1 end where line_code = ?1 ", nativeQuery=true)  
160 - public void sectionRouteDir(Integer line); 99 + @Query(value="UPDATE bsth_c_ls_sectionroute SET directions = CASE directions WHEN 1 THEN 0 WHEN 0 THEN 1 END WHERE line_code = ?1 AND versions = ?2", nativeQuery=true)
  100 + void exchangeDirection(int lineId, int version);
161 101
162 /** 102 /**
163 * @Description :TODO(查询路段信息) 103 * @Description :TODO(查询路段信息)
@@ -223,4 +163,15 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute, @@ -223,4 +163,15 @@ public interface LsSectionRouteRepository extends BaseRepository&lt;LsSectionRoute,
223 @Modifying 163 @Modifying
224 @Query(value="insert into bsth_c_ls_sectionroute (line_code,section_code,sectionroute_code,directions,line,section,descriptions,versions,destroy,is_roade_speed) select line_code,section_code,sectionroute_code,directions,line,section,descriptions,?3 as versions,destroy,is_roade_speed from bsth_c_ls_sectionroute where line = ?1 and versions = ?2 and destroy = 0", nativeQuery = true) 164 @Query(value="insert into bsth_c_ls_sectionroute (line_code,section_code,sectionroute_code,directions,line,section,descriptions,versions,destroy,is_roade_speed) select line_code,section_code,sectionroute_code,directions,line,section,descriptions,?3 as versions,destroy,is_roade_speed from bsth_c_ls_sectionroute where line = ?1 and versions = ?2 and destroy = 0", nativeQuery = true)
225 void cloneFromHistoryVersion(Integer lineId, Integer oldVersion, Integer newVersion); 165 void cloneFromHistoryVersion(Integer lineId, Integer oldVersion, Integer newVersion);
  166 +
  167 + /**
  168 + * 引用另一上下行路段(上行引用下行,下行引用上行)
  169 + * @param lineId
  170 + * @param version
  171 + * @param direction
  172 + * @param otherDirection
  173 + */
  174 + @Modifying
  175 + @Query(value="INSERT INTO bsth_c_ls_sectionroute (line_code,section_code,sectionroute_code,directions,line,section,descriptions,versions,destroy,is_roade_speed) SELECT line_code,section_code,a.sectionroute_code + b.sectionroute_code,?3 AS directions,a.line,section,descriptions,versions,destroy,is_roade_speed FROM bsth_c_ls_sectionroute a JOIN (SELECT IFNULL(MAX(sectionroute_code), 0) sectionroute_code FROM bsth_c_ls_sectionroute WHERE line = ?1 AND versions = ?2 AND directions = ?3 AND destroy = 0) b WHERE a.line = ?1 AND versions = ?2 AND directions = ?4 AND destroy = 0", nativeQuery = true)
  176 + void quoteOtherSide(Integer lineId, Integer version, Integer direction, Integer otherDirection);
226 } 177 }
src/main/java/com/bsth/repository/LsStationRouteRepository.java
@@ -80,11 +80,6 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute, @@ -80,11 +80,6 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute,
80 "ORDER BY " + 80 "ORDER BY " +
81 "lineCode,directions,stationRouteCode") 81 "lineCode,directions,stationRouteCode")
82 List<Map<String, String>> findLineWithLineCode4Ygc(String lineCode,Integer lineVersion); 82 List<Map<String, String>> findLineWithLineCode4Ygc(String lineCode,Integer lineVersion);
83 -  
84 - // 批量修改站点行业编码  
85 - @Modifying  
86 - @Query(value="update bsth_c_ls_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true)  
87 - void updIndustryCode(Integer id, String industryCode);  
88 83
89 /** 84 /**
90 * 将对应线路、版本、方向、未撤销的站点路由中 85 * 将对应线路、版本、方向、未撤销的站点路由中
@@ -121,17 +116,15 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute, @@ -121,17 +116,15 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute,
121 @Modifying 116 @Modifying
122 @Query(value="UPDATE bsth_c_ls_stationroute set station_route_code = (station_route_code + 10) where line = :#{#lsStationRoute.line.id} and destroy = 0 and versions = :#{#lsStationRoute.versions} and directions = :#{#lsStationRoute.directions} and station_route_code >= :#{#lsStationRoute.stationRouteCode}", nativeQuery=true) 117 @Query(value="UPDATE bsth_c_ls_stationroute set station_route_code = (station_route_code + 10) where line = :#{#lsStationRoute.line.id} and destroy = 0 and versions = :#{#lsStationRoute.versions} and directions = :#{#lsStationRoute.directions} and station_route_code >= :#{#lsStationRoute.stationRouteCode}", nativeQuery=true)
123 void updateStatiouRouteCode(LsStationRoute lsStationRoute); 118 void updateStatiouRouteCode(LsStationRoute lsStationRoute);
124 -  
125 - @Modifying  
126 - @Query(value="update bsth_c_ls_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true)  
127 - void stationRouteDir(Integer line);  
128 119
129 - @Query("select r from LsStationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")  
130 - List<LsStationRoute> findByLine(int lineId, int dir);  
131 -  
132 - @Modifying  
133 - @Query(value="update bsth_c_ls_stationroute set distances =?2 where id = ?1 ", nativeQuery=true)  
134 - void upddis(Integer id,Double dis); 120 + /**
  121 + * 交换历史站点路由指定版本的上下行站点路由
  122 + * @param lineId
  123 + * @param version
  124 + */
  125 + @Modifying
  126 + @Query(value="UPDATE bsth_c_ls_stationroute SET directions = CASE directions WHEN 1 THEN 0 WHEN 0 THEN 1 END WHERE line = ?1 AND versions = ?2", nativeQuery=true)
  127 + void exchangeDirection(int lineId, int version);
135 128
136 @Query(value="select * from bsth_c_ls_stationroute where line_code = ?3 and directions = ?4 and destroy = 0 and versions = ?5 limit ?1,?2", nativeQuery=true) 129 @Query(value="select * from bsth_c_ls_stationroute where line_code = ?3 and directions = ?4 and destroy = 0 and versions = ?5 limit ?1,?2", nativeQuery=true)
137 Iterable<LsStationRoute> page(int start , int end , int line ,int dir, int version); 130 Iterable<LsStationRoute> page(int start , int end , int line ,int dir, int version);
@@ -161,4 +154,14 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute, @@ -161,4 +154,14 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute,
161 @Modifying 154 @Modifying
162 @Query(value="insert into bsth_c_ls_stationroute (line,station,station_name,station_route_code,line_code,station_code,station_mark,out_station_nmber,directions,distances,to_time,first_time,end_time,descriptions,destroy,versions,industry_code,station_name_en,shaped_type,radius,buffer_polygon,buffer_polygon_wgs) select line,station,station_name,station_route_code,line_code,station_code,station_mark,out_station_nmber,directions,distances,to_time,first_time,end_time,descriptions,destroy,?3 as versions,industry_code,station_name_en,shaped_type,radius,buffer_polygon,buffer_polygon_wgs from bsth_c_ls_stationroute where line = ?1 and versions = ?2 and destroy = 0", nativeQuery = true) 155 @Query(value="insert into bsth_c_ls_stationroute (line,station,station_name,station_route_code,line_code,station_code,station_mark,out_station_nmber,directions,distances,to_time,first_time,end_time,descriptions,destroy,versions,industry_code,station_name_en,shaped_type,radius,buffer_polygon,buffer_polygon_wgs) select line,station,station_name,station_route_code,line_code,station_code,station_mark,out_station_nmber,directions,distances,to_time,first_time,end_time,descriptions,destroy,?3 as versions,industry_code,station_name_en,shaped_type,radius,buffer_polygon,buffer_polygon_wgs from bsth_c_ls_stationroute where line = ?1 and versions = ?2 and destroy = 0", nativeQuery = true)
163 void cloneFromHistoryVersion(Integer lineId, Integer oldVersion, Integer newVersion); 156 void cloneFromHistoryVersion(Integer lineId, Integer oldVersion, Integer newVersion);
  157 +
  158 + /**
  159 + *
  160 + * @param lineId
  161 + * @param version
  162 + * @param dir
  163 + * @return
  164 + */
  165 + @Query("select r from LsStationRoute r where r.line.id=?1 and r.versions=?2 and r.directions=?3 and r.destroy=0 order by r.stationRouteCode")
  166 + List<LsStationRoute> findByLineVersion(Integer lineId, Integer version, Integer direction, Integer stationRouteCode);
164 } 167 }
src/main/java/com/bsth/repository/RoadSpeedRepository.java deleted 100644 → 0
1 -package com.bsth.repository;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import org.springframework.data.jpa.repository.Modifying;  
7 -import org.springframework.data.jpa.repository.Query;  
8 -import org.springframework.stereotype.Repository;  
9 -import org.springframework.transaction.annotation.Transactional;  
10 -  
11 -import com.bsth.entity.RoadSpeed;  
12 -  
13 -/**  
14 - *  
15 - * @Interface: RoadSpeedRepository(路段限速Repository数据持久层接口)  
16 - *  
17 - * @Extends : BaseRepository  
18 - *  
19 - * @Description: TODO(线路版本Repository数据持久层接口)  
20 - *  
21 - * @Author bsth@lq  
22 - *  
23 - * @Version 公交调度系统BS版 0.1  
24 - *  
25 - */  
26 -@Repository  
27 -public interface RoadSpeedRepository extends BaseRepository<RoadSpeed, Integer> {  
28 -  
29 - @Transactional  
30 - @Modifying  
31 - @Query(value="INSERT INTO bsth_c_road_speed "+  
32 -  
33 - "(name , g_road_vector , b_road_vector , speed, speed_start_date ,"+  
34 -  
35 - "speed_end_date , is_start) VALUES (?1 , LINESTRINGFROMTEXT(?2) , LINESTRINGFROMTEXT(?3) , ?4 , ?5 , "+  
36 -  
37 - "?6 , ?7 )", nativeQuery=true)  
38 - public void roadSpeedSave(String name, String gRoadVector, String bRoadVector, double speed, String speedStartDate,  
39 - String speedEndDate, int isStart);  
40 -  
41 - @Query(value="SELECT "  
42 - + "rs.id as id, "  
43 - + "rs.name as name, "  
44 - + "AsText(rs.b_road_vector) as bRoadVector, "  
45 - + "AsText(rs.g_road_vector) as gRoadVector, "  
46 - + "rs.speed as speed, "  
47 - + "rs.speed_start_date as speedStartDate, "  
48 - + "rs.speed_end_date as speedEndDate, "  
49 - + "rs.is_start as isStart, "  
50 - + "rs.line as line "  
51 - + "FROM bsth_c_road_speed rs WHERE rs.id=?1 ", nativeQuery=true)  
52 - public List<Object[]> selectById(Integer id);  
53 -  
54 - @Transactional  
55 - @Modifying  
56 - @Query(value="update bsth_c_road_speed set name=?2, g_road_vector=LINESTRINGFROMTEXT(?3),"  
57 - + " b_road_vector=LINESTRINGFROMTEXT(?4), speed=?5, speed_start_date=?6, "  
58 - + "speed_end_date=?7, is_start=?8 where id=?1", nativeQuery=true)  
59 - public void update(int id, String name, String gRoadVector, String bRoadVector, double speed, String speedStartDate,  
60 - String speedEndDate, int isStart);  
61 -  
62 -}  
src/main/java/com/bsth/repository/SectionRepository.java
@@ -33,7 +33,7 @@ public interface SectionRepository extends BaseRepository&lt;Section, Integer&gt; { @@ -33,7 +33,7 @@ public interface SectionRepository extends BaseRepository&lt;Section, Integer&gt; {
33 * @return 最大ID值 33 * @return 最大ID值
34 */ 34 */
35 @Query(value = "SELECT IFNULL(MAX(id), 0) FROM bsth_c_section", nativeQuery = true) 35 @Query(value = "SELECT IFNULL(MAX(id), 0) FROM bsth_c_section", nativeQuery = true)
36 - int sectionMaxId(); 36 + int findLatestSectionId();
37 37
38 38
39 /** 39 /**
src/main/java/com/bsth/repository/SectionRouteRepository.java
@@ -28,14 +28,6 @@ import com.bsth.entity.SectionRoute; @@ -28,14 +28,6 @@ import com.bsth.entity.SectionRoute;
28 @Repository 28 @Repository
29 public interface SectionRouteRepository extends BaseRepository<SectionRoute, Integer> { 29 public interface SectionRouteRepository extends BaseRepository<SectionRoute, Integer> {
30 30
31 - // 查询最大ID  
32 - @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_sectionroute) k" , nativeQuery=true)  
33 - public long sectionRouteMaxId();  
34 -  
35 - // 查询最大ID  
36 - @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(sectionroute_code) as num FROM bsth_c_sectionroute where line_code = 601010 and directions = 1 and destroy = 0) k" , nativeQuery=true)  
37 - public int sectionRouteCodeMaxId();  
38 -  
39 /** 31 /**
40 * @Description :TODO(查询路段信息) 32 * @Description :TODO(查询路段信息)
41 * 33 *
@@ -80,66 +72,6 @@ public interface SectionRouteRepository extends BaseRepository&lt;SectionRoute, Int @@ -80,66 +72,6 @@ public interface SectionRouteRepository extends BaseRepository&lt;SectionRoute, Int
80 " LEFT JOIN bsth_c_section b ON a.sectionrouteSection = b.id order by a.sectionrouteCode asc", nativeQuery=true) 72 " LEFT JOIN bsth_c_section b ON a.sectionrouteSection = b.id order by a.sectionrouteCode asc", nativeQuery=true)
81 List<Object[]> getSectionRoute(int lineId, int directions); 73 List<Object[]> getSectionRoute(int lineId, int directions);
82 74
83 -  
84 - /**  
85 - * @Description :TODO(查询路段信息)  
86 - *  
87 - * @param map <id:路段路由ID>  
88 - *  
89 - * @return List<Object[]>  
90 - */  
91 - @Query(value ="SELECT a.sectionRouteId," +  
92 - "a.sectionRouteLineCode," +  
93 - "a.sectionRouteCode," +  
94 - "a.sectionRouteDirections," +  
95 - "a.sectionRouteLine," +  
96 - "a.sectionRouteSection," +  
97 - "a.sectionRouteDescriptions," +  
98 - "a.sectionRouteCreateBy," +  
99 - "a.sectionRouteCreateDate," +  
100 - "a.sectionRouteUpdateBy," +  
101 - "a.sectionRouteUpdateDate," +  
102 - "a.sectionRouteVersions," +  
103 - "a.sectionRouteDestroy," +  
104 - "b.id AS sectionId," +  
105 - "b.section_code AS sectionCode," +  
106 - "b.section_name AS sectionName," +  
107 - "b.road_coding AS sectionRoadCoding," +  
108 - "b.end_node AS sectionEndCode," +  
109 - "b.start_node AS sectionStartNode," +  
110 - "b.middle_node AS sectionMiddleNode," +  
111 - "b.section_type AS sectionType," +  
112 - "ST_AsText(b.csection_vector) AS sectionCsectionVector," +  
113 - "ST_AsText(b.bsection_vector) AS sectionBsectionVector," +  
114 - "ST_AsText(b.gsection_vector) AS sectionGsectionVector," +  
115 - "b.section_distance AS sectionDistance," +  
116 - "b.section_time AS sectionTime," +  
117 - "b.db_type AS sectionDbtype," +  
118 - "b.speed_limit AS sectionSpeedLimit," +  
119 - "b.descriptions AS sectionDescriptions," +  
120 - "b.create_by AS sectionCreateBy," +  
121 - "b.create_date AS sectionCreateDate," +  
122 - "b.update_by AS sectionUpdateBy," +  
123 - "b.update_date AS sectionUpdateDate," +  
124 - "b.versions AS sectionVersion , a.isRoadeSpeed FROM (" +  
125 - " SELECT s.id AS sectionRouteId," +  
126 - "s.line_code AS sectionRouteLineCode," +  
127 - "s.sectionroute_code AS sectionRouteCode," +  
128 - "s.directions AS sectionRouteDirections," +  
129 - "s.line AS sectionRouteLine," +  
130 - "s.section AS sectionRouteSection," +  
131 - "s.descriptions AS sectionRouteDescriptions," +  
132 - "s.create_by AS sectionRouteCreateBy," +  
133 - "s.create_date AS sectionRouteCreateDate," +  
134 - "s.update_by AS sectionRouteUpdateBy," +  
135 - "s.update_date AS sectionRouteUpdateDate," +  
136 - "s.versions AS sectionRouteVersions," +  
137 - "s.destroy AS sectionRouteDestroy, s.is_roade_speed AS isRoadeSpeed " +  
138 - " FROM bsth_c_sectionroute s where s.id =?1) a " +  
139 - " LEFT JOIN bsth_c_section b on a.sectionRouteSection = b.id", nativeQuery=true)  
140 - List<Object[]> findSectionRouteInfoFormId(int id);  
141 -  
142 -  
143 /** 75 /**
144 * @Description :TODO(查询线路某方向下的上一个路段序号) 76 * @Description :TODO(查询线路某方向下的上一个路段序号)
145 * 77 *
@@ -166,49 +98,12 @@ public interface SectionRouteRepository extends BaseRepository&lt;SectionRoute, Int @@ -166,49 +98,12 @@ public interface SectionRouteRepository extends BaseRepository&lt;SectionRoute, Int
166 " LEFT JOIN bsth_c_section s on c.section = s.id where c.line = ?1 and c.directions = ?2 and c.destroy = 0", nativeQuery=true) 98 " LEFT JOIN bsth_c_section s on c.section = s.id where c.line = ?1 and c.directions = ?2 and c.destroy = 0", nativeQuery=true)
167 List<Object[]> sectionRouteVector(Integer lineId,Integer directions); 99 List<Object[]> sectionRouteVector(Integer lineId,Integer directions);
168 100
169 - @Transactional  
170 - @Modifying  
171 - @Query(value="UPDATE bsth_c_sectionroute set is_roade_speed = ?1 where line= ?2 and directions=?3 ",nativeQuery = true)  
172 - void isRoadSpeedUpd(Integer isR,Integer line,Integer directions);  
173 -  
174 @Modifying 101 @Modifying
175 @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true) 102 @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true)
176 - public void sectionUpdSectionRouteCode(Integer line,Integer dir,Integer routeCod);  
177 -  
178 - @Modifying  
179 - @Query(value="UPDATE bsth_c_sectionroute set sectionroute_code = (sectionroute_code+1) where line_code = ?1 and directions = ?2 and sectionroute_code >=?3 and destroy = 0", nativeQuery=true)  
180 - public void sectionUpdSectionRouteCode(String lineCode,Integer dir,int routeCod);  
181 -  
182 - @Modifying  
183 - @Query(value="UPDATE bsth_c_sectionroute set destroy = 1 where id = ?1", nativeQuery=true)  
184 - public void sectionRouteIsDestroyUpdBatch(Integer id);  
185 -  
186 - /**  
187 - * 更新路线前撤销线路原有路段  
188 - *  
189 - * @param line  
190 - * @param dir  
191 - */  
192 - @Modifying  
193 - @Query(value="UPDATE bsth_c_sectionroute set destroy = 1 where line = ?1 and directions = ?2", nativeQuery=true)  
194 - public void sectionRouteUpdDestroy(Integer line,Integer dir);  
195 -  
196 - @Modifying  
197 - @Query(value="update bsth_c_sectionroute set directions = case directions when 1 then 0 when 0 then 1 end where line_code = ?1 ", nativeQuery=true)  
198 - public void sectionRouteDir(Integer line);  
199 -  
200 - // 更具线路批量撤销  
201 - @Modifying  
202 - @Query(value="UPDATE SectionRoute sr set sr.destroy = 1 where sr.line.id = ?1 and sr.lineCode = ?2")  
203 - public void batchUpdate(Integer lineId, String lineCode);  
204 -  
205 - // 批量删除  
206 - @Modifying  
207 - @Query(value="delete from SectionRoute sr where sr.line.id = ?1 and sr.lineCode = ?2")  
208 - public void batchDelete(Integer lineId, String lineCode); 103 + void sectionUpdSectionRouteCode(Integer line,Integer dir,Integer routeCod);
209 104
210 @Query("select r from SectionRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.sectionrouteCode") 105 @Query("select r from SectionRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.sectionrouteCode")
211 - public List<SectionRoute> findByLine(Integer lineId, Integer dir); 106 + List<SectionRoute> findByLine(Integer lineId, Integer dir);
212 107
213 /** 108 /**
214 * 删除相应线路和版本的站点路由信息 109 * 删除相应线路和版本的站点路由信息
src/main/java/com/bsth/repository/SectionSpeedRepository.java deleted 100644 → 0
1 -package com.bsth.repository;  
2 -  
3 -import java.util.List;  
4 -  
5 -import org.springframework.data.jpa.repository.Modifying;  
6 -import org.springframework.data.jpa.repository.Query;  
7 -import org.springframework.stereotype.Repository;  
8 -import org.springframework.transaction.annotation.Transactional;  
9 -  
10 -import com.bsth.entity.SectionSpeed;  
11 -  
12 -/**  
13 - * @description TODO(路段限速持久层)  
14 - *  
15 - * @author Administrator  
16 - *  
17 - * @date 2016年9月21日 13:31:25  
18 - */  
19 -@Repository  
20 -public interface SectionSpeedRepository extends BaseRepository<SectionSpeed, Integer>{  
21 -  
22 -  
23 - @Transactional  
24 - @Modifying  
25 - @Query(value="INSERT INTO bsth_c_sectionspeed (" +  
26 - "line , line_code , directions , `code` , s_name,road,road_code ) " +  
27 - " VALUES (" +  
28 - "?1 , ?2 , ?3 , ?4 , ?5,?6,?7)", nativeQuery=true)  
29 - /** @description TODO(路段限速保存) @param (<line:线路ID;versions:版本号;destroy:是否撤销;directions:方向;sValue:限速;code:路段序号> )*/  
30 - /** @param (<lineCode:线路编码;sName:路段名称;sType:路段类型;bLineStr:路段矢量百度坐标;gLineStr:路段矢量WGS坐标;descriptions:说明>)*/  
31 - void add(Integer line,String lineCode,Integer directions,Integer code,String sName,Integer road,String road_code);  
32 -  
33 - @Transactional  
34 - @Modifying  
35 - @Query(value="INSERT INTO bsth_c_road("+  
36 - "broad_vector,groad_vector,road_code,road_name,speed,id)"+  
37 - " VALUES(" +  
38 - "ST_GeomFromText(?1),ST_GeomFromText(?2),?3,?4,?5,?6)", nativeQuery=true)  
39 - void insertRoad(String broad_vector,String groad_vector,String road_code,String road_name,Double speed,Integer id);  
40 -  
41 - @Query(value="SELECT b.`name` as linename, a.speedid, a.bLineStr ,a.line_code,a.s_name,a.speed ,a.line,a.codenumb,a.road,a.directions FROM ("+  
42 - " SELECT p.id AS speedid,p.line,p.line_code,p.road,p.directions,p.`code` AS codenumb,p.s_name,ST_AsText(r.broad_vector) AS bLineStr,r.speed FROM ("+  
43 - " SELECT s.id,s.line,s.line_code,s.road,s.directions,s.`code`,s.s_name FROM bsth_c_sectionspeed s where s.line =?1 and s.line_code=?2 and s.directions=?3) p LEFT JOIN bsth_c_road r ON p.road = r.id) a "+  
44 - " LEFT JOIN bsth_c_line b ON a.line = b.id ORDER BY codenumb asc",nativeQuery = true)  
45 - List<Object[]> getSectionSpeedInfo(int lineId, String lineCode, int directions);  
46 -  
47 - /** 获取路网数据 */  
48 - @Query(value="SELECT ST_AsText(g.bdjw) as SHAPE , id as id ,ldbh,mc FROM jjwgps_t_gjldb g where g.bdjw is not null ",nativeQuery = true)  
49 - List<Object[]> getroadNet();  
50 -  
51 - /** */  
52 - @Query(value="SELECT ST_Contains(ST_Buffer(ST_GeomFromText(?1),0.0005),ST_GeomFromText(?2)) AS result",nativeQuery = true)  
53 - int ST_Contains(String g1,String g2);  
54 -  
55 -  
56 - @Query(value="SELECT id FROM bsth_c_road r where r.road_code = ?1",nativeQuery = true)  
57 - Integer validateRoade(String raodCode);  
58 -  
59 - @Transactional  
60 - @Modifying  
61 - @Query(value="UPDATE bsth_c_sectionspeed set `code` =?1 where id=?2",nativeQuery = true)  
62 - void roadUpdCode(Integer code,Integer sSpeedId);  
63 -  
64 - @Transactional  
65 - @Modifying  
66 - @Query(value="UPDATE bsth_c_road set road_name = ?1 ,speed =?2 where id= ?3",nativeQuery = true)  
67 - void sSpeedUpd(String roadName,Double speed ,Integer id);  
68 -  
69 -}  
src/main/java/com/bsth/repository/StationRepository.java
@@ -29,12 +29,12 @@ import com.bsth.entity.Station; @@ -29,12 +29,12 @@ import com.bsth.entity.Station;
29 public interface StationRepository extends BaseRepository<Station, Integer> { 29 public interface StationRepository extends BaseRepository<Station, Integer> {
30 30
31 /** 31 /**
  32 + * 查询最大站点ID
32 * @Description :TODO(查询最大站点ID) 33 * @Description :TODO(查询最大站点ID)
33 - *  
34 * @return int <站点id> 34 * @return int <站点id>
35 */ 35 */
36 @Query(value = "SELECT IFNULL(MAX(id), 0) FROM bsth_c_station", nativeQuery = true) 36 @Query(value = "SELECT IFNULL(MAX(id), 0) FROM bsth_c_station", nativeQuery = true)
37 - int stationMaxId(); 37 + int findLatestStationId();
38 38
39 @Query(value = " SELECT CONCAT(ST_X(t.center_point), ' ', ST_Y(t.center_point)) b_jwpoints,t.id FROM (" + 39 @Query(value = " SELECT CONCAT(ST_X(t.center_point), ' ', ST_Y(t.center_point)) b_jwpoints,t.id FROM (" +
40 " SELECT b.id,b.center_point,b.station_name,a.directions FROM (" + 40 " SELECT b.id,b.center_point,b.station_name,a.directions FROM (" +
@@ -44,5 +44,5 @@ public interface StationRepository extends BaseRepository&lt;Station, Integer&gt; { @@ -44,5 +44,5 @@ public interface StationRepository extends BaseRepository&lt;Station, Integer&gt; {
44 List<Object[]> findStationName(Integer dir , String stationName); 44 List<Object[]> findStationName(Integer dir , String stationName);
45 45
46 @Query(value = "SELECT ST_AsText(b.buffer_polygon_wgs) g_polygon_grid, b.shaped_type,CONCAT(ST_X(a.center_point), ' ', ST_Y(a.center_point)) g_center_point , b.radius, a.station_code, b.station_name FROM bsth_c_station a JOIN bsth_c_stationroute b ON a.id = b.station WHERE b.line_code = ?1 AND a.station_code = ?2", nativeQuery = true) 46 @Query(value = "SELECT ST_AsText(b.buffer_polygon_wgs) g_polygon_grid, b.shaped_type,CONCAT(ST_X(a.center_point), ' ', ST_Y(a.center_point)) g_center_point , b.radius, a.station_code, b.station_name FROM bsth_c_station a JOIN bsth_c_stationroute b ON a.id = b.station WHERE b.line_code = ?1 AND a.station_code = ?2", nativeQuery = true)
47 - Object[][] bufferAera(String lineCode, String stationCode); 47 + Object[][] findBufferArea(String lineCode, String stationCode);
48 } 48 }
src/main/java/com/bsth/service/BaseService.java
1 -package com.bsth.service;  
2 -  
3 -import org.springframework.data.domain.Page;  
4 -import org.springframework.data.domain.Pageable;  
5 -  
6 -import java.io.Serializable;  
7 -import java.util.Collection;  
8 -import java.util.Map;  
9 -  
10 -/**  
11 - *  
12 - * @ClassName: BaseService  
13 - * @Description: TODO(基础的Service接口)  
14 - * @author PanZhao  
15 - * @date 2016年3月17日 下午12:48:43  
16 - *  
17 - * @param <T>  
18 - * @param <ID>  
19 - */  
20 -public interface BaseService<T, ID extends Serializable> {  
21 - /**  
22 - * 根据主键获取单个对象  
23 - * @param id  
24 - * @return  
25 - */  
26 - T findById(ID id);  
27 -  
28 - /**  
29 - * 保存  
30 - * @param t  
31 - * @return  
32 - */  
33 - Map<String, Object> save(T t);  
34 -  
35 - /**  
36 - *  
37 - * @Title: list  
38 - * @Description: TODO(多条件分页查询)  
39 - * @param @param map 查询条件  
40 - * @param @param pageable 分页对象  
41 - * @throws  
42 - */  
43 - Page<T> list(Map<String, Object> map, Pageable pageable);  
44 -  
45 - /**  
46 - *  
47 - * @Title: list  
48 - * @Description: TODO(多条件查询)  
49 - * @throws  
50 - */  
51 - Iterable<T> list(Map<String, Object> map);  
52 -  
53 - /**  
54 - * 获取所有  
55 - * @return  
56 - */  
57 - Iterable<T> findAll();  
58 -  
59 - /**  
60 - *  
61 - * @Title: deleteById  
62 - * @Description: TODO(根据主键删除对象)  
63 - * @param @param id  
64 - * @throws  
65 - */  
66 - Map<String, Object> delete(ID id);  
67 -  
68 - /**  
69 - * 后端验证查询数据是否重复。  
70 - * @param params 查询条件  
71 - * @return {status:状态编码,msg:错误描述},状态编码 @see com.bsth.common.ResponseCode  
72 - */  
73 - Map<String, Object> validateEquale(Map<String, Object> params);  
74 -  
75 - /**  
76 - * 批量保存。  
77 - * @param entities 实体列表  
78 - * @return 保存后的entities  
79 - */  
80 - <S extends T> Collection<S> bulkSave(Collection<S> entities);  
81 -} 1 +package com.bsth.service;
  2 +
  3 +import org.springframework.data.domain.Page;
  4 +import org.springframework.data.domain.Pageable;
  5 +import org.springframework.data.domain.Sort;
  6 +
  7 +import java.io.Serializable;
  8 +import java.util.Collection;
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +/**
  13 + *
  14 + * @ClassName: BaseService
  15 + * @Description: TODO(基础的Service接口)
  16 + * @author PanZhao
  17 + * @date 2016年3月17日 下午12:48:43
  18 + *
  19 + * @param <T>
  20 + * @param <ID>
  21 + */
  22 +public interface BaseService<T, ID extends Serializable> {
  23 + /**
  24 + * 根据主键获取单个对象
  25 + * @param id
  26 + * @return
  27 + */
  28 + T findById(ID id);
  29 +
  30 + /**
  31 + * 保存
  32 + * @param t
  33 + * @return
  34 + */
  35 + Map<String, Object> save(T t);
  36 +
  37 + /**
  38 + *
  39 + * @Title: list
  40 + * @Description: TODO(多条件分页查询)
  41 + * @param @param map 查询条件
  42 + * @param @param pageable 分页对象
  43 + * @throws
  44 + */
  45 + Page<T> list(Map<String, Object> map, Pageable pageable);
  46 +
  47 + /**
  48 + *
  49 + * @Title: list
  50 + * @Description: TODO(多条件查询)
  51 + * @throws
  52 + */
  53 + Iterable<T> list(Map<String, Object> map);
  54 +
  55 + /**
  56 + * 根据筛选和排序条件获取所有数据
  57 + * @param map
  58 + * @param sort
  59 + * @return
  60 + */
  61 + List<T> findAll(Map<String, Object> map, Sort sort);
  62 +
  63 + /**
  64 + * 获取所有
  65 + * @return
  66 + */
  67 + Iterable<T> findAll();
  68 +
  69 + /**
  70 + *
  71 + * @Title: deleteById
  72 + * @Description: TODO(根据主键删除对象)
  73 + * @param @param id
  74 + * @throws
  75 + */
  76 + Map<String, Object> delete(ID id);
  77 +
  78 + /**
  79 + * 后端验证查询数据是否重复。
  80 + * @param params 查询条件
  81 + * @return {status:状态编码,msg:错误描述},状态编码 @see com.bsth.common.ResponseCode
  82 + */
  83 + Map<String, Object> validateEquale(Map<String, Object> params);
  84 +
  85 + /**
  86 + * 批量保存。
  87 + * @param entities 实体列表
  88 + * @return 保存后的entities
  89 + */
  90 + <S extends T> Collection<S> bulkSave(Collection<S> entities);
  91 +}
src/main/java/com/bsth/service/LineService.java
1 -package com.bsth.service;  
2 -  
3 -import com.bsth.entity.Line;  
4 -  
5 -import java.util.Map;  
6 -  
7 -/**  
8 - *  
9 - * @Interface: LineService(线路service业务层实现接口)  
10 - *  
11 - * @extends : BaseService  
12 - *  
13 - * @Description: TODO(线路service业务层实现接口)  
14 - *  
15 - * @Author bsth@lq  
16 - *  
17 - * @Date 2016年4月28日 上午9:21:17  
18 - *  
19 - * @Version 公交调度系统BS版 0.1  
20 - *  
21 - */  
22 -public interface LineService extends BaseService<Line, Integer> {  
23 -  
24 - /**  
25 - * 获取线路编码  
26 - *  
27 - * @return long <lineCode:线路编码>  
28 - */  
29 - long selectMaxIdToLineCode();  
30 -  
31 - Line findByLineCode(String lineCode);  
32 -  
33 - Line findById(Integer id);  
34 -  
35 - String lineCodeVerification(String lineCode);  
36 -  
37 - Map<String, Object> update(Line l);  
38 -  
39 - Map<String,Object> remove(Integer id);  
40 -  
41 - Map<String, Boolean> lineNature();  
42 -  
43 - Map<String,Object> getLineMatchStationIsUpdate(Integer id);  
44 -} 1 +package com.bsth.service;
  2 +
  3 +import com.bsth.entity.Line;
  4 +
  5 +import java.util.Map;
  6 +
  7 +/**
  8 + *
  9 + * @Interface: LineService(线路service业务层实现接口)
  10 + *
  11 + * @extends : BaseService
  12 + *
  13 + * @Description: TODO(线路service业务层实现接口)
  14 + *
  15 + * @Author bsth@lq
  16 + *
  17 + * @Date 2016年4月28日 上午9:21:17
  18 + *
  19 + * @Version 公交调度系统BS版 0.1
  20 + *
  21 + */
  22 +public interface LineService extends BaseService<Line, Integer> {
  23 +
  24 + /**
  25 + * 获取线路编码
  26 + *
  27 + * @return long <lineCode:线路编码>
  28 + */
  29 + long selectMaxIdToLineCode();
  30 +
  31 + Line findByLineCode(String lineCode);
  32 +
  33 + Line findById(Integer id);
  34 +
  35 + String lineCodeVerification(String lineCode);
  36 +
  37 + Map<String, Object> update(Line l);
  38 +
  39 + Map<String,Object> remove(Integer id);
  40 +
  41 + Map<String, Boolean> lineNature();
  42 +}
src/main/java/com/bsth/service/LsSectionRouteService.java
@@ -3,6 +3,7 @@ package com.bsth.service; @@ -3,6 +3,7 @@ package com.bsth.service;
3 import com.bsth.entity.LsSectionRoute; 3 import com.bsth.entity.LsSectionRoute;
4 4
5 import java.util.List; 5 import java.util.List;
  6 +import java.util.Map;
6 7
7 /** 8 /**
8 * @author Hill 9 * @author Hill
@@ -14,4 +15,26 @@ public interface LsSectionRouteService extends BaseService&lt;LsSectionRoute, Integ @@ -14,4 +15,26 @@ public interface LsSectionRouteService extends BaseService&lt;LsSectionRoute, Integ
14 * @param ids 15 * @param ids
15 */ 16 */
16 void batchDestroy(List<Integer> ids); 17 void batchDestroy(List<Integer> ids);
  18 +
  19 + /**
  20 + * 引用另一上下行路段
  21 + * @param lineId
  22 + * @param version
  23 + * @param direction
  24 + * @param otherDirection
  25 + * @return
  26 + */
  27 + Map<String, Object> quoteOtherSide(int lineId, int version, int direction, int otherDirection);
  28 +
  29 + /**
  30 + * 添加路段路由
  31 + * @param sectionRoute
  32 + */
  33 + void add(LsSectionRoute sectionRoute);
  34 +
  35 + /**
  36 + * 修改路段路由
  37 + * @param sectionRoute
  38 + */
  39 + void modify(LsSectionRoute sectionRoute);
17 } 40 }
src/main/java/com/bsth/service/LsStationRouteService.java
1 package com.bsth.service; 1 package com.bsth.service;
2 2
  3 +import com.bsth.entity.LsSectionRoute;
3 import com.bsth.entity.LsStationRoute; 4 import com.bsth.entity.LsStationRoute;
4 5
5 import java.util.List; 6 import java.util.List;
@@ -18,12 +19,31 @@ public interface LsStationRouteService extends BaseService&lt;LsStationRoute, Integ @@ -18,12 +19,31 @@ public interface LsStationRouteService extends BaseService&lt;LsStationRoute, Integ
18 Iterable<LsStationRoute> findAllByParams(Map<String, Object> map); 19 Iterable<LsStationRoute> findAllByParams(Map<String, Object> map);
19 20
20 /** 21 /**
  22 + * 获取当前站点以及下一站点路由
  23 + * @param id
  24 + * @return
  25 + */
  26 + List<LsStationRoute> findCurrentAndNext(Integer id);
  27 +
  28 + /**
21 * 批量撤销站点路由 29 * 批量撤销站点路由
22 * @param ids 30 * @param ids
23 */ 31 */
24 void batchDestroy(List<Integer> ids); 32 void batchDestroy(List<Integer> ids);
25 33
26 /** 34 /**
  35 + * 保存线路某个版本下单行的站点和路段路由
  36 + * 常规使用在根据百度地图生成数据或者模板导入的批量保存
  37 + * @param lineId
  38 + * @param versions
  39 + * @param directions
  40 + * @param stationRoutes
  41 + * @param sectionRoutes
  42 + * @return
  43 + */
  44 + Map<String, Object> addRoutes(Integer lineId, Integer versions, Integer directions, List<LsStationRoute> stationRoutes, List<LsSectionRoute> sectionRoutes);
  45 +
  46 + /**
27 * 添加站点路由 47 * 添加站点路由
28 * @param stationRoute 48 * @param stationRoute
29 */ 49 */
@@ -34,4 +54,29 @@ public interface LsStationRouteService extends BaseService&lt;LsStationRoute, Integ @@ -34,4 +54,29 @@ public interface LsStationRouteService extends BaseService&lt;LsStationRoute, Integ
34 * @param stationRoute 54 * @param stationRoute
35 */ 55 */
36 Map<String, Object> modify(LsStationRoute stationRoute); 56 Map<String, Object> modify(LsStationRoute stationRoute);
  57 +
  58 + /**
  59 + * 交换指定版本的站点、路段路由上下行
  60 + * 上行的路由换到下行 下行的路由换到上行
  61 + * @param lineId
  62 + * @param version
  63 + * @return
  64 + */
  65 + Map<String, Object> exchangeDirection(int lineId, int version);
  66 +
  67 + /**
  68 + * 调整站间距
  69 + * @param ids
  70 + * @param distances
  71 + * @return
  72 + */
  73 + Map<String, Object> modifyDistance(List<Integer> ids, List<Double> distances);
  74 +
  75 + /**
  76 + * 单环线将首末站路由指向同一个站点
  77 + * 双环线将四个首末站路由指向同一个站点
  78 + * @param lineId
  79 + * @return
  80 + */
  81 + Map<String, Object> circularRouteHandle(Integer lineId, Integer version);
37 } 82 }
src/main/java/com/bsth/service/RoadSpeedService.java deleted 100644 → 0
1 -package com.bsth.service;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import com.bsth.entity.RoadSpeed;  
7 -  
8 -/**  
9 - *  
10 - * @Interface: RoadSpeedService(路段限速service业务层实现接口)  
11 - *  
12 - * @extends : BaseService  
13 - *  
14 - * @Description: TODO(路段限速service业务层实现接口)  
15 - *  
16 - * @Author bsth@lq  
17 - *  
18 - * @Version 公交调度系统BS版 0.1  
19 - *  
20 - */  
21 -public interface RoadSpeedService extends BaseService<RoadSpeed, Integer> {  
22 -  
23 - Map<String, Object> update(Map<String, Object> map);  
24 -  
25 - Map<String, Object> roadSpeedSave(Map<String, Object> map);  
26 -  
27 - RoadSpeed findId(Integer id);  
28 -  
29 - List<RoadSpeed> allRoadSpeed();  
30 -}  
src/main/java/com/bsth/service/SectionRouteService.java
@@ -33,24 +33,6 @@ public interface SectionRouteService extends BaseService&lt;SectionRoute, Integer&gt; @@ -33,24 +33,6 @@ public interface SectionRouteService extends BaseService&lt;SectionRoute, Integer&gt;
33 List<Map<String, Object>> getSectionRoute(Map<String, Object> map); 33 List<Map<String, Object>> getSectionRoute(Map<String, Object> map);
34 34
35 /** 35 /**
36 - * @Description : TODO(根据路段路由Id批量撤销路段)  
37 - *  
38 - * @param map <id:路段路由ID>  
39 - *  
40 - * @return List<Map<String, Object>>  
41 - */  
42 - Map<String, Object> updateSectionRouteInfoFormId(Map<String, Object> map);  
43 -  
44 - /**  
45 - * @Description : TODO(根据路段路由Id查询详情)  
46 - *  
47 - * @param map <id:路段路由ID>  
48 - *  
49 - * @return List<Map<String, Object>>  
50 - */  
51 - List<Map<String, Object>> findSectionRouteInfoFormId(Map<String, Object> map);  
52 -  
53 - /**  
54 * @Description :TODO(查询线路某方向下的上一个路段序号) 36 * @Description :TODO(查询线路某方向下的上一个路段序号)
55 * 37 *
56 * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码> 38 * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码>
@@ -58,14 +40,4 @@ public interface SectionRouteService extends BaseService&lt;SectionRoute, Integer&gt; @@ -58,14 +40,4 @@ public interface SectionRouteService extends BaseService&lt;SectionRoute, Integer&gt;
58 * @return List<Map<String, Object>> 40 * @return List<Map<String, Object>>
59 */ 41 */
60 List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map); 42 List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map);
61 -  
62 - Map<String, Object> quoteSection(Map<String, Object> map);  
63 -  
64 - void batchUpdate(Integer lineId, String lineCode);  
65 -  
66 - Map<String,Object> destroy(Integer id);  
67 -  
68 - Map<String, Object> destroyHistory(Integer id);  
69 -  
70 - Map pageLs(Map<String, Object> map);  
71 } 43 }
src/main/java/com/bsth/service/SectionService.java
1 package com.bsth.service; 1 package com.bsth.service;
2 2
  3 +import java.util.List;
3 import java.util.Map; 4 import java.util.Map;
4 5
5 import com.bsth.entity.Section; 6 import com.bsth.entity.Section;
@@ -20,17 +21,25 @@ import com.bsth.entity.Section; @@ -20,17 +21,25 @@ import com.bsth.entity.Section;
20 * 21 *
21 */ 22 */
22 public interface SectionService extends BaseService<Section, Integer> { 23 public interface SectionService extends BaseService<Section, Integer> {
23 - 24 +
  25 + Map<String,Object> doubleName(Map<String, Object> map);
  26 +
24 /** 27 /**
25 - * @Description :TODO(编辑线路走向)  
26 - *  
27 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
28 - *  
29 - * @return Map<String, Object> <SUCCESS ; ERROR> 28 + * 新增路段信息
  29 + * @param section
30 */ 30 */
31 - Map<String, Object> sectionUpdate(Map<String, Object> map);  
32 -  
33 - Map<String, Object> sectionSave(Map<String, Object> map); 31 + void add(Section section);
34 32
35 - Map<String,Object> doubleName(Map<String, Object> map); 33 + /**
  34 + * 修改路段信息
  35 + * @param section
  36 + */
  37 + void modify(Section section);
  38 +
  39 + /**
  40 + * 根据路段名模糊检索路段信息
  41 + * @param sectionName
  42 + * @return
  43 + */
  44 + List<Section> findSectionByName(String sectionName);
36 } 45 }
src/main/java/com/bsth/service/SectionSpeedService.java deleted 100644 → 0
1 -package com.bsth.service;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import com.bsth.entity.SectionSpeed;  
7 -  
8 -/**  
9 - * Created by xu on 16/5/31.  
10 - */  
11 -public interface SectionSpeedService extends BaseService<SectionSpeed, Integer> {  
12 -  
13 - /** @description TODO(新增路段限速) @return map ({status:SUCCESS}成功 或者 {status:ERROR}失败) @param map (路段限速信息)*/  
14 - Map<String, Object> add(Map<String, Object> map);  
15 -  
16 - /** @description TODO(修改路段) @return map ({status:SUCCESS}成功 或者 {status:ERROR}失败) @param map (路段限速信息)*/  
17 - Map<String, Object> roadUpd(Map<String, Object> map);  
18 -  
19 - List<Map<String, Object>> getSectionSpeedInfo(Map<String, Object> map);  
20 -  
21 - /** 解析路段 */  
22 - List<Map<String, Object>> analyticSection(Map<String,Object> map);  
23 -  
24 -}  
src/main/java/com/bsth/service/StationRouteService.java
@@ -24,19 +24,13 @@ import java.util.Map; @@ -24,19 +24,13 @@ import java.util.Map;
24 */ 24 */
25 public interface StationRouteService extends BaseService<StationRoute, Integer> { 25 public interface StationRouteService extends BaseService<StationRoute, Integer> {
26 26
27 - /**  
28 - * 历史查询。  
29 - * @param map  
30 - * @return  
31 - */  
32 - Iterable<LsStationRoute> list_ls(Map<String, Object> map);  
33 -  
34 /** 27 /**
35 * 28 *
36 * @Title: list 29 * @Title: list
37 * @Description: TODO(多条件查询) 30 * @Description: TODO(多条件查询)
38 * @throws 31 * @throws
39 */ 32 */
  33 + @Override
40 Iterable<StationRoute> list(Map<String, Object> map); 34 Iterable<StationRoute> list(Map<String, Object> map);
41 35
42 /** 36 /**
@@ -46,28 +40,19 @@ public interface StationRouteService extends BaseService&lt;StationRoute, Integer&gt; @@ -46,28 +40,19 @@ public interface StationRouteService extends BaseService&lt;StationRoute, Integer&gt;
46 * 40 *
47 * @return List<Map<String, Object>> 41 * @return List<Map<String, Object>>
48 */ 42 */
49 - List<Map<String, Object>> findPoints(Map<String, Object> map); 43 + Map<String, Object> findPoints(Map<String, Object> map);
50 44
51 Map<String, Object> systemQuote(Map<String, Object> map); 45 Map<String, Object> systemQuote(Map<String, Object> map);
52 - 46 +
53 /** 47 /**
54 * @Description :TODO(查询线路某方向下的站点序号与类型) 48 * @Description :TODO(查询线路某方向下的站点序号与类型)
55 - * 49 + *
56 * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> 50 * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>
57 - *  
58 - * @return List<Map<String, Object>> 51 + *
  52 + * @return List<Map<String, Object>>
59 */ 53 */
60 List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map); 54 List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map);
61 55
62 - /**  
63 - * @Description :TODO(查询下一个站点)  
64 - *  
65 - * @param map <站点路由id; direction:方向;stationRouteCode:站点编码>  
66 - *  
67 - * @return List<Map<String, Object>>  
68 - */  
69 - List<Map<String, Object>> findDownStationRoute(Map<String, Object> map);  
70 -  
71 /** 56 /**
72 * @Description :TODO(查询线路某方向下所有站点的中心百度坐标) 57 * @Description :TODO(查询线路某方向下所有站点的中心百度坐标)
73 * 58 *
@@ -103,38 +88,12 @@ public interface StationRouteService extends BaseService&lt;StationRoute, Integer&gt; @@ -103,38 +88,12 @@ public interface StationRouteService extends BaseService&lt;StationRoute, Integer&gt;
103 * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA> 88 * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA>
104 */ 89 */
105 Map<String, Object> usingSingle(Map<String, Object> map); 90 Map<String, Object> usingSingle(Map<String, Object> map);
106 -  
107 -  
108 - /**  
109 - * @Description : TODO(根据站点路由Id查询详情)  
110 - *  
111 - * @param map <id:站点路由ID>  
112 - *  
113 - * @return List<Map<String, Object>>  
114 - */  
115 - List<Map<String, Object>> findStationRouteInfo(Map<String, Object> map);  
116 91
117 Map<String, Object> findByMultiLine(String lineIds); 92 Map<String, Object> findByMultiLine(String lineIds);
118 93
119 - Map<String, Object> updSwitchDir(String lineIds,int stauts);  
120 -  
121 - Map<String, Object> upddis(Map<String, Object> map);  
122 -  
123 /** 94 /**
124 * @param id 95 * @param id
125 * @return 96 * @return
126 */ 97 */
127 Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp); 98 Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp);
128 -  
129 - void batchUpdate(Integer lineId, String lineCode);  
130 -  
131 - Map<String, Object> findMatchStation(Map<String, Object> map);  
132 -  
133 - Map<String, Object> updIndustryCode(Map<String, Object> map);  
134 -  
135 - Map<String, Object> matchIndustryCode(Map<String, Object> map);  
136 -  
137 - Map<String, Object> matchNearbyStation(Map<String, Object> map);  
138 -  
139 - Map pageLs(Map<String, Object> map);  
140 } 99 }
src/main/java/com/bsth/service/StationService.java
@@ -23,35 +23,25 @@ import com.bsth.entity.Station; @@ -23,35 +23,25 @@ import com.bsth.entity.Station;
23 * 23 *
24 */ 24 */
25 public interface StationService extends BaseService<Station, Integer> { 25 public interface StationService extends BaseService<Station, Integer> {
26 - 26 +
27 /** 27 /**
28 - * @Description :TODO(系统规划保存数据)  
29 - *  
30 - * @param map <stationJSON:站点信息; sectionJSON:路段信息;dbType:坐标类型; destroy:是否撤销; directions:方向;lineId:线路ID;  
31 - *  
32 - * radius:圆半径;shapesType:图形类型;speedLimit:限速>  
33 - *  
34 - * @return Map<String, Object> <SUCCESS ; ERROR> 28 + * 查询最大站点ID
  29 + * @Description :TODO(查询最大站点ID)
  30 + * @return int <站点id>
35 */ 31 */
36 - Map<String, Object> systemSaveStations(Map<String, Object> map); 32 + long findLatestStationId();
37 33
38 /** 34 /**
39 - * 保存线路某个版本下单行的站点和路段路由  
40 - * 常规使用在根据百度地图生成数据或者模板导入的批量保存  
41 - * @param lineId  
42 - * @param versions  
43 - * @param directions  
44 - * @param stationRoutes  
45 - * @param sectionRoutes  
46 - * @return 35 + * 新增站点
  36 + * @param station
47 */ 37 */
48 - Map<String, Object> saveRoutes(Integer lineId, Integer versions, Integer directions, List<LsStationRoute> stationRoutes, List<LsSectionRoute> sectionRoutes); 38 + void add(Station station);
49 39
50 /** 40 /**
51 - * 更新站点、站点路由信息  
52 - * @param stationRoute 41 + * 更新站点信息
  42 + * @param station
53 */ 43 */
54 - void stationUpdate(LsStationRoute stationRoute); 44 + void modify(Station station);
55 45
56 /** 46 /**
57 * @Description :TODO(根据坐标点匹配数据库中的站点) 47 * @Description :TODO(根据坐标点匹配数据库中的站点)
@@ -66,5 +56,5 @@ public interface StationService extends BaseService&lt;Station, Integer&gt; { @@ -66,5 +56,5 @@ public interface StationService extends BaseService&lt;Station, Integer&gt; {
66 * @param stationName 56 * @param stationName
67 * @return 57 * @return
68 */ 58 */
69 - List<Station> getStationByName(String stationName); 59 + List<Station> findStationByName(String stationName);
70 } 60 }
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
@@ -619,9 +619,9 @@ public class GpsServiceImpl implements GpsService { @@ -619,9 +619,9 @@ public class GpsServiceImpl implements GpsService {
619 public Map<String, Object> findBuffAeraByCode(String lineCode, String code, String type) { 619 public Map<String, Object> findBuffAeraByCode(String lineCode, String code, String type) {
620 Object[][] obj = null; 620 Object[][] obj = null;
621 if (type.equals("station")) 621 if (type.equals("station"))
622 - obj = stationRepository.bufferAera(lineCode, code); 622 + obj = stationRepository.findBufferArea(lineCode, code);
623 else if (type.equals("park")) 623 else if (type.equals("park"))
624 - obj = carParkRepository.bufferAera(code); 624 + obj = carParkRepository.findBufferArea(code);
625 625
626 Map<String, Object> rs = new HashMap<>(); 626 Map<String, Object> rs = new HashMap<>();
627 627
src/main/java/com/bsth/service/impl/BaseServiceImpl.java
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Value; @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Value;
11 import org.springframework.dao.DataIntegrityViolationException; 11 import org.springframework.dao.DataIntegrityViolationException;
12 import org.springframework.data.domain.Page; 12 import org.springframework.data.domain.Page;
13 import org.springframework.data.domain.Pageable; 13 import org.springframework.data.domain.Pageable;
  14 +import org.springframework.data.domain.Sort;
14 15
15 import javax.persistence.EntityManager; 16 import javax.persistence.EntityManager;
16 import java.io.Serializable; 17 import java.io.Serializable;
@@ -36,6 +37,11 @@ public class BaseServiceImpl&lt;T, ID extends Serializable&gt; implements BaseService&lt; @@ -36,6 +37,11 @@ public class BaseServiceImpl&lt;T, ID extends Serializable&gt; implements BaseService&lt;
36 public Iterable<T> list(Map<String, Object> map) { 37 public Iterable<T> list(Map<String, Object> map) {
37 return this.baseRepository.findAll(new CustomerSpecs<T>(map)); 38 return this.baseRepository.findAll(new CustomerSpecs<T>(map));
38 } 39 }
  40 +
  41 + @Override
  42 + public List<T> findAll(Map<String, Object> map, Sort sort) {
  43 + return this.baseRepository.findAll(new CustomerSpecs<>(map), sort);
  44 + }
39 45
40 @Override 46 @Override
41 public T findById(ID id) { 47 public T findById(ID id) {
src/main/java/com/bsth/service/impl/InoutCarparkServiceImpl.java
@@ -435,7 +435,7 @@ public class InoutCarparkServiceImpl extends BaseServiceImpl&lt;LsInoutSectionRoute @@ -435,7 +435,7 @@ public class InoutCarparkServiceImpl extends BaseServiceImpl&lt;LsInoutSectionRoute
435 map.put("lineId", scheduleRealInfo.getXlBm()); 435 map.put("lineId", scheduleRealInfo.getXlBm());
436 map.put("lineCode", scheduleRealInfo.getXlBm()); 436 map.put("lineCode", scheduleRealInfo.getXlBm());
437 map.put("sectionName", scheduleRealInfo.getQdzName() + "-" + scheduleRealInfo.getZdzName()); 437 map.put("sectionName", scheduleRealInfo.getQdzName() + "-" + scheduleRealInfo.getZdzName());
438 - map.put("sectionCode", sectionRepository.sectionMaxId() + 1); 438 + map.put("sectionCode", sectionRepository.findLatestSectionId() + 1);
439 map.put("roadCoding", ""); 439 map.put("roadCoding", "");
440 map.put("dbType", "b"); 440 map.put("dbType", "b");
441 map.put("sectionrouteCode", "1"); 441 map.put("sectionrouteCode", "1");
src/main/java/com/bsth/service/impl/LineServiceImpl.java
@@ -2,22 +2,16 @@ package com.bsth.service.impl; @@ -2,22 +2,16 @@ package com.bsth.service.impl;
2 2
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
4 import com.bsth.entity.Line; 4 import com.bsth.entity.Line;
5 -import com.bsth.entity.StationMatchData;  
6 import com.bsth.repository.LineRepository; 5 import com.bsth.repository.LineRepository;
7 import com.bsth.service.LineService; 6 import com.bsth.service.LineService;
8 -import com.bsth.util.db.DBUtils_station;  
9 -import org.apache.commons.lang3.StringUtils;  
10 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.jdbc.core.JdbcTemplate; 8 import org.springframework.jdbc.core.JdbcTemplate;
12 import org.springframework.jdbc.core.RowMapper; 9 import org.springframework.jdbc.core.RowMapper;
13 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
14 import org.springframework.transaction.annotation.Transactional; 11 import org.springframework.transaction.annotation.Transactional;
15 12
16 -import java.sql.Connection;  
17 -import java.sql.PreparedStatement;  
18 import java.sql.ResultSet; 13 import java.sql.ResultSet;
19 import java.sql.SQLException; 14 import java.sql.SQLException;
20 -import java.util.ArrayList;  
21 import java.util.HashMap; 15 import java.util.HashMap;
22 import java.util.List; 16 import java.util.List;
23 import java.util.Map; 17 import java.util.Map;
@@ -162,37 +156,4 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L @@ -162,37 +156,4 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L
162 } 156 }
163 return map; 157 return map;
164 } 158 }
165 -  
166 - @Override  
167 - public Map<String, Object> getLineMatchStationIsUpdate(Integer id){  
168 - Map<String, Object> map = new HashMap<>();  
169 - Line l = repository.findById(id).get();  
170 - Connection conn = null;  
171 - PreparedStatement ps = null;  
172 - ResultSet rs = null;  
173 -  
174 - List<StationMatchData> listMD = new ArrayList<>();  
175 - String sql = "select `type` from roadline where RoadLine =\""+l.getName()+"\"";  
176 - if(!StringUtils.isEmpty(l.getShanghaiLinecode())){  
177 - sql += " or LineStandardCode=\""+l.getShanghaiLinecode()+"\"";  
178 - }  
179 - try {  
180 - conn = DBUtils_station.getConnection();  
181 - ps = conn.prepareStatement(sql);  
182 -// int stauts = ps.executeQuery().getInt(1);  
183 - String stauts = "0";  
184 - rs = ps.executeQuery();  
185 - while (rs.next()) {  
186 - stauts = rs.getString("type");  
187 - }  
188 - map.put("status",ResponseCode.SUCCESS);  
189 - map.put("data",stauts);  
190 - }catch(Exception e){  
191 - logger.error(e.toString(), e);  
192 - map.put("status",ResponseCode.ERROR);  
193 - }finally {  
194 - DBUtils_station.close(rs, ps, conn);  
195 - }  
196 - return map;  
197 - }  
198 } 159 }
src/main/java/com/bsth/service/impl/LsSectionRouteServiceImpl.java
1 package com.bsth.service.impl; 1 package com.bsth.service.impl;
2 2
3 -import com.bsth.entity.LsSectionRoute;  
4 -import com.bsth.repository.LsSectionRouteRepository; 3 +import com.bsth.entity.*;
  4 +import com.bsth.repository.*;
5 import com.bsth.service.LsSectionRouteService; 5 import com.bsth.service.LsSectionRouteService;
  6 +import com.bsth.util.CoordinateConverter;
  7 +import com.bsth.util.CustomBeanUtils;
  8 +import com.bsth.util.GeoConverter;
  9 +import org.geolatte.geom.Point;
  10 +import org.geolatte.geom.Polygon;
  11 +import org.geolatte.geom.codec.Wkt;
6 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
8 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
9 15
  16 +import java.util.HashMap;
10 import java.util.List; 17 import java.util.List;
  18 +import java.util.Map;
11 19
12 /** 20 /**
13 * @author Hill 21 * @author Hill
@@ -18,13 +26,97 @@ public class LsSectionRouteServiceImpl extends BaseServiceImpl&lt;LsSectionRoute, I @@ -18,13 +26,97 @@ public class LsSectionRouteServiceImpl extends BaseServiceImpl&lt;LsSectionRoute, I
18 @Autowired 26 @Autowired
19 private LsSectionRouteRepository lsSectionRouteRepository; 27 private LsSectionRouteRepository lsSectionRouteRepository;
20 28
  29 + @Autowired
  30 + private SectionRouteRepository sectionRouteRepository;
  31 +
  32 + @Autowired
  33 + private LineVersionsRepository lineVersionsRepository;
  34 +
  35 + @Autowired
  36 + private LineRepository lineRepository;
  37 +
  38 + @Autowired
  39 + private SectionRepository sectionRepository;
  40 +
21 /** 41 /**
22 * 批量撤销路段路由 42 * 批量撤销路段路由
23 * @param ids 43 * @param ids
24 */ 44 */
25 @Override 45 @Override
26 - @Transactional 46 + @Transactional(rollbackFor = RuntimeException.class)
27 public void batchDestroy(List<Integer> ids) { 47 public void batchDestroy(List<Integer> ids) {
  48 + LsSectionRoute lsSectionRoute = lsSectionRouteRepository.findById(ids.get(0)).get();
  49 + Integer currentVersion = lineVersionsRepository.findCurrentVersion(lsSectionRoute.getLine().getId());
  50 + if (lsSectionRoute.getVersions() < currentVersion) {
  51 + throw new IllegalArgumentException("历史版本不可变更");
  52 + }
28 lsSectionRouteRepository.batchDestroy(ids); 53 lsSectionRouteRepository.batchDestroy(ids);
  54 + if (lsSectionRoute.getVersions().equals(currentVersion)) {
  55 + refreshCurrent(lsSectionRoute.getLine().getId(), currentVersion);
  56 + }
  57 + }
  58 +
  59 + @Override
  60 + @Transactional(rollbackFor = RuntimeException.class)
  61 + public Map<String, Object> quoteOtherSide(int lineId, int version, int direction, int otherDirection) {
  62 + Integer currentVersion = lineVersionsRepository.findCurrentVersion(lineId);
  63 + if (version < currentVersion) {
  64 + throw new IllegalArgumentException("历史版本不可变更");
  65 + }
  66 + lsSectionRouteRepository.quoteOtherSide(lineId, version, direction, otherDirection);
  67 + if (Integer.valueOf(version).equals(currentVersion)) {
  68 + refreshCurrent(lineId, currentVersion);
  69 + }
  70 +
  71 + return new HashMap<>(0);
  72 + }
  73 +
  74 + @Transactional(rollbackFor = RuntimeException.class)
  75 + @Override
  76 + public void add(LsSectionRoute sectionRoute) {
  77 + Section section = sectionRoute.getSection();
  78 + Line line = lineRepository.findById(sectionRoute.getLine().getId()).get();
  79 + Integer version = lineVersionsRepository.findCurrentVersion(line.getId());
  80 + boolean isPresent = sectionRepository.findById(section.getId()).isPresent();
  81 + sectionRoute.setLineCode(line.getLineCode());
  82 + if (sectionRoute.getVersions() < version) {
  83 + throw new IllegalArgumentException("历史版本不可变更");
  84 + }
  85 +
  86 + // 路段坐标信息
  87 + if (!isPresent) {
  88 + SectionServiceImpl.centerLine(section);
  89 + }
  90 +
  91 + lsSectionRouteRepository.updateSectiouRouteCode(sectionRoute);
  92 + if (!isPresent) {
  93 + sectionRepository.save(section);
  94 + }
  95 + lsSectionRouteRepository.save(sectionRoute);
  96 + if (sectionRoute.getVersions().equals(version)) {
  97 + refreshCurrent(line.getId(), version);
  98 + }
  99 + }
  100 +
  101 + @Transactional(rollbackFor = RuntimeException.class)
  102 + @Override
  103 + public void modify(LsSectionRoute sectionRoute) {
  104 + LsSectionRoute sectionRoute1 = lsSectionRouteRepository.findById(sectionRoute.getId()).get();
  105 + Integer version = lineVersionsRepository.findCurrentVersion(sectionRoute1.getLine().getId());
  106 + if (sectionRoute1.getVersions() < version) {
  107 + throw new IllegalArgumentException("历史版本不可变更");
  108 + }
  109 +
  110 + lsSectionRouteRepository.updateSectiouRouteCode(sectionRoute);
  111 + CustomBeanUtils.copyPropertiesIgnoredNull(sectionRoute, sectionRoute1);
  112 + lsSectionRouteRepository.save(sectionRoute1);
  113 + if (sectionRoute.getVersions().equals(version)) {
  114 + refreshCurrent(sectionRoute1.getLine().getId(), version);
  115 + }
  116 + }
  117 +
  118 + protected void refreshCurrent(int lineId, int version) {
  119 + sectionRouteRepository.deleteByLineAndVersion(lineId, version);
  120 + sectionRouteRepository.updateFromHistory(lineId, version);
29 } 121 }
30 } 122 }
31 \ No newline at end of file 123 \ No newline at end of file
src/main/java/com/bsth/service/impl/LsStationRouteServiceImpl.java
1 package com.bsth.service.impl; 1 package com.bsth.service.impl;
2 2
3 -import com.bsth.entity.Line;  
4 -import com.bsth.entity.LsStationRoute;  
5 -import com.bsth.entity.Station; 3 +import com.bsth.annotation.BusinessDescription;
  4 +import com.bsth.entity.*;
6 import com.bsth.entity.search.CustomerSpecs; 5 import com.bsth.entity.search.CustomerSpecs;
7 import com.bsth.repository.*; 6 import com.bsth.repository.*;
8 import com.bsth.service.LsStationRouteService; 7 import com.bsth.service.LsStationRouteService;
9 import com.bsth.util.CoordinateConverter; 8 import com.bsth.util.CoordinateConverter;
10 import com.bsth.util.CustomBeanUtils; 9 import com.bsth.util.CustomBeanUtils;
11 import com.bsth.util.GeoConverter; 10 import com.bsth.util.GeoConverter;
  11 +import org.geolatte.geom.LineString;
12 import org.geolatte.geom.Point; 12 import org.geolatte.geom.Point;
13 import org.geolatte.geom.Polygon; 13 import org.geolatte.geom.Polygon;
14 import org.geolatte.geom.codec.Wkt; 14 import org.geolatte.geom.codec.Wkt;
15 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.data.domain.Sort; 16 import org.springframework.data.domain.Sort;
  17 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  18 +import org.springframework.jdbc.core.JdbcTemplate;
17 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Transactional; 20 import org.springframework.transaction.annotation.Transactional;
  21 +import org.springframework.util.StringUtils;
19 22
20 -import java.util.*; 23 +import java.sql.PreparedStatement;
  24 +import java.sql.SQLException;
  25 +import java.util.ArrayList;
  26 +import java.util.HashMap;
  27 +import java.util.List;
  28 +import java.util.Map;
21 29
22 /** 30 /**
23 * @author Hill 31 * @author Hill
@@ -35,11 +43,23 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I @@ -35,11 +43,23 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
35 private StationRepository stationRepository; 43 private StationRepository stationRepository;
36 44
37 @Autowired 45 @Autowired
  46 + private LsSectionRouteRepository lsSectionRouteRepository;
  47 +
  48 + @Autowired
  49 + private SectionRouteRepository sectionRouteRepository;
  50 +
  51 + @Autowired
  52 + private SectionRepository sectionRepository;
  53 +
  54 + @Autowired
38 private LineRepository lineRepository; 55 private LineRepository lineRepository;
39 56
40 @Autowired 57 @Autowired
41 private LineVersionsRepository lineVersionsRepository; 58 private LineVersionsRepository lineVersionsRepository;
42 59
  60 + @Autowired
  61 + private JdbcTemplate jdbcTemplate;
  62 +
43 @Override 63 @Override
44 public Iterable<LsStationRoute> findAllByParams(Map<String, Object> map) { 64 public Iterable<LsStationRoute> findAllByParams(Map<String, Object> map) {
45 List<Sort.Order> orders = new ArrayList<>(); 65 List<Sort.Order> orders = new ArrayList<>();
@@ -50,9 +70,37 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I @@ -50,9 +70,37 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
50 } 70 }
51 71
52 /** 72 /**
  73 + * 获取当前站点以及下一站点路由
  74 + * @param id
  75 + * @return
  76 + */
  77 + @Override
  78 + public List<LsStationRoute> findCurrentAndNext(Integer id) {
  79 + if (id == null) {
  80 + throw new IllegalArgumentException("需正确传入站点路由ID参数");
  81 + }
  82 + List<LsStationRoute> stationRoutes = new ArrayList<>();
  83 + LsStationRoute stationRoute = lsStationRouteRepository.findById(id).get();
  84 + Map<String, Object> params = new HashMap<>();
  85 + params.put("line.id_eq", stationRoute.getLine().getId());
  86 + params.put("versions_eq", stationRoute.getVersions());
  87 + params.put("directions_eq", stationRoute.getDirections());
  88 + params.put("destroy_eq", 0);
  89 + params.put("stationRouteCode_gt", stationRoute.getStationRouteCode());
  90 + List<LsStationRoute> stationRoutes1 = lsStationRouteRepository.findAll(new CustomerSpecs<>(params), Sort.by(Sort.Order.asc("stationRouteCode")));
  91 + stationRoutes.add(stationRoute);
  92 + if (stationRoutes1.size() > 0) {
  93 + stationRoutes.add(stationRoutes1.get(0));
  94 + }
  95 +
  96 + return stationRoutes;
  97 + }
  98 +
  99 + /**
53 * 批量撤销站点路由 100 * 批量撤销站点路由
54 * @param ids 101 * @param ids
55 */ 102 */
  103 + @BusinessDescription(value = "批量撤销站点路由")
56 @Transactional(rollbackFor = RuntimeException.class) 104 @Transactional(rollbackFor = RuntimeException.class)
57 @Override 105 @Override
58 public void batchDestroy(List<Integer> ids) { 106 public void batchDestroy(List<Integer> ids) {
@@ -60,49 +108,101 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I @@ -60,49 +108,101 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
60 Integer id = ids.get(0); 108 Integer id = ids.get(0);
61 LsStationRoute stationRoute = lsStationRouteRepository.findById(id).get(); 109 LsStationRoute stationRoute = lsStationRouteRepository.findById(id).get();
62 Integer lineId = stationRoute.getLine().getId(); 110 Integer lineId = stationRoute.getLine().getId();
63 - Integer versions = lineVersionsRepository.findCurrentVersion(lineId);  
64 - if (stationRoute.getVersions() < versions) { 111 + Integer currentVersion = lineVersionsRepository.findCurrentVersion(lineId);
  112 + if (stationRoute.getVersions() < currentVersion) {
65 throw new IllegalArgumentException("历史版本不可变更"); 113 throw new IllegalArgumentException("历史版本不可变更");
66 } 114 }
67 115
68 lsStationRouteRepository.batchDestroy(ids); 116 lsStationRouteRepository.batchDestroy(ids);
69 remark(stationRoute); 117 remark(stationRoute);
70 - if (stationRoute.getVersions().equals(versions)) {  
71 - stationRouteRepository.deleteByLineAndVersion(lineId, versions);  
72 - stationRouteRepository.updateFromHistory(lineId, versions); 118 + if (stationRoute.getVersions().equals(currentVersion)) {
  119 + refreshCurrent(lineId, currentVersion);
73 } 120 }
74 } 121 }
75 } 122 }
76 123
77 @Transactional 124 @Transactional
78 @Override 125 @Override
  126 + public Map<String, Object> addRoutes(Integer lineId, Integer versions, Integer directions, List<LsStationRoute> stationRoutes, List<LsSectionRoute> sectionRoutes) {
  127 + Map<String, Object> result = new HashMap<>();
  128 + Line line = lineRepository.findById(lineId).get();
  129 + Integer version = lineVersionsRepository.findCurrentVersion(lineId);
  130 + if (line == null) {
  131 + throw new RuntimeException(String.format("未找到ID为%d的线路信息", lineId));
  132 + }
  133 + stationRoutesHandle(line, versions, directions, stationRoutes);
  134 + List<Section> sections = sectionRoutesHandle(line, versions, directions, sectionRoutes);
  135 +
  136 + //stationRepository.saveAll(stations);
  137 + sectionRepository.saveAll(sections);
  138 + lsStationRouteRepository.saveAll(stationRoutes);
  139 + lsSectionRouteRepository.saveAll(sectionRoutes);
  140 + if (versions.equals(version)) {
  141 + refreshCurrent(lineId, version);
  142 + }
  143 +
  144 + return result;
  145 + }
  146 +
  147 + private void stationRoutesHandle(Line line, Integer versions, Integer directions, List<LsStationRoute> stationRoutes) {
  148 + int count = 0;
  149 + for (int len = stationRoutes.size();count < len;) {
  150 + LsStationRoute stationRoute = stationRoutes.get(count);
  151 + stationRoute.setStationMark(count == 0 ? "B" : count == len - 1 ? "E" : "Z");
  152 + count++;
  153 + stationRoute.setLine(line);
  154 + stationRoute.setVersions(versions);
  155 + stationRoute.setDirections(directions);
  156 + stationRoute.setLineCode(line.getLineCode());
  157 + stationRoute.setStationRouteCode(100 * count);
  158 + stationRoute.setStationCode(stationRoute.getStation().getStationCode());
  159 + }
  160 + }
  161 +
  162 + private List<Section> sectionRoutesHandle(Line line, Integer versions, Integer directions, List<LsSectionRoute> sectionRoutes) {
  163 + List<Section> sections = new ArrayList<>();
  164 + int currentId = sectionRepository.findLatestSectionId(), count = 0;
  165 + for (int len = sectionRoutes.size();count < len;) {
  166 + LsSectionRoute sectionRoute = sectionRoutes.get(count++);
  167 + sectionRoute.setLine(line);
  168 + sectionRoute.setVersions(versions);
  169 + sectionRoute.setDirections(directions);
  170 + sectionRoute.setLineCode(line.getLineCode());
  171 + sectionRoute.setSectionrouteCode(100 * count);
  172 + String wkt = sectionRoute.getSection().getBsectionVectorWkt();
  173 + Section section = sectionRoute.getSection();
  174 + section.setBsectionVector((LineString) Wkt.fromWkt(wkt));
  175 + section.setGsectionVector(GeoConverter.lineStringBd2wgs(wkt));
  176 + section.setId(currentId + count);
  177 + section.setSectionCode(section.getId().toString());
  178 + sectionRoute.setSectionCode(section.getSectionCode());
  179 + sections.add(section);
  180 + }
  181 +
  182 + return sections;
  183 + }
  184 +
  185 + @BusinessDescription(value = "添加站点路由")
  186 + @Transactional
  187 + @Override
79 public Map<String, Object> add(LsStationRoute stationRoute) { 188 public Map<String, Object> add(LsStationRoute stationRoute) {
80 Station station = stationRoute.getStation(); 189 Station station = stationRoute.getStation();
81 Line line = lineRepository.findById(stationRoute.getLine().getId()).get(); 190 Line line = lineRepository.findById(stationRoute.getLine().getId()).get();
82 - Integer versions = lineVersionsRepository.findCurrentVersion(line.getId()); 191 + Integer currentVersion = lineVersionsRepository.findCurrentVersion(line.getId());
83 boolean isPresent = stationRepository.findById(station.getId()).isPresent(); 192 boolean isPresent = stationRepository.findById(station.getId()).isPresent();
84 stationRoute.setLineCode(line.getLineCode()); 193 stationRoute.setLineCode(line.getLineCode());
85 - if (stationRoute.getVersions() < versions) { 194 + if (stationRoute.getVersions() < currentVersion) {
86 throw new IllegalArgumentException("历史版本不可变更"); 195 throw new IllegalArgumentException("历史版本不可变更");
87 } 196 }
88 197
89 // 中心点坐标信息 198 // 中心点坐标信息
90 if (!isPresent) { 199 if (!isPresent) {
91 - String centerPoint = station.getCenterPointWkt();  
92 - CoordinateConverter.Location bd = CoordinateConverter.LocationMake(centerPoint);  
93 - CoordinateConverter.Location wgs = CoordinateConverter.transformFromBDToWGS(bd);  
94 - Point baiduPoint = (Point) Wkt.fromWkt(bd.toWkt());  
95 - Point wgsPoint = (Point) Wkt.fromWkt(wgs.toWkt());  
96 - station.setCenterPoint(baiduPoint);  
97 - station.setCenterPointWgs(wgsPoint); 200 + centerPoint(station);
98 } 201 }
99 202
100 // 多边形缓冲区 203 // 多边形缓冲区
101 if ("d".equals(stationRoute.getShapedType())) { 204 if ("d".equals(stationRoute.getShapedType())) {
102 - String wkt = stationRoute.getBufferPolygonWkt();  
103 -  
104 - stationRoute.setBufferPolygon((Polygon) Wkt.fromWkt(wkt));  
105 - stationRoute.setBufferPolygonWgs(GeoConverter.polygonBd2wgs(wkt)); 205 + bufferPolygon(stationRoute);
106 } 206 }
107 207
108 lsStationRouteRepository.updateStatiouRouteCode(stationRoute); 208 lsStationRouteRepository.updateStatiouRouteCode(stationRoute);
@@ -111,9 +211,8 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I @@ -111,9 +211,8 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
111 } 211 }
112 lsStationRouteRepository.save(stationRoute); 212 lsStationRouteRepository.save(stationRoute);
113 remark(stationRoute); 213 remark(stationRoute);
114 - if (stationRoute.getVersions().equals(versions)) {  
115 - stationRouteRepository.deleteByLineAndVersion(line.getId(), versions);  
116 - stationRouteRepository.updateFromHistory(line.getId(), versions); 214 + if (stationRoute.getVersions().equals(currentVersion)) {
  215 + refreshCurrent(line.getId(), currentVersion);
117 } 216 }
118 217
119 return new HashMap<>(); 218 return new HashMap<>();
@@ -123,34 +222,126 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I @@ -123,34 +222,126 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
123 @Override 222 @Override
124 public Map<String, Object> modify(LsStationRoute stationRoute) { 223 public Map<String, Object> modify(LsStationRoute stationRoute) {
125 LsStationRoute stationRoute1 = lsStationRouteRepository.findById(stationRoute.getId()).get(); 224 LsStationRoute stationRoute1 = lsStationRouteRepository.findById(stationRoute.getId()).get();
126 - Integer versions = lineVersionsRepository.findCurrentVersion(stationRoute1.getLine().getId());  
127 - if (stationRoute1.getVersions() < versions) { 225 + Integer currentVersion = lineVersionsRepository.findCurrentVersion(stationRoute1.getLine().getId());
  226 + if (stationRoute1.getVersions() < currentVersion) {
128 throw new IllegalArgumentException("历史版本不可变更"); 227 throw new IllegalArgumentException("历史版本不可变更");
129 } 228 }
130 229
131 // 多边形缓冲区 230 // 多边形缓冲区
132 if ("d".equals(stationRoute.getShapedType())) { 231 if ("d".equals(stationRoute.getShapedType())) {
133 - String wkt = stationRoute.getBufferPolygonWkt();  
134 -  
135 - stationRoute.setBufferPolygon((Polygon) Wkt.fromWkt(wkt));  
136 - stationRoute.setBufferPolygonWgs(GeoConverter.polygonBd2wgs(wkt)); 232 + bufferPolygon(stationRoute);
137 } 233 }
138 234
139 lsStationRouteRepository.updateStatiouRouteCode(stationRoute); 235 lsStationRouteRepository.updateStatiouRouteCode(stationRoute);
140 CustomBeanUtils.copyPropertiesIgnoredNull(stationRoute, stationRoute1); 236 CustomBeanUtils.copyPropertiesIgnoredNull(stationRoute, stationRoute1);
141 lsStationRouteRepository.save(stationRoute1); 237 lsStationRouteRepository.save(stationRoute1);
142 remark(stationRoute1); 238 remark(stationRoute1);
143 - if (stationRoute.getVersions().equals(versions)) {  
144 - stationRouteRepository.deleteByLineAndVersion(stationRoute1.getLine().getId(), versions);  
145 - stationRouteRepository.updateFromHistory(stationRoute1.getLine().getId(), versions); 239 + if (stationRoute.getVersions().equals(currentVersion)) {
  240 + refreshCurrent(stationRoute1.getLine().getId(), currentVersion);
146 } 241 }
147 242
148 return new HashMap<>(); 243 return new HashMap<>();
149 } 244 }
150 245
151 - public void remark(LsStationRoute stationRoute) { 246 + @Transactional
  247 + @Override
  248 + public Map<String, Object> exchangeDirection(int lineId, int version) {
  249 + lsStationRouteRepository.exchangeDirection(lineId, version);
  250 + lsSectionRouteRepository.exchangeDirection(lineId, version);
  251 +
  252 + return new HashMap<>();
  253 + }
  254 +
  255 + @Transactional
  256 + @Override
  257 + public Map<String, Object> modifyDistance(List<Integer> ids, List<Double> distances) {
  258 + LsStationRoute stationRoute = lsStationRouteRepository.findById(ids.get(0)).get();
  259 + int currentVersion = lineVersionsRepository.findCurrentVersion(stationRoute.getLine().getId());
  260 + if (stationRoute.getVersions() < currentVersion) {
  261 + throw new IllegalArgumentException("历史版本不可变更");
  262 + }
  263 +
  264 + jdbcTemplate.batchUpdate("UPDATE bsth_c_ls_stationroute SET distances = ? WHERE id = ?", new BatchPreparedStatementSetter() {
  265 + @Override
  266 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  267 + ps.setDouble(1, distances.get(i));
  268 + ps.setInt(2, ids.get(i));
  269 + }
  270 +
  271 + @Override
  272 + public int getBatchSize() {
  273 + return ids.size();
  274 + }
  275 + });
  276 +
  277 + if (stationRoute.getVersions() == currentVersion) {
  278 + refreshCurrent(stationRoute.getLine().getId(), currentVersion);
  279 + }
  280 +
  281 + return new HashMap<>();
  282 + }
  283 +
  284 + @Transactional
  285 + @Override
  286 + public Map<String, Object> circularRouteHandle(Integer lineId, Integer version) {
  287 + Line line = lineRepository.findById(lineId).get();
  288 + Integer currentVersion = lineVersionsRepository.findCurrentVersion(lineId);
  289 + if (version < currentVersion) {
  290 + throw new IllegalArgumentException("历史版本不可变更");
  291 + }
  292 +
  293 + Map<String, Object> params = new HashMap<>();
  294 + params.put("line.id_eq", lineId);
  295 + params.put("versions_eq", version);
  296 + params.put("destroy_eq", 0);
  297 + params.put("stationMark_in", "B,E");
  298 +
  299 + Sort sort = Sort.by(Sort.Order.asc("directions"), Sort.Order.asc("stationRouteCode"));
  300 + List<LsStationRoute> routes = lsStationRouteRepository.findAll(new CustomerSpecs<>(params), sort);
  301 + LsStationRoute route = routes.get(0);
  302 + for (int i = 1;i < routes.size();i++) {
  303 + LsStationRoute route1 = routes.get(i);
  304 + if (line.getLinePlayType() == 1 && route1.getDirections() == 1) {
  305 + break;
  306 + }
  307 + route1.setStationCode(route.getStationCode());
  308 + route1.setStation(route.getStation());
  309 + }
  310 + lsStationRouteRepository.saveAll(routes);
  311 + if (version.equals(currentVersion)) {
  312 + refreshCurrent(lineId, version);
  313 + }
  314 +
  315 + return new HashMap<>();
  316 + }
  317 +
  318 + protected void centerPoint(Station station) {
  319 + // 中心点坐标信息
  320 + String wkt = station.getCenterPointWkt();
  321 + if (!StringUtils.isEmpty(wkt)) {
  322 + org.geolatte.geom.Point baidu = (org.geolatte.geom.Point) Wkt.fromWkt(wkt);
  323 + org.geolatte.geom.Point wgs = GeoConverter.pointBd2wgs(wkt);
  324 + station.setCenterPoint(baidu);
  325 + station.setCenterPointWgs(wgs);
  326 + }
  327 + }
  328 +
  329 + protected void bufferPolygon(LsStationRoute stationRoute) {
  330 + String wkt = stationRoute.getBufferPolygonWkt();
  331 + if (!StringUtils.isEmpty(wkt)) {
  332 + stationRoute.setBufferPolygon((Polygon) Wkt.fromWkt(wkt));
  333 + stationRoute.setBufferPolygonWgs(GeoConverter.polygonBd2wgs(wkt));
  334 + }
  335 + }
  336 +
  337 + protected void remark(LsStationRoute stationRoute) {
152 lsStationRouteRepository.updateStartZ(stationRoute); 338 lsStationRouteRepository.updateStartZ(stationRoute);
153 lsStationRouteRepository.updateStartB(stationRoute); 339 lsStationRouteRepository.updateStartB(stationRoute);
154 lsStationRouteRepository.updateStartE(stationRoute); 340 lsStationRouteRepository.updateStartE(stationRoute);
155 } 341 }
  342 +
  343 + protected void refreshCurrent(int lineId, int version) {
  344 + stationRouteRepository.deleteByLineAndVersion(lineId, version);
  345 + stationRouteRepository.updateFromHistory(lineId, version);
  346 + }
156 } 347 }
src/main/java/com/bsth/service/impl/RoadSpeedServiceImpl.java deleted 100644 → 0
1 -package com.bsth.service.impl;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.HashMap;  
5 -import java.util.Iterator;  
6 -import java.util.List;  
7 -import java.util.Map;  
8 -  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.stereotype.Service;  
11 -  
12 -import com.alibaba.fastjson.JSONArray;  
13 -import com.bsth.common.ResponseCode;  
14 -import com.bsth.entity.RoadSpeed;  
15 -import com.bsth.repository.RoadSpeedRepository;  
16 -import com.bsth.service.RoadSpeedService;  
17 -import com.bsth.util.CoordinateConverter;  
18 -import com.bsth.util.CoordinateConverter.Location;  
19 -  
20 -@Service  
21 -public class RoadSpeedServiceImpl extends BaseServiceImpl<RoadSpeed, Integer> implements RoadSpeedService {  
22 -  
23 - @Autowired  
24 - private RoadSpeedRepository repository;  
25 -  
26 - @Override  
27 - public Map<String, Object> update(Map<String, Object> map) {  
28 - Map<String, Object> resultMap = new HashMap<String, Object>();  
29 - try {  
30 - int id = Integer.parseInt(map.get("id").toString());  
31 - String name = map.get("name").toString();  
32 - double speed = Double.valueOf(map.get("speed").toString());  
33 - String speedStartDate = map.get("speedStartDate").toString();  
34 - String speedEndDate = map.get("speedEndDate").toString();  
35 - int isStart = Integer.parseInt(map.get("isStart").toString());  
36 - String sectionJSON = map.get("bRoadVector").toString();  
37 - // 原始线状图形坐标集合  
38 - String sectionsBpoints = "";  
39 - // WGS线状图形坐标集合  
40 - String sectionsWJPpoints = "";  
41 - if(!sectionJSON.equals("")) {  
42 - // 转换成JSON数组  
43 - JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);  
44 - // 遍历  
45 - for(int s = 0 ;s<sectionsArray.size();s++) {  
46 - String pointsLngStr = sectionsArray.getJSONObject(s).get("lng").toString();  
47 - String pointsLatStr = sectionsArray.getJSONObject(s).get("lat").toString();  
48 - String WGSLngStr = "";  
49 - String WGSLatStr = "";  
50 - Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);  
51 - WGSLngStr = String.valueOf(resultPoint.getLng());  
52 - WGSLatStr = String.valueOf(resultPoint.getLat());  
53 - if(s==0) {  
54 - sectionsBpoints = pointsLngStr + " " + pointsLatStr;  
55 - sectionsWJPpoints = WGSLngStr + " " + WGSLatStr;  
56 - }else {  
57 - sectionsBpoints = sectionsBpoints + "," + pointsLngStr + " " + pointsLatStr;  
58 - sectionsWJPpoints = sectionsWJPpoints + "," + WGSLngStr + " " + WGSLatStr;  
59 - }  
60 - }  
61 - }  
62 - // WGS坐标点集合  
63 - String gRoadVector = "LINESTRING(" + sectionsWJPpoints +")";  
64 - // 原坐标点集合  
65 - String bRoadVector = "LINESTRING(" + sectionsBpoints + ")";  
66 -  
67 - repository.update(id,name,gRoadVector,bRoadVector,speed,speedStartDate,speedEndDate,isStart);  
68 - resultMap.put("status", ResponseCode.SUCCESS);  
69 - } catch (Exception e) {  
70 - resultMap.put("status", ResponseCode.ERROR);  
71 - logger.error("save erro.", e);  
72 - }  
73 - return resultMap;  
74 - }  
75 -  
76 - @Override  
77 - public Map<String, Object> roadSpeedSave(Map<String, Object> map) {  
78 - Map<String, Object> resultMap = new HashMap<String, Object>();  
79 - try {  
80 - String name = map.get("name").toString();  
81 - double speed = Double.valueOf(map.get("speed").toString());  
82 - String speedStartDate = map.get("speedStartDate").toString();  
83 - String speedEndDate = map.get("speedEndDate").toString();  
84 - int isStart = Integer.parseInt(map.get("isStart").toString());  
85 - String sectionJSON = map.get("bRoadVector").toString();  
86 - // 原始线状图形坐标集合  
87 - String sectionsBpoints = "";  
88 - // WGS线状图形坐标集合  
89 - String sectionsWJPpoints = "";  
90 - if(!sectionJSON.equals("")) {  
91 - // 转换成JSON数组  
92 - JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);  
93 - // 遍历  
94 - for(int s = 0 ;s<sectionsArray.size();s++) {  
95 - String pointsLngStr = sectionsArray.getJSONObject(s).get("lng").toString();  
96 - String pointsLatStr = sectionsArray.getJSONObject(s).get("lat").toString();  
97 - String WGSLngStr = "";  
98 - String WGSLatStr = "";  
99 - Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);  
100 - WGSLngStr = String.valueOf(resultPoint.getLng());  
101 - WGSLatStr = String.valueOf(resultPoint.getLat());  
102 - if(s==0) {  
103 - sectionsBpoints = pointsLngStr + " " + pointsLatStr;  
104 - sectionsWJPpoints = WGSLngStr + " " + WGSLatStr;  
105 - }else {  
106 - sectionsBpoints = sectionsBpoints + "," + pointsLngStr + " " + pointsLatStr;  
107 - sectionsWJPpoints = sectionsWJPpoints + "," + WGSLngStr + " " + WGSLatStr;  
108 - }  
109 - }  
110 - }  
111 - // WGS坐标点集合  
112 - String gRoadVector = "LINESTRING(" + sectionsWJPpoints +")";  
113 - // 原坐标点集合  
114 - String bRoadVector = "LINESTRING(" + sectionsBpoints + ")";  
115 -  
116 - repository.roadSpeedSave(name,gRoadVector,bRoadVector,speed,speedStartDate,speedEndDate,isStart);  
117 - resultMap.put("status", ResponseCode.SUCCESS);  
118 - } catch (Exception e) {  
119 - resultMap.put("status", ResponseCode.ERROR);  
120 - logger.error("save erro.", e);  
121 - }  
122 - return resultMap;  
123 - }  
124 -  
125 - /** 百度坐标转WGS坐标 */  
126 - public Location FromBDPointToWGSPoint(String bLonx,String bLatx) {  
127 -  
128 - double lng = Double.parseDouble(bLonx);  
129 -  
130 - double lat = Double.parseDouble(bLatx);  
131 -  
132 - Location bdLoc = CoordinateConverter.LocationMake(lng, lat);  
133 -  
134 - Location location = CoordinateConverter.bd_decrypt(bdLoc);  
135 -  
136 - Location WGSPoint = CoordinateConverter.transformFromGCJToWGS(location);  
137 -  
138 - return WGSPoint;  
139 -  
140 - }  
141 -  
142 - @Override  
143 - public RoadSpeed findId(Integer id) {  
144 - List<Object[]> listObc = repository.selectById(id);  
145 -  
146 - Object rsObj[] = listObc.get(0);  
147 - RoadSpeed rs = new RoadSpeed();  
148 - String id1 = rsObj[0].toString();  
149 - rs.setId(Integer.parseInt(id1));  
150 - rs.setName(rsObj[1].toString());  
151 - rs.setbRoadVector(rsObj[2].toString());  
152 - rs.setgRoadVector(rsObj[3].toString());  
153 - rs.setSpeed(Double.valueOf(rsObj[4].toString()));  
154 - rs.setSpeedStartDate(rsObj[5].toString());  
155 - rs.setSpeedEndDate(rsObj[6].toString());  
156 - rs.setIsStart(Integer.parseInt(rsObj[7].toString()));  
157 - if (rsObj[8] != null) {  
158 - rs.setLine(rsObj[8].toString());  
159 - }  
160 - return rs;  
161 - }  
162 -  
163 - @Override  
164 - public List<RoadSpeed> allRoadSpeed() {  
165 - List<RoadSpeed> list = new ArrayList<>();  
166 - /*Iterator<RoadSpeed> itr = repository.findAll().iterator();  
167 - while (itr.hasNext()){  
168 - RoadSpeed aRoadSpeed = itr.next();  
169 - System.out.println("aRoadSpeed");  
170 - list.add(aRoadSpeed);  
171 - }*/  
172 - return list;  
173 - }  
174 -}