Commit af8d5f6d by 黎配弘

删除一些无效的代码

parent a09b3090
...@@ -39,10 +39,8 @@ public class HTTPSClient { ...@@ -39,10 +39,8 @@ public class HTTPSClient {
/** /**
* 向指定 URL 发送POST方法的请求 * 向指定 URL 发送POST方法的请求
* *
* @param url * @param url 发送请求的 URL
* 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果 * @return 所代表远程资源的响应结果
*/ */
// 不走代理 // 不走代理
...@@ -75,7 +73,7 @@ public class HTTPSClient { ...@@ -75,7 +73,7 @@ public class HTTPSClient {
e.printStackTrace(); e.printStackTrace();
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
httpClient.close(); httpClient.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -90,10 +88,8 @@ public class HTTPSClient { ...@@ -90,10 +88,8 @@ public class HTTPSClient {
/** /**
* 向指定 URL 发送POST方法的请求 * 向指定 URL 发送POST方法的请求
* *
* @param url * @param url 发送请求的 URL
* 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果 * @return 所代表远程资源的响应结果
*/ */
// 走代理 // 走代理
...@@ -105,7 +101,6 @@ public class HTTPSClient { ...@@ -105,7 +101,6 @@ public class HTTPSClient {
StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决 StringEntity s = new StringEntity(param, "UTF-8"); // 中文乱码在此解决
s.setContentType("application/json"); s.setContentType("application/json");
httpPost.setEntity(s); httpPost.setEntity(s);
HttpResponse res;
try { try {
HttpHost proxy = new HttpHost("172.18.101.170", 3128); HttpHost proxy = new HttpHost("172.18.101.170", 3128);
...@@ -121,7 +116,7 @@ public class HTTPSClient { ...@@ -121,7 +116,7 @@ public class HTTPSClient {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
httpClient.close(); httpClient.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -136,10 +131,8 @@ public class HTTPSClient { ...@@ -136,10 +131,8 @@ public class HTTPSClient {
/** /**
* 向指定 URL 发送POST方法的请求 * 向指定 URL 发送POST方法的请求
* *
* @param url * @param url 发送请求的 URL
* 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果 * @return 所代表远程资源的响应结果
*/ */
public static String sendCodePost(String url, String param) { public static String sendCodePost(String url, String param) {
...@@ -153,7 +146,6 @@ public class HTTPSClient { ...@@ -153,7 +146,6 @@ public class HTTPSClient {
s.setContentType("application/json"); s.setContentType("application/json");
httpPost.setEntity(s); httpPost.setEntity(s);
HttpResponse res;
try { try {
HttpHost proxy = new HttpHost("172.18.101.170", 3128); HttpHost proxy = new HttpHost("172.18.101.170", 3128);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build(); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build();
...@@ -168,7 +160,7 @@ public class HTTPSClient { ...@@ -168,7 +160,7 @@ public class HTTPSClient {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
httpClient.close(); httpClient.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -228,10 +220,8 @@ public class HTTPSClient { ...@@ -228,10 +220,8 @@ public class HTTPSClient {
/** /**
* 向指定 URL 发送POST方法的请求 * 向指定 URL 发送POST方法的请求
* *
* @param url * @param url 发送请求的 URL
* 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果 * @return 所代表远程资源的响应结果
*/ */
public static String sendPosts(String url, String param) { public static String sendPosts(String url, String param) {
...@@ -252,7 +242,7 @@ public class HTTPSClient { ...@@ -252,7 +242,7 @@ public class HTTPSClient {
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
// 获取URLConnection对象对应的输出流 // 获取URLConnection对象对应的输出流
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(),"utf-8")); out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "utf-8"));
// 发送请求参数 // 发送请求参数
out.print(param); out.print(param);
// flush输出流的缓冲 // flush输出流的缓冲
...@@ -271,26 +261,30 @@ public class HTTPSClient { ...@@ -271,26 +261,30 @@ public class HTTPSClient {
// 使用finally块来关闭输出流、输入流 // 使用finally块来关闭输出流、输入流
finally { finally {
if (out != null) { if (out != null) {
try{ try {
out.close(); out.close();
} catch (Exception ex) {} } 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{ try {
if (conn.getOutputStream() != null) { if (conn.getOutputStream() != null) {
conn.getOutputStream().close(); conn.getOutputStream().close();
} }
} catch (IOException ex) {} } catch (IOException ex) {
}
} }
return result; return result;
} }
...@@ -329,7 +323,8 @@ public class HTTPSClient { ...@@ -329,7 +323,8 @@ public class HTTPSClient {
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build(); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(200000).setConnectTimeout(200000).setProxy(proxy).build();
httpPost.setConfig(requestConfig); httpPost.setConfig(requestConfig);
CloseableHttpResponse result = httpClient.execute(httpPost); CloseableHttpResponse result = httpClient.execute(httpPost);
string = EntityUtils.toString(result.getEntity(), "utf-8"); ; string = EntityUtils.toString(result.getEntity(), "utf-8");
;
} catch (ClientProtocolException e) { } catch (ClientProtocolException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -343,32 +338,33 @@ public class HTTPSClient { ...@@ -343,32 +338,33 @@ public class HTTPSClient {
/** /**
* 发送xml请求到server端 * 发送xml请求到server端
*
* @param url xml请求数据地址 * @param url xml请求数据地址
* @param xmlString 发送的xml数据流 * @param xmlString 发送的xml数据流
* @return null发送失败,否则返回响应内容 * @return null发送失败,否则返回响应内容
* @throws IOException * @throws IOException
*/ */
public static String sendPostXml(String url,String xmlString) 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) {
...@@ -376,14 +372,14 @@ public class HTTPSClient { ...@@ -376,14 +372,14 @@ public class HTTPSClient {
} }
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;
...@@ -491,30 +487,30 @@ public class HTTPSClient { ...@@ -491,30 +487,30 @@ public class HTTPSClient {
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();
......
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