package cn.iocoder.yudao.module.erp.service.purchase.listener; import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchasePlanService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; /** * 采购计划审批状态监听器(Legacy,已停用) * * 采购计划审批已改为「审批配置」轻量级状态机,由 * {@link ErpPurchasePlanService#submitPurchasePlan(Long)} / {@link ErpPurchasePlanService#auditPurchasePlan(Long, Boolean, String)} * 直接驱动状态,不再依赖 BPM。 * * 保留本类仅作历史参考;不再注册为 Spring Bean,避免旧的 BPM 流程实例触发时 * 与新审批路径重复更新/重复生成采购申请。 * * @author xiaoyi */ @Slf4j public class ErpPurchasePlanStatusListener extends cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener { /** * 采购计划审批流程定义 Key */ private static final String PROCESS_DEFINITION_KEY = "purchase_plan_approve"; @Resource private ErpPurchasePlanService purchasePlanService; @Override protected String getProcessDefinitionKey() { return PROCESS_DEFINITION_KEY; } @Override protected void onEvent(BpmProcessInstanceStatusEvent event) { Long planId; try { planId = Long.parseLong(event.getBusinessKey()); } catch (NumberFormatException e) { log.warn("[onEvent] businessKey({}) 不是有效的采购计划编号", event.getBusinessKey()); return; } log.info("[onEvent] 收到BPM审批事件,planId={}, status={}", planId, event.getStatus()); try { purchasePlanService.updatePurchasePlanAuditStatus(planId, event.getStatus()); log.info("[onEvent] 采购计划({}) 审批状态更新完成", planId); } catch (Exception e) { log.error("[onEvent] 更新采购计划审批状态失败,planId={}", planId, e); } } }