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