优化下载功能
This commit is contained in:
@@ -80,6 +80,7 @@ public class FileTransformation {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean downLoadFileByUrl(String httpUrl, String dir) throws EsignDemoException {
|
public static boolean downLoadFileByUrl(String httpUrl, String dir) throws EsignDemoException {
|
||||||
|
boolean downLoadFileFlag = false;
|
||||||
InputStream fis = null;
|
InputStream fis = null;
|
||||||
FileOutputStream fileOutputStream = null;
|
FileOutputStream fileOutputStream = null;
|
||||||
try {
|
try {
|
||||||
@@ -95,10 +96,17 @@ public class FileTransformation {
|
|||||||
while ((length = fis.read(buffer, 0, 1024)) != -1) {
|
while ((length = fis.read(buffer, 0, 1024)) != -1) {
|
||||||
fileOutputStream.write(buffer, 0, length);
|
fileOutputStream.write(buffer, 0, length);
|
||||||
}
|
}
|
||||||
|
downLoadFileFlag = true;
|
||||||
|
|
||||||
|
System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
|
EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
|
||||||
ex.initCause(e);
|
ex.initCause(e);
|
||||||
throw ex;
|
|
||||||
|
System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag);
|
||||||
|
|
||||||
|
return downLoadFileFlag;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (fis != null) {
|
if (fis != null) {
|
||||||
@@ -110,10 +118,13 @@ public class FileTransformation {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
EsignDemoException ex = new EsignDemoException("关闭文件流异常", e);
|
EsignDemoException ex = new EsignDemoException("关闭文件流异常", e);
|
||||||
ex.initCause(e);
|
ex.initCause(e);
|
||||||
throw ex;
|
|
||||||
|
System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag);
|
||||||
|
|
||||||
|
return downLoadFileFlag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return downLoadFileFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ public class SaaSAPIFileUtils {
|
|||||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws EsignDemoException {
|
public static void main(String[] args) throws EsignDemoException {
|
||||||
String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
|
String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
|
||||||
EsignHttpResponse uploadUrl = getUploadUrl(filePath);
|
EsignHttpResponse uploadUrl = getUploadUrl(filePath);
|
||||||
|
|||||||
+22
-6
@@ -21,6 +21,8 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -38,6 +40,7 @@ public class FixSelectFlowDetailUtils {
|
|||||||
private DeptIdentifyMapper deptIdentifyMapper;
|
private DeptIdentifyMapper deptIdentifyMapper;
|
||||||
|
|
||||||
@Scheduled(cron = "0/10 * * * * ?")
|
@Scheduled(cron = "0/10 * * * * ?")
|
||||||
|
// @Scheduled(cron = "0/30 * * * * ?")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void fixExecuteSelectFlowDetailUtils(){
|
public void fixExecuteSelectFlowDetailUtils(){
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
@@ -118,18 +121,29 @@ public class FixSelectFlowDetailUtils {
|
|||||||
caseApplication.setFilearbitraUrl(filearbitraUrl);
|
caseApplication.setFilearbitraUrl(filearbitraUrl);
|
||||||
caseApplicationMapper.submitCaseApplication(caseApplication);
|
caseApplicationMapper.submitCaseApplication(caseApplication);
|
||||||
|
|
||||||
/* LocalDate now = LocalDate.now();
|
LocalDate now = LocalDate.now();
|
||||||
String year = Integer.toString(now.getYear());
|
String year = Integer.toString(now.getYear());
|
||||||
String month = String.format("%02d", now.getMonthValue());
|
String month = String.format("%02d", now.getMonthValue());
|
||||||
String day = String.format("%02d", now.getDayOfMonth());
|
String day = String.format("%02d", now.getDayOfMonth());
|
||||||
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
||||||
String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
|
String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
|
||||||
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
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 resultFilePath = saveFolderPath + "/" + fileName;
|
||||||
String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
|
File resultFilePathFile = new File(resultFilePath);
|
||||||
boolean b = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
|
if (!resultFilePathFile.exists()) {
|
||||||
if(b) {
|
resultFilePathFile.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
|
||||||
|
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
|
||||||
|
if(downLoadFile) {
|
||||||
Long caseAppliId = sealSignRecord.getCaseAppliId();
|
Long caseAppliId = sealSignRecord.getCaseAppliId();
|
||||||
CaseAttach caseAttach = new CaseAttach();
|
CaseAttach caseAttach = new CaseAttach();
|
||||||
caseAttach.setCaseAppliId(caseAppliId);
|
caseAttach.setCaseAppliId(caseAppliId);
|
||||||
@@ -137,7 +151,7 @@ public class FixSelectFlowDetailUtils {
|
|||||||
caseAttach.setAnnexPath(savePath);
|
caseAttach.setAnnexPath(savePath);
|
||||||
caseAttach.setAnnexName(saveName);
|
caseAttach.setAnnexName(saveName);
|
||||||
caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
|
caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,6 +163,8 @@ public class FixSelectFlowDetailUtils {
|
|||||||
}
|
}
|
||||||
} catch (EsignDemoException e) {
|
} catch (EsignDemoException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user