package cn.iocoder.yudao.module.bpm.service.oa.listener;

import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAExpensesService;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAExpensesServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * OA 生产开支的结果的监听器实现类
 *
 * @author 符溶馨
 */
@Component
public class BpmOAExpensesResultListener extends BpmProcessInstanceResultEventListener {
    @Resource
    private BpmOAExpensesService expensesService;

    @Override
    protected String getProcessDefinitionKey() {

        return BpmOAExpensesServiceImpl.PROCESS_KEY;
    }

    @Override
    protected void onEvent(BpmProcessInstanceResultEvent event) {

        expensesService.updateExpensesResult(event.getId(), Long.parseLong(event.getBusinessKey()), event.getResult());
    }
}
