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.BpmOASalesPerformanceService;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOASalesPerformanceServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * OA 销售业绩目标申请OA
 *
 * @author 符溶馨
 */
@Component
public class BpmOASalesPerformanceResultListener extends BpmProcessInstanceResultEventListener {

    @Resource
    private BpmOASalesPerformanceService salesPerformanceService;

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

    @Override
    protected void onEvent(BpmProcessInstanceResultEvent event) {
        salesPerformanceService.updateSalesPerformanceResult(event.getId(), Long.parseLong(event.getBusinessKey()), event.getResult());
    }
}
