智能仲裁后端服务

FixSelectFlowDetailUtils.java 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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/10 * * * * ?")
  36. @Transactional
  37. public void fixExecuteSelectFlowDetailUtils(){
  38. Gson gson = new Gson();
  39. SealSignRecord sealSignRecordselect = new SealSignRecord();
  40. // sealSignRecordselect.setSignFlowStatus(1);
  41. List<SealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecordbyStat(sealSignRecordselect);
  42. try {
  43. if(sealSignRecords!=null&&sealSignRecords.size()>0){
  44. for (int i = 0; i < sealSignRecords.size(); i++) {
  45. SealSignRecord sealSignRecord = sealSignRecords.get(i);
  46. EsignHttpResponse signFlowDetail = SignAward.signFlowDetail(sealSignRecord);
  47. JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
  48. JsonObject flowDetailData = signFlowDetailJsonObject.getAsJsonObject("data");
  49. JsonArray signersArray = flowDetailData.get("signers").getAsJsonArray();
  50. Integer psnsignStatus = null;
  51. Integer orgsignStatus = null;
  52. for (int j = 0; j < signersArray.size(); j++) {
  53. JsonObject signerObject = (JsonObject)signersArray.get(j);
  54. if(!(signerObject.get("psnSigner").toString()).equals("null")){
  55. JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner");
  56. if(psnSignerData!=null){
  57. psnsignStatus = signerObject.get("signStatus").getAsInt();
  58. }
  59. }
  60. if(!(signerObject.get("orgSigner").toString()).equals("null")){
  61. JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner");
  62. if(orgSignerData!=null){
  63. orgsignStatus = signerObject.get("signStatus").getAsInt();
  64. }
  65. }
  66. }
  67. if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==1)){
  68. //更新立案申请状态为待用印
  69. CaseApplication caseApplication = new CaseApplication();
  70. caseApplication.setId(sealSignRecord.getCaseAppliId());
  71. CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
  72. if(caseApplicationselect!=null){
  73. if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.SIGN_ARBITRATION)){
  74. caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
  75. caseApplicationMapper.submitCaseApplication(caseApplication);
  76. //修改"签署用印记录表"的状态为待用印
  77. sealSignRecord.setSignFlowStatus(2);
  78. sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
  79. }
  80. }
  81. }
  82. if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==2)){
  83. //更新立案申请状态为待送达
  84. CaseApplication caseApplication = new CaseApplication();
  85. caseApplication.setId(sealSignRecord.getCaseAppliId());
  86. CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
  87. if(caseApplicationselect!=null){
  88. if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.ARBITRATED_SEAL)){
  89. caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY);
  90. //下载审核完成的裁决书,
  91. String signFlowId = sealSignRecord.getSignFlowid();
  92. EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
  93. JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(),JsonObject.class);
  94. JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
  95. JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
  96. if(filesArray!=null&&filesArray.size()>0){
  97. JsonObject fileObject = (JsonObject)filesArray.get(0);
  98. String fileDownloadUrl = fileObject.get("downloadUrl").toString();
  99. //修改"签署用印记录表"的状态为签署完成
  100. sealSignRecord.setSignFlowStatus(3);
  101. sealSignRecord.setFileDownloadUrl(fileDownloadUrl.substring(1,fileDownloadUrl.length()-1));
  102. sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
  103. String filearbitraUrl = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
  104. caseApplication.setFilearbitraUrl(filearbitraUrl);
  105. caseApplicationMapper.submitCaseApplication(caseApplication);
  106. LocalDate now = LocalDate.now();
  107. String year = Integer.toString(now.getYear());
  108. String month = String.format("%02d", now.getMonthValue());
  109. String day = String.format("%02d", now.getDayOfMonth());
  110. String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
  111. String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
  112. String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
  113. String savePath = "/home/ruoyi/uploadPath/upload";
  114. String resultFilePath = saveFolderPath + "/" + fileName;
  115. String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
  116. boolean b = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
  117. if(b) {
  118. Long caseAppliId = sealSignRecord.getCaseAppliId();
  119. CaseAttach caseAttach = new CaseAttach();
  120. caseAttach.setCaseAppliId(caseAppliId);
  121. caseAttach.setAnnexType(3);
  122. caseAttach.setAnnexPath(savePath);
  123. caseAttach.setAnnexName(saveName);
  124. caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. } catch (EsignDemoException e) {
  133. e.printStackTrace();
  134. }
  135. }
  136. @Scheduled(cron = "0/30 * * * * ?")
  137. @Transactional
  138. public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException {
  139. Gson gson = new Gson();
  140. DeptIdentify deptIdentify = new DeptIdentify();
  141. deptIdentify.setIdentifyStatus(0);
  142. List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
  143. if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
  144. for (int i = 0; i < deptIdentifysnew.size(); i++) {
  145. EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentifysnew.get(i));
  146. JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
  147. JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
  148. int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
  149. String orgId = identifyInfoData.get("orgId").getAsString();
  150. if(realnameStatus==1){
  151. EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
  152. JsonObject identifyInfoJsonObject1 = gson.fromJson(identifyInfo1.getBody(), JsonObject.class);
  153. JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
  154. JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
  155. String sealNames = "";
  156. if(sealArray.size()>0){
  157. for (int j = 0; j < sealArray.size(); j++) {
  158. JsonObject sealObject = (JsonObject)sealArray.get(j);
  159. String sealName = sealObject.get("sealName").toString();
  160. String sealNamenew = sealName.substring(1,sealName.length()-1);
  161. sealNames += sealNamenew +",";
  162. }
  163. }
  164. String sealName = sealNames.substring(0,sealNames.length()-1);
  165. DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
  166. deptIdentifynew.setIdentifyStatus(1);
  167. deptIdentifynew.setSealName(sealName);
  168. int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
  169. }
  170. }
  171. }
  172. }
  173. }