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.maintain.IotMaintainService;
import cn.iocoder.yudao.module.pms.service.maintain.IotMaintainServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

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

    @Resource
    private IotMaintainService iotMaintainService;

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

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

}
