Просмотр исходного кода

Merge branch 'qtz3' of SH-Arbitrate/Arbitrate-Backend into dev

qtz 2 лет назад
Родитель
Сommit
d3701b7299

+ 5
- 3
ruoyi-common/src/main/java/com/ruoyi/common/constant/FileTransformation.java Просмотреть файл

@@ -80,6 +80,7 @@ public class FileTransformation {
80 80
      * @return
81 81
      */
82 82
     public static boolean downLoadFileByUrl(String httpUrl, String dir) throws EsignDemoException {
83
+        boolean downLoadFileFlag = false;
83 84
         InputStream fis = null;
84 85
         FileOutputStream fileOutputStream = null;
85 86
         try {
@@ -95,10 +96,11 @@ public class FileTransformation {
95 96
             while ((length = fis.read(buffer, 0, 1024)) != -1) {
96 97
                 fileOutputStream.write(buffer, 0, length);
97 98
             }
99
+            downLoadFileFlag = true;
98 100
         } catch (IOException e) {
99 101
             EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
100 102
             ex.initCause(e);
101
-            throw ex;
103
+            return downLoadFileFlag;
102 104
         } finally {
103 105
             try {
104 106
                 if (fis != null) {
@@ -110,10 +112,10 @@ public class FileTransformation {
110 112
             } catch (IOException e) {
111 113
                 EsignDemoException ex = new EsignDemoException("关闭文件流异常", e);
112 114
                 ex.initCause(e);
113
-                throw ex;
115
+                return downLoadFileFlag;
114 116
             }
115 117
         }
116
-        return true;
118
+        return downLoadFileFlag;
117 119
     }
118 120
 
119 121
 

+ 2
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java Просмотреть файл

@@ -85,6 +85,8 @@ public class SaaSAPIFileUtils {
85 85
         return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
86 86
     }
87 87
 
88
+
89
+
88 90
   public static void main(String[] args) throws EsignDemoException {
89 91
       String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
90 92
         EsignHttpResponse uploadUrl = getUploadUrl(filePath);

+ 22
- 6
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java Просмотреть файл

@@ -21,6 +21,8 @@ import org.springframework.scheduling.annotation.Scheduled;
21 21
 import org.springframework.stereotype.Component;
22 22
 import org.springframework.transaction.annotation.Transactional;
23 23
 
24
+import java.io.File;
25
+import java.io.IOException;
24 26
 import java.time.LocalDate;
25 27
 import java.util.List;
26 28
 import java.util.UUID;
@@ -38,6 +40,7 @@ public class FixSelectFlowDetailUtils {
38 40
     private DeptIdentifyMapper deptIdentifyMapper;
39 41
 
40 42
     @Scheduled(cron = "0/10 * * * * ?")
43
+//    @Scheduled(cron = "0/30 * * * * ?")
41 44
     @Transactional
42 45
     public void fixExecuteSelectFlowDetailUtils(){
43 46
         Gson gson = new Gson();
@@ -118,18 +121,29 @@ public class FixSelectFlowDetailUtils {
118 121
                                     caseApplication.setFilearbitraUrl(filearbitraUrl);
119 122
                                     caseApplicationMapper.submitCaseApplication(caseApplication);
120 123
 
121
-                     /*               LocalDate now = LocalDate.now();
124
+                                    LocalDate now = LocalDate.now();
122 125
                                     String year = Integer.toString(now.getYear());
123 126
                                     String month = String.format("%02d", now.getMonthValue());
124 127
                                     String day = String.format("%02d", now.getDayOfMonth());
125 128
                                     String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
126 129
                                     String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
127 130
                                     String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
128
-                                    String savePath = "/home/ruoyi/uploadPath/upload";
131
+                                    String savePath = "/home/ruoyi/uploadPath/upload/";
132
+
133
+                                    // 创建日期目录
134
+                                    File saveFolder = new File(saveFolderPath);
135
+                                    if (!saveFolder.exists()) {
136
+                                        saveFolder.mkdirs();
137
+                                    }
129 138
                                     String resultFilePath = saveFolderPath + "/" + fileName;
130
-                                    String fileDownloadUrlnew  = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
131
-                                    boolean b = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
132
-                                   if(b) {
139
+                                    File resultFilePathFile  = new File(resultFilePath);
140
+                                    if (!resultFilePathFile.exists()) {
141
+                                        resultFilePathFile.createNewFile();
142
+                                    }
143
+
144
+                                   String fileDownloadUrlnew  = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
145
+                                   boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
146
+                                   if(downLoadFile) {
133 147
                                        Long caseAppliId = sealSignRecord.getCaseAppliId();
134 148
                                        CaseAttach caseAttach = new CaseAttach();
135 149
                                        caseAttach.setCaseAppliId(caseAppliId);
@@ -137,7 +151,7 @@ public class FixSelectFlowDetailUtils {
137 151
                                        caseAttach.setAnnexPath(savePath);
138 152
                                        caseAttach.setAnnexName(saveName);
139 153
                                        caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
140
-                                   }*/
154
+                                   }
141 155
 
142 156
                                 }
143 157
                             }
@@ -149,6 +163,8 @@ public class FixSelectFlowDetailUtils {
149 163
             }
150 164
         } catch (EsignDemoException e) {
151 165
             e.printStackTrace();
166
+        }catch (IOException e) {
167
+            e.printStackTrace();
152 168
         }
153 169
 
154 170
     }