REQ-3581: 备份
This commit is contained in:
parent
26fce20bcc
commit
2886f85d7d
@ -19,8 +19,13 @@ import java.util.Optional;
|
||||
public class EssContractDao extends ServiceImpl<EssContractMapper, EssContract> {
|
||||
|
||||
public Optional<EssContract> find(String essContractId) {
|
||||
return find(essContractId, false);
|
||||
}
|
||||
|
||||
public Optional<EssContract> find(String essContractId, boolean forUpdate) {
|
||||
return lambdaQuery()
|
||||
.eq(EssContract::getEssContractId, essContractId)
|
||||
.last(forUpdate, "FOR UPDATE")
|
||||
.oneOpt();
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -114,13 +115,7 @@ public class ContractManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateContractState(EssContract contract,
|
||||
EssContractState state,
|
||||
List<EssApproverDetail> details) {
|
||||
essContractDao.updateState(contract, state, details);
|
||||
broadcaster.fireContractStateChanged(contract);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void revokeContract(RevokeContractRequest request) {
|
||||
EssContract contract = essContractDao.find(request.getEssContractId()).orElse(null);
|
||||
BizAssertions.assertNotNull(contract, "合同不存在: {}", request.getEssContractId());
|
||||
@ -129,7 +124,24 @@ public class ContractManager {
|
||||
"合同已是最终状态[{}], 无法撤销", contract.getState().getDescription());
|
||||
EssPerson creator = getContractCreatorOrThrow(contract);
|
||||
essClient.revokeContract(creator, contract.getEssContractId(), request.getReason());
|
||||
essContractDao.updateState(contract, EssContractState.CANCEL, null);
|
||||
updateContractState(contract, EssContractState.CANCEL, null);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateContractState(EssContract contract,
|
||||
EssContractState state,
|
||||
List<EssApproverDetail> details) {
|
||||
EssContract reloadContract = essContractDao
|
||||
.find(contract.getEssContractId(), true)
|
||||
.orElse(null);
|
||||
BizAssertions.assertNotNull(reloadContract, "合同不存在: {}", contract.getEssContractId());
|
||||
//noinspection DataFlowIssue
|
||||
if (reloadContract.getState().isFinalState()) {
|
||||
log.warn("合同已是最终状态[{}], 无法更新状态", reloadContract.getState().getDescription());
|
||||
return;
|
||||
}
|
||||
essContractDao.updateState(contract, state, details);
|
||||
broadcaster.fireContractStateChanged(contract);
|
||||
}
|
||||
|
||||
private EssPerson getContractCreatorOrThrow(EssContract contract) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user