优化归档功能
This commit is contained in:
+55
-1
@@ -11,6 +11,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ruoyi.common.constant.CaseApplicationConstants;
|
||||
import com.ruoyi.common.constant.FileTransformation;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
@@ -56,6 +57,7 @@ import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -541,7 +543,59 @@ public class MsSignSealServiceImpl implements MsSignSealService {
|
||||
File file = new File(path);
|
||||
// todo 部署放开
|
||||
if (!file.exists()) {
|
||||
return AjaxResult.error("未生成裁决书");
|
||||
Gson gson = new Gson();
|
||||
MsSealSignRecord sealSignRecord = new MsSealSignRecord();
|
||||
sealSignRecord.setCaseAppliId(id);
|
||||
List<MsSealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecord(sealSignRecord);
|
||||
if (sealSignRecords != null && sealSignRecords.size() > 0) {
|
||||
String signFlowid = sealSignRecords.get(0).getSignFlowId();
|
||||
EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowid);
|
||||
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
|
||||
JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
|
||||
JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
|
||||
if (filesArray != null && filesArray.size() > 0) {
|
||||
JsonObject fileObject = (JsonObject) filesArray.get(0);
|
||||
String fileDownloadUrl = fileObject.get("downloadUrl").toString();
|
||||
String filearbitraUrl = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
|
||||
|
||||
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 saveName = fileName;
|
||||
String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||
|
||||
// 创建日期目录
|
||||
File saveFolder = new File(saveFolderPath);
|
||||
if (!saveFolder.exists()) {
|
||||
saveFolder.mkdirs();
|
||||
}
|
||||
String resultFilePath = saveFolderPath + "/" + fileName;
|
||||
File resultFilePathFile = new File(resultFilePath);
|
||||
if (!resultFilePathFile.exists()) {
|
||||
resultFilePathFile.createNewFile();
|
||||
}
|
||||
|
||||
boolean downLoadFile = FileTransformation.downLoadFileByUrl(filearbitraUrl, resultFilePath);
|
||||
if (downLoadFile) {
|
||||
MsCaseAttach caseAttach1 = new MsCaseAttach();
|
||||
caseAttach1.setCaseAppliId(id);
|
||||
caseAttach1.setAnnexType(7);
|
||||
caseAttach1.setAnnexPath(savePath);
|
||||
caseAttach1.setAnnexName(saveName);
|
||||
msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach1);
|
||||
|
||||
caseAttach.setAnnexPath(savePath);
|
||||
caseAttach.setAnnexName(saveName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user