package com.xhkjedu.smarking.controller.papercheck;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.smarking.service.papercheck.MsPaperCheckTeacherTaskService;
import com.xhkjedu.smarking.vo.papercheck.MsCheckParam;
import com.xhkjedu.smarking.vo.papercheck.MsPaperCheckVo;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.utils.PageUtil;
import com.xhkjedu.vo.PageResult;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description 阅卷批阅教师任务表相关操作
 * @Author auto
 * @Date 2024-10-15
 */
@RestController
@RequestMapping("/mtask")
public class MsPaperCheckTeacherTaskController {
    @Resource
    private MsPaperCheckTeacherTaskService msPaperCheckTeacherTaskService;

    /**
     * @Description 阅卷进度-按题块
     * @Date 2024/10/30 10:23
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_by_block")
    public ResultVo listByBlock(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listByBlock(mpid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 阅卷进度-按题块-查看详情
     * @Date 2024/10/30 10:42
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/detail_by_block")
    public ResultVo detailByBlock(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        Integer mblockid = param.getMblockid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1, mblockid, "题块ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.detailByBlock(mpid, mblockid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 阅卷进度-按教师
     * @Date 2024/10/30 10:52
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_by_teacher")
    public ResultVo listByTeacher(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listByTeacher(mpid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 教师阅卷-待/已阅卷列表
     * @Date 2024/10/30 14:35
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_correct")
    public ResultVo listCorrect(@RequestBody MsCheckParam param) {
        Integer page = param.getPage();
        Integer size = param.getPageSize();
        N_Utils.validation(new Object[]{
                page, "显示页码", 1
                , size, "显示条数", 1
                , param.getHandleid(), "操作人ID", 1
                , param.getChecktype(), "类型", 2
        });
        msPaperCheckTeacherTaskService.setParam(param);
        PageHelper.startPage(page, size);
        List<Map> list = msPaperCheckTeacherTaskService.listCorrect(param);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "查询成功", pageResult);
    }

    /**
     * @Description 教师阅卷-待/已阅卷详情
     * @Date 2024/10/30 16:02
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_pending_block")
    public ResultVo listPendingBlock(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{param.getHandleid(), "操作人ID", 1, param.getMpid(), "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listPendingBlock(param);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 教师阅卷-题块列表
     * @Date 2024/10/31 9:40
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_teacher_block")
    public ResultVo listTeacherBlock(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{param.getHandleid(), "操作人ID", 1, param.getMpid(), "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listTeacherBlock(param);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 教师阅卷-试题列表
     * @Date 2024/11/13 17:59
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_teacher_question")
    public ResultVo listTeacherQuestion(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{param.getHandleid(), "操作人ID", 1, param.getMpid(), "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listTeacherQuestion(param);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 教师阅卷-班级列表
     * @Date 2024/11/14 9:41
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_teacher_class")
    public ResultVo listTeacherClass(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{param.getHandleid(), "操作人ID", 1, param.getMpid(), "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listTeacherClass(param);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 获取待批题块
     * @Date 2024/10/31 11:02
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/get_correct_block")
    public ResultVo getCorrectBlock(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{param.getHandleid(), "操作人ID", 1, param.getMpid(), "试卷ID", 1});
        return msPaperCheckTeacherTaskService.getCorrectBlock(param);
    }

    /**
     * @Description 批阅
     * @Date 2024/11/12 10:00
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/correct")
    public ResultVo correct(@RequestBody MsPaperCheckVo param) {
        N_Utils.validation(new Object[]{
                param.getHandleid(), "操作人ID", 1
                , param.getMpid(), "试卷ID", 1
                , param.getMblockid(), "题块ID", 1
                , param.getChecktype(), "批阅情况", 1
                , param.getMpsbid(), "学生试题ID", 1
                , param.getQscore(), "试题分值", 2
        });
        msPaperCheckTeacherTaskService.correct(param);
        return new ResultVo(0, "保存成功");
    }

    /**
     * @Description 阅卷进度-按试题
     * @Date 2024/11/8 16:19
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_by_question")
    public ResultVo listByQuestion(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listByQuestion(mpid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 阅卷进度-按试题-查看详情
     * @Date 2024/11/11 9:24
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/detail_by_question")
    public ResultVo detailByQuestion(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        Integer mblockid = param.getMblockid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1, mblockid, "试题ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.detailByQuestion(mpid, mblockid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 阅卷进度-按班级
     * @Date 2024/11/15 16:56
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_by_class")
    public ResultVo listByClass(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.listByClass(mpid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 阅卷进度-按班级-查看详情
     * @Date 2024/11/15 17:55
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/detail_by_class")
    public ResultVo detailByClass(@RequestBody MsCheckParam param) {
        Integer mpid = param.getMpid();
        Integer mblockid = param.getMblockid();
        N_Utils.validation(new Object[]{mpid, "试卷ID", 1, mblockid, "班级ID", 1});
        List<Map> list = msPaperCheckTeacherTaskService.detailByClass(mpid, mblockid);
        return new ResultVo(0, "查询成功", list);
    }

    /**
     * @Description 教师阅卷-上一份
     * @Date 2024/11/14 10:27
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/get_pre_correct")
    public ResultVo getPreCorrect(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{
                param.getHandleid(), "操作人ID", 1
                , param.getMpid(), "试卷ID", 1
                , param.getMblockid(), "题块ID", 1
                , param.getTaskorder(), "序号", 1
        });
        return new ResultVo(0, "查询成功", msPaperCheckTeacherTaskService.getPreCorrect(param));
    }

    /**
     * @Description 教师阅卷-阅卷历史
     * @Date 2024/11/14 14:12
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_correct_history")
    public ResultVo listCorrectHistory(@RequestBody MsCheckParam param) {
        Integer page = param.getPage();
        Integer size = param.getPageSize();
        N_Utils.validation(new Object[]{
                param.getHandleid(), "操作人ID", 1
                , param.getMpid(), "试卷ID", 1
                , param.getMblockid(), "题块ID", 1
                , page, "显示页码", 1
                , size, "显示条数", 1
        });
        PageHelper.startPage(page, size);
        List<Map> list = msPaperCheckTeacherTaskService.listCorrectHistory(param);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "查询成功", pageResult);
    }

    /**
     * @Description 教师阅卷-历史详情
     * @Date 2024/11/14 17:32
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/detail_history")
    public ResultVo detailHistory(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{
                param.getMpcttid(), "任务ID", 1
                , param.getCorrecttype(), "试卷ID", 1
        });
        return new ResultVo(0, "查询成功", msPaperCheckTeacherTaskService.detailHistory(param));
    }

    /**
     * @Description 教师阅卷-平均分
     * @Date 2024/11/15 9:10
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/avg_score")
    public ResultVo avgScore(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{
                param.getHandleid(), "操作人ID", 1
                , param.getMpid(), "试卷ID", 1
                , param.getMblockid(), "题块ID", 1
        });
        return new ResultVo(0, "查询成功", msPaperCheckTeacherTaskService.avgScore(param));
    }

    /**
     * @Description 教师阅卷-待处理数量
     * @Date 2024/11/15 9:58
     * @Author YWX
     * @Param [param]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/get_pending_num")
    public ResultVo getPendingNum(@RequestBody MsCheckParam param) {
        N_Utils.validation(new Object[]{
                param.getHandleid(), "操作人ID", 1
        });
        return new ResultVo(0, "查询成功", msPaperCheckTeacherTaskService.getPendingNum(param));
    }
}
