| | |
| | | package cn.iocoder.yudao.module.mes.service.wm.miscreceipt.listener; |
| | | |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener; |
| | | import cn.iocoder.yudao.module.mes.service.wm.miscreceipt.MesWmMiscReceiptService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 杂项入库单 BPM 审批状态监听器 |
| | | * MES 杂项入库单审批状态监听器 |
| | | * |
| | | * 监听 BPM 流程实例状态变更事件,更新杂项入库单的审批状态 |
| | | * 监听 BPM 审批结果,回写杂项入库单状态,使审批统一在「协同办公 - 我的流程」中流转。 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesWmMiscReceiptStatusListener |
| | | extends cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener { |
| | | public class MesWmMiscReceiptStatusListener extends BpmProcessInstanceStatusEventListener { |
| | | |
| | | private static final String PROCESS_DEFINITION_KEY = "misc_receipt_approve"; |
| | | |
| | | @Resource |
| | | private MesWmMiscReceiptService miscReceiptService; |
| | | |
| | | @Override |
| | | protected String getProcessDefinitionKey() { |
| | | return MesWmMiscReceiptService.APPROVE_CATEGORY_CODE; |
| | | return PROCESS_DEFINITION_KEY; |
| | | } |
| | | |
| | | @Override |
| | | protected void onEvent(BpmProcessInstanceStatusEvent event) { |
| | | Long id; |
| | | Long receiptId; |
| | | try { |
| | | id = Long.parseLong(event.getBusinessKey()); |
| | | receiptId = Long.parseLong(event.getBusinessKey()); |
| | | } catch (NumberFormatException e) { |
| | | log.warn("[onEvent] businessKey({}) 不是有效的杂项入库单编号", event.getBusinessKey()); |
| | | return; |
| | | } |
| | | log.info("[onEvent] 收到BPM审批事件,miscReceiptId={}, status={}", id, event.getStatus()); |
| | | log.info("[onEvent] 收到杂项入库单审批事件,receiptId={}, status={}", receiptId, event.getStatus()); |
| | | try { |
| | | miscReceiptService.updateMiscReceiptAuditStatus(id, event.getStatus()); |
| | | log.info("[onEvent] 杂项入库单({}) 审批状态更新完成", id); |
| | | miscReceiptService.updateMiscReceiptAuditStatus(receiptId, event.getStatus(), event.getReason()); |
| | | } catch (Exception e) { |
| | | log.error("[onEvent] 更新杂项入库单审批状态失败,miscReceiptId={}", id, e); |
| | | log.error("[onEvent] 回写杂项入库单审批状态失败,receiptId={}", receiptId, e); |
| | | } |
| | | } |
| | | |