REQ-3581: 修复印章状态同步问题
This commit is contained in:
parent
4a10d081a1
commit
bd639cd3cf
@ -20,6 +20,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -43,8 +44,8 @@ public class ContractManager {
|
||||
private final EssBroadcaster essBroadcaster;
|
||||
private final ContractSupport contractSupport;
|
||||
private final EssLogDao essLogDao;
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
|
||||
@Transactional
|
||||
public CreateContractByFileResponse
|
||||
createContractByFile(CreateContractByFileRequest request) {
|
||||
essLogDao.logRequest("createContractByFile", request.getBizCode(), request);
|
||||
@ -61,15 +62,16 @@ public class ContractManager {
|
||||
.collect(toList());
|
||||
for (int i = 0; i < contract.approverSize(); i++)
|
||||
contract.getApprover(i).setEssRecipientId(essRecipientIds.get(i));
|
||||
essContractDao.setEssContractCreated(
|
||||
contract.getId(), essResponse.getFlowId(),
|
||||
essFileIds, contract.getApprovers());
|
||||
contract = essContractDao.getOrThrow(essResponse.getFlowId());
|
||||
essBroadcaster.fireContractStateChanged(contract);
|
||||
CreateContractByFileResponse response = new CreateContractByFileResponse();
|
||||
response.setEssContractId(essResponse.getFlowId());
|
||||
response.setEssRecipientIds(essRecipientIds);
|
||||
return response;
|
||||
return transactionTemplate.execute(unused -> {
|
||||
essContractDao.setEssContractCreated(
|
||||
contract.getId(), essResponse.getFlowId(),
|
||||
essFileIds, contract.getApprovers());
|
||||
essBroadcaster.fireContractStateChanged(contract);
|
||||
CreateContractByFileResponse response = new CreateContractByFileResponse();
|
||||
response.setEssContractId(essResponse.getFlowId());
|
||||
response.setEssRecipientIds(essRecipientIds);
|
||||
return response;
|
||||
});
|
||||
} catch (TencentCloudSDKException | ServiceException e) {
|
||||
log.warn("创建合同失败", e);
|
||||
if (contract != null)
|
||||
|
||||
@ -29,6 +29,7 @@ import cn.axzo.nanopart.ess.server.utils.BizAssertions;
|
||||
import com.tencentcloudapi.essbasic.v20210526.models.CreateSignUrlsResponse;
|
||||
import com.tencentcloudapi.essbasic.v20210526.models.SignUrlInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -39,6 +40,7 @@ import static cn.axzo.nanopart.ess.server.utils.BizAssertions.fail;
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EssService {
|
||||
@ -165,14 +167,17 @@ public class EssService {
|
||||
|
||||
public void maybeUploadContractToOss(EssContract contract) {
|
||||
essSupport.asyncExec(() -> {
|
||||
EssContract effectiveContract = essContractDao.findOrNull(contract.getEssContractId());
|
||||
if (!effectiveContract.isFinalState()
|
||||
|| StringUtils.isNotBlank(effectiveContract.getOssFileKey()))
|
||||
return;
|
||||
String pdfUrl = getContractPDFUrlFromEss(effectiveContract);
|
||||
String fileName = String.format("%s.pdf", effectiveContract.getContractName());
|
||||
String fileKey = ossService.uploadToOss(pdfUrl, fileName);
|
||||
essContractDao.setOssKey(effectiveContract, fileKey);
|
||||
try {
|
||||
EssContract c = essContractDao.findOrNull(contract.getEssContractId());
|
||||
if (c == null || !c.isFinalState() || StringUtils.isNotBlank(c.getOssFileKey()))
|
||||
return;
|
||||
String pdfUrl = getContractPDFUrlFromEss(c);
|
||||
String fileName = String.format("%s.pdf", c.getContractName());
|
||||
String fileKey = ossService.uploadToOss(pdfUrl, fileName);
|
||||
essContractDao.setOssKey(c, fileKey);
|
||||
} catch (Exception e) {
|
||||
log.warn("上传合同到OSS失败", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user