From 6e8d8125bb1958307cc4005de0c56078c1110d15 Mon Sep 17 00:00:00 2001 From: qitz <18810291185@163.com> Date: Wed, 24 Jan 2024 10:18:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BD=92=E6=A1=A3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/dept/MsSealSignRecordMapper.java | 14 +++++ .../mscase/impl/MsSignSealServiceImpl.java | 56 ++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/dept/MsSealSignRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/dept/MsSealSignRecordMapper.java index 9e93c03..c63ca48 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/dept/MsSealSignRecordMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/dept/MsSealSignRecordMapper.java @@ -4,6 +4,7 @@ import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord; import com.ruoyi.wisdomarbitrate.domain.entity.dept.MsSealSignRecord; import org.apache.ibatis.annotations.Select; import tk.mybatis.mapper.common.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -12,4 +13,17 @@ public interface MsSealSignRecordMapper extends Mapper { @Select("SELECT s.id id ,s.case_appli_id caseAppliId ,s.file_id fileId ,s.sign_flow_id signFlowId ,s.sign_flow_status signFlowStatus from ms_seal_sign_record s join ms_case_application c on s.case_appli_id=c.id where s.sign_flow_status in (1,2) ") List selectSealSignRecordbyStat(); + + @Select("") + List selectSealSignRecord(@Param("sealSignRecord") MsSealSignRecord sealSignRecord); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java index 21c590e..16e7e7c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java @@ -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 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); + } + } + } + } }