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

This commit was merged in pull request #192.
This commit is contained in:
qtz
2023-11-04 19:47:29 +08:00
committed by Gitea
3 changed files with 29 additions and 9 deletions
@@ -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,11 @@ public class FileTransformation {
while ((length = fis.read(buffer, 0, 1024)) != -1) {
fileOutputStream.write(buffer, 0, length);
}
downLoadFileFlag = true;
} catch (IOException e) {
EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
ex.initCause(e);
throw ex;
return downLoadFileFlag;
} finally {
try {
if (fis != null) {
@@ -110,10 +112,10 @@ public class FileTransformation {
} catch (IOException e) {
EsignDemoException ex = new EsignDemoException("关闭文件流异常", e);
ex.initCause(e);
throw ex;
return downLoadFileFlag;
}
}
return true;
return downLoadFileFlag;
}
@@ -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);
@@ -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();
}
}