智能仲裁后端服务

FixSelectFlowDetailUtils.java 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.DeptIdentify;
  13. import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
  14. import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
  15. import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
  16. import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
  17. import com.ruoyi.wisdomarbitrate.mapper.SealSignRecordMapper;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.scheduling.annotation.Scheduled;
  20. import org.springframework.stereotype.Component;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import java.time.LocalDate;
  23. import java.util.List;
  24. import java.util.UUID;
  25. @Component
  26. public class FixSelectFlowDetailUtils {
  27. @Autowired
  28. private CaseApplicationMapper caseApplicationMapper;
  29. @Autowired
  30. private SealSignRecordMapper sealSignRecordMapper;
  31. @Autowired
  32. private CaseAttachMapper caseAttachMapper;
  33. @Autowired
  34. private DeptIdentifyMapper deptIdentifyMapper;
  35. @Scheduled(cron = "0/3 * * * * ?")
  36. @Transactional
  37. public void fixExecuteSelectFlowDetailUtils() throws EsignDemoException {
  38. Gson gson = new Gson();
  39. SealSignRecord sealSignRecordselect = new SealSignRecord();
  40. // sealSignRecordselect.setSignFlowStatus(1);
  41. List<SealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecordbyStat(sealSignRecordselect);
  42. if(sealSignRecords!=null&&sealSignRecords.size()>0){
  43. for (int i = 0; i < sealSignRecords.size(); i++) {
  44. SealSignRecord sealSignRecord = sealSignRecords.get(i);
  45. EsignHttpResponse signFlowDetail = SignAward.signFlowDetail(sealSignRecord);
  46. JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
  47. JsonObject flowDetailData = signFlowDetailJsonObject.getAsJsonObject("data");
  48. JsonArray signersArray = flowDetailData.get("signers").getAsJsonArray();
  49. Integer psnsignStatus = null;
  50. Integer orgsignStatus = null;
  51. for (int j = 0; j < signersArray.size(); j++) {
  52. JsonObject signerObject = (JsonObject)signersArray.get(j);
  53. if(!(signerObject.get("psnSigner").toString()).equals("null")){
  54. JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner");
  55. if(psnSignerData!=null){
  56. psnsignStatus = signerObject.get("signStatus").getAsInt();
  57. }
  58. }
  59. if(!(signerObject.get("orgSigner").toString()).equals("null")){
  60. JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner");
  61. if(orgSignerData!=null){
  62. orgsignStatus = signerObject.get("signStatus").getAsInt();
  63. }
  64. }
  65. }
  66. if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==1)){
  67. //更新立案申请状态为待用印
  68. CaseApplication caseApplication = new CaseApplication();
  69. caseApplication.setId(sealSignRecord.getCaseAppliId());
  70. CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
  71. if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.SIGN_ARBITRATION)){
  72. caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
  73. caseApplicationMapper.submitCaseApplication(caseApplication);
  74. //修改"签署用印记录表"的状态为待用印
  75. sealSignRecord.setSignFlowStatus(2);
  76. sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
  77. }
  78. }
  79. if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==2)){
  80. //更新立案申请状态为待送达
  81. CaseApplication caseApplication = new CaseApplication();
  82. caseApplication.setId(sealSignRecord.getCaseAppliId());
  83. CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
  84. if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.ARBITRATED_SEAL)){
  85. caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY);
  86. //下载审核完成的裁决书,
  87. String signFlowId = sealSignRecord.getSignFlowid();
  88. EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
  89. JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(),JsonObject.class);
  90. JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
  91. JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
  92. if(filesArray!=null&&filesArray.size()>0){
  93. JsonObject fileObject = (JsonObject)filesArray.get(0);
  94. String fileDownloadUrl = fileObject.get("downloadUrl").toString();
  95. //修改"签署用印记录表"的状态为签署完成
  96. sealSignRecord.setSignFlowStatus(3);
  97. sealSignRecord.setFileDownloadUrl(fileDownloadUrl.substring(1,fileDownloadUrl.length()-1));
  98. sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
  99. String filearbitraUrl = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
  100. caseApplication.setFilearbitraUrl(filearbitraUrl);
  101. caseApplicationMapper.submitCaseApplication(caseApplication);
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. @Scheduled(cron = "0/10 * * * * ?")
  109. @Transactional
  110. public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException {
  111. Gson gson = new Gson();
  112. DeptIdentify deptIdentify = new DeptIdentify();
  113. deptIdentify.setIdentifyStatus(0);
  114. List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
  115. if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
  116. for (int i = 0; i < deptIdentifysnew.size(); i++) {
  117. EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentifysnew.get(i));
  118. JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
  119. JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
  120. int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
  121. String orgId = identifyInfoData.get("orgId").getAsString();
  122. if(realnameStatus==1){
  123. EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
  124. JsonObject identifyInfoJsonObject1 = gson.fromJson(identifyInfo1.getBody(), JsonObject.class);
  125. JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
  126. JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
  127. String sealNames = "";
  128. if(sealArray.size()>0){
  129. for (int j = 0; j < sealArray.size(); j++) {
  130. JsonObject sealObject = (JsonObject)sealArray.get(j);
  131. String sealName = sealObject.get("sealName").toString();
  132. String sealNamenew = sealName.substring(1,sealName.length()-1);
  133. sealNames += sealNamenew +",";
  134. }
  135. }
  136. String sealName = sealNames.substring(0,sealNames.length()-1);
  137. DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
  138. deptIdentifynew.setIdentifyStatus(1);
  139. deptIdentifynew.setSealName(sealName);
  140. int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
  141. }
  142. }
  143. }
  144. }
  145. }