Merge branch 'qtz' of SH-Arbitrate/Mediation-Backend into dev

This commit was merged in pull request #40.
This commit is contained in:
qtz
2024-01-24 10:24:07 +08:00
committed by Gitea
2 changed files with 69 additions and 1 deletions
@@ -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<MsSealSignRecord> {
@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<MsSealSignRecord> selectSealSignRecordbyStat();
@Select("<script> SELECT s.id id ,s.case_appli_id caseAppliId ,s.file_id fileId ,s.sign_flow_id signFlowId,s.penson_account pensonAccount ,s.orgnize_name orgnizeName ,s.orgn_name_psn_acc orgnNamePsnAcc " +
" from ms_seal_sign_record s " +
" <where> " +
" <if test=\"sealSignRecord.signFlowStatus != null \"> " +
" AND s.sign_flow_status = #{sealSignRecord.signFlowStatus} " +
" </if> " +
" <if test=\"sealSignRecord.caseAppliId != null \"> " +
" AND s.case_appli_id = #{sealSignRecord.caseAppliId} " +
" </if> " +
" </where> " +
" </script>")
List<MsSealSignRecord> selectSealSignRecord(@Param("sealSignRecord") MsSealSignRecord sealSignRecord);
}
@@ -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);
}
}
}
}
}