Commit 5b362f5c373c3a6ff56082e054863fad6f3d87f3

Authored by 王通
1 parent 1af20aca

1.加入停车场、发车信息接口

src/main/java/com/bsth/CXFConfig.java
1   -package com.bsth;
2   -
3   -
4   -import com.bsth.server_rs.AuthorizeInterceptor_IN;
5   -import com.bsth.server_rs.base_info.car.CarRestService;
6   -import com.bsth.server_rs.base_info.line.LineRestService;
7   -import com.bsth.server_rs.base_info.person.PersonRestService;
8   -import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
9   -import com.bsth.server_rs.base_info.section.LD_SectionRestService;
10   -import com.bsth.server_rs.base_info.station.StationRestService;
11   -import com.bsth.server_rs.bigdata.BigdataService;
12   -import com.bsth.server_rs.bigdata.BigscreenService;
13   -import com.bsth.server_rs.destroy.DestroyDetailRestService;
14   -import com.bsth.server_rs.directive.DirectiveRestService;
15   -import com.bsth.server_rs.electric.ElectricService;
16   -import com.bsth.server_rs.exception.AesExceptionMapper;
17   -import com.bsth.server_rs.gps.GpsRestService;
18   -import com.bsth.server_rs.logs.RealLogRestService;
19   -import com.bsth.server_rs.rate.RateService;
20   -import com.bsth.server_rs.schedule.plan.SchedulePlanService;
21   -import com.bsth.server_rs.schedule.real.ScheduleRealService;
22   -import com.bsth.server_rs.schedule.real.StaffViewRealService;
23   -import com.bsth.server_rs.waybill.WaybillRestService;
24   -import com.bsth.server_ws.attendance.AttendanceServiceSoap;
25   -import com.bsth.server_ws.electric_oil.OilServiceSoap;
26   -import com.bsth.server_ws.park_station.CompanyServiceSoap;
27   -import com.bsth.server_ws.waybill.LD_ServiceSoap;
28   -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
29   -import org.apache.cxf.Bus;
30   -import org.apache.cxf.bus.spring.SpringBus;
31   -import org.apache.cxf.endpoint.Server;
32   -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
33   -import org.apache.cxf.jaxws.EndpointImpl;
34   -import org.apache.cxf.transport.servlet.CXFServlet;
35   -import org.springframework.beans.factory.annotation.Autowired;
36   -import org.springframework.boot.web.servlet.ServletRegistrationBean;
37   -import org.springframework.context.annotation.Bean;
38   -import org.springframework.context.annotation.Configuration;
39   -import org.springframework.core.Ordered;
40   -
41   -import javax.xml.ws.Endpoint;
42   -import java.util.Arrays;
43   -
44   -/**
45   - * Created by panzhao on 2017/3/9.
46   - */
47   -@Configuration
48   -public class CXFConfig {
49   -
50   - @Bean(name = Bus.DEFAULT_BUS_ID)
51   - public SpringBus springBus() {
52   - return new SpringBus();
53   - }
54   -
55   - @Autowired
56   - CompanyServiceSoap companyServiceSoap;
57   - @Autowired
58   - LD_ServiceSoap ld_serviceSoap;
59   - @Autowired
60   - AttendanceServiceSoap attendanceServiceSoap;
61   - @Autowired
62   - OilServiceSoap oilServiceSoap;
63   -
64   - @Bean
65   - public Endpoint companyEndpoint() {
66   - EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
67   - endpoint.publish("/CompanyService");
68   - //endpoint.getInInterceptors().add(new AuthInterceptor());
69   - return endpoint;
70   - }
71   -
72   - @Bean
73   - public Endpoint ldServiceEndpoint() {
74   - EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
75   - endpoint.publish("/LD_Service");
76   - //endpoint.getInInterceptors().add(new AuthInterceptor());
77   - return endpoint;
78   - }
79   -
80   - @Bean
81   - public Endpoint attendanceServiceEndpoint() {
82   - EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
83   - endpoint.publish("/attendanceService");
84   - //endpoint.getInInterceptors().add(new AuthInterceptor());
85   - return endpoint;
86   - }
87   -
88   - @Bean
89   - public Endpoint electricServiceEndpoint() {
90   - EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
91   - endpoint.publish("/oilServiceSoap");
92   - //endpoint.getInInterceptors().add(new AuthInterceptor());
93   - return endpoint;
94   - }
95   -
96   - @Autowired
97   - ScheduleRealService scheduleRealService;
98   - @Autowired
99   - StationRestService stationRestService;
100   - @Autowired
101   - LD_SectionRestService ldSectionRestService;
102   - @Autowired
103   - SchedulePlanService schedulePlanService;
104   - @Autowired
105   - RealLogRestService realLogRestService;
106   - @Autowired
107   - GpsRestService gpsRestService;
108   - @Autowired
109   - WaybillRestService waybillRestService;
110   - @Autowired
111   - DirectiveRestService directiveRestService;
112   - @Autowired
113   - LD_RoadSpeedRestService ld_roadSpeedRestService;
114   - @Autowired
115   - ElectricService electricService;
116   - @Autowired
117   - BigdataService bigdataService;
118   - @Autowired
119   - BigscreenService bigscreenService;
120   - @Autowired
121   - StaffViewRealService staffViewRealService;
122   - @Autowired
123   - RateService rateService;
124   - @Autowired
125   - private DestroyDetailRestService destroyDetailRestService;
126   -
127   - @Bean
128   - public Server rsServer() {
129   - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
130   - endpoint.setBus(springBus());
131   - endpoint.setAddress("/rest");
132   - endpoint.setServiceBeans(Arrays.<Object>asList(
133   - new LineRestService(),
134   - new CarRestService(),
135   - new PersonRestService(),
136   - gpsRestService,
137   - waybillRestService,
138   - scheduleRealService,
139   - stationRestService,
140   - ldSectionRestService,
141   - schedulePlanService,
142   - realLogRestService,
143   - directiveRestService,
144   - ld_roadSpeedRestService,
145   - electricService,
146   - staffViewRealService,
147   - bigdataService,
148   - bigscreenService,
149   - rateService,
150   - destroyDetailRestService));
151   - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
152   - //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
153   - endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
154   - return endpoint.create();
155   - }
156   -
157   - @Bean
158   - public ServletRegistrationBean servletRegistrationBean() {
159   - ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
160   - bean.setLoadOnStartup(0);
161   - bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
162   - return bean;
163   - }
164   -}
  1 +package com.bsth;
  2 +
  3 +
  4 +import com.bsth.server_rs.AuthorizeInterceptor_IN;
  5 +import com.bsth.server_rs.base_info.car.CarRestService;
  6 +import com.bsth.server_rs.base_info.carpark.CarparkRestService;
  7 +import com.bsth.server_rs.base_info.line.LineRestService;
  8 +import com.bsth.server_rs.base_info.person.PersonRestService;
  9 +import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
  10 +import com.bsth.server_rs.base_info.section.LD_SectionRestService;
  11 +import com.bsth.server_rs.base_info.station.StationRestService;
  12 +import com.bsth.server_rs.bigdata.BigdataService;
  13 +import com.bsth.server_rs.bigdata.BigscreenService;
  14 +import com.bsth.server_rs.departure.DepartureRestService;
  15 +import com.bsth.server_rs.destroy.DestroyDetailRestService;
  16 +import com.bsth.server_rs.directive.DirectiveRestService;
  17 +import com.bsth.server_rs.electric.ElectricService;
  18 +import com.bsth.server_rs.exception.AesExceptionMapper;
  19 +import com.bsth.server_rs.gps.GpsRestService;
  20 +import com.bsth.server_rs.logs.RealLogRestService;
  21 +import com.bsth.server_rs.rate.RateService;
  22 +import com.bsth.server_rs.schedule.plan.SchedulePlanService;
  23 +import com.bsth.server_rs.schedule.real.ScheduleRealService;
  24 +import com.bsth.server_rs.schedule.real.StaffViewRealService;
  25 +import com.bsth.server_rs.waybill.WaybillRestService;
  26 +import com.bsth.server_ws.attendance.AttendanceServiceSoap;
  27 +import com.bsth.server_ws.electric_oil.OilServiceSoap;
  28 +import com.bsth.server_ws.park_station.CompanyServiceSoap;
  29 +import com.bsth.server_ws.waybill.LD_ServiceSoap;
  30 +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
  31 +import org.apache.cxf.Bus;
  32 +import org.apache.cxf.bus.spring.SpringBus;
  33 +import org.apache.cxf.endpoint.Server;
  34 +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
  35 +import org.apache.cxf.jaxws.EndpointImpl;
  36 +import org.apache.cxf.transport.servlet.CXFServlet;
  37 +import org.springframework.beans.factory.annotation.Autowired;
  38 +import org.springframework.boot.web.servlet.ServletRegistrationBean;
  39 +import org.springframework.context.annotation.Bean;
  40 +import org.springframework.context.annotation.Configuration;
  41 +import org.springframework.core.Ordered;
  42 +
  43 +import javax.xml.ws.Endpoint;
  44 +import java.util.Arrays;
  45 +
  46 +/**
  47 + * Created by panzhao on 2017/3/9.
  48 + */
  49 +@Configuration
  50 +public class CXFConfig {
  51 +
  52 + @Bean(name = Bus.DEFAULT_BUS_ID)
  53 + public SpringBus springBus() {
  54 + return new SpringBus();
  55 + }
  56 +
  57 + @Autowired
  58 + CompanyServiceSoap companyServiceSoap;
  59 + @Autowired
  60 + LD_ServiceSoap ld_serviceSoap;
  61 + @Autowired
  62 + AttendanceServiceSoap attendanceServiceSoap;
  63 + @Autowired
  64 + OilServiceSoap oilServiceSoap;
  65 +
  66 + @Bean
  67 + public Endpoint companyEndpoint() {
  68 + EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
  69 + endpoint.publish("/CompanyService");
  70 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  71 + return endpoint;
  72 + }
  73 +
  74 + @Bean
  75 + public Endpoint ldServiceEndpoint() {
  76 + EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
  77 + endpoint.publish("/LD_Service");
  78 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  79 + return endpoint;
  80 + }
  81 +
  82 + @Bean
  83 + public Endpoint attendanceServiceEndpoint() {
  84 + EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
  85 + endpoint.publish("/attendanceService");
  86 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  87 + return endpoint;
  88 + }
  89 +
  90 + @Bean
  91 + public Endpoint electricServiceEndpoint() {
  92 + EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
  93 + endpoint.publish("/oilServiceSoap");
  94 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  95 + return endpoint;
  96 + }
  97 +
  98 + @Autowired
  99 + ScheduleRealService scheduleRealService;
  100 + @Autowired
  101 + StationRestService stationRestService;
  102 + @Autowired
  103 + LD_SectionRestService ldSectionRestService;
  104 + @Autowired
  105 + SchedulePlanService schedulePlanService;
  106 + @Autowired
  107 + RealLogRestService realLogRestService;
  108 + @Autowired
  109 + GpsRestService gpsRestService;
  110 + @Autowired
  111 + WaybillRestService waybillRestService;
  112 + @Autowired
  113 + DirectiveRestService directiveRestService;
  114 + @Autowired
  115 + LD_RoadSpeedRestService ld_roadSpeedRestService;
  116 + @Autowired
  117 + ElectricService electricService;
  118 + @Autowired
  119 + BigdataService bigdataService;
  120 + @Autowired
  121 + BigscreenService bigscreenService;
  122 + @Autowired
  123 + StaffViewRealService staffViewRealService;
  124 + @Autowired
  125 + RateService rateService;
  126 + @Autowired
  127 + private DestroyDetailRestService destroyDetailRestService;
  128 + @Autowired
  129 + private CarparkRestService carparkRestService;
  130 + @Autowired
  131 + private DepartureRestService departureRestService;
  132 +
  133 + @Bean
  134 + public Server rsServer() {
  135 + JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
  136 + endpoint.setBus(springBus());
  137 + endpoint.setAddress("/rest");
  138 + endpoint.setServiceBeans(Arrays.<Object>asList(
  139 + new LineRestService(),
  140 + new CarRestService(),
  141 + new PersonRestService(),
  142 + gpsRestService,
  143 + waybillRestService,
  144 + scheduleRealService,
  145 + stationRestService,
  146 + ldSectionRestService,
  147 + schedulePlanService,
  148 + realLogRestService,
  149 + directiveRestService,
  150 + ld_roadSpeedRestService,
  151 + electricService,
  152 + staffViewRealService,
  153 + bigdataService,
  154 + bigscreenService,
  155 + rateService,
  156 + destroyDetailRestService,
  157 + carparkRestService,
  158 + departureRestService));
  159 + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
  160 + //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
  161 + endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
  162 + return endpoint.create();
  163 + }
  164 +
  165 + @Bean
  166 + public ServletRegistrationBean servletRegistrationBean() {
  167 + ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
  168 + bean.setLoadOnStartup(0);
  169 + bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  170 + return bean;
  171 + }
  172 +}
... ...
src/main/java/com/bsth/server_rs/base_info/carpark/Carpark.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.carpark;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public class Carpark {
  7 +
  8 + /**
  9 + * 公司代码(大运营公司)
  10 + */
  11 + private String company;
  12 +
  13 + /**
  14 + * 停车场代码
  15 + */
  16 + private String parkCode;
  17 +
  18 + /**
  19 + * 停车场名称
  20 + */
  21 + private String parkName;
  22 +
  23 + /**
  24 + * 停车场空间坐标信息
  25 + */
  26 + private String gParkPoint;
  27 +
  28 + /**
  29 + * 描述
  30 + */
  31 + private String description;
  32 +
  33 + public String getCompany() {
  34 + return company;
  35 + }
  36 +
  37 + public void setCompany(String company) {
  38 + this.company = company;
  39 + }
  40 +
  41 + public String getParkCode() {
  42 + return parkCode;
  43 + }
  44 +
  45 + public void setParkCode(String parkCode) {
  46 + this.parkCode = parkCode;
  47 + }
  48 +
  49 + public String getParkName() {
  50 + return parkName;
  51 + }
  52 +
  53 + public void setParkName(String parkName) {
  54 + this.parkName = parkName;
  55 + }
  56 +
  57 + public String getgParkPoint() {
  58 + return gParkPoint;
  59 + }
  60 +
  61 + public void setgParkPoint(String gParkPoint) {
  62 + this.gParkPoint = gParkPoint;
  63 + }
  64 +
  65 + public String getDescription() {
  66 + return description;
  67 + }
  68 +
  69 + public void setDescription(String description) {
  70 + this.description = description;
  71 + }
  72 +}
... ...
src/main/java/com/bsth/server_rs/base_info/carpark/CarparkRestService.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.carpark;
  2 +
  3 +import com.bsth.server_rs.base_info.carpark.buffer.CarparkBufferData;
  4 +
  5 +import javax.ws.rs.*;
  6 +import javax.ws.rs.core.MediaType;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @Author hill
  11 + */
  12 +@Path("/carpark")
  13 +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  14 +public class CarparkRestService {
  15 +
  16 + @GET
  17 + @Path("/all")
  18 + public List<Carpark> findAll(){
  19 + return CarparkBufferData.findAll();
  20 + }
  21 +
  22 + @GET
  23 + @Path("/company/{companyId}")
  24 + public List<Carpark> findByCompany(@PathParam("companyId") String companyId) {
  25 + return companyId.equals("-9999") ? CarparkBufferData.findAll() : CarparkBufferData.findByCompany(companyId);
  26 + }
  27 +
  28 + @GET
  29 + @Path("/{parkCode}")
  30 + public Carpark findOne(@PathParam("parkCode") String parkCode) {
  31 + return CarparkBufferData.findOne(parkCode);
  32 + }
  33 +}
... ...
src/main/java/com/bsth/server_rs/base_info/carpark/buffer/CarparkBufferData.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.carpark.buffer;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.server_rs.base_info.car.Car;
  5 +import com.bsth.server_rs.base_info.car.buffer.CarRefreshThread;
  6 +import com.bsth.server_rs.base_info.carpark.Carpark;
  7 +import com.bsth.server_rs.base_info.dto.BusCardDto;
  8 +import com.google.common.collect.ArrayListMultimap;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.boot.CommandLineRunner;
  11 +import org.springframework.core.annotation.Order;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.*;
  15 +import java.util.concurrent.TimeUnit;
  16 +
  17 +/**
  18 + * 车辆数据缓存
  19 + * @Author hill
  20 + */
  21 +@Component
  22 +@Order(7)
  23 +public class CarparkBufferData implements CommandLineRunner {
  24 +
  25 + private static List<Carpark> data;
  26 + private static Map<String, Carpark> code2park;
  27 + private static ArrayListMultimap<String, Carpark> companyListMap;
  28 +
  29 + @Autowired
  30 + CarparkRefreshThread carparkRefreshThread;
  31 +
  32 + public static List<Carpark> findAll(){
  33 + return data;
  34 + }
  35 +
  36 + public static Carpark findOne(String parkCode){
  37 + return code2park.get(parkCode);
  38 + }
  39 +
  40 + public static List<Carpark> findByCompany(String company){
  41 + return companyListMap.get(company);
  42 + }
  43 +
  44 + public static void replaceAll(List<Carpark> newData){
  45 + data = newData;
  46 + Map<String, Carpark> code2parkCopy = new HashMap<>();
  47 + ArrayListMultimap<String, Carpark> listMap = ArrayListMultimap.create();
  48 +
  49 + for(Carpark carpark : data){
  50 + code2parkCopy.put(carpark.getParkCode(), carpark);
  51 + listMap.put(carpark.getCompany(), carpark);
  52 + }
  53 +
  54 + code2park = code2parkCopy;
  55 + companyListMap = listMap;
  56 + }
  57 +
  58 + @Override
  59 + public void run(String... strings) throws Exception {
  60 + Application.mainServices.scheduleWithFixedDelay(carparkRefreshThread, 10, 60 * 60, TimeUnit.SECONDS);
  61 + }
  62 +}
... ...
src/main/java/com/bsth/server_rs/base_info/carpark/buffer/CarparkRefreshThread.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.carpark.buffer;
  2 +
  3 +import com.bsth.server_rs.base_info.car.Car;
  4 +import com.bsth.server_rs.base_info.car.buffer.CarBufferData;
  5 +import com.bsth.server_rs.base_info.carpark.Carpark;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  10 +import org.springframework.jdbc.core.JdbcTemplate;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import java.util.ArrayList;
  14 +import java.util.HashMap;
  15 +import java.util.List;
  16 +import java.util.Map;
  17 +
  18 +/**
  19 + * @author hill
  20 + */
  21 +@Component
  22 +public class CarparkRefreshThread extends Thread{
  23 +
  24 + @Autowired
  25 + JdbcTemplate jdbcTemplate;
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
  28 +
  29 + @Override
  30 + public void run() {
  31 +
  32 + try {
  33 +
  34 + List<Carpark> list = jdbcTemplate.query("select * from bsth_c_car_park where destroy = 0"
  35 + , BeanPropertyRowMapper.newInstance(Carpark.class));
  36 +
  37 + Map<String, Carpark> map = new HashMap<>();
  38 + //过滤数据,多条线路配车的保留一条
  39 + for(Carpark c : list){
  40 + map.put(c.getParkCode(), c);
  41 + }
  42 +
  43 + if(list != null && list.size() > 0)
  44 + CarparkBufferData.replaceAll(new ArrayList(map.values()));
  45 + }catch (Exception e){
  46 + logger.error("", e);
  47 + }
  48 + }
  49 +}
... ...
src/main/java/com/bsth/server_rs/departure/Departure.java 0 → 100644
  1 +package com.bsth.server_rs.departure;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public class Departure {
  7 +
  8 + /**
  9 + * 发车日期
  10 + */
  11 + private String rq;
  12 +
  13 + /**
  14 + * 线路代码
  15 + */
  16 + private String lineCode;
  17 +
  18 + /**
  19 + * 线路名称
  20 + */
  21 + private String lineName;
  22 +
  23 + /**
  24 + * 线路名称缩写
  25 + */
  26 + private String lineNameEs;
  27 +
  28 + /**
  29 + * 路牌名称
  30 + */
  31 + private String lpName;
  32 +
  33 + /**
  34 + * 路牌顺序号
  35 + */
  36 + private int lpSn;
  37 +
  38 + /**
  39 + * 待发时间
  40 + */
  41 + private String dfsj;
  42 +
  43 + /**
  44 + * 内部编码
  45 + */
  46 + private String nbbm;
  47 +
  48 + /**
  49 + * 车牌号
  50 + */
  51 + private String cph;
  52 +
  53 + /**
  54 + * 班次类型
  55 + */
  56 + private String bcType;
  57 +
  58 + /**
  59 + * 终点站名称
  60 + */
  61 + private String endStationName;
  62 +
  63 + /**
  64 + * 终点站名称缩写
  65 + */
  66 + private String endStationNameEs;
  67 +
  68 + /**
  69 + * 上下行 0上行 1下行
  70 + */
  71 + private int updown;
  72 +
  73 + /**
  74 + * 驾驶员工号
  75 + */
  76 + private String jGh;
  77 +
  78 + /**
  79 + * 驾驶员姓名
  80 + */
  81 + private String jName;
  82 +
  83 + /**
  84 + * 备注
  85 + */
  86 + private String remarks;
  87 +
  88 + /**
  89 + * 顺序号
  90 + */
  91 + private int sn;
  92 +
  93 + public String getRq() {
  94 + return rq;
  95 + }
  96 +
  97 + public void setRq(String rq) {
  98 + this.rq = rq;
  99 + }
  100 +
  101 + public String getLineCode() {
  102 + return lineCode;
  103 + }
  104 +
  105 + public void setLineCode(String lineCode) {
  106 + this.lineCode = lineCode;
  107 + }
  108 +
  109 + public String getLineName() {
  110 + return lineName;
  111 + }
  112 +
  113 + public void setLineName(String lineName) {
  114 + this.lineName = lineName;
  115 + }
  116 +
  117 + public String getLineNameEs() {
  118 + return lineNameEs;
  119 + }
  120 +
  121 + public void setLineNameEs(String lineNameEs) {
  122 + this.lineNameEs = lineNameEs;
  123 + }
  124 +
  125 + public String getLpName() {
  126 + return lpName;
  127 + }
  128 +
  129 + public void setLpName(String lpName) {
  130 + this.lpName = lpName;
  131 + }
  132 +
  133 + public int getLpSn() {
  134 + return lpSn;
  135 + }
  136 +
  137 + public void setLpSn(int lpSn) {
  138 + this.lpSn = lpSn;
  139 + }
  140 +
  141 + public String getDfsj() {
  142 + return dfsj;
  143 + }
  144 +
  145 + public void setDfsj(String dfsj) {
  146 + this.dfsj = dfsj;
  147 + }
  148 +
  149 + public String getNbbm() {
  150 + return nbbm;
  151 + }
  152 +
  153 + public void setNbbm(String nbbm) {
  154 + this.nbbm = nbbm;
  155 + }
  156 +
  157 + public String getCph() {
  158 + return cph;
  159 + }
  160 +
  161 + public void setCph(String cph) {
  162 + this.cph = cph;
  163 + }
  164 +
  165 + public String getBcType() {
  166 + return bcType;
  167 + }
  168 +
  169 + public void setBcType(String bcType) {
  170 + this.bcType = bcType;
  171 + }
  172 +
  173 + public String getEndStationName() {
  174 + return endStationName;
  175 + }
  176 +
  177 + public void setEndStationName(String endStationName) {
  178 + this.endStationName = endStationName;
  179 + }
  180 +
  181 + public String getEndStationNameEs() {
  182 + return endStationNameEs;
  183 + }
  184 +
  185 + public void setEndStationNameEs(String endStationNameEs) {
  186 + this.endStationNameEs = endStationNameEs;
  187 + }
  188 +
  189 + public int getUpdown() {
  190 + return updown;
  191 + }
  192 +
  193 + public void setUpdown(int updown) {
  194 + this.updown = updown;
  195 + }
  196 +
  197 + public String getjGh() {
  198 + return jGh;
  199 + }
  200 +
  201 + public void setjGh(String jGh) {
  202 + this.jGh = jGh;
  203 + }
  204 +
  205 + public String getjName() {
  206 + return jName;
  207 + }
  208 +
  209 + public void setjName(String jName) {
  210 + this.jName = jName;
  211 + }
  212 +
  213 + public String getRemarks() {
  214 + return remarks;
  215 + }
  216 +
  217 + public void setRemarks(String remarks) {
  218 + this.remarks = remarks;
  219 + }
  220 +
  221 + public int getSn() {
  222 + return sn;
  223 + }
  224 +
  225 + public void setSn(int sn) {
  226 + this.sn = sn;
  227 + }
  228 +}
... ...
src/main/java/com/bsth/server_rs/departure/DepartureRestService.java 0 → 100644
  1 +package com.bsth.server_rs.departure;
  2 +
  3 +import com.bsth.server_rs.departure.buffer.DepartureBufferData;
  4 +
  5 +import javax.ws.rs.GET;
  6 +import javax.ws.rs.Path;
  7 +import javax.ws.rs.PathParam;
  8 +import javax.ws.rs.Produces;
  9 +import javax.ws.rs.core.MediaType;
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * @author hill
  14 + */
  15 +@Path("/departure")
  16 +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  17 +public class DepartureRestService {
  18 +
  19 + @GET
  20 + @Path("/all")
  21 + public List<Departure> findAll(){
  22 + return DepartureBufferData.findAll();
  23 + }
  24 +
  25 + @GET
  26 + @Path("/line/{lineCode}")
  27 + public List<Departure> findByCompany(@PathParam("lineCode") String lineCode) {
  28 + return DepartureBufferData.findByLine(lineCode);
  29 + }
  30 +}
... ...
src/main/java/com/bsth/server_rs/departure/buffer/DepartureBufferData.java 0 → 100644
  1 +package com.bsth.server_rs.departure.buffer;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.server_rs.base_info.car.buffer.CarRefreshThread;
  5 +import com.bsth.server_rs.departure.Departure;
  6 +import com.google.common.collect.ArrayListMultimap;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.boot.CommandLineRunner;
  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 +import java.util.concurrent.TimeUnit;
  16 +
  17 +/**
  18 + * 车辆数据缓存
  19 + * @Author hill
  20 + */
  21 +@Component
  22 +@Order(8)
  23 +public class DepartureBufferData implements CommandLineRunner {
  24 +
  25 + private static List<Departure> data;
  26 + private static ArrayListMultimap<String, Departure> line2list;
  27 +
  28 + @Autowired
  29 + DepartureRefreshThread departureRefreshThread;
  30 +
  31 + public static List<Departure> findAll(){
  32 + return data;
  33 + }
  34 +
  35 + public static List<Departure> findByLine(String lineCode){
  36 + return line2list.get(lineCode);
  37 + }
  38 +
  39 + public static void replaceAll(List<Departure> newData){
  40 + data = newData;
  41 + ArrayListMultimap<String, Departure> line2listCopy = ArrayListMultimap.create();
  42 +
  43 + for(Departure departure : data){
  44 + line2listCopy.put(departure.getLineCode(), departure);
  45 + }
  46 +
  47 + line2list = line2listCopy;
  48 + }
  49 +
  50 + @Override
  51 + public void run(String... strings) throws Exception {
  52 + Application.mainServices.scheduleWithFixedDelay(departureRefreshThread, 10, 10, TimeUnit.SECONDS);
  53 + }
  54 +}
... ...
src/main/java/com/bsth/server_rs/departure/buffer/DepartureRefreshThread.java 0 → 100644
  1 +package com.bsth.server_rs.departure.buffer;
  2 +
  3 +import com.bsth.server_rs.departure.Departure;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  8 +import org.springframework.jdbc.core.JdbcTemplate;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * @author hill
  15 + */
  16 +@Component
  17 +public class DepartureRefreshThread extends Thread{
  18 +
  19 + @Autowired
  20 + JdbcTemplate jdbcTemplate;
  21 +
  22 + Logger logger = LoggerFactory.getLogger(this.getClass());
  23 +
  24 + @Override
  25 + public void run() {
  26 +
  27 + try {
  28 +
  29 + List<Departure> list = jdbcTemplate.query("select * from bsth_t_clfcxxb order by line_code,updown,sn"
  30 + , BeanPropertyRowMapper.newInstance(Departure.class));
  31 +
  32 + if(list != null && list.size() > 0)
  33 + DepartureBufferData.replaceAll(list);
  34 + }catch (Exception e){
  35 + logger.error("", e);
  36 + }
  37 + }
  38 +}
... ...