Commit 04eef27c964e1c416bfd8b20d59c3273b719be66
Exists in
master
1.fix conflict
Showing
4 changed files
with
69 additions
and
1 deletions
Show diff stats
build.gradle
src/main/java/com/taover/util/UtilExcel.java
| ... | ... | @@ -15,6 +15,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| 15 | 15 | import org.apache.poi.hssf.util.HSSFColor; |
| 16 | 16 | import org.apache.poi.ss.usermodel.Cell; |
| 17 | 17 | import org.apache.poi.ss.usermodel.CellStyle; |
| 18 | +import org.apache.poi.ss.usermodel.CellType; | |
| 18 | 19 | import org.apache.poi.ss.usermodel.Row; |
| 19 | 20 | import org.apache.poi.ss.usermodel.Sheet; |
| 20 | 21 | import org.apache.poi.ss.usermodel.Workbook; |
| ... | ... | @@ -295,6 +296,9 @@ public class UtilExcel { |
| 295 | 296 | dataRow.add(df.format(cell.getNumericCellValue())); |
| 296 | 297 | }else if(cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN){ |
| 297 | 298 | dataRow.add(Boolean.valueOf(cell.getBooleanCellValue())); |
| 299 | + }else if(cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA){ | |
| 300 | + dataRow.add(""+cell.getCellFormula()); | |
| 301 | + //dataRow.add(cell.getNumericCellValue()); | |
| 298 | 302 | }else{ |
| 299 | 303 | dataRow.add(cell.getStringCellValue()); |
| 300 | 304 | } | ... | ... |
src/main/java/com/taover/util/UtilHttpByOkHttp.java
| 1 | 1 | package com.taover.util; |
| 2 | 2 | |
| 3 | +import java.io.File; | |
| 4 | +import java.io.IOException; | |
| 3 | 5 | import java.io.UnsupportedEncodingException; |
| 4 | 6 | import java.net.URLEncoder; |
| 5 | 7 | import java.nio.charset.Charset; |
| ... | ... | @@ -18,10 +20,14 @@ import javax.net.ssl.TrustManager; |
| 18 | 20 | import javax.net.ssl.X509TrustManager; |
| 19 | 21 | |
| 20 | 22 | import okhttp3.FormBody; |
| 23 | +import okhttp3.Headers; | |
| 21 | 24 | import okhttp3.MediaType; |
| 25 | +import okhttp3.MultipartBody; | |
| 22 | 26 | import okhttp3.OkHttpClient; |
| 23 | 27 | import okhttp3.Request; |
| 24 | 28 | import okhttp3.RequestBody; |
| 29 | +import okhttp3.Response; | |
| 30 | +import okhttp3.ResponseBody; | |
| 25 | 31 | |
| 26 | 32 | public class UtilHttpByOkHttp { |
| 27 | 33 | public static final String METHOD_GET = "GET"; |
| ... | ... | @@ -146,6 +152,62 @@ public class UtilHttpByOkHttp { |
| 146 | 152 | return builder.build(); |
| 147 | 153 | } |
| 148 | 154 | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * | |
| 158 | + * @param url 请求地址 | |
| 159 | + * @param filePath 文件路径 | |
| 160 | + * @param fileName 文件名 | |
| 161 | + * @param fileKey 表单上传文件对应的key值 | |
| 162 | + * @param header 请求头 | |
| 163 | + * @return 只发post请求 | |
| 164 | + * @throws Exception | |
| 165 | + */ | |
| 166 | + public static ResponseBody sendPostFile(String url, String filePath, String fileName,String fileKey,Map<String, String> header) throws Exception { | |
| 167 | + OkHttpClient client = new OkHttpClient(); | |
| 168 | + RequestBody requestBody = new MultipartBody.Builder() | |
| 169 | + .setType(MultipartBody.FORM) | |
| 170 | + .addFormDataPart(fileKey, fileName, | |
| 171 | + RequestBody.create(MediaType.parse("multipart/form-data"), new File(filePath))) | |
| 172 | + .build(); | |
| 173 | + | |
| 174 | + Request request = new Request.Builder() | |
| 175 | + .headers(Headers.of(header)) | |
| 176 | + .url(url) | |
| 177 | + .post(requestBody) | |
| 178 | + .build(); | |
| 179 | + | |
| 180 | + Response response = client.newCall(request).execute(); | |
| 181 | + if (!response.isSuccessful()){ | |
| 182 | + throw new IOException("Unexpected code " + response); | |
| 183 | + } | |
| 184 | + return response.body(); | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + public static ResponseBody sendPostFile(String url, File file,String fileKey,Map<String, String> header) throws Exception { | |
| 190 | + OkHttpClient client = new OkHttpClient(); | |
| 191 | + RequestBody requestBody = new MultipartBody.Builder() | |
| 192 | + .setType(MultipartBody.FORM) | |
| 193 | + .addFormDataPart(fileKey, file.getName(), | |
| 194 | + RequestBody.create(MediaType.parse("multipart/form-data"), file)) | |
| 195 | + .build(); | |
| 196 | + | |
| 197 | + Request request = new Request.Builder() | |
| 198 | + .headers(Headers.of(header)) | |
| 199 | + .url(url) | |
| 200 | + .post(requestBody) | |
| 201 | + .build(); | |
| 202 | + | |
| 203 | + Response response = client.newCall(request).execute(); | |
| 204 | + if (!response.isSuccessful()){ | |
| 205 | + throw new IOException("Unexpected code " + response); | |
| 206 | + } | |
| 207 | + return response.body(); | |
| 208 | + } | |
| 209 | + | |
| 210 | + | |
| 149 | 211 | static TrustManager[] trustAllCerts = new TrustManager[]{ |
| 150 | 212 | new X509TrustManager() { |
| 151 | 213 | public java.security.cert.X509Certificate[] getAcceptedIssuers() { | ... | ... |
src/main/java/com/taover/util/UtilPinyin.java
| ... | ... | @@ -5,6 +5,8 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; |
| 5 | 5 | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; |
| 6 | 6 | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; |
| 7 | 7 | |
| 8 | + | |
| 9 | + | |
| 8 | 10 | public class UtilPinyin { |
| 9 | 11 | /** |
| 10 | 12 | * 对单个字进行转换 | ... | ... |