2023-10-12 17:20:40 +08:00
|
|
|
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;
|
2023-10-15 10:16:48 +08:00
|
|
|
import com.ruoyi.common.constant.FileTransformation;
|
2023-10-12 17:20:40 +08:00
|
|
|
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
|
|
|
|
import com.ruoyi.common.exception.EsignDemoException;
|
2023-10-13 14:05:12 +08:00
|
|
|
import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
|
2023-10-12 17:20:40 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
2023-10-15 10:16:48 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
|
2023-10-30 20:06:38 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
|
2023-10-13 10:57:45 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
|
2023-10-12 17:20:40 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
|
2023-10-15 10:16:48 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
|
2023-10-30 20:06:38 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
|
2023-10-13 10:57:45 +08:00
|
|
|
import com.ruoyi.wisdomarbitrate.mapper.SealSignRecordMapper;
|
2023-10-12 17:20:40 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2023-10-13 10:57:45 +08:00
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
2023-10-15 15:53:37 +08:00
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2023-10-12 17:20:40 +08:00
|
|
|
|
2023-10-15 10:16:48 +08:00
|
|
|
import java.time.LocalDate;
|
2023-10-13 10:57:45 +08:00
|
|
|
import java.util.List;
|
2023-10-15 10:16:48 +08:00
|
|
|
import java.util.UUID;
|
2023-10-13 10:57:45 +08:00
|
|
|
|
|
|
|
|
@Component
|
2023-10-12 17:20:40 +08:00
|
|
|
public class FixSelectFlowDetailUtils {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CaseApplicationMapper caseApplicationMapper;
|
2023-10-13 10:57:45 +08:00
|
|
|
@Autowired
|
|
|
|
|
private SealSignRecordMapper sealSignRecordMapper;
|
2023-10-15 10:16:48 +08:00
|
|
|
@Autowired
|
|
|
|
|
private CaseAttachMapper caseAttachMapper;
|
2023-10-30 20:06:38 +08:00
|
|
|
@Autowired
|
|
|
|
|
private DeptIdentifyMapper deptIdentifyMapper;
|
2023-10-12 17:20:40 +08:00
|
|
|
|
2023-11-03 17:02:23 +08:00
|
|
|
@Scheduled(cron = "0/10 * * * * ?")
|
2023-10-15 15:53:37 +08:00
|
|
|
@Transactional
|
2023-11-03 17:02:23 +08:00
|
|
|
public void fixExecuteSelectFlowDetailUtils(){
|
2023-10-12 17:20:40 +08:00
|
|
|
Gson gson = new Gson();
|
|
|
|
|
|
2023-10-13 10:57:45 +08:00
|
|
|
SealSignRecord sealSignRecordselect = new SealSignRecord();
|
2023-11-03 20:05:12 +08:00
|
|
|
// sealSignRecordselect.setSignFlowStatus(1);
|
2023-10-13 10:57:45 +08:00
|
|
|
List<SealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecordbyStat(sealSignRecordselect);
|
2023-10-12 17:20:40 +08:00
|
|
|
|
2023-11-03 17:02:23 +08:00
|
|
|
try {
|
|
|
|
|
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);
|
2023-11-02 11:08:45 +08:00
|
|
|
|
2023-11-03 17:02:23 +08:00
|
|
|
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();
|
2023-11-01 14:15:21 +08:00
|
|
|
}
|
2023-10-13 14:05:12 +08:00
|
|
|
}
|
2023-11-01 13:59:47 +08:00
|
|
|
|
2023-11-03 17:02:23 +08:00
|
|
|
}
|
|
|
|
|
if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==1)){
|
|
|
|
|
//更新立案申请状态为待用印
|
|
|
|
|
CaseApplication caseApplication = new CaseApplication();
|
|
|
|
|
caseApplication.setId(sealSignRecord.getCaseAppliId());
|
|
|
|
|
|
|
|
|
|
CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
|
|
if(caseApplicationselect!=null){
|
|
|
|
|
if((caseApplicationselect.getCaseStatus()!=null)&&(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!=null){
|
|
|
|
|
if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.ARBITRATED_SEAL)){
|
|
|
|
|
caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY);
|
|
|
|
|
//下载审核完成的裁决书,
|
|
|
|
|
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.substring(1,fileDownloadUrl.length()-1));
|
|
|
|
|
sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
|
|
|
|
|
|
|
|
|
|
String filearbitraUrl = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
|
|
|
|
|
caseApplication.setFilearbitraUrl(filearbitraUrl);
|
|
|
|
|
caseApplicationMapper.submitCaseApplication(caseApplication);
|
|
|
|
|
|
2023-11-03 20:05:12 +08:00
|
|
|
/* LocalDate now = LocalDate.now();
|
2023-11-03 17:02:23 +08:00
|
|
|
String year = Integer.toString(now.getYear());
|
|
|
|
|
String month = String.format("%02d", now.getMonthValue());
|
|
|
|
|
String day = String.format("%02d", now.getDayOfMonth());
|
|
|
|
|
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
|
|
String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
|
|
|
|
|
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
|
|
String savePath = "/home/ruoyi/uploadPath/upload";
|
|
|
|
|
String resultFilePath = saveFolderPath + "/" + fileName;
|
|
|
|
|
String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
|
2023-11-03 18:26:44 +08:00
|
|
|
boolean b = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
|
|
|
|
|
if(b) {
|
|
|
|
|
Long caseAppliId = sealSignRecord.getCaseAppliId();
|
|
|
|
|
CaseAttach caseAttach = new CaseAttach();
|
|
|
|
|
caseAttach.setCaseAppliId(caseAppliId);
|
|
|
|
|
caseAttach.setAnnexType(3);
|
|
|
|
|
caseAttach.setAnnexPath(savePath);
|
|
|
|
|
caseAttach.setAnnexName(saveName);
|
|
|
|
|
caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
|
2023-11-03 20:05:12 +08:00
|
|
|
}*/
|
2023-11-03 17:02:23 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-13 10:57:45 +08:00
|
|
|
}
|
2023-11-03 17:02:23 +08:00
|
|
|
|
2023-10-12 17:20:40 +08:00
|
|
|
}
|
2023-11-03 17:02:23 +08:00
|
|
|
} catch (EsignDemoException e) {
|
|
|
|
|
e.printStackTrace();
|
2023-10-12 17:20:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-11-03 17:02:23 +08:00
|
|
|
@Scheduled(cron = "0/30 * * * * ?")
|
2023-10-30 20:06:38 +08:00
|
|
|
@Transactional
|
|
|
|
|
public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException {
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
DeptIdentify deptIdentify = new DeptIdentify();
|
|
|
|
|
deptIdentify.setIdentifyStatus(0);
|
|
|
|
|
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
|
|
|
|
|
if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
|
|
|
|
|
for (int i = 0; i < deptIdentifysnew.size(); i++) {
|
|
|
|
|
EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentifysnew.get(i));
|
|
|
|
|
JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
|
|
|
|
|
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
|
|
|
|
|
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
|
|
|
|
|
String orgId = identifyInfoData.get("orgId").getAsString();
|
|
|
|
|
if(realnameStatus==1){
|
|
|
|
|
EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
|
|
|
|
|
JsonObject identifyInfoJsonObject1 = gson.fromJson(identifyInfo1.getBody(), JsonObject.class);
|
|
|
|
|
JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
|
|
|
|
|
JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
|
|
|
|
|
String sealNames = "";
|
|
|
|
|
if(sealArray.size()>0){
|
|
|
|
|
for (int j = 0; j < sealArray.size(); j++) {
|
|
|
|
|
JsonObject sealObject = (JsonObject)sealArray.get(j);
|
|
|
|
|
String sealName = sealObject.get("sealName").toString();
|
|
|
|
|
String sealNamenew = sealName.substring(1,sealName.length()-1);
|
|
|
|
|
sealNames += sealNamenew +",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String sealName = sealNames.substring(0,sealNames.length()-1);
|
|
|
|
|
DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
|
|
|
|
|
deptIdentifynew.setIdentifyStatus(1);
|
|
|
|
|
deptIdentifynew.setSealName(sealName);
|
|
|
|
|
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-12 17:20:40 +08:00
|
|
|
}
|