智能仲裁后端服务

FixSelectFlowDetailUtils.java 5.7KB

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