Commit e8f4f55e61450c91bbd846808815e514a8e8fef5

Authored by 潘钊
1 parent fdf2d682

update...

src/main/java/com/bsth/CXFConfig.java
@@ -8,6 +8,7 @@ import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService; @@ -8,6 +8,7 @@ import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
8 import com.bsth.server_rs.base_info.section.LD_SectionRestService; 8 import com.bsth.server_rs.base_info.section.LD_SectionRestService;
9 import com.bsth.server_rs.base_info.station.StationRestService; 9 import com.bsth.server_rs.base_info.station.StationRestService;
10 import com.bsth.server_rs.directive.DirectiveRestService; 10 import com.bsth.server_rs.directive.DirectiveRestService;
  11 +import com.bsth.server_rs.electric.ElectricService;
11 import com.bsth.server_rs.exception.AesExceptionMapper; 12 import com.bsth.server_rs.exception.AesExceptionMapper;
12 import com.bsth.server_rs.gps.GpsRestService; 13 import com.bsth.server_rs.gps.GpsRestService;
13 import com.bsth.server_rs.logs.RealLogRestService; 14 import com.bsth.server_rs.logs.RealLogRestService;
@@ -101,6 +102,8 @@ public class CXFConfig { @@ -101,6 +102,8 @@ public class CXFConfig {
101 DirectiveRestService directiveRestService; 102 DirectiveRestService directiveRestService;
102 @Autowired 103 @Autowired
103 LD_RoadSpeedRestService ld_roadSpeedRestService; 104 LD_RoadSpeedRestService ld_roadSpeedRestService;
  105 + @Autowired
  106 + ElectricService electricService;
104 107
105 @Bean 108 @Bean
106 public Server rsServer() { 109 public Server rsServer() {
@@ -118,7 +121,8 @@ public class CXFConfig { @@ -118,7 +121,8 @@ public class CXFConfig {
118 schedulePlanService, 121 schedulePlanService,
119 realLogRestService, 122 realLogRestService,
120 directiveRestService, 123 directiveRestService,
121 - ld_roadSpeedRestService)); 124 + ld_roadSpeedRestService,
  125 + electricService));
122 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); 126 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
123 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); 127 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
124 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); 128 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
src/main/java/com/bsth/server_rs/electric/ElectricService.java 0 → 100644
  1 +package com.bsth.server_rs.electric;
  2 +
  3 +import com.bsth.server_ws.electric_oil.entity.Electric;
  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 javax.ws.rs.GET;
  12 +import javax.ws.rs.Path;
  13 +import javax.ws.rs.PathParam;
  14 +import javax.ws.rs.Produces;
  15 +import javax.ws.rs.core.MediaType;
  16 +import java.util.List;
  17 +
  18 +/**
  19 + * Created by panzhao on 2018/3/27.
  20 + */
  21 +@Component
  22 +@Path("/electric")
  23 +@Produces({MediaType.APPLICATION_JSON})
  24 +public class ElectricService {
  25 +
  26 + Logger logger = LoggerFactory.getLogger(this.getClass());
  27 +
  28 + @Autowired
  29 + JdbcTemplate jdbcTemplate;
  30 +
  31 + @GET
  32 + @Path("/company/{company}/{rq}")
  33 + public List<Electric> list(@PathParam("company") String company, @PathParam("rq") String rq){
  34 + List<Electric> list = null;
  35 + try {
  36 + //从数据库查询
  37 + list = jdbcTemplate.query("select fgs_bm,fgs_name,gs_bm,gs_name,jdl,jdz,remarks,rq,creater_date,nbbm,jsy from bsth_c_jdl where gs_bm="+company+" and rq='"+rq+"'"
  38 + , BeanPropertyRowMapper.newInstance(Electric.class));
  39 + }catch (Exception e){
  40 + logger.error("", e);
  41 + }
  42 + return list;
  43 + }
  44 +}
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleInOut.java
@@ -41,7 +41,7 @@ public class ScheduleInOut implements Serializable { @@ -41,7 +41,7 @@ public class ScheduleInOut implements Serializable {
41 41
42 ScheduleInOut(){} 42 ScheduleInOut(){}
43 43
44 - ScheduleInOut(ScheduleRealInfo sch){ 44 + public ScheduleInOut(ScheduleRealInfo sch){
45 this.id = sch.getId(); 45 this.id = sch.getId();
46 this.scheduleDateStr = sch.getScheduleDateStr(); 46 this.scheduleDateStr = sch.getScheduleDateStr();
47 this.lineCode = sch.getXlBm(); 47 this.lineCode = sch.getXlBm();
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
1 package com.bsth.server_rs.schedule.real; 1 package com.bsth.server_rs.schedule.real;
2 2
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
3 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
4 import com.bsth.common.BasicData; 6 import com.bsth.common.BasicData;
  7 +import com.bsth.common.ResponseCode;
5 import com.bsth.entity.ScheduleRealInfo; 8 import com.bsth.entity.ScheduleRealInfo;
6 import com.bsth.redis.ScheduleRedisService; 9 import com.bsth.redis.ScheduleRedisService;
7 import com.bsth.server_rs.base_info.line.Line; 10 import com.bsth.server_rs.base_info.line.Line;
@@ -9,20 +12,19 @@ import com.bsth.server_rs.base_info.line.buffer.LineBufferData; @@ -9,20 +12,19 @@ import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
9 import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig; 12 import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig;
10 import com.bsth.server_rs.schedule.dto.ScheduleInOut; 13 import com.bsth.server_rs.schedule.dto.ScheduleInOut;
11 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; 14 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK;
  15 +import com.bsth.util.ConfigUtil;
  16 +import com.bsth.util.HttpClientUtils;
12 import com.google.common.base.Splitter; 17 import com.google.common.base.Splitter;
  18 +import org.apache.commons.lang3.StringUtils;
13 import org.slf4j.Logger; 19 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory; 20 import org.slf4j.LoggerFactory;
15 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Component; 22 import org.springframework.stereotype.Component;
17 23
18 -import javax.ws.rs.GET;  
19 -import javax.ws.rs.Path;  
20 -import javax.ws.rs.PathParam;  
21 -import javax.ws.rs.Produces; 24 +import javax.ws.rs.*;
22 import javax.ws.rs.core.MediaType; 25 import javax.ws.rs.core.MediaType;
23 -import java.util.ArrayList;  
24 -import java.util.List;  
25 -import java.util.Set; 26 +import java.net.URLEncoder;
  27 +import java.util.*;
26 28
27 /** 29 /**
28 * Created by panzhao on 2017/8/24. 30 * Created by panzhao on 2017/8/24.
@@ -40,6 +42,79 @@ public class ScheduleRealService { @@ -40,6 +42,79 @@ public class ScheduleRealService {
40 42
41 Logger logger = LoggerFactory.getLogger(this.getClass()); 43 Logger logger = LoggerFactory.getLogger(this.getClass());
42 44
  45 + static String url;
  46 + static String secretKey;
  47 +
  48 + static {
  49 + secretKey = ConfigUtil.get("http.control.secret.key");
  50 + url = ConfigUtil.get("http.control.service_data_url");// + "/execSchList?secretKey=" + secretKey;
  51 + }
  52 +
  53 + @POST
  54 + @Path("tcc_tzrc")
  55 + public Map<String, Object> tccTzrc(String jsonStr) {
  56 + JSONObject rs = new JSONObject();
  57 + try {
  58 + StringBuilder sb = HttpClientUtils.post(url + "/tccHrhc?secretKey=" + secretKey, jsonStr);
  59 +
  60 + rs = JSONObject.parseObject(sb.toString());
  61 +
  62 + if ("SUCCESS".equals(rs.get("status"))) {
  63 + rs.put("list", ScheduleInOut.getMultiInstance(JSONArray.parseArray(rs.getJSONArray("list").toJSONString(), ScheduleRealInfo.class)));
  64 + }
  65 + } catch (Exception e) {
  66 + logger.error("", e);
  67 + rs.put("status", ResponseCode.ERROR);
  68 + rs.put("msg", "接口服务器出现异常!");
  69 + }
  70 + return rs;
  71 + }
  72 +
  73 + @POST
  74 + @Path("tcc_dftz")
  75 + public Map<String, Object> tccDftz(String jsonStr) {
  76 + JSONObject rs = new JSONObject();
  77 + try {
  78 + StringBuilder sb = HttpClientUtils.post(url + "/dftzAndDestroy?secretKey=" + secretKey, jsonStr);
  79 +
  80 + rs = JSON.parseObject(sb.toString());
  81 +
  82 + if ("SUCCESS".equals(rs.get("status"))) {
  83 + rs.put("t", new ScheduleInOut(JSON.toJavaObject(JSON.parseObject(rs.get("t").toString()), ScheduleRealInfo.class)));
  84 + }
  85 + //ScheduleInOut.getMultiInstance
  86 + } catch (Exception e) {
  87 + logger.error("", e);
  88 + rs.put("status", ResponseCode.ERROR);
  89 + rs.put("msg", "接口服务器出现异常!");
  90 + }
  91 + return rs;
  92 + }
  93 +
  94 + /**
  95 + * 获取路牌下的班次信息
  96 + *
  97 + * @param lineCode
  98 + * @param lpName
  99 + * @return
  100 + */
  101 + @GET
  102 + @Path("/findByLpName/{lineCode}/{lpName}")
  103 + public List<ScheduleRealInfo> findByLpName(@PathParam("lineCode") String lineCode, @PathParam("lpName") String lpName) {
  104 + List<ScheduleRealInfo> list = new ArrayList<>();
  105 + try {
  106 + if (StringUtils.isEmpty(lineCode) || StringUtils.isEmpty(lpName))
  107 + return list;
  108 +
  109 + lpName = URLEncoder.encode(lpName, "UTF-8");
  110 + StringBuilder sb = HttpClientUtils.get(url + "/findByLpName?secretKey=" + secretKey + "&lineCode=" + lineCode + "&lpName=" + lpName);
  111 + list = JSON.parseArray(sb.toString(), ScheduleRealInfo.class);
  112 + } catch (Exception e) {
  113 + logger.error("", e);
  114 + }
  115 + return list;
  116 + }
  117 +
43 /** 118 /**
44 * 获取当天指定停车场的进出场排班数据 119 * 获取当天指定停车场的进出场排班数据
45 * 120 *
@@ -59,13 +134,14 @@ public class ScheduleRealService { @@ -59,13 +134,14 @@ public class ScheduleRealService {
59 134
60 /** 135 /**
61 * 获取指定日期,指定公司的人员车辆配置情况(实际排班) 136 * 获取指定日期,指定公司的人员车辆配置情况(实际排班)
  137 + *
62 * @param company 138 * @param company
63 * @param rq 139 * @param rq
64 * @return 140 * @return
65 */ 141 */
66 @GET 142 @GET
67 @Path("/ccConfig/{company}/{rq}") 143 @Path("/ccConfig/{company}/{rq}")
68 - public List<ScheduleCcInfoConfig> ccInfoConfig(@PathParam("company") String company, @PathParam("rq") String rq){ 144 + public List<ScheduleCcInfoConfig> ccInfoConfig(@PathParam("company") String company, @PathParam("rq") String rq) {
69 List<Line> lines = LineBufferData.findByCompany(company); 145 List<Line> lines = LineBufferData.findByCompany(company);
70 146
71 List<ScheduleCcInfoConfig> all = new ArrayList<>(); 147 List<ScheduleCcInfoConfig> all = new ArrayList<>();
@@ -77,12 +153,13 @@ public class ScheduleRealService { @@ -77,12 +153,13 @@ public class ScheduleRealService {
77 153
78 /** 154 /**
79 * 根据车辆自编号获取对应执行的班次信息 155 * 根据车辆自编号获取对应执行的班次信息
  156 + *
80 * @param nbbm 157 * @param nbbm
81 * @return 158 * @return
82 */ 159 */
83 @GET 160 @GET
84 @Path("/exec/{nbbm}") 161 @Path("/exec/{nbbm}")
85 - public JSONObject getExecPlan(@PathParam("nbbm") String nbbm){ 162 + public JSONObject getExecPlan(@PathParam("nbbm") String nbbm) {
86 return schRealDataBuffer.getExecPlan(nbbm); 163 return schRealDataBuffer.getExecPlan(nbbm);
87 } 164 }
88 165
@@ -104,7 +181,7 @@ public class ScheduleRealService { @@ -104,7 +181,7 @@ public class ScheduleRealService {
104 List<ScheduleRealInfoDTO_JK> all = new ArrayList<>(); 181 List<ScheduleRealInfoDTO_JK> all = new ArrayList<>();
105 182
106 List<Line> lines = LineBufferData.findByCompany(company); 183 List<Line> lines = LineBufferData.findByCompany(company);
107 - for(Line line : lines){ 184 + for (Line line : lines) {
108 all.addAll(ScheduleRealInfoDTO_JK.getMultiInstance(redisService.read(rq, line.getLineCode()))); 185 all.addAll(ScheduleRealInfoDTO_JK.getMultiInstance(redisService.read(rq, line.getLineCode())));
109 } 186 }
110 return all; 187 return all;
@@ -112,27 +189,28 @@ public class ScheduleRealService { @@ -112,27 +189,28 @@ public class ScheduleRealService {
112 189
113 /** 190 /**
114 * 读取指定日期的redis 数据,计算程序调用 191 * 读取指定日期的redis 数据,计算程序调用
  192 + *
115 * @param rqs 193 * @param rqs
116 * @return 194 * @return
117 */ 195 */
118 @GET 196 @GET
119 @Path("/pz_vip/read/{rqs}") 197 @Path("/pz_vip/read/{rqs}")
120 - public List<ScheduleRealInfo> read(@PathParam("rqs") String rqs){ 198 + public List<ScheduleRealInfo> read(@PathParam("rqs") String rqs) {
121 List<ScheduleRealInfo> all = new ArrayList<>(), rs = new ArrayList<>(); 199 List<ScheduleRealInfo> all = new ArrayList<>(), rs = new ArrayList<>();
122 List<Line> lines = LineBufferData.findAll(); 200 List<Line> lines = LineBufferData.findAll();
123 List<String> rqArray = Splitter.on(",").splitToList(rqs); 201 List<String> rqArray = Splitter.on(",").splitToList(rqs);
124 202
125 - for(Line line : lines){  
126 - for(String rq : rqArray) 203 + for (Line line : lines) {
  204 + for (String rq : rqArray)
127 all.addAll(redisService.read(rq, line.getLineCode())); 205 all.addAll(redisService.read(rq, line.getLineCode()));
128 } 206 }
129 207
130 - for(ScheduleRealInfo sch : all){  
131 - if(sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks")) 208 + for (ScheduleRealInfo sch : all) {
  209 + if (sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks"))
132 continue; 210 continue;
133 211
134 //烂班,临加,有子任务的 212 //烂班,临加,有子任务的
135 - if(sch.getStatus()==-1 || sch.isSflj() || (sch.getcTasks()!=null && sch.getcTasks().size() > 0)) 213 + if (sch.getStatus() == -1 || sch.isSflj() || (sch.getcTasks() != null && sch.getcTasks().size() > 0))
136 rs.add(sch); 214 rs.add(sch);
137 } 215 }
138 return rs; 216 return rs;
@@ -140,20 +218,21 @@ public class ScheduleRealService { @@ -140,20 +218,21 @@ public class ScheduleRealService {
140 218
141 /** 219 /**
142 * 读取指定日期线路的redis 数据,计算程序调用 220 * 读取指定日期线路的redis 数据,计算程序调用
  221 + *
143 * @param rq 222 * @param rq
144 * @return 223 * @return
145 */ 224 */
146 @GET 225 @GET
147 @Path("/pz_vip/readByRqAndLine/{rq}/{lineCode}") 226 @Path("/pz_vip/readByRqAndLine/{rq}/{lineCode}")
148 - public List<ScheduleRealInfo> readByLine(@PathParam("rq") String rq,@PathParam("lineCode") String lineCode){ 227 + public List<ScheduleRealInfo> readByLine(@PathParam("rq") String rq, @PathParam("lineCode") String lineCode) {
149 List<ScheduleRealInfo> all = redisService.read(rq, lineCode), rs = new ArrayList<>(); 228 List<ScheduleRealInfo> all = redisService.read(rq, lineCode), rs = new ArrayList<>();
150 229
151 - for(ScheduleRealInfo sch : all){  
152 - if(sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks")) 230 + for (ScheduleRealInfo sch : all) {
  231 + if (sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks"))
153 continue; 232 continue;
154 233
155 //烂班,临加,有子任务的 234 //烂班,临加,有子任务的
156 - if(sch.getStatus()==-1 || sch.isSflj() || (sch.getcTasks()!=null && sch.getcTasks().size() > 0)) 235 + if (sch.getStatus() == -1 || sch.isSflj() || (sch.getcTasks() != null && sch.getcTasks().size() > 0))
157 rs.add(sch); 236 rs.add(sch);
158 } 237 }
159 return rs; 238 return rs;
src/main/java/com/bsth/server_ws/electric_oil/entity/Electric.java
@@ -20,8 +20,6 @@ import java.util.List; @@ -20,8 +20,6 @@ import java.util.List;
20 */ 20 */
21 public class Electric { 21 public class Electric {
22 22
23 - private Electric(){}  
24 -  
25 static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); 23 static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
26 static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); 24 static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
27 25
src/main/java/com/bsth/util/HttpClientUtils.java
@@ -31,8 +31,8 @@ public class HttpClientUtils { @@ -31,8 +31,8 @@ public class HttpClientUtils {
31 HttpGet get = new HttpGet(url); 31 HttpGet get = new HttpGet(url);
32 //超时时间 32 //超时时间
33 RequestConfig requestConfig = RequestConfig.custom() 33 RequestConfig requestConfig = RequestConfig.custom()
34 - .setConnectTimeout(3500).setConnectionRequestTimeout(2000)  
35 - .setSocketTimeout(3500).build(); 34 + .setConnectTimeout(6500).setConnectionRequestTimeout(6000)
  35 + .setSocketTimeout(6500).build();
36 get.setConfig(requestConfig); 36 get.setConfig(requestConfig);
37 get.addHeader("Content-Encoding", "gzip"); 37 get.addHeader("Content-Encoding", "gzip");
38 38