package com.xhkjedu.sapi.controller.region;

import com.xhkjedu.sapi.service.region.SAnalyzeService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import com.xhkjedu.sapi.vo.analyze.SchoolParams;
import com.xhkjedu.sapi.vo.region.RegionParam;
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.List;
import java.util.Map;

/**
 * @author ywx
 * @classname SAnalyzeController
 * @description 学校--可视化大数据总览
 * @date 2021/6/24 11:01
 **/
@RestController
@RequestMapping("/sanalyze")
public class SAnalyzeController {
    @Resource
    private SAnalyzeService sAnalyzeService;

    @PostMapping("/qsubject")
    public ResultVo listQuestionSubjectNum(@RequestBody SchoolParams param){
        Integer schoolid = param.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        Map map = sAnalyzeService.listResourceTypeNum(schoolid, "question");
        return new ResultVo(0,"获取试题科目统计成功",map);
    }

    @PostMapping("/rtype")
    public ResultVo listResourceTypeNum(@RequestBody SchoolParams param){
        Integer schoolid = param.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        Map map = sAnalyzeService.listResourceTypeNum(schoolid, "resource");
        return new ResultVo(0,"获取资源类型统计成功",map);
    }

    @PostMapping("/rclass")
    public ResultVo listResourceClassNum(@RequestBody SchoolParams param){
        Integer schoolid = param.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        List<Map> map = sAnalyzeService.listResourceClassNum(schoolid);
        return new ResultVo(0,"获取资源类型统计成功",map);
    }

    @PostMapping("/rsubject")
    public ResultVo listResourceSubjectNum(@RequestBody SchoolParams param){
        Integer schoolid = param.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        List<Map> map = sAnalyzeService.listResourceSubjectNum(schoolid);
        return new ResultVo(0,"获取资源科目统计成功",map);
    }

    @PostMapping("/ctslist")
    public ResultVo listClassTeacherStudentNum(@RequestBody SchoolParams param){
        Integer schoolid = param.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        Map map = sAnalyzeService.listClassTeacherStudentNum(param);
        return new ResultVo(0,"获取班级、教师、学生总量成功",map);
    }

    @PostMapping("/fwllist")
    public ResultVo listAccess(@RequestBody RegionParam param){
        Integer schoolid = param.getSchoolid();
        Integer begintime = param.getBegintime();
        Integer endtime = param.getEndtime();
        N_Utils.validation(new Object[]{schoolid,"学校id",1,begintime,"开始时间",1,endtime,"结束时间",1});
        Map map = sAnalyzeService.listAccess(schoolid, begintime, endtime);
        return new ResultVo(0,"获取访问量统计成功",map);
    }

    //应用监控统计
    @PostMapping("/jklist")
    public ResultVo listAppMonitorMonth(@RequestBody RegionParam param){
        Integer schoolid = param.getSchoolid();
        Integer begintime = param.getBegintime();
        Integer endtime = param.getEndtime();
        N_Utils.validation(new Object[]{schoolid,"学校id",1,begintime,"开始时间",1,endtime,"结束时间",1});
        Map map = sAnalyzeService.listAppMonitorMonth(schoolid, begintime, endtime);
        return new ResultVo(0,"获取应用监控统计成功",map);
    }

    //教学统计--作业提交率
    @PostMapping("/zylist")
    public ResultVo listPaperCommitMonth(@RequestBody RegionParam param){
        Integer schoolid = param.getSchoolid();
        Integer begintime = param.getBegintime();
        Integer endtime = param.getEndtime();
        N_Utils.validation(new Object[]{schoolid,"学校id",1,begintime,"开始时间",1,endtime,"结束时间",1});
        List<Map> map = sAnalyzeService.listPaperCommitMonth(param);
        return new ResultVo(0,"获取教学统计作业提交率成功",map);
    }
    //教学统计--预习提交率
    @PostMapping("/yxlist")
    public ResultVo listGuideCommitMonth(@RequestBody RegionParam param){
        Integer schoolid = param.getSchoolid();
        Integer begintime = param.getBegintime();
        Integer endtime = param.getEndtime();
        N_Utils.validation(new Object[]{schoolid,"学校id",1,begintime,"开始时间",1,endtime,"结束时间",1});
        List<Map> map = sAnalyzeService.listGuideCommitMonth(param);
        return new ResultVo(0,"获取教学任务预习统计信息成功",map);
    }

    //课堂使用统计--使用次数
    @PostMapping("/roomnum")
    public ResultVo listRoomNumMonth(@RequestBody RegionParam param){
        Integer schoolid = param.getSchoolid();
        Integer begintime = param.getBegintime();
        Integer endtime = param.getEndtime();
        N_Utils.validation(new Object[]{schoolid,"学校id",1,begintime,"开始时间",1,endtime,"结束时间",1});
        Map map = sAnalyzeService.listRoomNumMonth(param);
        return new ResultVo(0,"获取课堂使用数量成功",map);
    }

    //课堂使用统计--互动次数
    @PostMapping("/roomask")
    public ResultVo listRoomAskNumMonth(@RequestBody RegionParam param){
        Integer schoolid = param.getSchoolid();
        Integer begintime = param.getBegintime();
        Integer endtime = param.getEndtime();
        N_Utils.validation(new Object[]{schoolid,"学校id",1,begintime,"开始时间",1,endtime,"结束时间",1});
        List<Map> map = sAnalyzeService.listRoomAskNumMonth(param);
        return new ResultVo(0,"获取课堂互动数量成功",map);
    }

}
