From 2bbc030c40199ee89c07df3c44a843cf48613110 Mon Sep 17 00:00:00 2001 From: qitz <18810291185@163.com> Date: Sat, 4 Nov 2023 18:32:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/FileTransformation.java | 17 +++++++++-- .../common/utils/file/SaaSAPIFileUtils.java | 2 ++ .../utils/FixSelectFlowDetailUtils.java | 28 +++++++++++++++---- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java index f63a3d9..15091c1 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java @@ -80,6 +80,7 @@ public class FileTransformation { * @return */ public static boolean downLoadFileByUrl(String httpUrl, String dir) throws EsignDemoException { + boolean downLoadFileFlag = false; InputStream fis = null; FileOutputStream fileOutputStream = null; try { @@ -95,10 +96,17 @@ public class FileTransformation { while ((length = fis.read(buffer, 0, 1024)) != -1) { fileOutputStream.write(buffer, 0, length); } + downLoadFileFlag = true; + + System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag); + } catch (IOException e) { EsignDemoException ex = new EsignDemoException("获取文件流异常", e); ex.initCause(e); - throw ex; + + System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag); + + return downLoadFileFlag; } finally { try { if (fis != null) { @@ -110,10 +118,13 @@ public class FileTransformation { } catch (IOException e) { EsignDemoException ex = new EsignDemoException("关闭文件流异常", e); ex.initCause(e); - throw ex; + + System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag); + + return downLoadFileFlag; } } - return true; + return downLoadFileFlag; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java index 814d342..71b52dc 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java @@ -85,6 +85,8 @@ public class SaaSAPIFileUtils { return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true); } + + public static void main(String[] args) throws EsignDemoException { String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx"; EsignHttpResponse uploadUrl = getUploadUrl(filePath); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java index 618b6a3..75b1e9e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java @@ -21,6 +21,8 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.io.File; +import java.io.IOException; import java.time.LocalDate; import java.util.List; import java.util.UUID; @@ -38,6 +40,7 @@ public class FixSelectFlowDetailUtils { private DeptIdentifyMapper deptIdentifyMapper; @Scheduled(cron = "0/10 * * * * ?") +// @Scheduled(cron = "0/30 * * * * ?") @Transactional public void fixExecuteSelectFlowDetailUtils(){ Gson gson = new Gson(); @@ -118,18 +121,29 @@ public class FixSelectFlowDetailUtils { caseApplication.setFilearbitraUrl(filearbitraUrl); caseApplicationMapper.submitCaseApplication(caseApplication); - /* LocalDate now = LocalDate.now(); + LocalDate now = LocalDate.now(); String year = Integer.toString(now.getYear()); String month = String.format("%02d", now.getMonthValue()); String day = String.format("%02d", now.getDayOfMonth()); String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; - String savePath = "/home/ruoyi/uploadPath/upload"; + String savePath = "/home/ruoyi/uploadPath/upload/"; + + // 创建日期目录 + File saveFolder = new File(saveFolderPath); + if (!saveFolder.exists()) { + saveFolder.mkdirs(); + } String resultFilePath = saveFolderPath + "/" + fileName; - String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1); - boolean b = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); - if(b) { + File resultFilePathFile = new File(resultFilePath); + if (!resultFilePathFile.exists()) { + resultFilePathFile.createNewFile(); + } + + String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1); + boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); + if(downLoadFile) { Long caseAppliId = sealSignRecord.getCaseAppliId(); CaseAttach caseAttach = new CaseAttach(); caseAttach.setCaseAppliId(caseAppliId); @@ -137,7 +151,7 @@ public class FixSelectFlowDetailUtils { caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); caseAttachMapper.updateCaseAttachBycaseid(caseAttach); - }*/ + } } } @@ -149,6 +163,8 @@ public class FixSelectFlowDetailUtils { } } catch (EsignDemoException e) { e.printStackTrace(); + }catch (IOException e) { + e.printStackTrace(); } } From 4eb62becc56645f96f59700c51b130a7b3d838ce Mon Sep 17 00:00:00 2001 From: qitz <18810291185@163.com> Date: Sat, 4 Nov 2023 19:42:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=A3=81=E5=86=B3=E4=B9=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/constant/FileTransformation.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java index 15091c1..c1c6384 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java @@ -97,15 +97,9 @@ public class FileTransformation { fileOutputStream.write(buffer, 0, length); } downLoadFileFlag = true; - - System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag); - } catch (IOException e) { EsignDemoException ex = new EsignDemoException("获取文件流异常", e); ex.initCause(e); - - System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag); - return downLoadFileFlag; } finally { try { @@ -118,9 +112,6 @@ public class FileTransformation { } catch (IOException e) { EsignDemoException ex = new EsignDemoException("关闭文件流异常", e); ex.initCause(e); - - System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag); - return downLoadFileFlag; } }