package cn.iocoder.yudao.module.pms.listener;

import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
import cn.iocoder.yudao.module.pms.service.failure.IotFailureReportService;
import cn.iocoder.yudao.module.pms.service.failure.IotFailureReportServiceImpl;
import cn.iocoder.yudao.module.supplier.service.product.SupplierService;
import cn.iocoder.yudao.module.supplier.service.product.SupplierServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 故障上报监听器实现类
 *
 * @author phli
 */
@Component
public class FailureBpmStatusListener extends BpmProcessInstanceStatusEventListener {

    @Resource
    private IotFailureReportService iotFailureReportService;

    @Override
    public String getProcessDefinitionKey() {
        return IotFailureReportServiceImpl.PROCESS_KEY;
    }

    @Override
    public void onEvent(BpmProcessInstanceStatusEvent event) {
        iotFailureReportService.approvalFailureReport(Long.parseLong(event.getBusinessKey()), event.getStatus());
    }

}
