Commit 8b14b75a85fb12fb2cae183e5d457267b3d4accf

Authored by 王通
1 parent acb9f24e

1.产研院3个率

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.directive.DirectiveRestService;
13   -import com.bsth.server_rs.electric.ElectricService;
14   -import com.bsth.server_rs.exception.AesExceptionMapper;
15   -import com.bsth.server_rs.gps.GpsRestService;
16   -import com.bsth.server_rs.logs.RealLogRestService;
17   -import com.bsth.server_rs.schedule.plan.SchedulePlanService;
18   -import com.bsth.server_rs.schedule.real.ScheduleRealService;
19   -import com.bsth.server_rs.schedule.real.StaffViewRealService;
20   -import com.bsth.server_rs.waybill.WaybillRestService;
21   -import com.bsth.server_ws.attendance.AttendanceServiceSoap;
22   -import com.bsth.server_ws.electric_oil.OilServiceSoap;
23   -import com.bsth.server_ws.park_station.CompanyServiceSoap;
24   -import com.bsth.server_ws.waybill.LD_ServiceSoap;
25   -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
26   -import org.apache.cxf.Bus;
27   -import org.apache.cxf.bus.spring.SpringBus;
28   -import org.apache.cxf.endpoint.Server;
29   -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
30   -import org.apache.cxf.jaxws.EndpointImpl;
31   -import org.apache.cxf.transport.servlet.CXFServlet;
32   -import org.springframework.beans.factory.annotation.Autowired;
33   -import org.springframework.boot.web.servlet.ServletRegistrationBean;
34   -import org.springframework.context.annotation.Bean;
35   -import org.springframework.context.annotation.Configuration;
36   -import org.springframework.core.Ordered;
37   -
38   -import javax.xml.ws.Endpoint;
39   -import java.util.Arrays;
40   -
41   -/**
42   - * Created by panzhao on 2017/3/9.
43   - */
44   -@Configuration
45   -public class CXFConfig {
46   -
47   - @Bean(name = Bus.DEFAULT_BUS_ID)
48   - public SpringBus springBus() {
49   - return new SpringBus();
50   - }
51   -
52   - @Autowired
53   - CompanyServiceSoap companyServiceSoap;
54   - @Autowired
55   - LD_ServiceSoap ld_serviceSoap;
56   - @Autowired
57   - AttendanceServiceSoap attendanceServiceSoap;
58   - @Autowired
59   - OilServiceSoap oilServiceSoap;
60   -
61   - @Bean
62   - public Endpoint companyEndpoint() {
63   - EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
64   - endpoint.publish("/CompanyService");
65   - //endpoint.getInInterceptors().add(new AuthInterceptor());
66   - return endpoint;
67   - }
68   -
69   - @Bean
70   - public Endpoint ldServiceEndpoint() {
71   - EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
72   - endpoint.publish("/LD_Service");
73   - //endpoint.getInInterceptors().add(new AuthInterceptor());
74   - return endpoint;
75   - }
76   -
77   - @Bean
78   - public Endpoint attendanceServiceEndpoint() {
79   - EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
80   - endpoint.publish("/attendanceService");
81   - //endpoint.getInInterceptors().add(new AuthInterceptor());
82   - return endpoint;
83   - }
84   -
85   - @Bean
86   - public Endpoint electricServiceEndpoint() {
87   - EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
88   - endpoint.publish("/oilServiceSoap");
89   - //endpoint.getInInterceptors().add(new AuthInterceptor());
90   - return endpoint;
91   - }
92   -
93   - @Autowired
94   - ScheduleRealService scheduleRealService;
95   - @Autowired
96   - StationRestService stationRestService;
97   - @Autowired
98   - LD_SectionRestService ldSectionRestService;
99   - @Autowired
100   - SchedulePlanService schedulePlanService;
101   - @Autowired
102   - RealLogRestService realLogRestService;
103   - @Autowired
104   - GpsRestService gpsRestService;
105   - @Autowired
106   - WaybillRestService waybillRestService;
107   - @Autowired
108   - DirectiveRestService directiveRestService;
109   - @Autowired
110   - LD_RoadSpeedRestService ld_roadSpeedRestService;
111   - @Autowired
112   - ElectricService electricService;
113   - @Autowired
114   - BigdataService bigdataService;
115   - @Autowired
116   - StaffViewRealService staffViewRealService;
117   -
118   - @Bean
119   - public Server rsServer() {
120   - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
121   - endpoint.setBus(springBus());
122   - endpoint.setAddress("/rest");
123   - endpoint.setServiceBeans(Arrays.<Object>asList(
124   - new LineRestService(),
125   - new CarRestService(),
126   - new PersonRestService(),
127   - gpsRestService,
128   - waybillRestService,
129   - scheduleRealService,
130   - stationRestService,
131   - ldSectionRestService,
132   - schedulePlanService,
133   - realLogRestService,
134   - directiveRestService,
135   - ld_roadSpeedRestService,
136   - electricService,
137   - staffViewRealService,
138   - bigdataService));
139   - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
140   - //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
141   - endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
142   - return endpoint.create();
143   - }
144   -
145   - @Bean
146   - public ServletRegistrationBean servletRegistrationBean() {
147   - ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
148   - bean.setLoadOnStartup(0);
149   - bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
150   - return bean;
151   - }
152   -}
  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.directive.DirectiveRestService;
  13 +import com.bsth.server_rs.electric.ElectricService;
  14 +import com.bsth.server_rs.exception.AesExceptionMapper;
  15 +import com.bsth.server_rs.gps.GpsRestService;
  16 +import com.bsth.server_rs.logs.RealLogRestService;
  17 +import com.bsth.server_rs.rate.RateService;
  18 +import com.bsth.server_rs.schedule.plan.SchedulePlanService;
  19 +import com.bsth.server_rs.schedule.real.ScheduleRealService;
  20 +import com.bsth.server_rs.schedule.real.StaffViewRealService;
  21 +import com.bsth.server_rs.waybill.WaybillRestService;
  22 +import com.bsth.server_ws.attendance.AttendanceServiceSoap;
  23 +import com.bsth.server_ws.electric_oil.OilServiceSoap;
  24 +import com.bsth.server_ws.park_station.CompanyServiceSoap;
  25 +import com.bsth.server_ws.waybill.LD_ServiceSoap;
  26 +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
  27 +import org.apache.cxf.Bus;
  28 +import org.apache.cxf.bus.spring.SpringBus;
  29 +import org.apache.cxf.endpoint.Server;
  30 +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
  31 +import org.apache.cxf.jaxws.EndpointImpl;
  32 +import org.apache.cxf.transport.servlet.CXFServlet;
  33 +import org.springframework.beans.factory.annotation.Autowired;
  34 +import org.springframework.boot.web.servlet.ServletRegistrationBean;
  35 +import org.springframework.context.annotation.Bean;
  36 +import org.springframework.context.annotation.Configuration;
  37 +import org.springframework.core.Ordered;
  38 +
  39 +import javax.xml.ws.Endpoint;
  40 +import java.util.Arrays;
  41 +
  42 +/**
  43 + * Created by panzhao on 2017/3/9.
  44 + */
  45 +@Configuration
  46 +public class CXFConfig {
  47 +
  48 + @Bean(name = Bus.DEFAULT_BUS_ID)
  49 + public SpringBus springBus() {
  50 + return new SpringBus();
  51 + }
  52 +
  53 + @Autowired
  54 + CompanyServiceSoap companyServiceSoap;
  55 + @Autowired
  56 + LD_ServiceSoap ld_serviceSoap;
  57 + @Autowired
  58 + AttendanceServiceSoap attendanceServiceSoap;
  59 + @Autowired
  60 + OilServiceSoap oilServiceSoap;
  61 +
  62 + @Bean
  63 + public Endpoint companyEndpoint() {
  64 + EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
  65 + endpoint.publish("/CompanyService");
  66 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  67 + return endpoint;
  68 + }
  69 +
  70 + @Bean
  71 + public Endpoint ldServiceEndpoint() {
  72 + EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
  73 + endpoint.publish("/LD_Service");
  74 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  75 + return endpoint;
  76 + }
  77 +
  78 + @Bean
  79 + public Endpoint attendanceServiceEndpoint() {
  80 + EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
  81 + endpoint.publish("/attendanceService");
  82 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  83 + return endpoint;
  84 + }
  85 +
  86 + @Bean
  87 + public Endpoint electricServiceEndpoint() {
  88 + EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
  89 + endpoint.publish("/oilServiceSoap");
  90 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  91 + return endpoint;
  92 + }
  93 +
  94 + @Autowired
  95 + ScheduleRealService scheduleRealService;
  96 + @Autowired
  97 + StationRestService stationRestService;
  98 + @Autowired
  99 + LD_SectionRestService ldSectionRestService;
  100 + @Autowired
  101 + SchedulePlanService schedulePlanService;
  102 + @Autowired
  103 + RealLogRestService realLogRestService;
  104 + @Autowired
  105 + GpsRestService gpsRestService;
  106 + @Autowired
  107 + WaybillRestService waybillRestService;
  108 + @Autowired
  109 + DirectiveRestService directiveRestService;
  110 + @Autowired
  111 + LD_RoadSpeedRestService ld_roadSpeedRestService;
  112 + @Autowired
  113 + ElectricService electricService;
  114 + @Autowired
  115 + BigdataService bigdataService;
  116 + @Autowired
  117 + StaffViewRealService staffViewRealService;
  118 + @Autowired
  119 + RateService rateService;
  120 +
  121 + @Bean
  122 + public Server rsServer() {
  123 + JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
  124 + endpoint.setBus(springBus());
  125 + endpoint.setAddress("/rest");
  126 + endpoint.setServiceBeans(Arrays.<Object>asList(
  127 + new LineRestService(),
  128 + new CarRestService(),
  129 + new PersonRestService(),
  130 + gpsRestService,
  131 + waybillRestService,
  132 + scheduleRealService,
  133 + stationRestService,
  134 + ldSectionRestService,
  135 + schedulePlanService,
  136 + realLogRestService,
  137 + directiveRestService,
  138 + ld_roadSpeedRestService,
  139 + electricService,
  140 + staffViewRealService,
  141 + bigdataService,
  142 + rateService));
  143 + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
  144 + //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
  145 + endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
  146 + return endpoint.create();
  147 + }
  148 +
  149 + @Bean
  150 + public ServletRegistrationBean servletRegistrationBean() {
  151 + ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
  152 + bean.setLoadOnStartup(0);
  153 + bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  154 + return bean;
  155 + }
  156 +}
... ...
src/main/java/com/bsth/server_rs/rate/RateService.java 0 → 100644
  1 +package com.bsth.server_rs.rate;
  2 +
  3 +import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
  4 +import org.joda.time.DateTime;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.jdbc.core.JdbcTemplate;
  7 +import org.springframework.jdbc.core.RowMapper;
  8 +import org.springframework.stereotype.Component;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +
  11 +import javax.ws.rs.GET;
  12 +import javax.ws.rs.Path;
  13 +import javax.ws.rs.PathParam;
  14 +import javax.ws.rs.Produces;
  15 +import javax.ws.rs.core.MediaType;
  16 +import java.sql.ResultSet;
  17 +import java.sql.SQLException;
  18 +import java.util.*;
  19 +
  20 +/**
  21 + * @author hill
  22 + * @date
  23 + */
  24 +@Component
  25 +@Path("/rate")
  26 +@Produces({MediaType.APPLICATION_JSON})
  27 +public class RateService {
  28 +
  29 + @Autowired
  30 + private JdbcTemplate jdbcTemplate;
  31 +
  32 + private List<Map<String, Object>> fetchData(String rq) {
  33 + String sql = "select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz,"
  34 + + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz,"
  35 + + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz,"
  36 + + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz,"
  37 + + " jhszfcs,sjszfczds,szfczdl,"
  38 + + " create_date from bsth_c_calc_count "
  39 + + " where date = ?";
  40 + List<Map<String, Object>> list = jdbcTemplate.query(sql, new Object[]{rq}, new RowMapper<Map<String, Object>>() {
  41 + @Override
  42 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  43 + Map<String, Object> m = new HashMap<String, Object>();
  44 +
  45 + m.put("lineCode", rs.getString("xl"));
  46 + m.put("lineName", rs.getString("xl_name"));
  47 + m.put("date", rs.getString("date"));
  48 +
  49 + m.put("jhbc", rs.getString("jhbc"));
  50 + m.put("sjbc", rs.getString("sjbc"));
  51 + m.put("bczxl", rs.getString("bczxl"));
  52 +
  53 + m.put("jhsmbcs", rs.getString("jhsmbcs"));
  54 + m.put("sjsmbczds", rs.getString("sjsmbczds"));
  55 + m.put("smbczdl", rs.getString("smbczdl"));
  56 + /*m.put("jhsmbcsz", rs.getString("jhsmbcsz"));
  57 + m.put("sjsmbczdsz", rs.getString("sjsmbczdsz"));
  58 + m.put("smbczdlz", rs.getString("smbczdlz"));*/
  59 +
  60 + m.put("jhszfcs", rs.getString("jhszfcs"));
  61 + m.put("sjszfczds", rs.getString("sjszfczds"));
  62 + m.put("szfczdl", rs.getString("szfczdl"));
  63 +
  64 + DateTime dateTime = new DateTime(rs.getTimestamp("create_date").getTime());
  65 + m.put("createDate", dateTime.toString("yyyy-MM-dd HH:mm"));
  66 +
  67 + return m;
  68 + }
  69 + });
  70 +
  71 + return list;
  72 + }
  73 +
  74 + @GET
  75 + @Path("/bczxl/{rq}")
  76 + public List<Map<String, Object>> bczxl(@PathParam("rq") String rq) {
  77 + List<Map<String, Object>> result = new ArrayList<>();
  78 + List<Map<String, Object>> list = fetchData(rq);
  79 + for (Map<String, Object> map : list) {
  80 + Map<String, Object> map1 = new HashMap<>();
  81 + map1.put("rq", map.get("date"));
  82 + map1.put("xlbm", map.get("lineCode"));
  83 + map1.put("xlmc", map.get("lineName"));
  84 + map1.put("ssgs", LineBufferData.findOne(String.valueOf(map.get("lineName"))));
  85 + map1.put("jhzxbc", map.get("jhbc"));
  86 + map1.put("sjzxbc", map.get("sjbc"));
  87 + map1.put("bczxl", map.get("bczxl"));
  88 + map1.put("gxsj", map.get("createDate"));
  89 +
  90 + result.add(map1);
  91 + }
  92 +
  93 + return result;
  94 + }
  95 +
  96 + @GET
  97 + @Path("/smbczdl/{rq}")
  98 + public List<Map<String, Object>> smbzdl(@PathParam("rq") String rq) {
  99 + List<Map<String, Object>> result = new ArrayList<>();
  100 + List<Map<String, Object>> list = fetchData(rq);
  101 + for (Map<String, Object> map : list) {
  102 + Map<String, Object> map1 = new HashMap<>();
  103 + map1.put("rq", map.get("date"));
  104 + map1.put("xlbm", map.get("lineCode"));
  105 + map1.put("xlmc", map.get("lineName"));
  106 + map1.put("ssgs", LineBufferData.findOne(String.valueOf(map.get("lineName"))));
  107 + map1.put("sybcs", map.get("jhsmbcs"));
  108 + map1.put("zdbcs", map.get("sjsmbczds"));
  109 + map1.put("smbczdl", map.get("smbczdl"));
  110 + map1.put("gxsj", map.get("createDate"));
  111 +
  112 + result.add(map1);
  113 + }
  114 +
  115 + return result;
  116 + }
  117 +
  118 + @GET
  119 + @Path("/qqzfczdl/{rq}")
  120 + public List<Map<String, Object>> qqzzdl(@PathParam("rq") String rq) {
  121 + List<Map<String, Object>> result = new ArrayList<>();
  122 + List<Map<String, Object>> list = fetchData(rq);
  123 + for (Map<String, Object> map : list) {
  124 + Map<String, Object> map1 = new HashMap<>();
  125 + map1.put("rq", map.get("date"));
  126 + map1.put("xlbm", map.get("lineCode"));
  127 + map1.put("xlmc", map.get("lineName"));
  128 + map1.put("ssgs", LineBufferData.findOne(String.valueOf(map.get("lineName"))));
  129 + map1.put("sybcs", map.get("jhszfcs"));
  130 + map1.put("zdbcs", map.get("sjszfczds"));
  131 + map1.put("qqzfczdl", map.get("szfczdl"));
  132 + map1.put("gxsj", map.get("createDate"));
  133 +
  134 + result.add(map1);
  135 + }
  136 +
  137 + return result;
  138 + }
  139 +}
... ...