智能仲裁后端服务

FixSelectFlowDetailUtils.java 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package com.ruoyi.wisdomarbitrate.utils;
  2. import com.google.gson.Gson;
  3. import com.google.gson.JsonArray;
  4. import com.google.gson.JsonObject;
  5. import com.ruoyi.common.constant.CaseApplicationConstants;
  6. import com.ruoyi.common.constant.FileTransformation;
  7. import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
  8. import com.ruoyi.common.exception.EsignDemoException;
  9. import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
  10. import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
  11. import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
  12. import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
  13. import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
  14. import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
  15. import com.ruoyi.wisdomarbitrate.mapper.SealSignRecordMapper;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.scheduling.annotation.Scheduled;
  18. import org.springframework.stereotype.Component;
  19. import java.time.LocalDate;
  20. import java.util.List;
  21. import java.util.UUID;
  22. @Component
  23. public class FixSelectFlowDetailUtils {
  24. @Autowired
  25. private CaseApplicationMapper caseApplicationMapper;
  26. @Autowired
  27. private SealSignRecordMapper sealSignRecordMapper;
  28. @Autowired
  29. private CaseAttachMapper caseAttachMapper;
  30. // @Scheduled(cron = "0/3 * * * * ?")
  31. public void fixExecuteSelectFlowDetailUtils() throws EsignDemoException {
  32. Gson gson = new Gson();
  33. SealSignRecord sealSignRecordselect = new SealSignRecord();
  34. // sealSignRecordselect.setSignFlowStatus(1);
  35. List<SealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecordbyStat(sealSignRecordselect);
  36. if(sealSignRecords!=null&&sealSignRecords.size()>0){
  37. for (int i = 0; i < sealSignRecords.size(); i++) {
  38. SealSignRecord sealSignRecord = sealSignRecords.get(i);
  39. EsignHttpResponse signFlowDetail = SignAward.signFlowDetail(sealSignRecord);
  40. JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
  41. JsonObject flowDetailData = signFlowDetailJsonObject.getAsJsonObject("data");
  42. JsonArray signersArray = flowDetailData.get("signers").getAsJsonArray();
  43. Integer psnsignStatus = null;
  44. Integer orgsignStatus = null;
  45. for (int j = 0; j < signersArray.size(); j++) {
  46. JsonObject signerObject = (JsonObject)signersArray.get(j);
  47. if(!(signerObject.get("psnSigner").toString()).equals("null")){
  48. JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner");
  49. if(psnSignerData!=null){
  50. psnsignStatus = signerObject.get("signStatus").getAsInt();
  51. }
  52. }
  53. if(!(signerObject.get("orgSigner").toString()).equals("null")){
  54. JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner");
  55. if(orgSignerData!=null){
  56. orgsignStatus = signerObject.get("signStatus").getAsInt();
  57. }
  58. }
  59. }
  60. if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==1)){
  61. //更新立案申请状态为待用印
  62. CaseApplication caseApplication = new CaseApplication();
  63. caseApplication.setId(sealSignRecord.getCaseAppliId());
  64. CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
  65. if(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.SIGN_ARBITRATION){
  66. caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
  67. caseApplicationMapper.submitCaseApplication(caseApplication);
  68. //修改"签署用印记录表"的状态为待用印
  69. sealSignRecord.setSignFlowStatus(2);
  70. sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
  71. }
  72. }
  73. if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==2)){
  74. //更新立案申请状态为待送达
  75. CaseApplication caseApplication = new CaseApplication();
  76. caseApplication.setId(sealSignRecord.getCaseAppliId());
  77. CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
  78. if(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.ARBITRATED_SEAL){
  79. caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY);
  80. //下载审核完成的裁决书,
  81. String signFlowId = sealSignRecord.getSignFlowid();
  82. EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
  83. JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(),JsonObject.class);
  84. JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
  85. JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
  86. if(filesArray!=null&&filesArray.size()>0){
  87. JsonObject fileObject = (JsonObject)filesArray.get(0);
  88. String fileDownloadUrl = fileObject.get("downloadUrl").toString();
  89. //修改"签署用印记录表"的状态为签署完成
  90. sealSignRecord.setSignFlowStatus(3);
  91. sealSignRecord.setFileDownloadUrl(fileDownloadUrl.substring(1,fileDownloadUrl.length()-1));
  92. sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
  93. String filearbitraUrl = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
  94. caseApplication.setFilearbitraUrl(filearbitraUrl);
  95. caseApplicationMapper.submitCaseApplication(caseApplication);
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }