REQ-3581: 修复印章状态同步问题

This commit is contained in:
yanglin 2025-02-20 10:18:09 +08:00
parent aa1d5ec283
commit ce1f32548c
5 changed files with 13 additions and 14 deletions

View File

@ -1,6 +1,5 @@
package cn.axzo.nanopart.ess.server.dao;
import cn.axzo.nanopart.ess.api.domain.contract.Approver;
import cn.axzo.nanopart.ess.api.domain.contract.EssApproveDetail;
import cn.axzo.nanopart.ess.api.enums.EssContractState;
import cn.axzo.nanopart.ess.server.entity.EssContract;
@ -43,13 +42,11 @@ public class EssContractDao extends ServiceImpl<EssContractMapper, EssContract>
public void setEssContractCreated(Long id,
String flowId,
List<String> essFileIds,
List<Approver> approvers) {
List<String> essFileIds) {
lambdaUpdate()
.eq(EssContract::getId, id)
.set(EssContract::getEssFieldIds, JSON.toJSONString(essFileIds))
.set(EssContract::getEssContractId, flowId)
.set(EssContract::getApprovers, JSON.toJSONString(approvers))
.update();
}
@ -65,7 +62,7 @@ public class EssContractDao extends ServiceImpl<EssContractMapper, EssContract>
.update();
}
public void setOssInfo(EssContract contract, String fileKey) {
public void setOssFileKey(EssContract contract, String fileKey) {
lambdaUpdate()
.eq(EssContract::getId, contract.getId())
.set(EssContract::getOssFileKey, fileKey)

View File

@ -62,8 +62,7 @@ public class ContractManager {
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.getId(), essResponse.getFlowId(), essFileIds);
contract = essContractDao.getOrThrow(essResponse.getFlowId());
essBroadcaster.fireContractStateChanged(contract);
CreateContractByFileResponse response = new CreateContractByFileResponse();

View File

@ -173,7 +173,7 @@ public class EssService {
return;
String fileName = String.format("%s.pdf", effectiveContract.getContractName());
String fileKey = ossService.uploadToOss(essPdfUrl.get(), fileName);
essContractDao.setOssInfo(effectiveContract, fileKey);
essContractDao.setOssFileKey(effectiveContract, fileKey);
});
}

View File

@ -105,9 +105,10 @@ public class OrgManager {
// !! seal
@Transactional
public void maybeAddSeal(Long ouId, String essSealId, EssSealType type) {
public boolean maybeAddSeal(Long ouId, String essSealId, EssSealType type) {
EssSeal seal = essSealDao.findByEssSealId(essSealId).orElse(null);
if (seal != null) return;
if (seal != null)
return false;
seal = new EssSeal();
seal.setOuId(ouId);
seal.setEssSealId(essSealId);
@ -115,7 +116,9 @@ public class OrgManager {
seal.setType(type);
try {
essSealDao.save(seal);
return true;
} catch (DuplicateKeyException ignored) {
return false;
}
}
@ -157,7 +160,7 @@ public class OrgManager {
return;
try {
essSealPersonDao.saveBatch(newPersons);
} catch (Exception ignored) {
} catch (DuplicateKeyException ignored) {
}
}

View File

@ -108,10 +108,10 @@ class CallbackController implements EssCallbackApi, InitializingBean {
StringUtils.isBlank(operate.getAuthorizedOperatorOpenId())
? PersonOpenId.none()
: PersonOpenId.parse(operate.getAuthorizedOperatorOpenId());
orgManager.maybeAddSeal(ou.getOuId(), operate.getSealId(),
boolean sealCreated = orgManager.maybeAddSeal(ou.getOuId(), operate.getSealId(),
EssSealType.fromEssCode(operate.getSealType()));
// 印章创建人会自动获得授权
if ("Create".equals(operate.getOperate()))
// 1. 印章创建人会自动获得授权; 2. 避免miss create事件
if (sealCreated)
orgManager.addSealAuthorization(operate.getSealId(), operator.getPersonId(), operator.getPersonId());
if ("Delete".equals(operate.getOperate()))
orgManager.updateSealState(operate.getSealId(), EssSealState.DELETED);