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 XWGSWYHListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution delegateExecution) {
        DisciplinaryMapper disciplinaryMapper = (DisciplinaryMapper)SpringUtils.getBean("disciplinaryMapper");
        List<Long> xwgswyh = disciplinaryMapper.getApprovalByRoleKey("stumanger");
        log.info("设置学务干事委员会审批人员：{}", xwgswyh);
        if (xwgswyh.size()==0){
            throw new RuntimeException("学务干事委员会审批人员未设置");
        }else{
            // 设置学无干事委员会审批人员
            delegateExecution.setVariable("userList", xwgswyh);
            // todo 企业微信推送消息

        }

    }
}
