package com.xhkjedu.sexam.controller.report;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.sexam.model.reportstu.ERstudent;
import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
import com.xhkjedu.sexam.service.report.EReportClassService;
import com.xhkjedu.sexam.utils.ExamUtil;
import com.xhkjedu.sexam.vo.report.ERankParamVo;
import com.xhkjedu.sexam.vo.report.ReportParamsVo;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author ywx
 * @classname EReportClassController
 * @description 班级报告
 * @date 2022/8/8 9:44
 **/
@RestController
@RequestMapping("erc")
public class EReportClassController {
    @Resource
    private EReportClassService eReportClassService;

    /**
     * 考试概况--科目
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2022/8/30 9:20
     **/
    @PostMapping("/list_xkcj")
    public ResultVo listXkCj(@RequestBody ERankParamVo rank) {
        Integer examid = rank.getExamid();
        Integer classid = rank.getClassid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, classid, "班级id", 1});
        List<Map> list = eReportClassService.listXkCj(examid, classid);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 成绩单
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [stu]
     * @Author ywx
     * @Date 2022/8/30 9:36
     **/
    @PostMapping("/list_cjd")
    public ResultVo listCjd(@RequestBody ERstudent stu) {
        Integer examid = stu.getExamid();
        Integer page = stu.getPage();
        N_Utils.validation(new Object[]{examid, "考试id", 1, stu.getClassid(), "班级id", 1});
        Integer showrank = eReportClassService.getShowRank(examid);
        stu.setShowrank(showrank);
        if (N_Utils.isEmptyInteger(page)) {
            List<Map> list = eReportClassService.listCjd(stu);
            return new ResultVo(0, "获取成功", ExamUtil.listCjdOrder(list, showrank));
        } else {
            List<Map> list = eReportClassService.listCjd(stu);
            PageResult pageResult = ExamUtil.getCjdPageResult(stu, list);
            return new ResultVo(0, "获取成功", pageResult);
        }
    }

    /*
     * 成绩分析-搜索
     * @Param [rank]
     * @Author ywx
     * @Date 2022/8/30 9:55
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/cjfx_ss")
    public ResultVo listCjFxForSearch(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1});
        List<Map> map = eReportClassService.listCjFxForSearch(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * 成绩分析-设置
     * @Param [rank]
     * @Author ywx
     * @Date 2022/8/30 10:07
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/cjfx_sz")
    public ResultVo listCjFxForSet(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getCreateid(), "操作人id", 1, rank.getSubjectid(), "科目id", 2});
        List<Map> map = eReportClassService.listCjFxForSet(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * 单科概况
     * @Param [rank]
     * @Author ywx
     * @Date 2022/8/31 10:28
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/get_dkgk")
    public ResultVo getDkGk(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        Map map = eReportClassService.getDkGk(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * 单科概况-平均分
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/7 14:41
     **/
    @PostMapping("/list_pjf")
    public ResultVo listPjf(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        List<Map> list = eReportClassService.listPjf(rank);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 单科概况-高频错题
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/7 14:41
     **/
    @PostMapping("/list_gpct")
    public ResultVo listGpCt(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        List<Map> list = eReportClassService.listGpCt(rank);
        return new ResultVo(0, "获取成功", list);
    }

    /*
     * 单科概况-需关注学生
     * @Param [rank]
     * @Author ywx
     * @Date 2022/8/31 18:02
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_gzxs")
    public ResultVo listGzXs(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2, rank.getRanktype(), "类型", 1});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        List<Map> list = eReportClassService.listGzXs(rank);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * 单科概况-等级统计
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/9 10:40
     **/
    @PostMapping("/dkgk_djtj")
    public ResultVo listDkGkDjTj(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        List<Map> map = eReportClassService.listDkGkDjTj(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * 试卷概况
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/1 8:36
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_sjgk")
    public ResultVo listSjGk(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        Map list = eReportClassService.listSjGk(rank);
        return new ResultVo(0, "获取成功", list);
    }

    /*
     * 试卷分析
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/1 10:59
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/get_sjfx")
    public ResultVo getSjFx(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getClassid(), "班级id", 1
                , rank.getSubjectid(), "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        Map map = eReportClassService.getSjFx(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * 行为分析-科目
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/2 11:36
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_xw_km")
    public ResultVo listXwKm(@RequestBody ERstudentAction rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getActiontype(), "类型", 1
                , rank.getClassid(), "班级id", 1});
        List<Map> map = eReportClassService.listXwKm(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * 行为分析-学生
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/2 13:43
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_xw_xs")
    public ResultVo listXwXs(@RequestBody ERstudentAction rank) {
        Integer page = rank.getPage();
        Integer pageSize = rank.getPageSize();
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getActiontype(), "类型", 1
                , rank.getClassid(), "班级id", 1});
        if (N_Utils.isEmptyInteger(page)) {
            List<Map> list = eReportClassService.listXwXs(rank);
            return new ResultVo(0, "获取成功", list);
        } else {
            PageHelper.startPage(page, pageSize);
            List<Map> list = eReportClassService.listXwXs(rank);
            PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
            return new ResultVo(0, "获取成功", pageResult);
        }
    }

    /**
     * 单科行为分析-科目
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2023/1/4 11:09
     **/
    @PostMapping("/list_dkxw_km")
    public ResultVo listDkXwKm(@RequestBody ERstudentAction rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getActiontype(), "类型", 1
                , rank.getClassid(), "班级id", 1, rank.getSubjectid(), "科目id", 2});
        List<Map> map = eReportClassService.listXwKm(rank);
        return new ResultVo(0, "获取成功", map);
    }

    //处理科目json
    private void formatSubjectJson(String subjectid, List<Map> map) {
        for (Map m : map) {
            List<Map> list = JSON.parseArray(m.get("subjectjson").toString(), Map.class);
            List<Map> list2 = list.stream().filter(s -> subjectid.equals(s.get("subjectid").toString()))
                    .collect(Collectors.toList());
            m.put("subjectjson", JSON.toJSONString(list2));
        }
    }

    /**
     * 单科行为分析-学生
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2023/1/4 11:09
     **/
    @PostMapping("/list_dkxw_xs")
    public ResultVo listDkXwXs(@RequestBody ERstudentAction rank) {
        Integer page = rank.getPage();
        Integer pageSize = rank.getPageSize();
        String subjectid = rank.getSubjectid();
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1, rank.getActiontype(), "类型", 1
                , rank.getClassid(), "班级id", 1, subjectid, "科目id", 2});
        if (N_Utils.isEmptyInteger(page)) {
            List<Map> list = eReportClassService.listXwXs(rank);
            formatSubjectJson(subjectid, list);//处理科目json
            return new ResultVo(0, "获取成功", list);
        } else {
            PageHelper.startPage(page, pageSize);
            List<Map> list = eReportClassService.listXwXs(rank);
            formatSubjectJson(subjectid, list);//处理科目json
            PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
            return new ResultVo(0, "获取成功", pageResult);
        }
    }

    /*
     * 优秀试卷分析-详情
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/2 13:52
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/get_sjxq")
    public ResultVo getSjXq(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getExamid(), "考试id", 1
                , rank.getSubjectid(), "科目id", 2, rank.getCreateid(), "学生id", 1});
        Map map = eReportClassService.getSjXq(rank);
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * 试卷概况-优秀卷
     *
     * @return com.xhkjedu.vo.ResultVo
     * @Param [rank]
     * @Author ywx
     * @Date 2022/9/13 9:54
     **/
    @PostMapping("/sjgk_yxj")
    public ResultVo listSjGkYxj(@RequestBody ERankParamVo rank) {
        N_Utils.validation(new Object[]{rank.getEpid(), "试卷id", 1, rank.getClassid(), "班级id", 1, rank.getQorder(), "试题排序", 1});
        List<Map> list = eReportClassService.listSjGkYxj(rank);
        return new ResultVo(0, "获取成功", list);
    }

    /**
     * @Description 教师权限班级已结束考试列表
     * @Param [paramsVo]
     * @Return com.xhkjedu.vo.ResultVo
     * @Author wn
     * @Date 2022/9/21 9:47
     **/
    @PostMapping("/tends")
    public ResultVo listEndExamsForClassTeacher(@RequestBody ReportParamsVo paramsVo) {
        Integer page = paramsVo.getPage();
        Integer pageSize = paramsVo.getPageSize();
        int userid = paramsVo.getUserid();
        N_Utils.validation(new Object[]{userid, "用户id", 1
                , page, "显示页码", 1, pageSize, "显示条数", 1});
        Integer schoolid = eReportClassService.getSchoolidByUserid(paramsVo.getUserid());
        paramsVo.setSchoolid(schoolid);
        PageHelper.startPage(page, pageSize);
        List<Map> list = eReportClassService.listEndExamsForClassTeacher(paramsVo);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "获取成功", pageResult);
    }

    /**
     * @Description 获取考试关联的教师权限下班级
     * @Param [paramsVo]
     * @Return com.xhkjedu.vo.ResultVo
     * @Author wn
     * @Date 2022/9/22 11:20
     **/
    @PostMapping("/ecl")
    public ResultVo listExamQxClassTeacher(@RequestBody ReportParamsVo paramsVo) {
        N_Utils.validation(new Object[]{paramsVo.getUserid(), "用户id", 1,paramsVo.getExamid(),"考试id",1});
        List<Map> list = eReportClassService.listExamQxClassTeacher(paramsVo);
        return new ResultVo(0, "获取成功", list);
    }

    /*
     * 教师考试权限科目
     * @Param [paramsVo]
     * @Author ywx
     * @Date 2022/11/20 10:44
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_es")
    public ResultVo listExamSubject(@RequestBody ReportParamsVo paramsVo) {
        Integer teacherid = paramsVo.getTeacherid();
        Integer examid = paramsVo.getExamid();
        N_Utils.validation(new Object[]{teacherid, "教师id", 1, examid,"考试id",1});
        List<Map> list = eReportClassService.listExamSubject(examid, teacherid);
        return new ResultVo(0, "获取成功", list);
    }

    /*
     * 班级报告教师成绩单
     * @Param [stu]
     * @Author ywx
     * @Date 2022/11/20 11:19
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list_tcjd")
    public ResultVo listTeacherCjd(@RequestBody ERstudent stu) {
        Integer examid = stu.getExamid();
        Integer page = stu.getPage();
        Integer teacherid = stu.getTeacherid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, stu.getClassid(), "班级id", 1, teacherid, "教师id", 1});
        List<Map> subjects = eReportClassService.listExamSubject(stu.getExamid(), stu.getTeacherid());
        if(N_Utils.isListEmpty(subjects)) return new ResultVo(1, "没有查看权限");
        String subjectid = subjects.get(0).get("subjectid").toString();
        stu.setSubjectid(subjectid);
        Integer showrank = eReportClassService.getShowRank(examid);
        stu.setShowrank(showrank);
        if (N_Utils.isEmptyInteger(page)) {
            List<Map> list = eReportClassService.listTeacherCjd(stu);
            return new ResultVo(0, "获取成功", list);
        } else {
            PageHelper.startPage(page, stu.getPageSize());
            List<Map> list = eReportClassService.listTeacherCjd(stu);
            PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
            return new ResultVo(0, "获取成功", pageResult);
        }
    }

    /*
     * 获取考试基本信息（科目、班级）
     * @Param [params]
     * @Author ywx
     * @Date 2022/11/20 11:32
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/exam")
    public ResultVo getExamSubjectClass(@RequestBody ReportParamsVo params) {
        Integer examid = params.getExamid();
        Integer teacherid = params.getTeacherid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, teacherid, "教师id", 1});
        Map map = eReportClassService.getExamSubjectClass(examid, teacherid);
        return new ResultVo(0, "获取成功", map);
    }

    /*
     * 班级报告列表-班主任
     * @Param [paramsVo]
     * @Author ywx
     * @Date 2022/11/20 13:22
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/ends")
    public ResultVo listEndExamsForClass(@RequestBody ReportParamsVo paramsVo) {
        Integer page = paramsVo.getPage();
        Integer pageSize = paramsVo.getPageSize();
        int userid = paramsVo.getUserid();
        N_Utils.validation(new Object[]{userid, "用户id", 1
                , page, "显示页码", 1, pageSize, "显示条数", 1});
        Integer schoolid = eReportClassService.getSchoolidByUserid(paramsVo.getUserid());
        paramsVo.setSchoolid(schoolid);
        PageHelper.startPage(page, pageSize);
        List<Map> list = eReportClassService.listEndExamsForClass(paramsVo);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "获取成功", pageResult);
    }

    /*
     * pdf报告
     * @Param [rank]
     * @Author ywx
     * @Date 2022/12/7 18:13
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/pdf")
    public ResultVo toPdf(@RequestBody ERankParamVo rank) {
        Integer examid = rank.getExamid();
        Integer classid = rank.getClassid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, classid, "班级id", 1});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        Map map = new HashMap();
        List<Map> subjects = eReportClassService.listKmGg(rank);
        map.put("subjects",subjects);//科目概况
        double allscore = subjects.stream().mapToDouble(s -> Double.valueOf(ExamUtil.removeStrEnd0(s.get("allscore")))).sum();
        Map ksgk = eReportClassService.getPdfKsGk(examid);
        ksgk.put("allscore", allscore);//满分
        map.put("ksgk", ksgk);//考试概况
        List<Map> xkcj = eReportClassService.listXkCj(examid,classid);
        map.put("xkcj", xkcj);//学科成绩
        rank.setSubjectid(null);
        rank.setRanktype(1);
        List<Map> fsdjtj = eReportClassService.listCjFxForSearch(rank);
        map.put("fsdjtj", fsdjtj);//分数等级统计
        rank.setRanktype(2);
        List<Map> fsdtj = eReportClassService.listCjFxForSearch(rank);
        map.put("fsdtj", fsdtj);//分数段统计

        ERstudentAction ra = new ERstudentAction();
        ra.setExamid(examid);
        ra.setClassid(classid);
        ra.setActiontype(1);
        List<Map> wjkm = eReportClassService.listXwKm(ra);
        map.put("wjkm",wjkm);//违纪科目
        ra.setActiontype(2);
        List<Map> yxsjkm = eReportClassService.listXwKm(ra);
        map.put("yxsjkm",yxsjkm);//优秀试卷科目
        ra.setActiontype(3);
        List<Map> wjsjkm = eReportClassService.listXwKm(ra);
        map.put("wjsjkm",wjsjkm);//违纪试卷科目
        ERstudentAction arank = new ERstudentAction();
        arank.setExamid(examid);
        arank.setClassid(classid);
        arank.setActiontype(1);
        List<Map> wjxw = eReportClassService.listXwXs(arank);
        map.put("wjfx", wjxw);//违纪行为分析
        arank.setActiontype(2);
        List<Map> yxsj = eReportClassService.listXwXs(arank);
        map.put("yxsj", yxsj);//优秀试卷分析
        arank.setActiontype(3);
        List<Map> wjsj = eReportClassService.listXwXs(arank);
        map.put("wjsj", wjsj);//违纪试卷分析
        map.put("showRank", rank.getShowrank());//显示排名得分0保密1分数2分数+班排名3分数+班/校排名
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * @Description 获取考试PDF报告基础信息
     * @Param [rank]
     * @Author ywx
     * @Date 2023/3/2 15:46
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/pdf_info")
    public ResultVo getPdfInfo(@RequestBody ERankParamVo rank) {
        Integer examid = rank.getExamid();
        Integer classid = rank.getClassid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, classid, "班级id", 1});
        Map map = eReportClassService.getPdfInfo(examid, classid);
        return new ResultVo(0, "获取成功", map);
    }

    /**
    * @Description 班级报告-获取pdf报告状态和班级pdf地址
    * @Author WN
    * @Date 2023/2/28 17:03
    */
    @PostMapping("/rstate")
    public ResultVo getExamReportClassstate(@RequestBody ERankParamVo rbase) {
        Integer examid = rbase.getExamid();
        Integer classid = rbase.getClassid();
        N_Utils.validation(new Object[]{examid, "考试id", 1,examid, "班级id", 1});
        Map map = eReportClassService.getReportClass(examid,classid);
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * @Description 单科pdf报告
     * @Param [rank]
     * @Author ywx
     * @Date 2023/3/7 11:34
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/pdf_dk")
    public ResultVo toPdfForDk(@RequestBody ERankParamVo rank) {
        Integer examid = rank.getExamid();
        Integer classid = rank.getClassid();
        String subjectid = rank.getSubjectid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, classid, "班级id", 1, subjectid, "科目id", 2});
        rank.setShowrank(eReportClassService.getShowRank(rank.getExamid()));
        Map map = new HashMap();
        Map dkgk = eReportClassService.getDkKsGk(rank);//单科考试概况
        dkgk.put("xkpjf", eReportClassService.listPjf(rank));//学科平均分
        dkgk.put("dltj", eReportClassService.listDkGkDjTj(rank));//等级统计
        Map gzxs = new HashMap();
        rank.setRanktype(1);
        gzxs.put("dfjb", eReportClassService.listGzXs(rank));//大幅进步
        rank.setRanktype(2);
        gzxs.put("dftb", eReportClassService.listGzXs(rank));//大幅退步
        rank.setRanktype(3);
        gzxs.put("ljs", eReportClassService.listGzXs(rank));//临界生
        rank.setRanktype(4);
        gzxs.put("bds", eReportClassService.listGzXs(rank));//波动生
        dkgk.put("gzxs", gzxs);//需关注学生
        rank.setRanktype(1);
        dkgk.put("gpct", eReportClassService.listGpCt(rank));//高频错题
        map.put("dkgk", dkgk);//单科概况

        map.put("sjfx", eReportClassService.getSjFx(rank));//试卷分析

        ERstudentAction ra = new ERstudentAction();
        ra.setExamid(examid);
        ra.setClassid(classid);
        ra.setSubjectid(subjectid);
        ra.setActiontype(2);
        map.put("yxsjkm", eReportClassService.listXwKm(ra));//优秀试卷科目
        ra.setActiontype(3);
        map.put("wjsjkm", eReportClassService.listXwKm(ra));//违纪试卷科目

        ERstudentAction arank = new ERstudentAction();
        arank.setExamid(examid);
        arank.setClassid(classid);
        arank.setSubjectid(subjectid);
        arank.setActiontype(2);
        map.put("yxsj", eReportClassService.listXwXs(arank));//优秀试卷分析
        arank.setActiontype(3);
        map.put("wjsj", eReportClassService.listXwXs(arank));//违纪试卷分析
        map.put("showRank", rank.getShowrank());//显示排名得分0保密1分数2分数+班排名3分数+班/校排名
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * @Description 获取单科考试PDF报告基础信息
     * @Param [rank]
     * @Author ywx
     * @Date 2023/3/7 14:56
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/pdf_dkinfo")
    public ResultVo getPdfDkInfo(@RequestBody ERankParamVo rank) {
        Integer examid = rank.getExamid();
        Integer classid = rank.getClassid();
        String subjectid = rank.getSubjectid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, classid, "班级id", 1, subjectid, "科目id", 2});
        Map map = eReportClassService.getPdfDkInfo(examid, classid, subjectid);
        return new ResultVo(0, "获取成功", map);
    }

    /**
     * @Description 单科报告-获取pdf报告状态和地址
     * @Param [rbase]
     * @Author ywx
     * @Date 2023/3/7 15:01
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/rstate_dk")
    public ResultVo getExamDkReportClassstate(@RequestBody ERankParamVo rbase) {
        Integer examid = rbase.getExamid();
        Integer classid = rbase.getClassid();
        String subjectid = rbase.getSubjectid();
        N_Utils.validation(new Object[]{examid, "考试id", 1, classid, "班级id", 1, subjectid, "科目id", 2});
        Map map = eReportClassService.getReportDkClass(examid, classid, subjectid);
        return new ResultVo(0, "获取成功", map);
    }
}
