Commit 5cbf24ceeedeec589f76860a57a4761016e7c945
1 parent
04eef27c
Exists in
master
.
Showing
3 changed files
with
23 additions
and
2 deletions
Show diff stats
build.gradle
| @@ -54,7 +54,7 @@ uploadArchives { | @@ -54,7 +54,7 @@ uploadArchives { | ||
| 54 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) | 54 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) |
| 55 | } | 55 | } |
| 56 | pom.project { | 56 | pom.project { |
| 57 | - version '1.1.10' | 57 | + version '1.1.12' |
| 58 | artifactId ARTIFACT_Id | 58 | artifactId ARTIFACT_Id |
| 59 | groupId GROUP_ID | 59 | groupId GROUP_ID |
| 60 | packaging TYPE | 60 | packaging TYPE |
src/main/java/com/taover/util/UtilExcel.java
| @@ -299,6 +299,8 @@ public class UtilExcel { | @@ -299,6 +299,8 @@ public class UtilExcel { | ||
| 299 | }else if(cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA){ | 299 | }else if(cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA){ |
| 300 | dataRow.add(""+cell.getCellFormula()); | 300 | dataRow.add(""+cell.getCellFormula()); |
| 301 | //dataRow.add(cell.getNumericCellValue()); | 301 | //dataRow.add(cell.getNumericCellValue()); |
| 302 | + }else if(cell.getCellType() == HSSFCell.CELL_TYPE_ERROR){ | ||
| 303 | + dataRow.add(""+cell.getErrorCellValue()); | ||
| 302 | }else{ | 304 | }else{ |
| 303 | dataRow.add(cell.getStringCellValue()); | 305 | dataRow.add(cell.getStringCellValue()); |
| 304 | } | 306 | } |
src/main/java/com/taover/util/UtilHttpByOkHttp.java
| @@ -95,7 +95,7 @@ public class UtilHttpByOkHttp { | @@ -95,7 +95,7 @@ public class UtilHttpByOkHttp { | ||
| 95 | return getHttpClient(url).newCall(request).execute().body().bytes(); | 95 | return getHttpClient(url).newCall(request).execute().body().bytes(); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | - private static OkHttpClient getHttpClient(String url){ | 98 | + public static OkHttpClient getHttpClient(String url){ |
| 99 | if(url.trim().toLowerCase().startsWith("https")){ | 99 | if(url.trim().toLowerCase().startsWith("https")){ |
| 100 | return buildOkHttpClientForHttps(); | 100 | return buildOkHttpClientForHttps(); |
| 101 | }else{ | 101 | }else{ |
| @@ -103,6 +103,25 @@ public class UtilHttpByOkHttp { | @@ -103,6 +103,25 @@ public class UtilHttpByOkHttp { | ||
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | + /** | ||
| 107 | + * 并发请求复用连接池,避免内存溢出 | ||
| 108 | + * @param okHttpClient | ||
| 109 | + * @param url | ||
| 110 | + * @param headers | ||
| 111 | + * @param jsonStr | ||
| 112 | + * @return | ||
| 113 | + * @throws Exception | ||
| 114 | + */ | ||
| 115 | + public static String sendPostJson(OkHttpClient okHttpClient,String url, final Map<String, String> headers, String jsonStr) throws Exception{ | ||
| 116 | + //请求体 | ||
| 117 | + RequestBody requestBody = getReqeustBodyJson(jsonStr); | ||
| 118 | + | ||
| 119 | + //http头信息拼装 | ||
| 120 | + Request request = getRequestBuilder(url, headers).post(requestBody).build(); | ||
| 121 | + | ||
| 122 | + return okHttpClient.newCall(request).execute().body().string(); | ||
| 123 | + } | ||
| 124 | + | ||
| 106 | private static RequestBody getReqeustBody(Map<String, Object> params){ | 125 | private static RequestBody getReqeustBody(Map<String, Object> params){ |
| 107 | //表单信息拼装 | 126 | //表单信息拼装 |
| 108 | FormBody.Builder builder = new FormBody.Builder(Charset.forName("UTF-8")); | 127 | FormBody.Builder builder = new FormBody.Builder(Charset.forName("UTF-8")); |