派生自 projectDept/qhighschool

EricsHu
2023-11-24 0ad2f07a292895eeb3b9618eb1e275568c63a59e
src/main/java/com/qxueyou/scc/controller/ClassController.java
@@ -40,7 +40,7 @@
 *
 * @author chenjunliang
 */
@Api(tags="班级管理接口")
@Api(tags = "班级管理接口")
@RestController
@CrossOrigin
@RequestMapping("/admin/class")
@@ -60,10 +60,11 @@
    @Autowired
    ITeacherService teacherService;
   @Autowired
   IClassLectureService clsLectureService;
    @Autowired
    IClassLectureService clsLectureService;
    //---------------------------------------------------------------------------------app接口--------------------------------------------------------------------------------------------------------------------/
    /**
     * 获取正常班级列表
     *
@@ -73,7 +74,7 @@
     * @return
     */
    @ApiOperation(value = "获取正常班级列表", notes = "")
   @GetMapping(value = "/app/classList")
    @GetMapping(value = "/app/classList")
    public Result classList(@RequestParam(defaultValue = "") String keyword, Pager pager) {
        return this.classService.classList(keyword, pager, 1);
    }
@@ -87,7 +88,7 @@
     * @return
     */
    @ApiOperation(value = "获取历史班级列表", notes = "")
   @GetMapping(value = "/app/historyClassList")
    @GetMapping(value = "/app/historyClassList")
    public Result historyClassList(@RequestParam(defaultValue = "") String keyword, Pager pager) {
        return this.classService.classList(keyword, pager, 2);
    }
@@ -101,13 +102,13 @@
     */
    @ApiOperation(value = "学员详情", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "studentId", value = "学员id", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
            @ApiImplicitParam(name = "studentId", value = "学员id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
    })
      @GetMapping(value = "/app/studentInfo")
      public Result studentInfo(String classId, String studentId) {
         return this.studentService.queryStudent(classId, studentId);
      }
    @GetMapping(value = "/app/studentInfo")
    public Result studentInfo(String classId, String studentId) {
        return this.studentService.queryStudent(classId, studentId);
    }
    /**
     * 学员详情
@@ -118,93 +119,89 @@
     */
    @ApiOperation(value = "学员学习进度", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "studentId", value = "学员id", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
            @ApiImplicitParam(name = "studentId", value = "学员id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
    })
      @GetMapping(value = "/app/studentProgress")
      public Result studentProgress(String classId, String studentId) {
         return this.studentService.studentProgress(classId, studentId);
      }
    @GetMapping(value = "/app/studentProgress")
    public Result studentProgress(String classId, String studentId) {
        return this.studentService.studentProgress(classId, studentId);
    }
      /**
       * 获取首页数据排行
       *
       *
       * @param subjectId
       */
       @ApiOperation(value = "班级排行榜", notes = "")
       @ApiImplicitParams({
           @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
       })
      @GetMapping(value = "/app/getDataDesc")
      public Result getDataDesc(String classId, String subjectId) {
         return subjectService.getDataDesc(classId, subjectId);
      }
    /**
     * 获取首页数据排行
     *
     * @param subjectId
     */
    @ApiOperation(value = "班级排行榜", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/getDataDesc")
    public Result getDataDesc(String classId, String subjectId) {
        return subjectService.getDataDesc(classId, subjectId);
    }
    /**
     * 学员课程进度
     *
     *
     * @param subjectId
    */
     */
    @ApiOperation(value = "学员课程进度", notes = "")
      @ApiImplicitParams({
         @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
         @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType="query", dataType = "String"),
         @ApiImplicitParam(name = "studentId", value = "学员id", required = true, paramType="query", dataType = "String"),
      })
      @GetMapping(value = "/app/studentSubjectProgress")
      public Result studentSubjectProgress(String classId, String subjectId, String studentId) {
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "studentId", value = "学员id", required = true, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/studentSubjectProgress")
    public Result studentSubjectProgress(String classId, String subjectId, String studentId) {
         return new Result(true, "success", CollectionUtils.newObjectMap("homework", this.subjectService.studentSubjectHomeworkProgress(classId, subjectId, studentId),
               "exam", this.subjectService.studentSubjectExamProgress(classId, subjectId, studentId)));
      }
        return new Result(true, "success", CollectionUtils.newObjectMap("homework", this.subjectService.studentSubjectHomeworkProgress(classId, subjectId, studentId),
                "exam", this.subjectService.studentSubjectExamProgress(classId, subjectId, studentId)));
    }
    /**
     * 班级学员课程总体进度
     *
     *
     * @param classId
    */
     */
    @ApiOperation(value = "班级学员课程总体进度", notes = "")
      @ApiImplicitParams({
         @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
      })
      @GetMapping(value = "/app/studentAllSubjectProgress")
      public Result studentSubjectProgress(String classId) {
       if(StringUtils.isEmpty(classId)) {
          return new Result(false, "班级id参数不能为空");
       }
         return new Result(true, "success", CollectionUtils.newObjectMap("subjectList", this.subjectService.studentSubjectProgress(classId, new Pager())));
      }
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/studentAllSubjectProgress")
    public Result studentSubjectProgress(String classId) {
        if (StringUtils.isEmpty(classId)) {
            return new Result(false, "班级id参数不能为空");
        }
        return new Result(true, "success", CollectionUtils.newObjectMap("subjectList", this.subjectService.studentSubjectProgress(classId, new Pager())));
    }
    /**
     * 班级学员课件总体进度
     *
     *
     * @param classId
     */
    @ApiOperation(value = "班级学员课件总体进度", notes = "")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
       @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType="query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/studentSubjectLectureProgress")
    public Result studentSubjectLectureProgress(String classId, String subjectId) {
       if(StringUtils.isEmpty(classId)) {
          return new Result(false, "班级id参数不能为空");
       }
       if(StringUtils.isEmpty(subjectId)) {
          return new Result(false, "课程id参数不能为空");
       }
        if (StringUtils.isEmpty(classId)) {
            return new Result(false, "班级id参数不能为空");
        }
        if (StringUtils.isEmpty(subjectId)) {
            return new Result(false, "课程id参数不能为空");
        }
       //获取所有课件
      List<Map<String, Object>> lectures = this.subjectService.studentSubjectLectureProgress(subjectId, classId);
      //获取所以章节
      List<ClsSubjectChapter> chapterLst = clsLectureService.getChapterLectures(clsLectureService.getListChapter(classId, subjectId, null), lectures);
        //获取所有课件
        List<Map<String, Object>> lectures = this.subjectService.studentSubjectLectureProgress(subjectId, classId);
        //获取所以章节
        List<ClsSubjectChapter> chapterLst = clsLectureService.getChapterLectures(clsLectureService.getListChapter(classId, subjectId, null), lectures);
      return new Result(true, "success", CollectionUtils.newObjectMap("count",clsLectureService.stuLectureCountBySubject(subjectId, classId), "listData", QBeanUtils.listBean2ListMap(chapterLst,
            CollectionUtils.newStringMap("name", "name", "chapterId", "chapterId", "lectures", "lectures"))));
        return new Result(true, "success", CollectionUtils.newObjectMap("count", clsLectureService.stuLectureCountBySubject(subjectId, classId), "listData", QBeanUtils.listBean2ListMap(chapterLst,
                CollectionUtils.newStringMap("name", "name", "chapterId", "chapterId", "lectures", "lectures"))));
    }
    /**
@@ -216,13 +213,13 @@
     * @param mobilePhone   手机号
     */
    @ApiOperation(value = "app端学员注册接口", notes = "")
      @ApiImplicitParams({
         @ApiImplicitParam(name = "name", value = "名称", required = true, paramType="query", dataType = "String"),
         @ApiImplicitParam(name = "studentNumber", value = "学号", required = true, paramType="query", dataType = "String"),
         @ApiImplicitParam(name = "sex", value = "性别(0女,1男)", required = true, paramType="query", dataType = "String"),
         @ApiImplicitParam(name = "mobilePhone", value = "手机号", required = false, paramType="query", dataType = "String"),
         @ApiImplicitParam(name = "orgId", value = "机构", required = true, paramType="query", dataType = "String"),
      })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "studentNumber", value = "学号", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sex", value = "性别(0女,1男)", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "mobilePhone", value = "手机号", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orgId", value = "机构", required = true, paramType = "query", dataType = "String"),
    })
    @PostMapping(value = "/app/studentRegister")
    public Result studentRegister(String name, String studentNumber, Boolean sex, String mobilePhone, String orgId) {
        return studentService.insertStudent(null, name, studentNumber, sex, mobilePhone, orgId);
@@ -242,18 +239,20 @@
     */
    @PostMapping(value = "add")
    public Result add(String className, String classNumber, String startTime, String endTime, String subjectId,
                      String teacherId,String chargeClassName ) {
                      String teacherId, String chargeClassName) {
        try {
           return classService.insertClass(className, classNumber, DateUtils.convertStringToDate(startTime),
                    DateUtils.convertStringToDate(endTime), subjectId, teacherId,chargeClassName);
            return classService.insertClass(className, classNumber, DateUtils.convertStringToDate(startTime),
                    DateUtils.convertStringToDate(endTime), subjectId, teacherId, chargeClassName);
        } catch (ParseException e) {
            log.error(e, e);
            return new Result(false, "日期参数错误");
        }
    }
    /**
     * 新增补考分组
     *
     * @param className   班级名称
     * @param classNumber 班级编码
     * @param startTime   开班时间
@@ -262,17 +261,17 @@
     */
    @PostMapping(value = "addRe")
    public Result addRe(String className, String classNumber, String startTime, String endTime, String subjectId,
                      String teacherId,String classTypes) {
                        String teacherId, String classTypes) {
        try {
         ClsClass reClass = classService.getReClass("1");
           //如果补考类型分组不存在,新增
         if (reClass==null){
            return classService.insertReClass(className, classNumber, DateUtils.convertStringToDate(startTime),
                  DateUtils.convertStringToDate(endTime), subjectId, teacherId,classTypes);
         }else {
            //存在返回false
            return new Result(false, "补考分组已存在");
         }
            ClsClass reClass = classService.getReClass("1");
            //如果补考类型分组不存在,新增
            if (reClass == null) {
                return classService.insertReClass(className, classNumber, DateUtils.convertStringToDate(startTime),
                        DateUtils.convertStringToDate(endTime), subjectId, teacherId, classTypes);
            } else {
                //存在返回false
                return new Result(false, "补考分组已存在");
            }
        } catch (ParseException e) {
            log.error(e, e);
            return new Result(false, "日期参数错误");
@@ -285,7 +284,7 @@
    @GetMapping(value = "getSubjectLst")
    public Result getSubjectlst() {
        List<Subject> subjectLst = subjectService.list("", null, "",Subject.TYPE_ORG_SUBJECT, 1000, 1);
        List<Subject> subjectLst = subjectService.list("", null, "", Subject.TYPE_ORG_SUBJECT, 1000, 1);
        return new Result(true, "success", QBeanUtils.listBean2ListMap(subjectLst,
                CollectionUtils.newStringMap("name", "subjectName", "subjectId", "subjectId")));
@@ -300,10 +299,10 @@
     * @return
     */
    @ApiOperation(value = "获取班级列表", notes = "")
    @SuppressWarnings({ "unchecked", "rawtypes" })
   @GetMapping(value = "list")
    @SuppressWarnings({"unchecked", "rawtypes"})
    @GetMapping(value = "list")
    public Result list(@RequestParam(defaultValue = "") String keyword,
                       @RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "1")Integer pageType) {
                       @RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "1") Integer pageType) {
        String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId());
        // 获取数据
@@ -311,24 +310,24 @@
        // 获取班级总数
        int count = classService.getClassLstCount(keyword, teacherId, pageType);
        // 转成前端所需字段和结构
       List<Map<String, Object>> lstResult = QBeanUtils.listBean2ListMap(clsLst,
                CollectionUtils.newStringMap("name", "className", "classId", "classId", "classNumber", "classNumber","classTypes","classTypes",
        List<Map<String, Object>> lstResult = QBeanUtils.listBean2ListMap(clsLst,
                CollectionUtils.newStringMap("name", "className", "classId", "classId", "classNumber", "classNumber", "classTypes", "classTypes",
                        "studentCount", "studentCount", "createTime", "createTime", "startTime", "startTime", "endTime",
                        "endTime", "subjects", "sbjLst","chargeClassName","chargeClassName","chargeClassId","chargeClassId"));
                        "endTime", "subjects", "sbjLst", "chargeClassName", "chargeClassName", "chargeClassId", "chargeClassId"));
        // 单独处理课程的字段和结构
        for (Map<String, Object> item : lstResult) {
           if(item.get("sbjLst")==null){
              continue;
            if (item.get("sbjLst") == null) {
                continue;
           }
            }
            item.put("subjectLst",
                   QBeanUtils.listBean2ListMap(
                         this.filtCurrTeacherSubjects((List<Subject>) item.get("sbjLst"),teacherId),
                           CollectionUtils.newStringMap("subjectId", "subjectId", "name", "subjectName",
                                 "teacherId","teacherId","teacherName","teacherName","schoolYear","schoolYear","term","term")));
            item.put("subjectLst",
                    QBeanUtils.listBean2ListMap(
                            this.filtCurrTeacherSubjects((List<Subject>) item.get("sbjLst"), teacherId),
                            CollectionUtils.newStringMap("subjectId", "subjectId", "name", "subjectName",
                                    "teacherId", "teacherId", "teacherName", "teacherName", "schoolYear", "schoolYear", "term", "term")));
            item.remove("sbjLst");
        }
@@ -337,20 +336,20 @@
    }
    private List<Subject> filtCurrTeacherSubjects(List<Subject> subjects,String teacherId){
       if(StringUtils.isEmpty(teacherId) || subjects==null || subjects.size()==0){
          return subjects;
       }
    private List<Subject> filtCurrTeacherSubjects(List<Subject> subjects, String teacherId) {
        if (StringUtils.isEmpty(teacherId) || subjects == null || subjects.size() == 0) {
            return subjects;
        }
       List<Subject> newSubjects = new ArrayList<Subject>(subjects.size());
        List<Subject> newSubjects = new ArrayList<Subject>(subjects.size());
       for(Subject subject:subjects){
          if(teacherId.equals(subject.getTeacherId())){
             newSubjects.add(subject);
          }
       }
        for (Subject subject : subjects) {
            if (teacherId.equals(subject.getTeacherId())) {
                newSubjects.add(subject);
            }
        }
       return newSubjects;
        return newSubjects;
    }
@@ -362,7 +361,7 @@
     */
    @ApiOperation(value = "查询班级基本信息", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "queryClass")
    public Result findClass(String classId) {
@@ -371,10 +370,10 @@
        return new Result(true, "success", QBeanUtils.bean2Map(cls,
                CollectionUtils.newStringMap("name", "className", "classId", "classId", "classNumber", "classNumber",
                        "studentCount", "studentCount", "createTime", "createTime", "startTime", "startTime", "endTime","endTime","classTypes",
                        "studentCount", "studentCount", "createTime", "createTime", "startTime", "startTime", "endTime", "endTime", "classTypes",
                        "classTypes", "subjects", "subjectLst", "needJoinAudit", "needJoinAudit", "needQuitAudit",
                        "needQuitAudit", "showAnalysisAfterExer", "showAnalysisAfterExer", "canMultiExer",
                        "canMultiExer", "needForum", "needForum", "teacherId", "teacherId")));
                        "canMultiExer", "needForum", "needForum", "teacherId", "teacherId", "chargeClassName", "chargeClassName")));
    }
    /**
@@ -437,11 +436,11 @@
                         @RequestParam(defaultValue = "false") Boolean showAnalysisAfterExer,
                         @RequestParam(defaultValue = "false") Boolean canMultiExer,
                         @RequestParam(defaultValue = "false") Boolean needForum,
    String chargeClassName) {
                         String chargeClassName) {
        try {
            return classService.updateClass(classId, className, classNumber, DateUtils.convertStringToDate(startTime),
                    DateUtils.convertStringToDate(endTime), subjectId, needJoinAudit, needQuitAudit,
                    showAnalysisAfterExer, canMultiExer, needForum, teacherId,chargeClassName);
                    showAnalysisAfterExer, canMultiExer, needForum, teacherId, chargeClassName);
        } catch (ParseException e) {
            log.error(e, e);
            return new Result(false, "日期参数错误");
@@ -459,7 +458,7 @@
     */
    @ApiOperation(value = "获取学员列表", notes = "学习状态说明(0, 未开始 。 1, 学习中 。 2, 已结束, 3, 待激活 。 4, 已冻结)")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType="query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = true, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "lstStudent4Class")
    public Result lstStudent4Class(String classId, @RequestParam(defaultValue = "10") Integer limit,
@@ -492,9 +491,15 @@
     * @param mobilePhone   手机号
     */
    @PostMapping(value = "addStudent")
    public Result addStudent(String classId, String name, String studentNumber, Boolean sex, String mobilePhone,String comName) {
    public Result addStudent(String classId, String name, String studentNumber, Boolean sex, String mobilePhone, String comName,
                             String photo, String passporName, String nationality, String ancestralHome, String birthday, String birthplace,
                             String chinaStatus, String registeredAddress, String homeAddress, String religiousBelief, String email,
                             String workUnit) {
        return studentService.insertStudent(classId, name, studentNumber, sex, mobilePhone, ClientUtils.getOrgId(),comName);
        return studentService.insertStudent(classId, name, studentNumber, sex, mobilePhone, ClientUtils.getOrgId(), comName,
                photo,  passporName,  nationality,  ancestralHome,  birthday,  birthplace,
                chinaStatus,  registeredAddress,  homeAddress,  religiousBelief,  email,
                workUnit);
    }
@@ -508,12 +513,17 @@
     * @param mobilePhone   手机号
     */
    @PostMapping(value = "updateStudent")
    public Result updateStudent(String studentId, String name,String password, String studentNumber, Boolean sex, String mobilePhone) {
    public Result updateStudent(String studentId, String name, String password, String studentNumber, Boolean sex, String mobilePhone,
                                String photo, String passporName, String nationality, String ancestralHome, String birthday, String birthplace,
                                String chinaStatus, String registeredAddress, String homeAddress, String religiousBelief, String email,
                                String workUnit, String graduationDestination) {
        return studentService.updateStudent(studentId, name,password, studentNumber, sex, mobilePhone);
        return studentService.updateStudent(studentId, name, password, studentNumber, sex, mobilePhone,
                 photo,  passporName,  nationality,  ancestralHome,  birthday,  birthplace,
                 chinaStatus,  registeredAddress,  homeAddress,  religiousBelief,  email,
                 workUnit,  graduationDestination);
    }
    /**
@@ -548,41 +558,43 @@
    /**
     * 添加班级课程
     *
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     *
     */
    @PostMapping(value = "addClsSubject")
    public Result addClsSubject(String classId, String origSubjectId,String teacherId,Integer schoolYear ,Integer term) throws IllegalAccessException, InvocationTargetException {
       return  this.subjectService.addClsSubject(classId,origSubjectId,teacherId,schoolYear,term);
    public Result addClsSubject(String classId, String origSubjectId, String teacherId, Integer schoolYear, Integer term) throws IllegalAccessException, InvocationTargetException {
        return this.subjectService.addClsSubject(classId, origSubjectId, teacherId, schoolYear, term);
    }
    /**
     * 更新班级课程
     */
    @PostMapping(value = "updateClsSubject")
    public Result updateClsSubject(String classId,String subjectId, String origSubjectId,String teacherId,Integer schoolYear ,Integer term) {
       return this.subjectService.updateClsSubject(classId,subjectId,origSubjectId,teacherId,schoolYear,term);
    public Result updateClsSubject(String classId, String subjectId, String origSubjectId, String teacherId, Integer schoolYear, Integer term) {
        return this.subjectService.updateClsSubject(classId, subjectId, origSubjectId, teacherId, schoolYear, term);
    }
    /**
     * 删除班级课程
     */
    @GetMapping(value = "deleteClsSubject")
    public Result deleteClsSubject(String classId,String subjectIds){
       //删除课程及课程班级关联关系
       return subjectService.deleteClsSubject(classId,subjectIds.split(","));
    public Result deleteClsSubject(String classId, String subjectIds) {
        //删除课程及课程班级关联关系
        return subjectService.deleteClsSubject(classId, subjectIds.split(","));
    }
    /**
     * 所有班级列表
     *
     * @param subjectId 根据subjectId过滤
     * @return
     */
   @RequestMapping(value = "/selectlist", method = RequestMethod.GET)
   public @ResponseBody List<Map<String,Object>> classList() {
      return classService.queryAllClassIdAndName();
   }
    @RequestMapping(value = "/selectlist", method = RequestMethod.GET)
    public @ResponseBody
    List<Map<String, Object>> classList() {
        return classService.queryAllClassIdAndName();
    }
    /**
     * 获取学员详细信息