Commit af8d5f6d by 黎配弘

删除一些无效的代码

parent a09b3090
...@@ -36,150 +36,142 @@ import java.security.KeyStoreException; ...@@ -36,150 +36,142 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
public class HTTPSClient { public class HTTPSClient {
/** /**
* 向指定 URL 发送POST方法的请求 * 向指定 URL 发送POST方法的请求
* *
* @param url * @param url 发送请求的 URL
* 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param * @return 所代表远程资源的响应结果
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 */
* @return 所代表远程资源的响应结果 // 不走代理
*/ public static String sendPost(String url, String param) {
// 不走代理 String result = "";
public static String sendPost(String url, String param) { CloseableHttpClient httpClient = HTTPSClient.createSSLClientDefault();
String result = ""; HttpPost post = new HttpPost(url);
CloseableHttpClient httpClient = HTTPSClient.createSSLClientDefault(); StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决
HttpPost post = new HttpPost(url);
StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决 s.setContentType("application/json");
post.setEntity(s);
s.setContentType("application/json"); HttpResponse res;
post.setEntity(s); try {
HttpResponse res; res = httpClient.execute(post);
try { if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
res = httpClient.execute(post); HttpEntity entity = res.getEntity();
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { if (entity.getContentLength() > 0) {
HttpEntity entity = res.getEntity(); String charset = EntityUtils.getContentCharSet(entity);
if (entity.getContentLength() > 0) { org.json.JSONObject response = new org.json.JSONObject(new JSONTokener(new InputStreamReader(entity.getContent(), charset)));
String charset = EntityUtils.getContentCharSet(entity); result = response.toString();
org.json.JSONObject response = new org.json.JSONObject(new JSONTokener(new InputStreamReader(entity.getContent(), charset))); System.out.println(result);
result = response.toString(); }
System.out.println(result); }
}
} } catch (ClientProtocolException e) {
e.printStackTrace();
} catch (ClientProtocolException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IllegalStateException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} catch (JSONException e) { } finally {
e.printStackTrace(); try {
}finally { httpClient.close();
try { } catch (IOException e) {
httpClient.close(); // TODO Auto-generated catch block
} catch (IOException e) { e.printStackTrace();
// TODO Auto-generated catch block }
e.printStackTrace(); }
}
} return result;
}
return result;
} /**
* 向指定 URL 发送POST方法的请求
/** *
* 向指定 URL 发送POST方法的请求 * @param url 发送请求的 URL
* * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param url * @return 所代表远程资源的响应结果
* 发送请求的 URL */
* @param param // 走代理
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 public static String sendPostAgent(String url, String param) {
* @return 所代表远程资源的响应结果 String string = "";
*/
// 走代理 CloseableHttpClient httpClient = HTTPSClient.createSSLClientDefault();
public static String sendPostAgent(String url, String param) { HttpPost httpPost = new HttpPost(url);
String string = ""; StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决
s.setContentType("application/json");
CloseableHttpClient httpClient = HTTPSClient.createSSLClientDefault(); httpPost.setEntity(s);
HttpPost httpPost = new HttpPost(url);
StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决 try {
s.setContentType("application/json"); HttpHost proxy = new HttpHost("172.18.101.170", 3128);
httpPost.setEntity(s); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build();
HttpResponse res;
httpPost.setConfig(requestConfig);
try { CloseableHttpResponse result = httpClient.execute(httpPost);
HttpHost proxy = new HttpHost("172.18.101.170", 3128); string = EntityUtils.toString(result.getEntity(), "utf-8");
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build();
} catch (ClientProtocolException e) {
httpPost.setConfig(requestConfig); e.printStackTrace();
CloseableHttpResponse result = httpClient.execute(httpPost); } catch (IOException e) {
string = EntityUtils.toString(result.getEntity(), "utf-8"); e.printStackTrace();
} catch (IllegalStateException e) {
} catch (ClientProtocolException e) { e.printStackTrace();
e.printStackTrace(); } finally {
} catch (IOException e) { try {
e.printStackTrace(); httpClient.close();
} catch (IllegalStateException e) { } catch (IOException e) {
e.printStackTrace(); // TODO Auto-generated catch block
}finally { e.printStackTrace();
try { }
httpClient.close(); }
} catch (IOException e) {
// TODO Auto-generated catch block return string;
e.printStackTrace(); }
}
} /**
* 向指定 URL 发送POST方法的请求
return string; *
} * @param url 发送请求的 URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
/** * @return 所代表远程资源的响应结果
* 向指定 URL 发送POST方法的请求 */
* public static String sendCodePost(String url, String param) {
* @param url String string = "";
* 发送请求的 URL
* @param param CloseableHttpClient httpClient = HTTPSClient.createSSLClientDefault();
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 HttpPost httpPost = new HttpPost(url);
* @return 所代表远程资源的响应结果 StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决
*/ //s.setContentEncoding("UTF-8");
public static String sendCodePost(String url, String param) {
String string = "";
s.setContentType("application/json");
CloseableHttpClient httpClient = HTTPSClient.createSSLClientDefault(); httpPost.setEntity(s);
HttpPost httpPost = new HttpPost(url); try {
StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决 HttpHost proxy = new HttpHost("172.18.101.170", 3128);
//s.setContentEncoding("UTF-8"); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build();
httpPost.setConfig(requestConfig);
s.setContentType("application/json"); CloseableHttpResponse result = httpClient.execute(httpPost);
httpPost.setEntity(s); string = EntityUtils.toString(result.getEntity(), "utf-8");
HttpResponse res;
try { } catch (ClientProtocolException e) {
HttpHost proxy = new HttpHost("172.18.101.170", 3128); e.printStackTrace();
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build(); } catch (IOException e) {
e.printStackTrace();
httpPost.setConfig(requestConfig); } catch (IllegalStateException e) {
CloseableHttpResponse result = httpClient.execute(httpPost); e.printStackTrace();
string = EntityUtils.toString(result.getEntity(), "utf-8"); } finally {
try {
} catch (ClientProtocolException e) { httpClient.close();
e.printStackTrace(); } catch (IOException e) {
} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { }
e.printStackTrace(); }
}finally {
try { return string;
httpClient.close(); }
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return string;
}
// public static String sendCodePost(String url, String param) { // public static String sendCodePost(String url, String param) {
// String result = ""; // String result = "";
// //
...@@ -225,173 +217,177 @@ public class HTTPSClient { ...@@ -225,173 +217,177 @@ public class HTTPSClient {
// } // }
/** /**
* 向指定 URL 发送POST方法的请求 * 向指定 URL 发送POST方法的请求
* *
* @param url * @param url 发送请求的 URL
* 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param * @return 所代表远程资源的响应结果
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 */
* @return 所代表远程资源的响应结果 public static String sendPosts(String url, String param) {
*/ PrintWriter out = null;
public static String sendPosts(String url, String param) { BufferedReader in = null;
PrintWriter out = null; String result = "";
BufferedReader in = null; // 打开和URL之间的连接
String result = ""; URLConnection conn = null;
// 打开和URL之间的连接 try {
URLConnection conn = null; URL realUrl = new URL(url);
try { conn = realUrl.openConnection();
URL realUrl = new URL(url); // 设置通用的请求属性
conn = realUrl.openConnection(); /// conn.setRequestProperty("accept", "*/*");
// 设置通用的请求属性 // conn.setRequestProperty("connection", "Keep-Alive");
/// conn.setRequestProperty("accept", "*/*"); // conn.setRequestProperty("user-agent",
// conn.setRequestProperty("connection", "Keep-Alive"); // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// conn.setRequestProperty("user-agent", // 发送POST请求必须设置如下两行
// "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setDoOutput(true);
// 发送POST请求必须设置如下两行 conn.setDoInput(true);
conn.setDoOutput(true); // 获取URLConnection对象对应的输出流
conn.setDoInput(true); out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "utf-8"));
// 获取URLConnection对象对应的输出流 // 发送请求参数
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(),"utf-8")); out.print(param);
// 发送请求参数 // flush输出流的缓冲
out.print(param); out.flush();
// flush输出流的缓冲 // 定义BufferedReader输入流来读取URL的响应
out.flush(); in = new BufferedReader(new InputStreamReader(
// 定义BufferedReader输入流来读取URL的响应 conn.getInputStream(), "utf-8"));
in = new BufferedReader(new InputStreamReader( String line;
conn.getInputStream(), "utf-8")); while ((line = in.readLine()) != null) {
String line; result += line;
while ((line = in.readLine()) != null) { }
result += line; } catch (Exception e) {
} System.out.println("发送 POST 请求出现异常!" + e);
} catch (Exception e) { e.printStackTrace();
System.out.println("发送 POST 请求出现异常!" + e); }
e.printStackTrace(); // 使用finally块来关闭输出流、输入流
} finally {
// 使用finally块来关闭输出流、输入流 if (out != null) {
finally { try {
if (out != null) { out.close();
try{ } catch (Exception ex) {
out.close(); }
} catch (Exception ex) {} }
} if (in != null) {
if (in != null) { try {
try{ in.close();
in.close(); } catch (IOException ex) {
} catch (IOException ex) {} }
} }
try{ try {
if (conn.getInputStream() != null) { if (conn.getInputStream() != null) {
conn.getInputStream().close(); conn.getInputStream().close();
} }
} catch (IOException ex) {} } catch (IOException ex) {
}
try{
if (conn.getOutputStream() != null) { try {
conn.getOutputStream().close(); if (conn.getOutputStream() != null) {
} conn.getOutputStream().close();
} catch (IOException ex) {} }
} } catch (IOException ex) {
return result; }
} }
return result;
}
// 原方法 不走代理
public static String sendGet(String url) {
String result = ""; // 原方法 不走代理
HttpClient client = new HttpClient(); public static String sendGet(String url) {
GetMethod getMethod = new GetMethod(url); String result = "";
getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 25000); HttpClient client = new HttpClient();
try { GetMethod getMethod = new GetMethod(url);
int statusCode = client.executeMethod(getMethod); getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 25000);
if (statusCode == HttpStatus.SC_OK) { try {
result = getMethod.getResponseBodyAsString(); // 出现中文乱码 int statusCode = client.executeMethod(getMethod);
// result = new String(getMethod.getResponseBody(),"utf-8"); if (statusCode == HttpStatus.SC_OK) {
} result = getMethod.getResponseBodyAsString(); // 出现中文乱码
} catch (ClientProtocolException e) { // result = new String(getMethod.getResponseBody(),"utf-8");
e.printStackTrace(); }
} catch (IOException e) { } catch (ClientProtocolException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} } catch (IllegalStateException e) {
e.printStackTrace();
return result; }
}
return result;
// 新方法 走代理 }
public static String sendGet2(String url) {
String string = ""; // 新方法 走代理
CloseableHttpClient httpClient = HttpClients.createDefault(); public static String sendGet2(String url) {
HttpPost httpPost = new HttpPost(url); String string = "";
try { CloseableHttpClient httpClient = HttpClients.createDefault();
HttpHost proxy = new HttpHost("172.18.101.170", 3128); HttpPost httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build(); try {
httpPost.setConfig(requestConfig); HttpHost proxy = new HttpHost("172.18.101.170", 3128);
CloseableHttpResponse result = httpClient.execute(httpPost); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build();
string = EntityUtils.toString(result.getEntity(), "utf-8"); ; httpPost.setConfig(requestConfig);
CloseableHttpResponse result = httpClient.execute(httpPost);
} catch (ClientProtocolException e) { string = EntityUtils.toString(result.getEntity(), "utf-8");
e.printStackTrace(); ;
} catch (IOException e) {
e.printStackTrace(); } catch (ClientProtocolException e) {
} catch (IllegalStateException e) { e.printStackTrace();
e.printStackTrace(); } catch (IOException e) {
} e.printStackTrace();
return string; } catch (IllegalStateException e) {
} e.printStackTrace();
}
/** return string;
* 发送xml请求到server端 }
* @param url xml请求数据地址
* @param xmlString 发送的xml数据流 /**
* @return null发送失败,否则返回响应内容 * 发送xml请求到server端
* @throws IOException *
*/ * @param url xml请求数据地址
public static String sendPostXml(String url,String xmlString) throws IOException{ * @param xmlString 发送的xml数据流
* @return null发送失败,否则返回响应内容
* @throws IOException
*/
public static String sendPostXml(String url, String xmlString) throws IOException {
//创建httpclient工具对象 //创建httpclient工具对象
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();
//创建post请求方法 //创建post请求方法
PostMethod myPost = new PostMethod(url); PostMethod myPost = new PostMethod(url);
//设置请求超时时间 //设置请求超时时间
client.setConnectionTimeout(3000*1000); client.setConnectionTimeout(3000 * 1000);
String responseString = null; String responseString = null;
InputStream inputStream = null; InputStream inputStream = null;
BufferedReader br = null; BufferedReader br = null;
try{ try {
//设置请求头部类型 //设置请求头部类型
myPost.setRequestHeader("Content-Type","text/xml"); myPost.setRequestHeader("Content-Type", "text/xml");
myPost.setRequestHeader("charset","utf-8"); myPost.setRequestHeader("charset", "utf-8");
//设置请求体,即xml文本内容,一种是直接获取xml内容字符串,一种是读取xml文件以流的形式 //设置请求体,即xml文本内容,一种是直接获取xml内容字符串,一种是读取xml文件以流的形式
myPost.setRequestBody(xmlString); myPost.setRequestBody(xmlString);
int statusCode = client.executeMethod(myPost); int statusCode = client.executeMethod(myPost);
//只有请求成功200了,才做处理 //只有请求成功200了,才做处理
if(statusCode == HttpStatus.SC_OK){ if (statusCode == HttpStatus.SC_OK) {
inputStream = myPost.getResponseBodyAsStream(); inputStream = myPost.getResponseBodyAsStream();
br = new BufferedReader(new InputStreamReader(inputStream,"utf-8")); br = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
String str = ""; String str = "";
while ((str = br.readLine()) != null) { while ((str = br.readLine()) != null) {
stringBuffer.append(str); stringBuffer.append(str);
} }
responseString = stringBuffer.toString(); responseString = stringBuffer.toString();
} }
}catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally{ } finally {
myPost.releaseConnection(); myPost.releaseConnection();
if(null != inputStream) if (null != inputStream)
inputStream.close(); inputStream.close();
if(null != br) if (null != br)
br.close(); br.close();
} }
return responseString; return responseString;
} }
public static void main(String[] args) throws ClientProtocolException, public static void main(String[] args) throws ClientProtocolException,
IOException, IllegalStateException, JSONException { IOException, IllegalStateException, JSONException {
// String test = "{" // String test = "{"
// + "\"articles\": [" // + "\"articles\": ["
// + "{" // + "{"
...@@ -414,8 +410,8 @@ public class HTTPSClient { ...@@ -414,8 +410,8 @@ public class HTTPSClient {
// + "}" // + "}"
// + "]" // + "]"
// +"}"; // +"}";
// String test = "{" // String test = "{"
// + "\"filter\":{" // + "\"filter\":{"
// + "\"is_to_all\":true" // + "\"is_to_all\":true"
...@@ -425,7 +421,7 @@ public class HTTPSClient { ...@@ -425,7 +421,7 @@ public class HTTPSClient {
// + "}," // + "},"
// + "\"msgtype\":\"mpnews\"" // + "\"msgtype\":\"mpnews\""
// +"}"; // +"}";
// String test = "{" // String test = "{"
// + "\"filter\":{" // + "\"filter\":{"
// + "\"is_to_all\":true" // + "\"is_to_all\":true"
...@@ -441,281 +437,281 @@ public class HTTPSClient { ...@@ -441,281 +437,281 @@ public class HTTPSClient {
// + "}"; // + "}";
// //
// String access = WxInterfacesUtil.getToken("client_credential", WxConfig.APPID, WxConfig.APPSECRET); // String access = WxInterfacesUtil.getToken("client_credential", WxConfig.APPID, WxConfig.APPSECRET);
String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=63jVygxyIkK6oUCeM2YuzZHYLuzrkhSf6eDwmdd2HkXvIxnbfYIzQNMnt7deEWugUUobmyxNrZZa4gEMx1G0wtEJFqofT1sA3yvm9ZVctGPEG0B9DO0L8c3j3cnCC5XtZYRhAEATSL"; String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=63jVygxyIkK6oUCeM2YuzZHYLuzrkhSf6eDwmdd2HkXvIxnbfYIzQNMnt7deEWugUUobmyxNrZZa4gEMx1G0wtEJFqofT1sA3yvm9ZVctGPEG0B9DO0L8c3j3cnCC5XtZYRhAEATSL";
// String urldel = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=" + access; // String urldel = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=" + access;
// String urlup = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" + access; // String urlup = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" + access;
// //
//// ////
// String result = sendPosts(url, test); // String result = sendPosts(url, test);
// String reul = ""; // String reul = "";
// WxInterfacesUtil.sendMessage_text("dd","dd","dd"); // WxInterfacesUtil.sendMessage_text("dd","dd","dd");
PropertiesInit pinit = new PropertiesInit(); PropertiesInit pinit = new PropertiesInit();
pinit.initProperties(); pinit.initProperties();
returnMenu(pinit);
}
returnMenu(pinit); public static String returnMenu(PropertiesInit ppp) {
}
public static String returnMenu(PropertiesInit ppp) {
// WxInterfacesUtil.sendGroupMessage_text("", "", ""); // WxInterfacesUtil.sendGroupMessage_text("", "", "");
JSONObject button = new JSONObject(); JSONObject button = new JSONObject();
try { try {
String Weixin = ppp.getProperties("Weixin"); String Weixin = ppp.getProperties("Weixin");
// part1 // part1
String menu_tdhd = ppp.getProperties("wx_menu_tdhd"); String menu_tdhd = ppp.getProperties("wx_menu_tdhd");
String menu_grhd = ppp.getProperties("wx_menu_grhd"); String menu_grhd = ppp.getProperties("wx_menu_grhd");
String menu_lshd = ppp.getProperties("wx_menu_lshd"); String menu_lshd = ppp.getProperties("wx_menu_lshd");
String menu_ywdj = ppp.getProperties("wx_menu_ywdj"); String menu_ywdj = ppp.getProperties("wx_menu_ywdj");
String menu_xscx = ppp.getProperties("wx_menu_xscx"); String menu_xscx = ppp.getProperties("wx_menu_xscx");
String menu_xsgj = ppp.getProperties("wx_menu_xsgj"); String menu_xsgj = ppp.getProperties("wx_menu_xsgj");
String menu_fhdj = ppp.getProperties("wx_menu_fhdj"); String menu_fhdj = ppp.getProperties("wx_menu_fhdj");
String menu_userInfo = ppp.getProperties("wx_menu_userInfo"); String menu_userInfo = ppp.getProperties("wx_menu_userInfo");
String menu_register = ppp.getProperties("wx_menu_register"); String menu_register = ppp.getProperties("wx_menu_register");
String menu_czzj = ppp.getProperties("wx_menu_czzj"); String menu_czzj = ppp.getProperties("wx_menu_czzj");
String menu_twzf = ppp.getProperties("wx_menu_twzf"); String menu_twzf = ppp.getProperties("wx_menu_twzf");
String menu_yrym = ppp.getProperties("wx_menu_yrym"); String menu_yrym = ppp.getProperties("wx_menu_yrym");
//String menu_blzc = ppp.getProperties("wx_menu_blzc"); //String menu_blzc = ppp.getProperties("wx_menu_blzc");
// part2 // part2
menu_tdhd = URLEncoder.encode(menu_tdhd, "UTF-8"); menu_tdhd = URLEncoder.encode(menu_tdhd, "UTF-8");
menu_grhd = URLEncoder.encode(menu_grhd, "UTF-8"); menu_grhd = URLEncoder.encode(menu_grhd, "UTF-8");
menu_lshd = URLEncoder.encode(menu_lshd, "UTF-8"); menu_lshd = URLEncoder.encode(menu_lshd, "UTF-8");
menu_ywdj = URLEncoder.encode(menu_ywdj, "UTF-8"); menu_ywdj = URLEncoder.encode(menu_ywdj, "UTF-8");
menu_xscx = URLEncoder.encode(menu_xscx, "UTF-8"); menu_xscx = URLEncoder.encode(menu_xscx, "UTF-8");
menu_xsgj = URLEncoder.encode(menu_xsgj, "UTF-8"); menu_xsgj = URLEncoder.encode(menu_xsgj, "UTF-8");
menu_fhdj = URLEncoder.encode(menu_fhdj, "UTF-8"); menu_fhdj = URLEncoder.encode(menu_fhdj, "UTF-8");
menu_userInfo = URLEncoder.encode(menu_userInfo,"UTF-8"); menu_userInfo = URLEncoder.encode(menu_userInfo, "UTF-8");
menu_register = URLEncoder.encode(menu_register, "UTF-8"); menu_register = URLEncoder.encode(menu_register, "UTF-8");
menu_czzj = URLEncoder.encode(menu_czzj,"UTF-8"); menu_czzj = URLEncoder.encode(menu_czzj, "UTF-8");
menu_twzf = URLEncoder.encode(menu_twzf,"UTF-8"); menu_twzf = URLEncoder.encode(menu_twzf, "UTF-8");
menu_yrym = URLEncoder.encode(menu_yrym,"UTF-8"); menu_yrym = URLEncoder.encode(menu_yrym, "UTF-8");
//menu_blzc = URLEncoder.encode(menu_blzc, "UTF-8"); //menu_blzc = URLEncoder.encode(menu_blzc, "UTF-8");
//part3 //part3
menu_tdhd = Weixin.replace("redirect_uri=","redirect_uri=" + menu_tdhd); menu_tdhd = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_tdhd);
menu_grhd = Weixin.replace("redirect_uri=","redirect_uri=" + menu_grhd); menu_grhd = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_grhd);
menu_lshd = Weixin.replace("redirect_uri=","redirect_uri=" + menu_lshd); menu_lshd = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_lshd);
menu_xsgj = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_xsgj); menu_xsgj = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_xsgj);
menu_fhdj = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_fhdj); menu_fhdj = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_fhdj);
menu_ywdj = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_ywdj); menu_ywdj = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_ywdj);
menu_xscx = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_xscx); menu_xscx = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_xscx);
menu_register = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_register); menu_register = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_register);
menu_userInfo = Weixin.replace("redirect_uri=","redirect_uri=" + menu_userInfo); menu_userInfo = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_userInfo);
menu_czzj = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_czzj); menu_czzj = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_czzj);
menu_twzf = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_twzf); menu_twzf = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_twzf);
menu_yrym = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_yrym); menu_yrym = Weixin.replace("redirect_uri=", "redirect_uri=" + menu_yrym);
//menu_blzc = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_blzc); //menu_blzc = Weixin.replace("redirect_uri=", "redirect_uri="+ menu_blzc);
JSONArray menu = new JSONArray(); JSONArray menu = new JSONArray();
JSONArray menuList1 = new JSONArray(); JSONArray menuList1 = new JSONArray();
JSONObject menu1 = new JSONObject(); JSONObject menu1 = new JSONObject();
menu1.put("name", "活动参与"); menu1.put("name", "活动参与");
menu1.put("type", "click"); menu1.put("type", "click");
JSONObject btn11 = new JSONObject(); JSONObject btn11 = new JSONObject();
btn11.put("name", "个人活动参与"); btn11.put("name", "个人活动参与");
btn11.put("key", "m11"); btn11.put("key", "m11");
btn11.put("type", "view"); btn11.put("type", "view");
btn11.put("url", menu_grhd); btn11.put("url", menu_grhd);
JSONObject btn12 = new JSONObject(); JSONObject btn12 = new JSONObject();
btn12.put("name", "团队活动参与"); btn12.put("name", "团队活动参与");
btn12.put("key", "m12"); btn12.put("key", "m12");
btn12.put("type", "view"); btn12.put("type", "view");
btn12.put("url", menu_tdhd); btn12.put("url", menu_tdhd);
JSONObject btn13 = new JSONObject(); JSONObject btn13 = new JSONObject();
btn13.put("name", "历史活动查询"); btn13.put("name", "历史活动查询");
btn13.put("key", "m13"); btn13.put("key", "m13");
btn13.put("type", "view"); btn13.put("type", "view");
btn13.put("url", menu_lshd); btn13.put("url", menu_lshd);
JSONObject btn14 = new JSONObject(); JSONObject btn14 = new JSONObject();
btn14.put("name", "飞行考试"); btn14.put("name", "飞行考试");
btn14.put("key", "m14"); btn14.put("key", "m14");
btn14.put("type", "view"); btn14.put("type", "view");
btn14.put("url", "https://ks.sojump.hk/jq/15330543.aspx"); btn14.put("url", "https://ks.sojump.hk/jq/15330543.aspx");
JSONObject btn15 = new JSONObject(); JSONObject btn15 = new JSONObject();
btn15.put("name", "训练营报名"); btn15.put("name", "训练营报名");
btn15.put("key", "m15"); btn15.put("key", "m15");
btn15.put("type", "view"); btn15.put("type", "view");
btn15.put("url", "https://jinshuju.net/f/wTrBil"); btn15.put("url", "https://jinshuju.net/f/wTrBil");
menuList1.add(btn11); menuList1.add(btn11);
menuList1.add(btn12); menuList1.add(btn12);
menuList1.add(btn13); menuList1.add(btn13);
menuList1.add(btn14); menuList1.add(btn14);
menuList1.add(btn15); menuList1.add(btn15);
menu1.put("sub_button", menuList1); menu1.put("sub_button", menuList1);
menu.add(menu1); menu.add(menu1);
/*********************/ /*********************/
JSONArray menuList2 = new JSONArray(); JSONArray menuList2 = new JSONArray();
JSONObject menu2 = new JSONObject(); JSONObject menu2 = new JSONObject();
menu2.put("name", "业务销售"); menu2.put("name", "业务销售");
menu2.put("key", "m20"); menu2.put("key", "m20");
JSONObject btn21 = new JSONObject(); JSONObject btn21 = new JSONObject();
btn21.put("name", "业务登记"); btn21.put("name", "业务登记");
btn21.put("key", "m21"); btn21.put("key", "m21");
btn21.put("type", "view"); btn21.put("type", "view");
btn21.put("url", menu_ywdj); btn21.put("url", menu_ywdj);
// JSONObject btn22 = new JSONObject(); // JSONObject btn22 = new JSONObject();
// btn22.put("name", "历史销量查询"); // btn22.put("name", "历史销量查询");
// btn22.put("key", "m22"); // btn22.put("key", "m22");
// btn22.put("type", "view"); // btn22.put("type", "view");
// btn22.put("url", menu_xscx); // btn22.put("url", menu_xscx);
JSONObject btn22 = new JSONObject(); JSONObject btn22 = new JSONObject();
btn22.put("name", "放号登记"); btn22.put("name", "放号登记");
btn22.put("key", "m22"); btn22.put("key", "m22");
btn22.put("type", "view"); btn22.put("type", "view");
btn22.put("url", menu_fhdj); btn22.put("url", menu_fhdj);
JSONObject btn23 = new JSONObject(); JSONObject btn23 = new JSONObject();
btn23.put("name", "网络测速"); btn23.put("name", "网络测速");
btn23.put("key", "m23"); btn23.put("key", "m23");
btn23.put("type", "view"); btn23.put("type", "view");
btn23.put("url", "http://tool.cncn.com/cewangsu/"); btn23.put("url", "http://tool.cncn.com/cewangsu/");
JSONObject btn24 = new JSONObject(); JSONObject btn24 = new JSONObject();
btn24.put("name", "小白卡销售"); // 即销售工具 btn24.put("name", "小白卡销售"); // 即销售工具
btn24.put("key", "m24"); btn24.put("key", "m24");
btn24.put("type", "view"); btn24.put("type", "view");
btn24.put("url", menu_xsgj); btn24.put("url", menu_xsgj);
JSONObject btn25 = new JSONObject(); JSONObject btn25 = new JSONObject();
btn25.put("name", "电子传单"); btn25.put("name", "电子传单");
btn25.put("key", "m25"); btn25.put("key", "m25");
btn25.put("type", "view"); btn25.put("type", "view");
btn25.put("url", "http://a.xiumi.us/stage/v5/2Zq72/44772355"); btn25.put("url", "http://a.xiumi.us/stage/v5/2Zq72/44772355");
menuList2.add(btn21); menuList2.add(btn21);
menuList2.add(btn22); menuList2.add(btn22);
menuList2.add(btn23); menuList2.add(btn23);
menuList2.add(btn24); menuList2.add(btn24);
menuList2.add(btn25); menuList2.add(btn25);
menu2.put("sub_button", menuList2); menu2.put("sub_button", menuList2);
/***********************/ /***********************/
JSONArray menuList3 = new JSONArray(); JSONArray menuList3 = new JSONArray();
JSONObject menu3 = new JSONObject(); JSONObject menu3 = new JSONObject();
menu3.put("name", "用户管理"); menu3.put("name", "用户管理");
menu3.put("key", "m30"); menu3.put("key", "m30");
JSONObject btn31 = new JSONObject(); JSONObject btn31 = new JSONObject();
btn31.put("name", "报名加入"); btn31.put("name", "报名加入");
btn31.put("key", "m31"); btn31.put("key", "m31");
btn31.put("type", "view"); btn31.put("type", "view");
btn31.put("url", menu_register); btn31.put("url", menu_register);
// JSONObject btn32 = new JSONObject(); // JSONObject btn32 = new JSONObject();
// btn32.put("name", "部落成员注册"); // btn32.put("name", "部落成员注册");
// btn32.put("key", "m32"); // btn32.put("key", "m32");
// btn32.put("type", "view"); // btn32.put("type", "view");
// btn32.put("url", menu_blzc); // btn32.put("url", menu_blzc);
JSONObject btn32 = new JSONObject(); JSONObject btn32 = new JSONObject();
btn32.put("name", "个人信息"); btn32.put("name", "个人信息");
btn32.put("key", "m32"); btn32.put("key", "m32");
btn32.put("type", "view"); btn32.put("type", "view");
btn32.put("url", menu_userInfo); btn32.put("url", menu_userInfo);
JSONObject btn33 = new JSONObject(); JSONObject btn33 = new JSONObject();
btn33.put("name", "成长足迹"); btn33.put("name", "成长足迹");
btn33.put("key", "m33"); btn33.put("key", "m33");
btn33.put("type", "view"); btn33.put("type", "view");
btn33.put("url", menu_czzj); btn33.put("url", menu_czzj);
JSONObject btn34 = new JSONObject(); JSONObject btn34 = new JSONObject();
btn34.put("name", "推文转发"); btn34.put("name", "推文转发");
btn34.put("key", "m34"); btn34.put("key", "m34");
btn34.put("type", "view"); btn34.put("type", "view");
btn34.put("url", menu_twzf); btn34.put("url", menu_twzf);
JSONObject btn35 = new JSONObject(); JSONObject btn35 = new JSONObject();
btn35.put("name", "一人一码"); btn35.put("name", "一人一码");
btn35.put("key", "m35"); btn35.put("key", "m35");
btn35.put("type", "view"); btn35.put("type", "view");
btn35.put("url", menu_yrym); btn35.put("url", menu_yrym);
menuList3.add(btn31); menuList3.add(btn31);
menuList3.add(btn32); menuList3.add(btn32);
menuList3.add(btn33); menuList3.add(btn33);
menuList3.add(btn34); menuList3.add(btn34);
menuList3.add(btn35); menuList3.add(btn35);
menu3.put("sub_button", menuList3); menu3.put("sub_button", menuList3);
menu.add(menu2); menu.add(menu2);
menu.add(menu3); menu.add(menu3);
button.put("button", menu); button.put("button", menu);
System.out.println(button.toString()); System.out.println(button.toString());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public static String formateURL(String url) { public static String formateURL(String url) {
if (url != null) { if (url != null) {
url = "http://open.plus.yixin.im/connect/oauth2/authorize?appid=9e65cdacfb9e4f3b820031d7af01fceb&redirect_uri=" url = "http://open.plus.yixin.im/connect/oauth2/authorize?appid=9e65cdacfb9e4f3b820031d7af01fceb&redirect_uri="
+ url + url
+ "&response_type=code&scope=snsapi_base&state=from_menu"; + "&response_type=code&scope=snsapi_base&state=from_menu";
return url; return url;
} else { } else {
return null; return null;
} }
} }
public static CloseableHttpClient createSSLClientDefault() { public static CloseableHttpClient createSSLClientDefault() {
try { try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial( SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(
null, new TrustStrategy() { null, new TrustStrategy() {
// 信任所有 // 信任所有
public boolean isTrusted(X509Certificate[] chain, public boolean isTrusted(X509Certificate[] chain,
String authType) throws CertificateException { String authType) throws CertificateException {
return true; return true;
} }
@Override @Override
public boolean isTrusted( public boolean isTrusted(
java.security.cert.X509Certificate[] arg0, java.security.cert.X509Certificate[] arg0,
String arg1) String arg1)
throws java.security.cert.CertificateException { throws java.security.cert.CertificateException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
}).build(); }).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext); sslContext);
return HttpClients.custom().setSSLSocketFactory(sslsf).build(); return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (KeyManagementException e) { } catch (KeyManagementException e) {
e.printStackTrace(); e.printStackTrace();
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
e.printStackTrace(); e.printStackTrace();
} catch (KeyStoreException e) { } catch (KeyStoreException e) {
e.printStackTrace(); e.printStackTrace();
} }
return HttpClients.createDefault(); return HttpClients.createDefault();
} }
} }
\ No newline at end of file
package com.winsun.service.impl; package com.winsun.service.impl;
import com.winsun.auth.core.util.IOUtils;
import com.winsun.bean.ExportExcel; import com.winsun.bean.ExportExcel;
import com.winsun.service.ExportExcelService; import com.winsun.service.ExportExcelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -37,7 +36,20 @@ public class ExportExcelServiceImpl implements ExportExcelService { ...@@ -37,7 +36,20 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} catch (Exception e) { } catch (Exception e) {
log.error("下载excel文件异常" + e.getMessage(), e); log.error("下载excel文件异常" + e.getMessage(), e);
} finally { } finally {
IOUtils.closeQuite(fileInputStream, in); if(fileInputStream != null) {
try {
fileInputStream.close();
} catch (Exception e){
}
}
if(in != null) {
try {
in.close();
} catch (Exception e){
}
}
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment