Commit 32320a04a1a2f19be4468a3c07d10fa767afde33

Authored by 廖磊
1 parent 1edf7882

产研院大数据接口

src/main/java/com/bsth/CXFConfig.java
1   -package com.bsth;
2   -
3   -import com.bsth.server_rs.AuthorizeInterceptor_IN;
4   -import com.bsth.server_rs.base_info.car.CarRestService;
5   -import com.bsth.server_rs.base_info.line.LineRestService;
6   -import com.bsth.server_rs.base_info.person.PersonRestService;
7   -import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
8   -import com.bsth.server_rs.base_info.section.LD_SectionRestService;
9   -import com.bsth.server_rs.base_info.station.StationRestService;
10   -import com.bsth.server_rs.directive.DirectiveRestService;
11   -import com.bsth.server_rs.electric.ElectricService;
12   -import com.bsth.server_rs.exception.AesExceptionMapper;
13   -import com.bsth.server_rs.gps.GpsRestService;
14   -import com.bsth.server_rs.logs.RealLogRestService;
15   -import com.bsth.server_rs.schedule.plan.SchedulePlanService;
16   -import com.bsth.server_rs.schedule.real.ScheduleRealService;
17   -import com.bsth.server_rs.schedule.real.StaffViewRealService;
18   -import com.bsth.server_ws.attendance.AttendanceServiceSoap;
19   -import com.bsth.server_ws.electric_oil.OilServiceSoap;
20   -import com.bsth.server_ws.park_station.CompanyServiceSoap;
21   -import com.bsth.server_ws.waybill.LD_ServiceSoap;
22   -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
23   -import org.apache.cxf.Bus;
24   -import org.apache.cxf.bus.spring.SpringBus;
25   -import org.apache.cxf.endpoint.Server;
26   -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
27   -import org.apache.cxf.jaxws.EndpointImpl;
28   -import org.apache.cxf.transport.servlet.CXFServlet;
29   -import org.springframework.beans.factory.annotation.Autowired;
30   -import org.springframework.boot.web.servlet.ServletRegistrationBean;
31   -import org.springframework.context.annotation.Bean;
32   -import org.springframework.context.annotation.Configuration;
33   -import org.springframework.core.Ordered;
34   -
35   -import javax.xml.ws.Endpoint;
36   -import java.util.Arrays;
37   -
38   -/**
39   - * Created by panzhao on 2017/3/9.
40   - */
41   -@Configuration
42   -public class CXFConfig {
43   -
44   - @Bean(name = Bus.DEFAULT_BUS_ID)
45   - public SpringBus springBus() {
46   - return new SpringBus();
47   - }
48   -
49   - @Autowired
50   - CompanyServiceSoap companyServiceSoap;
51   - @Autowired
52   - LD_ServiceSoap ld_serviceSoap;
53   - @Autowired
54   - AttendanceServiceSoap attendanceServiceSoap;
55   - @Autowired
56   - OilServiceSoap oilServiceSoap;
57   -
58   - @Bean
59   - public Endpoint companyEndpoint() {
60   - EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
61   - endpoint.publish("/CompanyService");
62   - //endpoint.getInInterceptors().add(new AuthInterceptor());
63   - return endpoint;
64   - }
65   -
66   - @Bean
67   - public Endpoint ldServiceEndpoint() {
68   - EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
69   - endpoint.publish("/LD_Service");
70   - //endpoint.getInInterceptors().add(new AuthInterceptor());
71   - return endpoint;
72   - }
73   -
74   - @Bean
75   - public Endpoint attendanceServiceEndpoint() {
76   - EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
77   - endpoint.publish("/attendanceService");
78   - //endpoint.getInInterceptors().add(new AuthInterceptor());
79   - return endpoint;
80   - }
81   -
82   - @Bean
83   - public Endpoint electricServiceEndpoint() {
84   - EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
85   - endpoint.publish("/oilServiceSoap");
86   - //endpoint.getInInterceptors().add(new AuthInterceptor());
87   - return endpoint;
88   - }
89   -
90   - @Autowired
91   - ScheduleRealService scheduleRealService;
92   - @Autowired
93   - StationRestService stationRestService;
94   - @Autowired
95   - LD_SectionRestService ldSectionRestService;
96   - @Autowired
97   - SchedulePlanService schedulePlanService;
98   - @Autowired
99   - RealLogRestService realLogRestService;
100   - @Autowired
101   - GpsRestService gpsRestService;
102   - @Autowired
103   - DirectiveRestService directiveRestService;
104   - @Autowired
105   - LD_RoadSpeedRestService ld_roadSpeedRestService;
106   - @Autowired
107   - ElectricService electricService;
108   - @Autowired
109   - StaffViewRealService staffViewRealService;
110   -
111   - @Bean
112   - public Server rsServer() {
113   - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
114   - endpoint.setBus(springBus());
115   - endpoint.setAddress("/rest");
116   - endpoint.setServiceBeans(Arrays.<Object>asList(
117   - new LineRestService(),
118   - new CarRestService(),
119   - new PersonRestService(),
120   - gpsRestService,
121   - scheduleRealService,
122   - stationRestService,
123   - ldSectionRestService,
124   - schedulePlanService,
125   - realLogRestService,
126   - directiveRestService,
127   - ld_roadSpeedRestService,
128   - electricService,
129   - staffViewRealService));
130   - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
131   - //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
132   - endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
133   - return endpoint.create();
134   - }
135   -
136   - @Bean
137   - public ServletRegistrationBean servletRegistrationBean() {
138   - ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
139   - bean.setLoadOnStartup(0);
140   - bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
141   - return bean;
142   - }
143   -}
  1 +package com.bsth;
  2 +
  3 +import com.bsth.server_rs.AuthorizeInterceptor_IN;
  4 +import com.bsth.server_rs.base_info.car.CarRestService;
  5 +import com.bsth.server_rs.base_info.line.LineRestService;
  6 +import com.bsth.server_rs.base_info.person.PersonRestService;
  7 +import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
  8 +import com.bsth.server_rs.base_info.section.LD_SectionRestService;
  9 +import com.bsth.server_rs.base_info.station.StationRestService;
  10 +import com.bsth.server_rs.bigdata.BigdateService;
  11 +import com.bsth.server_rs.directive.DirectiveRestService;
  12 +import com.bsth.server_rs.electric.ElectricService;
  13 +import com.bsth.server_rs.exception.AesExceptionMapper;
  14 +import com.bsth.server_rs.gps.GpsRestService;
  15 +import com.bsth.server_rs.logs.RealLogRestService;
  16 +import com.bsth.server_rs.schedule.plan.SchedulePlanService;
  17 +import com.bsth.server_rs.schedule.real.ScheduleRealService;
  18 +import com.bsth.server_rs.schedule.real.StaffViewRealService;
  19 +import com.bsth.server_ws.attendance.AttendanceServiceSoap;
  20 +import com.bsth.server_ws.electric_oil.OilServiceSoap;
  21 +import com.bsth.server_ws.park_station.CompanyServiceSoap;
  22 +import com.bsth.server_ws.waybill.LD_ServiceSoap;
  23 +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
  24 +import org.apache.cxf.Bus;
  25 +import org.apache.cxf.bus.spring.SpringBus;
  26 +import org.apache.cxf.endpoint.Server;
  27 +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
  28 +import org.apache.cxf.jaxws.EndpointImpl;
  29 +import org.apache.cxf.transport.servlet.CXFServlet;
  30 +import org.springframework.beans.factory.annotation.Autowired;
  31 +import org.springframework.boot.web.servlet.ServletRegistrationBean;
  32 +import org.springframework.context.annotation.Bean;
  33 +import org.springframework.context.annotation.Configuration;
  34 +import org.springframework.core.Ordered;
  35 +
  36 +import javax.xml.ws.Endpoint;
  37 +import java.util.Arrays;
  38 +
  39 +/**
  40 + * Created by panzhao on 2017/3/9.
  41 + */
  42 +@Configuration
  43 +public class CXFConfig {
  44 +
  45 + @Bean(name = Bus.DEFAULT_BUS_ID)
  46 + public SpringBus springBus() {
  47 + return new SpringBus();
  48 + }
  49 +
  50 + @Autowired
  51 + CompanyServiceSoap companyServiceSoap;
  52 + @Autowired
  53 + LD_ServiceSoap ld_serviceSoap;
  54 + @Autowired
  55 + AttendanceServiceSoap attendanceServiceSoap;
  56 + @Autowired
  57 + OilServiceSoap oilServiceSoap;
  58 +
  59 + @Bean
  60 + public Endpoint companyEndpoint() {
  61 + EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
  62 + endpoint.publish("/CompanyService");
  63 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  64 + return endpoint;
  65 + }
  66 +
  67 + @Bean
  68 + public Endpoint ldServiceEndpoint() {
  69 + EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
  70 + endpoint.publish("/LD_Service");
  71 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  72 + return endpoint;
  73 + }
  74 +
  75 + @Bean
  76 + public Endpoint attendanceServiceEndpoint() {
  77 + EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
  78 + endpoint.publish("/attendanceService");
  79 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  80 + return endpoint;
  81 + }
  82 +
  83 + @Bean
  84 + public Endpoint electricServiceEndpoint() {
  85 + EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
  86 + endpoint.publish("/oilServiceSoap");
  87 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  88 + return endpoint;
  89 + }
  90 +
  91 + @Autowired
  92 + ScheduleRealService scheduleRealService;
  93 + @Autowired
  94 + StationRestService stationRestService;
  95 + @Autowired
  96 + LD_SectionRestService ldSectionRestService;
  97 + @Autowired
  98 + SchedulePlanService schedulePlanService;
  99 + @Autowired
  100 + RealLogRestService realLogRestService;
  101 + @Autowired
  102 + GpsRestService gpsRestService;
  103 + @Autowired
  104 + DirectiveRestService directiveRestService;
  105 + @Autowired
  106 + LD_RoadSpeedRestService ld_roadSpeedRestService;
  107 + @Autowired
  108 + ElectricService electricService;
  109 + @Autowired
  110 + BigdateService bigdateService;
  111 + @Autowired
  112 + StaffViewRealService staffViewRealService;
  113 +
  114 + @Bean
  115 + public Server rsServer() {
  116 + JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
  117 + endpoint.setBus(springBus());
  118 + endpoint.setAddress("/rest");
  119 + endpoint.setServiceBeans(Arrays.<Object>asList(
  120 + new LineRestService(),
  121 + new CarRestService(),
  122 + new PersonRestService(),
  123 + gpsRestService,
  124 + scheduleRealService,
  125 + stationRestService,
  126 + ldSectionRestService,
  127 + schedulePlanService,
  128 + realLogRestService,
  129 + directiveRestService,
  130 + ld_roadSpeedRestService,
  131 + electricService,
  132 + staffViewRealService,
  133 + bigdateService));
  134 + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
  135 + //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
  136 + endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
  137 + return endpoint.create();
  138 + }
  139 +
  140 + @Bean
  141 + public ServletRegistrationBean servletRegistrationBean() {
  142 + ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
  143 + bean.setLoadOnStartup(0);
  144 + bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  145 + return bean;
  146 + }
  147 +}
... ...
src/main/java/com/bsth/server_rs/bigdata/BigdateService.java 0 → 100644
  1 +package com.bsth.server_rs.bigdata;
  2 +
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.text.DecimalFormat;
  6 +import java.util.HashMap;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +import javax.ws.rs.GET;
  11 +import javax.ws.rs.Path;
  12 +import javax.ws.rs.PathParam;
  13 +import javax.ws.rs.Produces;
  14 +import javax.ws.rs.core.MediaType;
  15 +
  16 +import org.slf4j.Logger;
  17 +import org.slf4j.LoggerFactory;
  18 +import org.springframework.beans.factory.annotation.Autowired;
  19 +import org.springframework.jdbc.core.JdbcTemplate;
  20 +import org.springframework.jdbc.core.RowMapper;
  21 +import org.springframework.stereotype.Component;
  22 +
  23 +import com.alibaba.fastjson.JSONObject;
  24 +
  25 +@Component
  26 +@Path("/bigdate")
  27 +@Produces({MediaType.APPLICATION_JSON})
  28 +public class BigdateService {
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + @Autowired
  32 + JdbcTemplate jdbcTemplate;
  33 +
  34 + DecimalFormat df = new DecimalFormat("0.00");
  35 +
  36 + /*
  37 + * 线路接口开始
  38 + */
  39 +
  40 + private static String getNature(String natureCode){
  41 + String natureName="";
  42 + if("lj".equals(natureCode)){
  43 + natureName="路救";
  44 + }else if("bc".equals(natureCode)){
  45 + natureName="备车";
  46 + }else if("dbc".equals(natureCode)){
  47 + natureName="定班车";
  48 + }else if("yxl".equals(natureCode)){
  49 + natureName="夜宵路";
  50 + }else if("cgxl".equals(natureCode)){
  51 + natureName="常规线路";
  52 + }else if("gjxl".equals(natureCode)){
  53 + natureName="过江线路";
  54 + }else if("csbs".equals(natureCode)){
  55 + natureName="穿梭巴士";
  56 + }else if("tyxl".equals(natureCode)){
  57 + natureName="特约线路";
  58 + }else if("cctxl".equals(natureCode)){
  59 + natureName="村村通线路";
  60 + }else if("qt".equals(natureCode)){
  61 + natureName="其他";
  62 + }else {
  63 + natureName="";
  64 + }
  65 + return natureName;
  66 + }
  67 +
  68 + private static String getGs(String gs){
  69 + String name="";
  70 + if("05".equals(gs)){
  71 + name="杨高公司";
  72 + }else if("22".equals(gs)){
  73 + name="金高公司";
  74 + }else if("26".equals(gs)){
  75 + name="南汇公司";
  76 + }else if("55".equals(gs)){
  77 + name="上南公司";
  78 + }else{
  79 + name="";
  80 + }
  81 + return name;
  82 + }
  83 +
  84 + private static String getState(String carState){
  85 + if(carState.equals("1")){
  86 + return "在册未在用";
  87 + }else if(carState.equals("2")){
  88 + return "在册在用";
  89 + }else if(carState.equals("3")){
  90 + return "报废审核中";
  91 + }else if(carState.equals("4")){
  92 + return "报废待更新";
  93 + }else if(carState.equals("5")){
  94 + return "报废已更新";
  95 + }else{
  96 + return "";
  97 + }
  98 + }
  99 + @GET
  100 + @Path("/line/all")
  101 + public List<Map<String, Object>> findLineAll(){
  102 + String sql="SELECT company,line_code,name,level,shanghai_linecode, nature from bsth_c_line where "
  103 + + " shanghai_linecode is not null and shanghai_linecode !='' and destroy=0 and remove=0 ";
  104 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  105 + new RowMapper<Map<String, Object>>(){
  106 + @Override
  107 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  108 + Map<String, Object> m=new HashMap<String,Object>();
  109 + m.put("company", rs.getString("company"));
  110 + m.put("companyName", getGs(rs.getString("company")));
  111 + m.put("lineCode",rs.getString("line_code"));
  112 + m.put("name", rs.getString("name"));
  113 + m.put("level", rs.getString("level"));
  114 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  115 + m.put("nature", getNature(rs.getString("nature")));
  116 + return m;
  117 + }
  118 + });
  119 + return list;
  120 + }
  121 +
  122 +
  123 + @GET
  124 + @Path("/line/company/{companyId}")
  125 + public List<Map<String, Object>> findLineByCompany(@PathParam("companyId") String companyId) {
  126 + String sql="SELECT company,line_code,name,level,shanghai_linecode, nature from bsth_c_line where "
  127 + + " shanghai_linecode is not null and shanghai_linecode !='' and destroy=0 and remove=0 "
  128 + + " and company = '"+companyId+"'";
  129 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  130 + new RowMapper<Map<String, Object>>(){
  131 + @Override
  132 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  133 + Map<String, Object> m=new HashMap<String,Object>();
  134 + m.put("company", rs.getString("company"));
  135 + m.put("companyName", getGs(rs.getString("company")));
  136 + m.put("lineCode",rs.getString("line_code"));
  137 + m.put("name", rs.getString("name"));
  138 + m.put("level", rs.getString("level"));
  139 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  140 + m.put("nature", getNature(rs.getString("nature")));
  141 + return m;
  142 + }
  143 + });
  144 + return list;
  145 + }
  146 +
  147 + @GET
  148 + @Path("/line/{lineCode}")
  149 + public List<Map<String, Object>> findLineByCode(@PathParam("lineCode") String lineCode) {
  150 + String sql="SELECT company,line_code,name,level,shanghai_linecode, nature from bsth_c_line where "
  151 + + " shanghai_linecode is not null and shanghai_linecode !='' and destroy=0 and remove=0 "
  152 + + " and line_code = '"+lineCode+"'";
  153 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  154 + new RowMapper<Map<String, Object>>(){
  155 + @Override
  156 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  157 + Map<String, Object> m=new HashMap<String,Object>();
  158 + m.put("company", rs.getString("company"));
  159 + m.put("companyName", getGs(rs.getString("company")));
  160 + m.put("lineCode",rs.getString("line_code"));
  161 + m.put("name", rs.getString("name"));
  162 + m.put("level", rs.getString("level"));
  163 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  164 + m.put("nature", getNature(rs.getString("nature")));
  165 + return m;
  166 + }
  167 + });
  168 + return list;
  169 + }
  170 +
  171 + @GET
  172 + @Path("/line/level/{levle}")
  173 + public List<Map<String, Object>> findLineByLevle(@PathParam("levle") String levle) {
  174 + String sql="SELECT company,line_code,name,level,shanghai_linecode, nature from bsth_c_line where "
  175 + + " shanghai_linecode is not null and shanghai_linecode !='' and destroy=0 and remove=0 "
  176 + + " and levle = '"+levle+"'";
  177 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  178 + new RowMapper<Map<String, Object>>(){
  179 + @Override
  180 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  181 + Map<String, Object> m=new HashMap<String,Object>();
  182 + m.put("company", rs.getString("company"));
  183 + m.put("companyName", getGs(rs.getString("company")));
  184 + m.put("lineCode",rs.getString("line_code"));
  185 + m.put("name", rs.getString("name"));
  186 + m.put("level", rs.getString("level"));
  187 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  188 + m.put("nature", getNature(rs.getString("nature")));
  189 + return m;
  190 + }
  191 + });
  192 + return list;
  193 + }
  194 + /*
  195 + * 线路接口结束
  196 + */
  197 +
  198 +
  199 + /*
  200 + * 线路配车接口开始
  201 + */
  202 + @GET
  203 + @Path("/lineCar/{type}/date/{date}")
  204 + public List<Map<String, Object>> findLineCarByDate(@PathParam("type") String type,@PathParam("date") String date) {
  205 + String sql="";
  206 + if(type.equals("all")){
  207 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc"
  208 + + " from bsth_c_calc_count t where t.date='"+date+"'";
  209 + }
  210 + if(type.equals("actual")){
  211 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc"
  212 + + " from bsth_c_calc_count t where t.date='"+date+"'";
  213 + }
  214 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  215 + new RowMapper<Map<String, Object>>(){
  216 + @Override
  217 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  218 + Map<String, Object> m=new HashMap<String,Object>();
  219 + m.put("date", rs.getString("date"));
  220 + m.put("company", rs.getString("gsdm"));
  221 + m.put("companyName", getGs(rs.getString("gsdm")));
  222 + m.put("lineCode",rs.getString("xl"));
  223 + m.put("lineName", rs.getString("xl_name"));
  224 + m.put("jhcc", rs.getString("jhcc"));
  225 + m.put("sjcc", rs.getString("sjcc"));
  226 + return m;
  227 + }
  228 + });
  229 +
  230 + return list;
  231 + }
  232 +
  233 +
  234 + @GET
  235 + @Path("/lineCar/{type}/date/{date}/line/{line}")
  236 + public List<Map<String, Object>> findLineCarByDateLine(@PathParam("type") String type,@PathParam("date") String date,
  237 + @PathParam("line") String line) {
  238 + String sql="";
  239 + if(type.equals("all")){
  240 + sql="select t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc"
  241 + + " from bsth_c_calc_count t where t.date='"+date+"'"
  242 + + " and xl ='"+line+"'";
  243 + }
  244 + if(type.equals("actual")){
  245 + sql="select t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc"
  246 + + " from bsth_c_calc_count t where t.date='"+date+"'"
  247 + + " and xl ='"+line+"'";
  248 +
  249 + }
  250 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  251 + new RowMapper<Map<String, Object>>(){
  252 + @Override
  253 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  254 + Map<String, Object> m=new HashMap<String,Object>();
  255 + m.put("company", rs.getString("gsdm"));
  256 + m.put("companyName", getGs(rs.getString("gsdm")));
  257 + m.put("lineCode",rs.getString("xl"));
  258 + m.put("lineName", rs.getString("xl_name"));
  259 + m.put("jhcc", rs.getString("jhcc"));
  260 + m.put("sjcc", rs.getString("sjcc"));
  261 + return m;
  262 + }
  263 + });
  264 +
  265 + return list;
  266 + }
  267 +
  268 + /*
  269 + * 线路配车接口结束
  270 + */
  271 +
  272 + /*
  273 + * 线路班次接口开始
  274 + */
  275 + @GET
  276 + @Path("/lineBc/{type}/date/{date}")
  277 + public List<Map<String, Object>> findLineBcByDate(@PathParam("type") String type,
  278 + @PathParam("date") String date) {
  279 + String sql="";
  280 + if(type.equals("all")){
  281 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhgfbcsz as gfbcs,"
  282 + + " t.jhdgbcsz as dgbcs,t.sjbc,t.sjgfbcs,t.sjdgbcs from bsth_c_calc_count t "
  283 + + " where t.date='"+date+"'";
  284 + }
  285 + if(type.equals("actual")){
  286 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhssgfbcs as gfbcs,"
  287 + + " t.jhssdgbcs as dgbcs, t.sjbc,t.sjgfbcs,t.sjdgbcs from bsth_c_calc_count t"
  288 + + " t where t.date='"+date+"'";
  289 + }
  290 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  291 + new RowMapper<Map<String, Object>>(){
  292 + @Override
  293 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  294 + Map<String, Object> m=new HashMap<String,Object>();
  295 + m.put("company", rs.getString("gsdm"));
  296 + m.put("companyName", getGs(rs.getString("gsdm")));
  297 + m.put("lineCode",rs.getString("xl"));
  298 + m.put("lineName", rs.getString("xl_name"));
  299 + m.put("jhbc", rs.getString("jhbc"));
  300 + m.put("gfbcs", rs.getString("gfbcs"));
  301 + m.put("dgbcs", rs.getString("dgbcs"));
  302 + m.put("sjbc", rs.getString("sjbc"));
  303 + m.put("sjgfbcs", rs.getString("sjgfbcs"));
  304 + m.put("sjdgbcs", rs.getString("sjdgbcs"));
  305 + return m;
  306 + }
  307 + });
  308 + return list;
  309 + }
  310 +
  311 +
  312 + @GET
  313 + @Path("/lineBc/{type}/date/{date}/line/{line}")
  314 + public List<Map<String, Object>> findLineBcByDateLine(@PathParam("type") String type,
  315 + @PathParam("date") String date,@PathParam("line") String line) {
  316 + String sql="";
  317 + if(type.equals("all")){
  318 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhgfbcsz as gfbcs,"
  319 + + " t.jhdgbcsz as dgbcs,t.sjbc,t.sjgfbcs,t.sjdgbcs from bsth_c_calc_count t "
  320 + + " where t.date='"+date+"' and xl='"+line+"'";
  321 + }
  322 + if(type.equals("actual")){
  323 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhssgfbcs as gfbcs,"
  324 + + " t.jhssdgbcs as dgbcs,t.sjbc,t.sjgfbcs,t.sjdgbcs from bsth_c_calc_count t"
  325 + + " t where t.date='"+date+"' and xl='"+line+"'";
  326 + }
  327 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  328 + new RowMapper<Map<String, Object>>(){
  329 + @Override
  330 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  331 + Map<String, Object> m=new HashMap<String,Object>();
  332 + m.put("company", rs.getString("gsdm"));
  333 + m.put("companyName", getGs(rs.getString("gsdm")));
  334 + m.put("lineCode",rs.getString("xl"));
  335 + m.put("lineName", rs.getString("xl_name"));
  336 + m.put("jhbc", rs.getString("jhbc"));
  337 + m.put("gfbcs", rs.getString("gfbcs"));
  338 + m.put("dgbcs", rs.getString("dgbcs"));
  339 + m.put("sjbc", rs.getString("sjbc"));
  340 + m.put("sjgfbcs", rs.getString("sjgfbcs"));
  341 + m.put("sjdgbcs", rs.getString("sjdgbcs"));
  342 + return m;
  343 + }
  344 + });
  345 + return list;
  346 + }
  347 +
  348 + /*
  349 + * 线路班次接口结束
  350 + */
  351 +
  352 + /*
  353 + * 线路里程接口开始
  354 + */
  355 +
  356 + @GET
  357 + @Path("/lineLc/{type}/date/{date}")
  358 + public List<Map<String, Object>> findLineLcByDate(@PathParam("type") String type,
  359 + @PathParam("date") String date) {
  360 + String sql="";
  361 + if(type.equals("all")){
  362 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc,"
  363 + + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  364 + + " where t.date='"+date+"'";
  365 + }
  366 + if(type.equals("actual")){
  367 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc,"
  368 + + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  369 + + " t where t.date='"+date+"'";
  370 + }
  371 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  372 + new RowMapper<Map<String, Object>>(){
  373 + @Override
  374 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  375 + Map<String, Object> m=new HashMap<String,Object>();
  376 + m.put("company", rs.getString("gsdm"));
  377 + m.put("companyName", getGs(rs.getString("gsdm")));
  378 + m.put("lineCode",rs.getString("xl"));
  379 + m.put("lineName", rs.getString("xl_name"));
  380 + m.put("jhzlc", rs.getString("jhzlc"));
  381 + m.put("jhyylc", rs.getString("jhyylc"));
  382 + m.put("jhkslc", rs.getString("jhkslc"));
  383 + m.put("sjzgl", rs.getString("sjzgl"));
  384 + m.put("sjyylc", rs.getString("sjyylc"));
  385 + m.put("sjkslc", rs.getString("sjkslc"));
  386 + if(Double.parseDouble(rs.getString("jhyylc"))>0){
  387 + double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc"));
  388 + m.put("yylczxl",df.format(yylczxl));
  389 + }else{
  390 + m.put("yylczxl",df.format("0.00"));
  391 + }
  392 + return m;
  393 + }
  394 + });
  395 + return list;
  396 + }
  397 +
  398 +
  399 + @GET
  400 + @Path("/lineLc/date/{type}/{date}/line/{line}")
  401 + public List<Map<String, Object>> findLineLcByDateLine(@PathParam("type") String type,
  402 + @PathParam("date") String date,@PathParam("line") String line) {
  403 + String sql="";
  404 + if(type.equals("all")){
  405 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc,"
  406 + + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  407 + + " where t.date='"+date+"' and xl ='"+line+"'";
  408 + }
  409 + if(type.equals("actual")){
  410 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc,"
  411 + + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  412 + + " t where t.date='"+date+"' and xl ='"+line+"'";
  413 + }
  414 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  415 + new RowMapper<Map<String, Object>>(){
  416 + @Override
  417 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  418 + Map<String, Object> m=new HashMap<String,Object>();
  419 + m.put("company", rs.getString("gsdm"));
  420 + m.put("companyName", getGs(rs.getString("gsdm")));
  421 + m.put("lineCode",rs.getString("xl"));
  422 + m.put("lineName", rs.getString("xl_name"));
  423 + m.put("jhzlc", rs.getString("jhzlc"));
  424 + m.put("jhyylc", rs.getString("jhyylc"));
  425 + m.put("jhkslc", rs.getString("jhkslc"));
  426 + m.put("sjzgl", rs.getString("sjzgl"));
  427 + m.put("sjyylc", rs.getString("sjyylc"));
  428 + m.put("sjkslc", rs.getString("sjkslc"));
  429 + if(Double.parseDouble(rs.getString("jhyylc"))>0){
  430 + double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc"));
  431 + m.put("yylczxl",df.format(yylczxl));
  432 + }else{
  433 + m.put("yylczxl",df.format("0.00"));
  434 + }
  435 + return m;
  436 + }
  437 + });
  438 + return list;
  439 + }
  440 + /*
  441 + * 线路里程接口结束
  442 + */
  443 +
  444 +
  445 + /*
  446 + * 车辆数据接口开始
  447 + */
  448 +
  449 + @GET
  450 + @Path("/car/all")
  451 + public List<Map<String, Object>> findCar() {
  452 + String carStr= GetHttpInterface.
  453 + getHttpInterface("http://222.66.0.204:8076/cars/getAllCarsInterface");
  454 + //车辆库资料资料
  455 + List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);
  456 + //调度系统车辆资料
  457 + String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars";
  458 + List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,
  459 + new RowMapper<Map<String, Object>>(){
  460 + @Override
  461 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  462 + Map<String, Object> m=new HashMap<String,Object>();
  463 + m.put("equipmentCode", rs.getString("equipment_code"));
  464 + m.put("insideCode", rs.getString("inside_code"));
  465 + m.put("supplierName",rs.getString("supplier_name"));
  466 + return m;
  467 + }
  468 + });
  469 + for (int i = 0; i < clkList.size(); i++) {
  470 + Map<String, Object> m1=clkList.get(i);
  471 + String carCode=m1.get("car_code").toString();
  472 + m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));
  473 + for (int j = 0; j < ddkList.size(); j++) {
  474 + Map<String, Object> m2=ddkList.get(j);
  475 + String insideCode=m2.get("insideCode").toString();
  476 + if(carCode.equals(insideCode)){
  477 + m1.put("insideCode", m2.get("insideCode"));
  478 + m1.put("supplierName", m2.get("supplierName"));
  479 + }
  480 +
  481 + }
  482 + }
  483 + return clkList;
  484 + }
  485 +
  486 +
  487 + @GET
  488 + @Path("/car/company/{companyId}")
  489 + public List<Map<String, Object>> findCarByCompany(@PathParam("companyId") String companyId) {
  490 + String carStr= GetHttpInterface.
  491 + getHttpInterface("http://222.66.0.204:8076/cars/getAllCarsInterface?company="+companyId);
  492 + //车辆库资料资料
  493 + List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);
  494 + //调度系统车辆资料
  495 + String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where business_code='"+companyId+"'";
  496 + List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,
  497 + new RowMapper<Map<String, Object>>(){
  498 + @Override
  499 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  500 + Map<String, Object> m=new HashMap<String,Object>();
  501 + m.put("equipmentCode", rs.getString("equipment_code"));
  502 + m.put("insideCode", rs.getString("inside_code"));
  503 + m.put("supplierName",rs.getString("supplier_name"));
  504 + return m;
  505 + }
  506 + });
  507 + for (int i = 0; i < clkList.size(); i++) {
  508 + Map<String, Object> m1=clkList.get(i);
  509 + String carCode=m1.get("car_code").toString();
  510 + m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));
  511 + for (int j = 0; j < ddkList.size(); j++) {
  512 + Map<String, Object> m2=ddkList.get(j);
  513 + String insideCode=m2.get("insideCode").toString();
  514 + if(carCode.equals(insideCode)){
  515 + m1.put("insideCode", m2.get("insideCode"));
  516 + m1.put("supplierName", m2.get("supplierName"));
  517 + }
  518 +
  519 + }
  520 + }
  521 + return clkList;
  522 + }
  523 +
  524 + @GET
  525 + @Path("/car/code/{carCode}")
  526 + public List<Map<String, Object>> findCarByCode(@PathParam("carCode") String carCode) {
  527 + String carStr= GetHttpInterface.
  528 + getHttpInterface("http://222.66.0.204:8076/cars/getAllCarsInterface?car_code="+carCode);
  529 + //车辆库资料资料
  530 + List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);
  531 + //调度系统车辆资料
  532 + String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where inside_code='"+carCode+"'";
  533 + List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,
  534 + new RowMapper<Map<String, Object>>(){
  535 + @Override
  536 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  537 + Map<String, Object> m=new HashMap<String,Object>();
  538 + m.put("equipment_code", rs.getString("equipment_code"));
  539 + m.put("insideCode", rs.getString("inside_code"));
  540 + m.put("supplier_name",rs.getString("supplier_name"));
  541 + return m;
  542 + }
  543 + });
  544 +
  545 + for (int i = 0; i < clkList.size(); i++) {
  546 + Map<String, Object> m1=clkList.get(i);
  547 + String code=m1.get("car_code").toString().trim();
  548 + m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));
  549 + for (int j = 0; j < ddkList.size(); j++) {
  550 + Map<String, Object> m2=ddkList.get(j);
  551 + String insideCode=m2.get("insideCode").toString().trim();
  552 + if(code.equals(insideCode)){
  553 + m1.put("equipment_code", m2.get("equipment_code"));
  554 + m1.put("supplier_name", m2.get("supplier_name"));
  555 + }
  556 +
  557 + }
  558 + }
  559 + return clkList;
  560 + }
  561 + /*
  562 + * 车辆数据接口结束
  563 + */
  564 +
  565 + /*
  566 + * 事故数据接口开始
  567 + */
  568 + @GET
  569 + @Path("/accident/startTime/{startTime}/endTime/{endTime}")
  570 + public List<Map<String, Object>> findAccident(@PathParam("startTime") String startTime,
  571 + @PathParam("endTime") String endTime) {
  572 + String accidentAll= GetHttpInterface.getHttpInterface("http://180.168.57.114:9019/pdsafe/LineSms/getAccidentSubmitAll.do?"
  573 + + "submitDateBegin="+startTime+"&submitDateEnd="+endTime);
  574 + List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);
  575 + return list;
  576 + }
  577 +
  578 + /*
  579 + * 事故数据接口结束
  580 + */
  581 +
  582 + /*
  583 + *安全驾驶接口开始
  584 + */
  585 +
  586 +
  587 + /*
  588 + *安全驾驶接口结束
  589 + */
  590 +}
... ...
src/main/java/com/bsth/server_rs/bigdata/GetHttpInterface.java 0 → 100644
  1 +package com.bsth.server_rs.bigdata;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.InputStreamReader;
  5 +import java.net.HttpURLConnection;
  6 +import java.net.URL;
  7 +import java.net.URLDecoder;
  8 +import java.security.MessageDigest;
  9 +import java.security.NoSuchAlgorithmException;
  10 +import java.util.Date;
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +import com.alibaba.fastjson.JSONObject;
  15 +
  16 +public class GetHttpInterface {
  17 + // 调用http接口获取数据
  18 + public static String getHttpInterface(String path){
  19 + System.out.println("调用开始");
  20 + BufferedReader in = null;
  21 + StringBuffer result = null;
  22 + try {
  23 + URL url = new URL(path);
  24 + //打开和url之间的连接
  25 + HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  26 + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  27 + connection.setRequestProperty("Charset", "utf-8");
  28 + connection.connect();
  29 +
  30 + result = new StringBuffer();
  31 + //读取URL的响应
  32 + in = new BufferedReader(new InputStreamReader(
  33 + connection.getInputStream()));
  34 + String line;
  35 + while ((line = in.readLine()) != null) {
  36 +
  37 + result.append(line);
  38 + }
  39 + // System.out.println(result.toString());
  40 + return result.toString();
  41 + } catch (Exception e) {
  42 + e.printStackTrace();
  43 + }finally {
  44 + try {
  45 + if (in != null) {
  46 + in.close();
  47 + }
  48 + } catch (Exception e2) {
  49 + e2.printStackTrace();
  50 + }
  51 + }
  52 + return null;
  53 + }
  54 +
  55 +}
... ...