|
|
@@ -249,7 +249,7 @@ public class PaymentRsaDownloadJob {
|
|
|
if (inputStream != null) {
|
|
|
inputStream.close();
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
@@ -261,78 +261,97 @@ public class PaymentRsaDownloadJob {
|
|
|
* @param zipInputStream
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public static void decompressionFile(String outPath, ZipInputStream zipInputStream, HlwPayment hlwPayment) throws IOException {
|
|
|
+ public static void decompressionFile(String outPath, ZipInputStream zipInputStream, HlwPayment hlwPayment) {
|
|
|
//读取一个目录
|
|
|
- ZipEntry nextEntry = zipInputStream.getNextEntry();
|
|
|
+ ZipEntry nextEntry = null;
|
|
|
+ try {
|
|
|
+ nextEntry = zipInputStream.getNextEntry();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
//不为空进入循环
|
|
|
while (nextEntry != null) {
|
|
|
//包含后缀
|
|
|
String name = nextEntry.getName();
|
|
|
- // 创建文件根目录
|
|
|
+ // 创建临时文件根目录
|
|
|
File file = new File(outPath);
|
|
|
if (!file.exists()) {
|
|
|
file.mkdirs();
|
|
|
}
|
|
|
String localFilePath = outPath + "/" + name;
|
|
|
- File fileObject = new File(localFilePath);
|
|
|
- //文件则写入具体的路径中
|
|
|
- FileOutputStream fileOutputStream = new FileOutputStream(fileObject);
|
|
|
- BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
|
|
|
- int n;
|
|
|
- byte[] bytes = new byte[1024];
|
|
|
- while ((n = zipInputStream.read(bytes)) != -1) {
|
|
|
- bufferedOutputStream.write(bytes, 0, n);
|
|
|
- }
|
|
|
- //关闭流
|
|
|
- bufferedOutputStream.close();
|
|
|
- fileOutputStream.close();
|
|
|
- //上传oss
|
|
|
- //完整路径
|
|
|
- String objectName = "";
|
|
|
- //文件上传的业务路径
|
|
|
- String uploadPath = "/hpwisdom/hlwPaymentRsa";
|
|
|
- //获取当前年月
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- int year = cal.get(Calendar.YEAR);
|
|
|
- int month = cal.get(Calendar.MONTH) + 1;
|
|
|
- String fileDir = USERFILES_BASE_URL + uploadPath + "/admin" + "/" + year + "/" + month + "/";
|
|
|
- fileDir = fileDir + System.nanoTime() + "/";
|
|
|
- String fileName = name;
|
|
|
- objectName = fileDir + fileName;
|
|
|
- //读取本地文件流
|
|
|
- File fileUpload = new File(localFilePath);
|
|
|
- InputStream inputStream = new FileInputStream(fileUpload);
|
|
|
- //上传oss
|
|
|
- iOssClientUtil.uploadFileOSS(inputStream, objectName);
|
|
|
- //上传后的文件路径
|
|
|
- String filePath = "/" + objectName;
|
|
|
- log.info("dff==={}", filePath);
|
|
|
- /**
|
|
|
- * 区分打印模式(S:逐笔打印:每笔明细生成一个PDF文件 M:批量打印)
|
|
|
- */
|
|
|
- if ("M".equals(printMode)) {
|
|
|
- //更新付款表
|
|
|
- hlwPayment.setStatementUrl(filePath);
|
|
|
- iHlwPaymentService.updateById(hlwPayment);
|
|
|
- } else {
|
|
|
- //付款明细
|
|
|
- QueryWrapper<HlwPaymentDetail> queryWrapperDetail = new QueryWrapper<>();
|
|
|
- queryWrapperDetail.eq("payment_id", hlwPayment.getId());
|
|
|
- List<HlwPaymentDetail> detailList = iHlwPaymentDetailService.list(queryWrapperDetail);
|
|
|
- for (HlwPaymentDetail hlwPaymentDetail : detailList) {
|
|
|
- //文件名称是否包含银行卡号
|
|
|
- if (name.contains(hlwPaymentDetail.getCardNumber())) {
|
|
|
- hlwPaymentDetail.setStatementUrl(filePath);
|
|
|
- iHlwPaymentDetailService.updateById(hlwPaymentDetail);
|
|
|
- break;
|
|
|
+ File fileObject = null;
|
|
|
+ FileOutputStream fileOutputStream = null;
|
|
|
+ try {
|
|
|
+ fileObject = new File(localFilePath);
|
|
|
+ //文件则写入具体的路径中
|
|
|
+ fileOutputStream = new FileOutputStream(fileObject);
|
|
|
+ int n;
|
|
|
+ byte[] bytes = new byte[1024];
|
|
|
+ while ((n = zipInputStream.read(bytes)) != -1) {
|
|
|
+ fileOutputStream.write(bytes, 0, n);
|
|
|
+ fileOutputStream.flush();
|
|
|
+ }
|
|
|
+ //上传oss
|
|
|
+ //完整路径
|
|
|
+ String objectName = "";
|
|
|
+ //文件上传的业务路径
|
|
|
+ String uploadPath = "/hpwisdom/hlwPaymentRsa";
|
|
|
+ //获取当前年月
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ int year = cal.get(Calendar.YEAR);
|
|
|
+ int month = cal.get(Calendar.MONTH) + 1;
|
|
|
+ String fileDir = USERFILES_BASE_URL + uploadPath + "/admin" + "/" + year + "/" + month + "/";
|
|
|
+ fileDir = fileDir + System.nanoTime() + "/";
|
|
|
+ String fileName = name;
|
|
|
+ objectName = fileDir + fileName;
|
|
|
+ //读取本地文件流
|
|
|
+ File fileUpload = new File(localFilePath);
|
|
|
+ InputStream inputStream = new FileInputStream(fileUpload);
|
|
|
+ //上传oss
|
|
|
+ iOssClientUtil.uploadFileOSS(inputStream, objectName);
|
|
|
+ //上传后的文件路径
|
|
|
+ String filePath = "/" + objectName;
|
|
|
+ log.info("dff==={}", filePath);
|
|
|
+ //删除临时文件
|
|
|
+ fileObject.delete();
|
|
|
+ /**
|
|
|
+ * 区分打印模式(S:逐笔打印:每笔明细生成一个PDF文件 M:批量打印)
|
|
|
+ */
|
|
|
+ if ("M".equals(printMode)) {
|
|
|
+ //更新付款表
|
|
|
+ hlwPayment.setStatementUrl(filePath);
|
|
|
+ iHlwPaymentService.updateById(hlwPayment);
|
|
|
+ } else {
|
|
|
+ //付款明细
|
|
|
+ QueryWrapper<HlwPaymentDetail> queryWrapperDetail = new QueryWrapper<>();
|
|
|
+ queryWrapperDetail.eq("payment_id", hlwPayment.getId());
|
|
|
+ List<HlwPaymentDetail> detailList = iHlwPaymentDetailService.list(queryWrapperDetail);
|
|
|
+ for (HlwPaymentDetail hlwPaymentDetail : detailList) {
|
|
|
+ //文件名称是否包含银行卡号
|
|
|
+ if (name.contains(hlwPaymentDetail.getCardNumber())) {
|
|
|
+ hlwPaymentDetail.setStatementUrl(filePath);
|
|
|
+ iHlwPaymentDetailService.updateById(hlwPaymentDetail);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //关闭当前布姆
|
|
|
+ zipInputStream.closeEntry();
|
|
|
+ //读取下一个目录,作为循环条件
|
|
|
+ nextEntry = zipInputStream.getNextEntry();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (fileOutputStream != null) {
|
|
|
+ //关闭流
|
|
|
+ fileOutputStream.close();
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- //关闭当前布姆
|
|
|
- zipInputStream.closeEntry();
|
|
|
- //读取下一个目录,作为循环条件
|
|
|
- nextEntry = zipInputStream.getNextEntry();
|
|
|
}
|
|
|
}
|
|
|
|