Commit 4df634e67c6645d4fc0e29b2462fab66e3e66c3d

Authored by 王通
1 parent 9283e1c1

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.directive.DirectiveRestService;
14   -import com.bsth.server_rs.electric.ElectricService;
15   -import com.bsth.server_rs.exception.AesExceptionMapper;
16   -import com.bsth.server_rs.gps.GpsRestService;
17   -import com.bsth.server_rs.logs.RealLogRestService;
18   -import com.bsth.server_rs.rate.RateService;
19   -import com.bsth.server_rs.schedule.plan.SchedulePlanService;
20   -import com.bsth.server_rs.schedule.real.ScheduleRealService;
21   -import com.bsth.server_rs.schedule.real.StaffViewRealService;
22   -import com.bsth.server_rs.waybill.WaybillRestService;
23   -import com.bsth.server_ws.attendance.AttendanceServiceSoap;
24   -import com.bsth.server_ws.electric_oil.OilServiceSoap;
25   -import com.bsth.server_ws.park_station.CompanyServiceSoap;
26   -import com.bsth.server_ws.waybill.LD_ServiceSoap;
27   -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
28   -import org.apache.cxf.Bus;
29   -import org.apache.cxf.bus.spring.SpringBus;
30   -import org.apache.cxf.endpoint.Server;
31   -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
32   -import org.apache.cxf.jaxws.EndpointImpl;
33   -import org.apache.cxf.transport.servlet.CXFServlet;
34   -import org.springframework.beans.factory.annotation.Autowired;
35   -import org.springframework.boot.web.servlet.ServletRegistrationBean;
36   -import org.springframework.context.annotation.Bean;
37   -import org.springframework.context.annotation.Configuration;
38   -import org.springframework.core.Ordered;
39   -
40   -import javax.xml.ws.Endpoint;
41   -import java.util.Arrays;
42   -
43   -/**
44   - * Created by panzhao on 2017/3/9.
45   - */
46   -@Configuration
47   -public class CXFConfig {
48   -
49   - @Bean(name = Bus.DEFAULT_BUS_ID)
50   - public SpringBus springBus() {
51   - return new SpringBus();
52   - }
53   -
54   - @Autowired
55   - CompanyServiceSoap companyServiceSoap;
56   - @Autowired
57   - LD_ServiceSoap ld_serviceSoap;
58   - @Autowired
59   - AttendanceServiceSoap attendanceServiceSoap;
60   - @Autowired
61   - OilServiceSoap oilServiceSoap;
62   -
63   - @Bean
64   - public Endpoint companyEndpoint() {
65   - EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
66   - endpoint.publish("/CompanyService");
67   - //endpoint.getInInterceptors().add(new AuthInterceptor());
68   - return endpoint;
69   - }
70   -
71   - @Bean
72   - public Endpoint ldServiceEndpoint() {
73   - EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
74   - endpoint.publish("/LD_Service");
75   - //endpoint.getInInterceptors().add(new AuthInterceptor());
76   - return endpoint;
77   - }
78   -
79   - @Bean
80   - public Endpoint attendanceServiceEndpoint() {
81   - EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
82   - endpoint.publish("/attendanceService");
83   - //endpoint.getInInterceptors().add(new AuthInterceptor());
84   - return endpoint;
85   - }
86   -
87   - @Bean
88   - public Endpoint electricServiceEndpoint() {
89   - EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
90   - endpoint.publish("/oilServiceSoap");
91   - //endpoint.getInInterceptors().add(new AuthInterceptor());
92   - return endpoint;
93   - }
94   -
95   - @Autowired
96   - ScheduleRealService scheduleRealService;
97   - @Autowired
98   - StationRestService stationRestService;
99   - @Autowired
100   - LD_SectionRestService ldSectionRestService;
101   - @Autowired
102   - SchedulePlanService schedulePlanService;
103   - @Autowired
104   - RealLogRestService realLogRestService;
105   - @Autowired
106   - GpsRestService gpsRestService;
107   - @Autowired
108   - WaybillRestService waybillRestService;
109   - @Autowired
110   - DirectiveRestService directiveRestService;
111   - @Autowired
112   - LD_RoadSpeedRestService ld_roadSpeedRestService;
113   - @Autowired
114   - ElectricService electricService;
115   - @Autowired
116   - BigdataService bigdataService;
117   - @Autowired
118   - BigscreenService bigscreenService;
119   - @Autowired
120   - StaffViewRealService staffViewRealService;
121   - @Autowired
122   - RateService rateService;
123   -
124   - @Bean
125   - public Server rsServer() {
126   - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
127   - endpoint.setBus(springBus());
128   - endpoint.setAddress("/rest");
129   - endpoint.setServiceBeans(Arrays.<Object>asList(
130   - new LineRestService(),
131   - new CarRestService(),
132   - new PersonRestService(),
133   - gpsRestService,
134   - waybillRestService,
135   - scheduleRealService,
136   - stationRestService,
137   - ldSectionRestService,
138   - schedulePlanService,
139   - realLogRestService,
140   - directiveRestService,
141   - ld_roadSpeedRestService,
142   - electricService,
143   - staffViewRealService,
144   - bigdataService,
145   - bigscreenService,
146   - rateService));
147   - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
148   - //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
149   - endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
150   - return endpoint.create();
151   - }
152   -
153   - @Bean
154   - public ServletRegistrationBean servletRegistrationBean() {
155   - ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
156   - bean.setLoadOnStartup(0);
157   - bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
158   - return bean;
159   - }
160   -}
  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 +}
... ...
src/main/java/com/bsth/entity/DestroySituation.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.Id;
  5 +import javax.persistence.Table;
  6 +
  7 +/**
  8 + * 烂班情况
  9 + * Created by panzhao on 2017/10/31.
  10 + */
  11 +@Entity
  12 +@Table(name = "z_calc_destroy_detail")
  13 +public class DestroySituation {
  14 +
  15 + @Id
  16 + private Long id;
  17 +
  18 + private String rq;
  19 +
  20 + private String gsBm;
  21 +
  22 + private String fgsBm;
  23 +
  24 + private String lineCode;
  25 +
  26 + private String lineName;
  27 +
  28 + private String nbbm;
  29 +
  30 + private String jGh;
  31 +
  32 + private String sGh;
  33 +
  34 + private String reason;
  35 +
  36 + private int size;
  37 +
  38 + private Double mileage;
  39 +
  40 + private Long t;
  41 +
  42 + private String remark;
  43 +
  44 + private String idsStr;
  45 +
  46 + public Long getId() {
  47 + return id;
  48 + }
  49 +
  50 + public void setId(Long id) {
  51 + this.id = id;
  52 + }
  53 +
  54 + public String getRq() {
  55 + return rq;
  56 + }
  57 +
  58 + public void setRq(String rq) {
  59 + this.rq = rq;
  60 + }
  61 +
  62 + public String getLineCode() {
  63 + return lineCode;
  64 + }
  65 +
  66 + public void setLineCode(String lineCode) {
  67 + this.lineCode = lineCode;
  68 + }
  69 +
  70 + public String getLineName() {
  71 + return lineName;
  72 + }
  73 +
  74 + public void setLineName(String lineName) {
  75 + this.lineName = lineName;
  76 + }
  77 +
  78 + public String getNbbm() {
  79 + return nbbm;
  80 + }
  81 +
  82 + public void setNbbm(String nbbm) {
  83 + this.nbbm = nbbm;
  84 + }
  85 +
  86 + public String getjGh() {
  87 + return jGh;
  88 + }
  89 +
  90 + public void setjGh(String jGh) {
  91 + this.jGh = jGh;
  92 + }
  93 +
  94 + public String getsGh() {
  95 + return sGh;
  96 + }
  97 +
  98 + public void setsGh(String sGh) {
  99 + this.sGh = sGh;
  100 + }
  101 +
  102 + public String getReason() {
  103 + return reason;
  104 + }
  105 +
  106 + public void setReason(String reason) {
  107 + this.reason = reason;
  108 + }
  109 +
  110 + public int getSize() {
  111 + return size;
  112 + }
  113 +
  114 + public void setSize(int size) {
  115 + this.size = size;
  116 + }
  117 +
  118 + public Double getMileage() {
  119 + return mileage;
  120 + }
  121 +
  122 + public void setMileage(Double mileage) {
  123 + this.mileage = mileage;
  124 + }
  125 +
  126 + public Long getT() {
  127 + return t;
  128 + }
  129 +
  130 + public void setT(Long t) {
  131 + this.t = t;
  132 + }
  133 +
  134 + public String getRemark() {
  135 + return remark;
  136 + }
  137 +
  138 + public void setRemark(String remark) {
  139 + this.remark = remark;
  140 + }
  141 +
  142 + public String getIdsStr() {
  143 + return idsStr;
  144 + }
  145 +
  146 + public void setIdsStr(String idsStr) {
  147 + this.idsStr = idsStr;
  148 + }
  149 +
  150 + public String getGsBm() {
  151 + return gsBm;
  152 + }
  153 +
  154 + public void setGsBm(String gsBm) {
  155 + this.gsBm = gsBm;
  156 + }
  157 +
  158 + public String getFgsBm() {
  159 + return fgsBm;
  160 + }
  161 +
  162 + public void setFgsBm(String fgsBm) {
  163 + this.fgsBm = fgsBm;
  164 + }
  165 +}
... ...
src/main/java/com/bsth/repository/DestroySituationRepository.java 0 → 100644
  1 +package com.bsth.repository;
  2 +
  3 +import com.bsth.entity.DestroySituation;
  4 +import org.springframework.data.jpa.repository.Query;
  5 +import org.springframework.data.repository.PagingAndSortingRepository;
  6 +import org.springframework.stereotype.Repository;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by panzhao on 2017/11/1.
  12 + */
  13 +@Repository
  14 +public interface DestroySituationRepository extends PagingAndSortingRepository<DestroySituation, Long> {
  15 +
  16 + @Query("select t from DestroySituation t where t.rq = ?1 and t.reason = ?2")
  17 + List<DestroySituation> findByDateAndReason(String rq, String reason);
  18 +}
... ...
src/main/java/com/bsth/server_rs/destroy/DestroyDetailRestService.java 0 → 100644
  1 +package com.bsth.server_rs.destroy;
  2 +
  3 +import com.bsth.entity.DestroySituation;
  4 +import com.bsth.entity.ScheduleRealInfo;
  5 +import com.bsth.redis.ScheduleRedisService;
  6 +import com.bsth.repository.DestroySituationRepository;
  7 +import com.bsth.repository.ScheduleRealInfoRepository;
  8 +import com.bsth.server_rs.base_info.car.Car;
  9 +import com.bsth.server_rs.base_info.car.buffer.CarBufferData;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import javax.ws.rs.GET;
  14 +import javax.ws.rs.Path;
  15 +import javax.ws.rs.PathParam;
  16 +import javax.ws.rs.Produces;
  17 +import javax.ws.rs.core.MediaType;
  18 +import java.util.ArrayList;
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +/**
  24 + * @author hill
  25 + * @date
  26 + */
  27 +@Component
  28 +@Path("/destroy")
  29 +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  30 +public class DestroyDetailRestService {
  31 +
  32 + @Autowired
  33 + private DestroySituationRepository destroySituationRepository;
  34 +
  35 + @Autowired
  36 + private ScheduleRealInfoRepository scheduleRealInfoRepository;
  37 +
  38 + private static Map<String, String> COMPANY_CODE2NAME;
  39 +
  40 + static {
  41 + COMPANY_CODE2NAME = new HashMap<>();
  42 + COMPANY_CODE2NAME.put("55", "上南公司");
  43 + COMPANY_CODE2NAME.put("22", "金高公司");
  44 + COMPANY_CODE2NAME.put("05", "杨高公司");
  45 + COMPANY_CODE2NAME.put("26", "南汇公司");
  46 + COMPANY_CODE2NAME.put("05_1", "川沙分公司");
  47 + COMPANY_CODE2NAME.put("05_6", "周浦分公司");
  48 + COMPANY_CODE2NAME.put("05_2", "金桥分公司");
  49 + COMPANY_CODE2NAME.put("05_3", "芦潮港分公司");
  50 + COMPANY_CODE2NAME.put("05_5", "杨高分公司");
  51 + COMPANY_CODE2NAME.put("22_5", "一分公司");
  52 + COMPANY_CODE2NAME.put("22_1", "四分公司");
  53 + COMPANY_CODE2NAME.put("22_3", "三分公司");
  54 + COMPANY_CODE2NAME.put("22_2", "二分公司");
  55 + COMPANY_CODE2NAME.put("26_2", "南汇二分");
  56 + COMPANY_CODE2NAME.put("26_5", "南汇公司");
  57 + COMPANY_CODE2NAME.put("26_1", "南汇一分");
  58 + COMPANY_CODE2NAME.put("26_6", "南汇六分");
  59 + COMPANY_CODE2NAME.put("26_3", "南汇三分");
  60 + COMPANY_CODE2NAME.put("26_4", "南汇维修公司");
  61 + COMPANY_CODE2NAME.put("55_2", "上南三分公司");
  62 + COMPANY_CODE2NAME.put("55_3", "上南六分公司");
  63 + COMPANY_CODE2NAME.put("55_1", "上南二分公司");
  64 + COMPANY_CODE2NAME.put("55_4", "上南一分公司");
  65 + }
  66 +
  67 + @GET
  68 + @Path("/accident/{rq}")
  69 + public List<Map<String, Object>> waybill(@PathParam("rq") String rq) {
  70 + List<Map<String, Object>> result = new ArrayList<>();
  71 +
  72 + for (DestroySituation destroySituation : destroySituationRepository.findByDateAndReason(rq, "肇事")) {
  73 + Map<String, Object> map = new HashMap<>();
  74 + String nbbm = destroySituation.getNbbm(), ids = destroySituation.getIdsStr();
  75 + String gsBm = destroySituation.getGsBm(), fgsBm = destroySituation.getFgsBm();
  76 + Car car = CarBufferData.findOne(nbbm);
  77 + ScheduleRealInfo scheduleRealInfo = scheduleRealInfoRepository.findOne(Long.parseLong(ids.split(",")[0]));
  78 +
  79 + map.put("company", COMPANY_CODE2NAME.get(gsBm));
  80 + map.put("branch", COMPANY_CODE2NAME.get(gsBm + "_" + fgsBm));
  81 + map.put("line", destroySituation.getLineName());
  82 + map.put("plate", car.getCarPlate());
  83 + map.put("incode", nbbm);
  84 + map.put("driver", destroySituation.getjGh());
  85 + map.put("direction", scheduleRealInfo == null ? "" : (scheduleRealInfo.getQdzName() + "->" + scheduleRealInfo.getZdzName()));
  86 + map.put("remark", destroySituation.getRemark());
  87 + result.add(map);
  88 + }
  89 +
  90 + return result;
  91 + }
  92 +}
... ...