Commit 9f94a361f204b5e24ecd2a1153e2b1fbcde4c3b4

Authored by 王通
2 parents 9b5372af 7ab6aed4

1.lggj合并浦东公交分支,更新部分为线路信息编辑相关

Showing 29 changed files with 2168 additions and 2336 deletions

Too many changes to show.

To preserve performance only 29 of 302 files are displayed.

@@ -34,8 +34,6 @@ @@ -34,8 +34,6 @@
34 <groupId>org.springframework.boot</groupId> 34 <groupId>org.springframework.boot</groupId>
35 <artifactId>spring-boot-starter-security</artifactId> 35 <artifactId>spring-boot-starter-security</artifactId>
36 </dependency> 36 </dependency>
37 - <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId>  
38 - </dependency> -->  
39 <dependency> 37 <dependency>
40 <groupId>org.springframework.boot</groupId> 38 <groupId>org.springframework.boot</groupId>
41 <artifactId>spring-boot-starter-data-jpa</artifactId> 39 <artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -59,6 +57,10 @@ @@ -59,6 +57,10 @@
59 <optional>true</optional> 57 <optional>true</optional>
60 </dependency> 58 </dependency>
61 <dependency> 59 <dependency>
  60 + <groupId>org.springframework.kafka</groupId>
  61 + <artifactId>spring-kafka</artifactId>
  62 + </dependency>
  63 + <dependency>
62 <groupId>mysql</groupId> 64 <groupId>mysql</groupId>
63 <artifactId>mysql-connector-java</artifactId> 65 <artifactId>mysql-connector-java</artifactId>
64 <version>5.1.38</version> 66 <version>5.1.38</version>
@@ -405,6 +407,11 @@ @@ -405,6 +407,11 @@
405 <artifactId>jts-core</artifactId> 407 <artifactId>jts-core</artifactId>
406 <version>1.16.1</version> 408 <version>1.16.1</version>
407 </dependency> 409 </dependency>
  410 +
  411 + <dependency>
  412 + <groupId>org.hibernate</groupId>
  413 + <artifactId>hibernate-spatial</artifactId>
  414 + </dependency>
408 </dependencies> 415 </dependencies>
409 416
410 <dependencyManagement> 417 <dependencyManagement>
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/common/SystemParamKeys.java 0 → 100644
  1 +package com.bsth.common;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public class SystemParamKeys {
  7 +
  8 + public static final String SPECIAL_ROLES = "special.roles";
  9 +}
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.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 map
  88 + * @throws
  89 + * @Title: list
  90 + * @Description: TODO(多条件查询)
  91 + */
  92 + @RequestMapping(value = "/findAll", method = RequestMethod.GET)
  93 + public List<T> findAll(@RequestParam Map<String, Object> map,
  94 + @RequestParam(defaultValue = "id") String order,
  95 + @RequestParam(defaultValue = "DESC") String direction) {
  96 + String[] columns = order.split(","), directions = direction.split(",");
  97 + if (columns.length != directions.length) {
  98 + throw new IllegalArgumentException("不合法的排序参数");
  99 + }
  100 +
  101 + List<Sort.Order> orders = new ArrayList<>();
  102 + for (int i = 0;i < columns.length;i++) {
  103 + String column = columns[i], direction1 = directions[i];
  104 + if ("DESC".equals(direction1)) {
  105 + orders.add(Sort.Order.desc(column));
  106 + } else if ("ASC".equals(direction1)) {
  107 + orders.add(Sort.Order.asc(column));
  108 + } else {
  109 + throw new IllegalArgumentException("不合法的排序参数");
  110 + }
  111 + }
  112 +
  113 + return baseService.findAll(map, Sort.by(orders));
  114 + }
  115 +
  116 + /**
  117 + * @param @param t
  118 + * @param @return 设定文件
  119 + * @return Map<String,Object> {status: 1(成功),-1(失败)}
  120 + * @throws
  121 + * @Title: save
  122 + * @Description: TODO(持久化对象)
  123 + */
  124 + @RequestMapping(method = RequestMethod.POST)
  125 + public Map<String, Object> save(T t) {
  126 + return baseService.save(t);
  127 + }
  128 +
  129 + /**
  130 + * @param @param id
  131 + * @throws
  132 + * @Title: findById
  133 + * @Description: TODO(根据主键获取单个对象)
  134 + */
  135 + @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  136 + public T findById(@PathVariable("id") ID id) {
  137 + return baseService.findById(id);
  138 + }
  139 +
  140 + /**
  141 + * @param @param id
  142 + * @throws
  143 + * @Title: delete
  144 + * @Description: TODO(根据主键删除对象)
  145 + */
  146 + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  147 + public Map<String, Object> delete(@PathVariable("id") ID id) {
  148 + return baseService.delete(id);
  149 + }
  150 +
  151 +}
src/main/java/com/bsth/controller/IndexController.java
1 -package com.bsth.controller;  
2 -  
3 -import java.io.BufferedInputStream;  
4 -import java.io.IOException;  
5 -import java.io.InputStream;  
6 -  
7 -import javax.servlet.http.HttpServletResponse;  
8 -  
9 -import org.apache.commons.lang3.StringUtils;  
10 -import org.slf4j.Logger;  
11 -import org.slf4j.LoggerFactory;  
12 -import org.springframework.web.bind.annotation.RequestMapping;  
13 -import org.springframework.web.bind.annotation.RestController;  
14 -  
15 -@RestController  
16 -@RequestMapping("/")  
17 -public class IndexController {  
18 -  
19 - Logger logger = LoggerFactory.getLogger(this.getClass());  
20 -  
21 - String indexSource;  
22 -  
23 - /**  
24 - * 构造函数  
25 - */  
26 - public IndexController() {  
27 - BufferedInputStream bis = null;  
28 -  
29 - try {  
30 - InputStream is = IndexController.class.getClassLoader().getResourceAsStream("static/index.html");  
31 - bis = new BufferedInputStream(is);  
32 - StringBuilder source = new StringBuilder();  
33 - byte[] buffer = new byte[bis.available()];  
34 -  
35 - while (bis.read(buffer) != -1) {  
36 - source.append(new String(buffer));  
37 - }  
38 -  
39 - indexSource = source.toString();  
40 - } catch (Exception e) {  
41 - logger.error("", e);  
42 - } finally {  
43 - try {  
44 - bis.close();  
45 - } catch (IOException e) {  
46 - logger.error("", e);  
47 - }  
48 - }  
49 - }  
50 -  
51 - /**  
52 - *  
53 - * @Title: index  
54 - * @Description: TODO(输出首页 index.html)  
55 - */  
56 - @RequestMapping  
57 - public void index(String initFragment, HttpServletResponse resp) {  
58 -  
59 - // 初始打开的片段地址  
60 - String outStr = StringUtils.replace(indexSource, "^_^initFragment^_^",  
61 - initFragment == null ? "" : initFragment);  
62 -  
63 - resp.setContentType("text/html;charset=UTF-8");  
64 - try {  
65 - resp.getOutputStream().write(outStr.getBytes());  
66 - } catch (IOException e) {  
67 - logger.error("", e);  
68 - }  
69 -  
70 - }  
71 -} 1 +package com.bsth.controller;
  2 +
  3 +import java.io.BufferedInputStream;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +
  7 +import javax.servlet.http.HttpServletResponse;
  8 +
  9 +import org.apache.commons.lang3.StringUtils;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RequestMethod;
  14 +import org.springframework.web.bind.annotation.RestController;
  15 +
  16 +@RestController
  17 +@RequestMapping("/")
  18 +public class IndexController {
  19 +
  20 + Logger logger = LoggerFactory.getLogger(this.getClass());
  21 +
  22 + String indexSource;
  23 +
  24 + /**
  25 + * 构造函数
  26 + */
  27 + public IndexController() {
  28 + load();
  29 + }
  30 +
  31 + /**
  32 + *
  33 + * @Title: index
  34 + * @Description: TODO(输出首页 index.html)
  35 + */
  36 + @RequestMapping
  37 + public void index(String initFragment, HttpServletResponse resp) {
  38 +
  39 + // 初始打开的片段地址
  40 + String outStr = StringUtils.replace(indexSource, "^_^initFragment^_^",
  41 + initFragment == null ? "" : initFragment);
  42 +
  43 + resp.setContentType("text/html;charset=UTF-8");
  44 + try {
  45 + resp.getOutputStream().write(outStr.getBytes());
  46 + } catch (IOException e) {
  47 + logger.error("", e);
  48 + }
  49 +
  50 + }
  51 +
  52 + @RequestMapping(value = "/index/load", method = RequestMethod.GET)
  53 + public void load() {
  54 + BufferedInputStream bis = null;
  55 +
  56 + try {
  57 + InputStream is = IndexController.class.getClassLoader().getResourceAsStream("static/index.html");
  58 + bis = new BufferedInputStream(is);
  59 + StringBuilder source = new StringBuilder();
  60 + byte[] buffer = new byte[bis.available()];
  61 +
  62 + while (bis.read(buffer) != -1) {
  63 + source.append(new String(buffer));
  64 + }
  65 +
  66 + indexSource = source.toString();
  67 + } catch (Exception e) {
  68 + logger.error("", e);
  69 + } finally {
  70 + try {
  71 + bis.close();
  72 + } catch (IOException e) {
  73 + logger.error("", e);
  74 + }
  75 + }
  76 + }
  77 +}
src/main/java/com/bsth/controller/InoutCarparkController.java deleted 100644 → 0
1 -package com.bsth.controller;  
2 -  
3 -import com.bsth.common.ResponseCode;  
4 -import com.bsth.entity.LsInoutSectionRoute;  
5 -import com.bsth.repository.StationRouteCacheRepository;  
6 -import com.bsth.repository.StationRouteRepository;  
7 -import com.bsth.service.InoutCarparkService;  
8 -import com.bsth.service.StationRouteService;  
9 -import com.fasterxml.jackson.core.JsonProcessingException;  
10 -import org.slf4j.Logger;  
11 -import org.slf4j.LoggerFactory;  
12 -import org.springframework.beans.factory.annotation.Autowired;  
13 -import org.springframework.util.StringUtils;  
14 -import org.springframework.web.bind.annotation.*;  
15 -  
16 -import java.util.HashMap;  
17 -import java.util.Map;  
18 -  
19 -@RestController  
20 -@RequestMapping("inout")  
21 -public class InoutCarparkController extends BaseController<LsInoutSectionRoute, Long>{  
22 -  
23 - private final static Logger logger = LoggerFactory.getLogger(InoutCarparkController.class);  
24 -  
25 - @Autowired  
26 - InoutCarparkService inoutCarparkService;  
27 -  
28 - @RequestMapping(value = "/getStartEndByLine", method = RequestMethod.GET)  
29 - public Map<String, Object> getStartEndByLine(@RequestParam("lineId")int lineId, @RequestParam("version")int version) {  
30 - return inoutCarparkService.getStartEndByLine(lineId, version);  
31 - }  
32 -  
33 - @RequestMapping(value = "/getRouteByStartEnd", method = RequestMethod.GET)  
34 - public Map<String, Object> getRouteByStartEnd(@RequestParam("lineId")int lineId, @RequestParam("version")int version, @RequestParam("start")String start, @RequestParam("end")String end) {  
35 - return inoutCarparkService.getRouteByStartEnd(lineId, version, start, end);  
36 - }  
37 -  
38 - /**  
39 - * 新增路段信息  
40 - *  
41 - * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID  
42 - *  
43 - * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;  
44 - *  
45 - * sectionrouteCode:路段序号;speedLimit:路段限速>  
46 - *  
47 - * @return map<SUCCESS:成功;ERROR:异常>  
48 - */  
49 - @RequestMapping(value="sectionSave" , method = RequestMethod.POST)  
50 - public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {  
51 - map.put("createBy", "");  
52 - map.put("updateBy", "");  
53 - return inoutCarparkService.sectionSave(map);  
54 - }  
55 -  
56 - /**  
57 - * @Description :TODO(编辑线路走向)  
58 - *  
59 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
60 - *  
61 - * @return Map<String, Object> <SUCCESS ; ERROR>  
62 - */  
63 - @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)  
64 - public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {  
65 -  
66 - map.put("updateBy", "");  
67 -  
68 - map.put("createBy", "");  
69 -  
70 - map.put("createDate", "");  
71 -  
72 - return inoutCarparkService.sectionUpdate(map);  
73 -  
74 - }  
75 -  
76 - /**  
77 - * @param id //路段路由id  
78 - * @Description: TODO(撤销路段)  
79 - */  
80 - @RequestMapping(value = "/destroy", method = RequestMethod.POST)  
81 - public Map<String, Object> destroy(@RequestParam Map<String, Object> map) {  
82 - return inoutCarparkService.destroy(map);  
83 - }  
84 -  
85 - /**  
86 - * 从历史轨迹做进场路径规划  
87 - * @Description: TODO(撤销路段)  
88 - */  
89 - @RequestMapping(value = "/pathPlaningByHistory", method = RequestMethod.POST)  
90 - public Map<String, Object> pathPlaningByHistory(@RequestParam Map<String, Object> map){  
91 - Map<String, Object> result = new HashMap<>();  
92 - result.put("status", ResponseCode.SUCCESS);  
93 - try {  
94 - String schId = (String)map.get("schId"), version = (String)map.get("version");  
95 - if (StringUtils.isEmpty(schId) || StringUtils.isEmpty(version)) {  
96 - throw new RuntimeException("无效的参数");  
97 - }  
98 - inoutCarparkService.pathPlaningByHistory(Long.parseLong(schId), Integer.parseInt(version));  
99 - } catch (Exception e) {  
100 - result.put("status", ResponseCode.ERROR);  
101 - logger.error("路径规划异常", e);  
102 - }  
103 -  
104 - return result;  
105 - }  
106 -}  
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 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.LsSectionRoute;
  5 +import com.bsth.entity.LsStationRoute;
  6 +import com.bsth.entity.SectionRoute;
  7 +import com.bsth.service.LsSectionRouteService;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.data.domain.Page;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RequestMethod;
  14 +import org.springframework.web.bind.annotation.RequestParam;
  15 +import org.springframework.web.bind.annotation.RestController;
  16 +
  17 +import java.util.Arrays;
  18 +import java.util.HashMap;
  19 +import java.util.List;
  20 +import java.util.Map;
  21 +
  22 +/**
  23 + *
  24 + * @ClassName: SectionRouteController(路段路由控制器)
  25 + *
  26 + * @Extends : BaseController
  27 + *
  28 + * @Description: TODO(路段路由控制层)
  29 + *
  30 + * @Author bsth@lq
  31 + *
  32 + * @Date 2016年05月03日 上午9:21:17
  33 + *
  34 + * @Version 公交调度系统BS版 0.1
  35 + *
  36 + */
  37 +
  38 +@RestController
  39 +@RequestMapping("/api/lssectionroute")
  40 +public class LsSectionRouteController extends BaseController<LsSectionRoute, Integer> {
  41 +
  42 + private final static Logger log = LoggerFactory.getLogger(LsSectionRouteController.class);
  43 +
  44 + @Autowired
  45 + private LsSectionRouteService lsSectionRouteService;
  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 +
  56 + /**
  57 + * @param id
  58 + * @throws
  59 + * @Description: TODO(批量撤销路段)
  60 + */
  61 + @RequestMapping(value = "/destroy", method = RequestMethod.POST)
  62 + public Map<String, Object> destroy(Integer id) {
  63 + Map<String, Object> result = new HashMap<>();
  64 + try {
  65 + lsSectionRouteService.batchDestroy(Arrays.asList(id));
  66 + result.put("status", ResponseCode.SUCCESS);
  67 + } catch (Exception e) {
  68 + result.put("status", ResponseCode.ERROR);
  69 + log.error("", e);
  70 + }
  71 +
  72 + return result;
  73 + }
  74 +
  75 + /**
  76 + * @param ids
  77 + * @throws
  78 + * @Description: TODO(批量撤销路段)
  79 + */
  80 + @RequestMapping(value = "/batchDestroy", method = RequestMethod.POST)
  81 + public Map<String, Object> batchDestroy(@RequestParam(value = "ids[]") List<Integer> ids) {
  82 + Map<String, Object> result = new HashMap<>();
  83 + try {
  84 + lsSectionRouteService.batchDestroy(ids);
  85 + result.put("status", ResponseCode.SUCCESS);
  86 + } catch (Exception e) {
  87 + result.put("status", ResponseCode.ERROR);
  88 + log.error("", e);
  89 + }
  90 +
  91 + return result;
  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 + }
  145 +}
src/main/java/com/bsth/controller/LsStationRouteController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.LsSectionRoute;
  5 +import com.bsth.entity.LsStationRoute;
  6 +import com.bsth.service.LsStationRouteService;
  7 +import com.fasterxml.jackson.databind.ObjectMapper;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.data.domain.Page;
  12 +import org.springframework.web.bind.annotation.*;
  13 +
  14 +import java.util.*;
  15 +
  16 +/**
  17 + * @author Hill
  18 + */
  19 +@RestController
  20 +@RequestMapping("/api/lsstationroute")
  21 +public class LsStationRouteController extends BaseController<LsStationRoute, Integer> {
  22 +
  23 + private static final Logger log = LoggerFactory.getLogger(LsStationRouteController.class);
  24 +
  25 + @Autowired
  26 + private LsStationRouteService lsStationRouteService;
  27 +
  28 + @Autowired
  29 + private ObjectMapper mapper;
  30 +
  31 + @RequestMapping(value = "/findAllByParams", method = RequestMethod.GET)
  32 + public Iterable<LsStationRoute> findAllByParams(@RequestParam Map<String, Object> params) {
  33 + return lsStationRouteService.findAllByParams(params);
  34 + }
  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 +
  53 + /**
  54 + * @param id
  55 + * @throws
  56 + * @Description: TODO(批量撤销站点)
  57 + */
  58 + @RequestMapping(value = "/destroy", method = RequestMethod.POST)
  59 + public Map<String, Object> destroy(Integer id) {
  60 + Map<String, Object> result = new HashMap<>();
  61 + try {
  62 + lsStationRouteService.batchDestroy(Arrays.asList(id));
  63 + result.put("status", ResponseCode.SUCCESS);
  64 + } catch (Exception e) {
  65 + result.put("status", ResponseCode.ERROR);
  66 + result.put("msg", e.getMessage());
  67 + log.error("", e);
  68 + }
  69 +
  70 + return result;
  71 + }
  72 +
  73 + /**
  74 + * @param ids
  75 + * @throws
  76 + * @Description: TODO(批量撤销站点)
  77 + */
  78 + @RequestMapping(value = "/batchDestroy", method = RequestMethod.POST)
  79 + public Map<String, Object> batchDestroy(@RequestParam(value = "ids[]") List<Integer> ids) {
  80 + Map<String, Object> result = new HashMap<>();
  81 + try {
  82 + lsStationRouteService.batchDestroy(ids);
  83 + result.put("status", ResponseCode.SUCCESS);
  84 + } catch (Exception e) {
  85 + result.put("status", ResponseCode.ERROR);
  86 + result.put("msg", e.getMessage());
  87 + log.error("", e);
  88 + }
  89 +
  90 + return result;
  91 + }
  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 +
  120 + @RequestMapping(value = "/add", method = RequestMethod.POST)
  121 + public Map<String, Object> add(LsStationRoute stationRoute) {
  122 + Map<String, Object> result = new HashMap<>();
  123 + try {
  124 + lsStationRouteService.add(stationRoute);
  125 + result.put("status", ResponseCode.SUCCESS);
  126 + } catch (Exception e) {
  127 + result.put("status", ResponseCode.ERROR);
  128 + result.put("msg", e.getMessage());
  129 + log.error("", e);
  130 + }
  131 +
  132 + return result;
  133 + }
  134 +
  135 + @RequestMapping(value = "/modify", method = RequestMethod.POST)
  136 + public Map<String, Object> modify(LsStationRoute stationRoute) {
  137 + Map<String, Object> result = new HashMap<>();
  138 + try {
  139 + lsStationRouteService.modify(stationRoute);
  140 + result.put("status", ResponseCode.SUCCESS);
  141 + } catch (Exception e) {
  142 + result.put("status", ResponseCode.ERROR);
  143 + result.put("msg", e.getMessage());
  144 + log.error("", e);
  145 + }
  146 +
  147 + return result;
  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 + }
  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 java.util.Map;  
4 - 3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.Section;
  5 +import com.bsth.entity.Station;
  6 +import com.bsth.repository.SectionRepository;
  7 +import com.bsth.service.SectionService;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
5 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.web.bind.annotation.RequestMapping; 11 import org.springframework.web.bind.annotation.RequestMapping;
7 import org.springframework.web.bind.annotation.RequestMethod; 12 import org.springframework.web.bind.annotation.RequestMethod;
8 import org.springframework.web.bind.annotation.RequestParam; 13 import org.springframework.web.bind.annotation.RequestParam;
9 import org.springframework.web.bind.annotation.RestController; 14 import org.springframework.web.bind.annotation.RestController;
10 15
11 -import com.bsth.entity.Section;  
12 -import com.bsth.repository.SectionRepository;  
13 -import com.bsth.service.SectionService;  
14 -import com.bsth.util.GetUIDAndCode; 16 +import javax.servlet.http.HttpServletRequest;
  17 +import java.util.HashMap;
  18 +import java.util.List;
  19 +import java.util.Map;
15 20
16 /** 21 /**
17 * 22 *
@@ -32,113 +37,23 @@ import com.bsth.util.GetUIDAndCode; @@ -32,113 +37,23 @@ import com.bsth.util.GetUIDAndCode;
32 @RestController 37 @RestController
33 @RequestMapping("section") 38 @RequestMapping("section")
34 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);
35 42
36 @Autowired 43 @Autowired
37 - SectionService service; 44 + SectionService sectionService;
38 45
39 @Autowired 46 @Autowired
40 SectionRepository sectionRepository; 47 SectionRepository sectionRepository;
41 -  
42 - /**  
43 - * 新增路段信息  
44 - *  
45 - * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID  
46 - *  
47 - * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;  
48 - *  
49 - * sectionrouteCode:路段序号;speedLimit:路段限速>  
50 - *  
51 - * @return map<SUCCESS:成功;ERROR:异常>  
52 - */  
53 - @RequestMapping(value="sectionSave" , method = RequestMethod.POST)  
54 - public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {  
55 - map.put("createBy", "");  
56 - map.put("updateBy", "");  
57 - return service.sectionSave(map);  
58 - }  
59 -  
60 - /**  
61 - * @Description :TODO(编辑线路走向)  
62 - *  
63 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
64 - *  
65 - * @return Map<String, Object> <SUCCESS ; ERROR>  
66 - */  
67 - @RequestMapping(value="sectionCut" , method = RequestMethod.POST)  
68 - public Map<String, Object> sectionCut(@RequestParam Map<String, Object> map) {  
69 -  
70 - map.put("updateBy", "");  
71 -  
72 - map.put("createBy", "");  
73 -  
74 - map.put("createDate", "");  
75 -  
76 - return service.sectionCut(map);  
77 -  
78 - }  
79 -  
80 - /**  
81 - * @Description :TODO(编辑线路走向保存到线路历史表)  
82 - *  
83 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
84 - *  
85 - * @return Map<String, Object> <SUCCESS ; ERROR>  
86 - */  
87 - @RequestMapping(value="sectionCutSaveLineLS" , method = RequestMethod.POST)  
88 - public Map<String, Object> sectionCutSaveLineLS(@RequestParam Map<String, Object> map) {  
89 -  
90 - map.put("updateBy", "");  
91 -  
92 - map.put("createBy", "");  
93 -  
94 - return service.sectionCutSaveLineLS(map);  
95 -  
96 - }  
97 -  
98 - /**  
99 - * @Description :TODO(编辑线路走向)  
100 - *  
101 - * @param map <sectionId:路段ID; sectionJSON:路段信息>  
102 - *  
103 - * @return Map<String, Object> <SUCCESS ; ERROR>  
104 - */  
105 - @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)  
106 - public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {  
107 -  
108 - map.put("updateBy", "");  
109 -  
110 - map.put("createBy", "");  
111 -  
112 - map.put("createDate", "");  
113 -  
114 - return service.sectionUpdate(map);  
115 -  
116 - }  
117 -  
118 - /**  
119 - * @Description :TODO(编辑缓存线路走向)  
120 - */  
121 - @RequestMapping(value="sectionCacheUpdate" , method = RequestMethod.POST)  
122 - public Map<String, Object> sectionCacheUpdate(@RequestParam Map<String, Object> map) {  
123 -  
124 - map.put("updateBy", "");  
125 -  
126 - map.put("createBy", "");  
127 -  
128 - map.put("createDate", "");  
129 -  
130 - return service.sectionCacheUpdate(map);  
131 -  
132 - }  
133 - 48 +
134 /** 49 /**
135 * @Description :TODO(查询路段编码) 50 * @Description :TODO(查询路段编码)
136 * 51 *
137 * @return int <sectionCode路段编码> 52 * @return int <sectionCode路段编码>
138 */ 53 */
139 - @RequestMapping(value="getSectionCode" , method = RequestMethod.GET) 54 + @RequestMapping(value="getSectionCode", method = RequestMethod.GET)
140 public long getSectionCode() { 55 public long getSectionCode() {
141 - return sectionRepository.sectionMaxId() + 1; 56 + return sectionRepository.findLatestSectionId() + 1;
142 } 57 }
143 58
144 /** 59 /**
@@ -146,9 +61,69 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; { @@ -146,9 +61,69 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; {
146 * 61 *
147 * @return int <sectionCode路段编码> 62 * @return int <sectionCode路段编码>
148 */ 63 */
149 - @RequestMapping(value="doubleName" , method = RequestMethod.POST) 64 + @RequestMapping(value="doubleName", method = RequestMethod.POST)
150 public Map<String, Object> doubleName(@RequestParam Map<String, Object> map) { 65 public Map<String, Object> doubleName(@RequestParam Map<String, Object> map) {
151 - return service.doubleName(map); 66 + return sectionService.doubleName(map);
152 } 67 }
153 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;
  81 + }
  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 + @RequestMapping(value="findDistinctSectionName", method = RequestMethod.GET)
  98 + public Map<String, Object> findDistinctSectionName() {
  99 + Map<String, Object> result = new HashMap<>();
  100 + try {
  101 + result.put("data", sectionService.findDistinctSectionName());
  102 + result.put("status", ResponseCode.SUCCESS);
  103 + } catch (Exception e) {
  104 + result.put("status", ResponseCode.ERROR);
  105 + log.error("", e);
  106 + }
  107 +
  108 + return result;
  109 + }
  110 +
  111 + /**
  112 + * 根据路段名搜索路段信息
  113 + * @param sectionName
  114 + * @return 站点列表
  115 + */
  116 + @RequestMapping(value="findSectionByName" , method = RequestMethod.GET)
  117 + public Map<String, Object> findSectionByName(String sectionName) {
  118 + Map<String, Object> result = new HashMap<>();
  119 + try {
  120 + result.put("data", sectionService.findSectionByName(sectionName));
  121 + result.put("status", ResponseCode.SUCCESS);
  122 + } catch (Exception e) {
  123 + result.put("status", ResponseCode.ERROR);
  124 + log.error("", e);
  125 + }
  126 +
  127 + return result;
  128 + }
154 } 129 }
src/main/java/com/bsth/controller/SectionRouteController.java
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.SectionRoute;  
13 -import com.bsth.entity.StationRouteCache;  
14 -import com.bsth.service.SectionRouteService;  
15 -  
16 -/**  
17 - *  
18 - * @ClassName: SectionRouteController(路段路由控制器)  
19 - *  
20 - * @Extends : BaseController  
21 - *  
22 - * @Description: TODO(路段路由控制层)  
23 - *  
24 - * @Author bsth@lq  
25 - *  
26 - * @Date 2016年05月03日 上午9:21:17  
27 - *  
28 - * @Version 公交调度系统BS版 0.1  
29 - *  
30 - */  
31 -  
32 -@RestController  
33 -@RequestMapping("sectionroute")  
34 -public class SectionRouteController extends BaseController<SectionRoute, Integer> {  
35 -  
36 - @Autowired  
37 - SectionRouteService routeService;  
38 -  
39 - @RequestMapping(value = "/allls", method = RequestMethod.GET)  
40 - public Map allls(@RequestParam Map<String, Object> map) {  
41 -  
42 - return routeService.pageLs(map);  
43 - }  
44 -  
45 -  
46 - /**  
47 - * @param map  
48 - * @throws  
49 - * @Description: TODO(批量撤销路段)  
50 - */  
51 - @RequestMapping(value = "/batchDestroy", method = RequestMethod.POST)  
52 - public Map<String, Object> updateBatch(@RequestParam Map<String, Object> map) {  
53 - return routeService.updateSectionRouteInfoFormId(map);  
54 - }  
55 - /**  
56 - * @param id //路段路由id  
57 - * @Description: TODO(撤销路段)  
58 - */  
59 - @RequestMapping(value = "/destroy", method = RequestMethod.POST)  
60 - public Map<String, Object> destroy(@RequestParam Map<String, Object> map) {  
61 -  
62 - int id = Integer.parseInt(map.get("id").toString());  
63 -  
64 - if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) {  
65 - return routeService.destroy(id);  
66 - }else if(Integer.parseInt(map.get("status").toString()) == 2){  
67 - return routeService.destroyHistory(id);  
68 - }else {  
69 - return map;  
70 - }  
71 - }  
72 -  
73 - /**  
74 - * @param @param map  
75 - * @throws  
76 - * @Title: list  
77 - * @Description: TODO(多条件查询)  
78 - */  
79 - @RequestMapping(value = "/all", method = RequestMethod.GET)  
80 - public Iterable<SectionRoute> list(@RequestParam Map<String, Object> map) {  
81 - return routeService.list(map);  
82 - }  
83 -  
84 - @RequestMapping(value = "/cacheList", method = RequestMethod.GET)  
85 - public List<StationRouteCache> cacheList(@RequestParam Map<String, Object> map) {  
86 -// routeService.cacheList(map)  
87 - return null;  
88 - }  
89 -  
90 - /**  
91 - * @Description :TODO(查询路段信息)  
92 - *  
93 - * @param map <line.id_eq:线路ID; directions_eq:方向>  
94 - *  
95 - * @return Map<String, Object>  
96 - */  
97 - @RequestMapping(value = "/findSection" , method = RequestMethod.GET)  
98 - public List<Map<String, Object>> findPoints(@RequestParam Map<String, Object> map) {  
99 - return routeService.getSectionRoute(map);  
100 - }  
101 -  
102 -  
103 - /**  
104 - * @Description :TODO(查询路段信息)  
105 - *  
106 - * @param map <line.id_eq:线路ID; directions_eq:方向>  
107 - *  
108 - * @return Map<String, Object>  
109 - */  
110 - @RequestMapping(value = "/findCacheSection" , method = RequestMethod.GET)  
111 - public List<Map<String, Object>> getSectionRouteCache(@RequestParam Map<String, Object> map) {  
112 - return routeService.getSectionRouteCache(map);  
113 - }  
114 -  
115 - /**  
116 - * @Description : TODO(根据路段路由Id查询详情)  
117 - *  
118 - * @param map <id:路段路由ID>  
119 - *  
120 - * @return List<Map<String, Object>>  
121 - */  
122 - @RequestMapping(value = "/findSectionRouteInfoFormId",method = RequestMethod.GET)  
123 - public List<Map<String, Object>> findSectionRouteInfoFormId(@RequestParam Map<String, Object> map) {  
124 - return routeService.findSectionRouteInfoFormId(map);  
125 - }  
126 -  
127 - /**  
128 - * @Description :TODO(查询线路某方向下的上一个路段序号)  
129 - *  
130 - * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码>  
131 - *  
132 - * @return List<Map<String, Object>>  
133 - */  
134 - @RequestMapping(value = "/findUpSectionRouteCode" , method = RequestMethod.GET)  
135 - public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {  
136 - return routeService.findUpSectionRouteCode(map);  
137 - }  
138 -  
139 - @RequestMapping(value = "/findCacheUpSectionRouteCode" , method = RequestMethod.GET)  
140 - public List<Map<String, Object>> findCacheUpSectionRouteCode(@RequestParam Map<String, Object> map) {  
141 - return routeService.findCacheUpSectionRouteCode(map);  
142 - }  
143 -  
144 - /**  
145 - * @Description :TODO(引用路段)  
146 - *  
147 - * @return List<Map<String, Object>>  
148 - */  
149 - @RequestMapping(value = "/quoteSection" , method = RequestMethod.POST)  
150 - public Map<String, Object> quoteSection(@RequestParam Map<String, Object> map) {  
151 - return routeService.quoteSection(map);  
152 - }  
153 -} 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.SectionRoute;
  13 +import com.bsth.service.SectionRouteService;
  14 +
  15 +/**
  16 + *
  17 + * @ClassName: SectionRouteController(路段路由控制器)
  18 + *
  19 + * @Extends : BaseController
  20 + *
  21 + * @Description: TODO(路段路由控制层)
  22 + *
  23 + * @Author bsth@lq
  24 + *
  25 + * @Date 2016年05月03日 上午9:21:17
  26 + *
  27 + * @Version 公交调度系统BS版 0.1
  28 + *
  29 + */
  30 +
  31 +@RestController
  32 +@RequestMapping("sectionroute")
  33 +public class SectionRouteController extends BaseController<SectionRoute, Integer> {
  34 +
  35 + @Autowired
  36 + SectionRouteService routeService;
  37 +
  38 + /**
  39 + * @param @param map
  40 + * @throws
  41 + * @Title: list
  42 + * @Description: TODO(多条件查询)
  43 + */
  44 + @RequestMapping(value = "/all", method = RequestMethod.GET)
  45 + public Iterable<SectionRoute> list(@RequestParam Map<String, Object> map) {
  46 + return routeService.list(map);
  47 + }
  48 +
  49 + /**
  50 + * @Description :TODO(查询路段信息)
  51 + *
  52 + * @param map <line.id_eq:线路ID; directions_eq:方向>
  53 + *
  54 + * @return Map<String, Object>
  55 + */
  56 + @RequestMapping(value = "/findSection" , method = RequestMethod.GET)
  57 + public List<Map<String, Object>> findPoints(@RequestParam Map<String, Object> map) {
  58 + return routeService.getSectionRoute(map);
  59 + }
  60 +
  61 + /**
  62 + * @Description :TODO(查询线路某方向下的上一个路段序号)
  63 + *
  64 + * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码>
  65 + *
  66 + * @return List<Map<String, Object>>
  67 + */
  68 + @RequestMapping(value = "/findUpSectionRouteCode" , method = RequestMethod.GET)
  69 + public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {
  70 + return routeService.findUpSectionRouteCode(map);
  71 + }
  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;
  4 +import com.bsth.entity.LsSectionRoute;
  5 +import com.bsth.entity.LsStationRoute;
3 import com.bsth.entity.Station; 6 import com.bsth.entity.Station;
4 import com.bsth.repository.StationRepository; 7 import com.bsth.repository.StationRepository;
5 import com.bsth.service.StationService; 8 import com.bsth.service.StationService;
6 -import com.bsth.util.GetUIDAndCode; 9 +import com.fasterxml.jackson.databind.ObjectMapper;
7 import org.slf4j.Logger; 10 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 12 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; 13 +import org.springframework.web.bind.annotation.*;
14 14
  15 +import java.util.HashMap;
  16 +import java.util.List;
15 import java.util.Map; 17 import java.util.Map;
16 18
17 /** 19 /**
@@ -35,162 +37,88 @@ import java.util.Map; @@ -35,162 +37,88 @@ import java.util.Map;
35 public class StationController extends BaseController<Station, Integer> { 37 public class StationController extends BaseController<Station, Integer> {
36 38
37 @Autowired 39 @Autowired
38 - private StationService service; 40 + private StationService stationService;
39 41
40 @Autowired 42 @Autowired
41 - StationRepository stationRepository; 43 + private ObjectMapper mapper;
42 44
43 /** 日志记录器 */ 45 /** 日志记录器 */
44 - private static final Logger LOGGER = LoggerFactory.getLogger(StationController.class); 46 + private static final Logger log = LoggerFactory.getLogger(StationController.class);
45 47
46 /** 48 /**
47 * @Description :TODO(根据坐标点匹配数据库中的站点) 49 * @Description :TODO(根据坐标点匹配数据库中的站点)
48 - *  
49 - * @param map: <point:坐标点; name:站点名>  
50 - *  
51 */ 50 */
52 - @RequestMapping(value="matchStation" , method = RequestMethod.GET)  
53 - public Map<String, Object> matchStation(@RequestParam Map<String, Object> map) {  
54 - return service.matchStation(map);  
55 - }  
56 -  
57 - /**  
58 - * @Description :TODO(系统规划保存数据)  
59 - *  
60 - * @param map <stationJSON:站点信息;  
61 - *  
62 - * - - - - - - sectionJSON:路段信息;  
63 - *  
64 - * - - - - - - dbType:坐标类型;  
65 - *  
66 - * - - - - - - destroy:是否撤销;  
67 - *  
68 - * - - - - - - directions:方向;  
69 - *  
70 - * - - - - - - lineId:线路ID;  
71 - *  
72 - * - - - - - - radius:圆半径  
73 - *  
74 - * - - - - - - shapesType:图形类型  
75 - *  
76 - * - - - - - - speedLimit:限速>  
77 - *  
78 - * @return Map<String, Object> <SUCCESS ; ERROR>  
79 - */  
80 - @RequestMapping(value="collectionSave" , method = RequestMethod.POST)  
81 - public Map<String, Object> collectionSave(@RequestParam Map<String, Object> map) {  
82 - return service.systemSaveStations(map);  
83 - }  
84 -  
85 - @RequestMapping(value="manualSave" , method = RequestMethod.POST)  
86 - public Map<String, Object> manualSave(@RequestParam Map<String, Object> map) {  
87 - return service.manualSave(map);  
88 - }  
89 -  
90 - @RequestMapping(value="cacheSave" , method = RequestMethod.POST)  
91 - public Map<String, Object> cacheSave(@RequestParam Map<String, Object> map) {  
92 - return service.cacheSave(map);  
93 - }  
94 -  
95 - /**  
96 - * @Description :TODO(新增站点保存)  
97 - *  
98 - * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;  
99 - *  
100 - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;  
101 - *  
102 - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;  
103 - *  
104 - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间  
105 - *  
106 - * versions:版本号;x:城建坐标x;y:城建坐标y>  
107 - *  
108 - * @return Map<String, Object> <SUCCESS ; ERROR>  
109 - */  
110 - @RequestMapping(value="stationSave" , method = RequestMethod.POST)  
111 - public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) {  
112 - map.put("createBy", "");  
113 - map.put("updateBy", "");  
114 - return service.stationSaveMap(map);  
115 - }  
116 -  
117 - /**  
118 - * @Description :TODO(更新站点保存)  
119 - *  
120 - * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;  
121 - *  
122 - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;  
123 - *  
124 - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;  
125 - *  
126 - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间  
127 - *  
128 - * versions:版本号;x:城建坐标x;y:城建坐标y>  
129 - *  
130 - * @return Map<String, Object> <SUCCESS ; ERROR>  
131 - */  
132 - @RequestMapping(value="stationUpdate" , method = RequestMethod.POST)  
133 - public Map<String, Object> stationUpdate(@RequestParam Map<String, Object> map) {  
134 - map.put("updateBy", ""); //??  
135 - return service.stationUpdate(map); 51 + @RequestMapping(value="matchStation")
  52 + public Map<String, Object> matchStation(@RequestBody List<Station> stations) {
  53 + Map<String, Object> result = new HashMap<>();
  54 + try {
  55 + stationService.matchStation(stations);
  56 + result.put("status", ResponseCode.SUCCESS);
  57 + result.put("data", stations);
  58 + } catch (Exception e) {
  59 + result.put("status", ResponseCode.ERROR);
  60 + log.error("", e);
  61 + }
  62 +
  63 + return result;
136 } 64 }
137 - 65 +
138 /** 66 /**
139 - * @Description :TODO(更新缓存站点保存)  
140 - *  
141 - * @param map <bJwpoints:中心点百度坐标;bPolygonGrid:多边形图形百度坐标;dbType:原坐标类型;  
142 - *  
143 - * descriptions:说明;destroy:是否撤销;directions:方向;distances:到站距离;gJwpoints:中心点WGS坐标;  
144 - *  
145 - * gPolygonGrid:多边形图形WGS坐标;lineId:线路ID;radius:圆半径;roadCoding:道路编码;shapesType:图形类型;  
146 - *  
147 - * stationCod:站点编码;stationMark:站点类型;stationName:站点名称;stationRouteCode:站点序号;toTime:到站时间  
148 - *  
149 - * versions:版本号;x:城建坐标x;y:城建坐标y>  
150 - *  
151 - * @return Map<String, Object> <SUCCESS ; ERROR> 67 + * 新增站点
  68 + * @param station
  69 + * @return
152 */ 70 */
153 - @RequestMapping(value="stationCacheUpdate" , method = RequestMethod.POST)  
154 - public Map<String, Object> stationCacheUpdate(@RequestParam Map<String, Object> map) {  
155 - map.put("updateBy", "");  
156 - return service.stationCacheUpdate(map); 71 + @RequestMapping(value = "/add", method = RequestMethod.POST)
  72 + public Map<String, Object> add(Station station) {
  73 + Map<String, Object> result = new HashMap<>();
  74 + try {
  75 + stationService.add(station);
  76 + result.put("status", ResponseCode.SUCCESS);
  77 + } catch (Exception e) {
  78 + result.put("status", ResponseCode.ERROR);
  79 + result.put("msg", e.getMessage());
  80 + log.error("", e);
  81 + }
  82 +
  83 + return result;
157 } 84 }
  85 +
158 /** 86 /**
159 - * @Description :TODO(更新内部编码)  
160 - * @param stationCount,sectionCount 更新数 87 + * 更新站点、站点路由信息
  88 + * @param station
  89 + * @return
161 */ 90 */
162 - @RequestMapping(value="updateStationAndSectionCode" , method = RequestMethod.GET)  
163 - public int updateStationAndSectionCode(@RequestParam Integer stationCount, Integer sectionCount) {  
164 -// System.out.println(stationCount+" _ "+ sectionCount );  
165 -// for(int i = 0; i < stationCount; i++) {  
166 -//// System.out.println(i);  
167 -// stationRepository.stationMaxId() + 1;  
168 -// }  
169 -// for(int j = 0; j < sectionCount; j++) {  
170 -//// System.out.println(j);  
171 -// sectionRepository.sectionMaxId() + 1;  
172 -// }  
173 - return 1; 91 + @RequestMapping(value="modify" , method = RequestMethod.POST)
  92 + public Map<String, Object> modify(Station station) {
  93 + Map<String, Object> result = new HashMap<>();
  94 + try {
  95 + stationService.modify(station);
  96 + result.put("status", ResponseCode.SUCCESS);
  97 + } catch (Exception e) {
  98 + result.put("status", ResponseCode.ERROR);
  99 + throw new RuntimeException(e);
  100 + }
  101 +
  102 + return result;
174 } 103 }
  104 +
175 /** 105 /**
176 * @Description :TODO(查询站点编码) 106 * @Description :TODO(查询站点编码)
177 * 107 *
178 * @return int <stationCode站点编码> 108 * @return int <stationCode站点编码>
179 */ 109 */
180 - @RequestMapping(value="getStationCode" , method = RequestMethod.GET)  
181 - public long getStationCode() {  
182 - return stationRepository.stationMaxId() + 1;  
183 - 110 + @RequestMapping(value="findStationCode" , method = RequestMethod.GET)
  111 + public long findStationCode() {
  112 + return stationService.findLatestStationId() + 1;
184 } 113 }
  114 +
185 /** 115 /**
186 - * @Description :TODO(查询站点编码)  
187 - *  
188 - * @return int <stationCode站点编码> 116 + * 根据站名模糊搜索站点信息
  117 + * @param stationName
  118 + * @return 站点列表
189 */ 119 */
190 - @RequestMapping(value="stationCacheSave" , method = RequestMethod.POST)  
191 - public Map<String, Object> stationCacheSave(@RequestParam Map<String, Object> map) {  
192 - map.put("createBy", "");  
193 - map.put("updateBy", "");  
194 - return service.stationCacheSave(map); 120 + @RequestMapping(value="findStationByName" , method = RequestMethod.GET)
  121 + public List<Station> findStationByName(String stationName) {
  122 + return stationService.findStationByName(stationName);
195 } 123 }
196 } 124 }
src/main/java/com/bsth/controller/StationRouteController.java
1 -package com.bsth.controller;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import javax.servlet.http.HttpServletResponse;  
7 -  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.web.bind.annotation.RequestMapping;  
10 -import org.springframework.web.bind.annotation.RequestMethod;  
11 -import org.springframework.web.bind.annotation.RequestParam;  
12 -import org.springframework.web.bind.annotation.RestController;  
13 -  
14 -import com.bsth.entity.LsStationRoute;  
15 -import com.bsth.entity.StationRoute;  
16 -import com.bsth.entity.StationRouteCache;  
17 -import com.bsth.repository.StationRouteCacheRepository;  
18 -import com.bsth.repository.StationRouteRepository;  
19 -import com.bsth.service.StationRouteService;  
20 -  
21 -/**  
22 - *  
23 - * @ClassName: StationRouteController(站点路由控制器)  
24 - *  
25 - * @Extends : BaseController  
26 - *  
27 - * @Description: TODO(站点路由控制层)  
28 - *  
29 - * @Author bsth@lq  
30 - *  
31 - * @Date 2016年5月03日 上午9:21:17  
32 - *  
33 - * @Dersion 公交调度系统BS版 0.1  
34 - *  
35 - */  
36 -@RestController  
37 -@RequestMapping("stationroute")  
38 -public class StationRouteController extends BaseController<StationRoute, Integer> {  
39 -  
40 - @Autowired  
41 - StationRouteService service;  
42 - @Autowired  
43 - StationRouteRepository stationRouteRepository;  
44 - @Autowired  
45 - StationRouteCacheRepository stationRouteCacheRepository;  
46 -  
47 -  
48 - @RequestMapping(value = "/allls", method = RequestMethod.GET)  
49 - public Map allls(@RequestParam Map<String, Object> map) {  
50 -  
51 - return service.pageLs(map);  
52 - }  
53 -  
54 - @RequestMapping(value = "/all_ls", method = RequestMethod.GET)  
55 - public Iterable<LsStationRoute> list_ls(@RequestParam Map<String, Object> map) {  
56 - return service.list_ls(map);  
57 - }  
58 -  
59 -  
60 - @RequestMapping(value = "/all", method = RequestMethod.GET)  
61 - public Iterable<StationRoute> list(@RequestParam Map<String, Object> map) {  
62 - return service.list(map);  
63 - }  
64 -  
65 - @RequestMapping(value = "/cacheList", method = RequestMethod.GET)  
66 - public List<StationRouteCache> cacheList(@RequestParam Map<String, Object> map) {  
67 - return service.cacheList(map);  
68 - }  
69 -  
70 - /**  
71 - * @Description :TODO(查询路段信息)  
72 - *  
73 - * @param id  
74 - *  
75 - * @return Map<String, Object>  
76 - */  
77 - @RequestMapping(value = "/export" , method = RequestMethod.GET)  
78 - public Map<String, Object> export(@RequestParam Integer id, HttpServletResponse resp) {  
79 - return service.getSectionRouteExport(id, resp);  
80 - }  
81 -  
82 - /**  
83 - * @param map  
84 - * @throws  
85 - * @Description: TODO(批量撤销站点)  
86 - */  
87 - @RequestMapping(value = "/batchDestroy", method = RequestMethod.POST)  
88 - public Map<String, Object> updateBatch(@RequestParam Map<String, Object> map) {  
89 - return service.updateStationRouteInfoFormId(map);  
90 - }  
91 -  
92 - /**  
93 - * @Description :TODO(查询树站点与路段数据)  
94 - *  
95 - * @param map <line.id_eq:线路ID; directions_eq:方向>  
96 - *  
97 - * @return List<Map<String, Object>>  
98 - */  
99 - @RequestMapping(value = "/findStations" , method = RequestMethod.GET)  
100 - public List<Map<String, Object>> findStations(@RequestParam Map<String, Object> map) {  
101 - return service.findPoints(map);  
102 - }  
103 -  
104 - @RequestMapping(value = "/systemQuote" , method = RequestMethod.POST)  
105 - public Map<String, Object> systemQuote(@RequestParam Map<String, Object> map) {  
106 - return service.systemQuote(map);  
107 - }  
108 -  
109 - /**  
110 - * @Description :TODO(查询线路某方向下的站点序号与类型)  
111 - *  
112 - * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>  
113 - *  
114 - * @return List<Map<String, Object>>  
115 - */  
116 - @RequestMapping(value = "/findUpStationRouteCode" , method = RequestMethod.GET)  
117 - public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {  
118 - return service.findUpStationRouteCode(map);  
119 - }  
120 -  
121 - /**  
122 - * @Description :TODO(查询线路某方向下的站点序号与类型)  
123 - */  
124 - @RequestMapping(value = "/findCacheUpStationRouteCode" , method = RequestMethod.GET)  
125 - public List<Map<String, Object>> findCacheUpStationRouteCode(@RequestParam Map<String, Object> map) {  
126 - return service.findCacheUpStationRouteCode(map);  
127 - }  
128 -  
129 - /**  
130 - * @Description :TODO(查询站点的下一个缓存站点)  
131 - */  
132 - @RequestMapping(value = "/findDownStationRoute" , method = RequestMethod.GET)  
133 - public List<Map<String, Object>> findDownStationRoute(@RequestParam Map<String, Object> map) {  
134 - return service.findDownStationRoute(map);  
135 - }  
136 -  
137 - /**  
138 - * @Description :TODO(查询线路某方向下所有站点的中心百度坐标)  
139 - *  
140 - * @param map <lineId:线路ID; direction:方向>  
141 - *  
142 - * @return List<Map<String, Object>>  
143 - */  
144 - @RequestMapping(value = "/getStationRouteCenterPoints" , method = RequestMethod.GET)  
145 - public List<Map<String, Object>> getStationRouteCenterPoints(@RequestParam Map<String, Object> map) {  
146 - return service.getStationRouteCenterPoints(map);  
147 - }  
148 -  
149 - /**  
150 - * @Description :TODO(查询线路某方向下所有站点)  
151 - *  
152 - * @param map <lineId:线路ID; direction:方向>  
153 - *  
154 - * @return List<Map<String, Object>>  
155 - */  
156 - @RequestMapping(value = "/getStationRouteList" , method = RequestMethod.GET)  
157 - public List<Map<String, Object>> getStationRouteList(@RequestParam Map<String, Object> map) {  
158 - return service.getStationRouteList(map);  
159 - }  
160 -  
161 - /**  
162 - * @Description :TODO(查询线路某方向下所有站点的中心百度坐标)  
163 - *  
164 - * @param map <lineId:线路ID; direction:方向>  
165 - *  
166 - * @return List<Map<String, Object>>  
167 - */  
168 - @RequestMapping(value = "/getStationRouteCacheCenterPoints" , method = RequestMethod.GET)  
169 - public List<Map<String, Object>> getStationRouteCacheCenterPoints(@RequestParam Map<String, Object> map) {  
170 - return service.getStationRouteCacheCenterPoints(map);  
171 - }  
172 -  
173 - /**  
174 - * @Description :TODO(撤销站点)  
175 - *  
176 - * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)>  
177 - *  
178 - * @return Map<String, Object> <SUCCESS ; ERROR>  
179 - */  
180 - @RequestMapping(value = "/stationRouteIsDestroy" , method = RequestMethod.POST)  
181 - public Map<String, Object> stationRouteIsDestroy(@RequestParam Map<String, Object> map) {  
182 - return service.stationRouteIsDestroy(map);  
183 - }  
184 -  
185 - /**  
186 - * @Description : TODO(根据线路ID生成行单)  
187 - *  
188 - * @param map <id:线路ID>  
189 - *  
190 - * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA>  
191 - */  
192 - @RequestMapping(value = "/usingSingle",method = RequestMethod.POST)  
193 - public Map<String, Object> usingSingle(@RequestParam Map<String, Object> map) {  
194 - return service.usingSingle(map);  
195 - }  
196 -  
197 -  
198 - /**  
199 - * @Description : TODO(根据站点路由Id查询详情)  
200 - *  
201 - * @param map <id:站点路由ID>  
202 - *  
203 - * @return List<Map<String, Object>>  
204 - */  
205 - @RequestMapping(value = "/findStationRouteInfo",method = RequestMethod.GET)  
206 - public List<Map<String, Object>> findStationRouteInfo(@RequestParam Map<String, Object> map) {  
207 - return service.findStationRouteInfo(map);  
208 - }  
209 -  
210 - @RequestMapping(value = "/stations", method = RequestMethod.GET)  
211 - public List<Map<String, Object>> findStations(Integer xlid, Integer xldir) {  
212 - return stationRouteRepository.findStations(xlid, xldir);  
213 - }  
214 -  
215 - /**  
216 - *  
217 - * @Title: findByMultiLine  
218 - * @Description: TODO(多线路路由查询)  
219 - */  
220 - @RequestMapping(value = "/multiLine", method = RequestMethod.GET)  
221 - public Map<String, Object> findByMultiLine(@RequestParam String lineIds){  
222 - return service.findByMultiLine(lineIds);  
223 - }  
224 -  
225 - /**  
226 - *  
227 - * @Title: updSwitchDir  
228 - * @Description: TODO(上下行切换)  
229 - */  
230 - @RequestMapping(value = "/updSwitchDir", method = RequestMethod.POST)  
231 - public Map<String, Object> updSwitchDir(@RequestParam String lineIds, @RequestParam(value = "status", required = false)int status){  
232 - return service.updSwitchDir(lineIds,status);  
233 - }  
234 -  
235 - /**  
236 - *  
237 - * @Title: upddis  
238 - * @Description: TODO(更新站距)  
239 - */  
240 - @RequestMapping(value = "/upddis",method = RequestMethod.POST)  
241 - public Map<String, Object> upddis(@RequestParam Map<String, Object> map) {  
242 - return service.upddis(map);  
243 - }  
244 -  
245 - /**  
246 - *  
247 - * @Title: findCacheStationRoute  
248 - * @Description: TODO(查询缓存路由)  
249 - */  
250 - @RequestMapping(value = "/findCacheStationRoute",method = RequestMethod.GET)  
251 - public List<StationRouteCache> findCacheStationRoute(@RequestParam Map<String, Object> map) {  
252 - int lineId = Integer.parseInt(map.get("lineId").toString());  
253 - int dir = Integer.parseInt(map.get("dir").toString());  
254 - return stationRouteCacheRepository.findstationRoute(lineId, dir);  
255 - }  
256 -  
257 - /**  
258 - *  
259 - * @Title: findCachePoint  
260 - *  
261 - * @param map <lineId:线路ID; dir:方向>  
262 - *  
263 - * @Description: TODO(查询缓存路由)  
264 - */  
265 - @RequestMapping(value = "/findCachePoint",method = RequestMethod.GET)  
266 - public List<Map<String, Object>> findCachePoint(@RequestParam Map<String, Object> map) {  
267 - int lineId = Integer.parseInt(map.get("lineId").toString());  
268 - int dir = Integer.parseInt(map.get("dir").toString());  
269 - return service.findCachePoint(lineId, dir);  
270 - }  
271 -  
272 -  
273 - /**  
274 - * 查询博协站点  
275 - * @param map  
276 - * @return  
277 - */  
278 - @RequestMapping(value = "/findMatchStation", method = RequestMethod.GET)  
279 - public Map<String, Object> findMatchStation(@RequestParam Map<String, Object> map){  
280 - return service.findMatchStation(map);  
281 - }  
282 -  
283 - /**  
284 - * 批量修改行业编码  
285 - * @param map  
286 - * @return  
287 - */  
288 - @RequestMapping(value = "/updIndustryCode",method = RequestMethod.POST)  
289 - public Map<String, Object> updIndustryCode(@RequestParam Map<String, Object> map) {  
290 - return service.updIndustryCode(map);  
291 - }  
292 -  
293 - /**  
294 - * 匹配外部站点行业编码  
295 - * @param map  
296 - * @return  
297 - */  
298 - @RequestMapping(value = "/matchIndustryCode",method = RequestMethod.POST)  
299 - public Map<String, Object> matchIndustryCode(@RequestParam Map<String, Object> map) {  
300 - return service.matchIndustryCode(map);  
301 - }  
302 - /**  
303 - * 匹配附近站点行业编码  
304 - * @param map  
305 - * @return  
306 - */  
307 - @RequestMapping(value = "/matchNearbyStation",method = RequestMethod.GET)  
308 - public Map<String, Object> matchNearbyStation(@RequestParam Map<String, Object> map) {  
309 - return service.matchNearbyStation(map);  
310 - }  
311 -} 1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.entity.LsStationRoute;
  4 +import com.bsth.entity.StationRoute;
  5 +import com.bsth.repository.StationRouteRepository;
  6 +import com.bsth.service.StationRouteService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestMethod;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import javax.servlet.http.HttpServletResponse;
  14 +import java.util.List;
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + *
  19 + * @ClassName: StationRouteController(站点路由控制器)
  20 + *
  21 + * @Extends : BaseController
  22 + *
  23 + * @Description: TODO(站点路由控制层)
  24 + *
  25 + * @Author bsth@lq
  26 + *
  27 + * @Date 2016年5月03日 上午9:21:17
  28 + *
  29 + * @Dersion 公交调度系统BS版 0.1
  30 + *
  31 + */
  32 +@RestController
  33 +@RequestMapping("stationroute")
  34 +public class StationRouteController extends BaseController<StationRoute, Integer> {
  35 +
  36 + @Autowired
  37 + StationRouteService stationRouteService;
  38 + @Autowired
  39 + StationRouteRepository stationRouteRepository;
  40 +
  41 + @RequestMapping(value = "/all", method = RequestMethod.GET)
  42 + @Override
  43 + public Iterable<StationRoute> list(@RequestParam Map<String, Object> map) {
  44 + return stationRouteService.list(map);
  45 + }
  46 +
  47 + /**
  48 + * @Description :TODO(查询路段信息)
  49 + *
  50 + * @param id
  51 + *
  52 + * @return Map<String, Object>
  53 + */
  54 + @RequestMapping(value = "/export" , method = RequestMethod.GET)
  55 + public Map<String, Object> export(@RequestParam Integer id, HttpServletResponse resp) {
  56 + return stationRouteService.getSectionRouteExport(id, resp);
  57 + }
  58 +
  59 + /**
  60 + * @Description :TODO(查询树站点与路段数据)
  61 + *
  62 + * @param map <line.id_eq:线路ID; directions_eq:方向>
  63 + *
  64 + * @return List<Map<String, Object>>
  65 + */
  66 + @RequestMapping(value = "/findStations" , method = RequestMethod.GET)
  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);
  74 + }
  75 +
  76 + @RequestMapping(value = "/systemQuote" , method = RequestMethod.POST)
  77 + public Map<String, Object> systemQuote(@RequestParam Map<String, Object> map) {
  78 + return stationRouteService.systemQuote(map);
  79 + }
  80 +
  81 + /**
  82 + * @Description :TODO(查询线路某方向下的站点序号与类型)
  83 + *
  84 + * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码>
  85 + *
  86 + * @return List<Map<String, Object>>
  87 + */
  88 + @RequestMapping(value = "/findUpStationRouteCode" , method = RequestMethod.GET)
  89 + public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {
  90 + return stationRouteService.findUpStationRouteCode(map);
  91 + }
  92 +
  93 + /**
  94 + * @Description :TODO(查询线路某方向下所有站点的中心百度坐标)
  95 + *
  96 + * @param map <lineId:线路ID; direction:方向>
  97 + *
  98 + * @return List<Map<String, Object>>
  99 + */
  100 + @RequestMapping(value = "/getStationRouteCenterPoints" , method = RequestMethod.GET)
  101 + public List<Map<String, Object>> getStationRouteCenterPoints(@RequestParam Map<String, Object> map) {
  102 + return stationRouteService.getStationRouteCenterPoints(map);
  103 + }
  104 +
  105 + /**
  106 + * @Description :TODO(查询线路某方向下所有站点)
  107 + *
  108 + * @param map <lineId:线路ID; direction:方向>
  109 + *
  110 + * @return List<Map<String, Object>>
  111 + */
  112 + @RequestMapping(value = "/getStationRouteList" , method = RequestMethod.GET)
  113 + public List<Map<String, Object>> getStationRouteList(@RequestParam Map<String, Object> map) {
  114 + return stationRouteService.getStationRouteList(map);
  115 + }
  116 +
  117 + /**
  118 + * @Description : TODO(根据线路ID生成行单)
  119 + *
  120 + * @param map <id:线路ID>
  121 + *
  122 + * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA>
  123 + */
  124 + @RequestMapping(value = "/usingSingle",method = RequestMethod.POST)
  125 + public Map<String, Object> usingSingle(@RequestParam Map<String, Object> map) {
  126 + return stationRouteService.usingSingle(map);
  127 + }
  128 +
  129 + @RequestMapping(value = "/stations", method = RequestMethod.GET)
  130 + public List<Map<String, Object>> findStations(Integer xlid, Integer xldir) {
  131 + return stationRouteRepository.findStations(xlid, xldir);
  132 + }
  133 +
  134 + /**
  135 + *
  136 + * @Title: findByMultiLine
  137 + * @Description: TODO(多线路路由查询)
  138 + */
  139 + @RequestMapping(value = "/multiLine", method = RequestMethod.GET)
  140 + public Map<String, Object> findByMultiLine(@RequestParam String lineIds){
  141 + return stationRouteService.findByMultiLine(lineIds);
  142 + }
  143 +}
src/main/java/com/bsth/controller/geo_data/GeoDataController.java deleted 100644 → 0
1 -package com.bsth.controller.geo_data;  
2 -  
3 -import com.bsth.entity.geo_data.GeoRoad;  
4 -import com.bsth.entity.geo_data.GeoStation;  
5 -import com.bsth.service.geo_data.GeoDataService;  
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 java.util.Map;  
13 -  
14 -/**  
15 - * Created by panzhao on 2017/12/7.  
16 - */  
17 -@RestController  
18 -@RequestMapping("/_geo_data")  
19 -public class GeoDataController {  
20 -  
21 - @Autowired  
22 - GeoDataService geoDataService;  
23 -  
24 - @RequestMapping("findGeoStations")  
25 - public Map<String, Object> findGeoStations(@RequestParam String lineCode, Integer version){  
26 - return geoDataService.findGeoStations(lineCode, version);  
27 - }  
28 -  
29 -  
30 - @RequestMapping("findGeoRoad")  
31 - public Map<String, Object> findGeoRoad(@RequestParam String lineCode,Integer version){  
32 - return geoDataService.findGeoRoad(lineCode, version);  
33 - }  
34 -  
35 - @RequestMapping(value = "updateBufferInfo",method = RequestMethod.POST)  
36 - public Map<String, Object> updateBufferInfo(GeoStation station){  
37 - return geoDataService.updateBufferInfo(station);  
38 - }  
39 -  
40 - @RequestMapping(value = "updateStationName",method = RequestMethod.POST)  
41 - public Map<String, Object> updateStationName(@RequestParam Map<String, Object> map){  
42 - return geoDataService.updateStationName(map);  
43 - }  
44 -  
45 - @RequestMapping(value = "addNewStationRoute",method = RequestMethod.POST)  
46 - public Map<String, Object> addNewStationRoute(@RequestParam String lineCode,@RequestParam int versions,@RequestParam int upDown  
47 - ,@RequestParam String stationName,@RequestParam Float lat,@RequestParam Float lng,@RequestParam int prevRouteId){  
48 - return geoDataService.addNewStationRoute(lineCode, upDown, versions, stationName, lat, lng, prevRouteId);  
49 - }  
50 -  
51 - @RequestMapping(value = "addNewRoadRoute",method = RequestMethod.POST)  
52 - public Map<String, Object> addNewRoadRoute(@RequestParam String lineCode,@RequestParam int versions,@RequestParam int upDown  
53 - ,@RequestParam String sectionName,@RequestParam String crosesRoad,@RequestParam String coords,@RequestParam int prevRouteId){  
54 - return geoDataService.addNewRoadRoute(lineCode, upDown, versions, sectionName, crosesRoad, coords, prevRouteId);  
55 - }  
56 -  
57 - @RequestMapping(value = "destroyStation",method = RequestMethod.POST)  
58 - public Map<String, Object> destroyStation(GeoStation station){  
59 - return geoDataService.destroyStation(station);  
60 - }  
61 -  
62 - @RequestMapping(value = "updateRoadInfo",method = RequestMethod.POST)  
63 - public Map<String, Object> updateRoadInfo(GeoRoad road){  
64 - return geoDataService.updateRoadInfo(road);  
65 - }  
66 -  
67 - @RequestMapping(value = "destroyRoad",method = RequestMethod.POST)  
68 - public Map<String, Object> destroyRoad(GeoRoad road){  
69 - return geoDataService.destroyRoad(road);  
70 - }  
71 -  
72 - @RequestMapping("findVersionInfo")  
73 - public Map<String, Object> findVersionInfo(@RequestParam String lineCode){  
74 - return geoDataService.findVersionInfo(lineCode);  
75 - }  
76 -  
77 - @RequestMapping(value = "addNewLineVersion",method = RequestMethod.POST)  
78 - public Map<String, Object> addNewLineVersion(@RequestParam Map<String, Object> map){  
79 - return geoDataService.addNewLineVersion(map);  
80 - }  
81 -  
82 - @RequestMapping(value = "deleteLineVersion",method = RequestMethod.POST)  
83 - public Map<String, Object> deleteLineVersion(@RequestParam String lineCode,@RequestParam int version){  
84 - return geoDataService.deleteLineVersion(lineCode, version);  
85 - }  
86 -  
87 - @RequestMapping("findFutureVersion")  
88 - public Map<String, Object> findFutureVersion(@RequestParam String lineCode){  
89 - return geoDataService.findFutureVersion(lineCode);  
90 - }  
91 -  
92 - @RequestMapping(value = "addEnableInfo",method = RequestMethod.POST)  
93 - public Map<String, Object> addEnableInfo(@RequestParam String lineCode,@RequestParam int versions, @RequestParam String startDate){  
94 - return geoDataService.addEnableInfo(lineCode, versions, startDate);  
95 - }  
96 -}  
97 \ No newline at end of file 0 \ No newline at end of file
src/main/java/com/bsth/controller/gps/GpsController.java
1 -package com.bsth.controller.gps;  
2 -  
3 -import com.bsth.data.BasicData;  
4 -import com.bsth.data.gpsdata_v2.GpsRealData;  
5 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
6 -import com.bsth.data.gpsdata_v2.handlers.overspeed.GpsOverspeed;  
7 -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;  
8 -import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker;  
9 -import com.bsth.data.schedule.e_state_check.entity.SCodeInfo;  
10 -import com.bsth.service.gps.GpsService;  
11 -import com.bsth.service.gps.entity.GpsSpeed;  
12 -import com.google.common.base.Splitter;  
13 -import org.springframework.beans.factory.annotation.Autowired;  
14 -import org.springframework.web.bind.annotation.*;  
15 -  
16 -import javax.servlet.http.HttpServletResponse;  
17 -import java.text.ParseException;  
18 -import java.util.ArrayList;  
19 -import java.util.HashMap;  
20 -import java.util.List;  
21 -import java.util.Map;  
22 -  
23 -@RestController  
24 -@RequestMapping("gps")  
25 -public class GpsController {  
26 -  
27 - @Autowired  
28 - GpsRealData gpsRealData;  
29 -  
30 - @Autowired  
31 - GpsService gpsService;  
32 -  
33 - @Autowired  
34 - OverspeedProcess overspeedProcess;  
35 -  
36 - @RequestMapping(value = "/real/all")  
37 - public Map<String, Object> search(@RequestParam Map<String, Object> map,  
38 - @RequestParam(defaultValue = "0") int page,  
39 - @RequestParam(defaultValue = "15") int size,  
40 - @RequestParam(defaultValue = "timestamp") String order,  
41 - @RequestParam(defaultValue = "DESC") String direction) {  
42 -  
43 -  
44 - return gpsService.search(map, page, size, order, direction);  
45 - }  
46 -  
47 - @RequestMapping(value = "/real/line/{lineCode}")  
48 - public List<GpsEntity> findByLineCode(@PathVariable("lineCode") String lineCode) {  
49 - return gpsRealData.getByLine(lineCode);  
50 - }  
51 -  
52 - @RequestMapping(value = "/real/line")  
53 - public Map<String, Object> findByLineCodes(@RequestParam String lineCodes) {  
54 - Map<String, Object> rs = new HashMap();  
55 - List<String> lineArray = Splitter.on(",").splitToList(lineCodes);  
56 - //实时gps  
57 - List<GpsEntity> gpsList = gpsRealData.get(lineArray);  
58 -  
59 - //超速信息  
60 - List<GpsOverspeed> overspeedList = overspeedProcess.findByLines(lineArray);  
61 -  
62 - //班次站点检查信息  
63 - List<SCodeInfo> scis = ScheduleStationCodeChecker.findByLineIdx(lineArray);  
64 -  
65 - rs.put("gpsList", gpsList);  
66 - rs.put("overspeedList", overspeedList);  
67 - rs.put("scis", scis);  
68 - return rs;  
69 - }  
70 -  
71 - @RequestMapping(value = "/allDevices")  
72 - public Iterable<String> allDevices() {  
73 - return gpsRealData.allDevices();  
74 - }  
75 -  
76 - @RequestMapping(value = "/removeRealGps", method = RequestMethod.POST)  
77 - public Map<String, Object> removeRealGps(@RequestParam String device) {  
78 - return gpsService.removeRealGps(device);  
79 - }  
80 -  
81 - /**  
82 - * @Title: history @Description: TODO(这个方法给测试页面用) @throws  
83 - */  
84 - @RequestMapping(value = "/history/{device}")  
85 - public List<Map<String, Object>> history(@PathVariable("device") String device, @RequestParam Long startTime,  
86 - @RequestParam Long endTime, @RequestParam int directions) {  
87 -  
88 - return gpsService.history(device, startTime, endTime, directions);  
89 - }  
90 -  
91 - @RequestMapping(value = "/gpsHistory/multiple")  
92 - public List<Map<String, Object>> gpsHistory(@RequestParam String[] nbbmArray, @RequestParam Long st,  
93 - @RequestParam Long et) {  
94 - return (List<Map<String, Object>>) gpsService.history(nbbmArray, st, et).get("list");  
95 - }  
96 -  
97 - /*@RequestMapping(value = "/analyse/ram")  
98 - public List<ArrivalInfo> ramData(@RequestParam String nbbm) {  
99 - return ArrivalDataBuffer.allMap.get(nbbm);  
100 - }*/  
101 -  
102 - @RequestMapping(value = "/Car2DeviceId")  
103 - public Map<String, String> findCarDeviceIdMap() {  
104 - return BasicData.deviceId2NbbmMap.inverse();  
105 - }  
106 -  
107 - @RequestMapping(value = "/buffAera")  
108 - public Map<String, Object> findBuffAeraByCode(@RequestParam String code, @RequestParam String type) {  
109 - return gpsService.findBuffAeraByCode(code, type);  
110 - }  
111 -  
112 - @RequestMapping(value = "/findRoadSpeed")  
113 - public Map<String, Object> findRoadSpeed(@RequestParam String lineCode) {  
114 - return gpsService.findRoadSpeed(lineCode);  
115 - }  
116 -  
117 - /**  
118 - * gps补全  
119 - * type 0 : 实时GPS 1:走补传  
120 - * @return  
121 - */  
122 - @RequestMapping(value = "/gpsCompletion", method = RequestMethod.POST)  
123 - public Map<String, Object> gpsCompletion(@RequestParam long schId, @RequestParam int type) {  
124 - return gpsService.gpsCompletion(schId, type);  
125 - }  
126 -  
127 - /**  
128 - * 历史GPS查询 ,第二版轨迹回放用  
129 - * @param nbbm  
130 - * @param st  
131 - * @param et  
132 - * @return  
133 - */  
134 - @RequestMapping(value = "/history_v2/{nbbm}")  
135 - public Map<String, Object> history_v2(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){  
136 - return gpsService.history_v2(nbbm, st, et);  
137 - }  
138 -  
139 - /**  
140 - * 历史GPS查询 ,第三版轨迹回放用  
141 - * @param nbbm  
142 - * @param st  
143 - * @param et  
144 - * @return  
145 - */  
146 - @RequestMapping(value = "/history_v3/{nbbm}")  
147 - public Map<String, Object> history_v3(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){  
148 - return gpsService.history_v3(nbbm, st, et);  
149 - }  
150 -  
151 - /**  
152 - * 轨迹导出  
153 - * @param nbbm  
154 - * @param st  
155 - * @param et  
156 - * @return  
157 - */  
158 - @RequestMapping(value = "/history_v3/excel/{nbbm}")  
159 - public void trailExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){  
160 - gpsService.trailExcel(nbbm, st, et, resp);  
161 - }  
162 -  
163 - /**  
164 - * 轨迹异常数据导出  
165 - * @param nbbm  
166 - * @param st  
167 - * @param et  
168 - * @return  
169 - */  
170 - @RequestMapping(value = "/history_v3/excel_abnormal/{nbbm}")  
171 - public void abnormalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){  
172 - gpsService.abnormalExcel(nbbm, st, et, resp);  
173 - }  
174 -  
175 - /**  
176 - * 到离站数据导出  
177 - * @param nbbm  
178 - * @param st  
179 - * @param et  
180 - * @return  
181 - */  
182 - @RequestMapping(value = "/history_v3/excel_arrival/{nbbm}")  
183 - public void arrivalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){  
184 - gpsService.arrivalExcel(nbbm, st, et, resp);  
185 - }  
186 -  
187 -  
188 -  
189 -  
190 - /**  
191 - * 安全驾驶数据 分页查询  
192 - * @param map  
193 - * @param page  
194 - * @param size  
195 - * @param order  
196 - * @param direction  
197 - * @return  
198 - */  
199 - @RequestMapping(value = "/safeDriv")  
200 - public Map<String, Object> safeDrivList(@RequestParam Map<String, Object> map,  
201 - @RequestParam(defaultValue = "0") int page,  
202 - @RequestParam(defaultValue = "15") int size,  
203 - @RequestParam(defaultValue = "timestamp") String order,  
204 - @RequestParam(defaultValue = "DESC") String direction){  
205 - return gpsService.safeDrivList(map , page, size, order, direction);  
206 - }  
207 -  
208 - @RequestMapping(value = "/findPosition", method = RequestMethod.GET)  
209 - public List<GpsSpeed> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {  
210 - String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);  
211 - List<GpsSpeed> listGpsSpeed = new ArrayList<GpsSpeed>();  
212 - listGpsSpeed = gpsService.findPosition(deviceid,startdate,enddate);  
213 - return listGpsSpeed;  
214 - }  
215 -  
216 - @RequestMapping(value = "/pagequery",method = RequestMethod.GET)  
217 - public Map<String, Object> pagequery(@RequestParam Map<String, Object> map){  
218 - map.put("curPage", map.get("page").toString());  
219 - map.put("pageData","10");  
220 - return gpsService.Pagequery(map);  
221 - }  
222 -  
223 - /**  
224 - * 获取线路下所有车辆,包括实时设备 和 计划排班  
225 - * @param lineCode  
226 - * @return  
227 - */  
228 - @RequestMapping(value = "/allCarsByLine",method = RequestMethod.GET)  
229 - public Map<String, Object> allCarsByLine(String lineCode){  
230 - return gpsService.allCarsByLine(lineCode);  
231 - }  
232 -  
233 -} 1 +package com.bsth.controller.gps;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.gpsdata_v2.GpsRealData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.handlers.overspeed.GpsOverspeed;
  7 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
  8 +import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker;
  9 +import com.bsth.data.schedule.e_state_check.entity.SCodeInfo;
  10 +import com.bsth.service.gps.GpsService;
  11 +import com.bsth.service.gps.entity.GpsSpeed;
  12 +import com.google.common.base.Splitter;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.web.bind.annotation.*;
  15 +
  16 +import javax.servlet.http.HttpServletResponse;
  17 +import java.text.ParseException;
  18 +import java.util.ArrayList;
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +@RestController
  24 +@RequestMapping("gps")
  25 +public class GpsController {
  26 +
  27 + @Autowired
  28 + GpsRealData gpsRealData;
  29 +
  30 + @Autowired
  31 + GpsService gpsService;
  32 +
  33 + @Autowired
  34 + OverspeedProcess overspeedProcess;
  35 +
  36 + @RequestMapping(value = "/real/all")
  37 + public Map<String, Object> search(@RequestParam Map<String, Object> map,
  38 + @RequestParam(defaultValue = "0") int page,
  39 + @RequestParam(defaultValue = "15") int size,
  40 + @RequestParam(defaultValue = "timestamp") String order,
  41 + @RequestParam(defaultValue = "DESC") String direction) {
  42 +
  43 +
  44 + return gpsService.search(map, page, size, order, direction);
  45 + }
  46 +
  47 + @RequestMapping(value = "/real/line/{lineCode}")
  48 + public List<GpsEntity> findByLineCode(@PathVariable("lineCode") String lineCode) {
  49 + return gpsRealData.getByLine(lineCode);
  50 + }
  51 +
  52 + @RequestMapping(value = "/real/line")
  53 + public Map<String, Object> findByLineCodes(@RequestParam String lineCodes) {
  54 + Map<String, Object> rs = new HashMap();
  55 + List<String> lineArray = Splitter.on(",").splitToList(lineCodes);
  56 + //实时gps
  57 + List<GpsEntity> gpsList = gpsRealData.get(lineArray);
  58 +
  59 + //超速信息
  60 + List<GpsOverspeed> overspeedList = overspeedProcess.findByLines(lineArray);
  61 +
  62 + //班次站点检查信息
  63 + List<SCodeInfo> scis = ScheduleStationCodeChecker.findByLineIdx(lineArray);
  64 +
  65 + rs.put("gpsList", gpsList);
  66 + rs.put("overspeedList", overspeedList);
  67 + rs.put("scis", scis);
  68 + return rs;
  69 + }
  70 +
  71 + @RequestMapping(value = "/allDevices")
  72 + public Iterable<String> allDevices() {
  73 + return gpsRealData.allDevices();
  74 + }
  75 +
  76 + @RequestMapping(value = "/removeRealGps", method = RequestMethod.POST)
  77 + public Map<String, Object> removeRealGps(@RequestParam String device) {
  78 + return gpsService.removeRealGps(device);
  79 + }
  80 +
  81 + /**
  82 + * @Title: history @Description: TODO(这个方法给测试页面用) @throws
  83 + */
  84 + @RequestMapping(value = "/history/{device}")
  85 + public List<Map<String, Object>> history(@PathVariable("device") String device, @RequestParam Long startTime,
  86 + @RequestParam Long endTime, @RequestParam int directions) {
  87 +
  88 + return gpsService.history(device, startTime, endTime, directions);
  89 + }
  90 +
  91 + @RequestMapping(value = "/gpsHistory/multiple")
  92 + public List<Map<String, Object>> gpsHistory(@RequestParam String[] nbbmArray, @RequestParam Long st,
  93 + @RequestParam Long et) {
  94 + return (List<Map<String, Object>>) gpsService.history(nbbmArray, st, et).get("list");
  95 + }
  96 +
  97 + /*@RequestMapping(value = "/analyse/ram")
  98 + public List<ArrivalInfo> ramData(@RequestParam String nbbm) {
  99 + return ArrivalDataBuffer.allMap.get(nbbm);
  100 + }*/
  101 +
  102 + @RequestMapping(value = "/Car2DeviceId")
  103 + public Map<String, String> findCarDeviceIdMap() {
  104 + return BasicData.deviceId2NbbmMap.inverse();
  105 + }
  106 +
  107 + @RequestMapping(value = "/buffAera")
  108 + public Map<String, Object> findBuffAeraByCode(@RequestParam String lineCode, @RequestParam String code, @RequestParam String type) {
  109 + return gpsService.findBuffAeraByCode(lineCode, code, type);
  110 + }
  111 +
  112 + @RequestMapping(value = "/findRoadSpeed")
  113 + public Map<String, Object> findRoadSpeed(@RequestParam String lineCode) {
  114 + return gpsService.findRoadSpeed(lineCode);
  115 + }
  116 +
  117 + /**
  118 + * gps补全
  119 + * type 0 : 实时GPS 1:走补传
  120 + * @return
  121 + */
  122 + @RequestMapping(value = "/gpsCompletion", method = RequestMethod.POST)
  123 + public Map<String, Object> gpsCompletion(@RequestParam long schId, @RequestParam int type) {
  124 + return gpsService.gpsCompletion(schId, type);
  125 + }
  126 +
  127 + /**
  128 + * 历史GPS查询 ,第二版轨迹回放用
  129 + * @param nbbm
  130 + * @param st
  131 + * @param et
  132 + * @return
  133 + */
  134 + @RequestMapping(value = "/history_v2/{nbbm}")
  135 + public Map<String, Object> history_v2(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){
  136 + return gpsService.history_v2(nbbm, st, et);
  137 + }
  138 +
  139 + /**
  140 + * 历史GPS查询 ,第三版轨迹回放用
  141 + * @param nbbm
  142 + * @param st
  143 + * @param et
  144 + * @return
  145 + */
  146 + @RequestMapping(value = "/history_v3/{nbbm}")
  147 + public Map<String, Object> history_v3(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){
  148 + return gpsService.history_v3(nbbm, st, et);
  149 + }
  150 +
  151 + /**
  152 + * 轨迹导出
  153 + * @param nbbm
  154 + * @param st
  155 + * @param et
  156 + * @return
  157 + */
  158 + @RequestMapping(value = "/history_v3/excel/{nbbm}")
  159 + public void trailExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  160 + gpsService.trailExcel(nbbm, st, et, resp);
  161 + }
  162 +
  163 + /**
  164 + * 轨迹异常数据导出
  165 + * @param nbbm
  166 + * @param st
  167 + * @param et
  168 + * @return
  169 + */
  170 + @RequestMapping(value = "/history_v3/excel_abnormal/{nbbm}")
  171 + public void abnormalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  172 + gpsService.abnormalExcel(nbbm, st, et, resp);
  173 + }
  174 +
  175 + /**
  176 + * 到离站数据导出
  177 + * @param nbbm
  178 + * @param st
  179 + * @param et
  180 + * @return
  181 + */
  182 + @RequestMapping(value = "/history_v3/excel_arrival/{nbbm}")
  183 + public void arrivalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  184 + gpsService.arrivalExcel(nbbm, st, et, resp);
  185 + }
  186 +
  187 +
  188 +
  189 +
  190 + /**
  191 + * 安全驾驶数据 分页查询
  192 + * @param map
  193 + * @param page
  194 + * @param size
  195 + * @param order
  196 + * @param direction
  197 + * @return
  198 + */
  199 + @RequestMapping(value = "/safeDriv")
  200 + public Map<String, Object> safeDrivList(@RequestParam Map<String, Object> map,
  201 + @RequestParam(defaultValue = "0") int page,
  202 + @RequestParam(defaultValue = "15") int size,
  203 + @RequestParam(defaultValue = "timestamp") String order,
  204 + @RequestParam(defaultValue = "DESC") String direction){
  205 + return gpsService.safeDrivList(map , page, size, order, direction);
  206 + }
  207 +
  208 + @RequestMapping(value = "/findPosition", method = RequestMethod.GET)
  209 + public List<GpsSpeed> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {
  210 + String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);
  211 + List<GpsSpeed> listGpsSpeed = new ArrayList<GpsSpeed>();
  212 + listGpsSpeed = gpsService.findPosition(deviceid,startdate,enddate);
  213 + return listGpsSpeed;
  214 + }
  215 +
  216 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  217 + public Map<String, Object> pagequery(@RequestParam Map<String, Object> map){
  218 + map.put("curPage", map.get("page").toString());
  219 + map.put("pageData","10");
  220 + return gpsService.Pagequery(map);
  221 + }
  222 +
  223 + /**
  224 + * 获取线路下所有车辆,包括实时设备 和 计划排班
  225 + * @param lineCode
  226 + * @return
  227 + */
  228 + @RequestMapping(value = "/allCarsByLine",method = RequestMethod.GET)
  229 + public Map<String, Object> allCarsByLine(String lineCode){
  230 + return gpsService.allCarsByLine(lineCode);
  231 + }
  232 +
  233 +}
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
1 package com.bsth.controller.realcontrol; 1 package com.bsth.controller.realcontrol;
2 2
3 -import java.lang.reflect.Field;  
4 -import java.lang.reflect.Modifier;  
5 -import java.text.SimpleDateFormat;  
6 -import java.util.*;  
7 - 3 +import ch.qos.logback.classic.Level;
  4 +import ch.qos.logback.classic.LoggerContext;
  5 +import com.bsth.common.ResponseCode;
8 import com.bsth.data.BasicData; 6 import com.bsth.data.BasicData;
  7 +import com.bsth.data.directive.DayOfDirectives;
  8 +import com.bsth.data.directive.DirectivesPstThread;
  9 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  10 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
  11 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
  12 +import com.bsth.data.msg_queue.DirectivePushQueue;
  13 +import com.bsth.data.msg_queue.WebSocketPushQueue;
  14 +import com.bsth.data.pilot80.PilotReport;
  15 +import com.bsth.data.schedule.DayOfSchedule;
  16 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
9 import com.bsth.filter.SQLInjectFilter; 17 import com.bsth.filter.SQLInjectFilter;
  18 +import com.bsth.service.SectionService;
10 import com.bsth.service.schedule.utils.SpringUtils; 19 import com.bsth.service.schedule.utils.SpringUtils;
11 import com.bsth.util.MailUtils; 20 import com.bsth.util.MailUtils;
  21 +import com.bsth.websocket.handler.SendUtils;
12 import com.fasterxml.jackson.core.JsonProcessingException; 22 import com.fasterxml.jackson.core.JsonProcessingException;
13 -import com.fasterxml.jackson.databind.MapperFeature;  
14 import com.fasterxml.jackson.databind.ObjectMapper; 23 import com.fasterxml.jackson.databind.ObjectMapper;
15 import com.fasterxml.jackson.databind.SerializationFeature; 24 import com.fasterxml.jackson.databind.SerializationFeature;
16 import org.slf4j.Logger; 25 import org.slf4j.Logger;
@@ -20,21 +29,12 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -20,21 +29,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
20 import org.springframework.web.bind.annotation.RequestParam; 29 import org.springframework.web.bind.annotation.RequestParam;
21 import org.springframework.web.bind.annotation.RestController; 30 import org.springframework.web.bind.annotation.RestController;
22 31
23 -import com.bsth.common.ResponseCode;  
24 -import com.bsth.data.directive.DayOfDirectives;  
25 -import com.bsth.data.directive.DirectivesPstThread;  
26 -import com.bsth.data.gpsdata_v2.cache.GeoCacheData;  
27 -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;  
28 -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;  
29 -import com.bsth.data.msg_queue.DirectivePushQueue;  
30 -import com.bsth.data.msg_queue.WebSocketPushQueue;  
31 -import com.bsth.data.pilot80.PilotReport;  
32 -import com.bsth.data.schedule.DayOfSchedule;  
33 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
34 -import com.bsth.websocket.handler.SendUtils;  
35 -  
36 -import ch.qos.logback.classic.Level;  
37 -import ch.qos.logback.classic.LoggerContext; 32 +import java.lang.reflect.Field;
  33 +import java.lang.reflect.Modifier;
  34 +import java.util.HashMap;
  35 +import java.util.List;
  36 +import java.util.Map;
  37 +import java.util.Set;
38 38
39 /** 39 /**
40 * Created by panzhao on 2017/4/14. 40 * Created by panzhao on 2017/4/14.
@@ -70,6 +70,9 @@ public class AdminUtilsController { @@ -70,6 +70,9 @@ public class AdminUtilsController {
70 @Autowired 70 @Autowired
71 private SQLInjectFilter sqlInjectFilter; 71 private SQLInjectFilter sqlInjectFilter;
72 72
  73 + @Autowired
  74 + private SectionService sectionService;
  75 +
73 /** 76 /**
74 * 出现重复班次的车辆 77 * 出现重复班次的车辆
75 * 78 *
@@ -336,4 +339,30 @@ public class AdminUtilsController { @@ -336,4 +339,30 @@ public class AdminUtilsController {
336 339
337 return "error"; 340 return "error";
338 } 341 }
  342 +
  343 + @RequestMapping("/reloadSystemParam")
  344 + public String reloadSystemParam() {
  345 + Map<String, Object> result = new HashMap<>();
  346 + try {
  347 + basicDataLoader.loadSystemParam();
  348 + return "success";
  349 + } catch (Exception e) {
  350 + e.printStackTrace();
  351 + }
  352 +
  353 + return "error";
  354 + }
  355 +
  356 + @RequestMapping("/section/translateWgs2Bd")
  357 + public String translateWgs2Bd() {
  358 + Map<String, Object> result = new HashMap<>();
  359 + try {
  360 + sectionService.translateWgs2Bd();
  361 + return "success";
  362 + } catch (Exception e) {
  363 + e.printStackTrace();
  364 + }
  365 +
  366 + return "error";
  367 + }
339 } 368 }
340 \ No newline at end of file 369 \ No newline at end of file
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
1 package com.bsth.controller.realcontrol; 1 package com.bsth.controller.realcontrol;
2 2
3 -import java.io.ByteArrayOutputStream;  
4 -import java.io.IOException;  
5 -import java.io.InputStream;  
6 -import java.io.OutputStream;  
7 -import java.net.HttpURLConnection;  
8 -import java.net.MalformedURLException;  
9 -import java.net.URL;  
10 -import java.net.URLEncoder;  
11 -import java.sql.Connection;  
12 -import java.sql.Date;  
13 -import java.sql.PreparedStatement;  
14 -import java.sql.ResultSet;  
15 -import java.util.*;  
16 -  
17 -import com.bsth.data.forecast.entity.ArrivalEntity;  
18 -import com.bsth.entity.sys.SysUser;  
19 -import com.bsth.security.util.SecurityUtils;  
20 -import com.bsth.util.ReportUtils;  
21 -import com.bsth.util.db.DBUtils_MS;  
22 -import com.fasterxml.jackson.databind.ObjectMapper;  
23 -import org.apache.commons.io.IOUtils;  
24 -import org.apache.commons.lang3.StringEscapeUtils;  
25 -import org.joda.time.DateTime;  
26 -import org.joda.time.format.DateTimeFormat;  
27 -import org.joda.time.format.DateTimeFormatter;  
28 -import org.springframework.beans.factory.annotation.Autowired;  
29 -import org.springframework.beans.factory.annotation.Value;  
30 -import org.springframework.web.bind.annotation.*;  
31 -  
32 import com.alibaba.fastjson.JSONArray; 3 import com.alibaba.fastjson.JSONArray;
33 import com.bsth.common.ResponseCode; 4 import com.bsth.common.ResponseCode;
34 import com.bsth.controller.BaseController; 5 import com.bsth.controller.BaseController;
@@ -40,12 +11,39 @@ import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; @@ -40,12 +11,39 @@ import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
40 import com.bsth.entity.realcontrol.ScheduleRealInfo; 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
41 import com.bsth.entity.report.RepairReport; 12 import com.bsth.entity.report.RepairReport;
42 import com.bsth.entity.schedule.SchedulePlanInfo; 13 import com.bsth.entity.schedule.SchedulePlanInfo;
  14 +import com.bsth.entity.sys.SysUser;
  15 +import com.bsth.security.util.SecurityUtils;
43 import com.bsth.service.realcontrol.ScheduleRealInfoService; 16 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  17 +import com.bsth.util.HttpClientUtils;
  18 +import com.fasterxml.jackson.databind.ObjectMapper;
  19 +import org.apache.commons.io.IOUtils;
  20 +import org.apache.commons.lang3.StringEscapeUtils;
  21 +import org.apache.http.HttpEntity;
  22 +import org.apache.http.client.config.RequestConfig;
  23 +import org.apache.http.client.methods.CloseableHttpResponse;
  24 +import org.apache.http.client.methods.HttpGet;
  25 +import org.apache.http.impl.client.CloseableHttpClient;
  26 +import org.joda.time.format.DateTimeFormat;
  27 +import org.joda.time.format.DateTimeFormatter;
  28 +import org.slf4j.Logger;
  29 +import org.slf4j.LoggerFactory;
  30 +import org.springframework.beans.factory.annotation.Autowired;
  31 +import org.springframework.beans.factory.annotation.Value;
  32 +import org.springframework.web.bind.annotation.*;
  33 +
  34 +import java.io.*;
  35 +import java.net.HttpURLConnection;
  36 +import java.net.MalformedURLException;
  37 +import java.net.URL;
  38 +import java.net.URLEncoder;
  39 +import java.util.*;
44 40
45 @RestController 41 @RestController
46 @RequestMapping("/realSchedule") 42 @RequestMapping("/realSchedule")
47 public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> { 43 public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
48 44
  45 + private final static Logger log = LoggerFactory.getLogger(ScheduleRealInfoController.class);
  46 +
49 @Autowired 47 @Autowired
50 ScheduleRealInfoService scheduleRealInfoService; 48 ScheduleRealInfoService scheduleRealInfoService;
51 49
@@ -827,26 +825,30 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -827,26 +825,30 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
827 @RequestMapping(value = "ackCp", method = RequestMethod.POST) 825 @RequestMapping(value = "ackCp", method = RequestMethod.POST)
828 public Map<String, Object> ackCp(@RequestParam Map<String, Object> param){ 826 public Map<String, Object> ackCp(@RequestParam Map<String, Object> param){
829 Map<String, Object> res = new HashMap<>(); 827 Map<String, Object> res = new HashMap<>();
830 - InputStream in = null;  
831 - SysUser user = SecurityUtils.getCurrentUser();  
832 - DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); 828 + BufferedReader br = null;
833 StringBuilder url = new StringBuilder(cpUrl); 829 StringBuilder url = new StringBuilder(cpUrl);
834 - HttpURLConnection con = null;  
835 try { 830 try {
836 - con = (HttpURLConnection)new URL(url.append(param.get("id")).toString()).openConnection();  
837 - con.setDoInput(true);  
838 - con.setRequestMethod("GET");  
839 - con.setConnectTimeout(5000);  
840 - con.setReadTimeout(5000);  
841 - con.setRequestProperty("keep-alive", "true");  
842 - con.setRequestProperty("accept", "*/*");  
843 -  
844 - if (con.getResponseCode() == 200) {  
845 - in = con.getInputStream();  
846 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
847 - IOUtils.copy(in, bout);  
848 - Map<String, Object> map = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
849 - System.out.println(map); 831 + url.append(param.get("id"));
  832 + CloseableHttpClient httpClient = HttpClientUtils.defaultHttpClient(url.toString());
  833 + HttpGet get = new HttpGet(url.toString());
  834 + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5500).setConnectionRequestTimeout(5000).setSocketTimeout(5500).build();
  835 + get.setConfig(requestConfig);
  836 + CloseableHttpResponse response = httpClient.execute(get);
  837 +
  838 + int statusCode = response.getStatusLine().getStatusCode();
  839 + if(statusCode != 200){
  840 + log.error("http client status code: " + statusCode);
  841 + }
  842 + HttpEntity entity = response.getEntity();
  843 + if (null != entity) {
  844 + br = new BufferedReader(new InputStreamReader(entity.getContent()));
  845 + StringBuffer stringBuffer = new StringBuffer();
  846 + String str = "";
  847 + while ((str = br.readLine()) != null) {
  848 + stringBuffer.append(str);
  849 + }
  850 + br.close();
  851 + log.info(stringBuffer.toString());
850 } 852 }
851 } catch (MalformedURLException e) { 853 } catch (MalformedURLException e) {
852 // TODO Auto-generated catch block 854 // TODO Auto-generated catch block
@@ -854,10 +856,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -854,10 +856,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
854 } catch (IOException e) { 856 } catch (IOException e) {
855 // TODO Auto-generated catch block 857 // TODO Auto-generated catch block
856 e.printStackTrace(); 858 e.printStackTrace();
857 - } finally {  
858 - if (con != null) {  
859 - con.disconnect();  
860 - }  
861 } 859 }
862 860
863 return res; 861 return res;
src/main/java/com/bsth/controller/realcontrol/calc/ReCalcDataController.java
@@ -20,7 +20,8 @@ import java.util.Map; @@ -20,7 +20,8 @@ import java.util.Map;
20 @RequestMapping("/sch/reCalc") 20 @RequestMapping("/sch/reCalc")
21 public class ReCalcDataController { 21 public class ReCalcDataController {
22 22
23 - private static String reCalcUrl = "http://10.10.150.24:30571/reCalc/scheduleDetail"; 23 +// private static String reCalcUrl = "http://10.10.150.24:30571/reCalc/scheduleDetail";
  24 + private static String reCalcUrl = "http://127.0.0.1:30571/reCalc/scheduleDetail";
24 25
25 Logger logger = LoggerFactory.getLogger(this.getClass()); 26 Logger logger = LoggerFactory.getLogger(this.getClass());
26 27
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/data/BasicData.java
@@ -12,6 +12,8 @@ import java.util.List; @@ -12,6 +12,8 @@ import java.util.List;
12 import java.util.Map; 12 import java.util.Map;
13 import java.util.Set; 13 import java.util.Set;
14 14
  15 +import com.bsth.entity.*;
  16 +import com.bsth.repository.*;
15 import org.apache.commons.lang3.StringUtils; 17 import org.apache.commons.lang3.StringUtils;
16 import org.slf4j.Logger; 18 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 19 import org.slf4j.LoggerFactory;
@@ -28,13 +30,6 @@ import com.bsth.entity.Personnel; @@ -28,13 +30,6 @@ import com.bsth.entity.Personnel;
28 import com.bsth.entity.StationRoute; 30 import com.bsth.entity.StationRoute;
29 import com.bsth.entity.calc.CalcInterval; 31 import com.bsth.entity.calc.CalcInterval;
30 import com.bsth.entity.schedule.CarConfigInfo; 32 import com.bsth.entity.schedule.CarConfigInfo;
31 -import com.bsth.repository.BusinessRepository;  
32 -import com.bsth.repository.CarParkRepository;  
33 -import com.bsth.repository.CarsRepository;  
34 -import com.bsth.repository.LineRepository;  
35 -import com.bsth.repository.PersonnelRepository;  
36 -import com.bsth.repository.StationRepository;  
37 -import com.bsth.repository.StationRouteRepository;  
38 import com.bsth.repository.calc.CalcIntervalRepository; 33 import com.bsth.repository.calc.CalcIntervalRepository;
39 import com.bsth.repository.schedule.CarConfigInfoRepository; 34 import com.bsth.repository.schedule.CarConfigInfoRepository;
40 import com.google.common.collect.BiMap; 35 import com.google.common.collect.BiMap;
@@ -82,6 +77,9 @@ public class BasicData { @@ -82,6 +77,9 @@ public class BasicData {
82 //线路编码和名称对照 77 //线路编码和名称对照
83 public static Map<String, String> lineCode2NameMap; 78 public static Map<String, String> lineCode2NameMap;
84 79
  80 + //名称和线路编码对照
  81 + public static Map<String, String> lineName2CodeMap;
  82 +
85 public static Map<String, String> lineCodeAllNameMap; 83 public static Map<String, String> lineCodeAllNameMap;
86 //停车场 84 //停车场
87 public static List<String> parkCodeList; 85 public static List<String> parkCodeList;
@@ -107,6 +105,9 @@ public class BasicData { @@ -107,6 +105,9 @@ public class BasicData {
107 // 线路编码_日期 等级 105 // 线路编码_日期 等级
108 public static Map<String, String> lineDate2Level; 106 public static Map<String, String> lineDate2Level;
109 107
  108 +
  109 + private static Map<String, SystemParam> key2param = new HashMap<>();
  110 +
110 static Logger logger = LoggerFactory.getLogger(BasicData.class); 111 static Logger logger = LoggerFactory.getLogger(BasicData.class);
111 112
112 public static String getStationNameByCode(String code, String prefix){ 113 public static String getStationNameByCode(String code, String prefix){
@@ -165,6 +166,9 @@ public class BasicData { @@ -165,6 +166,9 @@ public class BasicData {
165 @Autowired 166 @Autowired
166 CalcIntervalRepository calcIntervalRepository; 167 CalcIntervalRepository calcIntervalRepository;
167 168
  169 + @Autowired
  170 + private SystemParamRepository systemParamRepository;
  171 +
168 @Override 172 @Override
169 public void run() { 173 public void run() {
170 loadAllData(); 174 loadAllData();
@@ -196,6 +200,7 @@ public class BasicData { @@ -196,6 +200,7 @@ public class BasicData {
196 logger.info("load geo cache..,"); 200 logger.info("load geo cache..,");
197 geoCacheData.loadData(); 201 geoCacheData.loadData();
198 station2ParkBuffer.saveAll(); 202 station2ParkBuffer.saveAll();
  203 + loadSystemParam();
199 logger.info("加载基础数据成功!,"); 204 logger.info("加载基础数据成功!,");
200 } catch (Exception e) { 205 } catch (Exception e) {
201 logger.error("加载基础数据时出现异常,", e); 206 logger.error("加载基础数据时出现异常,", e);
@@ -327,11 +332,12 @@ public class BasicData { @@ -327,11 +332,12 @@ public class BasicData {
327 * @Description: TODO(加载线路相关信息) 332 * @Description: TODO(加载线路相关信息)
328 */ 333 */
329 public void loadLineInfo() { 334 public void loadLineInfo() {
330 - Iterator<Line> iterator = lineRepository.findAllService().iterator(); 335 + Iterator<Line> iterator = lineRepository.findAllLine().iterator();
331 336
332 Line line; 337 Line line;
333 BiMap<Integer, String> biMap = HashBiMap.create(); 338 BiMap<Integer, String> biMap = HashBiMap.create();
334 Map<String, String> code2name = new HashMap<>(); 339 Map<String, String> code2name = new HashMap<>();
  340 + Map<String, String> name2code = new HashMap<>();
335 Map<Integer, String> id2SHcode = new HashMap<Integer, String>(); 341 Map<Integer, String> id2SHcode = new HashMap<Integer, String>();
336 Map<String, String> code2SHcode = new HashMap<String, String>(); 342 Map<String, String> code2SHcode = new HashMap<String, String>();
337 Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); 343 Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>();
@@ -365,12 +371,14 @@ public class BasicData { @@ -365,12 +371,14 @@ public class BasicData {
365 line = iterator.next(); 371 line = iterator.next();
366 biMap.put(line.getId(), line.getLineCode()); 372 biMap.put(line.getId(), line.getLineCode());
367 code2name.put(line.getLineCode(), line.getName()); 373 code2name.put(line.getLineCode(), line.getName());
  374 + name2code.put(line.getName(), line.getLineCode());
368 id2SHcode.put(line.getId(), line.getShanghaiLinecode()); 375 id2SHcode.put(line.getId(), line.getShanghaiLinecode());
369 code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode()); 376 code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode());
370 } 377 }
371 378
372 lineId2CodeMap = biMap; 379 lineId2CodeMap = biMap;
373 lineCode2NameMap = code2name; 380 lineCode2NameMap = code2name;
  381 + lineName2CodeMap = name2code;
374 lineId2ShangHaiCodeMap = id2SHcode; 382 lineId2ShangHaiCodeMap = id2SHcode;
375 lineCode2ShangHaiCodeMap = code2SHcode; 383 lineCode2ShangHaiCodeMap = code2SHcode;
376 stationName2YgcNumber = tempStationName2YgcNumber; 384 stationName2YgcNumber = tempStationName2YgcNumber;
@@ -448,5 +456,25 @@ public class BasicData { @@ -448,5 +456,25 @@ public class BasicData {
448 456
449 lineDate2Level = result; 457 lineDate2Level = result;
450 } 458 }
  459 +
  460 + /**
  461 + * 加载系统配置参数
  462 + */
  463 + public void loadSystemParam() {
  464 + Map<String, SystemParam> key2param = new HashMap<>();
  465 + Iterator<SystemParam> systemParamIterator = systemParamRepository.findAll().iterator();
  466 + while (systemParamIterator.hasNext()) {
  467 + SystemParam systemParam = systemParamIterator.next();
  468 + key2param.put(systemParam.getKey(), systemParam);
  469 + }
  470 +
  471 + if (key2param.size() > 0) {
  472 + BasicData.key2param = key2param;
  473 + }
  474 + }
  475 + }
  476 +
  477 + public static Map<String, SystemParam> getSystemParam() {
  478 + return key2param;
451 } 479 }
452 } 480 }
src/main/java/com/bsth/data/LineVersionsData.java
1 -package com.bsth.data;  
2 -  
3 -import com.bsth.entity.LineVersions;  
4 -import com.bsth.service.LineVersionsService;  
5 -import com.bsth.service.StationRouteService;  
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory;  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.core.annotation.Order;  
10 -import org.springframework.stereotype.Component;  
11 -  
12 -import java.util.HashMap;  
13 -import java.util.List;  
14 -import java.util.Map;  
15 -  
16 -/**  
17 - * @ClassName: LineVersionsData  
18 - * @Description: TODO(线路版本数据管理)  
19 - */  
20 -@Component  
21 -@Order(20)  
22 -public class LineVersionsData extends Thread {  
23 -  
24 - static Logger logger = LoggerFactory.getLogger(LineVersionsData.class);  
25 -  
26 - @Autowired  
27 - LineVersionsService lineVersionsService;  
28 -  
29 - @Autowired  
30 - StationRouteService stationRouteService;  
31 -  
32 - @Override  
33 - public void run() {  
34 - try {  
35 - List<LineVersions> list = lineVersionsService.lineUpdate();  
36 - if(list.size() == 0){  
37 - logger.info("没有需要更新的线路!");  
38 - return;  
39 - }  
40 - for (LineVersions lineVersions : list) {  
41 - Integer lineId = lineVersions.getLine().getId();  
42 - // 更新线路文件  
43 - Map<String, Object> map = new HashMap<>();  
44 - map.put("lineId", lineId);  
45 - stationRouteService.usingSingle(map);  
46 - logger.info("线路版本更新成功!");  
47 - }  
48 - } catch (Exception e) {  
49 - e.printStackTrace();  
50 - logger.error("线路版本更新出现异常!", e);  
51 - }  
52 - }  
53 -} 1 +package com.bsth.data;
  2 +
  3 +import com.bsth.entity.LineVersions;
  4 +import com.bsth.service.LineVersionsService;
  5 +import com.bsth.service.StationRouteService;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.core.annotation.Order;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.HashMap;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * @ClassName: LineVersionsData
  18 + * @Description: TODO(线路版本数据管理)
  19 + */
  20 +@Component
  21 +@Order(20)
  22 +public class LineVersionsData extends Thread {
  23 +
  24 + static Logger logger = LoggerFactory.getLogger(LineVersionsData.class);
  25 +
  26 + @Autowired
  27 + LineVersionsService lineVersionsService;
  28 +
  29 + @Autowired
  30 + StationRouteService stationRouteService;
  31 +
  32 + @Override
  33 + public void run() {
  34 + logger.warn("线路版本更新开始");
  35 + try {
  36 + List<LineVersions> list = lineVersionsService.lineUpdate();
  37 + if(list.size() == 0){
  38 + logger.info("没有需要更新的线路!");
  39 + return;
  40 + }
  41 + for (LineVersions lineVersions : list) {
  42 + Integer lineId = lineVersions.getLine().getId();
  43 + // 更新线路文件
  44 + Map<String, Object> map = new HashMap<>();
  45 + map.put("lineId", lineId);
  46 + stationRouteService.usingSingle(map);
  47 + logger.info("线路版本更新成功!");
  48 + }
  49 + } catch (Exception e) {
  50 + e.printStackTrace();
  51 + logger.error("线路版本更新出现异常!", e);
  52 + }
  53 + logger.warn("线路版本更新结束");
  54 + }
  55 +}
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
1 -package com.bsth.data.car_out_info;  
2 -  
3 -import com.bsth.data.BasicData;  
4 -import com.bsth.data.gpsdata_v2.cache.GeoCacheData;  
5 -import com.bsth.data.gpsdata_v2.entity.StationRoute;  
6 -import com.bsth.data.schedule.DayOfSchedule;  
7 -import com.bsth.data.schedule.ScheduleComparator;  
8 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
9 -import com.google.common.collect.ArrayListMultimap;  
10 -import org.apache.commons.lang3.StringUtils;  
11 -import org.slf4j.Logger;  
12 -import org.slf4j.LoggerFactory;  
13 -import org.springframework.beans.factory.annotation.Autowired;  
14 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
15 -import org.springframework.jdbc.core.JdbcTemplate;  
16 -import org.springframework.jdbc.datasource.DataSourceTransactionManager;  
17 -import org.springframework.stereotype.Component;  
18 -import org.springframework.transaction.TransactionDefinition;  
19 -import org.springframework.transaction.TransactionStatus;  
20 -import org.springframework.transaction.support.DefaultTransactionDefinition;  
21 -  
22 -import java.sql.PreparedStatement;  
23 -import java.sql.SQLException;  
24 -import java.util.*;  
25 -  
26 -/**  
27 - * 发车信息表处理程序  
28 - * Created by panzhao on 2017/5/5.  
29 - */  
30 -@Component  
31 -public class CarOutInfoHandler {  
32 -  
33 - @Autowired  
34 - DayOfSchedule dayOfSchedule;  
35 -  
36 - //班次类型对照表  
37 - static Map<String, String> bcTypeMap;  
38 -  
39 - static{  
40 - bcTypeMap = new HashMap<>();  
41 - bcTypeMap.put("normal", "正常班次");  
42 - bcTypeMap.put("region", "区间");  
43 - bcTypeMap.put("venting", "直放");  
44 - bcTypeMap.put("major", "放站");  
45 - bcTypeMap.put("ldks", "两点间空驶");  
46 - }  
47 -  
48 - private static ScheduleComparator.DFSJ2 schDFSJComparator = new ScheduleComparator.DFSJ2();  
49 -  
50 - @Autowired  
51 - JdbcTemplate jdbcTemplate;  
52 -  
53 - Logger logger = LoggerFactory.getLogger(this.getClass());  
54 -  
55 -  
56 - ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create();  
57 - List<ScheduleRealInfo> pstList = new ArrayList<>();  
58 - /**  
59 - * 全量更新发车信息表  
60 - */  
61 - public void updateAll() {  
62 - try{  
63 - //将班次按线路分组  
64 - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());  
65 - for(ScheduleRealInfo sch : all){  
66 - xlMaps.put(sch.getXlBm(), sch);  
67 - }  
68 -  
69 - Set<String> ks = xlMaps.keySet();  
70 - for (String k : ks) {  
71 - pstList.addAll(update(xlMaps.get(k)));  
72 - }  
73 -  
74 - save(pstList);  
75 - pstList.clear();  
76 - xlMaps.clear();  
77 - }catch (Exception e){  
78 - logger.error("", e);  
79 - }  
80 - }  
81 -  
82 - public List<ScheduleRealInfo> update(List<ScheduleRealInfo> list) {  
83 - if (list.size() == 0)  
84 - return new ArrayList<>();  
85 - //按上下行分组  
86 - List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>();  
87 - for (ScheduleRealInfo sch : list) {  
88 - if (sch.getXlDir().equals("0"))  
89 - ups.add(sch);  
90 - else  
91 - downs.add(sch);  
92 - }  
93 -  
94 - ScheduleRealInfo[] upArray = nexts(ups),  
95 - downArray = nexts(downs);  
96 -  
97 - List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray);  
98 -  
99 - return pstArray;  
100 - }  
101 -  
102 - private void save(final List<ScheduleRealInfo> pstList){  
103 - //编程式事务  
104 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
105 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
106 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
107 - TransactionStatus status = tran.getTransaction(def);  
108 -  
109 - try{  
110 - //删除  
111 - jdbcTemplate.update("delete from bsth_t_clfcxxb");  
112 - //重新写入  
113 - jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" +  
114 - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {  
115 - @Override  
116 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
117 - ScheduleRealInfo sch = pstList.get(i);  
118 - ps.setString(1, sch.getScheduleDateStr());  
119 - ps.setString(2, sch.getXlBm());  
120 - ps.setString(3, sch.getXlName());  
121 - ps.setString(4, /*sch.getLpName()*/"0");  
122 - ps.setInt(5, sch.getFcno()==null?-1:sch.getFcno());  
123 - ps.setString(6, sch.getDfsj().replace(":", ""));  
124 - ps.setString(7, sch.getClZbh().replace("-", ""));  
125 - ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh()));  
126 - ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType());  
127 - ps.setString(10, sch.getZdzName());  
128 - ps.setInt(11, Integer.parseInt(sch.getXlDir()));  
129 - ps.setString(12, sch.getjGh());  
130 - ps.setString(13, sch.getjName());  
131 - ps.setString(14, sch.getRemarks());  
132 - ps.setInt(15, sch.getFcpSn());  
133 - }  
134 -  
135 - @Override  
136 - public int getBatchSize() {  
137 - return pstList.size();  
138 - }  
139 - });  
140 -  
141 - tran.commit(status);  
142 - }catch (Exception e){  
143 - tran.rollback(status);  
144 - }  
145 - }  
146 -  
147 - private List<ScheduleRealInfo> mergeArray(ScheduleRealInfo[] upArray, ScheduleRealInfo[] downArray) {  
148 - List<ScheduleRealInfo> list = new ArrayList<>();  
149 - for (int i = 0; i < upArray.length; i++) {  
150 - if (upArray[i] != null) {  
151 - upArray[i].setFcpSn(i + 1);  
152 - list.add(upArray[i]);  
153 - }  
154 - }  
155 - for (int i = 0; i < downArray.length; i++) {  
156 - if (downArray[i] != null) {  
157 - downArray[i].setFcpSn(i + 1);  
158 - list.add(downArray[i]);  
159 - }  
160 - }  
161 - return list;  
162 - }  
163 -  
164 - /**  
165 - * 接下来要执行的3个班次  
166 - *  
167 - * @param list  
168 - * @return  
169 - */  
170 - private static String[] fls = new String[]{"in","out","ldks","venting","major"};  
171 - private static List<String> clearTypes;  
172 - static {  
173 - clearTypes = Arrays.asList(fls);  
174 - }  
175 - private ScheduleRealInfo[] nexts(List<ScheduleRealInfo> list) {  
176 - ScheduleRealInfo[] array = new ScheduleRealInfo[3];  
177 - Collections.sort(list, schDFSJComparator);  
178 -  
179 - int count = 0;//, threshold = 1000 * 60 * 60 * 4;  
180 - //long t = System.currentTimeMillis();  
181 - for (ScheduleRealInfo sch : list) {  
182 - if (count == 3)  
183 - break;  
184 -  
185 - //烂班  
186 - if (sch.isDestroy())  
187 - continue;  
188 -  
189 - //进场、出场、2点间空驶  
190 - if (clearTypes.contains(sch.getBcType()))  
191 - continue;  
192 -  
193 - //区间  
194 - if (sch.getBcType().equals("region")){  
195 - //是否起点发出  
196 - if(!isStartOut(sch))  
197 - continue;  
198 - }  
199 -  
200 - //有实发实达时间的  
201 - if (StringUtils.isNotEmpty(sch.getFcsjActual())  
202 - || StringUtils.isNotEmpty(sch.getZdsjActual()))  
203 - continue;  
204 -  
205 - /*if (t - sch.getDfsjT() > threshold)  
206 - continue;*/  
207 -  
208 - array[count] = sch;  
209 - count++;  
210 - }  
211 - return array;  
212 - }  
213 -  
214 - private static StationRouteComp sComp = new StationRouteComp();  
215 - private boolean isStartOut(ScheduleRealInfo sch) {  
216 - try{  
217 - List<StationRoute> list = GeoCacheData.getStationRoute(sch.getXlBm(), Integer.parseInt(sch.getXlDir()));  
218 -  
219 - if(null == list && list.size() == 0)  
220 - return false;  
221 - //排序  
222 - Collections.sort(list, sComp);  
223 -  
224 - if(sch.getQdzName().equals(list.get(0).getName()))  
225 - return true;  
226 - }catch (Exception e){  
227 - logger.error("", e);  
228 - }  
229 - return false;  
230 - }  
231 -  
232 - private static class StationRouteComp implements Comparator<StationRoute> {  
233 -  
234 - @Override  
235 - public int compare(StationRoute s1, StationRoute s2) {  
236 - return s1.getRouteSort() - s2.getRouteSort();  
237 - }  
238 - }  
239 -} 1 +package com.bsth.data.car_out_info;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.data.schedule.ScheduleComparator;
  8 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import com.fasterxml.jackson.core.JsonProcessingException;
  10 +import com.fasterxml.jackson.databind.ObjectMapper;
  11 +import com.google.common.collect.ArrayListMultimap;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  17 +import org.springframework.jdbc.core.JdbcTemplate;
  18 +import org.springframework.stereotype.Component;
  19 +import org.springframework.transaction.TransactionStatus;
  20 +import org.springframework.transaction.support.TransactionCallbackWithoutResult;
  21 +import org.springframework.transaction.support.TransactionTemplate;
  22 +
  23 +import java.sql.PreparedStatement;
  24 +import java.sql.SQLException;
  25 +import java.util.*;
  26 +
  27 +/**
  28 + * 发车信息表处理程序
  29 + * Created by panzhao on 2017/5/5.
  30 + */
  31 +@Component
  32 +public class CarOutInfoHandler {
  33 +
  34 + @Autowired
  35 + DayOfSchedule dayOfSchedule;
  36 +
  37 + //班次类型对照表
  38 + static Map<String, String> bcTypeMap;
  39 +
  40 + static{
  41 + bcTypeMap = new HashMap<>();
  42 + bcTypeMap.put("normal", "正常班次");
  43 + bcTypeMap.put("region", "区间");
  44 + bcTypeMap.put("venting", "直放");
  45 + bcTypeMap.put("major", "放站");
  46 + bcTypeMap.put("ldks", "两点间空驶");
  47 + }
  48 +
  49 + private static ScheduleComparator.DFSJ2 schDFSJComparator = new ScheduleComparator.DFSJ2();
  50 +
  51 + @Autowired
  52 + JdbcTemplate jdbcTemplate;
  53 +
  54 + @Autowired
  55 + private TransactionTemplate transactionTemplate;
  56 +
  57 + @Autowired
  58 + private ObjectMapper mapper;
  59 +
  60 + Logger logger = LoggerFactory.getLogger(this.getClass());
  61 +
  62 +
  63 + ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create();
  64 + List<ScheduleRealInfo> pstList = new ArrayList<>();
  65 + /**
  66 + * 全量更新发车信息表
  67 + */
  68 + public void updateAll() {
  69 + logger.warn("发车信息更新开始");
  70 + try{
  71 + //将班次按线路分组
  72 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
  73 + for(ScheduleRealInfo sch : all){
  74 + xlMaps.put(sch.getXlBm(), sch);
  75 + }
  76 +
  77 + Set<String> ks = xlMaps.keySet();
  78 + for (String k : ks) {
  79 + pstList.addAll(update(xlMaps.get(k)));
  80 + }
  81 +
  82 + save(pstList);
  83 + pstList.clear();
  84 + xlMaps.clear();
  85 + }catch (Exception e){
  86 + logger.error("", e);
  87 + }
  88 + logger.warn("发车信息更新结束");
  89 + }
  90 +
  91 + public List<ScheduleRealInfo> update(List<ScheduleRealInfo> list) {
  92 + if (list.size() == 0)
  93 + return new ArrayList<>();
  94 + //按上下行分组
  95 + List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>();
  96 + for (ScheduleRealInfo sch : list) {
  97 + if (sch.getXlDir().equals("0"))
  98 + ups.add(sch);
  99 + else
  100 + downs.add(sch);
  101 + }
  102 +
  103 + ScheduleRealInfo[] upArray = nexts(ups),
  104 + downArray = nexts(downs);
  105 +
  106 + List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray);
  107 +
  108 + return pstArray;
  109 + }
  110 +
  111 + private void save(final List<ScheduleRealInfo> pstList){
  112 + transactionTemplate.execute(new TransactionCallbackWithoutResult() {
  113 +
  114 + @Override
  115 + public void doInTransactionWithoutResult(TransactionStatus status) {
  116 + try {
  117 + //删除
  118 + jdbcTemplate.update("delete from bsth_t_clfcxxb");
  119 + //重新写入
  120 + jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" +
  121 + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
  122 + @Override
  123 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  124 + ScheduleRealInfo sch = pstList.get(i);
  125 + ps.setString(1, sch.getScheduleDateStr());
  126 + ps.setString(2, sch.getXlBm());
  127 + ps.setString(3, sch.getXlName());
  128 + ps.setString(4, /*sch.getLpName()*/"0");
  129 + ps.setInt(5, sch.getFcno()==null?-1:sch.getFcno());
  130 + ps.setString(6, sch.getDfsj().replace(":", ""));
  131 + ps.setString(7, sch.getClZbh().replace("-", ""));
  132 + ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh()));
  133 + ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType());
  134 + ps.setString(10, sch.getZdzName());
  135 + ps.setInt(11, Integer.parseInt(sch.getXlDir()));
  136 + ps.setString(12, sch.getjGh());
  137 + ps.setString(13, sch.getjName());
  138 + ps.setString(14, sch.getRemarks());
  139 + ps.setInt(15, sch.getFcpSn());
  140 + }
  141 +
  142 + @Override
  143 + public int getBatchSize() {
  144 + return pstList.size();
  145 + }
  146 + });
  147 + } catch (Exception e) {
  148 + status.setRollbackOnly();
  149 + try {
  150 + logger.error(String.format("发车信息批量保存异常: %s", mapper.writeValueAsString(pstList)), e);
  151 + } catch (JsonProcessingException jsonProcessingException) {
  152 + jsonProcessingException.printStackTrace();
  153 + }
  154 + }
  155 + }
  156 + });
  157 + }
  158 +
  159 + private List<ScheduleRealInfo> mergeArray(ScheduleRealInfo[] upArray, ScheduleRealInfo[] downArray) {
  160 + List<ScheduleRealInfo> list = new ArrayList<>();
  161 + for (int i = 0; i < upArray.length; i++) {
  162 + if (upArray[i] != null) {
  163 + upArray[i].setFcpSn(i + 1);
  164 + list.add(upArray[i]);
  165 + }
  166 + }
  167 + for (int i = 0; i < downArray.length; i++) {
  168 + if (downArray[i] != null) {
  169 + downArray[i].setFcpSn(i + 1);
  170 + list.add(downArray[i]);
  171 + }
  172 + }
  173 + return list;
  174 + }
  175 +
  176 + /**
  177 + * 接下来要执行的3个班次
  178 + *
  179 + * @param list
  180 + * @return
  181 + */
  182 + private static String[] fls = new String[]{"in","out","ldks","venting","major"};
  183 + private static List<String> clearTypes;
  184 + static {
  185 + clearTypes = Arrays.asList(fls);
  186 + }
  187 + private ScheduleRealInfo[] nexts(List<ScheduleRealInfo> list) {
  188 + ScheduleRealInfo[] array = new ScheduleRealInfo[3];
  189 + Collections.sort(list, schDFSJComparator);
  190 +
  191 + int count = 0;//, threshold = 1000 * 60 * 60 * 4;
  192 + //long t = System.currentTimeMillis();
  193 + for (ScheduleRealInfo sch : list) {
  194 + if (count == 3)
  195 + break;
  196 +
  197 + //烂班
  198 + if (sch.isDestroy())
  199 + continue;
  200 +
  201 + //进场、出场、2点间空驶
  202 + if (clearTypes.contains(sch.getBcType()))
  203 + continue;
  204 +
  205 + //区间
  206 + if (sch.getBcType().equals("region")){
  207 + //是否起点发出
  208 + if(!isStartOut(sch))
  209 + continue;
  210 + }
  211 +
  212 + //有实发实达时间的
  213 + if (StringUtils.isNotEmpty(sch.getFcsjActual())
  214 + || StringUtils.isNotEmpty(sch.getZdsjActual()))
  215 + continue;
  216 +
  217 + /*if (t - sch.getDfsjT() > threshold)
  218 + continue;*/
  219 +
  220 + array[count] = sch;
  221 + count++;
  222 + }
  223 + return array;
  224 + }
  225 +
  226 + private static StationRouteComp sComp = new StationRouteComp();
  227 + private boolean isStartOut(ScheduleRealInfo sch) {
  228 + try{
  229 + List<StationRoute> list = GeoCacheData.getStationRoute(sch.getXlBm(), Integer.parseInt(sch.getXlDir()));
  230 +
  231 + if(null == list && list.size() == 0)
  232 + return false;
  233 + //排序
  234 + Collections.sort(list, sComp);
  235 +
  236 + if(sch.getQdzName().equals(list.get(0).getName()))
  237 + return true;
  238 + }catch (Exception e){
  239 + logger.error("", e);
  240 + }
  241 + return false;
  242 + }
  243 +
  244 + private static class StationRouteComp implements Comparator<StationRoute> {
  245 +
  246 + @Override
  247 + public int compare(StationRoute s1, StationRoute s2) {
  248 + return s1.getRouteSort() - s2.getRouteSort();
  249 + }
  250 + }
  251 +}
src/main/java/com/bsth/data/directive/DirectivesPstThread.java
1 -package com.bsth.data.directive;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.bsth.data.schedule.DayOfSchedule;  
5 -import com.bsth.entity.directive.D60;  
6 -import com.bsth.entity.directive.D64;  
7 -import com.bsth.entity.directive.Directive;  
8 -import com.bsth.repository.directive.D60Repository;  
9 -import com.bsth.repository.directive.D64Repository;  
10 -import org.joda.time.format.DateTimeFormat;  
11 -import org.joda.time.format.DateTimeFormatter;  
12 -import org.slf4j.Logger;  
13 -import org.slf4j.LoggerFactory;  
14 -import org.springframework.beans.factory.annotation.Autowired;  
15 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
16 -import org.springframework.jdbc.core.JdbcTemplate;  
17 -import org.springframework.jdbc.datasource.DataSourceTransactionManager;  
18 -import org.springframework.stereotype.Component;  
19 -import org.springframework.transaction.TransactionDefinition;  
20 -import org.springframework.transaction.TransactionStatus;  
21 -import org.springframework.transaction.support.DefaultTransactionDefinition;  
22 -  
23 -import java.sql.PreparedStatement;  
24 -import java.sql.SQLException;  
25 -import java.sql.Types;  
26 -import java.util.ArrayList;  
27 -import java.util.List;  
28 -import java.util.concurrent.ConcurrentLinkedQueue;  
29 -  
30 -/**  
31 - * 指令持久化线程  
32 - * Created by panzhao on 2017/3/6.  
33 - */  
34 -@Component  
35 -public class DirectivesPstThread extends Thread {  
36 -  
37 - Logger logger = LoggerFactory.getLogger(this.getClass());  
38 -  
39 - @Autowired  
40 - D60Repository d60Repository;  
41 -  
42 - @Autowired  
43 - D64Repository d64Repository;  
44 -  
45 - @Autowired  
46 - DayOfSchedule dayOfSchedule;  
47 -  
48 - @Autowired  
49 - JdbcTemplate jdbcTemplate;  
50 -  
51 - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");  
52 -  
53 - @Override  
54 - public void run() {  
55 - try{  
56 - ConcurrentLinkedQueue<Directive> list = DayOfDirectives.pstDirectives;  
57 -  
58 - List<D60> d60s = new ArrayList<>();  
59 - List<D64> d64s = new ArrayList<>();  
60 - //按 60 和 64 分组  
61 - Directive directive;  
62 - D60 d60;  
63 - for (int i = 0; i < 2000; i++) {  
64 - directive = list.poll();  
65 - if(null == directive)  
66 - break;  
67 -  
68 - //日期  
69 - directive.setRq(fmtyyyyMMdd.print(directive.getTimestamp()));  
70 -  
71 - if (directive instanceof D60) {  
72 - d60 = (D60) directive;  
73 - if(isDelete(d60))  
74 - continue;  
75 - d60s.add(d60);  
76 - }  
77 - else if(directive instanceof D64)  
78 - d64s.add((D64) directive);  
79 - }  
80 -  
81 - //入库60  
82 - save60(d60s);  
83 - //入库64  
84 - save64(d64s);  
85 -  
86 -  
87 - // 60 指令更新(车载响应)  
88 - ConcurrentLinkedQueue<D60> updateD60s = DayOfDirectives.pstD60s;  
89 - d60s = new ArrayList<>();  
90 - for (int i = 0; i < 2000; i++) {  
91 - d60 = updateD60s.poll();  
92 - if(null == d60)  
93 - break;  
94 - d60s.add(d60);  
95 - }  
96 -  
97 - if(d60s.size() > 0)  
98 - update60(d60s);  
99 - }catch (Exception e){  
100 - logger.error("指令入库出现异常", e);  
101 - }  
102 - }  
103 -  
104 - private void save64(final List<D64> d64s) {  
105 - if(null == d64s || d64s.size() == 0)  
106 - return;  
107 -  
108 - String sql = "insert into bsth_v_directive_64(device_id,error_text,http_code,oper_code,rq,sender,timestamp,city_code,line_id,txt_content,resp_ack) " +  
109 - " values(?,?,?,?,?,?,?,?,?,?,?)";  
110 -  
111 - //编程式事务  
112 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
113 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
114 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
115 - TransactionStatus status = tran.getTransaction(def);  
116 -  
117 - try{  
118 - jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {  
119 - @Override  
120 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
121 - D64 d64 = d64s.get(i);  
122 - ps.setString(1 , d64.getDeviceId());  
123 - ps.setString(2, isNvl(d64.getErrorText()));  
124 - ps.setInt(3, d64.getHttpCode());  
125 - ps.setShort(4, isNvl(d64.getOperCode()));  
126 - ps.setString(5, d64.getRq());  
127 -  
128 - ps.setString(6, isNvl(d64.getSender()));  
129 - ps.setLong(7, d64.getTimestamp());  
130 -  
131 - ps.setShort(8, isNvl(d64.getData().getCityCode()));  
132 - ps.setString(9, isNvl(d64.getData().getLineId()));  
133 - ps.setString(10, isNvl(d64.getData().getTxtContent()));  
134 - ps.setShort(11, isNvl(d64.getRespAck()));  
135 - }  
136 -  
137 - @Override  
138 - public int getBatchSize() {  
139 - return d64s.size();  
140 - }  
141 - });  
142 -  
143 - tran.commit(status);  
144 -  
145 - logger.info("64 入库成功: " + d64s.size());  
146 - }catch (Exception e){  
147 - tran.rollback(status);  
148 - logger.error("", e);  
149 - logger.warn("失败的数据:" + JSON.toJSONString(d64s));  
150 - }  
151 - }  
152 -  
153 - private void update60(final List<D60> d60s) {  
154 - if(null == d60s || d60s.size() == 0)  
155 - return;  
156 -  
157 - String sql = "update bsth_v_directive_60 set reply46=?,reply46time=?,reply47=?,reply47time=? where device_id=? and timestamp=? and msg_id=?";  
158 -  
159 - //编程式事务  
160 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
161 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
162 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
163 - TransactionStatus status = tran.getTransaction(def);  
164 -  
165 - try{  
166 - jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {  
167 - @Override  
168 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
169 - D60 d60 = d60s.get(i);  
170 - ps.setShort(1, isNvl(d60.getReply46()));  
171 - if(null == d60.getReply46Time())  
172 - ps.setNull(2, Types.BIGINT);  
173 - else  
174 - ps.setLong(2, d60.getReply46Time());  
175 -  
176 - ps.setShort(3, isNvl(d60.getReply47()));  
177 -  
178 - if(null == d60.getReply47Time())  
179 - ps.setNull(4, Types.BIGINT);  
180 - else  
181 - ps.setLong(4, d60.getReply47Time());  
182 - ps.setString(5, d60.getDeviceId());  
183 - ps.setLong(6, d60.getTimestamp());  
184 - ps.setInt(7, d60.getMsgId());  
185 - }  
186 -  
187 - @Override  
188 - public int getBatchSize() {  
189 - return d60s.size();  
190 - }  
191 - });  
192 -  
193 - tran.commit(status);  
194 -  
195 - logger.info("60 更新成功: " + d60s.size());  
196 - }catch (Exception e){  
197 - tran.rollback(status);  
198 - logger.error("", e);  
199 - logger.warn("失败的数据:" + JSON.toJSONString(d60s));  
200 - }  
201 - }  
202 -  
203 - private void save60(final List<D60> d60s) {  
204 - if(null == d60s || d60s.size() == 0)  
205 - return;  
206 -  
207 - String sql = "insert into bsth_v_directive_60(device_id,error_text,http_code,oper_code,rq,sender,timestamp" +  
208 - ",alarm_time,company_code,dispatch_instruct,instruct_type,msg_id,service_state,txt_content,is_dispatch" +  
209 - ",line_code,reply46,reply46time,reply47,reply47time,sch) " +  
210 - " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";  
211 -  
212 - //编程式事务  
213 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
214 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
215 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
216 - TransactionStatus status = tran.getTransaction(def);  
217 -  
218 - try{  
219 - jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {  
220 - @Override  
221 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
222 - D60 d60 = d60s.get(i);  
223 - ps.setString(1, d60.getDeviceId());  
224 - ps.setString(2, isNvl(d60.getErrorText()));  
225 - ps.setInt(3, d60.getHttpCode());  
226 - ps.setShort(4, d60.getOperCode());  
227 - ps.setString(5, d60.getRq());  
228 - ps.setString(6, d60.getSender());  
229 - ps.setLong(7, d60.getTimestamp());  
230 -  
231 - ps.setLong(8, isNvl(d60.getData().getAlarmTime()));  
232 - ps.setShort(9, isNvl(d60.getData().getCompanyCode()));  
233 - ps.setShort(10, isNvl(d60.getData().getDispatchInstruct()));  
234 - ps.setInt(11, d60.getData().getInstructType());  
235 - ps.setInt(12, d60.getData().getMsgId());  
236 - ps.setLong(13, d60.getData().getServiceState());  
237 - ps.setString(14, d60.getData().getTxtContent());  
238 - ps.setBoolean(15, d60.isDispatch());  
239 -  
240 - ps.setString(16, isNvl(d60.getLineCode()));  
241 - ps.setShort(17, isNvl(d60.getReply46()));  
242 -  
243 - if(null == d60.getReply46Time())  
244 - ps.setNull(18, Types.BIGINT);  
245 - else  
246 - ps.setLong(18, d60.getReply46Time());  
247 -  
248 - ps.setShort(19, isNvl(d60.getReply47()));  
249 -  
250 - if(null == d60.getReply47Time())  
251 - ps.setNull(20, Types.BIGINT);  
252 - else  
253 - ps.setLong(20, d60.getReply47Time());  
254 -  
255 - if(d60.getSch()==null)  
256 - ps.setNull(21, Types.BIGINT);  
257 - else  
258 - ps.setLong(21, d60.getSch().getId());  
259 - }  
260 -  
261 - @Override  
262 - public int getBatchSize() {  
263 - return d60s.size();  
264 - }  
265 - });  
266 -  
267 - tran.commit(status);  
268 -  
269 - logger.info("60 入库成功: " + d60s.size());  
270 - }catch (Exception e){  
271 - tran.rollback(status);  
272 - logger.error("", e);  
273 - logger.warn("失败的数据:" + JSON.toJSONString(d60s));  
274 - }  
275 - }  
276 -  
277 - private String isNvl(String v) {  
278 - return v==null?"":v;  
279 - }  
280 -  
281 - private short isNvl(Short v) {  
282 - return v==null?0:v;  
283 - }  
284 -  
285 - private long isNvl(Long v) {  
286 - return v==null?0:v;  
287 - }  
288 -  
289 - private boolean isDelete(D60 d60){  
290 - try{  
291 - //如果关联的班次已经不存在了,放弃入库,很低概率出现  
292 - if(d60.isDispatch() && d60.getSch().isDeleted()){  
293 - logger.warn("save 指令,发现 deleted=true 的班次,id=" + d60.getSch().getId());  
294 - return true;  
295 - }  
296 - }catch (Exception e){  
297 - logger.error("", e);  
298 - }  
299 -  
300 - return false;  
301 - }  
302 -} 1 +package com.bsth.data.directive;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.schedule.DayOfSchedule;
  5 +import com.bsth.entity.directive.D60;
  6 +import com.bsth.entity.directive.D64;
  7 +import com.bsth.entity.directive.Directive;
  8 +import com.bsth.repository.directive.D60Repository;
  9 +import com.bsth.repository.directive.D64Repository;
  10 +import org.joda.time.format.DateTimeFormat;
  11 +import org.joda.time.format.DateTimeFormatter;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
  17 +import org.springframework.stereotype.Component;
  18 +import org.springframework.transaction.TransactionStatus;
  19 +import org.springframework.transaction.support.TransactionCallbackWithoutResult;
  20 +import org.springframework.transaction.support.TransactionTemplate;
  21 +
  22 +import java.sql.PreparedStatement;
  23 +import java.sql.SQLException;
  24 +import java.sql.Types;
  25 +import java.util.ArrayList;
  26 +import java.util.List;
  27 +import java.util.concurrent.ConcurrentLinkedQueue;
  28 +
  29 +/**
  30 + * 指令持久化线程
  31 + * Created by panzhao on 2017/3/6.
  32 + */
  33 +@Component
  34 +public class DirectivesPstThread extends Thread {
  35 +
  36 + Logger logger = LoggerFactory.getLogger(this.getClass());
  37 +
  38 + @Autowired
  39 + D60Repository d60Repository;
  40 +
  41 + @Autowired
  42 + D64Repository d64Repository;
  43 +
  44 + @Autowired
  45 + DayOfSchedule dayOfSchedule;
  46 +
  47 + @Autowired
  48 + JdbcTemplate jdbcTemplate;
  49 +
  50 + @Autowired
  51 + private TransactionTemplate transactionTemplate;
  52 +
  53 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  54 +
  55 + @Override
  56 + public void run() {
  57 + logger.warn("指令持久化开始");
  58 + try{
  59 + ConcurrentLinkedQueue<Directive> list = DayOfDirectives.pstDirectives;
  60 +
  61 + List<D60> d60s = new ArrayList<>();
  62 + List<D64> d64s = new ArrayList<>();
  63 + //按 60 和 64 分组
  64 + Directive directive;
  65 + D60 d60;
  66 + for (int i = 0; i < 2000; i++) {
  67 + directive = list.poll();
  68 + if(null == directive)
  69 + break;
  70 +
  71 + //日期
  72 + directive.setRq(fmtyyyyMMdd.print(directive.getTimestamp()));
  73 +
  74 + if (directive instanceof D60) {
  75 + d60 = (D60) directive;
  76 + if(isDelete(d60))
  77 + continue;
  78 + d60s.add(d60);
  79 + }
  80 + else if(directive instanceof D64)
  81 + d64s.add((D64) directive);
  82 + }
  83 +
  84 + //入库60
  85 + save60(d60s);
  86 + //入库64
  87 + save64(d64s);
  88 +
  89 +
  90 + // 60 指令更新(车载响应)
  91 + ConcurrentLinkedQueue<D60> updateD60s = DayOfDirectives.pstD60s;
  92 + d60s = new ArrayList<>();
  93 + for (int i = 0; i < 2000; i++) {
  94 + d60 = updateD60s.poll();
  95 + if(null == d60)
  96 + break;
  97 + d60s.add(d60);
  98 + }
  99 +
  100 + if(d60s.size() > 0)
  101 + update60(d60s);
  102 + }catch (Exception e){
  103 + logger.error("指令入库出现异常", e);
  104 + }
  105 + logger.warn("指令持久化结束");
  106 + }
  107 +
  108 + private void save64(final List<D64> d64s) {
  109 + if(null == d64s || d64s.size() == 0)
  110 + return;
  111 +
  112 + logger.warn("64指令保存开始");
  113 +
  114 + String sql = "insert into bsth_v_directive_64(device_id,error_text,http_code,oper_code,rq,sender,timestamp,city_code,line_id,txt_content,resp_ack) " +
  115 + " values(?,?,?,?,?,?,?,?,?,?,?)";
  116 +
  117 + transactionTemplate.execute(new TransactionCallbackWithoutResult() {
  118 +
  119 + @Override
  120 + protected void doInTransactionWithoutResult(TransactionStatus status) {
  121 + try {
  122 + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
  123 + @Override
  124 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  125 + D64 d64 = d64s.get(i);
  126 + ps.setString(1 , d64.getDeviceId());
  127 + ps.setString(2, isNvl(d64.getErrorText()));
  128 + ps.setInt(3, d64.getHttpCode());
  129 + ps.setShort(4, isNvl(d64.getOperCode()));
  130 + ps.setString(5, d64.getRq());
  131 +
  132 + ps.setString(6, isNvl(d64.getSender()));
  133 + ps.setLong(7, d64.getTimestamp());
  134 +
  135 + ps.setShort(8, isNvl(d64.getData().getCityCode()));
  136 + ps.setString(9, isNvl(d64.getData().getLineId()));
  137 + ps.setString(10, isNvl(d64.getData().getTxtContent()));
  138 + ps.setShort(11, isNvl(d64.getRespAck()));
  139 + }
  140 +
  141 + @Override
  142 + public int getBatchSize() {
  143 + return d64s.size();
  144 + }
  145 + });
  146 + } catch (Exception e) {
  147 + logger.error(String.format("错误数据:%s", JSON.toJSONString(d64s)), e);
  148 + status.setRollbackOnly();
  149 + }
  150 + }
  151 + });
  152 + logger.warn("64指令保存结束");
  153 + }
  154 +
  155 + private void update60(final List<D60> d60s) {
  156 + if(null == d60s || d60s.size() == 0)
  157 + return;
  158 +
  159 + logger.warn("60指令更新开始");
  160 + String sql = "update bsth_v_directive_60 set reply46=?,reply46time=?,reply47=?,reply47time=? where device_id=? and timestamp=? and msg_id=?";
  161 +
  162 + transactionTemplate.execute(new TransactionCallbackWithoutResult() {
  163 +
  164 + @Override
  165 + protected void doInTransactionWithoutResult(TransactionStatus status) {
  166 + try{
  167 + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
  168 + @Override
  169 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  170 + D60 d60 = d60s.get(i);
  171 + ps.setShort(1, isNvl(d60.getReply46()));
  172 + if(null == d60.getReply46Time())
  173 + ps.setNull(2, Types.BIGINT);
  174 + else
  175 + ps.setLong(2, d60.getReply46Time());
  176 +
  177 + ps.setShort(3, isNvl(d60.getReply47()));
  178 +
  179 + if(null == d60.getReply47Time())
  180 + ps.setNull(4, Types.BIGINT);
  181 + else
  182 + ps.setLong(4, d60.getReply47Time());
  183 + ps.setString(5, d60.getDeviceId());
  184 + ps.setLong(6, d60.getTimestamp());
  185 + ps.setInt(7, d60.getMsgId());
  186 + }
  187 +
  188 + @Override
  189 + public int getBatchSize() {
  190 + return d60s.size();
  191 + }
  192 + });
  193 + }catch (Exception e){
  194 + logger.error(String.format("错误数据:%s", JSON.toJSONString(d60s)), e);
  195 + status.setRollbackOnly();
  196 + }
  197 + }
  198 + });
  199 + logger.warn("60指令更新结束");
  200 + }
  201 +
  202 + private void save60(final List<D60> d60s) {
  203 + if(null == d60s || d60s.size() == 0)
  204 + return;
  205 +
  206 + logger.warn("60指令保存开始");
  207 + String sql = "insert into bsth_v_directive_60(device_id,error_text,http_code,oper_code,rq,sender,timestamp" +
  208 + ",alarm_time,company_code,dispatch_instruct,instruct_type,msg_id,service_state,txt_content,is_dispatch" +
  209 + ",line_code,reply46,reply46time,reply47,reply47time,sch) " +
  210 + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  211 +
  212 + transactionTemplate.execute(new TransactionCallbackWithoutResult() {
  213 +
  214 + @Override
  215 + protected void doInTransactionWithoutResult(TransactionStatus status) {
  216 + try{
  217 + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
  218 + @Override
  219 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  220 + D60 d60 = d60s.get(i);
  221 + ps.setString(1, d60.getDeviceId());
  222 + ps.setString(2, isNvl(d60.getErrorText()));
  223 + ps.setInt(3, d60.getHttpCode());
  224 + ps.setShort(4, d60.getOperCode());
  225 + ps.setString(5, d60.getRq());
  226 + ps.setString(6, d60.getSender());
  227 + ps.setLong(7, d60.getTimestamp());
  228 +
  229 + ps.setLong(8, isNvl(d60.getData().getAlarmTime()));
  230 + ps.setShort(9, isNvl(d60.getData().getCompanyCode()));
  231 + ps.setShort(10, isNvl(d60.getData().getDispatchInstruct()));
  232 + ps.setInt(11, d60.getData().getInstructType());
  233 + ps.setInt(12, d60.getData().getMsgId());
  234 + ps.setLong(13, d60.getData().getServiceState());
  235 + ps.setString(14, d60.getData().getTxtContent());
  236 + ps.setBoolean(15, d60.isDispatch());
  237 +
  238 + ps.setString(16, isNvl(d60.getLineCode()));
  239 + ps.setShort(17, isNvl(d60.getReply46()));
  240 +
  241 + if(null == d60.getReply46Time())
  242 + ps.setNull(18, Types.BIGINT);
  243 + else
  244 + ps.setLong(18, d60.getReply46Time());
  245 +
  246 + ps.setShort(19, isNvl(d60.getReply47()));
  247 +
  248 + if(null == d60.getReply47Time())
  249 + ps.setNull(20, Types.BIGINT);
  250 + else
  251 + ps.setLong(20, d60.getReply47Time());
  252 +
  253 + if(d60.getSch()==null)
  254 + ps.setNull(21, Types.BIGINT);
  255 + else
  256 + ps.setLong(21, d60.getSch().getId());
  257 + }
  258 +
  259 + @Override
  260 + public int getBatchSize() {
  261 + return d60s.size();
  262 + }
  263 + });
  264 + }catch (Exception e){
  265 + logger.error(String.format("错误数据:%s", JSON.toJSONString(d60s)), e);
  266 + status.setRollbackOnly();
  267 + }
  268 + }
  269 + });
  270 + logger.warn("60指令保存结束");
  271 + }
  272 +
  273 + private String isNvl(String v) {
  274 + return v==null?"":v;
  275 + }
  276 +
  277 + private short isNvl(Short v) {
  278 + return v==null?0:v;
  279 + }
  280 +
  281 + private long isNvl(Long v) {
  282 + return v==null?0:v;
  283 + }
  284 +
  285 + private boolean isDelete(D60 d60){
  286 + try{
  287 + //如果关联的班次已经不存在了,放弃入库,很低概率出现
  288 + if(d60.isDispatch() && d60.getSch().isDeleted()){
  289 + logger.warn("save 指令,发现 deleted=true 的班次,id=" + d60.getSch().getId());
  290 + return true;
  291 + }
  292 + }catch (Exception e){
  293 + logger.error("", e);
  294 + }
  295 +
  296 + return false;
  297 + }
  298 +}
src/main/java/com/bsth/data/forecast/SampleTimeDataLoader.java
1 -package com.bsth.data.forecast;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.Collections;  
5 -import java.util.Comparator;  
6 -import java.util.Date;  
7 -import java.util.Iterator;  
8 -import java.util.List;  
9 -import java.util.Set;  
10 -  
11 -import org.joda.time.format.DateTimeFormat;  
12 -import org.joda.time.format.DateTimeFormatter;  
13 -import org.slf4j.Logger;  
14 -import org.slf4j.LoggerFactory;  
15 -import org.springframework.beans.factory.annotation.Autowired;  
16 -import org.springframework.stereotype.Component;  
17 -  
18 -import com.bsth.data.forecast.entity.SimpleRoute;  
19 -import com.bsth.data.forecast.entity.SimpleRoute.TimeRange;  
20 -import com.bsth.entity.StationRoute;  
21 -import com.bsth.entity.forecast.Sample;  
22 -import com.bsth.repository.StationRouteRepository;  
23 -import com.bsth.repository.forecast.SampleRepository;  
24 -import com.google.common.collect.ArrayListMultimap;  
25 -  
26 -/**  
27 - *  
28 - * @Title: loadData  
29 - * @Description: TODO(从数据库加载数据)  
30 - */  
31 -@Component  
32 -public class SampleTimeDataLoader extends Thread {  
33 -  
34 - @Autowired  
35 - SampleRepository sampleRepository;  
36 -  
37 - @Autowired  
38 - StationRouteRepository stationRouteRepository;  
39 -  
40 - // 当天日期  
41 - String rq;  
42 -  
43 - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm")  
44 - ,fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");  
45 -  
46 - Logger logger = LoggerFactory.getLogger(this.getClass());  
47 -  
48 - @Override  
49 - public void run() {  
50 - rq = fmtyyyyMMdd.print(new Date().getTime());  
51 -  
52 - Iterator<Sample> iterator = sampleRepository.findAll().iterator();  
53 - ArrayListMultimap<String, Sample> sampleMap = ArrayListMultimap.create();  
54 -  
55 - Sample sample;  
56 - String key;  
57 - while (iterator.hasNext()) {  
58 - sample = iterator.next();  
59 - key = sample.getLineCode() + "_" + sample.getUpdown() + "_" + sample.getsStation() + "_"  
60 - + sample.geteStation();  
61 - sampleMap.put(key, sample);  
62 - }  
63 -  
64 - // 加载全部路由信息  
65 - List<StationRoute> allRoutes = stationRouteRepository.findAllEffective();  
66 - // 线路和走向分组  
67 - ArrayListMultimap<String, StationRoute> groupMap = ArrayListMultimap.create();  
68 - for (StationRoute sr : allRoutes)  
69 - groupMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);  
70 -  
71 - ArrayListMultimap<String, SimpleRoute> lineSampleMapCopy = ArrayListMultimap.create();  
72 - // 排序路由链并附加各个时区耗时信息  
73 - StationRouteComp comp = new StationRouteComp();  
74 - Set<String> kys = groupMap.keySet();  
75 - List<StationRoute> routeList;  
76 - StationRoute sRoute;  
77 -  
78 - List<Sample> sapList;  
79 - for (String k : kys) {  
80 - routeList = groupMap.get(k);  
81 - // 排序  
82 - Collections.sort(routeList, comp);  
83 -  
84 - for (int i = 1; i < routeList.size(); i++) {  
85 - sRoute = routeList.get(i);  
86 -  
87 - sapList = sampleMap.get(k + "_" +routeList.get(i - 1).getStationCode() + "_" + sRoute.getStationCode());  
88 -  
89 - lineSampleMapCopy.put(k, createSimpleRoute(sRoute, sapList));  
90 - }  
91 - }  
92 -  
93 - ForecastRealServer.lineSampleMap = lineSampleMapCopy;  
94 - logger.info("SampleTimeDataLoader.... over...");  
95 - }  
96 -  
97 - private SimpleRoute createSimpleRoute(StationRoute sRoute, List<Sample> list) {  
98 - SimpleRoute simple = new SimpleRoute();  
99 -  
100 - simple.stationCode = sRoute.getStationCode();  
101 - simple.ranges = new ArrayList<>();  
102 -  
103 - try{  
104 - TimeRange tg;  
105 - for (Sample s : list) {  
106 - tg = new TimeRange();  
107 -  
108 - tg.startTime = fmtyyyyMMddHHmm.parseMillis(rq + s.getsDate());  
109 - tg.endTime = fmtyyyyMMddHHmm.parseMillis(rq + s.geteDate());  
110 - tg.runTime = s.getRunTime();  
111 - simple.ranges.add(tg);  
112 - }  
113 -  
114 - //排序  
115 - Collections.sort(simple.ranges);  
116 - }catch(Exception e){  
117 - logger.error("", e);  
118 - }  
119 - return simple;  
120 - }  
121 -  
122 - public static class StationRouteComp implements Comparator<StationRoute> {  
123 -  
124 - @Override  
125 - public int compare(StationRoute o1, StationRoute o2) {  
126 - return o1.getStationRouteCode() - o2.getStationRouteCode();  
127 - }  
128 - }  
129 -} 1 +package com.bsth.data.forecast;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Collections;
  5 +import java.util.Comparator;
  6 +import java.util.Date;
  7 +import java.util.Iterator;
  8 +import java.util.List;
  9 +import java.util.Set;
  10 +
  11 +import org.joda.time.format.DateTimeFormat;
  12 +import org.joda.time.format.DateTimeFormatter;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +import com.bsth.data.forecast.entity.SimpleRoute;
  19 +import com.bsth.data.forecast.entity.SimpleRoute.TimeRange;
  20 +import com.bsth.entity.StationRoute;
  21 +import com.bsth.entity.forecast.Sample;
  22 +import com.bsth.repository.StationRouteRepository;
  23 +import com.bsth.repository.forecast.SampleRepository;
  24 +import com.google.common.collect.ArrayListMultimap;
  25 +
  26 +/**
  27 + *
  28 + * @Title: loadData
  29 + * @Description: TODO(从数据库加载数据)
  30 + */
  31 +@Component
  32 +public class SampleTimeDataLoader extends Thread {
  33 +
  34 + @Autowired
  35 + SampleRepository sampleRepository;
  36 +
  37 + @Autowired
  38 + StationRouteRepository stationRouteRepository;
  39 +
  40 + // 当天日期
  41 + String rq;
  42 +
  43 + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm")
  44 + ,fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  45 +
  46 + Logger logger = LoggerFactory.getLogger(this.getClass());
  47 +
  48 + @Override
  49 + public void run() {
  50 + logger.warn("到离站预测样本加载开始");
  51 + rq = fmtyyyyMMdd.print(System.currentTimeMillis());
  52 +
  53 + Iterator<Sample> iterator = sampleRepository.findAll().iterator();
  54 + ArrayListMultimap<String, Sample> sampleMap = ArrayListMultimap.create();
  55 +
  56 + Sample sample;
  57 + String key;
  58 + while (iterator.hasNext()) {
  59 + sample = iterator.next();
  60 + key = sample.getLineCode() + "_" + sample.getUpdown() + "_" + sample.getsStation() + "_"
  61 + + sample.geteStation();
  62 + sampleMap.put(key, sample);
  63 + }
  64 +
  65 + // 加载全部路由信息
  66 + List<StationRoute> allRoutes = stationRouteRepository.findAllEffective();
  67 + // 线路和走向分组
  68 + ArrayListMultimap<String, StationRoute> groupMap = ArrayListMultimap.create();
  69 + for (StationRoute sr : allRoutes)
  70 + groupMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
  71 +
  72 + ArrayListMultimap<String, SimpleRoute> lineSampleMapCopy = ArrayListMultimap.create();
  73 + // 排序路由链并附加各个时区耗时信息
  74 + StationRouteComp comp = new StationRouteComp();
  75 + Set<String> kys = groupMap.keySet();
  76 + List<StationRoute> routeList;
  77 + StationRoute sRoute;
  78 +
  79 + List<Sample> sapList;
  80 + for (String k : kys) {
  81 + routeList = groupMap.get(k);
  82 + // 排序
  83 + Collections.sort(routeList, comp);
  84 +
  85 + for (int i = 1; i < routeList.size(); i++) {
  86 + sRoute = routeList.get(i);
  87 +
  88 + sapList = sampleMap.get(k + "_" +routeList.get(i - 1).getStationCode() + "_" + sRoute.getStationCode());
  89 +
  90 + lineSampleMapCopy.put(k, createSimpleRoute(sRoute, sapList));
  91 + }
  92 + }
  93 +
  94 + ForecastRealServer.lineSampleMap = lineSampleMapCopy;
  95 + logger.warn("到离站预测样本加载结束");
  96 + }
  97 +
  98 + private SimpleRoute createSimpleRoute(StationRoute sRoute, List<Sample> list) {
  99 + SimpleRoute simple = new SimpleRoute();
  100 +
  101 + simple.stationCode = sRoute.getStationCode();
  102 + simple.ranges = new ArrayList<>();
  103 +
  104 + try{
  105 + TimeRange tg;
  106 + for (Sample s : list) {
  107 + tg = new TimeRange();
  108 +
  109 + tg.startTime = fmtyyyyMMddHHmm.parseMillis(rq + s.getsDate());
  110 + tg.endTime = fmtyyyyMMddHHmm.parseMillis(rq + s.geteDate());
  111 + tg.runTime = s.getRunTime();
  112 + simple.ranges.add(tg);
  113 + }
  114 +
  115 + //排序
  116 + Collections.sort(simple.ranges);
  117 + }catch(Exception e){
  118 + logger.error("", e);
  119 + }
  120 + return simple;
  121 + }
  122 +
  123 + public static class StationRouteComp implements Comparator<StationRoute> {
  124 +
  125 + @Override
  126 + public int compare(StationRoute o1, StationRoute o2) {
  127 + return o1.getStationRouteCode() - o2.getStationRouteCode();
  128 + }
  129 + }
  130 +}
src/main/java/com/bsth/data/gpsdata_v2/cache/GeoCacheData.java
@@ -94,7 +94,7 @@ public class GeoCacheData { @@ -94,7 +94,7 @@ public class GeoCacheData {
94 } 94 }
95 95
96 private void loadStationRoutesData(){ 96 private void loadStationRoutesData(){
97 - String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code"; 97 + String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,r.SHAPED_TYPE,ST_X(s.CENTER_POINT_WGS) G_LONX, ST_Y(s.CENTER_POINT_WGS) G_LATY,ST_AsText(r.BUFFER_POLYGON_WGS) as G_POLYGON_GRID,r.RADIUS, r.STATION_ROUTE_CODE,r.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
98 List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper() { 98 List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper() {
99 99
100 @Override 100 @Override
@@ -109,10 +109,11 @@ public class GeoCacheData { @@ -109,10 +109,11 @@ public class GeoCacheData {
109 sRoute.setMark(rs.getString("STATION_MARK")); 109 sRoute.setMark(rs.getString("STATION_MARK"));
110 sRoute.setName(rs.getString("STATION_NAME")); 110 sRoute.setName(rs.getString("STATION_NAME"));
111 111
112 - String shapesType = rs.getString("SHAPES_TYPE"); 112 + String shapesType = rs.getString("SHAPED_TYPE");
113 //多边形电子围栏 113 //多边形电子围栏
114 - if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) 114 + if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
115 sRoute.setPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))); 115 sRoute.setPolygon(parsePolygon(rs.getString("G_POLYGON_GRID")));
  116 + }
116 return sRoute; 117 return sRoute;
117 } 118 }
118 }); 119 });
src/main/java/com/bsth/data/gpsdata_v2/thread/GpsDataLoaderThread.java
1 -package com.bsth.data.gpsdata_v2.thread;  
2 -  
3 -import com.bsth.data.gpsdata_v2.DataHandleProcess;  
4 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
5 -import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader;  
6 -import com.bsth.data.gpsdata_v2.load.SocketClientLoader;  
7 -import org.slf4j.Logger;  
8 -import org.slf4j.LoggerFactory;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.stereotype.Component;  
11 -  
12 -import java.util.List;  
13 -  
14 -/**  
15 - * Created by panzhao on 2017/1/11.  
16 - */  
17 -@Component  
18 -public class GpsDataLoaderThread extends Thread {  
19 -  
20 - Logger logger = LoggerFactory.getLogger(this.getClass());  
21 -  
22 - //0:从GPS客户端内存获取 -1:从网关获取  
23 - private static int flag = 0;  
24 -  
25 - public static void setFlag(int v) {  
26 - flag = v;  
27 - }  
28 -  
29 - @Autowired  
30 - DataHandleProcess handleProcess;  
31 -  
32 - @Override  
33 - public void run() {  
34 - try {  
35 - List<GpsEntity> list;  
36 - if (flag == 0)  
37 - list = SocketClientLoader.load();  
38 - else  
39 - list = GatewayHttpLoader.load();  
40 -  
41 - if(null != list && list.size() > 0)  
42 - handleProcess.handle(list);  
43 - } catch (Exception e) {  
44 - logger.error("", e);  
45 - }  
46 - } 1 +package com.bsth.data.gpsdata_v2.thread;
  2 +
  3 +import com.bsth.data.gpsdata_v2.DataHandleProcess;
  4 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  5 +import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader;
  6 +import com.bsth.data.gpsdata_v2.load.SocketClientLoader;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * Created by panzhao on 2017/1/11.
  16 + */
  17 +@Component
  18 +public class GpsDataLoaderThread extends Thread {
  19 +
  20 + Logger logger = LoggerFactory.getLogger(this.getClass());
  21 +
  22 + //0:从GPS客户端内存获取 -1:从网关获取
  23 + private static int flag = 0;
  24 +
  25 + public static void setFlag(int v) {
  26 + flag = v;
  27 + }
  28 +
  29 + @Autowired
  30 + DataHandleProcess handleProcess;
  31 +
  32 + @Override
  33 + public void run() {
  34 + logger.warn("GPS获取数据开始");
  35 + try {
  36 + List<GpsEntity> list;
  37 + if (flag == 0)
  38 + list = SocketClientLoader.load();
  39 + else
  40 + list = GatewayHttpLoader.load();
  41 +
  42 + if(null != list && list.size() > 0)
  43 + handleProcess.handle(list);
  44 + } catch (Exception e) {
  45 + logger.error("", e);
  46 + }
  47 + logger.warn("GPS获取数据结束");
  48 + }
47 } 49 }
48 \ No newline at end of file 50 \ No newline at end of file