package cn.iocoder.yudao.module.asset.service.replacement.listener;

import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent;
import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
import cn.iocoder.yudao.module.asset.service.replacement.VehicleReplacementService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * 替换车审批状态监听器
 *
 * @author 芋道源码
 */
@Component
public class ReplacementBpmListener extends BpmProcessInstanceStatusEventListener {

    /**
     * 流程定义 Key
     */
    public static final String PROCESS_KEY = "asset_vehicle_replacement";

    @Resource
    private VehicleReplacementService replacementService;

    @Override
    protected String getProcessDefinitionKey() {
        return PROCESS_KEY;
    }

    @Override
    protected void onEvent(BpmProcessInstanceStatusEvent event) {
        replacementService.updateApprovalStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
    }

}
