Commit 4790851119023284a5bd58948e05981f3f115496

Authored by 王通
1 parent 2dd32eb3

1.zyl接口加入电量信息

src/main/java/com/bsth/server_rs/directive/DirectiveRestService.java
@@ -71,13 +71,14 @@ public class DirectiveRestService implements InitializingBean { @@ -71,13 +71,14 @@ public class DirectiveRestService implements InitializingBean {
71 71
72 return result; 72 return result;
73 } 73 }
74 - if (plate.contains("-")) { 74 + if (!plate.contains("-")) {
75 plate = BasicDataBuffer.getIncodeByIncode(plate); 75 plate = BasicDataBuffer.getIncodeByIncode(plate);
76 } 76 }
  77 + String incode = plate;
77 plate = BasicDataBuffer.getPlateByIncode(plate); 78 plate = BasicDataBuffer.getPlateByIncode(plate);
78 map.put("plate", plate); 79 map.put("plate", plate);
79 ZylInfo zylInfo = new ZylInfo(lineId, trainNum); 80 ZylInfo zylInfo = new ZylInfo(lineId, trainNum);
80 - plate2zyl.put(plate, zylInfo); 81 + plate2zyl.put(incode, zylInfo);
81 map.put("sender", "中运量接口@系统"); 82 map.put("sender", "中运量接口@系统");
82 StringBuilder sb = HttpClientUtils.post(url, JSON.toJSONString(map)); 83 StringBuilder sb = HttpClientUtils.post(url, JSON.toJSONString(map));
83 }catch (Exception e){ 84 }catch (Exception e){
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataBuffer.java
@@ -23,15 +23,19 @@ public class BasicDataBuffer { @@ -23,15 +23,19 @@ public class BasicDataBuffer {
23 private static Map<String, String> INCODE_PLATE = new HashMap<String, String>(); 23 private static Map<String, String> INCODE_PLATE = new HashMap<String, String>();
24 24
25 private static Map<String, String> INCODE_INCODE = new HashMap<>(); 25 private static Map<String, String> INCODE_INCODE = new HashMap<>();
  26 +
  27 + private static Map<String, String> INCODE_VIN = new HashMap<>();
26 28
27 public static void putLine(Integer lineId, LineInfo info) { 29 public static void putLine(Integer lineId, LineInfo info) {
28 LINEID_INFO.put(lineId, info); 30 LINEID_INFO.put(lineId, info);
29 } 31 }
30 32
31 - public static void putCar(String deviceId, String plateNo, String insideCode) { 33 + public static void putCar(String deviceId, String plateNo, String insideCode, String vin) {
32 DEVICE_PLATE.put(deviceId, plateNo); 34 DEVICE_PLATE.put(deviceId, plateNo);
33 DEVICE_INCODE.put(deviceId, insideCode); 35 DEVICE_INCODE.put(deviceId, insideCode);
34 INCODE_PLATE.put(insideCode, plateNo); 36 INCODE_PLATE.put(insideCode, plateNo);
  37 + INCODE_VIN.put(insideCode, vin);
  38 +
35 if (insideCode != null) { 39 if (insideCode != null) {
36 INCODE_INCODE.put(insideCode.replaceAll("-", ""), insideCode); 40 INCODE_INCODE.put(insideCode.replaceAll("-", ""), insideCode);
37 } 41 }
@@ -52,6 +56,10 @@ public class BasicDataBuffer { @@ -52,6 +56,10 @@ public class BasicDataBuffer {
52 public static String getPlateByIncode(String insideCode) { 56 public static String getPlateByIncode(String insideCode) {
53 return INCODE_PLATE.get(insideCode); 57 return INCODE_PLATE.get(insideCode);
54 } 58 }
  59 +
  60 + public static String getVinByIncode(String insideCode) {
  61 + return INCODE_VIN.get(insideCode);
  62 + }
55 63
56 public static Set<Integer> getAllLine() { 64 public static Set<Integer> getAllLine() {
57 return LINEID_INFO.keySet(); 65 return LINEID_INFO.keySet();
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataRefreshThread.java
@@ -38,7 +38,7 @@ public class BasicDataRefreshThread extends Thread implements InitializingBean { @@ -38,7 +38,7 @@ public class BasicDataRefreshThread extends Thread implements InitializingBean {
38 try { 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'"; 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"; 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, inside_code from bsth_c_cars"; 41 + String qcar = "select equipment_code device_id, car_plate plate_no, inside_code, vin from bsth_c_cars";
42 42
43 List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo()); 43 List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo());
44 List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo()); 44 List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo());
@@ -64,7 +64,7 @@ public class BasicDataRefreshThread extends Thread implements InitializingBean { @@ -64,7 +64,7 @@ public class BasicDataRefreshThread extends Thread implements InitializingBean {
64 } 64 }
65 65
66 for (Map<String, Object> car : cars) { 66 for (Map<String, Object> car : cars) {
67 - BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no"), (String)car.get("inside_code")); 67 + BasicDataBuffer.putCar((String) car.get("device_id"), (String) car.get("plate_no"), (String) car.get("inside_code"), (String) car.get("vin"));
68 } 68 }
69 69
70 logger.info("基础数据加载成功"); 70 logger.info("基础数据加载成功");
src/main/java/com/bsth/server_rs/gps/buffer/GpsRefreshThread.java
@@ -2,6 +2,7 @@ package com.bsth.server_rs.gps.buffer; @@ -2,6 +2,7 @@ package com.bsth.server_rs.gps.buffer;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.entity.VehicleData;
5 import com.bsth.entity.ZylInfo; 6 import com.bsth.entity.ZylInfo;
6 import com.bsth.server_rs.directive.DirectiveRestService; 7 import com.bsth.server_rs.directive.DirectiveRestService;
7 import com.bsth.server_rs.gps.entity.GpsEntity; 8 import com.bsth.server_rs.gps.entity.GpsEntity;
@@ -67,9 +68,13 @@ public class GpsRefreshThread extends Thread{ @@ -67,9 +68,13 @@ public class GpsRefreshThread extends Thread{
67 rs = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class); 68 rs = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
68 69
69 for (GpsEntity gps : rs) { 70 for (GpsEntity gps : rs) {
70 - String incode = BasicDataBuffer.getIncodeByDevice(gps.getDeviceId()); 71 + String incode = BasicDataBuffer.getIncodeByDevice(gps.getDeviceId()), vin = BasicDataBuffer.getVinByIncode(incode);
71 if (incode != null) { 72 if (incode != null) {
72 gps.setPlate(incode); 73 gps.setPlate(incode);
  74 + VehicleData vehicleData = VehicleRealDataBuffer.getVehicleData(vin);
  75 + if (vehicleData != null) {
  76 + gps.setEnergy(vehicleData.getSoc());
  77 + }
73 //gps.setPlate(incode.replace("-", "")); 78 //gps.setPlate(incode.replace("-", ""));
74 } 79 }
75 if (gps.getPlate() == null) { 80 if (gps.getPlate() == null) {
src/main/java/com/bsth/server_rs/gps/entity/GpsEntity.java
@@ -81,6 +81,8 @@ public class GpsEntity implements Serializable{ @@ -81,6 +81,8 @@ public class GpsEntity implements Serializable{
81 81
82 private int zylTrainNum; 82 private int zylTrainNum;
83 83
  84 + private int energy;
  85 +
84 public Integer getCompanyCode() { 86 public Integer getCompanyCode() {
85 return companyCode; 87 return companyCode;
86 } 88 }
@@ -272,4 +274,12 @@ public class GpsEntity implements Serializable{ @@ -272,4 +274,12 @@ public class GpsEntity implements Serializable{
272 public void setZylTrainNum(int zylTrainNum) { 274 public void setZylTrainNum(int zylTrainNum) {
273 this.zylTrainNum = zylTrainNum; 275 this.zylTrainNum = zylTrainNum;
274 } 276 }
  277 +
  278 + public int getEnergy() {
  279 + return energy;
  280 + }
  281 +
  282 + public void setEnergy(int energy) {
  283 + this.energy = energy;
  284 + }
275 } 285 }
src/main/java/com/bsth/server_rs/schedule/SchedulePlanService.java
@@ -17,7 +17,6 @@ import javax.ws.rs.*; @@ -17,7 +17,6 @@ import javax.ws.rs.*;
17 import javax.ws.rs.core.MediaType; 17 import javax.ws.rs.core.MediaType;
18 import java.sql.PreparedStatement; 18 import java.sql.PreparedStatement;
19 import java.sql.SQLException; 19 import java.sql.SQLException;
20 -import java.util.ArrayList;  
21 import java.util.HashMap; 20 import java.util.HashMap;
22 import java.util.List; 21 import java.util.List;
23 import java.util.Map; 22 import java.util.Map;
@@ -35,10 +34,8 @@ public class SchedulePlanService { @@ -35,10 +34,8 @@ public class SchedulePlanService {
35 private JdbcTemplate jdbcTemplate; 34 private JdbcTemplate jdbcTemplate;
36 35
37 @POST 36 @POST
38 - public Map<String, Object> save(ScheduleRealInfo real) throws JsonProcessingException { 37 + public Map<String, Object> save(final List<ScheduleRealInfo> reals) throws JsonProcessingException {
39 Map<String, Object> result = new HashMap<>(); 38 Map<String, Object> result = new HashMap<>();
40 - final List<ScheduleRealInfo> reals = new ArrayList<>();  
41 - reals.add(real);  
42 log.error(mapper.writeValueAsString(reals)); 39 log.error(mapper.writeValueAsString(reals));
43 jdbcTemplate.batchUpdate("insert into zyl.bsth_c_s_sp_real_info (schedule_date_str,xl_name,lp_name,cl_zbh,jsy,spy," + 40 jdbcTemplate.batchUpdate("insert into zyl.bsth_c_s_sp_real_info (schedule_date_str,xl_name,lp_name,cl_zbh,jsy,spy," +
44 "direction,qdz_name,zdz_name,fcsj,fcno,jhlc,bcsj,bc_type) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { 41 "direction,qdz_name,zdz_name,fcsj,fcno,jhlc,bcsj,bc_type) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {
src/main/java/com/bsth/server_rs/schedule/ScheduleRealService.java
@@ -19,7 +19,6 @@ import javax.ws.rs.Produces; @@ -19,7 +19,6 @@ import javax.ws.rs.Produces;
19 import javax.ws.rs.core.MediaType; 19 import javax.ws.rs.core.MediaType;
20 import java.sql.PreparedStatement; 20 import java.sql.PreparedStatement;
21 import java.sql.SQLException; 21 import java.sql.SQLException;
22 -import java.util.ArrayList;  
23 import java.util.HashMap; 22 import java.util.HashMap;
24 import java.util.List; 23 import java.util.List;
25 import java.util.Map; 24 import java.util.Map;
@@ -38,12 +37,10 @@ public class ScheduleRealService { @@ -38,12 +37,10 @@ public class ScheduleRealService {
38 37
39 @POST 38 @POST
40 @Path("/leave") 39 @Path("/leave")
41 - public Map<String, Object> leave(ScheduleExec exec) throws JsonProcessingException { 40 + public Map<String, Object> leave(final List<ScheduleExec> execs) throws JsonProcessingException {
42 Map<String, Object> result = new HashMap<>(); 41 Map<String, Object> result = new HashMap<>();
43 - final List<ScheduleExec> execs = new ArrayList<>();  
44 - execs.add(exec);  
45 log.error(mapper.writeValueAsString(execs)); 42 log.error(mapper.writeValueAsString(execs));
46 - jdbcTemplate.batchUpdate("update zyl.bsth_c_s_sp_real_info set fcsj_actual = ? where xl_name = ? and cl_zbh = ? and lp_name = ? and fcsj = ?", new BatchPreparedStatementSetter() { 43 + jdbcTemplate.batchUpdate("update zyl.bsth_c_s_sp_info_real set fcsj_actual = ? where xl_name = ? and cl_zbh = ? and lp_name = ? and fcsj = ?", new BatchPreparedStatementSetter() {
47 @Override 44 @Override
48 public void setValues(PreparedStatement ps, int i) throws SQLException { 45 public void setValues(PreparedStatement ps, int i) throws SQLException {
49 ScheduleExec scheduleExec = execs.get(i); 46 ScheduleExec scheduleExec = execs.get(i);
@@ -67,12 +64,10 @@ public class ScheduleRealService { @@ -67,12 +64,10 @@ public class ScheduleRealService {
67 64
68 @POST 65 @POST
69 @Path("/arrival") 66 @Path("/arrival")
70 - public Map<String, Object> arrival(ScheduleExec exec) throws JsonProcessingException { 67 + public Map<String, Object> arrival(final List<ScheduleExec> execs) throws JsonProcessingException {
71 Map<String, Object> result = new HashMap<>(); 68 Map<String, Object> result = new HashMap<>();
72 - final List<ScheduleExec> execs = new ArrayList<>();  
73 - execs.add(exec);  
74 log.error(mapper.writeValueAsString(execs)); 69 log.error(mapper.writeValueAsString(execs));
75 - jdbcTemplate.batchUpdate("update zyl.bsth_c_s_sp_real_info set zdsj_actual = ? where xl_name = ? and cl_zbh = ? and lp_name = ? and fcsj = ?", new BatchPreparedStatementSetter() { 70 + jdbcTemplate.batchUpdate("update zyl.bsth_c_s_sp_info_real set zdsj_actual = ? where xl_name = ? and cl_zbh = ? and lp_name = ? and fcsj = ?", new BatchPreparedStatementSetter() {
76 @Override 71 @Override
77 public void setValues(PreparedStatement ps, int i) throws SQLException { 72 public void setValues(PreparedStatement ps, int i) throws SQLException {
78 ScheduleExec scheduleExec = execs.get(i); 73 ScheduleExec scheduleExec = execs.get(i);
@@ -96,12 +91,10 @@ public class ScheduleRealService { @@ -96,12 +91,10 @@ public class ScheduleRealService {
96 91
97 @POST 92 @POST
98 @Path("/destroy") 93 @Path("/destroy")
99 - public Map<String, Object> destroy(ScheduleExec exec) throws JsonProcessingException { 94 + public Map<String, Object> destroy(final List<ScheduleExec> execs) throws JsonProcessingException {
100 Map<String, Object> result = new HashMap<>(); 95 Map<String, Object> result = new HashMap<>();
101 - final List<ScheduleExec> execs = new ArrayList<>();  
102 - execs.add(exec);  
103 log.error(mapper.writeValueAsString(execs)); 96 log.error(mapper.writeValueAsString(execs));
104 - jdbcTemplate.batchUpdate("update zyl.bsth_c_s_sp_real_info set status = -1 where xl_name = ? and cl_zbh = ? and lp_name = ? and fcsj = ?", new BatchPreparedStatementSetter() { 97 + jdbcTemplate.batchUpdate("update zyl.bsth_c_s_sp_info_real set status = -1 where xl_name = ? and cl_zbh = ? and lp_name = ? and fcsj = ?", new BatchPreparedStatementSetter() {
105 @Override 98 @Override
106 public void setValues(PreparedStatement ps, int i) throws SQLException { 99 public void setValues(PreparedStatement ps, int i) throws SQLException {
107 ScheduleExec scheduleExec = execs.get(i); 100 ScheduleExec scheduleExec = execs.get(i);
src/main/resources/application-prod.properties
@@ -23,6 +23,13 @@ spring.datasource.test-on-return=true @@ -23,6 +23,13 @@ spring.datasource.test-on-return=true
23 spring.datasource.test-while-idle=true 23 spring.datasource.test-while-idle=true
24 spring.datasource.validation-query=select 1 24 spring.datasource.validation-query=select 1
25 25
  26 +#kafka
  27 +spring.kafka.bootstrap-servers= 10.10.200.203:9092
  28 +spring.kafka.consumer.group-id= zyl_group
  29 +spring.kafka.consumer.auto-offset-reset= latest
  30 +spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer
  31 +spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer
  32 +
26 http.control.service_data_url= http://10.10.150.103:9088/companyService 33 http.control.service_data_url= http://10.10.150.103:9088/companyService
27 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki 34 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki
28 35