|
@@ -50,12 +50,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.Reader;
|
|
|
+import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -1203,15 +1201,19 @@ public class TaskService {
|
|
|
paramMap.put("gjzwfwpt_rtime",String.valueOf(gjzwfwpt_rtime));
|
|
|
paramMap.put("gjzwfwpt_sign",gjzwfwpt_sign);
|
|
|
String http = "http://59.255.22.70:8443/authz/authSystem/getAppSecret";
|
|
|
+ BufferedReader in = null;
|
|
|
+ String response = "";
|
|
|
try {
|
|
|
String data = HttpClientUtils.send(http, paramMap,"utf-8");
|
|
|
System.out.println("/authSystem/getAppSecret返回值------"+data);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
Map<String,Object> map = (Map<String, Object>) jsonObject.get("data");
|
|
|
System.out.println("secret------"+(String) map.get("secret"));
|
|
|
- String my = AESUtil.AESDncode("e72f935d839db74e407ca9fa13cc78b7", (String) map.get("secret"));
|
|
|
- System.out.println("解密------"+my);
|
|
|
-
|
|
|
+ //秘钥 24小时有效
|
|
|
+ String appsecret = AESUtil.AESDncode("e72f935d839db74e407ca9fa13cc78b7", (String) map.get("secret"));
|
|
|
+ System.out.println("解密------"+appsecret);
|
|
|
+ //根据秘钥获得最终签名
|
|
|
+ gjzwfwpt_sign = AESUtil.sign(sb.toString(),appsecret);
|
|
|
|
|
|
//请求url
|
|
|
URL postUrl = new URL("http://59.255.22.70:8443/gateway/wsproxy");
|
|
@@ -1219,10 +1221,10 @@ public class TaskService {
|
|
|
Map<String,String> postParams = new HashMap<String,String>();
|
|
|
//组装参数
|
|
|
//公共请求参数
|
|
|
- postParams.put("access_key", "e72f935d839db74e407ca9fa13cc78b7");
|
|
|
+ postParams.put("access_key", "TE3400003400000001@f6eae674bdc840d2b0474dd3d736faf1");
|
|
|
postParams.put("format","json");
|
|
|
postParams.put("request_id","");
|
|
|
- postParams.put("sign", my);
|
|
|
+ postParams.put("sign", gjzwfwpt_sign);
|
|
|
postParams.put("timestamp",String.valueOf(gjzwfwpt_rtime));
|
|
|
postParams.put("version","1.0");
|
|
|
//请求查询条件参数
|
|
@@ -1247,35 +1249,43 @@ public class TaskService {
|
|
|
postData.append(param.getValue());
|
|
|
}
|
|
|
System.out.println("http://59.255.22.70:8443/gateway/wsproxy参数"+postData.toString());
|
|
|
- byte[] postDataBytes = postData.toString().getBytes("UTF-8");
|
|
|
+ byte[] postDataBytes = postData.toString().getBytes(StandardCharsets.UTF_8);
|
|
|
HttpURLConnection conn = (HttpURLConnection)postUrl.openConnection();
|
|
|
conn.setDoOutput(true);
|
|
|
conn.setDoInput(true);
|
|
|
- conn.setUseCaches(false);
|
|
|
conn.setRequestMethod("POST");
|
|
|
- conn.setRequestProperty("accept", "*/*");
|
|
|
conn.setRequestProperty("connection", "Keep-Alive");
|
|
|
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
|
|
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
|
|
|
conn.setRequestProperty("Content-Length",String.valueOf(postDataBytes.length));
|
|
|
conn.connect();
|
|
|
- conn.getOutputStream().write(postDataBytes);
|
|
|
- Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
|
|
+ OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8");
|
|
|
+ out.write(postData.toString());
|
|
|
+ // flush输出流的缓冲
|
|
|
+ out.flush();
|
|
|
+ // 定义BufferedReader输入流来读取URL的响应
|
|
|
+ in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
|
|
StringBuilder sb1 = new StringBuilder();
|
|
|
for (int c; (c = in.read()) >= 0;){
|
|
|
sb1.append((char)c);
|
|
|
}
|
|
|
//获取查询结果,结果示例见第5条,
|
|
|
- String response = sb1.toString();
|
|
|
-
|
|
|
+ response = sb1.toString();
|
|
|
System.out.println("结果------"+response);
|
|
|
- return response;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ //使用finally块来关闭输出流、输入流
|
|
|
+ finally {
|
|
|
+ try {
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return response;
|
|
|
}
|
|
|
-
|
|
|
}
|