| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package com.ruoyi.wisdomarbitrate.utils;
-
- 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.core.domain.entity.EsignHttpResponse;
- import com.ruoyi.common.exception.EsignDemoException;
- import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
- import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
- import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
- import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
- import com.ruoyi.wisdomarbitrate.mapper.SealSignRecordMapper;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
-
- import java.util.List;
-
- @Component
- public class FixSelectFlowDetailUtils {
-
- @Autowired
- private CaseApplicationMapper caseApplicationMapper;
- @Autowired
- private SealSignRecordMapper sealSignRecordMapper;
-
- @Scheduled(cron = "0/3 * * * * ?")
- public void fixExecuteSelectFlowDetailUtils() throws EsignDemoException {
- Gson gson = new Gson();
-
- SealSignRecord sealSignRecordselect = new SealSignRecord();
- // sealSignRecordselect.setSignFlowStatus(1);
- List<SealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecordbyStat(sealSignRecordselect);
- if(sealSignRecords!=null&&sealSignRecords.size()>0){
- for (int i = 0; i < sealSignRecords.size(); i++) {
- SealSignRecord sealSignRecord = sealSignRecords.get(i);
- EsignHttpResponse signFlowDetail = SignAward.signFlowDetail(sealSignRecord);
- JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
- JsonObject flowDetailData = signFlowDetailJsonObject.getAsJsonObject("data");
- JsonArray signersArray = flowDetailData.get("signers").getAsJsonArray();
- Integer psnsignStatus = null;
- Integer orgsignStatus = null;
- for (int j = 0; j < signersArray.size(); j++) {
- JsonObject signerObject = (JsonObject)signersArray.get(j);
-
- if(!(signerObject.get("psnSigner").toString()).equals("null")){
- JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner");
- if(psnSignerData!=null){
- psnsignStatus = signerObject.get("signStatus").getAsInt();
- }
- }
- if(!(signerObject.get("orgSigner").toString()).equals("null")){
- JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner");
- if(orgSignerData!=null){
- orgsignStatus = signerObject.get("signStatus").getAsInt();
- }
- }
-
- }
- if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==1)){
- //更新立案申请状态为待用印
- CaseApplication caseApplication = new CaseApplication();
- caseApplication.setId(sealSignRecord.getCaseAppliId());
-
- CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
- if(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.SIGN_ARBITRATION){
- caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
- caseApplicationMapper.submitCaseApplication(caseApplication);
-
- //修改"签署用印记录表"的状态为待用印
- sealSignRecord.setSignFlowStatus(2);
- sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
- }
-
-
- }
- if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==2)){
- //更新立案申请状态为待送达
- CaseApplication caseApplication = new CaseApplication();
- caseApplication.setId(sealSignRecord.getCaseAppliId());
-
- CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
- if(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.ARBITRATED_SEAL){
- caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY);
- caseApplicationMapper.submitCaseApplication(caseApplication);
-
- //下载审核完成的裁决书,
- String signFlowId = sealSignRecord.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();
- //修改"签署用印记录表"的状态为签署完成
- sealSignRecord.setSignFlowStatus(3);
- sealSignRecord.setFileDownloadUrl(fileDownloadUrl);
- sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
-
- }
- }
- }
- }
-
- }
-
-
-
- }
-
-
-
-
-
-
- }
|