Commit f78526b1cddb932f084fef8251ae7ae58a224dfc

Authored by 王通
1 parent a979ed8e

1.大邑迁移

... ... @@ -64,6 +64,7 @@
64 64 <dependency>
65 65 <groupId>mysql</groupId>
66 66 <artifactId>mysql-connector-java</artifactId>
  67 + <version>8.0.33</version>
67 68 </dependency>
68 69  
69 70 <dependency>
... ...
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataRefreshThread.java
1   -package com.bsth.server_rs.gps.buffer;
2   -
3   -import java.sql.ResultSet;
4   -import java.sql.SQLException;
5   -import java.util.ArrayList;
6   -import java.util.List;
7   -import java.util.Map;
8   -
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.factory.InitializingBean;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -import org.springframework.jdbc.core.JdbcTemplate;
14   -import org.springframework.jdbc.core.RowMapper;
15   -import org.springframework.stereotype.Component;
16   -
17   -import com.bsth.server_rs.gps.entity.LineInfo;
18   -import com.bsth.server_rs.gps.entity.Point;
19   -import com.bsth.server_rs.gps.entity.StopInfo;
20   -
21   -/**
22   - * Created by panzhao on 2017/3/30.
23   - */
24   -@Component
25   -public class BasicDataRefreshThread extends Thread implements InitializingBean {
26   -
27   - Logger logger = LoggerFactory.getLogger(this.getClass());
28   -
29   - @Autowired
30   - private JdbcTemplate jdbcTemplate;
31   -
32   - @Override
33   - public void run() {
34   - loadBasicData();
35   - }
36   -
37   - private void loadBasicData() {
38   - try {
39   - String qline = "select a.id,in_use,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,shanghai_linecode,line_play_type,up_travel_time,down_travel_time from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0 and a.nature = 'hlwgj'";
40   - String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code";
41   - String qcar = "select equipment_code device_id, car_plate plate_no from bsth_c_cars";
42   -
43   - List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo());
44   - List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo());
45   - List<Map<String, Object>> cars = jdbcTemplate.queryForList(qcar);
46   -
47   - // 缓存线路基本信息
48   - for (LineInfo line : lines) {
49   - BasicDataBuffer.putLine(line.getLineId(), line);
50   - }
51   -
52   - // 线路信息中添加上下行站点信息
53   - int oldId = -1;
54   - LineInfo line = null;
55   - for (StopInfo stop : stops) {
56   - if (stop.getLineCode() != oldId) {
57   - oldId = stop.getLineCode();
58   - line = BasicDataBuffer.getLineById(oldId);
59   - }
60   - if (line != null) {
61   - if (stop.getDirections() == 0) line.getStopsUp().add(stop);
62   - else line.getStopsDown().add(stop);
63   - }
64   - }
65   -
66   - for (Map<String, Object> car : cars) {
67   - BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no"));
68   - }
69   -
70   - logger.info("基础数据加载成功");
71   - }catch (Exception e){
72   - logger.error("基础数据加载失败", e);
73   - }
74   - }
75   -
76   - final class RowMapperLineInfo implements RowMapper<LineInfo> {
77   -
78   - @Override
79   - public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
80   - // TODO Auto-generated method stub
81   - LineInfo line = new LineInfo();
82   - line.setId(rs.getInt("id"));
83   - line.setInUse(rs.getInt("in_use"));
84   - line.setLineId(rs.getInt("line_code"));
85   - line.setLineName(rs.getString("name"));
86   - //line.setStartStation(rs.getInt("start_station"));
87   - line.setStartStationName(rs.getString("start_station_name"));
88   - line.setStartStationFirstTime(rs.getString("start_station_first_time"));
89   - line.setStartStationEndTime(rs.getString("start_station_end_time"));
90   - //line.setEndStation(rs.getInt("end_station"));
91   - line.setEndStationName(rs.getString("end_station_name"));
92   - line.setEndStationFirstTime(rs.getString("end_station_first_time"));
93   - line.setEndStationEndTime(rs.getString("end_station_end_time"));
94   - line.setCompany(rs.getString("company"));
95   - line.setBrancheCompany(rs.getString("branche_company"));
96   - line.setTelephone(rs.getString("telephone"));
97   - line.setLinePlayType(rs.getInt("line_play_type"));
98   - return line;
99   - }
100   -
101   - }
102   -
103   - final class RowMapperStopInfo implements RowMapper<StopInfo> {
104   -
105   - @Override
106   - public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
107   - // TODO Auto-generated method stub
108   - StopInfo stop = new StopInfo();
109   - stop.setId(rs.getInt("id"));
110   - stop.setStationCod(rs.getString("station_cod"));
111   - stop.setStationName(rs.getString("station_name"));
112   - //stop.setStationType(rs.getString("station_type"));
113   - stop.setRoadCoding(rs.getString("road_coding"));
114   - float lon = rs.getFloat("g_lonx");
115   - float lat = rs.getFloat("g_laty");
116   - stop.setPoint(new Point(lon, lat));
117   - stop.setLineId(rs.getInt("line"));
118   - stop.setLineCode(rs.getInt("line_code"));
119   - stop.setDirections(rs.getInt("directions"));
120   - stop.setShapesType(rs.getString("shapes_type"));
121   - stop.setRadius(rs.getInt("radius"));
122   - stop.setPoints(new ArrayList<Point>());
123   - stop.setDistances(rs.getDouble("distances")*1000);
124   - return stop;
125   - }
126   -
127   - }
128   -
129   - @Override
130   - public void afterPropertiesSet() throws Exception {
131   - // TODO Auto-generated method stub
132   - loadBasicData();
133   - }
134   -}
  1 +package com.bsth.server_rs.gps.buffer;
  2 +
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.util.ArrayList;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.InitializingBean;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.jdbc.core.JdbcTemplate;
  14 +import org.springframework.jdbc.core.RowMapper;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import com.bsth.server_rs.gps.entity.LineInfo;
  18 +import com.bsth.server_rs.gps.entity.Point;
  19 +import com.bsth.server_rs.gps.entity.StopInfo;
  20 +
  21 +/**
  22 + * Created by panzhao on 2017/3/30.
  23 + */
  24 +@Component
  25 +public class BasicDataRefreshThread extends Thread implements InitializingBean {
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
  28 +
  29 + @Autowired
  30 + private JdbcTemplate jdbcTemplate;
  31 +
  32 + @Override
  33 + public void run() {
  34 + loadBasicData();
  35 + }
  36 +
  37 + private void loadBasicData() {
  38 + try {
  39 + String qline = "select a.id,in_use,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,shanghai_linecode,line_play_type,up_travel_time,down_travel_time from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0 and a.nature = 'hlwgj'";
  40 + String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,ST_AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code";
  41 + String qcar = "select equipment_code device_id, car_plate plate_no from bsth_c_cars";
  42 +
  43 + List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo());
  44 + List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo());
  45 + List<Map<String, Object>> cars = jdbcTemplate.queryForList(qcar);
  46 +
  47 + // 缓存线路基本信息
  48 + for (LineInfo line : lines) {
  49 + BasicDataBuffer.putLine(line.getLineId(), line);
  50 + }
  51 +
  52 + // 线路信息中添加上下行站点信息
  53 + int oldId = -1;
  54 + LineInfo line = null;
  55 + for (StopInfo stop : stops) {
  56 + if (stop.getLineCode() != oldId) {
  57 + oldId = stop.getLineCode();
  58 + line = BasicDataBuffer.getLineById(oldId);
  59 + }
  60 + if (line != null) {
  61 + if (stop.getDirections() == 0) line.getStopsUp().add(stop);
  62 + else line.getStopsDown().add(stop);
  63 + }
  64 + }
  65 +
  66 + for (Map<String, Object> car : cars) {
  67 + BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no"));
  68 + }
  69 +
  70 + logger.info("基础数据加载成功");
  71 + }catch (Exception e){
  72 + logger.error("基础数据加载失败", e);
  73 + }
  74 + }
  75 +
  76 + final class RowMapperLineInfo implements RowMapper<LineInfo> {
  77 +
  78 + @Override
  79 + public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  80 + // TODO Auto-generated method stub
  81 + LineInfo line = new LineInfo();
  82 + line.setId(rs.getInt("id"));
  83 + line.setInUse(rs.getInt("in_use"));
  84 + line.setLineId(rs.getInt("line_code"));
  85 + line.setLineName(rs.getString("name"));
  86 + //line.setStartStation(rs.getInt("start_station"));
  87 + line.setStartStationName(rs.getString("start_station_name"));
  88 + line.setStartStationFirstTime(rs.getString("start_station_first_time"));
  89 + line.setStartStationEndTime(rs.getString("start_station_end_time"));
  90 + //line.setEndStation(rs.getInt("end_station"));
  91 + line.setEndStationName(rs.getString("end_station_name"));
  92 + line.setEndStationFirstTime(rs.getString("end_station_first_time"));
  93 + line.setEndStationEndTime(rs.getString("end_station_end_time"));
  94 + line.setCompany(rs.getString("company"));
  95 + line.setBrancheCompany(rs.getString("branche_company"));
  96 + line.setTelephone(rs.getString("telephone"));
  97 + line.setLinePlayType(rs.getInt("line_play_type"));
  98 + return line;
  99 + }
  100 +
  101 + }
  102 +
  103 + final class RowMapperStopInfo implements RowMapper<StopInfo> {
  104 +
  105 + @Override
  106 + public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  107 + // TODO Auto-generated method stub
  108 + StopInfo stop = new StopInfo();
  109 + stop.setId(rs.getInt("id"));
  110 + stop.setStationCod(rs.getString("station_cod"));
  111 + stop.setStationName(rs.getString("station_name"));
  112 + //stop.setStationType(rs.getString("station_type"));
  113 + stop.setRoadCoding(rs.getString("road_coding"));
  114 + float lon = rs.getFloat("g_lonx");
  115 + float lat = rs.getFloat("g_laty");
  116 + stop.setPoint(new Point(lon, lat));
  117 + stop.setLineId(rs.getInt("line"));
  118 + stop.setLineCode(rs.getInt("line_code"));
  119 + stop.setDirections(rs.getInt("directions"));
  120 + stop.setShapesType(rs.getString("shapes_type"));
  121 + stop.setRadius(rs.getInt("radius"));
  122 + stop.setPoints(new ArrayList<Point>());
  123 + stop.setDistances(rs.getDouble("distances")*1000);
  124 + return stop;
  125 + }
  126 +
  127 + }
  128 +
  129 + @Override
  130 + public void afterPropertiesSet() throws Exception {
  131 + // TODO Auto-generated method stub
  132 + loadBasicData();
  133 + }
  134 +}
... ...
src/main/resources/application-prod.properties
... ... @@ -7,8 +7,8 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
7 7 #DATABASE
8 8 spring.jpa.database= MYSQL
9 9 spring.jpa.show-sql= false
10   -spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11   -spring.datasource.url= jdbc:mysql://10.10.2.20/control_dy?useUnicode=true&characterEncoding=utf-8&useSSL=false
  10 +spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver
  11 +spring.datasource.url= jdbc:mysql://127.0.0.1/control_dy?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 12 spring.datasource.username= root
13 13 spring.datasource.password= root2jsp
14 14 #DATASOURCE
... ... @@ -25,11 +25,11 @@ spring.datasource.validation-query=select 1
25 25  
26 26 #REDIS
27 27 spring.redis.database=0
28   -spring.redis.host=10.10.2.20
  28 +spring.redis.host=127.0.0.1
29 29 spring.redis.password=bsth_control_001
30 30 spring.redis.port=28008
31 31  
32   -http.control.service_data_url= http://10.10.2.20:9088/companyService
  32 +http.control.service_data_url= http://127.0.0.1:9088/companyService
33 33 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki
34 34  
35   -http.gps.real.url= http://10.10.2.20:8080/transport_server/rtgps/
36 35 \ No newline at end of file
  36 +http.gps.real.url= http://127.0.0.1:8080/transport_server/rtgps/
37 37 \ No newline at end of file
... ...
src/main/resources/ms-jdbc.properties
... ... @@ -3,7 +3,7 @@
3 3 #ms.mysql.username= root
4 4 #ms.mysql.password= panzhao
5 5  
6   -ms.mysql.driver= com.mysql.jdbc.Driver
7   -ms.mysql.url= jdbc:mysql://10.10.2.20/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false
  6 +ms.mysql.driver= com.mysql.cj.jdbc.Driver
  7 +ms.mysql.url= jdbc:mysql://127.0.0.1/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false
8 8 ms.mysql.username= root
9 9 ms.mysql.password= root2jsp
10 10 \ No newline at end of file
... ...
src/main/resources/xxfb-jdbc.properties
... ... @@ -3,7 +3,7 @@
3 3 #xxfb.mysql.username= root
4 4 #xxfb.mysql.password= panzhao
5 5  
6   -xxfb.mysql.driver= com.mysql.jdbc.Driver
7   -xxfb.mysql.url= jdbc:mysql://10.10.2.20/info_publish?useUnicode=true&characterEncoding=utf-8&useSSL=false
  6 +xxfb.mysql.driver= com.mysql.cj.jdbc.Driver
  7 +xxfb.mysql.url= jdbc:mysql://127.0.0.1/info_publish?useUnicode=true&characterEncoding=utf-8&useSSL=false
8 8 xxfb.mysql.username= root
9 9 xxfb.mysql.password= root2jsp
10 10 \ No newline at end of file
... ...