gaoluyang
8 天以前 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java
@@ -5,27 +5,39 @@
import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService;
import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
 * 回款审批的结果的监听器实现类
 * 回款审批结果监听器
 *
 * @author HUIHUI
 * 流程审批通过:回款状态更新为审核通过,并回写回款计划已回款金额;
 * 流程驳回/取消:仅更新回款状态,不回写金额。
 *
 * @author 超级管理员
 */
@Component
@Slf4j
public class CrmReceivableStatusListener extends BpmProcessInstanceStatusEventListener {
    @Resource
    private CrmReceivableService receivableService;
    @Override
    public String getProcessDefinitionKey() {
    protected String getProcessDefinitionKey() {
        return CrmReceivableServiceImpl.BPM_PROCESS_DEFINITION_KEY;
    }
    @Override
    public void onEvent(BpmProcessInstanceStatusEvent event) {
        receivableService.updateReceivableAuditStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
    protected void onEvent(BpmProcessInstanceStatusEvent event) {
        Long receivableId;
        try {
            receivableId = Long.parseLong(event.getBusinessKey());
        } catch (NumberFormatException | NullPointerException ex) {
            log.warn("[onEvent][回款审批事件的 businessKey({}) 不是回款编号,忽略]", event.getBusinessKey());
            return;
        }
        receivableService.updateReceivableAuditStatus(receivableId, event.getStatus());
    }
}