Commit f11113a56810d9a61cfd2e2b757fe6fb484a114d

Authored by 娄高锋
1 parent 4681a8ec

接口没有改https协议,故改会http请求

src/main/java/com/bsth/realschedule/DataUpload.java
... ... @@ -45,7 +45,7 @@ public class DataUpload {
45 45 * 云平台数据需求对接(建交委)
46 46 * @throws Exception
47 47 */
48   - @Scheduled(cron = "0 00 06 * * ? ")
  48 + @Scheduled(cron = "0 00 06 * * ? ") // 每天凌晨6点
49 49 public void realScheduleUpload() throws Exception{
50 50 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
51 51 SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd");
... ... @@ -205,7 +205,7 @@ public class DataUpload {
205 205 listGroup.add(newList);
206 206 }
207 207  
208   - String json= getHttpInterface("https://180.167.126.126:8992/api/getcode");
  208 + String json= getHttpInterface("http://180.167.126.126:8992/api/getcode");
209 209 Map<String, Object> map=(Map<String, Object>) JSONObject.parse(json);
210 210 String token = encrypt(accessToken, map.get("result").toString());
211 211 String deleteAll = "TRUE";
... ... @@ -218,7 +218,7 @@ public class DataUpload {
218 218 // param.put("DeleteAll", deleteAll);
219 219 // param.put("DataList", JSON.toJSONString(list));
220 220 param.put("list", URLEncoder.encode(JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd HH:mm:ss"), "UTF-8"));
221   - HttpUtils.request("https://180.167.126.126:8992/api/todaybuslinescheduleinfo/addEntityList",
  221 + HttpUtils.request("http://180.167.126.126:8992/api/todaybuslinescheduleinfo/addEntityList",
222 222 new BackClass(), "POST", header, param);
223 223 deleteAll = "FALSE";
224 224 }
... ... @@ -377,7 +377,7 @@ public class DataUpload {
377 377 listGroup.add(newList);
378 378 }
379 379  
380   - String json= getHttpInterface("https://180.167.126.126:8992/api/getcode");
  380 + String json= getHttpInterface("http://180.167.126.126:8992/api/getcode");
381 381 Map<String, Object> map=(Map<String, Object>) JSONObject.parse(json);
382 382 String token = encrypt(accessToken, map.get("result").toString());
383 383 String deleteAll = "TRUE";
... ... @@ -389,8 +389,8 @@ public class DataUpload {
389 389 // param.put("AccessToken", token);
390 390 // param.put("DeleteAll", deleteAll);
391 391 // param.put("DataList", JSON.toJSONString(list));
392   -// param.put("list", URLEncoder.encode(JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd HH:mm:ss"), "UTF-8"));
393   - HttpUtils.request("https://180.167.126.126:8992/api/busdispatchuncarrymileage/addEntityList",
  392 + param.put("list", URLEncoder.encode(JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd HH:mm:ss"), "UTF-8"));
  393 + HttpUtils.request("http://180.167.126.126:8992/api/busdispatchuncarrymileage/addEntityList",
394 394 new BackClass(), "POST", header, param);
395 395 deleteAll = "FALSE";
396 396 }
... ... @@ -568,7 +568,7 @@ public class DataUpload {
568 568 listGroup.add(newList);
569 569 }
570 570  
571   - String json= getHttpInterface("https://180.167.126.126:8992/api/getcode");
  571 + String json= getHttpInterface("http://180.167.126.126:8992/api/getcode");
572 572 Map<String, Object> map=(Map<String, Object>) JSONObject.parse(json);
573 573 String token = encrypt(accessToken, map.get("result").toString());
574 574 String deleteAll = "TRUE";
... ... @@ -580,8 +580,8 @@ public class DataUpload {
580 580 // param.put("AccessToken", token);
581 581 // param.put("DeleteAll", deleteAll);
582 582 // param.put("DataList", JSON.toJSONString(list));
583   -// param.put("list", URLEncoder.encode(JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd HH:mm:ss"), "UTF-8"));
584   - HttpUtils.request("https://180.167.126.126:8992/api/busdispatchundonemileage/addEntityList",
  583 + param.put("list", URLEncoder.encode(JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd HH:mm:ss"), "UTF-8"));
  584 + HttpUtils.request("http://180.167.126.126:8992/api/busdispatchundonemileage/addEntityList",
585 585 new BackClass(), "POST", header, param);
586 586 deleteAll = "FALSE";
587 587 }
... ...
src/main/java/com/bsth/serviec_jk/JkToken.java
... ... @@ -15,7 +15,7 @@ public class JkToken {
15 15 public static String jkdata() {
16 16 try {
17 17 String token ="abfed98867c64fde99f7f88a4532efa8";
18   - String endpoint = "https://180.167.126.126:8992/api/getcode";
  18 + String endpoint = "http://180.167.126.126:8992/api/getcode";
19 19 InputStream in = null;
20 20 try {
21 21 HttpURLConnection con = (HttpURLConnection) new URL(endpoint).openConnection();
... ...
src/main/java/com/bsth/serviec_jk/car_start/CarStartService.java
... ... @@ -33,7 +33,7 @@ public class CarStartService {
33 33 public void listall() throws UnsupportedEncodingException {
34 34 log.info("调用车辆发车信息接口开始---------------");
35 35 long startTime=System.currentTimeMillis();
36   - String url="https://180.167.126.126:8992/api/todaybuslinescheduleshiftinfo/addEntityList";
  36 + String url="http://180.167.126.126:8992/api/todaybuslinescheduleshiftinfo/addEntityList";
37 37 Map<String,Object> map = new HashMap<>();
38 38 //不走缓存,暂时直连数据库
39 39 List<Clfcxxb> list = jdbcTemplate.query("select * from bsth_t_clfcxxb", BeanPropertyRowMapper.newInstance(Clfcxxb.class));
... ...
src/main/java/com/bsth/serviec_jk/xl_basic/HttpService.java
1   -package com.bsth.serviec_jk.xl_basic;
2   -
3   -import com.alibaba.fastjson.JSONObject;
4   -import com.bsth.utils.HttpUtils;
5   -import com.bsth.utils.postUtil;
6   -import org.slf4j.Logger;
7   -import org.slf4j.LoggerFactory;
8   -
9   -import java.io.IOException;
10   -import java.io.UnsupportedEncodingException;
11   -
12   -
13   -public class HttpService {
14   - private final static Logger log = LoggerFactory.getLogger(HttpUtils.class);
15   -
16   - public static int httpRequestResult(JSONObject json, String token, String url, int count){
17   -
18   -
19   -
20   - String result= null;
21   - try {
22   - result = postUtil.send(url, json, "UTF-8", token);
23   - System.out.println(result);
24   - } catch (UnsupportedEncodingException e) {
25   - e.printStackTrace();
26   - } catch (IOException e) {
27   - e.printStackTrace();
28   - }
29   - log.info("返回结果------------------"+result);
30   - if(result !=null){
31   - if(result.indexOf("state")!=-1){
32   - log.info("第"+count+"次调用插入成功!");
33   - return 1;
34   - }else {
35   - log.info("第"+count+"次调用插入失败!");
36   - return -1;
37   - }
38   - }
39   - log.info("第"+count+"次调用插入未返回数据!");
40   - return -1;
41   - }
42   -
43   - public static int httpRequestResulty(String json, String token, String url, int count){
44   - String result= null;
45   - try {
46   - result = postUtil.sendy(url, json, "UTF-8", token);
47   - System.out.println(result);
48   - } catch (UnsupportedEncodingException e) {
49   - e.printStackTrace();
50   - } catch (IOException e) {
51   - e.printStackTrace();
52   - }
53   - log.info("返回结果------------------"+result);
54   - if(result !=null){
55   - if(result.indexOf("state")!=-1){
56   - log.info("第"+count+"次调用插入成功!");
57   - return 1;
58   - }else {
59   - log.info("第"+count+"次调用插入失败!");
60   - return -1;
61   - }
62   - }
63   - log.info("第"+count+"次调用插入未返回数据!");
64   - return -1;
65   - }
66   -}
  1 +package com.bsth.serviec_jk.xl_basic;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.bsth.utils.HttpUtils;
  5 +import com.bsth.utils.postUtil;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +
  9 +import java.io.IOException;
  10 +import java.io.UnsupportedEncodingException;
  11 +
  12 +
  13 +public class HttpService {
  14 + private final static Logger log = LoggerFactory.getLogger(HttpUtils.class);
  15 +
  16 + public static int httpRequestResult(JSONObject json, String token, String url, int count){
  17 +
  18 +
  19 +
  20 + String result= null;
  21 + try {
  22 + result = postUtil.send(url, json, "UTF-8", token);
  23 + System.out.println(result);
  24 + } catch (UnsupportedEncodingException e) {
  25 + e.printStackTrace();
  26 + } catch (IOException e) {
  27 + e.printStackTrace();
  28 + }
  29 + log.info("返回结果------------------"+result);
  30 + if(result !=null){
  31 + if(result.indexOf("state")!=-1){
  32 + log.info("第"+count+"次调用插入成功!");
  33 + return 1;
  34 + }else {
  35 + log.info("第"+count+"次调用插入失败!");
  36 + return -1;
  37 + }
  38 + }
  39 + log.info("第"+count+"次调用插入未返回数据!");
  40 + return -1;
  41 + }
  42 +
  43 + public static int httpRequestResulty(String json, String token, String url, int count){
  44 + String result= null;
  45 + try {
  46 + result = postUtil.sendy(url, json, "UTF-8", token);
  47 + System.out.println(result);
  48 + } catch (UnsupportedEncodingException e) {
  49 + e.printStackTrace();
  50 + } catch (IOException e) {
  51 + e.printStackTrace();
  52 + }
  53 + log.info("返回结果------------------"+result);
  54 + if(result !=null){
  55 + if(result.indexOf("state")!=-1){
  56 + log.info("第"+count+"次调用插入成功!");
  57 + return 1;
  58 + }else {
  59 + log.info("第"+count+"次调用插入失败!");
  60 + return -1;
  61 + }
  62 + }
  63 + log.info("第"+count+"次调用插入未返回数据!");
  64 + return -1;
  65 + }
  66 +}
... ...
src/main/java/com/bsth/serviec_jk/xl_basic/XlBasicService.java
... ... @@ -37,7 +37,7 @@ public class XlBasicService {
37 37 log.info("调用线路基本信息接口开始---------------");
38 38 long startTime=System.currentTimeMillis();
39 39 Map<String,Object> xlmap = new LinkedHashMap<>();
40   - String url = "https://180.167.126.126:8992/api/buslineinfo/insertlist";
  40 + String url = "http://180.167.126.126:8992/api/buslineinfo/insertlist";
41 41 try{
42 42 String password = "6DABD12209BEDAB0808CF7DC967EC2B4C6748277";
43 43 String timestamp = String.valueOf(System.currentTimeMillis());
... ... @@ -171,7 +171,7 @@ public class XlBasicService {
171 171 public void xlparameter(){
172 172 log.info("调用线路参数信息接口开始---------------");
173 173 long startTime=System.currentTimeMillis();
174   - String url = "https://180.167.126.126:8992/api/buslineparmterinfo/insertlist";
  174 + String url = "http://180.167.126.126:8992/api/buslineparmterinfo/insertlist";
175 175 Map<String,Object> xlmap = new HashMap<>();
176 176 try{
177 177 String password = "6DABD12209BEDAB0808CF7DC967EC2B4C6748277";
... ... @@ -306,7 +306,7 @@ public class XlBasicService {
306 306 long startTime=System.currentTimeMillis();
307 307 Map<String,Object> xlmap = new HashMap<>();
308 308 List numlist = new ArrayList();
309   - String url="https://180.167.126.126:8992/api/stationnetpoints/insertlist";
  309 + String url="http://180.167.126.126:8992/api/stationnetpoints/insertlist";
310 310 try{
311 311 String password = "6DABD12209BEDAB0808CF7DC967EC2B4C6748277";
312 312 String timestamp = String.valueOf(System.currentTimeMillis());
... ... @@ -420,7 +420,7 @@ public class XlBasicService {
420 420 long startTime=System.currentTimeMillis();
421 421 Map<String,Object> xlmap = new HashMap<>();
422 422 List numlist = new ArrayList();
423   - String url="https://180.167.126.126:8992/api/buslinenetstation/insertlist";
  423 + String url="http://180.167.126.126:8992/api/buslinenetstation/insertlist";
424 424 try{
425 425 String password = "6DABD12209BEDAB0808CF7DC967EC2B4C6748277";
426 426 String timestamp = String.valueOf(System.currentTimeMillis());
... ...
src/main/java/com/bsth/utils/HttpUtils.java
... ... @@ -68,8 +68,8 @@ public class HttpUtils {
68 68 // con.setRequestProperty("charset", "utf-8");
69 69 con.setDoInput(true);
70 70 con.setDoOutput(true);
71   - con.setReadTimeout(20000);
72   - con.setConnectTimeout(20000);
  71 + con.setReadTimeout(180000);
  72 + con.setConnectTimeout(180000);
73 73  
74 74 if (header.size() > 0) {
75 75 for (Map.Entry<String, String> entry : header.entrySet()) {
... ...
src/main/java/com/bsth/utils/postUtil.java
1   -package com.bsth.utils;
2   -
3   -import com.alibaba.fastjson.JSONObject;
4   -import net.sf.json.JSONArray;
5   -import org.apache.http.HttpEntity;
6   -import org.apache.http.ParseException;
7   -import org.apache.http.client.methods.CloseableHttpResponse;
8   -import org.apache.http.client.methods.HttpPost;
9   -import org.apache.http.entity.StringEntity;
10   -import org.apache.http.impl.client.CloseableHttpClient;
11   -import org.apache.http.impl.client.HttpClients;
12   -import org.apache.http.message.BasicHeader;
13   -import org.apache.http.util.EntityUtils;
14   -import java.io.IOException;
15   -
16   -public class postUtil {
17   -
18   - public static String send(String url, JSONObject jsonObject, String encoding, String token) throws ParseException, IOException {
19   - String body = "";
20   -
21   - CloseableHttpClient client = HttpClients.createDefault();
22   -
23   - HttpPost httpPost = new HttpPost(url);
24   -
25   - StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
26   - s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
27   -
28   - httpPost.setEntity(s);
29   - System.out.println("请求地址:" + url);
30   -
31   - httpPost.setHeader("Content-type", "application/json");
32   - httpPost.setHeader("Access-Token", token);
33   -
34   - CloseableHttpResponse response = client.execute(httpPost);
35   -
36   - HttpEntity entity = response.getEntity();
37   - if (entity != null)
38   - {
39   - body = EntityUtils.toString(entity, encoding);
40   - }
41   - EntityUtils.consume(entity);
42   -
43   - response.close();
44   - return body;
45   - }
46   -
47   - public static String sendy(String url, String object, String encoding, String token) throws ParseException, IOException {
48   - String body = "";
49   -
50   - CloseableHttpClient client = HttpClients.createDefault();
51   -
52   - HttpPost httpPost = new HttpPost(url);
53   -
54   - StringEntity s = new StringEntity(object, "utf-8");
55   - s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
56   -
57   - httpPost.setEntity(s);
58   - System.out.println("请求地址:" + url);
59   -
60   - httpPost.setHeader("Content-type", "application/json");
61   - httpPost.setHeader("Access-Token", token);
62   -
63   - CloseableHttpResponse response = client.execute(httpPost);
64   -
65   - HttpEntity entity = response.getEntity();
66   - if (entity != null)
67   - {
68   - body = EntityUtils.toString(entity, encoding);
69   - }
70   - EntityUtils.consume(entity);
71   -
72   - response.close();
73   - return body;
74   - }
75   -
76   -}
  1 +package com.bsth.utils;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import net.sf.json.JSONArray;
  5 +import org.apache.http.HttpEntity;
  6 +import org.apache.http.ParseException;
  7 +import org.apache.http.client.methods.CloseableHttpResponse;
  8 +import org.apache.http.client.methods.HttpPost;
  9 +import org.apache.http.entity.StringEntity;
  10 +import org.apache.http.impl.client.CloseableHttpClient;
  11 +import org.apache.http.impl.client.HttpClients;
  12 +import org.apache.http.message.BasicHeader;
  13 +import org.apache.http.util.EntityUtils;
  14 +import java.io.IOException;
  15 +
  16 +public class postUtil {
  17 +
  18 + public static String send(String url, JSONObject jsonObject, String encoding, String token) throws ParseException, IOException {
  19 + String body = "";
  20 +
  21 + CloseableHttpClient client = HttpClients.createDefault();
  22 +
  23 + HttpPost httpPost = new HttpPost(url);
  24 +
  25 + StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
  26 + s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
  27 +
  28 + httpPost.setEntity(s);
  29 + System.out.println("请求地址:" + url);
  30 +
  31 + httpPost.setHeader("Content-type", "application/json");
  32 + httpPost.setHeader("Access-Token", token);
  33 +
  34 + CloseableHttpResponse response = client.execute(httpPost);
  35 +
  36 + HttpEntity entity = response.getEntity();
  37 + if (entity != null)
  38 + {
  39 + body = EntityUtils.toString(entity, encoding);
  40 + }
  41 + EntityUtils.consume(entity);
  42 +
  43 + response.close();
  44 + return body;
  45 + }
  46 +
  47 + public static String sendy(String url, String object, String encoding, String token) throws ParseException, IOException {
  48 + String body = "";
  49 +
  50 + CloseableHttpClient client = HttpClients.createDefault();
  51 +
  52 + HttpPost httpPost = new HttpPost(url);
  53 +
  54 + StringEntity s = new StringEntity(object, "utf-8");
  55 + s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
  56 +
  57 + httpPost.setEntity(s);
  58 + System.out.println("请求地址:" + url);
  59 +
  60 + httpPost.setHeader("Content-type", "application/json");
  61 + httpPost.setHeader("Access-Token", token);
  62 +
  63 + CloseableHttpResponse response = client.execute(httpPost);
  64 +
  65 + HttpEntity entity = response.getEntity();
  66 + if (entity != null)
  67 + {
  68 + body = EntityUtils.toString(entity, encoding);
  69 + }
  70 + EntityUtils.consume(entity);
  71 +
  72 + response.close();
  73 + return body;
  74 + }
  75 +
  76 +}
... ...
src/main/resources/application-dev.yml
1   -server:
2   - port: 10010
3   -
4   -management:
5   - port: 9001
6   - address: 127.0.0.1
7   - security:
8   - enabled: false
9   - context-path: /manage
10   -
11   -#DATASOURCE
12   -spring:
13   - datasource:
14   - driver-class-name: com.mysql.jdbc.Driver
15   - url: jdbc:mysql://192.168.168.241/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
16   - username: root
17   - password: root2jsp
18   - max-active: 100
19   - max-idle: 8
20   - min-idle: 8
21   - initial-size: 5
22   - test-on-borrow: true
23   - test-on-connect: true
24   - test-on-return: true
25   - test-while-idle: true
26   - validation-query: select 1
27   -## gateway real data
28   -http:
29   - gps:
30   - real:
  1 +server:
  2 + port: 10010
  3 +
  4 +management:
  5 + port: 9001
  6 + address: 127.0.0.1
  7 + security:
  8 + enabled: false
  9 + context-path: /manage
  10 +
  11 +#DATASOURCE
  12 +spring:
  13 + datasource:
  14 + driver-class-name: com.mysql.jdbc.Driver
  15 +# url: jdbc:mysql://192.168.168.241/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
  16 +# username: root
  17 +# password: root2jsp
  18 + url: jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
  19 + username: root
  20 + password: root
  21 + max-active: 100
  22 + max-idle: 8
  23 + min-idle: 8
  24 + initial-size: 5
  25 + test-on-borrow: true
  26 + test-on-connect: true
  27 + test-on-return: true
  28 + test-while-idle: true
  29 + validation-query: select 1
  30 +## gateway real data
  31 +http:
  32 + gps:
  33 + real:
31 34 url: http://114.80.178.12:18080/transport_server/rtgps/
32 35 \ No newline at end of file
... ...
src/main/resources/application-prod.yml
1   -server:
2   - port: 29088
3   -
4   -management:
5   - port: 9001
6   - address: 127.0.0.1
7   - security:
8   - enabled: false
9   - context-path: /manage
10   -
11   -#DATASOURCE
12   -spring:
13   - datasource:
14   - driver-class-name: com.mysql.jdbc.Driver
15   - url: jdbc:mysql://10.10.200.121/control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
16   - username: root
17   - password: root2jsp
18   - max-active: 100
19   - max-idle: 8
20   - min-idle: 8
21   - initial-size: 5
22   - test-on-borrow: true
23   - test-on-connect: true
24   - test-on-return: true
25   - test-while-idle: true
26   - validation-query: select 1
27   -## gateway real data
28   -http:
29   - gps:
30   - real:
  1 +server:
  2 + port: 29088
  3 +
  4 +management:
  5 + port: 9001
  6 + address: 127.0.0.1
  7 + security:
  8 + enabled: false
  9 + context-path: /manage
  10 +
  11 +#DATASOURCE
  12 +spring:
  13 + datasource:
  14 + driver-class-name: com.mysql.jdbc.Driver
  15 + url: jdbc:mysql://10.10.200.121/control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
  16 + username: root
  17 + password: root2jsp
  18 + max-active: 100
  19 + max-idle: 8
  20 + min-idle: 8
  21 + initial-size: 5
  22 + test-on-borrow: true
  23 + test-on-connect: true
  24 + test-on-return: true
  25 + test-while-idle: true
  26 + validation-query: select 1
  27 +## gateway real data
  28 +http:
  29 + gps:
  30 + real:
31 31 url: http://10.10.200.79:8080/transport_server/rtgps/
32 32 \ No newline at end of file
... ...
src/main/resources/application.yml
1 1 spring:
2 2 profiles:
3 3 active: prod
  4 + #dev,prod
4 5 view:
5 6 suffix: .html
6 7 server:
... ...