package cn.iocoder.yudao.module.crm.service.receivable.listener;
|
|
import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent;
|
import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
|
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 超级管理员
|
*/
|
@Component
|
@Slf4j
|
public class CrmReceivableStatusListener extends BpmProcessInstanceStatusEventListener {
|
|
@Resource
|
private CrmReceivableService receivableService;
|
|
@Override
|
protected String getProcessDefinitionKey() {
|
return CrmReceivableServiceImpl.BPM_PROCESS_DEFINITION_KEY;
|
}
|
|
@Override
|
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());
|
}
|
|
}
|