package cn.iocoder.yudao.module.erp.service.finance.listener;
|
|
import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent;
|
import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
|
import cn.iocoder.yudao.module.erp.service.finance.ErpFinancePaymentService;
|
import jakarta.annotation.Resource;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* 付款单审批状态监听器
|
*
|
* 监听 BPM 流程实例状态变更事件,更新付款单的审批状态
|
*
|
* @author 超级管理员
|
*/
|
@Component
|
@Slf4j
|
public class ErpFinancePaymentStatusListener extends BpmProcessInstanceStatusEventListener {
|
|
/**
|
* BPM 付款单审批流程定义 key
|
*/
|
private static final String BPM_PROCESS_DEFINITION_KEY = "erp-finance-payment-audit";
|
|
@Resource
|
private ErpFinancePaymentService financePaymentService;
|
|
@Override
|
protected String getProcessDefinitionKey() {
|
return BPM_PROCESS_DEFINITION_KEY;
|
}
|
|
@Override
|
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
Long paymentId;
|
try {
|
paymentId = Long.parseLong(event.getBusinessKey());
|
} catch (NumberFormatException e) {
|
log.warn("[onEvent] businessKey({}) 不是有效的付款单编号", event.getBusinessKey());
|
return;
|
}
|
log.info("[onEvent] 收到BPM审批事件,paymentId={}, status={}", paymentId, event.getStatus());
|
financePaymentService.updateFinancePaymentAuditStatus(paymentId, event.getStatus());
|
}
|
|
}
|