Commit 6597099090b4391d16bd5a87d5376bfc32af017d

Authored by 王通
1 parent 1b24416b

1./external相关接口

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.number.NumberService;  
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 - NumberService numberService;  
118 - @Autowired  
119 - StaffViewRealService staffViewRealService;  
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 - numberService));  
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 -} 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.external.ExternalService;
  16 +import com.bsth.server_rs.gps.GpsRestService;
  17 +import com.bsth.server_rs.logs.RealLogRestService;
  18 +import com.bsth.server_rs.number.NumberService;
  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 + AuthorizeInterceptor_IN authorizeInterceptor_IN;
  97 + @Autowired
  98 + ScheduleRealService scheduleRealService;
  99 + @Autowired
  100 + StationRestService stationRestService;
  101 + @Autowired
  102 + LD_SectionRestService ldSectionRestService;
  103 + @Autowired
  104 + SchedulePlanService schedulePlanService;
  105 + @Autowired
  106 + RealLogRestService realLogRestService;
  107 + @Autowired
  108 + GpsRestService gpsRestService;
  109 + @Autowired
  110 + WaybillRestService waybillRestService;
  111 + @Autowired
  112 + DirectiveRestService directiveRestService;
  113 + @Autowired
  114 + LD_RoadSpeedRestService ld_roadSpeedRestService;
  115 + @Autowired
  116 + ElectricService electricService;
  117 + @Autowired
  118 + BigdataService bigdataService;
  119 + @Autowired
  120 + NumberService numberService;
  121 + @Autowired
  122 + StaffViewRealService staffViewRealService;
  123 + @Autowired
  124 + ExternalService externalService;
  125 +
  126 + @Bean
  127 + public Server rsServer() {
  128 + JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
  129 + endpoint.setBus(springBus());
  130 + endpoint.setAddress("/rest");
  131 + endpoint.setServiceBeans(Arrays.<Object>asList(
  132 + new LineRestService(),
  133 + new CarRestService(),
  134 + new PersonRestService(),
  135 + gpsRestService,
  136 + waybillRestService,
  137 + scheduleRealService,
  138 + stationRestService,
  139 + ldSectionRestService,
  140 + schedulePlanService,
  141 + realLogRestService,
  142 + directiveRestService,
  143 + ld_roadSpeedRestService,
  144 + electricService,
  145 + staffViewRealService,
  146 + bigdataService,
  147 + numberService,
  148 + externalService));
  149 + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
  150 + //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
  151 + endpoint.getInInterceptors().add(authorizeInterceptor_IN);
  152 + return endpoint.create();
  153 + }
  154 +
  155 + @Bean
  156 + public ServletRegistrationBean servletRegistrationBean() {
  157 + ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
  158 + bean.setLoadOnStartup(0);
  159 + bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  160 + return bean;
  161 + }
  162 +}
src/main/java/com/bsth/entity/PasswordUser.java
1 -package com.bsth.entity;  
2 -  
3 -import javax.persistence.*;  
4 -import java.util.Date;  
5 -  
6 -/**  
7 - * 接口 密码 访问用户  
8 - * Created by panzhao on 2017/3/26.  
9 - */  
10 -@Entity  
11 -@Table(name = "interface_user")  
12 -public class PasswordUser {  
13 -  
14 - @Id  
15 - @GeneratedValue  
16 - private Integer id;  
17 -  
18 - /** 访问密码 */  
19 - private String pwd;  
20 -  
21 - /** 调用方名称 */  
22 - private String callName;  
23 -  
24 - /** 创建日期 */  
25 - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")  
26 - private Date createDate;  
27 -  
28 - /** 备注 */  
29 - private String remark;  
30 -  
31 - public Integer getId() {  
32 - return id;  
33 - }  
34 -  
35 - public void setId(Integer id) {  
36 - this.id = id;  
37 - }  
38 -  
39 - public String getPwd() {  
40 - return pwd;  
41 - }  
42 -  
43 - public void setPwd(String pwd) {  
44 - this.pwd = pwd;  
45 - }  
46 -  
47 - public String getCallName() {  
48 - return callName;  
49 - }  
50 -  
51 - public void setCallName(String callName) {  
52 - this.callName = callName;  
53 - }  
54 -  
55 - public String getRemark() {  
56 - return remark;  
57 - }  
58 -  
59 - public void setRemark(String remark) {  
60 - this.remark = remark;  
61 - }  
62 -  
63 - public Date getCreateDate() {  
64 - return createDate;  
65 - }  
66 -  
67 - public void setCreateDate(Date createDate) {  
68 - this.createDate = createDate;  
69 - }  
70 -} 1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 接口 密码 访问用户
  9 + * Created by panzhao on 2017/3/26.
  10 + */
  11 +@Entity
  12 +@Table(name = "interface_user")
  13 +public class PasswordUser {
  14 +
  15 + @Id
  16 + @GeneratedValue
  17 + private Integer id;
  18 +
  19 + /** 访问密码 */
  20 + private String pwd;
  21 +
  22 + /** 调用方名称 */
  23 + private String callName;
  24 +
  25 + /** 创建日期 */
  26 + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  27 + private Date createDate;
  28 +
  29 + /** 备注 */
  30 + private String remark;
  31 +
  32 + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  33 + @JoinTable(name = "interface_users_resources",
  34 + joinColumns = @JoinColumn(name = "user_id"),
  35 + inverseJoinColumns = @JoinColumn(name = "resource_id"))
  36 + private List<Resource> resources;
  37 +
  38 + public Integer getId() {
  39 + return id;
  40 + }
  41 +
  42 + public void setId(Integer id) {
  43 + this.id = id;
  44 + }
  45 +
  46 + public String getPwd() {
  47 + return pwd;
  48 + }
  49 +
  50 + public void setPwd(String pwd) {
  51 + this.pwd = pwd;
  52 + }
  53 +
  54 + public String getCallName() {
  55 + return callName;
  56 + }
  57 +
  58 + public void setCallName(String callName) {
  59 + this.callName = callName;
  60 + }
  61 +
  62 + public String getRemark() {
  63 + return remark;
  64 + }
  65 +
  66 + public void setRemark(String remark) {
  67 + this.remark = remark;
  68 + }
  69 +
  70 + public Date getCreateDate() {
  71 + return createDate;
  72 + }
  73 +
  74 + public void setCreateDate(Date createDate) {
  75 + this.createDate = createDate;
  76 + }
  77 +
  78 + public List<Resource> getResources() {
  79 + return resources;
  80 + }
  81 +
  82 + public void setResources(List<Resource> resources) {
  83 + this.resources = resources;
  84 + }
  85 +}
src/main/java/com/bsth/server_rs/AuthorizeInterceptor_IN.java
1 -package com.bsth.server_rs;  
2 -  
3 -import com.bsth.server_rs.exception.AesException;  
4 -import com.bsth.service.UserService;  
5 -import org.apache.commons.lang3.StringEscapeUtils;  
6 -import org.apache.cxf.interceptor.Fault;  
7 -import org.apache.cxf.message.Message;  
8 -import org.apache.cxf.phase.AbstractPhaseInterceptor;  
9 -import org.apache.cxf.phase.Phase;  
10 -import org.eclipse.jetty.util.MultiMap;  
11 -import org.eclipse.jetty.util.UrlEncoded;  
12 -import org.slf4j.Logger;  
13 -import org.slf4j.LoggerFactory;  
14 -import org.springframework.beans.BeansException;  
15 -import org.springframework.context.ApplicationContext;  
16 -import org.springframework.context.ApplicationContextAware;  
17 -import org.springframework.stereotype.Component;  
18 -  
19 -import java.security.MessageDigest;  
20 -import java.util.Arrays;  
21 -import java.util.HashMap;  
22 -import java.util.Map;  
23 -import java.util.Set;  
24 -  
25 -/**  
26 - * rest 接口授权校验(IN 输入拦截)  
27 - * Created by panzhao on 2017/3/28.  
28 - */  
29 -@Component  
30 -public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> implements ApplicationContextAware {  
31 -  
32 - private static final String SIGN = "sign";  
33 - private static final String TIMESTAMP = "timestamp";  
34 - private static final String NONCE = "nonce";  
35 - private static final String PASSWORD = "password";  
36 - private static final int MAX_TIME_DIFF = 1000 * 60 * 10;  
37 - private static Map<String, String> pwd2nonceMap;  
38 -  
39 - static UserService userService;  
40 -  
41 - static Logger logger = LoggerFactory.getLogger(AuthorizeInterceptor_IN.class);  
42 -  
43 - public AuthorizeInterceptor_IN() {  
44 - super(Phase.RECEIVE);  
45 - }  
46 -  
47 - static {  
48 - pwd2nonceMap = new HashMap<>();  
49 - }  
50 -  
51 - @Override  
52 - public void handleMessage(Message message) throws Fault {  
53 -  
54 - long t = System.currentTimeMillis();  
55 - if (message.get(Message.QUERY_STRING) == null) {  
56 - throw new AesException(AesException.MISS_SIGN);  
57 - }  
58 -  
59 - //放行wadl  
60 - if(message.get(Message.QUERY_STRING).equals("_wadl")  
61 - && message.get(Message.PATH_INFO).equals("/webservice/rest")){  
62 - return ;  
63 - }  
64 -  
65 - //获取参数,不包括 url 路径参数 只包括?号之后的  
66 - String queryString = StringEscapeUtils.unescapeHtml4(message.get(Message.QUERY_STRING).toString());  
67 - MultiMap<String> params = new MultiMap<>();  
68 - UrlEncoded.decodeTo(queryString, params, "utf-8");  
69 - Map<String, String> map = multi2One(params);  
70 -  
71 - if (!map.containsKey(SIGN)) {  
72 - throw new AesException(AesException.MISS_SIGN);  
73 - }  
74 - if (!map.containsKey(TIMESTAMP)) {  
75 - throw new AesException(AesException.MISS_TIMESTAMP);  
76 - }  
77 -  
78 - try{  
79 - long timestamp = Long.parseLong(map.get(TIMESTAMP));  
80 - if(Math.abs(t - timestamp) > MAX_TIME_DIFF){  
81 - throw new AesException(AesException.INVALID_TIMESTAMP);  
82 - }  
83 - }catch(Exception e){  
84 - throw new AesException(AesException.INVALID_TIMESTAMP);  
85 - }  
86 -  
87 - if (!map.containsKey(NONCE)) {  
88 - throw new AesException(AesException.MISS_NONCE);  
89 - }  
90 - if (!map.containsKey(PASSWORD)) {  
91 - throw new AesException(AesException.MISS_PWD);  
92 - }  
93 -  
94 - String prevNonce = pwd2nonceMap.get(map.get(PASSWORD));  
95 - if(prevNonce != null && prevNonce.equals(map.get(NONCE)))  
96 - throw new AesException(AesException.NO_RANDOM_NONCE);  
97 -  
98 - if (userService.get(map.get(PASSWORD)) == null) {  
99 - throw new AesException(AesException.INVALID_PWD);  
100 - }  
101 -  
102 - String sign = map.get(SIGN);  
103 - map.remove(SIGN);  
104 - String sh1 = "";  
105 - try {  
106 - sh1 = getSHA1(map);  
107 - } catch (Exception e) {  
108 - throw new AesException(AesException.SIGN_CHECK_ERROR);  
109 - }  
110 -  
111 - if (!sign.equals(sh1)) {  
112 - throw new AesException(AesException.SIGN_CHECK_FAIL);  
113 - }  
114 - }  
115 -  
116 - public static Map<String, String> multi2One(MultiMap<String> params) {  
117 - Map<String, String> map = new HashMap<>();  
118 - Set<String> ks = params.keySet();  
119 - for (String k : ks) {  
120 - map.put(k, params.getString(k));  
121 - }  
122 - return map;  
123 - }  
124 -  
125 -  
126 - public static String getSHA1(Map<String, String> map) throws Exception {  
127 -  
128 - try {  
129 - String[] array = new String[map.size()];  
130 - map.values().toArray(array);  
131 - StringBuffer sb = new StringBuffer();  
132 -  
133 - // 字符串排序  
134 - Arrays.sort(array);  
135 - for (int i = 0; i < array.length; i++) {  
136 - sb.append(array[i]);  
137 - }  
138 - String str = sb.toString();  
139 - // SHA1签名生成  
140 - MessageDigest md = MessageDigest.getInstance("SHA-1");  
141 - md.update(str.getBytes());  
142 - byte[] digest = md.digest();  
143 -  
144 - StringBuffer hexstr = new StringBuffer();  
145 - String shaHex = "";  
146 - for (int i = 0; i < digest.length; i++) {  
147 - shaHex = Integer.toHexString(digest[i] & 0xFF);  
148 - if (shaHex.length() < 2) {  
149 - hexstr.append(0);  
150 - }  
151 - hexstr.append(shaHex);  
152 - }  
153 - return hexstr.toString();  
154 - } catch (Exception e) {  
155 - logger.error("", e);  
156 - throw e;  
157 - }  
158 - }  
159 -  
160 - @Override  
161 - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {  
162 - userService = applicationContext.getBean(UserService.class);  
163 - }  
164 -} 1 +package com.bsth.server_rs;
  2 +
  3 +import com.bsth.entity.PasswordUser;
  4 +import com.bsth.entity.Resource;
  5 +import com.bsth.server_rs.exception.AesException;
  6 +import com.bsth.service.UserService;
  7 +import org.apache.commons.lang3.StringEscapeUtils;
  8 +import org.apache.cxf.interceptor.Fault;
  9 +import org.apache.cxf.message.Message;
  10 +import org.apache.cxf.phase.AbstractPhaseInterceptor;
  11 +import org.apache.cxf.phase.Phase;
  12 +import org.eclipse.jetty.util.MultiMap;
  13 +import org.eclipse.jetty.util.UrlEncoded;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.beans.BeansException;
  17 +import org.springframework.beans.factory.annotation.Value;
  18 +import org.springframework.context.ApplicationContext;
  19 +import org.springframework.context.ApplicationContextAware;
  20 +import org.springframework.stereotype.Component;
  21 +import org.springframework.util.AntPathMatcher;
  22 +import org.springframework.util.PathMatcher;
  23 +
  24 +import java.io.BufferedReader;
  25 +import java.io.File;
  26 +import java.io.FileReader;
  27 +import java.io.IOException;
  28 +import java.security.MessageDigest;
  29 +import java.util.*;
  30 +import java.util.concurrent.ConcurrentHashMap;
  31 +
  32 +/**
  33 + * rest 接口授权校验(IN 输入拦截)
  34 + * Created by panzhao on 2017/3/28.
  35 + */
  36 +@Component
  37 +public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> implements ApplicationContextAware {
  38 +
  39 + private static final String SIGN = "sign";
  40 + private static final String TIMESTAMP = "timestamp";
  41 + private static final String NONCE = "nonce";
  42 + private static final String PASSWORD = "password";
  43 + private static final int MAX_TIME_DIFF = 1000 * 60 * 10;
  44 + private static Map<String, String> pwd2nonceMap;
  45 +
  46 + static UserService userService;
  47 +
  48 + static Logger logger = LoggerFactory.getLogger(AuthorizeInterceptor_IN.class);
  49 +
  50 + private static PathMatcher matcher = new AntPathMatcher();
  51 +
  52 + @Value("${path.limits}")
  53 + private String pathLimits;
  54 +
  55 + private Map<String, Set<String>> pwd2lines = new ConcurrentHashMap<>();
  56 +
  57 + private Map<String, Set<String>> pwd2device = new ConcurrentHashMap<>();
  58 +
  59 + private ThreadLocal<String> passwords = new ThreadLocal<>();
  60 +
  61 + public AuthorizeInterceptor_IN() {
  62 + super(Phase.RECEIVE);
  63 + }
  64 +
  65 + static {
  66 + pwd2nonceMap = new HashMap<>();
  67 + }
  68 +
  69 + @Override
  70 + public void handleMessage(Message message) throws Fault {
  71 +
  72 + long t = System.currentTimeMillis();
  73 + if (message.get(Message.QUERY_STRING) == null) {
  74 + throw new AesException(AesException.MISS_SIGN);
  75 + }
  76 +
  77 + //放行wadl
  78 + if(message.get(Message.QUERY_STRING).equals("_wadl")
  79 + && message.get(Message.PATH_INFO).equals("/webservice/rest")){
  80 + return ;
  81 + }
  82 +
  83 + //获取参数,不包括 url 路径参数 只包括?号之后的
  84 + String queryString = StringEscapeUtils.unescapeHtml4(message.get(Message.QUERY_STRING).toString());
  85 + MultiMap<String> params = new MultiMap<>();
  86 + UrlEncoded.decodeTo(queryString, params, "utf-8");
  87 + Map<String, String> map = multi2One(params);
  88 +
  89 + if (!map.containsKey(SIGN)) {
  90 + throw new AesException(AesException.MISS_SIGN);
  91 + }
  92 + if (!map.containsKey(TIMESTAMP)) {
  93 + throw new AesException(AesException.MISS_TIMESTAMP);
  94 + }
  95 +
  96 + try{
  97 + long timestamp = Long.parseLong(map.get(TIMESTAMP));
  98 + if(Math.abs(t - timestamp) > MAX_TIME_DIFF){
  99 + throw new AesException(AesException.INVALID_TIMESTAMP);
  100 + }
  101 + }catch(Exception e){
  102 + throw new AesException(AesException.INVALID_TIMESTAMP);
  103 + }
  104 +
  105 + if (!map.containsKey(NONCE)) {
  106 + throw new AesException(AesException.MISS_NONCE);
  107 + }
  108 + if (!map.containsKey(PASSWORD)) {
  109 + throw new AesException(AesException.MISS_PWD);
  110 + }
  111 +
  112 + String prevNonce = pwd2nonceMap.get(map.get(PASSWORD));
  113 + if(prevNonce != null && prevNonce.equals(map.get(NONCE)))
  114 + throw new AesException(AesException.NO_RANDOM_NONCE);
  115 +
  116 + if (userService.get(map.get(PASSWORD)) == null) {
  117 + throw new AesException(AesException.INVALID_PWD);
  118 + }
  119 +
  120 + String sign = map.get(SIGN);
  121 + map.remove(SIGN);
  122 + String sh1 = "";
  123 + try {
  124 + sh1 = getSHA1(map);
  125 + } catch (Exception e) {
  126 + throw new AesException(AesException.SIGN_CHECK_ERROR);
  127 + }
  128 +
  129 + if (!sign.equals(sh1)) {
  130 + throw new AesException(AesException.SIGN_CHECK_FAIL);
  131 + }
  132 +
  133 + validate(map, message);
  134 + }
  135 +
  136 + private void validate(Map<String, String> map, Message message) {
  137 + String password = map.get(PASSWORD);
  138 + PasswordUser user = userService.get(password);
  139 + if (user.getResources().size() > 0) {
  140 + loadLimit(password);
  141 + boolean isMatch = false;
  142 + String uri = (String) message.get(Message.REQUEST_URI);
  143 + for (Resource resource : user.getResources()) {
  144 + if (matcher.match(resource.getUrl(), uri)) {
  145 + isMatch = true;
  146 + break;
  147 + }
  148 + }
  149 + if (!isMatch) {
  150 + throw new AesException(AesException.INVALID_URI);
  151 + }
  152 + }
  153 + }
  154 +
  155 + public void loadLimit(String password) {
  156 + if (!pwd2lines.containsKey(password)) {
  157 + Set<String> set = new HashSet<>();
  158 + try {
  159 + BufferedReader reader = new BufferedReader(new FileReader(pathLimits + String.format("lines-%s.txt", password)));
  160 + String line = null;
  161 + while ((line = reader.readLine()) != null) {
  162 + set.add(line);
  163 + }
  164 + } catch (IOException e) {
  165 + logger.error("加载受限线路信息异常", e);
  166 + } finally {
  167 + pwd2lines.put(password, set);
  168 + }
  169 + }
  170 + if (!pwd2device.containsKey(password)) {
  171 + Set<String> set = new HashSet<>();
  172 + try {
  173 + BufferedReader reader = new BufferedReader(new FileReader(pathLimits + String.format("devices-%s.txt", password)));
  174 + String line = null;
  175 + while ((line = reader.readLine()) != null) {
  176 + set.add(line);
  177 + }
  178 + } catch (IOException e) {
  179 + logger.error("加载受限设备信息异常", e);
  180 + } finally {
  181 + pwd2device.put(password, set);
  182 + }
  183 + }
  184 + }
  185 +
  186 + public Set<String> getLimitLines(String password) {
  187 + return pwd2lines.get(password);
  188 + }
  189 +
  190 + public Set<String> getLimitDevices(String password) {
  191 + return pwd2device.get(password);
  192 + }
  193 +
  194 + public ThreadLocal<String> getPasswords() {
  195 + return passwords;
  196 + }
  197 +
  198 + public static Map<String, String> multi2One(MultiMap<String> params) {
  199 + Map<String, String> map = new HashMap<>();
  200 + Set<String> ks = params.keySet();
  201 + for (String k : ks) {
  202 + map.put(k, params.getString(k));
  203 + }
  204 + return map;
  205 + }
  206 +
  207 +
  208 + public static String getSHA1(Map<String, String> map) throws Exception {
  209 +
  210 + try {
  211 + String[] array = new String[map.size()];
  212 + map.values().toArray(array);
  213 + StringBuffer sb = new StringBuffer();
  214 +
  215 + // 字符串排序
  216 + Arrays.sort(array);
  217 + for (int i = 0; i < array.length; i++) {
  218 + sb.append(array[i]);
  219 + }
  220 + String str = sb.toString();
  221 + // SHA1签名生成
  222 + MessageDigest md = MessageDigest.getInstance("SHA-1");
  223 + md.update(str.getBytes());
  224 + byte[] digest = md.digest();
  225 +
  226 + StringBuffer hexstr = new StringBuffer();
  227 + String shaHex = "";
  228 + for (int i = 0; i < digest.length; i++) {
  229 + shaHex = Integer.toHexString(digest[i] & 0xFF);
  230 + if (shaHex.length() < 2) {
  231 + hexstr.append(0);
  232 + }
  233 + hexstr.append(shaHex);
  234 + }
  235 + return hexstr.toString();
  236 + } catch (Exception e) {
  237 + logger.error("", e);
  238 + throw e;
  239 + }
  240 + }
  241 +
  242 + @Override
  243 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  244 + userService = applicationContext.getBean(UserService.class);
  245 + }
  246 +}
src/main/java/com/bsth/server_rs/base_info/car/Car.java
1 -package com.bsth.server_rs.base_info.car;  
2 -  
3 -import javax.xml.bind.annotation.XmlRootElement;  
4 -import java.io.Serializable;  
5 -  
6 -/**  
7 - * 车辆信息  
8 - * Created by panzhao on 2017/3/30.  
9 - */  
10 -@XmlRootElement  
11 -public class Car implements Serializable {  
12 -  
13 - /**  
14 - * 自编号/内部编号  
15 - */  
16 - private String nbbm;  
17 -  
18 - /**  
19 - * 公司代码  
20 - */  
21 - private String companyCode;  
22 - /**  
23 - * 分公司编码  
24 - */  
25 - private String brancheCompanyCode;  
26 -  
27 - /**  
28 - * 车牌号  
29 - */  
30 - private String carPlate;  
31 - /**  
32 - * 设备终端号  
33 - */  
34 - private String equipmentCode;  
35 - /**  
36 - * 车辆类型  
37 - */  
38 - private String carType;  
39 - /**  
40 - * 是否机动车(机动车类型选择)  
41 - */  
42 - private String vehicleStats;  
43 -  
44 - /**  
45 - * 是否电车(TODO:在原系统里没有,这里暂时留着)  
46 - */  
47 - private Boolean sfdc;  
48 - /**  
49 - * 是否报废  
50 - */  
51 - private Boolean scrapState;  
52 -  
53 - /**  
54 - * RFID 车卡ID号(16进制)  
55 - */  
56 - private String idRfid;  
57 -  
58 - /**  
59 - * RFID 标签号  
60 - */  
61 - private String tagRfid;  
62 -  
63 - private String lineCode;  
64 -  
65 - private String lineName;  
66 -  
67 - private String remark;  
68 -  
69 - public String getNbbm() {  
70 - return nbbm;  
71 - }  
72 -  
73 - public void setNbbm(String nbbm) {  
74 - this.nbbm = nbbm;  
75 - }  
76 -  
77 - public String getCompanyCode() {  
78 - return companyCode;  
79 - }  
80 -  
81 - public void setCompanyCode(String companyCode) {  
82 - this.companyCode = companyCode;  
83 - }  
84 -  
85 - public String getBrancheCompanyCode() {  
86 - return brancheCompanyCode;  
87 - }  
88 -  
89 - public void setBrancheCompanyCode(String brancheCompanyCode) {  
90 - this.brancheCompanyCode = brancheCompanyCode;  
91 - }  
92 -  
93 - public String getCarPlate() {  
94 - return carPlate;  
95 - }  
96 -  
97 - public void setCarPlate(String carPlate) {  
98 - this.carPlate = carPlate;  
99 - }  
100 -  
101 - public String getEquipmentCode() {  
102 - return equipmentCode;  
103 - }  
104 -  
105 - public void setEquipmentCode(String equipmentCode) {  
106 - this.equipmentCode = equipmentCode;  
107 - }  
108 -  
109 - public String getCarType() {  
110 - return carType;  
111 - }  
112 -  
113 - public void setCarType(String carType) {  
114 - this.carType = carType;  
115 - }  
116 -  
117 - public String getVehicleStats() {  
118 - return vehicleStats;  
119 - }  
120 -  
121 - public void setVehicleStats(String vehicleStats) {  
122 - this.vehicleStats = vehicleStats;  
123 - }  
124 -  
125 - public Boolean getSfdc() {  
126 - return sfdc;  
127 - }  
128 -  
129 - public void setSfdc(Boolean sfdc) {  
130 - this.sfdc = sfdc;  
131 - }  
132 -  
133 - public Boolean getScrapState() {  
134 - return scrapState;  
135 - }  
136 -  
137 - public void setScrapState(Boolean scrapState) {  
138 - this.scrapState = scrapState;  
139 - }  
140 -  
141 - public String getIdRfid() {  
142 - return idRfid;  
143 - }  
144 -  
145 - public void setIdRfid(String idRfid) {  
146 - this.idRfid = idRfid;  
147 - }  
148 -  
149 - public String getTagRfid() {  
150 - return tagRfid;  
151 - }  
152 -  
153 - public void setTagRfid(String tagRfid) {  
154 - this.tagRfid = tagRfid;  
155 - }  
156 -  
157 - public String getLineCode() {  
158 - return lineCode;  
159 - }  
160 -  
161 - public void setLineCode(String lineCode) {  
162 - this.lineCode = lineCode;  
163 - }  
164 -  
165 - public String getLineName() {  
166 - return lineName;  
167 - }  
168 -  
169 - public void setLineName(String lineName) {  
170 - this.lineName = lineName;  
171 - }  
172 -  
173 - public String getRemark() {  
174 - return remark;  
175 - }  
176 -  
177 - public void setRemark(String remark) {  
178 - this.remark = remark;  
179 - }  
180 -} 1 +package com.bsth.server_rs.base_info.car;
  2 +
  3 +import javax.xml.bind.annotation.XmlRootElement;
  4 +import java.io.Serializable;
  5 +import java.util.Date;
  6 +
  7 +/**
  8 + * 车辆信息
  9 + * Created by panzhao on 2017/3/30.
  10 + */
  11 +@XmlRootElement
  12 +public class Car implements Serializable {
  13 +
  14 + /**
  15 + * 自编号/内部编号
  16 + */
  17 + private String nbbm;
  18 +
  19 + /**
  20 + * 公司代码
  21 + */
  22 + private String companyCode;
  23 + /**
  24 + * 分公司编码
  25 + */
  26 + private String brancheCompanyCode;
  27 +
  28 + /**
  29 + * 车牌号
  30 + */
  31 + private String carPlate;
  32 + /**
  33 + * 设备终端号
  34 + */
  35 + private String equipmentCode;
  36 + /**
  37 + * 车辆类型
  38 + */
  39 + private String carType;
  40 + /**
  41 + * 是否机动车(机动车类型选择)
  42 + */
  43 + private String vehicleStats;
  44 +
  45 + /**
  46 + * 是否电车(TODO:在原系统里没有,这里暂时留着)
  47 + */
  48 + private Boolean sfdc;
  49 + /**
  50 + * 是否报废
  51 + */
  52 + private Boolean scrapState;
  53 +
  54 + /**
  55 + * RFID 车卡ID号(16进制)
  56 + */
  57 + private String idRfid;
  58 +
  59 + /**
  60 + * RFID 标签号
  61 + */
  62 + private String tagRfid;
  63 +
  64 + private String lineCode;
  65 +
  66 + private String lineName;
  67 +
  68 + private String remark;
  69 +
  70 + private Date updateDate;
  71 +
  72 + private String vehicleType;
  73 +
  74 + public String getNbbm() {
  75 + return nbbm;
  76 + }
  77 +
  78 + public void setNbbm(String nbbm) {
  79 + this.nbbm = nbbm;
  80 + }
  81 +
  82 + public String getCompanyCode() {
  83 + return companyCode;
  84 + }
  85 +
  86 + public void setCompanyCode(String companyCode) {
  87 + this.companyCode = companyCode;
  88 + }
  89 +
  90 + public String getBrancheCompanyCode() {
  91 + return brancheCompanyCode;
  92 + }
  93 +
  94 + public void setBrancheCompanyCode(String brancheCompanyCode) {
  95 + this.brancheCompanyCode = brancheCompanyCode;
  96 + }
  97 +
  98 + public String getCarPlate() {
  99 + return carPlate;
  100 + }
  101 +
  102 + public void setCarPlate(String carPlate) {
  103 + this.carPlate = carPlate;
  104 + }
  105 +
  106 + public String getEquipmentCode() {
  107 + return equipmentCode;
  108 + }
  109 +
  110 + public void setEquipmentCode(String equipmentCode) {
  111 + this.equipmentCode = equipmentCode;
  112 + }
  113 +
  114 + public String getCarType() {
  115 + return carType;
  116 + }
  117 +
  118 + public void setCarType(String carType) {
  119 + this.carType = carType;
  120 + }
  121 +
  122 + public String getVehicleStats() {
  123 + return vehicleStats;
  124 + }
  125 +
  126 + public void setVehicleStats(String vehicleStats) {
  127 + this.vehicleStats = vehicleStats;
  128 + }
  129 +
  130 + public Boolean getSfdc() {
  131 + return sfdc;
  132 + }
  133 +
  134 + public void setSfdc(Boolean sfdc) {
  135 + this.sfdc = sfdc;
  136 + }
  137 +
  138 + public Boolean getScrapState() {
  139 + return scrapState;
  140 + }
  141 +
  142 + public void setScrapState(Boolean scrapState) {
  143 + this.scrapState = scrapState;
  144 + }
  145 +
  146 + public String getIdRfid() {
  147 + return idRfid;
  148 + }
  149 +
  150 + public void setIdRfid(String idRfid) {
  151 + this.idRfid = idRfid;
  152 + }
  153 +
  154 + public String getTagRfid() {
  155 + return tagRfid;
  156 + }
  157 +
  158 + public void setTagRfid(String tagRfid) {
  159 + this.tagRfid = tagRfid;
  160 + }
  161 +
  162 + public String getLineCode() {
  163 + return lineCode;
  164 + }
  165 +
  166 + public void setLineCode(String lineCode) {
  167 + this.lineCode = lineCode;
  168 + }
  169 +
  170 + public String getLineName() {
  171 + return lineName;
  172 + }
  173 +
  174 + public void setLineName(String lineName) {
  175 + this.lineName = lineName;
  176 + }
  177 +
  178 + public String getRemark() {
  179 + return remark;
  180 + }
  181 +
  182 + public void setRemark(String remark) {
  183 + this.remark = remark;
  184 + }
  185 +
  186 + public Date getUpdateDate() {
  187 + return updateDate;
  188 + }
  189 +
  190 + public void setUpdateDate(Date updateDate) {
  191 + this.updateDate = updateDate;
  192 + }
  193 +
  194 + public String getVehicleType() {
  195 + return vehicleType;
  196 + }
  197 +
  198 + public void setVehicleType(String vehicleType) {
  199 + this.vehicleType = vehicleType;
  200 + }
  201 +}
src/main/java/com/bsth/server_rs/base_info/car/buffer/CarBufferData.java
1 -package com.bsth.server_rs.base_info.car.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.dto.BusCardDto;  
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.*;  
13 -import java.util.concurrent.TimeUnit;  
14 -  
15 -/**  
16 - * 车辆数据缓存  
17 - * Created by panzhao on 2017/3/30.  
18 - */  
19 -@Component  
20 -@Order(6)  
21 -public class CarBufferData implements CommandLineRunner {  
22 -  
23 - private static List<Car> data;  
24 - private static Map<String, Car> idMap;  
25 - private static ArrayListMultimap<String, Car> companyListMap;  
26 -  
27 - /**  
28 - * 待入库的bus car  
29 - */  
30 - public static LinkedList<Car> pstList = new LinkedList<>();  
31 -  
32 - @Autowired  
33 - CarRefreshThread carRefreshThread;  
34 -  
35 - public static List<Car> findAll(){  
36 - return data;  
37 - }  
38 -  
39 - public static Car findOne(String nbbm){  
40 - return idMap.get(nbbm);  
41 - }  
42 -  
43 - public static List<Car> findByCompany(String company){  
44 - return companyListMap.get(company);  
45 - }  
46 -  
47 - public static void replaceAll(List<Car> newData){  
48 - data = newData;  
49 - Map<String, Car> idMapCopy = new HashMap<>();  
50 - ArrayListMultimap<String, Car> listMap = ArrayListMultimap.create();  
51 -  
52 - for(Car car : data){  
53 - idMapCopy.put(car.getNbbm(), car);  
54 - listMap.put(car.getCompanyCode(), car);  
55 - }  
56 - idMap = idMapCopy;  
57 -  
58 - companyListMap = listMap;  
59 - }  
60 -  
61 - @Override  
62 - public void run(String... strings) throws Exception {  
63 - Application.mainServices.scheduleWithFixedDelay(carRefreshThread, 10, 60 * 60, TimeUnit.SECONDS);  
64 - }  
65 -  
66 - public static Map<String, Object> multiSaveCards(List<BusCardDto> list) {  
67 - int success=0,error=0;  
68 - //返回写入成功的卡数据  
69 - List<BusCardDto> rsList = new ArrayList<>();  
70 -  
71 - Car c;  
72 - for(BusCardDto bcd : list){  
73 - c = idMap.get(bcd.getNbbm());  
74 - if(c == null)  
75 - error ++;  
76 - else{  
77 - c.setIdRfid(bcd.getIdCard());  
78 - c.setTagRfid(bcd.getTagCard());  
79 - c.setRemark(bcd.getRemark());  
80 - success ++;  
81 -  
82 - pstList.add(c);  
83 - rsList.add(bcd);  
84 - }  
85 - }  
86 -  
87 - Map<String, Object> rs = new HashMap<>();  
88 - rs.put("success", success);  
89 - rs.put("successList", rsList);  
90 - rs.put("error", error);  
91 - return rs;  
92 - }  
93 -} 1 +package com.bsth.server_rs.base_info.car.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.dto.BusCardDto;
  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.*;
  13 +import java.util.concurrent.TimeUnit;
  14 +
  15 +/**
  16 + * 车辆数据缓存
  17 + * Created by panzhao on 2017/3/30.
  18 + */
  19 +@Component
  20 +@Order(6)
  21 +public class CarBufferData implements CommandLineRunner {
  22 +
  23 + private static List<Car> data;
  24 + private static Map<String, Car> idMap;
  25 + private static ArrayListMultimap<String, Car> companyListMap;
  26 + private static Map<String, Car> device2car = new HashMap<>();
  27 +
  28 + /**
  29 + * 待入库的bus car
  30 + */
  31 + public static LinkedList<Car> pstList = new LinkedList<>();
  32 +
  33 + @Autowired
  34 + CarRefreshThread carRefreshThread;
  35 +
  36 + public static List<Car> findAll(){
  37 + return data;
  38 + }
  39 +
  40 + public static Car findOne(String nbbm){
  41 + return idMap.get(nbbm);
  42 + }
  43 +
  44 + public static List<Car> findByCompany(String company){
  45 + return companyListMap.get(company);
  46 + }
  47 +
  48 + public static Car findByDevice(String device){
  49 + return device2car.get(device);
  50 + }
  51 +
  52 + public static void replaceAll(List<Car> newData){
  53 + data = newData;
  54 + Map<String, Car> idMapCopy = new HashMap<>();
  55 + ArrayListMultimap<String, Car> listMap = ArrayListMultimap.create();
  56 + Map<String, Car> device2carCopy = new HashMap<>();
  57 +
  58 + for(Car car : data){
  59 + idMapCopy.put(car.getNbbm(), car);
  60 + listMap.put(car.getCompanyCode(), car);
  61 + device2carCopy.put(car.getEquipmentCode(), car);
  62 + }
  63 + idMap = idMapCopy;
  64 +
  65 + companyListMap = listMap;
  66 + device2car = device2carCopy;
  67 + }
  68 +
  69 + @Override
  70 + public void run(String... strings) throws Exception {
  71 + Application.mainServices.scheduleWithFixedDelay(carRefreshThread, 10, 60 * 60, TimeUnit.SECONDS);
  72 + }
  73 +
  74 + public static Map<String, Object> multiSaveCards(List<BusCardDto> list) {
  75 + int success=0,error=0;
  76 + //返回写入成功的卡数据
  77 + List<BusCardDto> rsList = new ArrayList<>();
  78 +
  79 + Car c;
  80 + for(BusCardDto bcd : list){
  81 + c = idMap.get(bcd.getNbbm());
  82 + if(c == null)
  83 + error ++;
  84 + else{
  85 + c.setIdRfid(bcd.getIdCard());
  86 + c.setTagRfid(bcd.getTagCard());
  87 + c.setRemark(bcd.getRemark());
  88 + success ++;
  89 +
  90 + pstList.add(c);
  91 + rsList.add(bcd);
  92 + }
  93 + }
  94 +
  95 + Map<String, Object> rs = new HashMap<>();
  96 + rs.put("success", success);
  97 + rs.put("successList", rsList);
  98 + rs.put("error", error);
  99 + return rs;
  100 + }
  101 +}
src/main/java/com/bsth/server_rs/base_info/car/buffer/CarRefreshThread.java
1 -package com.bsth.server_rs.base_info.car.buffer;  
2 -  
3 -import com.bsth.server_rs.base_info.car.Car;  
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.ArrayList;  
12 -import java.util.HashMap;  
13 -import java.util.List;  
14 -import java.util.Map;  
15 -  
16 -/**  
17 - * Created by panzhao on 2017/3/30.  
18 - */  
19 -@Component  
20 -public class CarRefreshThread extends Thread{  
21 -  
22 - @Autowired  
23 - JdbcTemplate jdbcTemplate;  
24 -  
25 - Logger logger = LoggerFactory.getLogger(this.getClass());  
26 -  
27 - @Override  
28 - public void run() {  
29 -  
30 - try {  
31 -  
32 - List<Car> list = jdbcTemplate.query("SELECT DISTINCT t1.*,t2.line_code,t2.name as line_name FROM(SELECT c.inside_code as nbbm,c.business_code as company_code,c.branche_company_code,c.car_plate,c.equipment_code,c.car_type,c.vehicle_stats,c.sfdc,c.scrap_state,c.id_rfid,c.tag_rfid,c2.xl FROM bsth_c_cars c LEFT JOIN bsth_c_s_ccinfo c2 ON c.id = c2.cl and c2.is_cancel=0) t1 LEFT JOIN bsth_c_line t2 on t1.xl=t2.id"  
33 - , BeanPropertyRowMapper.newInstance(Car.class));  
34 -  
35 - Map<String, Car> map = new HashMap<>();  
36 - //过滤数据,多条线路配车的保留一条  
37 - for(Car c : list){  
38 - map.put(c.getNbbm(), c);  
39 - }  
40 -  
41 - if(list != null && list.size() > 0)  
42 - CarBufferData.replaceAll(new ArrayList(map.values()));  
43 - }catch (Exception e){  
44 - logger.error("", e);  
45 - }  
46 - }  
47 -} 1 +package com.bsth.server_rs.base_info.car.buffer;
  2 +
  3 +import com.bsth.server_rs.base_info.car.Car;
  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.ArrayList;
  12 +import java.util.HashMap;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Created by panzhao on 2017/3/30.
  18 + */
  19 +@Component
  20 +public class CarRefreshThread extends Thread{
  21 +
  22 + @Autowired
  23 + JdbcTemplate jdbcTemplate;
  24 +
  25 + Logger logger = LoggerFactory.getLogger(this.getClass());
  26 +
  27 + @Override
  28 + public void run() {
  29 +
  30 + try {
  31 +
  32 + List<Car> list = jdbcTemplate.query("SELECT DISTINCT t1.*,t2.line_code,t2.name as line_name FROM(SELECT c.inside_code as nbbm,c.business_code as company_code,c.branche_company_code,c.car_plate,c.equipment_code,c.car_type,c.vehicle_stats,c.sfdc,c.scrap_state,c.id_rfid,c.tag_rfid,c.update_date,c2.xl,c2.qyrq,c.vehicle_type FROM bsth_c_cars c LEFT JOIN bsth_c_s_ccinfo c2 ON c.id = c2.cl and c2.is_cancel=0) t1 LEFT JOIN bsth_c_line t2 on t1.xl=t2.id ORDER BY nbbm,qyrq"
  33 + , BeanPropertyRowMapper.newInstance(Car.class));
  34 +
  35 + Map<String, Car> map = new HashMap<>();
  36 + //过滤数据,多条线路配车的保留一条
  37 + for(Car c : list){
  38 + map.put(c.getNbbm(), c);
  39 + }
  40 +
  41 + if(list != null && list.size() > 0)
  42 + CarBufferData.replaceAll(new ArrayList(map.values()));
  43 + }catch (Exception e){
  44 + logger.error("", e);
  45 + }
  46 + }
  47 +}
src/main/java/com/bsth/server_rs/bigdata/BigdataService.java
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.text.SimpleDateFormat;  
7 -import java.util.Calendar;  
8 -import java.util.Date;  
9 -import java.util.HashMap;  
10 -import java.util.List;  
11 -import java.util.Map;  
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 -  
19 -import org.slf4j.Logger;  
20 -import org.slf4j.LoggerFactory;  
21 -import org.springframework.beans.factory.annotation.Autowired;  
22 -import org.springframework.jdbc.core.JdbcTemplate;  
23 -import org.springframework.jdbc.core.RowMapper;  
24 -import org.springframework.stereotype.Component;  
25 -  
26 -import com.alibaba.fastjson.JSONObject;  
27 -  
28 -@Component  
29 -@Path("/bigdata")  
30 -@Produces({MediaType.APPLICATION_JSON})  
31 -public class BigdataService {  
32 - Logger logger = LoggerFactory.getLogger(this.getClass());  
33 -  
34 - @Autowired  
35 - JdbcTemplate jdbcTemplate;  
36 -  
37 - DecimalFormat df = new DecimalFormat("0.00");  
38 -  
39 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
40 -  
41 - /*  
42 - * 线路接口开始  
43 - */  
44 -  
45 - private static String getNature(String natureCode){  
46 - String natureName="";  
47 - if("lj".equals(natureCode)){  
48 - natureName="路救";  
49 - }else if("bc".equals(natureCode)){  
50 - natureName="备车";  
51 - }else if("dbc".equals(natureCode)){  
52 - natureName="定班车";  
53 - }else if("yxl".equals(natureCode)){  
54 - natureName="夜宵路";  
55 - }else if("cgxl".equals(natureCode)){  
56 - natureName="常规线路";  
57 - }else if("gjxl".equals(natureCode)){  
58 - natureName="过江线路";  
59 - }else if("csbs".equals(natureCode)){  
60 - natureName="穿梭巴士";  
61 - }else if("tyxl".equals(natureCode)){  
62 - natureName="特约线路";  
63 - }else if("cctxl".equals(natureCode)){  
64 - natureName="村村通线路";  
65 - }else if("qt".equals(natureCode)){  
66 - natureName="其他";  
67 - }else {  
68 - natureName="";  
69 - }  
70 - return natureName;  
71 - }  
72 -  
73 - private static String getGs(String gs){  
74 - String name="";  
75 - if("05".equals(gs)){  
76 - name="杨高公司";  
77 - }else if("22".equals(gs)){  
78 - name="金高公司";  
79 - }else if("26".equals(gs)){  
80 - name="南汇公司";  
81 - }else if("55".equals(gs)){  
82 - name="上南公司";  
83 - }else{  
84 - name="";  
85 - }  
86 - return name;  
87 - }  
88 -  
89 - private static String getState(String carState){  
90 - if(carState.equals("1")){  
91 - return "在册未在用";  
92 - }else if(carState.equals("2")){  
93 - return "在册在用";  
94 - }else if(carState.equals("3")){  
95 - return "报废审核中";  
96 - }else if(carState.equals("4")){  
97 - return "报废待更新";  
98 - }else if(carState.equals("5")){  
99 - return "报废已更新";  
100 - }else{  
101 - return "";  
102 - }  
103 - }  
104 - public Map<String, Long> getEndtime(String date){  
105 - Map<String, Long> map=new HashMap<String,Long>();  
106 - List<String> objList = new ArrayList<String>();  
107 - String sql="select xl,endtime from bsth_c_calc_count "  
108 - + " where date = ? ";  
109 - objList.add(date);  
110 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
111 - new RowMapper<Map<String, Object>>(){  
112 - @Override  
113 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
114 - Map<String, Object> m=new HashMap<String, Object>();  
115 - m.put("line", rs.getString("xl"));  
116 - m.put("endtime", rs.getString("endtime"));  
117 - return m;  
118 - }  
119 - });  
120 - for (int i = 0; i < list.size(); i++) {  
121 - map.put(list.get(i).get("line").toString(),  
122 - Long.parseLong(list.get(i).get("endtime").toString()));  
123 - }  
124 - return map;  
125 - }  
126 - @GET  
127 - @Path("/line/all")  
128 - public List<Map<String, Object>> findLineAll(){  
129 - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"  
130 - + " a.shanghai_linecode, a.nature from "  
131 - + " bsth_c_line a left join bsth_c_line_config b "  
132 - + " on a.id=b.line where "  
133 - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "  
134 - + " and a.remove=0 ";  
135 - List<Map<String, Object>> list=jdbcTemplate.query(sql,  
136 - new RowMapper<Map<String, Object>>(){  
137 - @Override  
138 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
139 - Map<String, Object> m=new HashMap<String,Object>();  
140 - m.put("state", rs.getString("start_opt"));  
141 - m.put("company", rs.getString("company"));  
142 - m.put("companyName", getGs(rs.getString("company")));  
143 - m.put("lineCode",rs.getString("line_code"));  
144 - m.put("name", rs.getString("name"));  
145 - m.put("level", rs.getString("level"));  
146 - m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));  
147 - m.put("nature", getNature(rs.getString("nature")));  
148 - return m;  
149 - }  
150 - });  
151 - Date d=new Date();  
152 - SimpleDateFormat hm=new SimpleDateFormat("HH:mm");  
153 - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");  
154 -  
155 - String qqrq=ymd.format(d);  
156 - String qqsj=hm.format(d);  
157 - String qqsjs[]=qqsj.split(":");  
158 - Date nDate=new Date();  
159 - Calendar calendar = Calendar.getInstance();  
160 - calendar.setTime(nDate);  
161 - calendar.add(Calendar.DAY_OF_MONTH, -1);  
162 - Date dBefore = calendar.getTime();  
163 - String qqrqbefore =ymd.format(dBefore);  
164 - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);  
165 - Map<String, Long> endMap1=getEndtime(qqrqbefore);  
166 - Map<String, Long> endMap2=getEndtime(qqrq);  
167 -  
168 - for (int i = 0; i < list.size(); i++) {  
169 - Map<String, Object> m=list.get(i);  
170 - int fcsjtime=0;  
171 - if(m.get("state")!=null){  
172 - String start_opt[]=m.get("state").toString().split(":");  
173 - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);  
174 - }  
175 - //请求时间小于翻班时间 营运日期当做请求日期的前一天。  
176 - long maxtime=d.getTime();  
177 - String yyzt="";  
178 - if(qqsjtime<fcsjtime){  
179 - if(endMap1.get(m.get("lineCode").toString())!=null){  
180 - if(endMap1.get(m.get("lineCode").toString())>=maxtime){  
181 - yyzt="营运";  
182 - }else{  
183 - yyzt="未营运";  
184 - }  
185 - }else{  
186 - yyzt="未营运";  
187 - }  
188 - }else{  
189 - if(endMap2.get(m.get("lineCode").toString())!=null){  
190 - if(endMap2.get(m.get("lineCode").toString())>=maxtime){  
191 - yyzt="营运";  
192 - }else{  
193 - yyzt="未营运";  
194 - }  
195 - }else{  
196 - yyzt="未营运";  
197 - }  
198 - }  
199 - m.put("state", yyzt);  
200 - }  
201 - return list;  
202 - }  
203 -  
204 -  
205 - @GET  
206 - @Path("/line/company/{companyId}")  
207 - public List<Map<String, Object>> findLineByCompany(@PathParam("companyId") String companyId) {  
208 - List<String> objList = new ArrayList<String>();  
209 - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"  
210 - + " a.shanghai_linecode, a.nature from "  
211 - + " bsth_c_line a left join bsth_c_line_config b "  
212 - + " on a.id=b.line where "  
213 - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "  
214 - + " and a.remove=0 and a.company = ?";  
215 - objList.add(companyId);  
216 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
217 - new RowMapper<Map<String, Object>>(){  
218 - @Override  
219 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
220 - Map<String, Object> m=new HashMap<String,Object>();  
221 - m.put("state", rs.getString("start_opt"));  
222 - m.put("company", rs.getString("company"));  
223 - m.put("companyName", getGs(rs.getString("company")));  
224 - m.put("lineCode",rs.getString("line_code"));  
225 - m.put("name", rs.getString("name"));  
226 - m.put("level", rs.getString("level"));  
227 - m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));  
228 - m.put("nature", getNature(rs.getString("nature")));  
229 - return m;  
230 - }  
231 - });  
232 - Date d=new Date();  
233 - SimpleDateFormat hm=new SimpleDateFormat("HH:mm");  
234 - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");  
235 -  
236 - String qqrq=ymd.format(d);  
237 - String qqsj=hm.format(d);  
238 - String qqsjs[]=qqsj.split(":");  
239 - Date nDate=new Date();  
240 - Calendar calendar = Calendar.getInstance();  
241 - calendar.setTime(nDate);  
242 - calendar.add(Calendar.DAY_OF_MONTH, -1);  
243 - Date dBefore = calendar.getTime();  
244 - String qqrqbefore =ymd.format(dBefore);  
245 - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);  
246 - Map<String, Long> endMap1=getEndtime(qqrqbefore);  
247 - Map<String, Long> endMap2=getEndtime(qqrq);  
248 -  
249 - for (int i = 0; i < list.size(); i++) {  
250 - Map<String, Object> m=list.get(i);  
251 - int fcsjtime=0;  
252 - if(m.get("state")!=null){  
253 - String start_opt[]=m.get("state").toString().split(":");  
254 - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);  
255 - }  
256 - //请求时间小于翻班时间 营运日期当做请求日期的前一天。  
257 - long maxtime=d.getTime();  
258 - String yyzt="";  
259 - if(qqsjtime<fcsjtime){  
260 - if(endMap1.get(m.get("lineCode").toString())!=null){  
261 - if(endMap1.get(m.get("lineCode").toString())>=maxtime){  
262 - yyzt="营运";  
263 - }else{  
264 - yyzt="未营运";  
265 - }  
266 - }else{  
267 - yyzt="未营运";  
268 - }  
269 - }else{  
270 - if(endMap2.get(m.get("lineCode").toString())!=null){  
271 - if(endMap2.get(m.get("lineCode").toString())>=maxtime){  
272 - yyzt="营运";  
273 - }else{  
274 - yyzt="未营运";  
275 - }  
276 - }else{  
277 - yyzt="未营运";  
278 - }  
279 - }  
280 - m.put("state", yyzt);  
281 - }  
282 - return list;  
283 - }  
284 -  
285 - @GET  
286 - @Path("/line/{lineCode}")  
287 - public List<Map<String, Object>> findLineByCode(@PathParam("lineCode") String lineCode) {  
288 - List<String> objList = new ArrayList<String>();  
289 - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"  
290 - + " a.shanghai_linecode, a.nature from "  
291 - + " bsth_c_line a left join bsth_c_line_config b "  
292 - + " on a.id=b.line where "  
293 - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "  
294 - + " and a.remove=0 and a.line_code = ?";  
295 - objList.add(lineCode);  
296 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
297 - new RowMapper<Map<String, Object>>(){  
298 - @Override  
299 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
300 - Map<String, Object> m=new HashMap<String,Object>();  
301 - m.put("state", rs.getString("start_opt"));  
302 - m.put("company", rs.getString("company"));  
303 - m.put("companyName", getGs(rs.getString("company")));  
304 - m.put("lineCode",rs.getString("line_code"));  
305 - m.put("name", rs.getString("name"));  
306 - m.put("level", rs.getString("level"));  
307 - m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));  
308 - m.put("nature", getNature(rs.getString("nature")));  
309 - return m;  
310 - }  
311 - });  
312 - Date d=new Date();  
313 - SimpleDateFormat hm=new SimpleDateFormat("HH:mm");  
314 - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");  
315 -  
316 - String qqrq=ymd.format(d);  
317 - String qqsj=hm.format(d);  
318 - String qqsjs[]=qqsj.split(":");  
319 - Date nDate=new Date();  
320 - Calendar calendar = Calendar.getInstance();  
321 - calendar.setTime(nDate);  
322 - calendar.add(Calendar.DAY_OF_MONTH, -1);  
323 - Date dBefore = calendar.getTime();  
324 - String qqrqbefore =ymd.format(dBefore);  
325 - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);  
326 - Map<String, Long> endMap1=getEndtime(qqrqbefore);  
327 - Map<String, Long> endMap2=getEndtime(qqrq);  
328 -  
329 - for (int i = 0; i < list.size(); i++) {  
330 - Map<String, Object> m=list.get(i);  
331 - int fcsjtime=0;  
332 - if(m.get("state")!=null){  
333 - String start_opt[]=m.get("state").toString().split(":");  
334 - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);  
335 - }  
336 - //请求时间小于翻班时间 营运日期当做请求日期的前一天。  
337 - long maxtime=d.getTime();  
338 - String yyzt="";  
339 - if(qqsjtime<fcsjtime){  
340 - if(endMap1.get(m.get("lineCode").toString())!=null){  
341 - if(endMap1.get(m.get("lineCode").toString())>=maxtime){  
342 - yyzt="营运";  
343 - }else{  
344 - yyzt="未营运";  
345 - }  
346 - }else{  
347 - yyzt="未营运";  
348 - }  
349 - }else{  
350 - if(endMap2.get(m.get("lineCode").toString())!=null){  
351 - if(endMap2.get(m.get("lineCode").toString())>=maxtime){  
352 - yyzt="营运";  
353 - }else{  
354 - yyzt="未营运";  
355 - }  
356 - }else{  
357 - yyzt="未营运";  
358 - }  
359 - }  
360 - m.put("state", yyzt);  
361 - }  
362 - return list;  
363 - }  
364 -  
365 - @GET  
366 - @Path("/line/level/{level}")  
367 - public List<Map<String, Object>> findLineByLevle(@PathParam("level") String level) {  
368 - List<String> objList = new ArrayList<String>();  
369 - String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"  
370 - + " a.shanghai_linecode, a.nature from "  
371 - + " bsth_c_line a left join bsth_c_line_config b "  
372 - + " on a.id=b.line where "  
373 - + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "  
374 - + " and a.remove=0 and a.level = ?";  
375 - objList.add(level);  
376 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
377 - new RowMapper<Map<String, Object>>(){  
378 - @Override  
379 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
380 - Map<String, Object> m=new HashMap<String,Object>();  
381 - m.put("state", rs.getString("start_opt"));  
382 - m.put("company", rs.getString("company"));  
383 - m.put("companyName", getGs(rs.getString("company")));  
384 - m.put("lineCode",rs.getString("line_code"));  
385 - m.put("name", rs.getString("name"));  
386 - m.put("level", rs.getString("level"));  
387 - m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));  
388 - m.put("nature", getNature(rs.getString("nature")));  
389 - return m;  
390 - }  
391 - });  
392 - Date d=new Date();  
393 - SimpleDateFormat hm=new SimpleDateFormat("HH:mm");  
394 - SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");  
395 -  
396 - String qqrq=ymd.format(d);  
397 - String qqsj=hm.format(d);  
398 - String qqsjs[]=qqsj.split(":");  
399 - Date nDate=new Date();  
400 - Calendar calendar = Calendar.getInstance();  
401 - calendar.setTime(nDate);  
402 - calendar.add(Calendar.DAY_OF_MONTH, -1);  
403 - Date dBefore = calendar.getTime();  
404 - String qqrqbefore =ymd.format(dBefore);  
405 - int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);  
406 - Map<String, Long> endMap1=getEndtime(qqrqbefore);  
407 - Map<String, Long> endMap2=getEndtime(qqrq);  
408 -  
409 - for (int i = 0; i < list.size(); i++) {  
410 - Map<String, Object> m=list.get(i);  
411 - int fcsjtime=0;  
412 - if(m.get("state")!=null){  
413 - String start_opt[]=m.get("state").toString().split(":");  
414 - fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);  
415 - }  
416 - //请求时间小于翻班时间 营运日期当做请求日期的前一天。  
417 - long maxtime=d.getTime();  
418 - String yyzt="";  
419 - if(qqsjtime<fcsjtime){  
420 - if(endMap1.get(m.get("lineCode").toString())!=null){  
421 - if(endMap1.get(m.get("lineCode").toString())>=maxtime){  
422 - yyzt="营运";  
423 - }else{  
424 - yyzt="未营运";  
425 - }  
426 - }else{  
427 - yyzt="未营运";  
428 - }  
429 - }else{  
430 - if(endMap2.get(m.get("lineCode").toString())!=null){  
431 - if(endMap2.get(m.get("lineCode").toString())>=maxtime){  
432 - yyzt="营运";  
433 - }else{  
434 - yyzt="未营运";  
435 - }  
436 - }else{  
437 - yyzt="未营运";  
438 - }  
439 - }  
440 - m.put("state", yyzt);  
441 - }  
442 - return list;  
443 - }  
444 - /*  
445 - * 线路接口结束  
446 - */  
447 -  
448 -  
449 - /*  
450 - * 线路配车接口开始  
451 - */  
452 - @GET  
453 - @Path("/lineCar/{type}/date/{date}")  
454 - public List<Map<String, Object>> findLineCarByDate(@PathParam("type") String type,@PathParam("date") String date) {  
455 - String sql="";  
456 - List<String> objList = new ArrayList<String>();  
457 - if(type.equals("all")){  
458 - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc"  
459 - + " from bsth_c_calc_count t where t.date = ?";  
460 - objList.add(date);  
461 - }  
462 - if(type.equals("actual")){  
463 - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc"  
464 - + " from bsth_c_calc_count t where t.date = ?";  
465 - objList.add(date);  
466 - }  
467 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
468 - new RowMapper<Map<String, Object>>(){  
469 - @Override  
470 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
471 - Map<String, Object> m=new HashMap<String,Object>();  
472 - m.put("date", rs.getString("date"));  
473 - m.put("company", rs.getString("gsdm"));  
474 - m.put("companyName", getGs(rs.getString("gsdm")));  
475 - m.put("lineCode",rs.getString("xl"));  
476 - m.put("lineName", rs.getString("xl_name"));  
477 - m.put("jhcc", rs.getString("jhcc"));  
478 - m.put("sjcc", rs.getString("sjcc"));  
479 - return m;  
480 - }  
481 - });  
482 -  
483 - return list;  
484 - }  
485 -  
486 -  
487 - @GET  
488 - @Path("/lineCar/{type}/date/{date}/line/{line}")  
489 - public List<Map<String, Object>> findLineCarByDateLine(@PathParam("type") String type,@PathParam("date") String date,  
490 - @PathParam("line") String line) {  
491 - String sql="";  
492 - List<String> objList = new ArrayList<String>();  
493 - if(type.equals("all")){  
494 - sql="select t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc"  
495 - + " from bsth_c_calc_count t where t.date = ?"  
496 - + " and xl = ?";  
497 - objList.add(date);  
498 - objList.add(line);  
499 - }  
500 - if(type.equals("actual")){  
501 - sql="select t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc"  
502 - + " from bsth_c_calc_count t where t.date = ?"  
503 - + " and xl = ?";  
504 - objList.add(date);  
505 - objList.add(line);  
506 -  
507 - }  
508 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
509 - new RowMapper<Map<String, Object>>(){  
510 - @Override  
511 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
512 - Map<String, Object> m=new HashMap<String,Object>();  
513 - m.put("company", rs.getString("gsdm"));  
514 - m.put("companyName", getGs(rs.getString("gsdm")));  
515 - m.put("lineCode",rs.getString("xl"));  
516 - m.put("lineName", rs.getString("xl_name"));  
517 - m.put("jhcc", rs.getString("jhcc"));  
518 - m.put("sjcc", rs.getString("sjcc"));  
519 - return m;  
520 - }  
521 - });  
522 -  
523 - return list;  
524 - }  
525 -  
526 - /*  
527 - * 线路配车接口结束  
528 - */  
529 -  
530 - /*  
531 - * 线路配人接口开始  
532 - */  
533 - @GET  
534 - @Path("/linePerson/{type}/date/{date}")  
535 - public List<Map<String, Object>> findLinePersonByDate(@PathParam("type") String type,@PathParam("date") String date) {  
536 - String sql="";  
537 - List<String> objList = new ArrayList<String>();  
538 - if(type.equals("all")){  
539 - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr"  
540 - + " from bsth_c_calc_count t where t.date = ?";  
541 - objList.add(date);  
542 - }  
543 - if(type.equals("actual")){  
544 - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr"  
545 - + " from bsth_c_calc_count t where t.date = ?";  
546 - objList.add(date);  
547 - }  
548 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
549 - new RowMapper<Map<String, Object>>(){  
550 - @Override  
551 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
552 - Map<String, Object> m=new HashMap<String,Object>();  
553 - m.put("date", rs.getString("date"));  
554 - m.put("company", rs.getString("gsdm"));  
555 - m.put("companyName", getGs(rs.getString("gsdm")));  
556 - m.put("lineCode",rs.getString("xl"));  
557 - m.put("lineName", rs.getString("xl_name"));  
558 - String jhpr=rs.getString("jhpr");  
559 - m.put("jhjsy", jhpr.split("/")[0]);  
560 - m.put("jhspy", jhpr.split("/")[1]);  
561 - String sjpr= rs.getString("sjpr");  
562 - m.put("sjjsy", sjpr.split("/")[0]);  
563 - m.put("sjspy", sjpr.split("/")[1]);  
564 - return m;  
565 - }  
566 - });  
567 -  
568 - return list;  
569 - }  
570 -  
571 -  
572 - @GET  
573 - @Path("/linePerson/{type}/date/{date}/line/{line}")  
574 - public List<Map<String, Object>> findLinePersonByDateLine(@PathParam("type") String type,@PathParam("date") String date,  
575 - @PathParam("line") String line) {  
576 - String sql="";  
577 - List<String> objList = new ArrayList<String>();  
578 - if(type.equals("all")){  
579 - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr"  
580 - + " from bsth_c_calc_count t where t.date = ?"  
581 - + " and xl = ?";  
582 - objList.add(date);  
583 - objList.add(line);  
584 - }  
585 - if(type.equals("actual")){  
586 - sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr"  
587 - + " from bsth_c_calc_count t where t.date = ?"  
588 - + " and xl = ?";  
589 - objList.add(date);  
590 - objList.add(line);  
591 - }  
592 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
593 - new RowMapper<Map<String, Object>>(){  
594 - @Override  
595 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
596 - Map<String, Object> m=new HashMap<String,Object>();  
597 - m.put("date", rs.getString("date"));  
598 - m.put("company", rs.getString("gsdm"));  
599 - m.put("companyName", getGs(rs.getString("gsdm")));  
600 - m.put("lineCode",rs.getString("xl"));  
601 - m.put("lineName", rs.getString("xl_name"));  
602 - String jhpr=rs.getString("jhpr");  
603 - m.put("jhjsy", jhpr.split("/")[0]);  
604 - m.put("jhspy", jhpr.split("/")[1]);  
605 - String sjpr= rs.getString("sjpr");  
606 - m.put("sjjsy", sjpr.split("/")[0]);  
607 - m.put("sjspy", sjpr.split("/")[1]);  
608 - return m;  
609 - }  
610 - });  
611 -  
612 - return list;  
613 - }  
614 -  
615 -  
616 -  
617 -  
618 - /*  
619 - * 线路配人接口结束  
620 - */  
621 -  
622 -  
623 - /*  
624 - * 线路班次接口开始  
625 - */  
626 - @GET  
627 - @Path("/lineBc/{type}/date/{date}")  
628 - public List<Map<String, Object>> findLineBcByDate(@PathParam("type") String type,  
629 - @PathParam("date") String date) {  
630 - String sql="";  
631 - List<String> objList = new ArrayList<String>();  
632 - if(type.equals("all")){  
633 - sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc,"  
634 - + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t"  
635 - + " where t.date = ?";  
636 - objList.add(date);  
637 - }  
638 - if(type.equals("actual")){  
639 - sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc,"  
640 - + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t"  
641 - + " where t.date = ?";  
642 - objList.add(date);  
643 - }  
644 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
645 - new RowMapper<Map<String, Object>>(){  
646 - @Override  
647 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
648 - Map<String, Object> m=new HashMap<String,Object>();  
649 - m.put("company", rs.getString("gsdm"));  
650 - m.put("companyName", getGs(rs.getString("gsdm")));  
651 - m.put("lineCode",rs.getString("xl"));  
652 - m.put("lineName", rs.getString("xl_name"));  
653 - m.put("jhbc", rs.getString("jhbc"));  
654 - m.put("jhzgfbc", rs.getString("jhzgfbc"));  
655 - m.put("jhwgfbc", rs.getString("jhwgfbc"));  
656 - m.put("sjbc", rs.getString("sjbc"));  
657 - m.put("sjzgfbc", rs.getString("sjzgfbc"));  
658 - m.put("sjwgfbc", rs.getString("sjwgfbc"));  
659 - return m;  
660 - }  
661 - });  
662 - return list;  
663 - }  
664 -  
665 -  
666 - @GET  
667 - @Path("/lineBc/{type}/date/{date}/line/{line}")  
668 - public List<Map<String, Object>> findLineBcByDateLine(@PathParam("type") String type,  
669 - @PathParam("date") String date,@PathParam("line") String line) {  
670 - String sql="";  
671 - List<String> objList = new ArrayList<String>();  
672 - if(type.equals("all")){  
673 - sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc,"  
674 - + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t "  
675 - + " where t.date = ? and xl = ?";  
676 - objList.add(date);  
677 - objList.add(line);  
678 - }  
679 - if(type.equals("actual")){  
680 - sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc,"  
681 - + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t"  
682 - + " where t.date = ? and xl = ?";  
683 - objList.add(date);  
684 - objList.add(line);  
685 - }  
686 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
687 - new RowMapper<Map<String, Object>>(){  
688 - @Override  
689 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
690 - Map<String, Object> m=new HashMap<String,Object>();  
691 - m.put("company", rs.getString("gsdm"));  
692 - m.put("companyName", getGs(rs.getString("gsdm")));  
693 - m.put("lineCode",rs.getString("xl"));  
694 - m.put("lineName", rs.getString("xl_name"));  
695 - m.put("jhbc", rs.getString("jhbc"));  
696 - m.put("jhzgfbc", rs.getString("jhzgfbc"));  
697 - m.put("jhwgfbc", rs.getString("jhwgfbc"));  
698 - m.put("sjbc", rs.getString("sjbc"));  
699 - m.put("sjzgfbc", rs.getString("sjzgfbc"));  
700 - m.put("sjwgfbc", rs.getString("sjwgfbc"));  
701 - return m;  
702 - }  
703 - });  
704 - return list;  
705 - }  
706 -  
707 - /*  
708 - * 线路班次接口结束  
709 - */  
710 -  
711 - /*  
712 - * 线路里程接口开始  
713 - */  
714 -  
715 - @GET  
716 - @Path("/lineLc/{type}/date/{date}")  
717 - public List<Map<String, Object>> findLineLcByDate(@PathParam("type") String type,  
718 - @PathParam("date") String date) {  
719 - String sql="";  
720 - List<String> objList = new ArrayList<String>();  
721 - if(type.equals("all")){  
722 - sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc,"  
723 - + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"  
724 - + " where t.date = ?";  
725 - objList.add(date);  
726 - }  
727 - if(type.equals("actual")){  
728 - sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc,"  
729 - + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"  
730 - + " where t.date = ?";  
731 - objList.add(date);  
732 - }  
733 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
734 - new RowMapper<Map<String, Object>>(){  
735 - @Override  
736 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
737 - Map<String, Object> m=new HashMap<String,Object>();  
738 - m.put("company", rs.getString("gsdm"));  
739 - m.put("companyName", getGs(rs.getString("gsdm")));  
740 - m.put("lineCode",rs.getString("xl"));  
741 - m.put("lineName", rs.getString("xl_name"));  
742 - m.put("jhzlc", rs.getString("jhzlc"));  
743 - m.put("jhyylc", rs.getString("jhyylc"));  
744 - m.put("jhkslc", rs.getString("jhkslc"));  
745 - m.put("sjzlc", rs.getString("sjzlc"));  
746 - m.put("sjyylc", rs.getString("sjyylc"));  
747 - m.put("sjkslc", rs.getString("sjkslc"));  
748 - if(Double.parseDouble(rs.getString("jhzlc"))>0){  
749 - double zlczxl=Double.parseDouble(rs.getString("sjzlc"))/Double.parseDouble(rs.getString("jhzlc"));  
750 - m.put("zlczxl",df.format(zlczxl*100)+"%");  
751 - }else{  
752 - m.put("zlczxl","0.00%");  
753 -  
754 - }  
755 - if(Double.parseDouble(rs.getString("jhyylc"))>0){  
756 - double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc"));  
757 - m.put("yylczxl",df.format(yylczxl*100)+"%");  
758 - }else{  
759 - m.put("yylczxl","0.00%");  
760 - }  
761 - return m;  
762 - }  
763 - });  
764 - return list;  
765 - }  
766 -  
767 -  
768 - @GET  
769 - @Path("/lineLc/{type}/date/{date}/line/{line}")  
770 - public List<Map<String, Object>> findLineLcByDateLine(@PathParam("type") String type,  
771 - @PathParam("date") String date,@PathParam("line") String line) {  
772 - String sql="";  
773 - List<String> objList = new ArrayList<String>();  
774 - if(type.equals("all")){  
775 - sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc,"  
776 - + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"  
777 - + " where t.date = ? and xl = ?";  
778 - objList.add(date);  
779 - objList.add(line);  
780 - }  
781 - if(type.equals("actual")){  
782 - sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc,"  
783 - + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"  
784 - + " where t.date = ? and xl = ?";  
785 - objList.add(date);  
786 - objList.add(line);  
787 - }  
788 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
789 - new RowMapper<Map<String, Object>>(){  
790 - @Override  
791 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
792 - Map<String, Object> m=new HashMap<String,Object>();  
793 - m.put("company", rs.getString("gsdm"));  
794 - m.put("companyName", getGs(rs.getString("gsdm")));  
795 - m.put("lineCode",rs.getString("xl"));  
796 - m.put("lineName", rs.getString("xl_name"));  
797 - m.put("jhzlc", rs.getString("jhzlc"));  
798 - m.put("jhyylc", rs.getString("jhyylc"));  
799 - m.put("jhkslc", rs.getString("jhkslc"));  
800 - m.put("sjzlc", rs.getString("sjzlc"));  
801 - m.put("sjyylc", rs.getString("sjyylc"));  
802 - m.put("sjkslc", rs.getString("sjkslc"));  
803 - if(Double.parseDouble(rs.getString("jhzlc"))>0){  
804 - double zlczxl=Double.parseDouble(rs.getString("sjzlc"))/Double.parseDouble(rs.getString("jhzlc"));  
805 - m.put("zlczxl",df.format(zlczxl*100)+"%");  
806 - }else{  
807 - m.put("zlczxl","0.00%");  
808 -  
809 - }  
810 - if(Double.parseDouble(rs.getString("jhyylc"))>0){  
811 - double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc"));  
812 - m.put("yylczxl",df.format(yylczxl*100)+"%");  
813 - }else{  
814 - m.put("yylczxl","0.00%");  
815 - }  
816 - return m;  
817 - }  
818 - });  
819 - return list;  
820 - }  
821 - /*  
822 - * 线路里程接口结束  
823 - */  
824 -  
825 -  
826 - /*  
827 - * 班次执行率连续三天不满93%推送  
828 - */  
829 - @GET  
830 - @Path("/abnormal/executionRate/date/{date}")  
831 - public List<Map<String, Object>> executionRate(@PathParam("date") String date) {  
832 - List<String> objList = new ArrayList<String>();  
833 - String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t"  
834 - + " where t.date = ? and push_type in ('1','3')";  
835 - objList.add(date);  
836 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
837 - new RowMapper<Map<String, Object>>(){  
838 - @Override  
839 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
840 - Map<String, Object> m=new HashMap<String,Object>();  
841 - m.put("companyName", rs.getString("gs_name"));  
842 - m.put("lineCode",rs.getString("xl_bm"));  
843 - m.put("lineName", rs.getString("xl_name"));  
844 - m.put("showDate", rs.getString("show_date"));  
845 - return m;  
846 - }  
847 - });  
848 - return list;  
849 - }  
850 - /*  
851 - * 首末班发车连续三天不准点  
852 - */  
853 - @GET  
854 - @Path("/abnormal/firstAndLast/date/{date}")  
855 - public List<Map<String, Object>> firstAndLast(@PathParam("date") String date) {  
856 - List<String> objList = new ArrayList<String>();  
857 - String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t"  
858 - + " where t.date = ? and push_type in ('2','3')";  
859 - objList.add(date);  
860 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
861 - new RowMapper<Map<String, Object>>(){  
862 - @Override  
863 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
864 - Map<String, Object> m=new HashMap<String,Object>();  
865 - m.put("companyName", rs.getString("gs_name"));  
866 - m.put("lineCode",rs.getString("xl_bm"));  
867 - m.put("lineName", rs.getString("xl_name"));  
868 - m.put("showDate", rs.getString("show_date"));  
869 - return m;  
870 - }  
871 - });  
872 - return list;  
873 - }  
874 -  
875 - /*  
876 - * 车辆数据接口开始  
877 - */  
878 -  
879 - @GET  
880 - @Path("/car/all")  
881 - public List<Map<String, Object>> findCar() {  
882 - String carStr= GetHttpInterface.getHttpInterface("http://180.166.5.82:8076/cars/getAllCarsInterface");  
883 - //车辆库资料资料  
884 - List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);  
885 - //调度系统车辆资料  
886 - String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars";  
887 - List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,  
888 - new RowMapper<Map<String, Object>>(){  
889 - @Override  
890 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
891 - Map<String, Object> m=new HashMap<String,Object>();  
892 - m.put("equipment_code", rs.getString("equipment_code"));  
893 - m.put("insideCode", rs.getString("inside_code"));  
894 - m.put("supplier_name",rs.getString("supplier_name"));  
895 - return m;  
896 - }  
897 - });  
898 - for (int i = 0; i < clkList.size(); i++) {  
899 - Map<String, Object> m1=clkList.get(i);  
900 - String carCode=m1.get("car_code").toString();  
901 - m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));  
902 - for (int j = 0; j < ddkList.size(); j++) {  
903 - Map<String, Object> m2=ddkList.get(j);  
904 - String insideCode=m2.get("insideCode").toString();  
905 - if(carCode.equals(insideCode)){  
906 - m1.put("equipment_code", m2.get("equipment_code"));  
907 - m1.put("supplier_name", m2.get("supplier_name"));  
908 - }  
909 -  
910 - }  
911 - }  
912 - return clkList;  
913 - }  
914 -  
915 -  
916 - @GET  
917 - @Path("/car/company/{companyId}")  
918 - public List<Map<String, Object>> findCarByCompany(@PathParam("companyId") String companyId) {  
919 - String carStr= GetHttpInterface.  
920 - getHttpInterface("http://180.166.5.82:8076/cars/getAllCarsInterface?company="+companyId);  
921 - //车辆库资料资料  
922 - List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);  
923 - //调度系统车辆资料  
924 - String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where business_code='"+companyId+"'";  
925 - List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,  
926 - new RowMapper<Map<String, Object>>(){  
927 - @Override  
928 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
929 - Map<String, Object> m=new HashMap<String,Object>();  
930 - m.put("equipment_code", rs.getString("equipment_code"));  
931 - m.put("insideCode", rs.getString("inside_code"));  
932 - m.put("supplier_name",rs.getString("supplier_name"));  
933 - return m;  
934 - }  
935 - });  
936 - for (int i = 0; i < clkList.size(); i++) {  
937 - Map<String, Object> m1=clkList.get(i);  
938 - String carCode=m1.get("car_code").toString();  
939 - m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));  
940 - for (int j = 0; j < ddkList.size(); j++) {  
941 - Map<String, Object> m2=ddkList.get(j);  
942 - String insideCode=m2.get("insideCode").toString();  
943 - if(carCode.equals(insideCode)){  
944 - m1.put("equipment_code", m2.get("equipment_code"));  
945 - m1.put("supplier_name", m2.get("supplier_name"));  
946 - }  
947 -  
948 - }  
949 - }  
950 - return clkList;  
951 - }  
952 -  
953 - @GET  
954 - @Path("/car/code/{carCode}")  
955 - public List<Map<String, Object>> findCarByCode(@PathParam("carCode") String carCode) {  
956 - String carStr= GetHttpInterface.  
957 - getHttpInterface("http://101.95.0.106:8076/cars/getAllCarsInterface?car_code="+carCode);  
958 - //车辆库资料资料  
959 - List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);  
960 - //调度系统车辆资料  
961 - String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where inside_code='"+carCode+"'";  
962 - List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,  
963 - new RowMapper<Map<String, Object>>(){  
964 - @Override  
965 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
966 - Map<String, Object> m=new HashMap<String,Object>();  
967 - m.put("equipment_code", rs.getString("equipment_code"));  
968 - m.put("insideCode", rs.getString("inside_code"));  
969 - m.put("supplier_name",rs.getString("supplier_name"));  
970 - return m;  
971 - }  
972 - });  
973 -  
974 - for (int i = 0; i < clkList.size(); i++) {  
975 - Map<String, Object> m1=clkList.get(i);  
976 - String code=m1.get("car_code").toString().trim();  
977 - m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));  
978 - for (int j = 0; j < ddkList.size(); j++) {  
979 - Map<String, Object> m2=ddkList.get(j);  
980 - String insideCode=m2.get("insideCode").toString().trim();  
981 - if(code.equals(insideCode)){  
982 - m1.put("equipment_code", m2.get("equipment_code"));  
983 - m1.put("supplier_name", m2.get("supplier_name"));  
984 - }  
985 -  
986 - }  
987 - }  
988 - return clkList;  
989 - }  
990 - /*  
991 - * 车辆数据接口结束  
992 - */  
993 -  
994 - /*  
995 - * 事故数据接口开始  
996 - */  
997 - @GET  
998 - @Path("/accident/startTime/{startTime}/endTime/{endTime}")  
999 - public List<Map<String, Object>> findAccident(@PathParam("startTime") String startTime,  
1000 - @PathParam("endTime") String endTime) {  
1001 - String accidentAll= GetHttpInterface.getHttpInterface("http://180.168.57.114:9019/pdsafe/LineSms/getAccidentSubmitAll.do?"  
1002 - + "submitDateBegin="+startTime+"&submitDateEnd="+endTime);  
1003 - List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);  
1004 - return list;  
1005 - }  
1006 -  
1007 -  
1008 - /*  
1009 - * 事故数据接口结束  
1010 - */  
1011 -  
1012 - /*  
1013 - *安全驾驶接口开始  
1014 - */  
1015 - @GET  
1016 - @Path("/safedriving/starDate/{starDate}/endDate/{endDate}")  
1017 - public List<Map<String, Object>> findSafedriving(@PathParam("starDate") String starDate,  
1018 - @PathParam("endDate") String endDate) {  
1019 - String accidentAll= GetHttpInterface.getHttpInterface("http://211.95.61.66:9006/safedriving/safedrivingInterface?StarTime="+starDate+"&EndTime="+endDate);  
1020 - List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);  
1021 - return list;  
1022 - }  
1023 - @GET  
1024 - @Path("/safedriving/starDate/{starDate}/endDate/{endDate}/line/{line}")  
1025 - public List<Map<String, Object>> findSafedrivingByLine(@PathParam("starDate") String starDate,  
1026 - @PathParam("endDate") String endDate,@PathParam("line") String line) {  
1027 - String accidentAll= GetHttpInterface.getHttpInterface("http://211.95.61.66:9006/safedriving/safedrivingInterface?StarTime="+starDate+"&EndTime="+endDate  
1028 - +"&LineId="+line);  
1029 - List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);  
1030 - return list;  
1031 - }  
1032 - /*  
1033 - *安全驾驶接口结束  
1034 - */  
1035 -  
1036 -  
1037 - /**  
1038 - * 闵行线路班次里程  
1039 - *  
1040 - *  
1041 - *  
1042 - */  
1043 -  
1044 - @GET  
1045 - @Path("/findByAll/starDate/{starDate}/endDate/{endDate}/line/{line}")  
1046 - public List<Map<String, Object>> findMinhang(@PathParam("starDate") String starDate,  
1047 - @PathParam("endDate") String endDate,@PathParam("line") String line) {  
1048 - List<String> objList = new ArrayList<String>();  
1049 - String sql="select xl,xl_name,date,jhszfcs,sjszfczds,jhbc,sjbc,jhcc,sjcc,"  
1050 - + " jhyylc,sjyylc,jhkslc,sjkslc,jhssgfbcs,sjgfbcs,jhssdgbcs,"  
1051 - + " sjdgbcs from bsth_c_calc_count "  
1052 - + " where date >= ? and date <= ?";  
1053 - objList.add(starDate);  
1054 - objList.add(endDate);  
1055 -  
1056 - if(!line.equals("all")){  
1057 - sql +=" and xl = ?";  
1058 - objList.add(line);  
1059 - }  
1060 -  
1061 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
1062 - new RowMapper<Map<String, Object>>(){  
1063 - @Override  
1064 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1065 - Map<String, Object> m=new HashMap<String,Object>();  
1066 - m.put("lineCode",rs.getString("xl"));  
1067 - m.put("lineName", rs.getString("xl_name"));  
1068 - m.put("date", rs.getString("date"));  
1069 - m.put("jhszfcs", rs.getString("jhszfcs"));  
1070 - m.put("sjszfczds", rs.getString("sjszfczds"));  
1071 - m.put("jhbc", rs.getString("jhbc"));  
1072 - m.put("sjbc", rs.getString("sjbc"));  
1073 - m.put("jhcc", rs.getString("jhcc"));  
1074 - m.put("sjcc", rs.getString("sjcc"));  
1075 - m.put("jhyylc", rs.getString("jhyylc"));  
1076 - m.put("sjyylc", rs.getString("sjyylc"));  
1077 - m.put("jhkslc", rs.getString("jhkslc"));  
1078 - m.put("sjkslc", rs.getString("sjkslc"));  
1079 - m.put("jhgfbcs", rs.getString("jhssgfbcs"));  
1080 - m.put("sjgfbcs", rs.getString("sjgfbcs"));  
1081 - m.put("jhdgbcs", rs.getString("jhssdgbcs"));  
1082 - m.put("sjdgbcs", rs.getString("sjdgbcs"));  
1083 - return m;  
1084 - }  
1085 - });  
1086 - return list;  
1087 - }  
1088 -  
1089 - /**  
1090 - * 赵冲需要的数据接口  
1091 - *  
1092 - */  
1093 - @GET  
1094 - @Path("/findByCompany/{company}/date/{date}")  
1095 - public List<Map<String, Object>> findByCompany(@PathParam("company") String company,  
1096 - @PathParam("date") String date) {  
1097 - List<String> objList = new ArrayList<String>();  
1098 - String sql="select t.company as gs_code,t.date,SUM(t.jhcczgf) as jhccs ,SUM(t.sjcczgf) as ccs,AVG(ccl) as ccl"  
1099 - + " ,SUM(t.sjzgl*1000)/1000 as sum_mileage ,SUM(jcgl*1000)/1000 as airpor_mileage "  
1100 - + " from (select a.line_code,b.date,a.company,b.jhcczgf,b.sjcczgf,"  
1101 - + " round(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0)),3) as ccl,c.sjzgl ,"  
1102 - + " ifnull(d.sjzgl,0) as jcgl from bsth_c_line a LEFT JOIN "  
1103 - + " (SELECT * from bsth_c_calc_sheet where date = ?) b on a.line_code=b.xl"  
1104 - + " left join (select * from bsth_c_calc_count where date = ?) c on a.line_code=c.xl "  
1105 - + " left join (select * from bsth_c_calc_count where date = ? "  
1106 - + " and xl_name like '%机场%') d on a.line_code=d.xl "  
1107 - + " where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')) t "  
1108 - + " where t.date is not null ";  
1109 - objList.add(date);  
1110 - objList.add(date);  
1111 - objList.add(date);  
1112 - if(!company.equals("all")){  
1113 - sql +=" and t.company = ?";  
1114 - objList.add(company);  
1115 - }  
1116 - sql +=" group by t.company,t.date";  
1117 -  
1118 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
1119 - new RowMapper<Map<String, Object>>(){  
1120 - @Override  
1121 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1122 - Map<String, Object> m=new HashMap<String,Object>();  
1123 - m.put("gs_name", getGs(rs.getString("gs_code")));  
1124 - m.put("gs_code",rs.getString("gs_code"));  
1125 - m.put("date", rs.getString("date"));  
1126 - m.put("jhccs", rs.getString("jhccs"));  
1127 - m.put("ccs", rs.getString("ccs"));  
1128 - m.put("ccl", rs.getString("ccl"));  
1129 - m.put("sum_mileage", rs.getString("sum_mileage"));  
1130 - m.put("airpor_mileage", rs.getString("airpor_mileage"));  
1131 - return m;  
1132 - }  
1133 - });  
1134 - return list;  
1135 - }  
1136 - @GET  
1137 - @Path("/findTarget/gs/{gs}/fgs/{fgs}/date/{date}")  
1138 - public List<Map<String, Object>> findTarget(@PathParam("gs") String gs,@PathParam("fgs") String fgs,  
1139 - @PathParam("date") String date) {  
1140 - SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");  
1141 - String d=sdf.format(new Date());  
1142 - String sql="";  
1143 - List<String> objList = new ArrayList<String>();  
1144 - if(gs.equals("all")){  
1145 - sql ="select x.gsdm,'' as fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from ("  
1146 - + " select b.gsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3)* 100 as zgf_ccl,"  
1147 - + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from "  
1148 - + " bsth_c_calc_sheet b where b.date like ? and b.date < ? "  
1149 - + " and b.xl in(select a.line_code from bsth_c_line a where "  
1150 - + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm ) x "  
1151 - + " left join (select c.gsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl,"  
1152 - + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl,"  
1153 - + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl "  
1154 - + " from bsth_c_calc_count c where c.date like ? and c.date < ? and "  
1155 - + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) "  
1156 - + " group by c.gsdm ) y on x.gsdm=y.gsdm where 1=1 ";  
1157 - objList.add("%"+date+"%");  
1158 - objList.add(d);  
1159 - objList.add("%"+date+"%");  
1160 - objList.add(d);  
1161 -  
1162 - }else{  
1163 - sql ="select x.gsdm,x.fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from ("  
1164 - + " select b.gsdm,b.fgsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3) * 100 as zgf_ccl,"  
1165 - + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from "  
1166 - + " bsth_c_calc_sheet b where b.date like ? and b.date < ? "  
1167 - + " and b.xl in(select a.line_code from bsth_c_line a where "  
1168 - + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm,b.fgsdm ) x "  
1169 - + " left join (select c.gsdm,c.fgsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl,"  
1170 - + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl,"  
1171 - + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl "  
1172 - + " from bsth_c_calc_count c where c.date like ? and c.date < ? and "  
1173 - + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) "  
1174 - + " group by c.gsdm,c.fgsdm ) y on x.gsdm=y.gsdm and x.fgsdm=y.fgsdm where 1=1 ";  
1175 - objList.add("%"+date+"%");  
1176 - objList.add(d);  
1177 - objList.add("%"+date+"%");  
1178 - objList.add(d);  
1179 -  
1180 - }  
1181 - if(!gs.equals("all")){  
1182 - sql += " and x.gsdm = ?";  
1183 - objList.add(gs);  
1184 - }  
1185 -  
1186 - if(!fgs.equals("all")){  
1187 - sql += " and x.fgsdm = ?";  
1188 - objList.add(fgs);  
1189 - }  
1190 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
1191 - new RowMapper<Map<String, Object>>(){  
1192 - @Override  
1193 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1194 - Map<String, Object> m=new HashMap<String,Object>();  
1195 - m.put("gsdm", getGs(rs.getString("gsdm")));  
1196 - m.put("fgsdm",rs.getString("fgsdm"));  
1197 - m.put("smb_zdl", rs.getString("smb_zdl"));  
1198 - m.put("zgf_ccl", rs.getString("zgf_ccl"));  
1199 - m.put("yylc_zxl", rs.getString("yylc_zxl"));  
1200 - m.put("szfc_zdl", rs.getString("szfc_zdl"));  
1201 - m.put("bc_zxl", rs.getString("bc_zxl"));  
1202 - return m;  
1203 - }  
1204 - });  
1205 - return list;  
1206 - }  
1207 -  
1208 -  
1209 - /**  
1210 - *公司内部使用数据  
1211 - *  
1212 - *班次里程基础数据接口  
1213 - */  
1214 - @GET  
1215 - @Path("/basicData/starDate/{starDate}/endDate/{endDate}/line/{line}")  
1216 - public List<Map<String, Object>> basicData(@PathParam("starDate") String starDate,  
1217 - @PathParam("endDate") String endDate,@PathParam("line") String line) {  
1218 - List<String> objList = new ArrayList<String>();  
1219 - String sql="select gsdm,fgsdm,xl,xl_name,date,jhbc,sjbc,"  
1220 - + " jhyylc,sjyylc,jhkslc,sjkslc,jhgfbcsz,sjgfbcs,jhdgbcsz,"  
1221 - + " sjdgbcs from bsth_c_calc_count "  
1222 - + " where date >= ? and date <= ?";  
1223 - objList.add(starDate);  
1224 - objList.add(endDate);  
1225 - if(!line.equals("all")){  
1226 - sql +=" and xl = ?";  
1227 - objList.add(line);  
1228 - }  
1229 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
1230 - new RowMapper<Map<String, Object>>(){  
1231 - @Override  
1232 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1233 - Map<String, Object> m=new HashMap<String,Object>();  
1234 - m.put("gsdm",rs.getString("gsdm"));  
1235 - m.put("fgsdm",rs.getString("fgsdm"));  
1236 - m.put("lineCode",rs.getString("xl"));  
1237 - m.put("lineName", rs.getString("xl_name"));  
1238 - m.put("date", rs.getString("date"));  
1239 - m.put("jhbc", rs.getString("jhbc"));  
1240 - m.put("sjbc", rs.getString("sjbc"));  
1241 - m.put("jhyylc", rs.getString("jhyylc"));  
1242 - m.put("sjyylc", rs.getString("sjyylc"));  
1243 - m.put("jhkslc", rs.getString("jhkslc"));  
1244 - m.put("sjkslc", rs.getString("sjkslc"));  
1245 - m.put("jhgfbcs", rs.getString("jhgfbcsz"));  
1246 - m.put("sjgfbcs", rs.getString("sjgfbcs"));  
1247 - m.put("jhdgbcs", rs.getString("jhdgbcsz"));  
1248 - m.put("sjdgbcs", rs.getString("sjdgbcs"));  
1249 - return m;  
1250 - }  
1251 - });  
1252 - return list;  
1253 - }  
1254 -  
1255 - @GET  
1256 - @Path("/targetData/starDate/{starDate}/endDate/{endDate}/line/{line}")  
1257 - public List<Map<String, Object>> targetData(@PathParam("starDate") String starDate,  
1258 - @PathParam("endDate") String endDate,@PathParam("line") String line) {  
1259 - List<String> objList = new ArrayList<String>();  
1260 - String sql="select gsdm,fgsdm,date,xl,xl_name,szfczdl,smbfczdl,"  
1261 - + " round(if(ifnull(sjcczgf/jhcczgf,0)>1,1,ifnull(sjcczgf/jhcczgf,0)),3) * 100 as zgfccl , "  
1262 - + " round(if(ifnull(sjcc/jhcc,0)>1,1,ifnull(sjcc/jhcc,0)),3) * 100 as ccl from bsth_c_calc_sheet "  
1263 - + " where date >= ? and date <= ?";  
1264 - objList.add(starDate);  
1265 - objList.add(endDate);  
1266 - if(!line.equals("all")){  
1267 - sql +=" and xl = ?";  
1268 - objList.add(line);  
1269 - }  
1270 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
1271 - new RowMapper<Map<String, Object>>(){  
1272 - @Override  
1273 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1274 - Map<String, Object> m=new HashMap<String,Object>();  
1275 - m.put("gsdm",rs.getString("gsdm"));  
1276 - m.put("fgsdm",rs.getString("fgsdm"));  
1277 - m.put("lineCode",rs.getString("xl"));  
1278 - m.put("lineName", rs.getString("xl_name"));  
1279 - m.put("date", rs.getString("date"));  
1280 - m.put("szfczdl", rs.getString("szfczdl"));  
1281 - m.put("smbfczdl", rs.getString("smbfczdl"));  
1282 - m.put("zgfccl", rs.getString("zgfccl"));  
1283 - m.put("ccl", rs.getString("ccl"));  
1284 - return m;  
1285 - }  
1286 - });  
1287 - return list;  
1288 - }  
1289 -  
1290 - @GET  
1291 - @Path("/departureTime/starDate/{starDate}/endDate/{endDate}/line/{line}")  
1292 - public List<Map<String, Object>> departureTime(@PathParam("starDate") String starDate,  
1293 - @PathParam("endDate") String endDate,@PathParam("line") String line) {  
1294 - List<String> objList = new ArrayList<String>();  
1295 - String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz,"  
1296 - + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz,"  
1297 - + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz,"  
1298 - + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz,"  
1299 - + " jhszfcs,sjszfczds,szfczdl,"  
1300 - + " create_date from bsth_c_calc_count "  
1301 - + " where date >= ? and date <= ?";  
1302 - objList.add(starDate);  
1303 - objList.add(endDate);  
1304 - if(!line.equals("all")){  
1305 - sql +=" and xl = ?";  
1306 - objList.add(line);  
1307 - }  
1308 -  
1309 - List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),  
1310 - new RowMapper<Map<String, Object>>(){  
1311 - @Override  
1312 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1313 - Map<String, Object> m=new HashMap<String,Object>();  
1314 - m.put("lineCode",rs.getString("xl"));  
1315 - m.put("lineName", rs.getString("xl_name"));  
1316 - m.put("date", rs.getString("date"));  
1317 -  
1318 - m.put("jhbc", rs.getString("jhbc"));  
1319 - m.put("sjbc", rs.getString("sjbc"));  
1320 - m.put("bczxl", rs.getString("bczxl"));  
1321 - m.put("jhbcz", rs.getString("jhbcz"));  
1322 -  
1323 - m.put("jhcc", rs.getString("jhcc"));  
1324 - m.put("sjcc", rs.getString("sjcc"));  
1325 - m.put("ccl", rs.getString("ccl"));  
1326 - m.put("jhccz", rs.getString("jhccz"));  
1327 -  
1328 - m.put("jhyylc", rs.getString("jhyylc"));  
1329 - m.put("sjyylc", rs.getString("sjyylc"));  
1330 - m.put("jhyylcz", rs.getString("jhyylcz"));  
1331 - m.put("jhkslc", rs.getString("jhkslc"));  
1332 - m.put("sjkslc", rs.getString("sjkslc"));  
1333 - m.put("jhkslcz", rs.getString("jhkslcz"));  
1334 -  
1335 - m.put("jhgfbcs", rs.getString("jhssgfbcs"));  
1336 - m.put("sjgfbcs", rs.getString("sjgfbcs"));  
1337 - m.put("jhgfbcsz", rs.getString("jhgfbcsz"));  
1338 - m.put("jhdgbcs", rs.getString("jhssdgbcs"));  
1339 - m.put("sjdgbcs", rs.getString("sjdgbcs"));  
1340 - m.put("jhdgbcsz", rs.getString("jhdgbcsz"));  
1341 -  
1342 - m.put("jhsmbcs", rs.getString("jhsmbcs"));  
1343 - m.put("sjsmbczds", rs.getString("sjsmbczds"));  
1344 - m.put("smbczdl", rs.getString("smbczdl"));  
1345 - m.put("jhsmbcsz", rs.getString("jhsmbcsz"));  
1346 - m.put("sjsmbczdsz", rs.getString("sjsmbczdsz"));  
1347 - m.put("smbczdlz", rs.getString("smbczdlz"));  
1348 -  
1349 - m.put("jhszfcs", rs.getString("jhszfcs"));  
1350 - m.put("sjszfczds", rs.getString("sjszfczds"));  
1351 - m.put("szfczdl", rs.getString("szfczdl"));  
1352 -  
1353 - Date date = new Date();  
1354 - date.setTime(rs.getTimestamp("create_date").getTime());  
1355 - m.put("createDate", sdf.format(date));  
1356 - return m;  
1357 - }  
1358 - });  
1359 - return list;  
1360 - }  
1361 -  
1362 -} 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.text.SimpleDateFormat;
  7 +import java.util.*;
  8 +
  9 +import javax.ws.rs.GET;
  10 +import javax.ws.rs.Path;
  11 +import javax.ws.rs.PathParam;
  12 +import javax.ws.rs.Produces;
  13 +import javax.ws.rs.core.MediaType;
  14 +
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.jdbc.core.JdbcTemplate;
  19 +import org.springframework.jdbc.core.RowMapper;
  20 +import org.springframework.stereotype.Component;
  21 +
  22 +import com.alibaba.fastjson.JSONObject;
  23 +
  24 +@Component
  25 +@Path("/bigdata")
  26 +@Produces({MediaType.APPLICATION_JSON})
  27 +public class BigdataService {
  28 + Logger logger = LoggerFactory.getLogger(this.getClass());
  29 +
  30 + @Autowired
  31 + JdbcTemplate jdbcTemplate;
  32 +
  33 + DecimalFormat df = new DecimalFormat("0.00");
  34 +
  35 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  36 +
  37 + /*
  38 + * 线路接口开始
  39 + */
  40 +
  41 + private static String getNature(String natureCode){
  42 + String natureName="";
  43 + if("lj".equals(natureCode)){
  44 + natureName="路救";
  45 + }else if("bc".equals(natureCode)){
  46 + natureName="备车";
  47 + }else if("dbc".equals(natureCode)){
  48 + natureName="定班车";
  49 + }else if("yxl".equals(natureCode)){
  50 + natureName="夜宵路";
  51 + }else if("cgxl".equals(natureCode)){
  52 + natureName="常规线路";
  53 + }else if("gjxl".equals(natureCode)){
  54 + natureName="过江线路";
  55 + }else if("csbs".equals(natureCode)){
  56 + natureName="穿梭巴士";
  57 + }else if("tyxl".equals(natureCode)){
  58 + natureName="特约线路";
  59 + }else if("cctxl".equals(natureCode)){
  60 + natureName="村村通线路";
  61 + }else if("qt".equals(natureCode)){
  62 + natureName="其他";
  63 + }else {
  64 + natureName="";
  65 + }
  66 + return natureName;
  67 + }
  68 +
  69 + private static String getGs(String gs){
  70 + String name="";
  71 + if("05".equals(gs)){
  72 + name="杨高公司";
  73 + }else if("22".equals(gs)){
  74 + name="金高公司";
  75 + }else if("26".equals(gs)){
  76 + name="南汇公司";
  77 + }else if("55".equals(gs)){
  78 + name="上南公司";
  79 + }else{
  80 + name="";
  81 + }
  82 + return name;
  83 + }
  84 +
  85 + private static String getState(String carState){
  86 + if(carState.equals("1")){
  87 + return "在册未在用";
  88 + }else if(carState.equals("2")){
  89 + return "在册在用";
  90 + }else if(carState.equals("3")){
  91 + return "报废审核中";
  92 + }else if(carState.equals("4")){
  93 + return "报废待更新";
  94 + }else if(carState.equals("5")){
  95 + return "报废已更新";
  96 + }else{
  97 + return "";
  98 + }
  99 + }
  100 + public Map<String, Long> getEndtime(String date){
  101 + Map<String, Long> map=new HashMap<String,Long>();
  102 + List<String> objList = new ArrayList<String>();
  103 + String sql="select xl,endtime from bsth_c_calc_count "
  104 + + " where date = ? ";
  105 + objList.add(date);
  106 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  107 + new RowMapper<Map<String, Object>>(){
  108 + @Override
  109 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  110 + Map<String, Object> m=new HashMap<String, Object>();
  111 + m.put("line", rs.getString("xl"));
  112 + m.put("endtime", rs.getString("endtime"));
  113 + return m;
  114 + }
  115 + });
  116 + for (int i = 0; i < list.size(); i++) {
  117 + map.put(list.get(i).get("line").toString(),
  118 + Long.parseLong(list.get(i).get("endtime").toString()));
  119 + }
  120 + return map;
  121 + }
  122 + @GET
  123 + @Path("/line/all")
  124 + public List<Map<String, Object>> findLineAll(){
  125 + String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"
  126 + + " a.shanghai_linecode, a.nature from "
  127 + + " bsth_c_line a left join bsth_c_line_config b "
  128 + + " on a.id=b.line where "
  129 + + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "
  130 + + " and a.remove=0 ";
  131 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  132 + new RowMapper<Map<String, Object>>(){
  133 + @Override
  134 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  135 + Map<String, Object> m=new HashMap<String,Object>();
  136 + m.put("state", rs.getString("start_opt"));
  137 + m.put("company", rs.getString("company"));
  138 + m.put("companyName", getGs(rs.getString("company")));
  139 + m.put("lineCode",rs.getString("line_code"));
  140 + m.put("name", rs.getString("name"));
  141 + m.put("level", rs.getString("level"));
  142 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  143 + m.put("nature", getNature(rs.getString("nature")));
  144 + return m;
  145 + }
  146 + });
  147 + Date d=new Date();
  148 + SimpleDateFormat hm=new SimpleDateFormat("HH:mm");
  149 + SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");
  150 +
  151 + String qqrq=ymd.format(d);
  152 + String qqsj=hm.format(d);
  153 + String qqsjs[]=qqsj.split(":");
  154 + Date nDate=new Date();
  155 + Calendar calendar = Calendar.getInstance();
  156 + calendar.setTime(nDate);
  157 + calendar.add(Calendar.DAY_OF_MONTH, -1);
  158 + Date dBefore = calendar.getTime();
  159 + String qqrqbefore =ymd.format(dBefore);
  160 + int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);
  161 + Map<String, Long> endMap1=getEndtime(qqrqbefore);
  162 + Map<String, Long> endMap2=getEndtime(qqrq);
  163 +
  164 + for (int i = 0; i < list.size(); i++) {
  165 + Map<String, Object> m=list.get(i);
  166 + int fcsjtime=0;
  167 + if(m.get("state")!=null){
  168 + String start_opt[]=m.get("state").toString().split(":");
  169 + fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);
  170 + }
  171 + //请求时间小于翻班时间 营运日期当做请求日期的前一天。
  172 + long maxtime=d.getTime();
  173 + String yyzt="";
  174 + if(qqsjtime<fcsjtime){
  175 + if(endMap1.get(m.get("lineCode").toString())!=null){
  176 + if(endMap1.get(m.get("lineCode").toString())>=maxtime){
  177 + yyzt="营运";
  178 + }else{
  179 + yyzt="未营运";
  180 + }
  181 + }else{
  182 + yyzt="未营运";
  183 + }
  184 + }else{
  185 + if(endMap2.get(m.get("lineCode").toString())!=null){
  186 + if(endMap2.get(m.get("lineCode").toString())>=maxtime){
  187 + yyzt="营运";
  188 + }else{
  189 + yyzt="未营运";
  190 + }
  191 + }else{
  192 + yyzt="未营运";
  193 + }
  194 + }
  195 + m.put("state", yyzt);
  196 + }
  197 + return list;
  198 + }
  199 +
  200 +
  201 + @GET
  202 + @Path("/line/company/{companyId}")
  203 + public List<Map<String, Object>> findLineByCompany(@PathParam("companyId") String companyId) {
  204 + List<String> objList = new ArrayList<String>();
  205 + String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"
  206 + + " a.shanghai_linecode, a.nature from "
  207 + + " bsth_c_line a left join bsth_c_line_config b "
  208 + + " on a.id=b.line where "
  209 + + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "
  210 + + " and a.remove=0 and a.company = ?";
  211 + objList.add(companyId);
  212 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  213 + new RowMapper<Map<String, Object>>(){
  214 + @Override
  215 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  216 + Map<String, Object> m=new HashMap<String,Object>();
  217 + m.put("state", rs.getString("start_opt"));
  218 + m.put("company", rs.getString("company"));
  219 + m.put("companyName", getGs(rs.getString("company")));
  220 + m.put("lineCode",rs.getString("line_code"));
  221 + m.put("name", rs.getString("name"));
  222 + m.put("level", rs.getString("level"));
  223 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  224 + m.put("nature", getNature(rs.getString("nature")));
  225 + return m;
  226 + }
  227 + });
  228 + Date d=new Date();
  229 + SimpleDateFormat hm=new SimpleDateFormat("HH:mm");
  230 + SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");
  231 +
  232 + String qqrq=ymd.format(d);
  233 + String qqsj=hm.format(d);
  234 + String qqsjs[]=qqsj.split(":");
  235 + Date nDate=new Date();
  236 + Calendar calendar = Calendar.getInstance();
  237 + calendar.setTime(nDate);
  238 + calendar.add(Calendar.DAY_OF_MONTH, -1);
  239 + Date dBefore = calendar.getTime();
  240 + String qqrqbefore =ymd.format(dBefore);
  241 + int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);
  242 + Map<String, Long> endMap1=getEndtime(qqrqbefore);
  243 + Map<String, Long> endMap2=getEndtime(qqrq);
  244 +
  245 + for (int i = 0; i < list.size(); i++) {
  246 + Map<String, Object> m=list.get(i);
  247 + int fcsjtime=0;
  248 + if(m.get("state")!=null){
  249 + String start_opt[]=m.get("state").toString().split(":");
  250 + fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);
  251 + }
  252 + //请求时间小于翻班时间 营运日期当做请求日期的前一天。
  253 + long maxtime=d.getTime();
  254 + String yyzt="";
  255 + if(qqsjtime<fcsjtime){
  256 + if(endMap1.get(m.get("lineCode").toString())!=null){
  257 + if(endMap1.get(m.get("lineCode").toString())>=maxtime){
  258 + yyzt="营运";
  259 + }else{
  260 + yyzt="未营运";
  261 + }
  262 + }else{
  263 + yyzt="未营运";
  264 + }
  265 + }else{
  266 + if(endMap2.get(m.get("lineCode").toString())!=null){
  267 + if(endMap2.get(m.get("lineCode").toString())>=maxtime){
  268 + yyzt="营运";
  269 + }else{
  270 + yyzt="未营运";
  271 + }
  272 + }else{
  273 + yyzt="未营运";
  274 + }
  275 + }
  276 + m.put("state", yyzt);
  277 + }
  278 + return list;
  279 + }
  280 +
  281 + @GET
  282 + @Path("/line/{lineCode}")
  283 + public List<Map<String, Object>> findLineByCode(@PathParam("lineCode") String lineCode) {
  284 + List<String> objList = new ArrayList<String>();
  285 + String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"
  286 + + " a.shanghai_linecode, a.nature from "
  287 + + " bsth_c_line a left join bsth_c_line_config b "
  288 + + " on a.id=b.line where "
  289 + + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "
  290 + + " and a.remove=0 and a.line_code = ?";
  291 + objList.add(lineCode);
  292 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  293 + new RowMapper<Map<String, Object>>(){
  294 + @Override
  295 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  296 + Map<String, Object> m=new HashMap<String,Object>();
  297 + m.put("state", rs.getString("start_opt"));
  298 + m.put("company", rs.getString("company"));
  299 + m.put("companyName", getGs(rs.getString("company")));
  300 + m.put("lineCode",rs.getString("line_code"));
  301 + m.put("name", rs.getString("name"));
  302 + m.put("level", rs.getString("level"));
  303 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  304 + m.put("nature", getNature(rs.getString("nature")));
  305 + return m;
  306 + }
  307 + });
  308 + Date d=new Date();
  309 + SimpleDateFormat hm=new SimpleDateFormat("HH:mm");
  310 + SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");
  311 +
  312 + String qqrq=ymd.format(d);
  313 + String qqsj=hm.format(d);
  314 + String qqsjs[]=qqsj.split(":");
  315 + Date nDate=new Date();
  316 + Calendar calendar = Calendar.getInstance();
  317 + calendar.setTime(nDate);
  318 + calendar.add(Calendar.DAY_OF_MONTH, -1);
  319 + Date dBefore = calendar.getTime();
  320 + String qqrqbefore =ymd.format(dBefore);
  321 + int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);
  322 + Map<String, Long> endMap1=getEndtime(qqrqbefore);
  323 + Map<String, Long> endMap2=getEndtime(qqrq);
  324 +
  325 + for (int i = 0; i < list.size(); i++) {
  326 + Map<String, Object> m=list.get(i);
  327 + int fcsjtime=0;
  328 + if(m.get("state")!=null){
  329 + String start_opt[]=m.get("state").toString().split(":");
  330 + fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);
  331 + }
  332 + //请求时间小于翻班时间 营运日期当做请求日期的前一天。
  333 + long maxtime=d.getTime();
  334 + String yyzt="";
  335 + if(qqsjtime<fcsjtime){
  336 + if(endMap1.get(m.get("lineCode").toString())!=null){
  337 + if(endMap1.get(m.get("lineCode").toString())>=maxtime){
  338 + yyzt="营运";
  339 + }else{
  340 + yyzt="未营运";
  341 + }
  342 + }else{
  343 + yyzt="未营运";
  344 + }
  345 + }else{
  346 + if(endMap2.get(m.get("lineCode").toString())!=null){
  347 + if(endMap2.get(m.get("lineCode").toString())>=maxtime){
  348 + yyzt="营运";
  349 + }else{
  350 + yyzt="未营运";
  351 + }
  352 + }else{
  353 + yyzt="未营运";
  354 + }
  355 + }
  356 + m.put("state", yyzt);
  357 + }
  358 + return list;
  359 + }
  360 +
  361 + @GET
  362 + @Path("/line/level/{level}")
  363 + public List<Map<String, Object>> findLineByLevle(@PathParam("level") String level) {
  364 + List<String> objList = new ArrayList<String>();
  365 + String sql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"
  366 + + " a.shanghai_linecode, a.nature from "
  367 + + " bsth_c_line a left join bsth_c_line_config b "
  368 + + " on a.id=b.line where "
  369 + + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "
  370 + + " and a.remove=0 and a.level = ?";
  371 + objList.add(level);
  372 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  373 + new RowMapper<Map<String, Object>>(){
  374 + @Override
  375 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  376 + Map<String, Object> m=new HashMap<String,Object>();
  377 + m.put("state", rs.getString("start_opt"));
  378 + m.put("company", rs.getString("company"));
  379 + m.put("companyName", getGs(rs.getString("company")));
  380 + m.put("lineCode",rs.getString("line_code"));
  381 + m.put("name", rs.getString("name"));
  382 + m.put("level", rs.getString("level"));
  383 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  384 + m.put("nature", getNature(rs.getString("nature")));
  385 + return m;
  386 + }
  387 + });
  388 + Date d=new Date();
  389 + SimpleDateFormat hm=new SimpleDateFormat("HH:mm");
  390 + SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd");
  391 +
  392 + String qqrq=ymd.format(d);
  393 + String qqsj=hm.format(d);
  394 + String qqsjs[]=qqsj.split(":");
  395 + Date nDate=new Date();
  396 + Calendar calendar = Calendar.getInstance();
  397 + calendar.setTime(nDate);
  398 + calendar.add(Calendar.DAY_OF_MONTH, -1);
  399 + Date dBefore = calendar.getTime();
  400 + String qqrqbefore =ymd.format(dBefore);
  401 + int qqsjtime=Integer.parseInt(qqsjs[0])*60+Integer.parseInt(qqsjs[1]);
  402 + Map<String, Long> endMap1=getEndtime(qqrqbefore);
  403 + Map<String, Long> endMap2=getEndtime(qqrq);
  404 +
  405 + for (int i = 0; i < list.size(); i++) {
  406 + Map<String, Object> m=list.get(i);
  407 + int fcsjtime=0;
  408 + if(m.get("state")!=null){
  409 + String start_opt[]=m.get("state").toString().split(":");
  410 + fcsjtime=Integer.parseInt(start_opt[0])*60+Integer.parseInt(start_opt[1]);
  411 + }
  412 + //请求时间小于翻班时间 营运日期当做请求日期的前一天。
  413 + long maxtime=d.getTime();
  414 + String yyzt="";
  415 + if(qqsjtime<fcsjtime){
  416 + if(endMap1.get(m.get("lineCode").toString())!=null){
  417 + if(endMap1.get(m.get("lineCode").toString())>=maxtime){
  418 + yyzt="营运";
  419 + }else{
  420 + yyzt="未营运";
  421 + }
  422 + }else{
  423 + yyzt="未营运";
  424 + }
  425 + }else{
  426 + if(endMap2.get(m.get("lineCode").toString())!=null){
  427 + if(endMap2.get(m.get("lineCode").toString())>=maxtime){
  428 + yyzt="营运";
  429 + }else{
  430 + yyzt="未营运";
  431 + }
  432 + }else{
  433 + yyzt="未营运";
  434 + }
  435 + }
  436 + m.put("state", yyzt);
  437 + }
  438 + return list;
  439 + }
  440 + /*
  441 + * 线路接口结束
  442 + */
  443 +
  444 +
  445 + /*
  446 + * 线路配车接口开始
  447 + */
  448 + @GET
  449 + @Path("/lineCar/{type}/date/{date}")
  450 + public List<Map<String, Object>> findLineCarByDate(@PathParam("type") String type,@PathParam("date") String date) {
  451 + String sql="";
  452 + List<String> objList = new ArrayList<String>();
  453 + if(type.equals("all")){
  454 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc"
  455 + + " from bsth_c_calc_count t where t.date = ?";
  456 + objList.add(date);
  457 + }
  458 + if(type.equals("actual")){
  459 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc"
  460 + + " from bsth_c_calc_count t where t.date = ?";
  461 + objList.add(date);
  462 + }
  463 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  464 + new RowMapper<Map<String, Object>>(){
  465 + @Override
  466 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  467 + Map<String, Object> m=new HashMap<String,Object>();
  468 + m.put("date", rs.getString("date"));
  469 + m.put("company", rs.getString("gsdm"));
  470 + m.put("companyName", getGs(rs.getString("gsdm")));
  471 + m.put("lineCode",rs.getString("xl"));
  472 + m.put("lineName", rs.getString("xl_name"));
  473 + m.put("jhcc", rs.getString("jhcc"));
  474 + m.put("sjcc", rs.getString("sjcc"));
  475 + return m;
  476 + }
  477 + });
  478 +
  479 + return list;
  480 + }
  481 +
  482 +
  483 + @GET
  484 + @Path("/lineCar/{type}/date/{date}/line/{line}")
  485 + public List<Map<String, Object>> findLineCarByDateLine(@PathParam("type") String type,@PathParam("date") String date,
  486 + @PathParam("line") String line) {
  487 + String sql="";
  488 + List<String> objList = new ArrayList<String>();
  489 + if(type.equals("all")){
  490 + sql="select t.gsdm,t.xl,t.xl_name,t.jhccz as jhcc,t.sjcc"
  491 + + " from bsth_c_calc_count t where t.date = ?"
  492 + + " and xl = ?";
  493 + objList.add(date);
  494 + objList.add(line);
  495 + }
  496 + if(type.equals("actual")){
  497 + sql="select t.gsdm,t.xl,t.xl_name,t.jhcc as jhcc,t.sjcc"
  498 + + " from bsth_c_calc_count t where t.date = ?"
  499 + + " and xl = ?";
  500 + objList.add(date);
  501 + objList.add(line);
  502 +
  503 + }
  504 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  505 + new RowMapper<Map<String, Object>>(){
  506 + @Override
  507 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  508 + Map<String, Object> m=new HashMap<String,Object>();
  509 + m.put("company", rs.getString("gsdm"));
  510 + m.put("companyName", getGs(rs.getString("gsdm")));
  511 + m.put("lineCode",rs.getString("xl"));
  512 + m.put("lineName", rs.getString("xl_name"));
  513 + m.put("jhcc", rs.getString("jhcc"));
  514 + m.put("sjcc", rs.getString("sjcc"));
  515 + return m;
  516 + }
  517 + });
  518 +
  519 + return list;
  520 + }
  521 +
  522 + /*
  523 + * 线路配车接口结束
  524 + */
  525 +
  526 + /*
  527 + * 线路配人接口开始
  528 + */
  529 + @GET
  530 + @Path("/linePerson/{type}/date/{date}")
  531 + public List<Map<String, Object>> findLinePersonByDate(@PathParam("type") String type,@PathParam("date") String date) {
  532 + String sql="";
  533 + List<String> objList = new ArrayList<String>();
  534 + if(type.equals("all")){
  535 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr"
  536 + + " from bsth_c_calc_count t where t.date = ?";
  537 + objList.add(date);
  538 + }
  539 + if(type.equals("actual")){
  540 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr"
  541 + + " from bsth_c_calc_count t where t.date = ?";
  542 + objList.add(date);
  543 + }
  544 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  545 + new RowMapper<Map<String, Object>>(){
  546 + @Override
  547 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  548 + Map<String, Object> m=new HashMap<String,Object>();
  549 + m.put("date", rs.getString("date"));
  550 + m.put("company", rs.getString("gsdm"));
  551 + m.put("companyName", getGs(rs.getString("gsdm")));
  552 + m.put("lineCode",rs.getString("xl"));
  553 + m.put("lineName", rs.getString("xl_name"));
  554 + String jhpr=rs.getString("jhpr");
  555 + m.put("jhjsy", jhpr.split("/")[0]);
  556 + m.put("jhspy", jhpr.split("/")[1]);
  557 + String sjpr= rs.getString("sjpr");
  558 + m.put("sjjsy", sjpr.split("/")[0]);
  559 + m.put("sjspy", sjpr.split("/")[1]);
  560 + return m;
  561 + }
  562 + });
  563 +
  564 + return list;
  565 + }
  566 +
  567 +
  568 + @GET
  569 + @Path("/linePerson/{type}/date/{date}/line/{line}")
  570 + public List<Map<String, Object>> findLinePersonByDateLine(@PathParam("type") String type,@PathParam("date") String date,
  571 + @PathParam("line") String line) {
  572 + String sql="";
  573 + List<String> objList = new ArrayList<String>();
  574 + if(type.equals("all")){
  575 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprz as jhpr,t.sjpr"
  576 + + " from bsth_c_calc_count t where t.date = ?"
  577 + + " and xl = ?";
  578 + objList.add(date);
  579 + objList.add(line);
  580 + }
  581 + if(type.equals("actual")){
  582 + sql="select t.date,t.gsdm,t.xl,t.xl_name,t.jhprss as jhpr,t.sjpr"
  583 + + " from bsth_c_calc_count t where t.date = ?"
  584 + + " and xl = ?";
  585 + objList.add(date);
  586 + objList.add(line);
  587 + }
  588 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  589 + new RowMapper<Map<String, Object>>(){
  590 + @Override
  591 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  592 + Map<String, Object> m=new HashMap<String,Object>();
  593 + m.put("date", rs.getString("date"));
  594 + m.put("company", rs.getString("gsdm"));
  595 + m.put("companyName", getGs(rs.getString("gsdm")));
  596 + m.put("lineCode",rs.getString("xl"));
  597 + m.put("lineName", rs.getString("xl_name"));
  598 + String jhpr=rs.getString("jhpr");
  599 + m.put("jhjsy", jhpr.split("/")[0]);
  600 + m.put("jhspy", jhpr.split("/")[1]);
  601 + String sjpr= rs.getString("sjpr");
  602 + m.put("sjjsy", sjpr.split("/")[0]);
  603 + m.put("sjspy", sjpr.split("/")[1]);
  604 + return m;
  605 + }
  606 + });
  607 +
  608 + return list;
  609 + }
  610 +
  611 +
  612 +
  613 +
  614 + /*
  615 + * 线路配人接口结束
  616 + */
  617 +
  618 +
  619 + /*
  620 + * 线路班次接口开始
  621 + */
  622 + @GET
  623 + @Path("/lineBc/{type}/date/{date}")
  624 + public List<Map<String, Object>> findLineBcByDate(@PathParam("type") String type,
  625 + @PathParam("date") String date) {
  626 + String sql="";
  627 + List<String> objList = new ArrayList<String>();
  628 + if(type.equals("all")){
  629 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc,"
  630 + + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t"
  631 + + " where t.date = ?";
  632 + objList.add(date);
  633 + }
  634 + if(type.equals("actual")){
  635 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc,"
  636 + + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t"
  637 + + " where t.date = ?";
  638 + objList.add(date);
  639 + }
  640 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  641 + new RowMapper<Map<String, Object>>(){
  642 + @Override
  643 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  644 + Map<String, Object> m=new HashMap<String,Object>();
  645 + m.put("company", rs.getString("gsdm"));
  646 + m.put("companyName", getGs(rs.getString("gsdm")));
  647 + m.put("lineCode",rs.getString("xl"));
  648 + m.put("lineName", rs.getString("xl_name"));
  649 + m.put("jhbc", rs.getString("jhbc"));
  650 + m.put("jhzgfbc", rs.getString("jhzgfbc"));
  651 + m.put("jhwgfbc", rs.getString("jhwgfbc"));
  652 + m.put("sjbc", rs.getString("sjbc"));
  653 + m.put("sjzgfbc", rs.getString("sjzgfbc"));
  654 + m.put("sjwgfbc", rs.getString("sjwgfbc"));
  655 + return m;
  656 + }
  657 + });
  658 + return list;
  659 + }
  660 +
  661 +
  662 + @GET
  663 + @Path("/lineBc/{type}/date/{date}/line/{line}")
  664 + public List<Map<String, Object>> findLineBcByDateLine(@PathParam("type") String type,
  665 + @PathParam("date") String date,@PathParam("line") String line) {
  666 + String sql="";
  667 + List<String> objList = new ArrayList<String>();
  668 + if(type.equals("all")){
  669 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbcz as jhbc,t.jhzgfbcz as jhzgfbc,"
  670 + + " t.jhwgfbcz as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t "
  671 + + " where t.date = ? and xl = ?";
  672 + objList.add(date);
  673 + objList.add(line);
  674 + }
  675 + if(type.equals("actual")){
  676 + sql="select t.gsdm,t.xl,t.xl_name,t.jhbc as jhbc,t.jhzgfbcss as jhzgfbc,"
  677 + + " t.jhwgfbcss as jhwgfbc,t.sjbc,t.sjzgfbc,t.sjwgfbc from bsth_c_calc_count t"
  678 + + " where t.date = ? and xl = ?";
  679 + objList.add(date);
  680 + objList.add(line);
  681 + }
  682 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  683 + new RowMapper<Map<String, Object>>(){
  684 + @Override
  685 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  686 + Map<String, Object> m=new HashMap<String,Object>();
  687 + m.put("company", rs.getString("gsdm"));
  688 + m.put("companyName", getGs(rs.getString("gsdm")));
  689 + m.put("lineCode",rs.getString("xl"));
  690 + m.put("lineName", rs.getString("xl_name"));
  691 + m.put("jhbc", rs.getString("jhbc"));
  692 + m.put("jhzgfbc", rs.getString("jhzgfbc"));
  693 + m.put("jhwgfbc", rs.getString("jhwgfbc"));
  694 + m.put("sjbc", rs.getString("sjbc"));
  695 + m.put("sjzgfbc", rs.getString("sjzgfbc"));
  696 + m.put("sjwgfbc", rs.getString("sjwgfbc"));
  697 + return m;
  698 + }
  699 + });
  700 + return list;
  701 + }
  702 +
  703 + /*
  704 + * 线路班次接口结束
  705 + */
  706 +
  707 + /*
  708 + * 线路里程接口开始
  709 + */
  710 +
  711 + @GET
  712 + @Path("/lineLc/{type}/date/{date}")
  713 + public List<Map<String, Object>> findLineLcByDate(@PathParam("type") String type,
  714 + @PathParam("date") String date) {
  715 + String sql="";
  716 + List<String> objList = new ArrayList<String>();
  717 + if(type.equals("all")){
  718 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc,"
  719 + + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  720 + + " where t.date = ?";
  721 + objList.add(date);
  722 + }
  723 + if(type.equals("actual")){
  724 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc,"
  725 + + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  726 + + " where t.date = ?";
  727 + objList.add(date);
  728 + }
  729 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  730 + new RowMapper<Map<String, Object>>(){
  731 + @Override
  732 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  733 + Map<String, Object> m=new HashMap<String,Object>();
  734 + m.put("company", rs.getString("gsdm"));
  735 + m.put("companyName", getGs(rs.getString("gsdm")));
  736 + m.put("lineCode",rs.getString("xl"));
  737 + m.put("lineName", rs.getString("xl_name"));
  738 + m.put("jhzlc", rs.getString("jhzlc"));
  739 + m.put("jhyylc", rs.getString("jhyylc"));
  740 + m.put("jhkslc", rs.getString("jhkslc"));
  741 + m.put("sjzlc", rs.getString("sjzlc"));
  742 + m.put("sjyylc", rs.getString("sjyylc"));
  743 + m.put("sjkslc", rs.getString("sjkslc"));
  744 + if(Double.parseDouble(rs.getString("jhzlc"))>0){
  745 + double zlczxl=Double.parseDouble(rs.getString("sjzlc"))/Double.parseDouble(rs.getString("jhzlc"));
  746 + m.put("zlczxl",df.format(zlczxl*100)+"%");
  747 + }else{
  748 + m.put("zlczxl","0.00%");
  749 +
  750 + }
  751 + if(Double.parseDouble(rs.getString("jhyylc"))>0){
  752 + double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc"));
  753 + m.put("yylczxl",df.format(yylczxl*100)+"%");
  754 + }else{
  755 + m.put("yylczxl","0.00%");
  756 + }
  757 + return m;
  758 + }
  759 + });
  760 + return list;
  761 + }
  762 +
  763 +
  764 + @GET
  765 + @Path("/lineLc/{type}/date/{date}/line/{line}")
  766 + public List<Map<String, Object>> findLineLcByDateLine(@PathParam("type") String type,
  767 + @PathParam("date") String date,@PathParam("line") String line) {
  768 + String sql="";
  769 + List<String> objList = new ArrayList<String>();
  770 + if(type.equals("all")){
  771 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzglz as jhzlc,t.jhyylcz as jhyylc,"
  772 + + " t.jhkslcz as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  773 + + " where t.date = ? and xl = ?";
  774 + objList.add(date);
  775 + objList.add(line);
  776 + }
  777 + if(type.equals("actual")){
  778 + sql="select t.gsdm,t.xl,t.xl_name,t.jhzgl as jhzlc,t.jhyylc as jhyylc,"
  779 + + " t.jhkslc as jhkslc,t.sjzgl as sjzlc,t.sjyylc,t.sjkslc from bsth_c_calc_count t"
  780 + + " where t.date = ? and xl = ?";
  781 + objList.add(date);
  782 + objList.add(line);
  783 + }
  784 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  785 + new RowMapper<Map<String, Object>>(){
  786 + @Override
  787 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  788 + Map<String, Object> m=new HashMap<String,Object>();
  789 + m.put("company", rs.getString("gsdm"));
  790 + m.put("companyName", getGs(rs.getString("gsdm")));
  791 + m.put("lineCode",rs.getString("xl"));
  792 + m.put("lineName", rs.getString("xl_name"));
  793 + m.put("jhzlc", rs.getString("jhzlc"));
  794 + m.put("jhyylc", rs.getString("jhyylc"));
  795 + m.put("jhkslc", rs.getString("jhkslc"));
  796 + m.put("sjzlc", rs.getString("sjzlc"));
  797 + m.put("sjyylc", rs.getString("sjyylc"));
  798 + m.put("sjkslc", rs.getString("sjkslc"));
  799 + if(Double.parseDouble(rs.getString("jhzlc"))>0){
  800 + double zlczxl=Double.parseDouble(rs.getString("sjzlc"))/Double.parseDouble(rs.getString("jhzlc"));
  801 + m.put("zlczxl",df.format(zlczxl*100)+"%");
  802 + }else{
  803 + m.put("zlczxl","0.00%");
  804 +
  805 + }
  806 + if(Double.parseDouble(rs.getString("jhyylc"))>0){
  807 + double yylczxl=Double.parseDouble(rs.getString("sjyylc"))/Double.parseDouble(rs.getString("jhyylc"));
  808 + m.put("yylczxl",df.format(yylczxl*100)+"%");
  809 + }else{
  810 + m.put("yylczxl","0.00%");
  811 + }
  812 + return m;
  813 + }
  814 + });
  815 + return list;
  816 + }
  817 + /*
  818 + * 线路里程接口结束
  819 + */
  820 +
  821 +
  822 + /*
  823 + * 班次执行率连续三天不满93%推送
  824 + */
  825 + @GET
  826 + @Path("/abnormal/executionRate/date/{date}")
  827 + public List<Map<String, Object>> executionRate(@PathParam("date") String date) {
  828 + List<String> objList = new ArrayList<String>();
  829 + String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t"
  830 + + " where t.date = ? and push_type in ('1','3')";
  831 + objList.add(date);
  832 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  833 + new RowMapper<Map<String, Object>>(){
  834 + @Override
  835 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  836 + Map<String, Object> m=new HashMap<String,Object>();
  837 + m.put("companyName", rs.getString("gs_name"));
  838 + m.put("lineCode",rs.getString("xl_bm"));
  839 + m.put("lineName", rs.getString("xl_name"));
  840 + m.put("showDate", rs.getString("show_date"));
  841 + return m;
  842 + }
  843 + });
  844 + return list;
  845 + }
  846 + /*
  847 + * 首末班发车连续三天不准点
  848 + */
  849 + @GET
  850 + @Path("/abnormal/firstAndLast/date/{date}")
  851 + public List<Map<String, Object>> firstAndLast(@PathParam("date") String date) {
  852 + List<String> objList = new ArrayList<String>();
  853 + String sql="select gs_name,show_date,xl_bm,xl_name from bsth_c_calc_push t"
  854 + + " where t.date = ? and push_type in ('2','3')";
  855 + objList.add(date);
  856 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  857 + new RowMapper<Map<String, Object>>(){
  858 + @Override
  859 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  860 + Map<String, Object> m=new HashMap<String,Object>();
  861 + m.put("companyName", rs.getString("gs_name"));
  862 + m.put("lineCode",rs.getString("xl_bm"));
  863 + m.put("lineName", rs.getString("xl_name"));
  864 + m.put("showDate", rs.getString("show_date"));
  865 + return m;
  866 + }
  867 + });
  868 + return list;
  869 + }
  870 +
  871 + /*
  872 + * 车辆数据接口开始
  873 + */
  874 +
  875 + @GET
  876 + @Path("/car/all")
  877 + public List<Map<String, Object>> findCar() {
  878 + String carStr= GetHttpInterface.getHttpInterface("http://180.166.5.82:8076/cars/getAllCarsInterface");
  879 + //车辆库资料资料
  880 + List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);
  881 + //调度系统车辆资料
  882 + String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars";
  883 + List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,
  884 + new RowMapper<Map<String, Object>>(){
  885 + @Override
  886 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  887 + Map<String, Object> m=new HashMap<String,Object>();
  888 + m.put("equipment_code", rs.getString("equipment_code"));
  889 + m.put("insideCode", rs.getString("inside_code"));
  890 + m.put("supplier_name",rs.getString("supplier_name"));
  891 + return m;
  892 + }
  893 + });
  894 + for (int i = 0; i < clkList.size(); i++) {
  895 + Map<String, Object> m1=clkList.get(i);
  896 + String carCode=m1.get("car_code").toString();
  897 + m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));
  898 + for (int j = 0; j < ddkList.size(); j++) {
  899 + Map<String, Object> m2=ddkList.get(j);
  900 + String insideCode=m2.get("insideCode").toString();
  901 + if(carCode.equals(insideCode)){
  902 + m1.put("equipment_code", m2.get("equipment_code"));
  903 + m1.put("supplier_name", m2.get("supplier_name"));
  904 + }
  905 +
  906 + }
  907 + }
  908 + return clkList;
  909 + }
  910 +
  911 +
  912 + @GET
  913 + @Path("/car/company/{companyId}")
  914 + public List<Map<String, Object>> findCarByCompany(@PathParam("companyId") String companyId) {
  915 + String carStr= GetHttpInterface.
  916 + getHttpInterface("http://180.166.5.82:8076/cars/getAllCarsInterface?company="+companyId);
  917 + //车辆库资料资料
  918 + List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);
  919 + //调度系统车辆资料
  920 + String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where business_code='"+companyId+"'";
  921 + List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,
  922 + new RowMapper<Map<String, Object>>(){
  923 + @Override
  924 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  925 + Map<String, Object> m=new HashMap<String,Object>();
  926 + m.put("equipment_code", rs.getString("equipment_code"));
  927 + m.put("insideCode", rs.getString("inside_code"));
  928 + m.put("supplier_name",rs.getString("supplier_name"));
  929 + return m;
  930 + }
  931 + });
  932 + for (int i = 0; i < clkList.size(); i++) {
  933 + Map<String, Object> m1=clkList.get(i);
  934 + String carCode=m1.get("car_code").toString();
  935 + m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));
  936 + for (int j = 0; j < ddkList.size(); j++) {
  937 + Map<String, Object> m2=ddkList.get(j);
  938 + String insideCode=m2.get("insideCode").toString();
  939 + if(carCode.equals(insideCode)){
  940 + m1.put("equipment_code", m2.get("equipment_code"));
  941 + m1.put("supplier_name", m2.get("supplier_name"));
  942 + }
  943 +
  944 + }
  945 + }
  946 + return clkList;
  947 + }
  948 +
  949 + @GET
  950 + @Path("/car/code/{carCode}")
  951 + public List<Map<String, Object>> findCarByCode(@PathParam("carCode") String carCode) {
  952 + String carStr= GetHttpInterface.
  953 + getHttpInterface("http://101.95.0.106:8076/cars/getAllCarsInterface?car_code="+carCode);
  954 + //车辆库资料资料
  955 + List<Map<String, Object>> clkList=(List<Map<String, Object>>) JSONObject.parse(carStr);
  956 + //调度系统车辆资料
  957 + String carSql="select equipment_code, inside_code,supplier_name from bsth_c_cars where inside_code='"+carCode+"'";
  958 + List<Map<String, Object>> ddkList=jdbcTemplate.query(carSql,
  959 + new RowMapper<Map<String, Object>>(){
  960 + @Override
  961 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  962 + Map<String, Object> m=new HashMap<String,Object>();
  963 + m.put("equipment_code", rs.getString("equipment_code"));
  964 + m.put("insideCode", rs.getString("inside_code"));
  965 + m.put("supplier_name",rs.getString("supplier_name"));
  966 + return m;
  967 + }
  968 + });
  969 +
  970 + for (int i = 0; i < clkList.size(); i++) {
  971 + Map<String, Object> m1=clkList.get(i);
  972 + String code=m1.get("car_code").toString().trim();
  973 + m1.put("state_name", getState(m1.get("car_state")==null?"":m1.get("car_state").toString()));
  974 + for (int j = 0; j < ddkList.size(); j++) {
  975 + Map<String, Object> m2=ddkList.get(j);
  976 + String insideCode=m2.get("insideCode").toString().trim();
  977 + if(code.equals(insideCode)){
  978 + m1.put("equipment_code", m2.get("equipment_code"));
  979 + m1.put("supplier_name", m2.get("supplier_name"));
  980 + }
  981 +
  982 + }
  983 + }
  984 + return clkList;
  985 + }
  986 + /*
  987 + * 车辆数据接口结束
  988 + */
  989 +
  990 + /*
  991 + * 事故数据接口开始
  992 + */
  993 + @GET
  994 + @Path("/accident/startTime/{startTime}/endTime/{endTime}")
  995 + public List<Map<String, Object>> findAccident(@PathParam("startTime") String startTime,
  996 + @PathParam("endTime") String endTime) {
  997 + String accidentAll= GetHttpInterface.getHttpInterface("http://180.168.57.114:9019/pdsafe/LineSms/getAccidentSubmitAll.do?"
  998 + + "submitDateBegin="+startTime+"&submitDateEnd="+endTime);
  999 + List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);
  1000 + return list;
  1001 + }
  1002 +
  1003 +
  1004 + /*
  1005 + * 事故数据接口结束
  1006 + */
  1007 +
  1008 + /*
  1009 + *安全驾驶接口开始
  1010 + */
  1011 + @GET
  1012 + @Path("/safedriving/starDate/{starDate}/endDate/{endDate}")
  1013 + public List<Map<String, Object>> findSafedriving(@PathParam("starDate") String starDate,
  1014 + @PathParam("endDate") String endDate) {
  1015 + String accidentAll= GetHttpInterface.getHttpInterface("http://211.95.61.66:9006/safedriving/safedrivingInterface?StarTime="+starDate+"&EndTime="+endDate);
  1016 + List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);
  1017 + return list;
  1018 + }
  1019 + @GET
  1020 + @Path("/safedriving/starDate/{starDate}/endDate/{endDate}/line/{line}")
  1021 + public List<Map<String, Object>> findSafedrivingByLine(@PathParam("starDate") String starDate,
  1022 + @PathParam("endDate") String endDate,@PathParam("line") String line) {
  1023 + String accidentAll= GetHttpInterface.getHttpInterface("http://211.95.61.66:9006/safedriving/safedrivingInterface?StarTime="+starDate+"&EndTime="+endDate
  1024 + +"&LineId="+line);
  1025 + List<Map<String, Object>> list=(List<Map<String, Object>>) JSONObject.parse(accidentAll);
  1026 + return list;
  1027 + }
  1028 + /*
  1029 + *安全驾驶接口结束
  1030 + */
  1031 +
  1032 +
  1033 + /**
  1034 + * 闵行线路班次里程
  1035 + *
  1036 + *
  1037 + *
  1038 + */
  1039 +
  1040 + @GET
  1041 + @Path("/findByAll/starDate/{starDate}/endDate/{endDate}/line/{line}")
  1042 + public List<Map<String, Object>> findMinhang(@PathParam("starDate") String starDate,
  1043 + @PathParam("endDate") String endDate,@PathParam("line") String line) {
  1044 + List<String> objList = new ArrayList<String>();
  1045 + String sql="select xl,xl_name,date,jhszfcs,sjszfczds,jhbc,sjbc,jhcc,sjcc,"
  1046 + + " jhyylc,sjyylc,jhkslc,sjkslc,jhssgfbcs,sjgfbcs,jhssdgbcs,"
  1047 + + " sjdgbcs from bsth_c_calc_count "
  1048 + + " where date >= ? and date <= ?";
  1049 + objList.add(starDate);
  1050 + objList.add(endDate);
  1051 +
  1052 + if(!line.equals("all")){
  1053 + sql +=" and xl = ?";
  1054 + objList.add(line);
  1055 + }
  1056 +
  1057 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  1058 + new RowMapper<Map<String, Object>>(){
  1059 + @Override
  1060 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1061 + Map<String, Object> m=new HashMap<String,Object>();
  1062 + m.put("lineCode",rs.getString("xl"));
  1063 + m.put("lineName", rs.getString("xl_name"));
  1064 + m.put("date", rs.getString("date"));
  1065 + m.put("jhszfcs", rs.getString("jhszfcs"));
  1066 + m.put("sjszfczds", rs.getString("sjszfczds"));
  1067 + m.put("jhbc", rs.getString("jhbc"));
  1068 + m.put("sjbc", rs.getString("sjbc"));
  1069 + m.put("jhcc", rs.getString("jhcc"));
  1070 + m.put("sjcc", rs.getString("sjcc"));
  1071 + m.put("jhyylc", rs.getString("jhyylc"));
  1072 + m.put("sjyylc", rs.getString("sjyylc"));
  1073 + m.put("jhkslc", rs.getString("jhkslc"));
  1074 + m.put("sjkslc", rs.getString("sjkslc"));
  1075 + m.put("jhgfbcs", rs.getString("jhssgfbcs"));
  1076 + m.put("sjgfbcs", rs.getString("sjgfbcs"));
  1077 + m.put("jhdgbcs", rs.getString("jhssdgbcs"));
  1078 + m.put("sjdgbcs", rs.getString("sjdgbcs"));
  1079 + return m;
  1080 + }
  1081 + });
  1082 + return list;
  1083 + }
  1084 +
  1085 + /**
  1086 + * 赵冲需要的数据接口
  1087 + *
  1088 + */
  1089 + @GET
  1090 + @Path("/findByCompany/{company}/date/{date}")
  1091 + public List<Map<String, Object>> findByCompany(@PathParam("company") String company,
  1092 + @PathParam("date") String date) {
  1093 + List<String> objList = new ArrayList<String>();
  1094 + String sql="select t.company as gs_code,t.date,SUM(t.jhcczgf) as jhccs ,SUM(t.sjcczgf) as ccs,AVG(ccl) as ccl"
  1095 + + " ,SUM(t.sjzgl*1000)/1000 as sum_mileage ,SUM(jcgl*1000)/1000 as airpor_mileage "
  1096 + + " from (select a.line_code,b.date,a.company,b.jhcczgf,b.sjcczgf,"
  1097 + + " round(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0)),3) as ccl,c.sjzgl ,"
  1098 + + " ifnull(d.sjzgl,0) as jcgl from bsth_c_line a LEFT JOIN "
  1099 + + " (SELECT * from bsth_c_calc_sheet where date = ?) b on a.line_code=b.xl"
  1100 + + " left join (select * from bsth_c_calc_count where date = ?) c on a.line_code=c.xl "
  1101 + + " left join (select * from bsth_c_calc_count where date = ? "
  1102 + + " and xl_name like '%机场%') d on a.line_code=d.xl "
  1103 + + " where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')) t "
  1104 + + " where t.date is not null ";
  1105 + objList.add(date);
  1106 + objList.add(date);
  1107 + objList.add(date);
  1108 + if(!company.equals("all")){
  1109 + sql +=" and t.company = ?";
  1110 + objList.add(company);
  1111 + }
  1112 + sql +=" group by t.company,t.date";
  1113 +
  1114 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  1115 + new RowMapper<Map<String, Object>>(){
  1116 + @Override
  1117 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1118 + Map<String, Object> m=new HashMap<String,Object>();
  1119 + m.put("gs_name", getGs(rs.getString("gs_code")));
  1120 + m.put("gs_code",rs.getString("gs_code"));
  1121 + m.put("date", rs.getString("date"));
  1122 + m.put("jhccs", rs.getString("jhccs"));
  1123 + m.put("ccs", rs.getString("ccs"));
  1124 + m.put("ccl", rs.getString("ccl"));
  1125 + m.put("sum_mileage", rs.getString("sum_mileage"));
  1126 + m.put("airpor_mileage", rs.getString("airpor_mileage"));
  1127 + return m;
  1128 + }
  1129 + });
  1130 + return list;
  1131 + }
  1132 + @GET
  1133 + @Path("/findTarget/gs/{gs}/fgs/{fgs}/date/{date}")
  1134 + public List<Map<String, Object>> findTarget(@PathParam("gs") String gs,@PathParam("fgs") String fgs,
  1135 + @PathParam("date") String date) {
  1136 + SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
  1137 + String d=sdf.format(new Date());
  1138 + String sql="";
  1139 + List<String> objList = new ArrayList<String>();
  1140 + if(gs.equals("all")){
  1141 + sql ="select x.gsdm,'' as fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from ("
  1142 + + " select b.gsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3)* 100 as zgf_ccl,"
  1143 + + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from "
  1144 + + " bsth_c_calc_sheet b where b.date like ? and b.date < ? "
  1145 + + " and b.xl in(select a.line_code from bsth_c_line a where "
  1146 + + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm ) x "
  1147 + + " left join (select c.gsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl,"
  1148 + + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl,"
  1149 + + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl "
  1150 + + " from bsth_c_calc_count c where c.date like ? and c.date < ? and "
  1151 + + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) "
  1152 + + " group by c.gsdm ) y on x.gsdm=y.gsdm where 1=1 ";
  1153 + objList.add("%"+date+"%");
  1154 + objList.add(d);
  1155 + objList.add("%"+date+"%");
  1156 + objList.add(d);
  1157 +
  1158 + }else{
  1159 + sql ="select x.gsdm,x.fgsdm,x.smb_zdl,x.zgf_ccl,y.yylc_zxl,y.szfc_zdl,y.bc_zxl from ("
  1160 + + " select b.gsdm,b.fgsdm,round(avg(if(ifnull(b.sjcczgf/b.jhcczgf,0)>1,1,ifnull(b.sjcczgf/b.jhcczgf,0))),3) * 100 as zgf_ccl,"
  1161 + + " round(avg(ifnull(b.smbfczdl,0)),3) as smb_zdl from "
  1162 + + " bsth_c_calc_sheet b where b.date like ? and b.date < ? "
  1163 + + " and b.xl in(select a.line_code from bsth_c_line a where "
  1164 + + " a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) group by b.gsdm,b.fgsdm ) x "
  1165 + + " left join (select c.gsdm,c.fgsdm,round(avg(if(CONVERT(c.yylczxl,DECIMAL(9,2))>100,100,c.yylczxl)),3) as yylc_zxl,"
  1166 + + " round(avg(if(CONVERT(c.szfczdl,DECIMAL(9,2))>100,100,c.szfczdl)),3) as szfc_zdl,"
  1167 + + " round(avg(if(CONVERT(c.bczxl,DECIMAL(9,2))>100,100,c.bczxl)),3) as bc_zxl "
  1168 + + " from bsth_c_calc_count c where c.date like ? and c.date < ? and "
  1169 + + " c.xl in(select a.line_code from bsth_c_line a where a.nature in ('yxl','cgxl','gjxl','csbs','cctxl') ) "
  1170 + + " group by c.gsdm,c.fgsdm ) y on x.gsdm=y.gsdm and x.fgsdm=y.fgsdm where 1=1 ";
  1171 + objList.add("%"+date+"%");
  1172 + objList.add(d);
  1173 + objList.add("%"+date+"%");
  1174 + objList.add(d);
  1175 +
  1176 + }
  1177 + if(!gs.equals("all")){
  1178 + sql += " and x.gsdm = ?";
  1179 + objList.add(gs);
  1180 + }
  1181 +
  1182 + if(!fgs.equals("all")){
  1183 + sql += " and x.fgsdm = ?";
  1184 + objList.add(fgs);
  1185 + }
  1186 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  1187 + new RowMapper<Map<String, Object>>(){
  1188 + @Override
  1189 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1190 + Map<String, Object> m=new HashMap<String,Object>();
  1191 + m.put("gsdm", getGs(rs.getString("gsdm")));
  1192 + m.put("fgsdm",rs.getString("fgsdm"));
  1193 + m.put("smb_zdl", rs.getString("smb_zdl"));
  1194 + m.put("zgf_ccl", rs.getString("zgf_ccl"));
  1195 + m.put("yylc_zxl", rs.getString("yylc_zxl"));
  1196 + m.put("szfc_zdl", rs.getString("szfc_zdl"));
  1197 + m.put("bc_zxl", rs.getString("bc_zxl"));
  1198 + return m;
  1199 + }
  1200 + });
  1201 + return list;
  1202 + }
  1203 +
  1204 +
  1205 + /**
  1206 + *公司内部使用数据
  1207 + *
  1208 + *班次里程基础数据接口
  1209 + */
  1210 + @GET
  1211 + @Path("/basicData/starDate/{starDate}/endDate/{endDate}/line/{line}")
  1212 + public List<Map<String, Object>> basicData(@PathParam("starDate") String starDate,
  1213 + @PathParam("endDate") String endDate,@PathParam("line") String line) {
  1214 + List<String> objList = new ArrayList<String>();
  1215 + String sql="select gsdm,fgsdm,xl,xl_name,date,jhbc,sjbc,"
  1216 + + " jhyylc,sjyylc,jhkslc,sjkslc,jhgfbcsz,sjgfbcs,jhdgbcsz,"
  1217 + + " sjdgbcs from bsth_c_calc_count "
  1218 + + " where date >= ? and date <= ?";
  1219 + objList.add(starDate);
  1220 + objList.add(endDate);
  1221 + if(!line.equals("all")){
  1222 + sql +=" and xl = ?";
  1223 + objList.add(line);
  1224 + }
  1225 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  1226 + new RowMapper<Map<String, Object>>(){
  1227 + @Override
  1228 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1229 + Map<String, Object> m=new HashMap<String,Object>();
  1230 + m.put("gsdm",rs.getString("gsdm"));
  1231 + m.put("fgsdm",rs.getString("fgsdm"));
  1232 + m.put("lineCode",rs.getString("xl"));
  1233 + m.put("lineName", rs.getString("xl_name"));
  1234 + m.put("date", rs.getString("date"));
  1235 + m.put("jhbc", rs.getString("jhbc"));
  1236 + m.put("sjbc", rs.getString("sjbc"));
  1237 + m.put("jhyylc", rs.getString("jhyylc"));
  1238 + m.put("sjyylc", rs.getString("sjyylc"));
  1239 + m.put("jhkslc", rs.getString("jhkslc"));
  1240 + m.put("sjkslc", rs.getString("sjkslc"));
  1241 + m.put("jhgfbcs", rs.getString("jhgfbcsz"));
  1242 + m.put("sjgfbcs", rs.getString("sjgfbcs"));
  1243 + m.put("jhdgbcs", rs.getString("jhdgbcsz"));
  1244 + m.put("sjdgbcs", rs.getString("sjdgbcs"));
  1245 + return m;
  1246 + }
  1247 + });
  1248 + return list;
  1249 + }
  1250 +
  1251 + @GET
  1252 + @Path("/targetData/starDate/{starDate}/endDate/{endDate}/line/{line}")
  1253 + public List<Map<String, Object>> targetData(@PathParam("starDate") String starDate,
  1254 + @PathParam("endDate") String endDate,@PathParam("line") String line) {
  1255 + List<String> objList = new ArrayList<String>();
  1256 + String sql="select gsdm,fgsdm,date,xl,xl_name,szfczdl,smbfczdl,"
  1257 + + " round(if(ifnull(sjcczgf/jhcczgf,0)>1,1,ifnull(sjcczgf/jhcczgf,0)),3) * 100 as zgfccl , "
  1258 + + " round(if(ifnull(sjcc/jhcc,0)>1,1,ifnull(sjcc/jhcc,0)),3) * 100 as ccl from bsth_c_calc_sheet "
  1259 + + " where date >= ? and date <= ?";
  1260 + objList.add(starDate);
  1261 + objList.add(endDate);
  1262 + if(!line.equals("all")){
  1263 + sql +=" and xl = ?";
  1264 + objList.add(line);
  1265 + }
  1266 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  1267 + new RowMapper<Map<String, Object>>(){
  1268 + @Override
  1269 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1270 + Map<String, Object> m=new HashMap<String,Object>();
  1271 + m.put("gsdm",rs.getString("gsdm"));
  1272 + m.put("fgsdm",rs.getString("fgsdm"));
  1273 + m.put("lineCode",rs.getString("xl"));
  1274 + m.put("lineName", rs.getString("xl_name"));
  1275 + m.put("date", rs.getString("date"));
  1276 + m.put("szfczdl", rs.getString("szfczdl"));
  1277 + m.put("smbfczdl", rs.getString("smbfczdl"));
  1278 + m.put("zgfccl", rs.getString("zgfccl"));
  1279 + m.put("ccl", rs.getString("ccl"));
  1280 + return m;
  1281 + }
  1282 + });
  1283 + return list;
  1284 + }
  1285 +
  1286 + @GET
  1287 + @Path("/departureTime/starDate/{starDate}/endDate/{endDate}/line/{line}")
  1288 + public List<Map<String, Object>> departureTime(@PathParam("starDate") String starDate,
  1289 + @PathParam("endDate") String endDate,@PathParam("line") String line) {
  1290 + List<String> objList = new ArrayList<String>();
  1291 + String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz,"
  1292 + + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz,"
  1293 + + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz,"
  1294 + + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz,"
  1295 + + " jhszfcs,sjszfczds,szfczdl,"
  1296 + + " create_date from bsth_c_calc_count "
  1297 + + " where date >= ? and date <= ?";
  1298 + objList.add(starDate);
  1299 + objList.add(endDate);
  1300 + if(!line.equals("all")){
  1301 + sql +=" and xl = ?";
  1302 + objList.add(line);
  1303 + }
  1304 +
  1305 + List<Map<String, Object>> list=jdbcTemplate.query(sql, objList.toArray(),
  1306 + new RowMapper<Map<String, Object>>(){
  1307 + @Override
  1308 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1309 + Map<String, Object> m=new HashMap<String,Object>();
  1310 + m.put("lineCode",rs.getString("xl"));
  1311 + m.put("lineName", rs.getString("xl_name"));
  1312 + m.put("date", rs.getString("date"));
  1313 +
  1314 + m.put("jhbc", rs.getString("jhbc"));
  1315 + m.put("sjbc", rs.getString("sjbc"));
  1316 + m.put("bczxl", rs.getString("bczxl"));
  1317 + m.put("jhbcz", rs.getString("jhbcz"));
  1318 +
  1319 + m.put("jhcc", rs.getString("jhcc"));
  1320 + m.put("sjcc", rs.getString("sjcc"));
  1321 + m.put("ccl", rs.getString("ccl"));
  1322 + m.put("jhccz", rs.getString("jhccz"));
  1323 +
  1324 + m.put("jhyylc", rs.getString("jhyylc"));
  1325 + m.put("sjyylc", rs.getString("sjyylc"));
  1326 + m.put("jhyylcz", rs.getString("jhyylcz"));
  1327 + m.put("jhkslc", rs.getString("jhkslc"));
  1328 + m.put("sjkslc", rs.getString("sjkslc"));
  1329 + m.put("jhkslcz", rs.getString("jhkslcz"));
  1330 +
  1331 + m.put("jhgfbcs", rs.getString("jhssgfbcs"));
  1332 + m.put("sjgfbcs", rs.getString("sjgfbcs"));
  1333 + m.put("jhgfbcsz", rs.getString("jhgfbcsz"));
  1334 + m.put("jhdgbcs", rs.getString("jhssdgbcs"));
  1335 + m.put("sjdgbcs", rs.getString("sjdgbcs"));
  1336 + m.put("jhdgbcsz", rs.getString("jhdgbcsz"));
  1337 +
  1338 + m.put("jhsmbcs", rs.getString("jhsmbcs"));
  1339 + m.put("sjsmbczds", rs.getString("sjsmbczds"));
  1340 + m.put("smbczdl", rs.getString("smbczdl"));
  1341 + m.put("jhsmbcsz", rs.getString("jhsmbcsz"));
  1342 + m.put("sjsmbczdsz", rs.getString("sjsmbczdsz"));
  1343 + m.put("smbczdlz", rs.getString("smbczdlz"));
  1344 +
  1345 + m.put("jhszfcs", rs.getString("jhszfcs"));
  1346 + m.put("sjszfczds", rs.getString("sjszfczds"));
  1347 + m.put("szfczdl", rs.getString("szfczdl"));
  1348 +
  1349 + Date date = new Date();
  1350 + date.setTime(rs.getTimestamp("create_date").getTime());
  1351 + m.put("createDate", sdf.format(date));
  1352 + return m;
  1353 + }
  1354 + });
  1355 + return list;
  1356 + }
  1357 +
  1358 +}
src/main/java/com/bsth/server_rs/exception/AesException.java
1 -package com.bsth.server_rs.exception;  
2 -  
3 -/**  
4 - * Created by panzhao on 2017/3/28.  
5 - */  
6 -public class AesException extends RuntimeException {  
7 -  
8 - public final static int OK = 0;  
9 - public final static int MISS_SIGN = -30001;  
10 - public final static int MISS_TIMESTAMP = -30002;  
11 - public final static int MISS_NONCE = -30003;  
12 - public final static int NO_RANDOM_NONCE = -30005;  
13 - public final static int MISS_PWD = -30004;  
14 - public final static int SIGN_CHECK_ERROR = -40001;  
15 - public final static int SIGN_CHECK_FAIL = -40002;  
16 - public final static int INVALID_PWD = -40003;  
17 - public final static int INVALID_TIMESTAMP = -40004;  
18 -  
19 - private int code;  
20 -  
21 - private static String getMessage(int code) {  
22 - switch (code) {  
23 - case MISS_SIGN:  
24 - return "sign参数丢失";  
25 - case MISS_TIMESTAMP:  
26 - return "timestamp参数丢失";  
27 - case MISS_NONCE:  
28 - return "nonce参数丢失";  
29 - case NO_RANDOM_NONCE:  
30 - return "nonce参数异常";  
31 - case MISS_PWD:  
32 - return "密码参数丢失";  
33 - case INVALID_PWD:  
34 - return "无效的密码";  
35 - case SIGN_CHECK_ERROR:  
36 - return "签名校验时出现异常";  
37 - case SIGN_CHECK_FAIL:  
38 - return "无效的签名";  
39 - case INVALID_TIMESTAMP:  
40 - return "无效的时间戳";  
41 - default:  
42 - return null;  
43 - }  
44 - }  
45 -  
46 - public int getCode() {  
47 - return code;  
48 - }  
49 -  
50 - public AesException(int code) {  
51 - super(getMessage(code));  
52 - this.code = code;  
53 - }  
54 -} 1 +package com.bsth.server_rs.exception;
  2 +
  3 +/**
  4 + * Created by panzhao on 2017/3/28.
  5 + */
  6 +public class AesException extends RuntimeException {
  7 +
  8 + public final static int OK = 0;
  9 + public final static int MISS_SIGN = -30001;
  10 + public final static int MISS_TIMESTAMP = -30002;
  11 + public final static int MISS_NONCE = -30003;
  12 + public final static int NO_RANDOM_NONCE = -30005;
  13 + public final static int MISS_PWD = -30004;
  14 + public final static int SIGN_CHECK_ERROR = -40001;
  15 + public final static int SIGN_CHECK_FAIL = -40002;
  16 + public final static int INVALID_PWD = -40003;
  17 + public final static int INVALID_TIMESTAMP = -40004;
  18 + public final static int INVALID_URI = -40005;
  19 +
  20 + private int code;
  21 +
  22 + private static String getMessage(int code) {
  23 + switch (code) {
  24 + case MISS_SIGN:
  25 + return "sign参数丢失";
  26 + case MISS_TIMESTAMP:
  27 + return "timestamp参数丢失";
  28 + case MISS_NONCE:
  29 + return "nonce参数丢失";
  30 + case NO_RANDOM_NONCE:
  31 + return "nonce参数异常";
  32 + case MISS_PWD:
  33 + return "密码参数丢失";
  34 + case INVALID_PWD:
  35 + return "无效的密码";
  36 + case SIGN_CHECK_ERROR:
  37 + return "签名校验时出现异常";
  38 + case SIGN_CHECK_FAIL:
  39 + return "无效的签名";
  40 + case INVALID_TIMESTAMP:
  41 + return "无效的时间戳";
  42 + case INVALID_URI:
  43 + return "无效的URI";
  44 + default:
  45 + return null;
  46 + }
  47 + }
  48 +
  49 + public int getCode() {
  50 + return code;
  51 + }
  52 +
  53 + public AesException(int code) {
  54 + super(getMessage(code));
  55 + this.code = code;
  56 + }
  57 +}
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataBuffer.java
1 -package com.bsth.server_rs.gps.buffer;  
2 -  
3 -import java.util.HashMap;  
4 -import java.util.Map;  
5 -import java.util.Set;  
6 -  
7 -import org.springframework.stereotype.Component;  
8 -  
9 -import com.bsth.server_rs.gps.entity.LineInfo;  
10 -  
11 -/**  
12 - * Created by panzhao on 2017/3/30.  
13 - */  
14 -@Component  
15 -public class BasicDataBuffer {  
16 -  
17 - private static Map<Integer, LineInfo> LINEID_INFO = new HashMap<Integer, LineInfo>();  
18 -  
19 - private static Map<String, String> DEVICE_PLATE = new HashMap<String, String>();  
20 -  
21 - public static void putLine(Integer lineId, LineInfo info) {  
22 - LINEID_INFO.put(lineId, info);  
23 - }  
24 -  
25 - public static void putCar(String deviceId, String plateNo) {  
26 - DEVICE_PLATE.put(deviceId, plateNo);  
27 - }  
28 -  
29 - public static String getPlateByDevice(String deviceId) {  
30 - return DEVICE_PLATE.get(deviceId);  
31 - }  
32 -  
33 - public static Set<Integer> getAllLine() {  
34 - return LINEID_INFO.keySet();  
35 - }  
36 -  
37 - public static LineInfo getLineById(Integer lineId) {  
38 - return LINEID_INFO.get(lineId);  
39 - }  
40 -} 1 +package com.bsth.server_rs.gps.buffer;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +import java.util.Set;
  6 +
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import com.bsth.server_rs.gps.entity.LineInfo;
  10 +
  11 +/**
  12 + * Created by panzhao on 2017/3/30.
  13 + */
  14 +@Component
  15 +public class BasicDataBuffer {
  16 +
  17 + private static Map<Integer, LineInfo> LINEID_INFO = new HashMap<Integer, LineInfo>();
  18 +
  19 + private static Map<String, String> DEVICE_PLATE = new HashMap<String, String>();
  20 +
  21 + private static Map<String, String> BCODE_NAME = new HashMap<>();
  22 +
  23 + public static void putLine(Integer lineId, LineInfo info) {
  24 + LINEID_INFO.put(lineId, info);
  25 + }
  26 +
  27 + public static void putCar(String deviceId, String plateNo) {
  28 + DEVICE_PLATE.put(deviceId, plateNo);
  29 + }
  30 +
  31 + public static String getPlateByDevice(String deviceId) {
  32 + return DEVICE_PLATE.get(deviceId);
  33 + }
  34 +
  35 + public static Set<Integer> getAllLine() {
  36 + return LINEID_INFO.keySet();
  37 + }
  38 +
  39 + public static LineInfo getLineById(Integer lineId) {
  40 + return LINEID_INFO.get(lineId);
  41 + }
  42 +
  43 + public static void putBusiness(String code, String name) {
  44 + BCODE_NAME.put(code, name);
  45 + }
  46 +
  47 + public static String getBusinessByCode(String code) {
  48 + return BCODE_NAME.get(code);
  49 + }
  50 +}
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataRefreshThread.java
1 -package com.bsth.server_rs.gps.buffer;  
2 -  
3 -import java.sql.ResultSet;  
4 -import java.sql.SQLException;  
5 -import java.util.ArrayList;  
6 -import java.util.List;  
7 -import java.util.Map;  
8 -  
9 -import org.slf4j.Logger;  
10 -import org.slf4j.LoggerFactory;  
11 -import org.springframework.beans.factory.InitializingBean;  
12 -import org.springframework.beans.factory.annotation.Autowired;  
13 -import org.springframework.jdbc.core.JdbcTemplate;  
14 -import org.springframework.jdbc.core.RowMapper;  
15 -import org.springframework.stereotype.Component;  
16 -  
17 -import com.bsth.server_rs.gps.entity.LineInfo;  
18 -import com.bsth.server_rs.gps.entity.Point;  
19 -import com.bsth.server_rs.gps.entity.StopInfo;  
20 -  
21 -/**  
22 - * Created by panzhao on 2017/3/30.  
23 - */  
24 -@Component  
25 -public class BasicDataRefreshThread extends Thread implements InitializingBean {  
26 -  
27 - Logger logger = LoggerFactory.getLogger(this.getClass());  
28 -  
29 - @Autowired  
30 - private JdbcTemplate jdbcTemplate;  
31 -  
32 - @Override  
33 - public void run() {  
34 - loadBasicData();  
35 - }  
36 -  
37 - private void loadBasicData() {  
38 - try {  
39 - String qline = "select a.id,in_use,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,shanghai_linecode,line_play_type,up_travel_time,down_travel_time from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0 and a.nature = 'hlwgj'";  
40 - String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code";  
41 - String qcar = "select equipment_code device_id, car_plate plate_no from bsth_c_cars";  
42 -  
43 - List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo());  
44 - List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo());  
45 - List<Map<String, Object>> cars = jdbcTemplate.queryForList(qcar);  
46 -  
47 - // 缓存线路基本信息  
48 - for (LineInfo line : lines) {  
49 - BasicDataBuffer.putLine(line.getLineId(), line);  
50 - }  
51 -  
52 - // 线路信息中添加上下行站点信息  
53 - int oldId = -1;  
54 - LineInfo line = null;  
55 - for (StopInfo stop : stops) {  
56 - if (stop.getLineCode() != oldId) {  
57 - oldId = stop.getLineCode();  
58 - line = BasicDataBuffer.getLineById(oldId);  
59 - }  
60 - if (line != null) {  
61 - if (stop.getDirections() == 0) line.getStopsUp().add(stop);  
62 - else line.getStopsDown().add(stop);  
63 - }  
64 - }  
65 -  
66 - for (Map<String, Object> car : cars) {  
67 - BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no"));  
68 - }  
69 -  
70 - logger.info("基础数据加载成功");  
71 - }catch (Exception e){  
72 - logger.error("基础数据加载失败", e);  
73 - }  
74 - }  
75 -  
76 - final class RowMapperLineInfo implements RowMapper<LineInfo> {  
77 -  
78 - @Override  
79 - public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException {  
80 - // TODO Auto-generated method stub  
81 - LineInfo line = new LineInfo();  
82 - line.setId(rs.getInt("id"));  
83 - line.setInUse(rs.getInt("in_use"));  
84 - line.setLineId(rs.getInt("line_code"));  
85 - line.setLineName(rs.getString("name"));  
86 - //line.setStartStation(rs.getInt("start_station"));  
87 - line.setStartStationName(rs.getString("start_station_name"));  
88 - line.setStartStationFirstTime(rs.getString("start_station_first_time"));  
89 - line.setStartStationEndTime(rs.getString("start_station_end_time"));  
90 - //line.setEndStation(rs.getInt("end_station"));  
91 - line.setEndStationName(rs.getString("end_station_name"));  
92 - line.setEndStationFirstTime(rs.getString("end_station_first_time"));  
93 - line.setEndStationEndTime(rs.getString("end_station_end_time"));  
94 - line.setCompany(rs.getString("company"));  
95 - line.setBrancheCompany(rs.getString("branche_company"));  
96 - line.setTelephone(rs.getString("telephone"));  
97 - line.setLinePlayType(rs.getInt("line_play_type"));  
98 - return line;  
99 - }  
100 -  
101 - }  
102 -  
103 - final class RowMapperStopInfo implements RowMapper<StopInfo> {  
104 -  
105 - @Override  
106 - public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException {  
107 - // TODO Auto-generated method stub  
108 - StopInfo stop = new StopInfo();  
109 - stop.setId(rs.getInt("id"));  
110 - stop.setStationCod(rs.getString("station_cod"));  
111 - stop.setStationName(rs.getString("station_name"));  
112 - //stop.setStationType(rs.getString("station_type"));  
113 - stop.setRoadCoding(rs.getString("road_coding"));  
114 - float lon = rs.getFloat("g_lonx");  
115 - float lat = rs.getFloat("g_laty");  
116 - stop.setPoint(new Point(lon, lat));  
117 - stop.setLineId(rs.getInt("line"));  
118 - stop.setLineCode(rs.getInt("line_code"));  
119 - stop.setDirections(rs.getInt("directions"));  
120 - stop.setShapesType(rs.getString("shapes_type"));  
121 - stop.setRadius(rs.getInt("radius"));  
122 - stop.setPoints(new ArrayList<Point>());  
123 - stop.setDistances(rs.getDouble("distances")*1000);  
124 - return stop;  
125 - }  
126 -  
127 - }  
128 -  
129 - @Override  
130 - public void afterPropertiesSet() throws Exception {  
131 - // TODO Auto-generated method stub  
132 - loadBasicData();  
133 - }  
134 -} 1 +package com.bsth.server_rs.gps.buffer;
  2 +
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.util.ArrayList;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.InitializingBean;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.jdbc.core.JdbcTemplate;
  14 +import org.springframework.jdbc.core.RowMapper;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import com.bsth.server_rs.gps.entity.LineInfo;
  18 +import com.bsth.server_rs.gps.entity.Point;
  19 +import com.bsth.server_rs.gps.entity.StopInfo;
  20 +
  21 +/**
  22 + * Created by panzhao on 2017/3/30.
  23 + */
  24 +@Component
  25 +public class BasicDataRefreshThread extends Thread implements InitializingBean {
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
  28 +
  29 + @Autowired
  30 + private JdbcTemplate jdbcTemplate;
  31 +
  32 + @Override
  33 + public void run() {
  34 + loadBasicData();
  35 + }
  36 +
  37 + private void loadBasicData() {
  38 + try {
  39 + String qline = "select a.id,in_use,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,shanghai_linecode,line_play_type,up_travel_time,down_travel_time from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0 and a.nature = 'hlwgj'";
  40 + String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code";
  41 + String qcar = "select equipment_code device_id, car_plate plate_no from bsth_c_cars";
  42 + String qbusiness = "select business_code, up_code, business_name from bsth_c_business where up_code <> 0";
  43 +
  44 + List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo());
  45 + List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo());
  46 + List<Map<String, Object>> cars = jdbcTemplate.queryForList(qcar);
  47 + List<Map<String, Object>> businesses = jdbcTemplate.queryForList(qbusiness);
  48 +
  49 + // 缓存线路基本信息
  50 + for (LineInfo line : lines) {
  51 + BasicDataBuffer.putLine(line.getLineId(), line);
  52 + }
  53 +
  54 + // 线路信息中添加上下行站点信息
  55 + int oldId = -1;
  56 + LineInfo line = null;
  57 + for (StopInfo stop : stops) {
  58 + if (stop.getLineCode() != oldId) {
  59 + oldId = stop.getLineCode();
  60 + line = BasicDataBuffer.getLineById(oldId);
  61 + }
  62 + if (line != null) {
  63 + if (stop.getDirections() == 0) line.getStopsUp().add(stop);
  64 + else line.getStopsDown().add(stop);
  65 + }
  66 + }
  67 +
  68 + for (Map<String, Object> car : cars) {
  69 + BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no"));
  70 + }
  71 +
  72 + for (Map<String, Object> business : businesses) {
  73 + String businessCode = (String)business.get("business_code"), upCode = (String)business.get("up_code"), businessName = (String)business.get("business_name");
  74 + if ("88".equals(upCode)) {
  75 + BasicDataBuffer.putBusiness(businessCode, businessName);
  76 + } else {
  77 + BasicDataBuffer.putBusiness(String.format("%s_%s", upCode, businessCode), businessName);
  78 + }
  79 + }
  80 +
  81 + logger.info("基础数据加载成功");
  82 + }catch (Exception e){
  83 + logger.error("基础数据加载失败", e);
  84 + }
  85 + }
  86 +
  87 + final class RowMapperLineInfo implements RowMapper<LineInfo> {
  88 +
  89 + @Override
  90 + public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  91 + // TODO Auto-generated method stub
  92 + LineInfo line = new LineInfo();
  93 + line.setId(rs.getInt("id"));
  94 + line.setInUse(rs.getInt("in_use"));
  95 + line.setLineId(rs.getInt("line_code"));
  96 + line.setLineName(rs.getString("name"));
  97 + //line.setStartStation(rs.getInt("start_station"));
  98 + line.setStartStationName(rs.getString("start_station_name"));
  99 + line.setStartStationFirstTime(rs.getString("start_station_first_time"));
  100 + line.setStartStationEndTime(rs.getString("start_station_end_time"));
  101 + //line.setEndStation(rs.getInt("end_station"));
  102 + line.setEndStationName(rs.getString("end_station_name"));
  103 + line.setEndStationFirstTime(rs.getString("end_station_first_time"));
  104 + line.setEndStationEndTime(rs.getString("end_station_end_time"));
  105 + line.setCompany(rs.getString("company"));
  106 + line.setBrancheCompany(rs.getString("branche_company"));
  107 + line.setTelephone(rs.getString("telephone"));
  108 + line.setLinePlayType(rs.getInt("line_play_type"));
  109 + return line;
  110 + }
  111 +
  112 + }
  113 +
  114 + final class RowMapperStopInfo implements RowMapper<StopInfo> {
  115 +
  116 + @Override
  117 + public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  118 + // TODO Auto-generated method stub
  119 + StopInfo stop = new StopInfo();
  120 + stop.setId(rs.getInt("id"));
  121 + stop.setStationCod(rs.getString("station_cod"));
  122 + stop.setStationName(rs.getString("station_name"));
  123 + //stop.setStationType(rs.getString("station_type"));
  124 + stop.setRoadCoding(rs.getString("road_coding"));
  125 + float lon = rs.getFloat("g_lonx");
  126 + float lat = rs.getFloat("g_laty");
  127 + stop.setPoint(new Point(lon, lat));
  128 + stop.setLineId(rs.getInt("line"));
  129 + stop.setLineCode(rs.getInt("line_code"));
  130 + stop.setDirections(rs.getInt("directions"));
  131 + stop.setShapesType(rs.getString("shapes_type"));
  132 + stop.setRadius(rs.getInt("radius"));
  133 + stop.setPoints(new ArrayList<Point>());
  134 + stop.setDistances(rs.getDouble("distances")*1000);
  135 + return stop;
  136 + }
  137 +
  138 + }
  139 +
  140 + @Override
  141 + public void afterPropertiesSet() throws Exception {
  142 + // TODO Auto-generated method stub
  143 + loadBasicData();
  144 + }
  145 +}
src/main/java/com/bsth/server_rs/gps/buffer/GpsRealDataBuffer.java
1 -package com.bsth.server_rs.gps.buffer;  
2 -  
3 -import com.bsth.server_rs.gps.entity.GpsEntity;  
4 -import org.springframework.beans.factory.annotation.Autowired;  
5 -import org.springframework.stereotype.Component;  
6 -  
7 -import java.util.Collection;  
8 -import java.util.HashMap;  
9 -import java.util.Map;  
10 -  
11 -/**  
12 - * Created by panzhao on 2017/3/30.  
13 - */  
14 -@Component  
15 -public class GpsRealDataBuffer {  
16 -  
17 - private static Map<String, GpsEntity> realMap;  
18 -  
19 - @Autowired  
20 - GpsRefreshThread gpsRefreshThread;  
21 -  
22 - static{  
23 - realMap = new HashMap<>();  
24 - }  
25 -  
26 - public static void put(GpsEntity gps){  
27 - realMap.put(gps.getDeviceId(), gps);  
28 - }  
29 -  
30 - public static GpsEntity get(String device){  
31 - return realMap.get(device);  
32 - }  
33 -  
34 - public static Collection<GpsEntity> all(){  
35 - return realMap.values();  
36 - }  
37 -} 1 +package com.bsth.server_rs.gps.buffer;
  2 +
  3 +import com.bsth.server_rs.gps.entity.GpsEntity;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.stereotype.Component;
  6 +
  7 +import java.util.Collection;
  8 +import java.util.HashMap;
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * Created by panzhao on 2017/3/30.
  13 + */
  14 +@Component
  15 +public class GpsRealDataBuffer {
  16 +
  17 + private static Map<String, GpsEntity> realMap = new HashMap<>();
  18 +
  19 + private static Map<String, String> device2line = new HashMap<>();
  20 +
  21 + @Autowired
  22 + GpsRefreshThread gpsRefreshThread;
  23 +
  24 + public static void put(GpsEntity gps){
  25 + realMap.put(gps.getDeviceId(), gps);
  26 + }
  27 +
  28 + public static GpsEntity get(String device){
  29 + return realMap.get(device);
  30 + }
  31 +
  32 + public static Collection<GpsEntity> all(){
  33 + return realMap.values();
  34 + }
  35 +
  36 + public static void putLineCode(String device, String lineCode){
  37 + device2line.put(device, lineCode);
  38 + }
  39 +
  40 + public static String getLineCodeByDevice(String device){
  41 + return device2line.get(device);
  42 + }
  43 +
  44 + public static Map<String, String> getDevice2Line(){
  45 + return device2line;
  46 + }
  47 +}
src/main/java/com/bsth/server_rs/gps/buffer/GpsRefreshThread.java
1 -package com.bsth.server_rs.gps.buffer;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONObject;  
5 -import com.bsth.server_rs.gps.entity.GpsEntity;  
6 -import com.bsth.util.ConfigUtil;  
7 -import org.apache.http.HttpEntity;  
8 -import org.apache.http.client.config.RequestConfig;  
9 -import org.apache.http.client.methods.CloseableHttpResponse;  
10 -import org.apache.http.client.methods.HttpGet;  
11 -import org.apache.http.impl.client.CloseableHttpClient;  
12 -import org.apache.http.impl.client.HttpClients;  
13 -import org.slf4j.Logger;  
14 -import org.slf4j.LoggerFactory;  
15 -import org.springframework.stereotype.Component;  
16 -  
17 -import java.io.BufferedReader;  
18 -import java.io.InputStreamReader;  
19 -import java.util.List;  
20 -  
21 -/**  
22 - * Created by panzhao on 2017/3/30.  
23 - */  
24 -@Component  
25 -public class GpsRefreshThread extends Thread{  
26 -  
27 - static String url;  
28 -  
29 - static {  
30 - url = ConfigUtil.get("http.gps.real.url");  
31 - }  
32 -  
33 - Logger logger = LoggerFactory.getLogger(this.getClass());  
34 -  
35 - @Override  
36 - public void run() {  
37 - try {  
38 - CloseableHttpClient httpClient = null;  
39 - List<GpsEntity> rs = null;  
40 - httpClient = HttpClients.createDefault();  
41 - //超时时间  
42 - RequestConfig requestConfig = RequestConfig.custom()  
43 - .setConnectTimeout(2000).setConnectionRequestTimeout(1000)  
44 - .setSocketTimeout(3000).build();  
45 -  
46 - HttpGet get = new HttpGet(url);  
47 - get.setConfig(requestConfig);  
48 -  
49 - CloseableHttpResponse response = httpClient.execute(get);  
50 -  
51 - HttpEntity entity = response.getEntity();  
52 - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));  
53 - StringBuffer stringBuffer = new StringBuffer();  
54 - String str = "";  
55 - while ((str = br.readLine()) != null)  
56 - stringBuffer.append(str);  
57 -  
58 - JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());  
59 -  
60 - if (jsonObj != null)  
61 - rs = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);  
62 -  
63 - for(GpsEntity gps : rs){  
64 - GpsRealDataBuffer.put(gps);  
65 - }  
66 - }catch (Exception e){  
67 - logger.error("", e);  
68 - }  
69 - }  
70 -} 1 +package com.bsth.server_rs.gps.buffer;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.server_rs.gps.entity.GpsEntity;
  6 +import com.bsth.util.ConfigUtil;
  7 +import org.apache.http.HttpEntity;
  8 +import org.apache.http.client.config.RequestConfig;
  9 +import org.apache.http.client.methods.CloseableHttpResponse;
  10 +import org.apache.http.client.methods.HttpGet;
  11 +import org.apache.http.impl.client.CloseableHttpClient;
  12 +import org.apache.http.impl.client.HttpClients;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import java.io.BufferedReader;
  18 +import java.io.InputStreamReader;
  19 +import java.util.List;
  20 +
  21 +/**
  22 + * Created by panzhao on 2017/3/30.
  23 + */
  24 +@Component
  25 +public class GpsRefreshThread extends Thread{
  26 +
  27 + static String url;
  28 +
  29 + static {
  30 + url = ConfigUtil.get("http.gps.real.url");
  31 + }
  32 +
  33 + Logger logger = LoggerFactory.getLogger(this.getClass());
  34 +
  35 + @Override
  36 + public void run() {
  37 + try {
  38 + CloseableHttpClient httpClient = null;
  39 + List<GpsEntity> rs = null;
  40 + httpClient = HttpClients.createDefault();
  41 + //超时时间
  42 + RequestConfig requestConfig = RequestConfig.custom()
  43 + .setConnectTimeout(2000).setConnectionRequestTimeout(1000)
  44 + .setSocketTimeout(3000).build();
  45 +
  46 + HttpGet get = new HttpGet(url);
  47 + get.setConfig(requestConfig);
  48 +
  49 + CloseableHttpResponse response = httpClient.execute(get);
  50 +
  51 + HttpEntity entity = response.getEntity();
  52 + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
  53 + StringBuffer stringBuffer = new StringBuffer();
  54 + String str = "";
  55 + while ((str = br.readLine()) != null)
  56 + stringBuffer.append(str);
  57 +
  58 + JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
  59 +
  60 + if (jsonObj != null)
  61 + rs = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
  62 +
  63 + for(GpsEntity gps : rs){
  64 + GpsRealDataBuffer.put(gps);
  65 + GpsRealDataBuffer.putLineCode(gps.getDeviceId(), gps.getLineId());
  66 + }
  67 + }catch (Exception e){
  68 + logger.error("", e);
  69 + }
  70 + }
  71 +}
src/main/resources/application-prod.properties
@@ -8,7 +8,7 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy @@ -8,7 +8,7 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
8 spring.jpa.database= MYSQL 8 spring.jpa.database= MYSQL
9 spring.jpa.show-sql= false 9 spring.jpa.show-sql= false
10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver 10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11 -spring.datasource.url= jdbc:mysql://192.168.160.222:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false 11 +spring.datasource.url= jdbc:mysql://172.16.10.110/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 spring.datasource.username= root 12 spring.datasource.username= root
13 spring.datasource.password= root2jsp 13 spring.datasource.password= root2jsp
14 #DATASOURCE 14 #DATASOURCE
@@ -29,7 +29,7 @@ spring.redis.host=127.0.0.1 @@ -29,7 +29,7 @@ spring.redis.host=127.0.0.1
29 spring.redis.password=bsth_control_001 29 spring.redis.password=bsth_control_001
30 spring.redis.port=28008 30 spring.redis.port=28008
31 31
32 -http.control.service_data_url= http://192.168.160.152:17818/companyService 32 +http.control.service_data_url= http://172.16.10.123:17818/companyService
33 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki 33 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki
34 34
35 -http.gps.real.url= http://192.168.160.151:8080/transport_server/rtgps/  
36 \ No newline at end of file 35 \ No newline at end of file
  36 +http.gps.real.url= http://172.16.10.81:8080/transport_server/rtgps/
37 \ No newline at end of file 37 \ No newline at end of file
src/main/resources/application.properties
1 -spring.profiles: dev,prod  
2 -spring.profiles.active: prod  
3 -  
4 -spring.view.suffix=.html  
5 -server.session-timeout=-1  
6 -security.basic.enabled=false  
7 -  
8 -# \u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u9650\u5236\u914D\u7F6E  
9 -# File size limit  
10 -multipart.maxFileSize = -1  
11 -# Total request size for a multipart/form-data  
12 -multipart.maxRequestSize = -1  
13 -  
14 -server.compression.enabled=true  
15 -server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript  
16 -  
17 -#redis  
18 -cache.days=15 1 +spring.profiles: dev,prod
  2 +spring.profiles.active: prod
  3 +
  4 +spring.view.suffix=.html
  5 +server.session-timeout=-1
  6 +security.basic.enabled=false
  7 +
  8 +# \u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u9650\u5236\u914D\u7F6E
  9 +# File size limit
  10 +multipart.maxFileSize = -1
  11 +# Total request size for a multipart/form-data
  12 +multipart.maxRequestSize = -1
  13 +
  14 +server.compression.enabled=true
  15 +server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript
  16 +
  17 +#redis
  18 +cache.days=15
  19 +
  20 +#limits
  21 +path.limits=limits/
src/main/resources/static/assets/js/template.js deleted 100644 → 0
1 -/*!art-template - Template Engine | http://aui.github.com/artTemplate/*/  
2 -!function(){function a(a){return a.replace(t,"").replace(u,",").replace(v,"").replace(w,"").replace(x,"").split(y)}function b(a){return"'"+a.replace(/('|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+"'"}function c(c,d){function e(a){return m+=a.split(/\n/).length-1,k&&(a=a.replace(/\s+/g," ").replace(/<!--[\w\W]*?-->/g,"")),a&&(a=s[1]+b(a)+s[2]+"\n"),a}function f(b){var c=m;if(j?b=j(b,d):g&&(b=b.replace(/\n/g,function(){return m++,"$line="+m+";"})),0===b.indexOf("=")){var e=l&&!/^=[=#]/.test(b);if(b=b.replace(/^=[=#]?|[\s;]*$/g,""),e){var f=b.replace(/\s*\([^\)]+\)/,"");n[f]||/^(include|print)$/.test(f)||(b="$escape("+b+")")}else b="$string("+b+")";b=s[1]+b+s[2]}return g&&(b="$line="+c+";"+b),r(a(b),function(a){if(a&&!p[a]){var b;b="print"===a?u:"include"===a?v:n[a]?"$utils."+a:o[a]?"$helpers."+a:"$data."+a,w+=a+"="+b+",",p[a]=!0}}),b+"\n"}var g=d.debug,h=d.openTag,i=d.closeTag,j=d.parser,k=d.compress,l=d.escape,m=1,p={$data:1,$filename:1,$utils:1,$helpers:1,$out:1,$line:1},q="".trim,s=q?["$out='';","$out+=",";","$out"]:["$out=[];","$out.push(",");","$out.join('')"],t=q?"$out+=text;return $out;":"$out.push(text);",u="function(){var text=''.concat.apply('',arguments);"+t+"}",v="function(filename,data){data=data||$data;var text=$utils.$include(filename,data,$filename);"+t+"}",w="'use strict';var $utils=this,$helpers=$utils.$helpers,"+(g?"$line=0,":""),x=s[0],y="return new String("+s[3]+");";r(c.split(h),function(a){a=a.split(i);var b=a[0],c=a[1];1===a.length?x+=e(b):(x+=f(b),c&&(x+=e(c)))});var z=w+x+y;g&&(z="try{"+z+"}catch(e){throw {filename:$filename,name:'Render Error',message:e.message,line:$line,source:"+b(c)+".split(/\\n/)[$line-1].replace(/^\\s+/,'')};}");try{var A=new Function("$data","$filename",z);return A.prototype=n,A}catch(B){throw B.temp="function anonymous($data,$filename) {"+z+"}",B}}var d=function(a,b){return"string"==typeof b?q(b,{filename:a}):g(a,b)};d.version="3.0.0",d.config=function(a,b){e[a]=b};var e=d.defaults={openTag:"<%",closeTag:"%>",escape:!0,cache:!0,compress:!1,parser:null},f=d.cache={};d.render=function(a,b){return q(a,b)};var g=d.renderFile=function(a,b){var c=d.get(a)||p({filename:a,name:"Render Error",message:"Template not found"});return b?c(b):c};d.get=function(a){var b;if(f[a])b=f[a];else if("object"==typeof document){var c=document.getElementById(a);if(c){var d=(c.value||c.innerHTML).replace(/^\s*|\s*$/g,"");b=q(d,{filename:a})}}return b};var h=function(a,b){return"string"!=typeof a&&(b=typeof a,"number"===b?a+="":a="function"===b?h(a.call(a)):""),a},i={"<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","&":"&#38;"},j=function(a){return i[a]},k=function(a){return h(a).replace(/&(?![\w#]+;)|[<>"']/g,j)},l=Array.isArray||function(a){return"[object Array]"==={}.toString.call(a)},m=function(a,b){var c,d;if(l(a))for(c=0,d=a.length;d>c;c++)b.call(a,a[c],c,a);else for(c in a)b.call(a,a[c],c)},n=d.utils={$helpers:{},$include:g,$string:h,$escape:k,$each:m};d.helper=function(a,b){o[a]=b};var o=d.helpers=n.$helpers;d.onerror=function(a){var b="Template Error\n\n";for(var c in a)b+="<"+c+">\n"+a[c]+"\n\n";"object"==typeof console&&console.error(b)};var p=function(a){return d.onerror(a),function(){return"{Template Error}"}},q=d.compile=function(a,b){function d(c){try{return new i(c,h)+""}catch(d){return b.debug?p(d)():(b.debug=!0,q(a,b)(c))}}b=b||{};for(var g in e)void 0===b[g]&&(b[g]=e[g]);var h=b.filename;try{var i=c(a,b)}catch(j){return j.filename=h||"anonymous",j.name="Syntax Error",p(j)}return d.prototype=i.prototype,d.toString=function(){return i.toString()},h&&b.cache&&(f[h]=d),d},r=n.$each,s="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,undefined",t=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|\s*\.\s*[$\w\.]+/g,u=/[^\w$]+/g,v=new RegExp(["\\b"+s.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),w=/^\d[^,]*|,\d[^,]*/g,x=/^,+|,+$/g,y=/^$|,+/;e.openTag="{{",e.closeTag="}}";var z=function(a,b){var c=b.split(":"),d=c.shift(),e=c.join(":")||"";return e&&(e=", "+e),"$helpers."+d+"("+a+e+")"};e.parser=function(a){a=a.replace(/^\s/,"");var b=a.split(" "),c=b.shift(),e=b.join(" ");switch(c){case"if":a="if("+e+"){";break;case"else":b="if"===b.shift()?" if("+b.join(" ")+")":"",a="}else"+b+"{";break;case"/if":a="}";break;case"each":var f=b[0]||"$data",g=b[1]||"as",h=b[2]||"$value",i=b[3]||"$index",j=h+","+i;"as"!==g&&(f="[]"),a="$each("+f+",function("+j+"){";break;case"/each":a="});";break;case"echo":a="print("+e+");";break;case"print":case"include":a=c+"("+b.join(",")+");";break;default:if(/^\s*\|\s*[\w\$]/.test(e)){var k=!0;0===a.indexOf("#")&&(a=a.substr(1),k=!1);for(var l=0,m=a.split("|"),n=m.length,o=m[l++];n>l;l++)o=z(o,m[l]);a=(k?"=":"=#")+o}else a=d.helpers[c]?"=#"+c+"("+b.join(",")+");":"="+a}return a},"function"==typeof define?define(function(){return d}):"undefined"!=typeof exports?module.exports=d:this.template=d}();  
3 \ No newline at end of file 0 \ No newline at end of file
src/main/resources/static/bootstrap-switch/css/bootstrap3/bootstrap-switch.css deleted 100644 → 0
1 -/**  
2 - * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.  
3 - *  
4 - * @version v3.3.4  
5 - * @homepage https://bttstrp.github.io/bootstrap-switch  
6 - * @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)  
7 - * @license Apache-2.0  
8 - */  
9 -.bootstrap-switch {  
10 - display: inline-block;  
11 - direction: ltr;  
12 - cursor: pointer;  
13 - border-radius: 4px;  
14 - border: 1px solid;  
15 - border-color: #ccc;  
16 - position: relative;  
17 - text-align: left;  
18 - overflow: hidden;  
19 - line-height: 8px;  
20 - z-index: 0;  
21 - -webkit-user-select: none;  
22 - -moz-user-select: none;  
23 - -ms-user-select: none;  
24 - user-select: none;  
25 - vertical-align: middle;  
26 - -webkit-transition: border-color ease-in-out .15s, box-shadow  
27 - ease-in-out .15s;  
28 - -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out  
29 - .15s;  
30 - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;  
31 -}  
32 -  
33 -.bootstrap-switch .bootstrap-switch-container {  
34 - display: inline-block;  
35 - top: 0;  
36 - border-radius: 4px;  
37 - -webkit-transform: translate3d(0, 0, 0);  
38 - transform: translate3d(0, 0, 0);  
39 -}  
40 -  
41 -.bootstrap-switch .bootstrap-switch-handle-on, .bootstrap-switch .bootstrap-switch-handle-off,  
42 - .bootstrap-switch .bootstrap-switch-label {  
43 - -webkit-box-sizing: border-box;  
44 - -moz-box-sizing: border-box;  
45 - box-sizing: border-box;  
46 - cursor: pointer;  
47 - display: table-cell;  
48 - vertical-align: middle;  
49 - padding: 6px 12px;  
50 - font-size: 14px;  
51 - line-height: 20px;  
52 -}  
53 -  
54 -.bootstrap-switch .bootstrap-switch-handle-on, .bootstrap-switch .bootstrap-switch-handle-off  
55 - {  
56 - text-align: center;  
57 - z-index: 1;  
58 -}  
59 -  
60 -.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary,  
61 - .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary  
62 - {  
63 - color: #fff;  
64 - background: #337ab7;  
65 -}  
66 -  
67 -.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info,  
68 - .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info {  
69 - color: #fff;  
70 - background: #5bc0de;  
71 -}  
72 -  
73 -.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success,  
74 - .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success  
75 - {  
76 - color: #fff;  
77 - background: #5cb85c;  
78 -}  
79 -  
80 -.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning,  
81 - .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning  
82 - {  
83 - background: #f0ad4e;  
84 - color: #fff;  
85 -}  
86 -  
87 -.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger,  
88 - .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger  
89 - {  
90 - color: #fff;  
91 - background: #d9534f;  
92 -}  
93 -  
94 -.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default,  
95 - .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default  
96 - {  
97 - color: #000;  
98 - background: #eeeeee;  
99 -}  
100 -  
101 -.bootstrap-switch .bootstrap-switch-label {  
102 - text-align: center;  
103 - margin-top: -1px;  
104 - margin-bottom: -1px;  
105 - z-index: 100;  
106 - color: #333;  
107 - background: #fff;  
108 -}  
109 -  
110 -.bootstrap-switch span::before {  
111 - content: "\200b";  
112 -}  
113 -  
114 -.bootstrap-switch .bootstrap-switch-handle-on {  
115 - border-bottom-left-radius: 3px;  
116 - border-top-left-radius: 3px;  
117 -}  
118 -  
119 -.bootstrap-switch .bootstrap-switch-handle-off {  
120 - border-bottom-right-radius: 3px;  
121 - border-top-right-radius: 3px;  
122 -}  
123 -  
124 -.bootstrap-switch input[type='radio'], .bootstrap-switch input[type='checkbox']  
125 - {  
126 - position: absolute !important;  
127 - top: 0;  
128 - left: 0;  
129 - margin: 0;  
130 - z-index: -1;  
131 - opacity: 0;  
132 - filter: alpha(opacity = 0);  
133 - visibility: hidden;  
134 -}  
135 -  
136 -.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,  
137 - .bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,  
138 - .bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label {  
139 - padding: 1px 5px;  
140 - font-size: 12px;  
141 - line-height: 1.5;  
142 -}  
143 -  
144 -.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,  
145 - .bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,  
146 - .bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label {  
147 - padding: 5px 10px;  
148 - font-size: 12px;  
149 - line-height: 1.5;  
150 -}  
151 -  
152 -.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,  
153 - .bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,  
154 - .bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label {  
155 - padding: 6px 16px;  
156 - font-size: 18px;  
157 - line-height: 1.3333333;  
158 -}  
159 -  
160 -.bootstrap-switch.bootstrap-switch-disabled, .bootstrap-switch.bootstrap-switch-readonly,  
161 - .bootstrap-switch.bootstrap-switch-indeterminate {  
162 - cursor: default !important;  
163 -}  
164 -  
165 -.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,  
166 - .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,  
167 - .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,  
168 - .bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,  
169 - .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,  
170 - .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,  
171 - .bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,  
172 - .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label,  
173 - .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label  
174 - {  
175 - opacity: 0.5;  
176 - filter: alpha(opacity = 50);  
177 - cursor: default !important;  
178 -}  
179 -  
180 -.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container {  
181 - -webkit-transition: margin-left 0.5s;  
182 - -o-transition: margin-left 0.5s;  
183 - transition: margin-left 0.5s;  
184 -}  
185 -  
186 -.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on {  
187 - border-bottom-left-radius: 0;  
188 - border-top-left-radius: 0;  
189 - border-bottom-right-radius: 3px;  
190 - border-top-right-radius: 3px;  
191 -}  
192 -  
193 -.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off  
194 - {  
195 - border-bottom-right-radius: 0;  
196 - border-top-right-radius: 0;  
197 - border-bottom-left-radius: 3px;  
198 - border-top-left-radius: 3px;  
199 -}  
200 -  
201 -.bootstrap-switch.bootstrap-switch-focused {  
202 - border-color: #66afe9;  
203 - outline: 0;  
204 - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px  
205 - rgba(102, 175, 233, 0.6);  
206 - box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px  
207 - rgba(102, 175, 233, 0.6);  
208 -}  
209 -  
210 -.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label,  
211 - .bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label  
212 - {  
213 - border-bottom-right-radius: 3px;  
214 - border-top-right-radius: 3px;  
215 -}  
216 -  
217 -.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label,  
218 - .bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label  
219 - {  
220 - border-bottom-left-radius: 3px;  
221 - border-top-left-radius: 3px;  
222 -}  
223 \ No newline at end of file 0 \ No newline at end of file
src/main/resources/static/bootstrap-switch/css/bootstrap3/bootstrap-switch.min.css deleted 100644 → 0
1 -/**  
2 - * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.  
3 - *  
4 - * @version v3.3.4  
5 - * @homepage https://bttstrp.github.io/bootstrap-switch  
6 - * @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)  
7 - * @license Apache-2.0  
8 - */  
9 -.bootstrap-switch {  
10 - display: inline-block;  
11 - direction: ltr;  
12 - cursor: pointer;  
13 - border-radius: 4px;  
14 - border: 1px solid #ccc;  
15 - position: relative;  
16 - text-align: left;  
17 - overflow: hidden;  
18 - line-height: 8px;  
19 - z-index: 0;  
20 - -webkit-user-select: none;  
21 - -moz-user-select: none;  
22 - -ms-user-select: none;  
23 - user-select: none;  
24 - vertical-align: middle;  
25 - -webkit-transition: border-color ease-in-out .15s, box-shadow  
26 - ease-in-out .15s;  
27 - -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out  
28 - .15s;  
29 - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s  
30 -}  
31 -  
32 -.bootstrap-switch .bootstrap-switch-container {  
33 - display: inline-block;  
34 - top: 0;  
35 - border-radius: 4px;  
36 - -webkit-transform: translate3d(0, 0, 0);  
37 - transform: translate3d(0, 0, 0)  
38 -}  
39 -  
40 -.bootstrap-switch .bootstrap-switch-handle-off, .bootstrap-switch .bootstrap-switch-handle-on,  
41 - .bootstrap-switch .bootstrap-switch-label {  
42 - -webkit-box-sizing: border-box;  
43 - -moz-box-sizing: border-box;  
44 - box-sizing: border-box;  
45 - cursor: pointer;  
46 - display: table-cell;  
47 - vertical-align: middle;  
48 - padding: 6px 12px;  
49 - font-size: 14px;  
50 - line-height: 20px  
51 -}  
52 -  
53 -.bootstrap-switch .bootstrap-switch-handle-off, .bootstrap-switch .bootstrap-switch-handle-on  
54 - {  
55 - text-align: center;  
56 - z-index: 1  
57 -}  
58 -  
59 -.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary,  
60 - .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary  
61 - {  
62 - color: #fff;  
63 - background: #337ab7  
64 -}  
65 -  
66 -.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info,  
67 - .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info {  
68 - color: #fff;  
69 - background: #5bc0de  
70 -}  
71 -  
72 -.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success,  
73 - .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success  
74 - {  
75 - color: #fff;  
76 - background: #5cb85c  
77 -}  
78 -  
79 -.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning,  
80 - .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning  
81 - {  
82 - background: #f0ad4e;  
83 - color: #fff  
84 -}  
85 -  
86 -.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger,  
87 - .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger {  
88 - color: #fff;  
89 - background: #d9534f  
90 -}  
91 -  
92 -.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default,  
93 - .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default  
94 - {  
95 - color: #000;  
96 - background: #eee  
97 -}  
98 -  
99 -.bootstrap-switch .bootstrap-switch-label {  
100 - text-align: center;  
101 - margin-top: -1px;  
102 - margin-bottom: -1px;  
103 - z-index: 100;  
104 - color: #333;  
105 - background: #fff  
106 -}  
107 -  
108 -.bootstrap-switch span::before {  
109 - content: "\200b"  
110 -}  
111 -  
112 -.bootstrap-switch .bootstrap-switch-handle-on {  
113 - border-bottom-left-radius: 3px;  
114 - border-top-left-radius: 3px  
115 -}  
116 -  
117 -.bootstrap-switch .bootstrap-switch-handle-off {  
118 - border-bottom-right-radius: 3px;  
119 - border-top-right-radius: 3px  
120 -}  
121 -  
122 -.bootstrap-switch input[type=radio], .bootstrap-switch input[type=checkbox]  
123 - {  
124 - position: absolute !important;  
125 - top: 0;  
126 - left: 0;  
127 - margin: 0;  
128 - z-index: -1;  
129 - opacity: 0;  
130 - filter: alpha(opacity = 0);  
131 - visibility: hidden  
132 -}  
133 -  
134 -.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,  
135 - .bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,  
136 - .bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label {  
137 - padding: 1px 5px;  
138 - font-size: 12px;  
139 - line-height: 1.5  
140 -}  
141 -  
142 -.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,  
143 - .bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,  
144 - .bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label {  
145 - padding: 5px 10px;  
146 - font-size: 12px;  
147 - line-height: 1.5  
148 -}  
149 -  
150 -.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,  
151 - .bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,  
152 - .bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label {  
153 - padding: 6px 16px;  
154 - font-size: 18px;  
155 - line-height: 1.3333333  
156 -}  
157 -  
158 -.bootstrap-switch.bootstrap-switch-disabled, .bootstrap-switch.bootstrap-switch-indeterminate,  
159 - .bootstrap-switch.bootstrap-switch-readonly {  
160 - cursor: default !important  
161 -}  
162 -  
163 -.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,  
164 - .bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,  
165 - .bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,  
166 - .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,  
167 - .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,  
168 - .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label,  
169 - .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,  
170 - .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,  
171 - .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label {  
172 - opacity: .5;  
173 - filter: alpha(opacity = 50);  
174 - cursor: default !important  
175 -}  
176 -  
177 -.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container {  
178 - -webkit-transition: margin-left .5s;  
179 - -o-transition: margin-left .5s;  
180 - transition: margin-left .5s  
181 -}  
182 -  
183 -.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on {  
184 - border-radius: 0 3px 3px 0  
185 -}  
186 -  
187 -.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off  
188 - {  
189 - border-radius: 3px 0 0 3px  
190 -}  
191 -  
192 -.bootstrap-switch.bootstrap-switch-focused {  
193 - border-color: #66afe9;  
194 - outline: 0;  
195 - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px  
196 - rgba(102, 175, 233, .6);  
197 - box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px  
198 - rgba(102, 175, 233, .6)  
199 -}  
200 -  
201 -.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label,  
202 - .bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label {  
203 - border-bottom-right-radius: 3px;  
204 - border-top-right-radius: 3px  
205 -}  
206 -  
207 -.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label,  
208 - .bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label {  
209 - border-bottom-left-radius: 3px;  
210 - border-top-left-radius: 3px  
211 -}  
212 \ No newline at end of file 0 \ No newline at end of file
src/main/resources/static/bootstrap-switch/js/bootstrap-switch.js deleted 100644 → 0
1 -/**  
2 - * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.  
3 - *  
4 - * @version v3.3.4  
5 - * @homepage https://bttstrp.github.io/bootstrap-switch  
6 - * @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)  
7 - * @license Apache-2.0  
8 - */  
9 -  
10 -(function (global, factory) {  
11 - if (typeof define === "function" && define.amd) {  
12 - define(['jquery'], factory);  
13 - } else if (typeof exports !== "undefined") {  
14 - factory(require('jquery'));  
15 - } else {  
16 - var mod = {  
17 - exports: {}  
18 - };  
19 - factory(global.jquery);  
20 - global.bootstrapSwitch = mod.exports;  
21 - }  
22 -})(this, function (_jquery) {  
23 - 'use strict';  
24 -  
25 - var _jquery2 = _interopRequireDefault(_jquery);  
26 -  
27 - function _interopRequireDefault(obj) {  
28 - return obj && obj.__esModule ? obj : {  
29 - default: obj  
30 - };  
31 - }  
32 -  
33 - var _extends = Object.assign || function (target) {  
34 - for (var i = 1; i < arguments.length; i++) {  
35 - var source = arguments[i];  
36 -  
37 - for (var key in source) {  
38 - if (Object.prototype.hasOwnProperty.call(source, key)) {  
39 - target[key] = source[key];  
40 - }  
41 - }  
42 - }  
43 -  
44 - return target;  
45 - };  
46 -  
47 - function _classCallCheck(instance, Constructor) {  
48 - if (!(instance instanceof Constructor)) {  
49 - throw new TypeError("Cannot call a class as a function");  
50 - }  
51 - }  
52 -  
53 - var _createClass = function () {  
54 - function defineProperties(target, props) {  
55 - for (var i = 0; i < props.length; i++) {  
56 - var descriptor = props[i];  
57 - descriptor.enumerable = descriptor.enumerable || false;  
58 - descriptor.configurable = true;  
59 - if ("value" in descriptor) descriptor.writable = true;  
60 - Object.defineProperty(target, descriptor.key, descriptor);  
61 - }  
62 - }  
63 -  
64 - return function (Constructor, protoProps, staticProps) {  
65 - if (protoProps) defineProperties(Constructor.prototype, protoProps);  
66 - if (staticProps) defineProperties(Constructor, staticProps);  
67 - return Constructor;  
68 - };  
69 - }();  
70 -  
71 - var $ = _jquery2.default || window.jQuery || window.$;  
72 -  
73 - var BootstrapSwitch = function () {  
74 - function BootstrapSwitch(element) {  
75 - var _this = this;  
76 -  
77 - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};  
78 -  
79 - _classCallCheck(this, BootstrapSwitch);  
80 -  
81 - this.$element = $(element);  
82 - this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, this._getElementOptions(), options);  
83 - this.prevOptions = {};  
84 - this.$wrapper = $('<div>', {  
85 - class: function _class() {  
86 - var classes = [];  
87 - classes.push(_this.options.state ? 'on' : 'off');  
88 - if (_this.options.size) {  
89 - classes.push(_this.options.size);  
90 - }  
91 - if (_this.options.disabled) {  
92 - classes.push('disabled');  
93 - }  
94 - if (_this.options.readonly) {  
95 - classes.push('readonly');  
96 - }  
97 - if (_this.options.indeterminate) {  
98 - classes.push('indeterminate');  
99 - }  
100 - if (_this.options.inverse) {  
101 - classes.push('inverse');  
102 - }  
103 - if (_this.$element.attr('id')) {  
104 - classes.push('id-' + _this.$element.attr('id'));  
105 - }  
106 - return classes.map(_this._getClass.bind(_this)).concat([_this.options.baseClass], _this._getClasses(_this.options.wrapperClass)).join(' ');  
107 - }  
108 - });  
109 - this.$container = $('<div>', { class: this._getClass('container') });  
110 - this.$on = $('<span>', {  
111 - html: this.options.onText,  
112 - class: this._getClass('handle-on') + ' ' + this._getClass(this.options.onColor)  
113 - });  
114 - this.$off = $('<span>', {  
115 - html: this.options.offText,  
116 - class: this._getClass('handle-off') + ' ' + this._getClass(this.options.offColor)  
117 - });  
118 - this.$label = $('<span>', {  
119 - html: this.options.labelText,  
120 - class: this._getClass('label')  
121 - });  
122 -  
123 - this.$element.on('init.bootstrapSwitch', this.options.onInit.bind(this, element));  
124 - this.$element.on('switchChange.bootstrapSwitch', function () {  
125 - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {  
126 - args[_key] = arguments[_key];  
127 - }  
128 -  
129 - if (_this.options.onSwitchChange.apply(element, args) === false) {  
130 - if (_this.$element.is(':radio')) {  
131 - $('[name="' + _this.$element.attr('name') + '"]').trigger('previousState.bootstrapSwitch', true);  
132 - } else {  
133 - _this.$element.trigger('previousState.bootstrapSwitch', true);  
134 - }  
135 - }  
136 - });  
137 -  
138 - this.$container = this.$element.wrap(this.$container).parent();  
139 - this.$wrapper = this.$container.wrap(this.$wrapper).parent();  
140 - this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off);  
141 -  
142 - if (this.options.indeterminate) {  
143 - this.$element.prop('indeterminate', true);  
144 - }  
145 -  
146 - this._init();  
147 - this._elementHandlers();  
148 - this._handleHandlers();  
149 - this._labelHandlers();  
150 - this._formHandler();  
151 - this._externalLabelHandler();  
152 - this.$element.trigger('init.bootstrapSwitch', this.options.state);  
153 - }  
154 -  
155 - _createClass(BootstrapSwitch, [{  
156 - key: 'setPrevOptions',  
157 - value: function setPrevOptions() {  
158 - this.prevOptions = _extends({}, this.options);  
159 - }  
160 - }, {  
161 - key: 'state',  
162 - value: function state(value, skip) {  
163 - if (typeof value === 'undefined') {  
164 - return this.options.state;  
165 - }  
166 - if (this.options.disabled || this.options.readonly || this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) {  
167 - return this.$element;  
168 - }  
169 - if (this.$element.is(':radio')) {  
170 - $('[name="' + this.$element.attr('name') + '"]').trigger('setPreviousOptions.bootstrapSwitch');  
171 - } else {  
172 - this.$element.trigger('setPreviousOptions.bootstrapSwitch');  
173 - }  
174 - if (this.options.indeterminate) {  
175 - this.indeterminate(false);  
176 - }  
177 - this.$element.prop('checked', Boolean(value)).trigger('change.bootstrapSwitch', skip);  
178 - return this.$element;  
179 - }  
180 - }, {  
181 - key: 'toggleState',  
182 - value: function toggleState(skip) {  
183 - if (this.options.disabled || this.options.readonly) {  
184 - return this.$element;  
185 - }  
186 - if (this.options.indeterminate) {  
187 - this.indeterminate(false);  
188 - return this.state(true);  
189 - } else {  
190 - return this.$element.prop('checked', !this.options.state).trigger('change.bootstrapSwitch', skip);  
191 - }  
192 - }  
193 - }, {  
194 - key: 'size',  
195 - value: function size(value) {  
196 - if (typeof value === 'undefined') {  
197 - return this.options.size;  
198 - }  
199 - if (this.options.size != null) {  
200 - this.$wrapper.removeClass(this._getClass(this.options.size));  
201 - }  
202 - if (value) {  
203 - this.$wrapper.addClass(this._getClass(value));  
204 - }  
205 - this._width();  
206 - this._containerPosition();  
207 - this.options.size = value;  
208 - return this.$element;  
209 - }  
210 - }, {  
211 - key: 'animate',  
212 - value: function animate(value) {  
213 - if (typeof value === 'undefined') {  
214 - return this.options.animate;  
215 - }  
216 - if (this.options.animate === Boolean(value)) {  
217 - return this.$element;  
218 - }  
219 - return this.toggleAnimate();  
220 - }  
221 - }, {  
222 - key: 'toggleAnimate',  
223 - value: function toggleAnimate() {  
224 - this.options.animate = !this.options.animate;  
225 - this.$wrapper.toggleClass(this._getClass('animate'));  
226 - return this.$element;  
227 - }  
228 - }, {  
229 - key: 'disabled',  
230 - value: function disabled(value) {  
231 - if (typeof value === 'undefined') {  
232 - return this.options.disabled;  
233 - }  
234 - if (this.options.disabled === Boolean(value)) {  
235 - return this.$element;  
236 - }  
237 - return this.toggleDisabled();  
238 - }  
239 - }, {  
240 - key: 'toggleDisabled',  
241 - value: function toggleDisabled() {  
242 - this.options.disabled = !this.options.disabled;  
243 - this.$element.prop('disabled', this.options.disabled);  
244 - this.$wrapper.toggleClass(this._getClass('disabled'));  
245 - return this.$element;  
246 - }  
247 - }, {  
248 - key: 'readonly',  
249 - value: function readonly(value) {  
250 - if (typeof value === 'undefined') {  
251 - return this.options.readonly;  
252 - }  
253 - if (this.options.readonly === Boolean(value)) {  
254 - return this.$element;  
255 - }  
256 - return this.toggleReadonly();  
257 - }  
258 - }, {  
259 - key: 'toggleReadonly',  
260 - value: function toggleReadonly() {  
261 - this.options.readonly = !this.options.readonly;  
262 - this.$element.prop('readonly', this.options.readonly);  
263 - this.$wrapper.toggleClass(this._getClass('readonly'));  
264 - return this.$element;  
265 - }  
266 - }, {  
267 - key: 'indeterminate',  
268 - value: function indeterminate(value) {  
269 - if (typeof value === 'undefined') {  
270 - return this.options.indeterminate;  
271 - }  
272 - if (this.options.indeterminate === Boolean(value)) {  
273 - return this.$element;  
274 - }  
275 - return this.toggleIndeterminate();  
276 - }  
277 - }, {  
278 - key: 'toggleIndeterminate',  
279 - value: function toggleIndeterminate() {  
280 - this.options.indeterminate = !this.options.indeterminate;  
281 - this.$element.prop('indeterminate', this.options.indeterminate);  
282 - this.$wrapper.toggleClass(this._getClass('indeterminate'));  
283 - this._containerPosition();  
284 - return this.$element;  
285 - }  
286 - }, {  
287 - key: 'inverse',  
288 - value: function inverse(value) {  
289 - if (typeof value === 'undefined') {  
290 - return this.options.inverse;  
291 - }  
292 - if (this.options.inverse === Boolean(value)) {  
293 - return this.$element;  
294 - }  
295 - return this.toggleInverse();  
296 - }  
297 - }, {  
298 - key: 'toggleInverse',  
299 - value: function toggleInverse() {  
300 - this.$wrapper.toggleClass(this._getClass('inverse'));  
301 - var $on = this.$on.clone(true);  
302 - var $off = this.$off.clone(true);  
303 - this.$on.replaceWith($off);  
304 - this.$off.replaceWith($on);  
305 - this.$on = $off;  
306 - this.$off = $on;  
307 - this.options.inverse = !this.options.inverse;  
308 - return this.$element;  
309 - }  
310 - }, {  
311 - key: 'onColor',  
312 - value: function onColor(value) {  
313 - if (typeof value === 'undefined') {  
314 - return this.options.onColor;  
315 - }  
316 - if (this.options.onColor) {  
317 - this.$on.removeClass(this._getClass(this.options.onColor));  
318 - }  
319 - this.$on.addClass(this._getClass(value));  
320 - this.options.onColor = value;  
321 - return this.$element;  
322 - }  
323 - }, {  
324 - key: 'offColor',  
325 - value: function offColor(value) {  
326 - if (typeof value === 'undefined') {  
327 - return this.options.offColor;  
328 - }  
329 - if (this.options.offColor) {  
330 - this.$off.removeClass(this._getClass(this.options.offColor));  
331 - }  
332 - this.$off.addClass(this._getClass(value));  
333 - this.options.offColor = value;  
334 - return this.$element;  
335 - }  
336 - }, {  
337 - key: 'onText',  
338 - value: function onText(value) {  
339 - if (typeof value === 'undefined') {  
340 - return this.options.onText;  
341 - }  
342 - this.$on.html(value);  
343 - this._width();  
344 - this._containerPosition();  
345 - this.options.onText = value;  
346 - return this.$element;  
347 - }  
348 - }, {  
349 - key: 'offText',  
350 - value: function offText(value) {  
351 - if (typeof value === 'undefined') {  
352 - return this.options.offText;  
353 - }  
354 - this.$off.html(value);  
355 - this._width();  
356 - this._containerPosition();  
357 - this.options.offText = value;  
358 - return this.$element;  
359 - }  
360 - }, {  
361 - key: 'labelText',  
362 - value: function labelText(value) {  
363 - if (typeof value === 'undefined') {  
364 - return this.options.labelText;  
365 - }  
366 - this.$label.html(value);  
367 - this._width();  
368 - this.options.labelText = value;  
369 - return this.$element;  
370 - }  
371 - }, {  
372 - key: 'handleWidth',  
373 - value: function handleWidth(value) {  
374 - if (typeof value === 'undefined') {  
375 - return this.options.handleWidth;  
376 - }  
377 - this.options.handleWidth = value;  
378 - this._width();  
379 - this._containerPosition();  
380 - return this.$element;  
381 - }  
382 - }, {  
383 - key: 'labelWidth',  
384 - value: function labelWidth(value) {  
385 - if (typeof value === 'undefined') {  
386 - return this.options.labelWidth;  
387 - }  
388 - this.options.labelWidth = value;  
389 - this._width();  
390 - this._containerPosition();  
391 - return this.$element;  
392 - }  
393 - }, {  
394 - key: 'baseClass',  
395 - value: function baseClass(value) {  
396 - return this.options.baseClass;  
397 - }  
398 - }, {  
399 - key: 'wrapperClass',  
400 - value: function wrapperClass(value) {  
401 - if (typeof value === 'undefined') {  
402 - return this.options.wrapperClass;  
403 - }  
404 - if (!value) {  
405 - value = $.fn.bootstrapSwitch.defaults.wrapperClass;  
406 - }  
407 - this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(' '));  
408 - this.$wrapper.addClass(this._getClasses(value).join(' '));  
409 - this.options.wrapperClass = value;  
410 - return this.$element;  
411 - }  
412 - }, {  
413 - key: 'radioAllOff',  
414 - value: function radioAllOff(value) {  
415 - if (typeof value === 'undefined') {  
416 - return this.options.radioAllOff;  
417 - }  
418 - var val = Boolean(value);  
419 - if (this.options.radioAllOff === val) {  
420 - return this.$element;  
421 - }  
422 - this.options.radioAllOff = val;  
423 - return this.$element;  
424 - }  
425 - }, {  
426 - key: 'onInit',  
427 - value: function onInit(value) {  
428 - if (typeof value === 'undefined') {  
429 - return this.options.onInit;  
430 - }  
431 - if (!value) {  
432 - value = $.fn.bootstrapSwitch.defaults.onInit;  
433 - }  
434 - this.options.onInit = value;  
435 - return this.$element;  
436 - }  
437 - }, {  
438 - key: 'onSwitchChange',  
439 - value: function onSwitchChange(value) {  
440 - if (typeof value === 'undefined') {  
441 - return this.options.onSwitchChange;  
442 - }  
443 - if (!value) {  
444 - value = $.fn.bootstrapSwitch.defaults.onSwitchChange;  
445 - }  
446 - this.options.onSwitchChange = value;  
447 - return this.$element;  
448 - }  
449 - }, {  
450 - key: 'destroy',  
451 - value: function destroy() {  
452 - var $form = this.$element.closest('form');  
453 - if ($form.length) {  
454 - $form.off('reset.bootstrapSwitch').removeData('bootstrap-switch');  
455 - }  
456 - this.$container.children().not(this.$element).remove();  
457 - this.$element.unwrap().unwrap().off('.bootstrapSwitch').removeData('bootstrap-switch');  
458 - return this.$element;  
459 - }  
460 - }, {  
461 - key: '_getElementOptions',  
462 - value: function _getElementOptions() {  
463 - return {  
464 - state: this.$element.is(':checked'),  
465 - size: this.$element.data('size'),  
466 - animate: this.$element.data('animate'),  
467 - disabled: this.$element.is(':disabled'),  
468 - readonly: this.$element.is('[readonly]'),  
469 - indeterminate: this.$element.data('indeterminate'),  
470 - inverse: this.$element.data('inverse'),  
471 - radioAllOff: this.$element.data('radio-all-off'),  
472 - onColor: this.$element.data('on-color'),  
473 - offColor: this.$element.data('off-color'),  
474 - onText: this.$element.data('on-text'),  
475 - offText: this.$element.data('off-text'),  
476 - labelText: this.$element.data('label-text'),  
477 - handleWidth: this.$element.data('handle-width'),  
478 - labelWidth: this.$element.data('label-width'),  
479 - baseClass: this.$element.data('base-class'),  
480 - wrapperClass: this.$element.data('wrapper-class')  
481 - };  
482 - }  
483 - }, {  
484 - key: '_width',  
485 - value: function _width() {  
486 - var _this2 = this;  
487 -  
488 - var $handles = this.$on.add(this.$off).add(this.$label).css('width', '');  
489 - var handleWidth = this.options.handleWidth === 'auto' ? Math.round(Math.max(this.$on.width(), this.$off.width())) : this.options.handleWidth;  
490 - $handles.width(handleWidth);  
491 - this.$label.width(function (index, width) {  
492 - if (_this2.options.labelWidth !== 'auto') {  
493 - return _this2.options.labelWidth;  
494 - }  
495 - if (width < handleWidth) {  
496 - return handleWidth;  
497 - }  
498 - return width;  
499 - });  
500 - this._handleWidth = this.$on.outerWidth();  
501 - this._labelWidth = this.$label.outerWidth();  
502 - this.$container.width(this._handleWidth * 2 + this._labelWidth);  
503 - return this.$wrapper.width(this._handleWidth + this._labelWidth);  
504 - }  
505 - }, {  
506 - key: '_containerPosition',  
507 - value: function _containerPosition() {  
508 - var _this3 = this;  
509 -  
510 - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.state;  
511 - var callback = arguments[1];  
512 -  
513 - this.$container.css('margin-left', function () {  
514 - var values = [0, '-' + _this3._handleWidth + 'px'];  
515 - if (_this3.options.indeterminate) {  
516 - return '-' + _this3._handleWidth / 2 + 'px';  
517 - }  
518 - if (state) {  
519 - if (_this3.options.inverse) {  
520 - return values[1];  
521 - } else {  
522 - return values[0];  
523 - }  
524 - } else {  
525 - if (_this3.options.inverse) {  
526 - return values[0];  
527 - } else {  
528 - return values[1];  
529 - }  
530 - }  
531 - });  
532 - }  
533 - }, {  
534 - key: '_init',  
535 - value: function _init() {  
536 - var _this4 = this;  
537 -  
538 - var init = function init() {  
539 - _this4.setPrevOptions();  
540 - _this4._width();  
541 - _this4._containerPosition();  
542 - setTimeout(function () {  
543 - if (_this4.options.animate) {  
544 - return _this4.$wrapper.addClass(_this4._getClass('animate'));  
545 - }  
546 - }, 50);  
547 - };  
548 - if (this.$wrapper.is(':visible')) {  
549 - init();  
550 - return;  
551 - }  
552 - var initInterval = window.setInterval(function () {  
553 - if (_this4.$wrapper.is(':visible')) {  
554 - init();  
555 - return window.clearInterval(initInterval);  
556 - }  
557 - }, 50);  
558 - }  
559 - }, {  
560 - key: '_elementHandlers',  
561 - value: function _elementHandlers() {  
562 - var _this5 = this;  
563 -  
564 - return this.$element.on({  
565 - 'setPreviousOptions.bootstrapSwitch': this.setPrevOptions.bind(this),  
566 -  
567 - 'previousState.bootstrapSwitch': function previousStateBootstrapSwitch() {  
568 - _this5.options = _this5.prevOptions;  
569 - if (_this5.options.indeterminate) {  
570 - _this5.$wrapper.addClass(_this5._getClass('indeterminate'));  
571 - }  
572 - _this5.$element.prop('checked', _this5.options.state).trigger('change.bootstrapSwitch', true);  
573 - },  
574 -  
575 - 'change.bootstrapSwitch': function changeBootstrapSwitch(event, skip) {  
576 - event.preventDefault();  
577 - event.stopImmediatePropagation();  
578 - var state = _this5.$element.is(':checked');  
579 - _this5._containerPosition(state);  
580 - if (state === _this5.options.state) {  
581 - return;  
582 - }  
583 - _this5.options.state = state;  
584 - _this5.$wrapper.toggleClass(_this5._getClass('off')).toggleClass(_this5._getClass('on'));  
585 - if (!skip) {  
586 - if (_this5.$element.is(':radio')) {  
587 - $('[name="' + _this5.$element.attr('name') + '"]').not(_this5.$element).prop('checked', false).trigger('change.bootstrapSwitch', true);  
588 - }  
589 - _this5.$element.trigger('switchChange.bootstrapSwitch', [state]);  
590 - }  
591 - },  
592 -  
593 - 'focus.bootstrapSwitch': function focusBootstrapSwitch(event) {  
594 - event.preventDefault();  
595 - _this5.$wrapper.addClass(_this5._getClass('focused'));  
596 - },  
597 -  
598 - 'blur.bootstrapSwitch': function blurBootstrapSwitch(event) {  
599 - event.preventDefault();  
600 - _this5.$wrapper.removeClass(_this5._getClass('focused'));  
601 - },  
602 -  
603 - 'keydown.bootstrapSwitch': function keydownBootstrapSwitch(event) {  
604 - if (!event.which || _this5.options.disabled || _this5.options.readonly) {  
605 - return;  
606 - }  
607 - if (event.which === 37 || event.which === 39) {  
608 - event.preventDefault();  
609 - event.stopImmediatePropagation();  
610 - _this5.state(event.which === 39);  
611 - }  
612 - }  
613 - });  
614 - }  
615 - }, {  
616 - key: '_handleHandlers',  
617 - value: function _handleHandlers() {  
618 - var _this6 = this;  
619 -  
620 - this.$on.on('click.bootstrapSwitch', function (event) {  
621 - event.preventDefault();  
622 - event.stopPropagation();  
623 - _this6.state(false);  
624 - return _this6.$element.trigger('focus.bootstrapSwitch');  
625 - });  
626 - return this.$off.on('click.bootstrapSwitch', function (event) {  
627 - event.preventDefault();  
628 - event.stopPropagation();  
629 - _this6.state(true);  
630 - return _this6.$element.trigger('focus.bootstrapSwitch');  
631 - });  
632 - }  
633 - }, {  
634 - key: '_labelHandlers',  
635 - value: function _labelHandlers() {  
636 - var _this7 = this;  
637 -  
638 - var handlers = {  
639 - click: function click(event) {  
640 - event.stopPropagation();  
641 - },  
642 -  
643 -  
644 - 'mousedown.bootstrapSwitch touchstart.bootstrapSwitch': function mousedownBootstrapSwitchTouchstartBootstrapSwitch(event) {  
645 - if (_this7._dragStart || _this7.options.disabled || _this7.options.readonly) {  
646 - return;  
647 - }  
648 - event.preventDefault();  
649 - event.stopPropagation();  
650 - _this7._dragStart = (event.pageX || event.originalEvent.touches[0].pageX) - parseInt(_this7.$container.css('margin-left'), 10);  
651 - if (_this7.options.animate) {  
652 - _this7.$wrapper.removeClass(_this7._getClass('animate'));  
653 - }  
654 - _this7.$element.trigger('focus.bootstrapSwitch');  
655 - },  
656 -  
657 - 'mousemove.bootstrapSwitch touchmove.bootstrapSwitch': function mousemoveBootstrapSwitchTouchmoveBootstrapSwitch(event) {  
658 - if (_this7._dragStart == null) {  
659 - return;  
660 - }  
661 - var difference = (event.pageX || event.originalEvent.touches[0].pageX) - _this7._dragStart;  
662 - event.preventDefault();  
663 - if (difference < -_this7._handleWidth || difference > 0) {  
664 - return;  
665 - }  
666 - _this7._dragEnd = difference;  
667 - _this7.$container.css('margin-left', _this7._dragEnd + 'px');  
668 - },  
669 -  
670 - 'mouseup.bootstrapSwitch touchend.bootstrapSwitch': function mouseupBootstrapSwitchTouchendBootstrapSwitch(event) {  
671 - if (!_this7._dragStart) {  
672 - return;  
673 - }  
674 - event.preventDefault();  
675 - if (_this7.options.animate) {  
676 - _this7.$wrapper.addClass(_this7._getClass('animate'));  
677 - }  
678 - if (_this7._dragEnd) {  
679 - var state = _this7._dragEnd > -(_this7._handleWidth / 2);  
680 - _this7._dragEnd = false;  
681 - _this7.state(_this7.options.inverse ? !state : state);  
682 - } else {  
683 - _this7.state(!_this7.options.state);  
684 - }  
685 - _this7._dragStart = false;  
686 - },  
687 -  
688 - 'mouseleave.bootstrapSwitch': function mouseleaveBootstrapSwitch() {  
689 - _this7.$label.trigger('mouseup.bootstrapSwitch');  
690 - }  
691 - };  
692 - this.$label.on(handlers);  
693 - }  
694 - }, {  
695 - key: '_externalLabelHandler',  
696 - value: function _externalLabelHandler() {  
697 - var _this8 = this;  
698 -  
699 - var $externalLabel = this.$element.closest('label');  
700 - $externalLabel.on('click', function (event) {  
701 - event.preventDefault();  
702 - event.stopImmediatePropagation();  
703 - if (event.target === $externalLabel[0]) {  
704 - _this8.toggleState();  
705 - }  
706 - });  
707 - }  
708 - }, {  
709 - key: '_formHandler',  
710 - value: function _formHandler() {  
711 - var $form = this.$element.closest('form');  
712 - if ($form.data('bootstrap-switch')) {  
713 - return;  
714 - }  
715 - $form.on('reset.bootstrapSwitch', function () {  
716 - window.setTimeout(function () {  
717 - $form.find('input').filter(function () {  
718 - return $(this).data('bootstrap-switch');  
719 - }).each(function () {  
720 - return $(this).bootstrapSwitch('state', this.checked);  
721 - });  
722 - }, 1);  
723 - }).data('bootstrap-switch', true);  
724 - }  
725 - }, {  
726 - key: '_getClass',  
727 - value: function _getClass(name) {  
728 - return this.options.baseClass + '-' + name;  
729 - }  
730 - }, {  
731 - key: '_getClasses',  
732 - value: function _getClasses(classes) {  
733 - if (!$.isArray(classes)) {  
734 - return [this._getClass(classes)];  
735 - }  
736 - return classes.map(this._getClass.bind(this));  
737 - }  
738 - }]);  
739 -  
740 - return BootstrapSwitch;  
741 - }();  
742 -  
743 - $.fn.bootstrapSwitch = function (option) {  
744 - for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {  
745 - args[_key2 - 1] = arguments[_key2];  
746 - }  
747 -  
748 - function reducer(ret, next) {  
749 - var $this = $(next);  
750 - var existingData = $this.data('bootstrap-switch');  
751 - var data = existingData || new BootstrapSwitch(next, option);  
752 - if (!existingData) {  
753 - $this.data('bootstrap-switch', data);  
754 - }  
755 - if (typeof option === 'string') {  
756 - return data[option].apply(data, args);  
757 - }  
758 - return ret;  
759 - }  
760 - return Array.prototype.reduce.call(this, reducer, this);  
761 - };  
762 - $.fn.bootstrapSwitch.Constructor = BootstrapSwitch;  
763 - $.fn.bootstrapSwitch.defaults = {  
764 - state: true,  
765 - size: null,  
766 - animate: true,  
767 - disabled: false,  
768 - readonly: false,  
769 - indeterminate: false,  
770 - inverse: false,  
771 - radioAllOff: false,  
772 - onColor: 'primary',  
773 - offColor: 'default',  
774 - onText: 'ON',  
775 - offText: 'OFF',  
776 - labelText: '&nbsp',  
777 - handleWidth: 'auto',  
778 - labelWidth: 'auto',  
779 - baseClass: 'bootstrap-switch',  
780 - wrapperClass: 'wrapper',  
781 - onInit: function onInit() {},  
782 - onSwitchChange: function onSwitchChange() {}  
783 - };  
784 -});  
src/main/resources/static/bootstrap-switch/js/bootstrap-switch.min.js deleted 100644 → 0
1 -/**  
2 - * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.  
3 - *  
4 - * @version v3.3.4  
5 - * @homepage https://bttstrp.github.io/bootstrap-switch  
6 - * @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)  
7 - * @license Apache-2.0  
8 - */  
9 -  
10 -(function(a,b){if('function'==typeof define&&define.amd)define(['jquery'],b);else if('undefined'!=typeof exports)b(require('jquery'));else{b(a.jquery),a.bootstrapSwitch={exports:{}}.exports}})(this,function(a){'use strict';function c(j,k){if(!(j instanceof k))throw new TypeError('Cannot call a class as a function')}var d=function(j){return j&&j.__esModule?j:{default:j}}(a),e=Object.assign||function(j){for(var l,k=1;k<arguments.length;k++)for(var m in l=arguments[k],l)Object.prototype.hasOwnProperty.call(l,m)&&(j[m]=l[m]);return j},f=function(){function j(k,l){for(var n,m=0;m<l.length;m++)n=l[m],n.enumerable=n.enumerable||!1,n.configurable=!0,'value'in n&&(n.writable=!0),Object.defineProperty(k,n.key,n)}return function(k,l,m){return l&&j(k.prototype,l),m&&j(k,m),k}}(),g=d.default||window.jQuery||window.$,h=function(){function j(k){var l=this,m=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};c(this,j),this.$element=g(k),this.options=g.extend({},g.fn.bootstrapSwitch.defaults,this._getElementOptions(),m),this.prevOptions={},this.$wrapper=g('<div>',{class:function(){var o=[];return o.push(l.options.state?'on':'off'),l.options.size&&o.push(l.options.size),l.options.disabled&&o.push('disabled'),l.options.readonly&&o.push('readonly'),l.options.indeterminate&&o.push('indeterminate'),l.options.inverse&&o.push('inverse'),l.$element.attr('id')&&o.push('id-'+l.$element.attr('id')),o.map(l._getClass.bind(l)).concat([l.options.baseClass],l._getClasses(l.options.wrapperClass)).join(' ')}}),this.$container=g('<div>',{class:this._getClass('container')}),this.$on=g('<span>',{html:this.options.onText,class:this._getClass('handle-on')+' '+this._getClass(this.options.onColor)}),this.$off=g('<span>',{html:this.options.offText,class:this._getClass('handle-off')+' '+this._getClass(this.options.offColor)}),this.$label=g('<span>',{html:this.options.labelText,class:this._getClass('label')}),this.$element.on('init.bootstrapSwitch',this.options.onInit.bind(this,k)),this.$element.on('switchChange.bootstrapSwitch',function(){for(var n=arguments.length,o=Array(n),p=0;p<n;p++)o[p]=arguments[p];!1===l.options.onSwitchChange.apply(k,o)&&(l.$element.is(':radio')?g('[name="'+l.$element.attr('name')+'"]').trigger('previousState.bootstrapSwitch',!0):l.$element.trigger('previousState.bootstrapSwitch',!0))}),this.$container=this.$element.wrap(this.$container).parent(),this.$wrapper=this.$container.wrap(this.$wrapper).parent(),this.$element.before(this.options.inverse?this.$off:this.$on).before(this.$label).before(this.options.inverse?this.$on:this.$off),this.options.indeterminate&&this.$element.prop('indeterminate',!0),this._init(),this._elementHandlers(),this._handleHandlers(),this._labelHandlers(),this._formHandler(),this._externalLabelHandler(),this.$element.trigger('init.bootstrapSwitch',this.options.state)}return f(j,[{key:'setPrevOptions',value:function(){this.prevOptions=e({},this.options)}},{key:'state',value:function(l,m){return'undefined'==typeof l?this.options.state:this.options.disabled||this.options.readonly||this.options.state&&!this.options.radioAllOff&&this.$element.is(':radio')?this.$element:(this.$element.is(':radio')?g('[name="'+this.$element.attr('name')+'"]').trigger('setPreviousOptions.bootstrapSwitch'):this.$element.trigger('setPreviousOptions.bootstrapSwitch'),this.options.indeterminate&&this.indeterminate(!1),this.$element.prop('checked',!!l).trigger('change.bootstrapSwitch',m),this.$element)}},{key:'toggleState',value:function(l){return this.options.disabled||this.options.readonly?this.$element:this.options.indeterminate?(this.indeterminate(!1),this.state(!0)):this.$element.prop('checked',!this.options.state).trigger('change.bootstrapSwitch',l)}},{key:'size',value:function(l){return'undefined'==typeof l?this.options.size:(null!=this.options.size&&this.$wrapper.removeClass(this._getClass(this.options.size)),l&&this.$wrapper.addClass(this._getClass(l)),this._width(),this._containerPosition(),this.options.size=l,this.$element)}},{key:'animate',value:function(l){return'undefined'==typeof l?this.options.animate:this.options.animate===!!l?this.$element:this.toggleAnimate()}},{key:'toggleAnimate',value:function(){return this.options.animate=!this.options.animate,this.$wrapper.toggleClass(this._getClass('animate')),this.$element}},{key:'disabled',value:function(l){return'undefined'==typeof l?this.options.disabled:this.options.disabled===!!l?this.$element:this.toggleDisabled()}},{key:'toggleDisabled',value:function(){return this.options.disabled=!this.options.disabled,this.$element.prop('disabled',this.options.disabled),this.$wrapper.toggleClass(this._getClass('disabled')),this.$element}},{key:'readonly',value:function(l){return'undefined'==typeof l?this.options.readonly:this.options.readonly===!!l?this.$element:this.toggleReadonly()}},{key:'toggleReadonly',value:function(){return this.options.readonly=!this.options.readonly,this.$element.prop('readonly',this.options.readonly),this.$wrapper.toggleClass(this._getClass('readonly')),this.$element}},{key:'indeterminate',value:function(l){return'undefined'==typeof l?this.options.indeterminate:this.options.indeterminate===!!l?this.$element:this.toggleIndeterminate()}},{key:'toggleIndeterminate',value:function(){return this.options.indeterminate=!this.options.indeterminate,this.$element.prop('indeterminate',this.options.indeterminate),this.$wrapper.toggleClass(this._getClass('indeterminate')),this._containerPosition(),this.$element}},{key:'inverse',value:function(l){return'undefined'==typeof l?this.options.inverse:this.options.inverse===!!l?this.$element:this.toggleInverse()}},{key:'toggleInverse',value:function(){this.$wrapper.toggleClass(this._getClass('inverse'));var l=this.$on.clone(!0),m=this.$off.clone(!0);return this.$on.replaceWith(m),this.$off.replaceWith(l),this.$on=m,this.$off=l,this.options.inverse=!this.options.inverse,this.$element}},{key:'onColor',value:function(l){return'undefined'==typeof l?this.options.onColor:(this.options.onColor&&this.$on.removeClass(this._getClass(this.options.onColor)),this.$on.addClass(this._getClass(l)),this.options.onColor=l,this.$element)}},{key:'offColor',value:function(l){return'undefined'==typeof l?this.options.offColor:(this.options.offColor&&this.$off.removeClass(this._getClass(this.options.offColor)),this.$off.addClass(this._getClass(l)),this.options.offColor=l,this.$element)}},{key:'onText',value:function(l){return'undefined'==typeof l?this.options.onText:(this.$on.html(l),this._width(),this._containerPosition(),this.options.onText=l,this.$element)}},{key:'offText',value:function(l){return'undefined'==typeof l?this.options.offText:(this.$off.html(l),this._width(),this._containerPosition(),this.options.offText=l,this.$element)}},{key:'labelText',value:function(l){return'undefined'==typeof l?this.options.labelText:(this.$label.html(l),this._width(),this.options.labelText=l,this.$element)}},{key:'handleWidth',value:function(l){return'undefined'==typeof l?this.options.handleWidth:(this.options.handleWidth=l,this._width(),this._containerPosition(),this.$element)}},{key:'labelWidth',value:function(l){return'undefined'==typeof l?this.options.labelWidth:(this.options.labelWidth=l,this._width(),this._containerPosition(),this.$element)}},{key:'baseClass',value:function(){return this.options.baseClass}},{key:'wrapperClass',value:function(l){return'undefined'==typeof l?this.options.wrapperClass:(l||(l=g.fn.bootstrapSwitch.defaults.wrapperClass),this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(' ')),this.$wrapper.addClass(this._getClasses(l).join(' ')),this.options.wrapperClass=l,this.$element)}},{key:'radioAllOff',value:function(l){if('undefined'==typeof l)return this.options.radioAllOff;var m=!!l;return this.options.radioAllOff===m?this.$element:(this.options.radioAllOff=m,this.$element)}},{key:'onInit',value:function(l){return'undefined'==typeof l?this.options.onInit:(l||(l=g.fn.bootstrapSwitch.defaults.onInit),this.options.onInit=l,this.$element)}},{key:'onSwitchChange',value:function(l){return'undefined'==typeof l?this.options.onSwitchChange:(l||(l=g.fn.bootstrapSwitch.defaults.onSwitchChange),this.options.onSwitchChange=l,this.$element)}},{key:'destroy',value:function(){var l=this.$element.closest('form');return l.length&&l.off('reset.bootstrapSwitch').removeData('bootstrap-switch'),this.$container.children().not(this.$element).remove(),this.$element.unwrap().unwrap().off('.bootstrapSwitch').removeData('bootstrap-switch'),this.$element}},{key:'_getElementOptions',value:function(){return{state:this.$element.is(':checked'),size:this.$element.data('size'),animate:this.$element.data('animate'),disabled:this.$element.is(':disabled'),readonly:this.$element.is('[readonly]'),indeterminate:this.$element.data('indeterminate'),inverse:this.$element.data('inverse'),radioAllOff:this.$element.data('radio-all-off'),onColor:this.$element.data('on-color'),offColor:this.$element.data('off-color'),onText:this.$element.data('on-text'),offText:this.$element.data('off-text'),labelText:this.$element.data('label-text'),handleWidth:this.$element.data('handle-width'),labelWidth:this.$element.data('label-width'),baseClass:this.$element.data('base-class'),wrapperClass:this.$element.data('wrapper-class')}}},{key:'_width',value:function(){var l=this,m=this.$on.add(this.$off).add(this.$label).css('width',''),n='auto'===this.options.handleWidth?Math.round(Math.max(this.$on.width(),this.$off.width())):this.options.handleWidth;return m.width(n),this.$label.width(function(o,p){return'auto'===l.options.labelWidth?p<n?n:p:l.options.labelWidth}),this._handleWidth=this.$on.outerWidth(),this._labelWidth=this.$label.outerWidth(),this.$container.width(2*this._handleWidth+this._labelWidth),this.$wrapper.width(this._handleWidth+this._labelWidth)}},{key:'_containerPosition',value:function(){var l=this,m=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.options.state,n=arguments[1];this.$container.css('margin-left',function(){var o=[0,'-'+l._handleWidth+'px'];return l.options.indeterminate?'-'+l._handleWidth/2+'px':m?l.options.inverse?o[1]:o[0]:l.options.inverse?o[0]:o[1]})}},{key:'_init',value:function(){var l=this,m=function(){l.setPrevOptions(),l._width(),l._containerPosition(),setTimeout(function(){if(l.options.animate)return l.$wrapper.addClass(l._getClass('animate'))},50)};if(this.$wrapper.is(':visible'))return void m();var n=window.setInterval(function(){if(l.$wrapper.is(':visible'))return m(),window.clearInterval(n)},50)}},{key:'_elementHandlers',value:function(){var l=this;return this.$element.on({'setPreviousOptions.bootstrapSwitch':this.setPrevOptions.bind(this),'previousState.bootstrapSwitch':function(){l.options=l.prevOptions,l.options.indeterminate&&l.$wrapper.addClass(l._getClass('indeterminate')),l.$element.prop('checked',l.options.state).trigger('change.bootstrapSwitch',!0)},'change.bootstrapSwitch':function(n,o){n.preventDefault(),n.stopImmediatePropagation();var p=l.$element.is(':checked');l._containerPosition(p),p===l.options.state||(l.options.state=p,l.$wrapper.toggleClass(l._getClass('off')).toggleClass(l._getClass('on')),!o&&(l.$element.is(':radio')&&g('[name="'+l.$element.attr('name')+'"]').not(l.$element).prop('checked',!1).trigger('change.bootstrapSwitch',!0),l.$element.trigger('switchChange.bootstrapSwitch',[p])))},'focus.bootstrapSwitch':function(n){n.preventDefault(),l.$wrapper.addClass(l._getClass('focused'))},'blur.bootstrapSwitch':function(n){n.preventDefault(),l.$wrapper.removeClass(l._getClass('focused'))},'keydown.bootstrapSwitch':function(n){!n.which||l.options.disabled||l.options.readonly||(37===n.which||39===n.which)&&(n.preventDefault(),n.stopImmediatePropagation(),l.state(39===n.which))}})}},{key:'_handleHandlers',value:function(){var l=this;return this.$on.on('click.bootstrapSwitch',function(m){return m.preventDefault(),m.stopPropagation(),l.state(!1),l.$element.trigger('focus.bootstrapSwitch')}),this.$off.on('click.bootstrapSwitch',function(m){return m.preventDefault(),m.stopPropagation(),l.state(!0),l.$element.trigger('focus.bootstrapSwitch')})}},{key:'_labelHandlers',value:function(){var l=this;this.$label.on({click:function(o){o.stopPropagation()},'mousedown.bootstrapSwitch touchstart.bootstrapSwitch':function(o){l._dragStart||l.options.disabled||l.options.readonly||(o.preventDefault(),o.stopPropagation(),l._dragStart=(o.pageX||o.originalEvent.touches[0].pageX)-parseInt(l.$container.css('margin-left'),10),l.options.animate&&l.$wrapper.removeClass(l._getClass('animate')),l.$element.trigger('focus.bootstrapSwitch'))},'mousemove.bootstrapSwitch touchmove.bootstrapSwitch':function(o){if(null!=l._dragStart){var p=(o.pageX||o.originalEvent.touches[0].pageX)-l._dragStart;o.preventDefault(),p<-l._handleWidth||0<p||(l._dragEnd=p,l.$container.css('margin-left',l._dragEnd+'px'))}},'mouseup.bootstrapSwitch touchend.bootstrapSwitch':function(o){if(l._dragStart){if(o.preventDefault(),l.options.animate&&l.$wrapper.addClass(l._getClass('animate')),l._dragEnd){var p=l._dragEnd>-(l._handleWidth/2);l._dragEnd=!1,l.state(l.options.inverse?!p:p)}else l.state(!l.options.state);l._dragStart=!1}},'mouseleave.bootstrapSwitch':function(){l.$label.trigger('mouseup.bootstrapSwitch')}})}},{key:'_externalLabelHandler',value:function(){var l=this,m=this.$element.closest('label');m.on('click',function(n){n.preventDefault(),n.stopImmediatePropagation(),n.target===m[0]&&l.toggleState()})}},{key:'_formHandler',value:function(){var l=this.$element.closest('form');l.data('bootstrap-switch')||l.on('reset.bootstrapSwitch',function(){window.setTimeout(function(){l.find('input').filter(function(){return g(this).data('bootstrap-switch')}).each(function(){return g(this).bootstrapSwitch('state',this.checked)})},1)}).data('bootstrap-switch',!0)}},{key:'_getClass',value:function(l){return this.options.baseClass+'-'+l}},{key:'_getClasses',value:function(l){return g.isArray(l)?l.map(this._getClass.bind(this)):[this._getClass(l)]}}]),j}();g.fn.bootstrapSwitch=function(j){for(var l=arguments.length,m=Array(1<l?l-1:0),n=1;n<l;n++)m[n-1]=arguments[n];return Array.prototype.reduce.call(this,function(o,p){var q=g(p),r=q.data('bootstrap-switch'),s=r||new h(p,j);return r||q.data('bootstrap-switch',s),'string'==typeof j?s[j].apply(s,m):o},this)},g.fn.bootstrapSwitch.Constructor=h,g.fn.bootstrapSwitch.defaults={state:!0,size:null,animate:!0,disabled:!1,readonly:!1,indeterminate:!1,inverse:!1,radioAllOff:!1,onColor:'primary',offColor:'default',onText:'ON',offText:'OFF',labelText:'&nbsp',handleWidth:'auto',labelWidth:'auto',baseClass:'bootstrap-switch',wrapperClass:'wrapper',onInit:function(){},onSwitchChange:function(){}}});  
src/main/resources/static/favicon.ico deleted 100644 → 0
No preview for this file type
src/main/resources/static/index.html deleted 100644 → 0
1 -<!DOCTYPE html>  
2 -<html>  
3 -<head>  
4 -<title>调度系统营运数据接口</title>  
5 -<meta charset="utf-8">  
6 -<meta http-equiv="Expires" content="0">  
7 -<meta http-equiv="Pragma" content="no-cache">  
8 -<meta http-equiv="Cache-control" content="no-cache">  
9 -<meta http-equiv="Cache" content="no-cache">  
10 -<link rel="stylesheet"  
11 - href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css">  
12 -<link rel="stylesheet" href="/simple_switch/simple.switch.three.css">  
13 -<style>  
14 -.table-wrap {  
15 - height: 500px;  
16 - overflow: auto;  
17 -}  
18 -  
19 -#line2SysListTable .Switch_FlatRadius .SwitchLine:before {  
20 - content: "老系统";  
21 -}  
22 -  
23 -#line2SysListTable .Switch_FlatRadius .SwitchLine:after {  
24 - content: "新系统";  
25 -}  
26 -  
27 -#line2SysListTable .Switch_FlatRadius {  
28 - width: 118px;  
29 -}  
30 -  
31 -#line2SysListTable .Switch_FlatRadius .SwitchButton {  
32 - width: 52px;  
33 -}  
34 -  
35 -#line2SysListTable .Switch_FlatRadius .SwitchButton:before {  
36 - left: 18px;  
37 -}  
38 -  
39 -#line2SysListTable .Switch_FlatRadius .SwitchButton:after {  
40 - left: 30px;  
41 -}  
42 -  
43 -#line2SysListTable .Switch_FlatRadius.On .SwitchButton {  
44 - left: 60px;  
45 -}  
46 -</style>  
47 -</head>  
48 -  
49 -<body>  
50 -  
51 - <div class="row" style="margin: 15px;">  
52 - <div class="col-md-12 well">  
53 - <h4>  
54 - Available SOAP services: <a href="/webservice" target="_blank">/webservice</a>  
55 - </h4>  
56 - <h4>  
57 - WSDL: <a href="/webservice/CompanyService?wsdl" target="_blank">/webservice/CompanyService?wsdl</a>  
58 - </h4>  
59 - </div>  
60 -  
61 - <div class="col-lg-4 col-md-6 col-sm-12">  
62 - <div class="bs-example"  
63 - data-example-id="panel-without-body-with-table">  
64 - <div class="panel panel-default">  
65 - <!-- Default panel contents -->  
66 - <div class="panel-heading">线路清单</div>  
67 - <div class="panel-body">  
68 - <p style="color: #ff2727;">屏蔽新老系统的底层数据差异,对外提供统一的数据输出</p>  
69 - <p>1、使用员工号查询数据时,系统将参考 “线路人员配置” 以确定人员所在线路。</p>  
70 - <p>2、使用公司编码查询数据时,系统将参考 “线路基础信息” 里的公司编码。</p>  
71 - </div>  
72 - <div class="table-wrap">  
73 - <table class="table" id="line2SysListTable">  
74 - <thead>  
75 - <tr>  
76 - <th>线路编码</th>  
77 - <th>线路名称</th>  
78 - <th>数据来源</th>  
79 - </tr>  
80 - </thead>  
81 - <tbody>  
82 - </tbody>  
83 - </table>  
84 - </div>  
85 - </div>  
86 - </div>  
87 - </div>  
88 -  
89 - <div class="col-lg-8 col-md-6 col-sm-12">  
90 - <div class="bs-example">  
91 - <div class="panel panel-default">  
92 - <div class="panel-heading">接口调试工具</div>  
93 - <div style="padding: 15px; margin-top: 15px;">  
94 - <form class="form-inline">  
95 - <div class="form-group">  
96 - <label>函数</label> <select class="form-control">  
97 - <option value="returnCCInfo">returnCCInfo(获取出场班次信息)</option>  
98 - <option value="returnJCInfo">returnJCInfo(获取进场班次信息)</option>  
99 - </select>  
100 - </div>  
101 - &nbsp;  
102 - <div class="form-group">  
103 - <label>公司编码</label> <select class="form-control">  
104 - <option value="55">55(上南)</option>  
105 - <option value="22">22(金高)</option>  
106 - <option value="05">05(杨高)</option>  
107 - <option value="26">26(南汇)</option>  
108 - </select>  
109 - </div>  
110 - &nbsp;  
111 - <div class="form-group">  
112 - <label>日期</label> <input type="date" class="form-control"  
113 - style="width: 150px;" required>  
114 - </div>  
115 - <button type="submit" class="btn btn-primary">获取数据</button>  
116 -  
117 - <textarea class="form-control" rows="25"  
118 - style="width: 100%; margin-top: 25px;"></textarea>  
119 - </form>  
120 -  
121 - </div>  
122 - </div>  
123 - </div>  
124 - </div>  
125 - </div>  
126 -  
127 - <script id="line2sys-table-list-temp" type="text/html">  
128 - {{each list as obj i}}  
129 - <tr data-id="{{obj.lineCode}}" data-name="{{obj.lineName}}" {{if obj.new}}class="warning" {{/if}} >  
130 - <td>{{obj.lineCode}}</td>  
131 - <td>{{obj.lineName}}</td>  
132 - <td>  
133 - <input type="checkbox" {{if obj.new}}checked{{/if}} />  
134 - </td>  
135 - </tr>  
136 - {{/each}}  
137 -</script>  
138 -  
139 - <script src="http://apps.bdimg.com/libs/jquery/1.8.3/jquery.min.js"></script>  
140 - <script  
141 - src="http://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.min.js"></script>  
142 - <script src="/assets/js/template.js"></script>  
143 - <script src="/simple_switch/simple.switch.min.js"></script>  
144 -  
145 - <script>  
146 -  
147 - //线路清单  
148 - !function () {  
149 - var f = arguments.callee;  
150 -/* $.get('/line2System/all', function (list) {  
151 - list.sort(function (a, b) {  
152 - return b.new - a.new;  
153 - });  
154 - var htmlStr = template('line2sys-table-list-temp', {list: list});  
155 - $('#line2SysListTable tbody').html(htmlStr);  
156 -  
157 - $('input[type=checkbox]').simpleSwitch({  
158 - "theme": "FlatRadius"  
159 - });  
160 -  
161 - $('input[type=checkbox]').on('change', function () {  
162 - var $tr = $(this).parents('tr');  
163 - var data = {  
164 - lineCode: $tr.data('id'),  
165 - lineName: $tr.data('name'),  
166 - new: this.checked  
167 - }  
168 -  
169 - $.post('/line2System/update', data, function (rs) {  
170 - var $tr = $('#line2SysListTable tr[data-id=' + rs.lineCode + ']');  
171 - $tr.attr('class', rs.new ? 'warning' : '');  
172 - });  
173 - });  
174 - });*/  
175 - }();  
176 -  
177 -</script>  
178 -</body>  
179 -</html>  
180 \ No newline at end of file 0 \ No newline at end of file
src/main/resources/static/simple_switch/simple.switch.min.js deleted 100644 → 0
1 -/*!  
2 - * Copyright 2015, Lu Kang  
3 - * WeChat:lukangdaye  
4 - * https://github.com/1029131145/Simple-Switch  
5 - */  
6 -  
7 -(function($){var Switch_Num=0;$.extend($.fn,{simpleSwitch:function(ATTR){var _ATTR={"id":$.simpleSwitch.Id,"theme":$.simpleSwitch.Theme,"end":$.simpleSwitch.End};$.extend(_ATTR,ATTR);var _ALL=$(this),a=_ATTR,_NUM=Switch_Num,_ID=a["id"],_THEME=a["theme"];_ALL.each(function(){var _THIS=$(this);_THIS.hide();_THIS.attr("simpleSwitch",_NUM);_THIS.after('<div class="'+_ID+" "+_ID+"_"+_THEME+'" id="'+_ID+_NUM+'"><div class="SwitchLine"></div><span class="SwitchButton"></span></div>');var _CONTAINER=$("#"+_ID+_NUM);var _type=_THIS.attr("type");var _name=_THIS.attr("name");if(_type=="radio"){_CONTAINER.attr("type",_type+_name)}$.simpleSwitch.Init(this,_CONTAINER);_THIS.change(function(){$.simpleSwitch.Change(this,_CONTAINER,_type,_name)});_CONTAINER.click(function(){$.simpleSwitch.Click(this,_THIS)});_NUM++;a["end"](_THIS,_CONTAINER)});Switch_Num=_NUM}}),$.simpleSwitch=function(){return !0},$.extend($.simpleSwitch,{Id:"Switch",Theme:"Flat",Result:"Result",setTheme:function(theme){$.extend(this.Theme,theme)  
8 -},setDisabled:function(o,i){if(i){$(o).attr("disabled","disabled");$(o).next(".Switch").addClass("Disabled")}else{$(o).removeAttr("disabled");$(o).next(".Switch").removeClass("Disabled")}},Click:function(t,input){input.click()},Change:function(t,cont,type,name){var $T=$(t);var $type=cont.attr("type");if(type){$("div[type='"+$type+"']").removeClass("On");$("input[type='"+type+"'][name='"+name+"']").attr(this.Result,"false")}var checked=$T.attr("checked");if(checked){cont.addClass("On");$T.attr(this.Result,"true")}else{cont.removeClass("On");$T.attr(this.Result,"false")}},Init:function(t,cont){var $T=$(t);var checked=$T.attr("checked");if(checked){cont.addClass("On");$T.attr(this.Result,"true")}else{cont.removeClass("On");$T.attr(this.Result,"false")}if($T.attr("disabled")){cont.addClass("Disabled")}},End:function(t,c){}})})(jQuery);  
9 \ No newline at end of file 0 \ No newline at end of file
src/main/resources/static/simple_switch/simple.switch.three.css deleted 100644 → 0
1 -* {  
2 - box-sizing: border-box !important;  
3 -}  
4 -  
5 -.Switch, .Switch * {  
6 - -webkit-transition-property: all;  
7 - -moz-transition-property: all;  
8 - -o-transition-property: all;  
9 - transition-property: all;  
10 - -webkit-transition-duration: 0.2s;  
11 - -moz-transition-duration: 0.2s;  
12 - -o-transition-duration: 0.2s;  
13 - transition-duration: 0.2s;  
14 - -webkit-transition-delay: 0s;  
15 - -moz-transition-delay: 0s;  
16 - -o-transition-delay: 0s;  
17 - transition-delay: 0s;  
18 -}  
19 -  
20 -/*  
21 -Default  
22 -*/  
23 -.Switch_Default {  
24 - position: relative;  
25 - width: 64px;  
26 - height: 32px;  
27 - cursor: pointer;  
28 - display: inline-block;  
29 - vertical-align: middle;  
30 -}  
31 -  
32 -.Switch_Default .SwitchLine {  
33 - position: absolute;  
34 - width: 60px;  
35 - height: 4px;  
36 - left: 2px;  
37 - top: 14px;  
38 - z-index: 1;  
39 - background-color: #dadada;  
40 -}  
41 -  
42 -.Switch_Default .SwitchButton {  
43 - position: absolute;  
44 - width: 32px;  
45 - height: 32px;  
46 - left: 0;  
47 - top: 0;  
48 - z-index: 2;  
49 - background-color: #dadada;  
50 - border-radius: 32px;  
51 -}  
52 -  
53 -.Switch_Default.On .SwitchLine {  
54 - background-color: #00c0ff;  
55 -}  
56 -  
57 -.Switch_Default.On .SwitchButton {  
58 - left: 32px;  
59 - background-color: #00c0ff;  
60 -}  
61 -  
62 -.Switch_Default.On .SwitchButton {  
63 - left: 32px;  
64 - background-color: #00c0ff;  
65 -}  
66 -  
67 -.Switch_Default.Disabled {  
68 - opacity: 0.3;  
69 -}  
70 -  
71 -.Switch_Default.Disabled .SwitchButton {  
72 - /*opacity:0.5;*/  
73 -  
74 -}  
75 -  
76 -.Switch_Default.On.Disabled .SwitchLine {  
77 - /*opacity:0.5;*/  
78 -  
79 -}  
80 -  
81 -/* DefaultMin */  
82 -.Switch_DefaultMin {  
83 - position: relative;  
84 - width: 48px;  
85 - height: 24px;  
86 - cursor: pointer;  
87 - display: inline-block;  
88 - vertical-align: middle;  
89 -}  
90 -  
91 -.Switch_DefaultMin .SwitchLine {  
92 - position: absolute;  
93 - width: 44px;  
94 - height: 2px;  
95 - left: 2px;  
96 - top: 11px;  
97 - z-index: 1;  
98 - background-color: #dadada;  
99 -}  
100 -  
101 -.Switch_DefaultMin .SwitchButton {  
102 - position: absolute;  
103 - width: 24px;  
104 - height: 24px;  
105 - left: 0;  
106 - top: 0;  
107 - z-index: 2;  
108 - background-color: #dadada;  
109 - border-radius: 24px;  
110 -}  
111 -  
112 -.Switch_DefaultMin.On .SwitchLine {  
113 - background-color: #00c0ff;  
114 -}  
115 -  
116 -.Switch_DefaultMin.On .SwitchButton {  
117 - left: 24px;  
118 - background-color: #00c0ff;  
119 -}  
120 -  
121 -.Switch_DefaultMin.Disabled {  
122 - opacity: 0.3;  
123 -}  
124 -  
125 -.Switch_DefaultMin.Disabled .SwitchButton {  
126 - /*opacity:0.5;*/  
127 -  
128 -}  
129 -  
130 -.Switch_DefaultMin.On.Disabled .SwitchLine {  
131 - /*opacity:0.5;*/  
132 -  
133 -}  
134 -  
135 -/* Flat */  
136 -.Switch_Flat {  
137 - position: relative;  
138 - width: 100px;  
139 - height: 40px;  
140 - cursor: pointer;  
141 - display: inline-block;  
142 - vertical-align: middle;  
143 - background-color: #f5a5a6;  
144 -}  
145 -  
146 -.Switch_Flat .SwitchLine:before {  
147 - position: absolute;  
148 - content: "OFF";  
149 - color: #fff;  
150 - left: 60px;  
151 - top: 9px;  
152 -}  
153 -  
154 -.Switch_Flat .SwitchLine:after {  
155 - position: absolute;  
156 - content: "ON";  
157 - color: #fff;  
158 - left: 15px;  
159 - top: 9px;  
160 -}  
161 -  
162 -.Switch_Flat .SwitchButton {  
163 - position: absolute;  
164 - width: 45px;  
165 - height: 30px;  
166 - left: 5px;  
167 - top: 5px;  
168 - z-index: 2;  
169 - background-color: #fff;  
170 -}  
171 -  
172 -.Switch_Flat .SwitchButton:before {  
173 - position: absolute;  
174 - content: "";  
175 - width: 4px;  
176 - height: 16px;  
177 - left: 15px;  
178 - top: 7px;  
179 - background-color: #f5a5a6;  
180 -}  
181 -  
182 -.Switch_Flat .SwitchButton:after {  
183 - position: absolute;  
184 - content: "";  
185 - width: 4px;  
186 - height: 16px;  
187 - left: 26px;  
188 - top: 7px;  
189 - background-color: #f5a5a6;  
190 -}  
191 -  
192 -.Switch_Flat.On {  
193 - background-color: #a7cce9;  
194 -}  
195 -  
196 -.Switch_Flat.On .SwitchLine {  
197 -  
198 -}  
199 -  
200 -.Switch_Flat.On .SwitchButton {  
201 - left: 50px;  
202 -}  
203 -  
204 -.Switch_Flat.On .SwitchButton:after, .Switch_Flat.On .SwitchButton:before  
205 - {  
206 - background-color: #a7cce9;  
207 -}  
208 -  
209 -.Switch_Flat.Disabled {  
210 - opacity: 0.3;  
211 -}  
212 -  
213 -.Switch_Flat.Disabled .SwitchButton {  
214 - /*opacity:0.5;*/  
215 -  
216 -}  
217 -  
218 -.Switch_Flat.On.Disabled .SwitchLine {  
219 - /*opacity:0.5;*/  
220 -  
221 -}  
222 -  
223 -/* FlatRadius */  
224 -.Switch_FlatRadius {  
225 - position: relative;  
226 - width: 100px;  
227 - height: 40px;  
228 - cursor: pointer;  
229 - display: inline-block;  
230 - vertical-align: middle;  
231 - background-color: #f5a5a6;  
232 - border-radius: 4px;  
233 -}  
234 -  
235 -.Switch_FlatRadius .SwitchLine:before {  
236 - position: absolute;  
237 - content: "OFF";  
238 - color: #fff;  
239 - left: 60px;  
240 - top: 9px;  
241 -}  
242 -  
243 -.Switch_FlatRadius .SwitchLine:after {  
244 - position: absolute;  
245 - content: "ON";  
246 - color: #fff;  
247 - left: 15px;  
248 - top: 9px;  
249 -}  
250 -  
251 -.Switch_FlatRadius .SwitchButton {  
252 - position: absolute;  
253 - width: 45px;  
254 - height: 30px;  
255 - left: 5px;  
256 - top: 5px;  
257 - z-index: 2;  
258 - background-color: #fff;  
259 - border-radius: 4px;  
260 -}  
261 -  
262 -.Switch_FlatRadius .SwitchButton:before {  
263 - position: absolute;  
264 - content: "";  
265 - width: 4px;  
266 - height: 16px;  
267 - left: 15px;  
268 - top: 7px;  
269 - background-color: #f5a5a6;  
270 -}  
271 -  
272 -.Switch_FlatRadius .SwitchButton:after {  
273 - position: absolute;  
274 - content: "";  
275 - width: 4px;  
276 - height: 16px;  
277 - left: 26px;  
278 - top: 7px;  
279 - background-color: #f5a5a6;  
280 -}  
281 -  
282 -.Switch_FlatRadius.On {  
283 - background-color: #a7cce9;  
284 -}  
285 -  
286 -.Switch_FlatRadius.On .SwitchLine {  
287 -  
288 -}  
289 -  
290 -.Switch_FlatRadius.On .SwitchButton {  
291 - left: 50px;  
292 -}  
293 -  
294 -.Switch_FlatRadius.On .SwitchButton:after, .Switch_FlatRadius.On .SwitchButton:before  
295 - {  
296 - background-color: #a7cce9;  
297 -}  
298 -  
299 -.Switch_FlatRadius.Disabled {  
300 - opacity: 0.3;  
301 -}  
302 -  
303 -.Switch_FlatRadius.Disabled .SwitchButton {  
304 - /*opacity:0.5;*/  
305 -  
306 -}  
307 -  
308 -.Switch_FlatRadius.On.Disabled .SwitchLine {  
309 - /*opacity:0.5;*/  
310 -  
311 -}  
312 -  
313 -/* FlatCircular */  
314 -.Switch_FlatCircular {  
315 - position: relative;  
316 - width: 100px;  
317 - height: 40px;  
318 - cursor: pointer;  
319 - display: inline-block;  
320 - vertical-align: middle;  
321 - background-color: #f5a5a6;  
322 - border-radius: 20px;  
323 -}  
324 -  
325 -.Switch_FlatCircular .SwitchLine:before {  
326 - position: absolute;  
327 - content: "OFF";  
328 - color: #fff;  
329 - left: 60px;  
330 - top: 9px;  
331 -}  
332 -  
333 -.Switch_FlatCircular .SwitchLine:after {  
334 - position: absolute;  
335 - content: "ON";  
336 - color: #fff;  
337 - left: 15px;  
338 - top: 9px;  
339 -}  
340 -  
341 -.Switch_FlatCircular .SwitchButton {  
342 - position: absolute;  
343 - width: 46px;  
344 - height: 46px;  
345 - left: -3px;  
346 - top: -3px;  
347 - z-index: 2;  
348 - background-color: #fff;  
349 - border-radius: 45px;  
350 - border: 1px solid #f5a5a6;  
351 -}  
352 -  
353 -.Switch_FlatCircular.On {  
354 - background-color: #a7cce9;  
355 -}  
356 -  
357 -.Switch_FlatCircular.On .SwitchLine {  
358 -  
359 -}  
360 -  
361 -.Switch_FlatCircular.On .SwitchButton {  
362 - border: 1px solid #a7cce9;  
363 - left: 57px;  
364 -}  
365 -  
366 -.Switch_FlatCircular.On .SwitchButton:after, .Switch_FlatCircular.On .SwitchButton:before  
367 - {  
368 - background-color: #a7cce9;  
369 -}  
370 -  
371 -.Switch_FlatCircular.Disabled {  
372 - opacity: 0.3;  
373 -}  
374 -  
375 -.Switch_FlatCircular.Disabled .SwitchButton {  
376 - /*opacity:0.5;*/  
377 -  
378 -}  
379 -  
380 -.Switch_FlatCircular.On.Disabled .SwitchLine {  
381 - /*opacity:0.5;*/  
382 -  
383 -}  
384 -  
385 -/* Green */  
386 -.Switch_Green {  
387 - position: relative;  
388 - width: 100px;  
389 - height: 40px;  
390 - cursor: pointer;  
391 - display: inline-block;  
392 - vertical-align: middle;  
393 - background-color: #b4aa9f;  
394 - border-radius: 20px;  
395 -}  
396 -  
397 -.Switch_Green .SwitchLine:before {  
398 - position: absolute;  
399 - content: "\f00d";  
400 - color: #fff3e3;  
401 - left: 62px;  
402 - top: 8px;  
403 - /*font-awesome*/  
404 - font: normal normal normal 14px/1 FontAwesome !important;  
405 - font-size: 25px !important;  
406 -}  
407 -  
408 -.Switch_Green .SwitchLine:after {  
409 - position: absolute;  
410 - content: "\f00c";  
411 - color: #fff3e3;  
412 - left: 15px;  
413 - top: 8px;  
414 - /*font-awesome*/  
415 - font: normal normal normal 14px/1 FontAwesome !important;  
416 - font-size: 25px !important;  
417 -}  
418 -  
419 -.Switch_Green .SwitchButton {  
420 - position: absolute;  
421 - width: 46px;  
422 - height: 46px;  
423 - left: -3px;  
424 - top: -3px;  
425 - z-index: 2;  
426 - background-color: #fff3e3;  
427 - border-radius: 45px;  
428 - border: 3px solid #b4aa9f;  
429 -}  
430 -  
431 -.Switch_Green.On {  
432 - background-color: #6ebf5f;  
433 -}  
434 -  
435 -.Switch_Green.On .SwitchLine {  
436 -  
437 -}  
438 -  
439 -.Switch_Green.On .SwitchButton {  
440 - border: 3px solid #6ebf5f;  
441 - left: 57px;  
442 -}  
443 -  
444 -.Switch_Green.On .SwitchButton:after, .Switch_Green.On .SwitchButton:before  
445 - {  
446 - background-color: #a7cce9;  
447 -}  
448 -  
449 -.Switch_Green.Disabled {  
450 - opacity: 0.3;  
451 -}  
452 -  
453 -.Switch_Green.Disabled .SwitchButton {  
454 - /*opacity:0.5;*/  
455 -  
456 -}  
457 -  
458 -.Switch_Green.On.Disabled .SwitchLine {  
459 - /*opacity:0.5;*/  
460 -  
461 -}  
462 -  
463 -/* Icon */  
464 -.Switch_Icon {  
465 - position: relative;  
466 - width: 90px;  
467 - height: 50px;  
468 - cursor: pointer;  
469 - display: inline-block;  
470 - vertical-align: middle;  
471 - border-radius: 30px;  
472 - border: 6px solid #fff;  
473 - margin: 0 38px;  
474 -}  
475 -  
476 -.Switch_Icon .SwitchLine:before {  
477 - position: absolute;  
478 - content: "\f1e3";  
479 - color: #1b5a95;  
480 - left: 96px;  
481 - top: 8px;  
482 - /*font-awesome*/  
483 - font: normal normal normal 14px/1 FontAwesome !important;  
484 - font-size: 25px !important;  
485 -}  
486 -  
487 -.Switch_Icon .SwitchLine:after {  
488 - position: absolute;  
489 - content: "\f1db";  
490 - color: #fff;  
491 - left: -42px;  
492 - top: 8px;  
493 - /*font-awesome*/  
494 - font: normal normal normal 14px/1 FontAwesome !important;  
495 - font-size: 25px !important;  
496 -}  
497 -  
498 -.Switch_Icon .SwitchButton {  
499 - position: absolute;  
500 - width: 26px;  
501 - height: 26px;  
502 - left: 6px;  
503 - top: 6px;  
504 - z-index: 2;  
505 - background-color: #fff;  
506 - border-radius: 26px;  
507 -}  
508 -  
509 -.Switch_Icon.On {  
510 -  
511 -}  
512 -  
513 -.Switch_Icon.On .SwitchLine {  
514 -  
515 -}  
516 -  
517 -.Switch_Icon.On .SwitchButton {  
518 - left: 48px;  
519 -}  
520 -  
521 -.Switch_Icon.On .SwitchLine:after {  
522 - color: #1b5a95;  
523 -}  
524 -  
525 -.Switch_Icon.On .SwitchLine:before {  
526 - color: #fff;  
527 -}  
528 -  
529 -.Switch_Icon.Disabled {  
530 - opacity: 0.3;  
531 -}  
532 -  
533 -.Switch_Icon.Disabled .SwitchButton {  
534 - /*opacity:0.5;*/  
535 -  
536 -}  
537 -  
538 -.Switch_Icon.On.Disabled .SwitchLine {  
539 - /*opacity:0.5;*/  
540 -  
541 -}  
542 \ No newline at end of file 0 \ No newline at end of file