package com.srs.flowable.listener.disciplinary;

import com.srs.common.utils.spring.SpringUtils;
import com.srs.flowable.mapper.DisciplinaryMapper;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 学院违纪处理委员会审批
 */
@Component
@Slf4j
public class XYWJCLWYHListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution delegateExecution) {
        DisciplinaryMapper disciplinaryMapper = (DisciplinaryMapper)SpringUtils.getBean("disciplinaryMapper");
        List<Long> xywjclwyh = disciplinaryMapper.getApprovalByRoleKey("xywjclwyh");
        if (xywjclwyh.size() == 0){
            log.error("未找到角色相关信息");
            throw new RuntimeException("学院违纪处理委员会审批人员未设置");
        }else{
            delegateExecution.setVariable("userList",xywjclwyh);
            // todo 企业微信推送消息

        }

    }
}
