package com.xjrsoft.module.liteflow.node;

import cn.hutool.core.convert.Convert;
import com.xjrsoft.module.courseTable.service.ICourseTableService;
import com.xjrsoft.module.schedule.entity.WfCourseAdjust;
import com.xjrsoft.module.schedule.service.IWfCourseAdjustService;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 调课规则
 */
@Component("wf_course_adjust_node")
public class WfCourseAdjustNode extends NodeComponent {
    @Autowired
    private ICourseTableService courseTableService;

    @Autowired
    private IWfCourseAdjustService wfCourseAdjustService;

    @Override
    public void process() throws Exception {
        Map<String, Object> params = this.getFirstContextBean();
        Object value = util.getFormDatKey(params,"id");
        Long formId = Convert.toLong(value);
        if (formId != null) {
            // 数据处理
            WfCourseAdjust courseAdjust = wfCourseAdjustService.getById(formId);
            courseTableService.adjustCourse(courseAdjust);
        }
    }
}
