派生自 projectDept/qhighschool

Administrator
2022-11-29 8c99e2d8b6c1e0d9cde6abbe80b4df75be19f6d1
src/main/java/com/qxueyou/scc/stucontroller/StuSubjectController.java
@@ -1,12 +1,21 @@
package com.qxueyou.scc.stucontroller;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.querydsl.jpa.hibernate.HibernateQueryFactory;
import com.qxueyou.scc.base.dao.BaseDAO;
import com.qxueyou.scc.base.model.UserInfoWrapper;
import com.qxueyou.scc.teach.subject.model.SubjectUtils;
import com.qxueyou.scc.user.model.User;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.orm.hibernate4.HibernateTemplate;
import org.springframework.orm.jpa.vendor.HibernateJpaSessionFactoryBean;
import org.springframework.web.bind.annotation.*;
import com.alibaba.druid.util.StringUtils;
@@ -34,6 +43,7 @@
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -41,429 +51,450 @@
 * 学习端 课程前端控制器
 *
 * @author chenjunliang
 *
 */
@Api(tags= "课程管理-学员端")
@Api(tags = "课程管理-学员端")
@RestController
@CrossOrigin(origins="*",maxAge=3600)
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping(value = "stu/subject")
public class StuSubjectController {
   @Autowired
   ISubjectService subjectService;
    @Autowired
    ISubjectService subjectService;
   @Autowired
   ILectureService lectureService;
    @Autowired
    ILectureService lectureService;
   @Autowired
   IClassLectureService clsLectureService;
    @Autowired
    IClassLectureService clsLectureService;
   @Autowired
   IResAudioService audioService;
    @Autowired
    IResAudioService audioService;
   @Autowired
   ProgressDAO progressDao;
    @Autowired
    ProgressDAO progressDao;
   @Autowired
   ITopicService topicService;
    @Autowired
    ITopicService topicService;
   @Autowired
   IEvaluateService evaluateService;
    @Autowired
    IEvaluateService evaluateService;
   //--------------------------------------------------------------app端接口---------------------------------------------------------------------------------------------------
   /**
    * 学习端获取 所有课件
    *
    * @param classId
    * @return 状态说明(0,视频。1,音频。2,文档。3,练习。)
    */
   @ApiOperation(value = "获取班级所有课件-学习端", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "sort", value = "排序方式(desc从大到小,asc从小到大)", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/getCoursewareLstByClassId")
   public Result appCoursewareLst(String classId, @RequestParam(defaultValue="desc")String sort, Pager pager) {
      System.out.println(classId);
      return clsLectureService.listSubjectLecture(CommonUtils.getClassId(classId), sort, pager);
   }
    //--------------------------------------------------------------app端接口---------------------------------------------------------------------------------------------------
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "学习端获取课程学年列表")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/termList")
   public Result termList(String classId) {
      classId = CommonUtils.getClassId(classId);
      if(StringUtils.isEmpty(classId)) {
          return new Result(false, "班级id不能为空");
       }
      //课程
      List<Map<String, Object>> lstSubject = subjectService.clsSubjectlist(classId, null, null);
      //组装的学期和课程
      List<Map<String, Object>> lstTerm = subjectService.termSubjectList(classId, lstSubject);
      return new Result(true, "success",CollectionUtils.newObjectMap("termList", lstTerm, "allSubject", lstSubject));
   }
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "我的课程按学期分类")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/myTermSubjectList")
   public Result myTermSubjectList(String classId) {
      classId = CommonUtils.getClassId(classId);
      System.out.println("vvvvvvvvv"+classId);
      if(StringUtils.isEmpty(classId)) {
          return new Result(false, "班级id不能为空");
       }
      return new Result(true, "success",subjectService.myTermSubjectList(classId));
   }
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "我的课程按时间排序")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/mySubjectList")
   public Result mySubjectList(String classId, Pager pager ) {
//      System.out.println("0.0.0.0"+classId);
      classId = CommonUtils.getClassId(classId);
      long count = subjectService.myClsSubjectCount(classId);
      return new Result(true, "success",
            CollectionUtils.newObjectMap("count", count, "listData", subjectService.mySubjectList(classId, pager)));
   }
   /**
    * 我的课程详情
    *
    * @param subjectId
    * @param classId
    * @return
    */
   @ApiOperation(value = "我的课程详情")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/mySubjectInfo")
   public Result mySubjectInfo(String subjectId, String classId) {
      classId = CommonUtils.getClassId(classId);
      if(StringUtils.isEmpty(classId)) {
          return new Result(false, "班级id不能为空");
       }
      if(StringUtils.isEmpty(subjectId)) {
          return new Result(false, "课程id不能为空");
       }
      return new Result(true, "success", subjectService.mySubjectInfo(subjectId, classId));
   }
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "我的班级信息")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/myClassInfo")
   public Result myClassInfo(String classId) {
      classId = ClientUtils.getClassId();
      if(StringUtils.isEmpty(classId)) {
          return new Result(false, "班级id不能为空");
       }
      return new Result(true, "success",subjectService.myClassInfo(classId));
   }
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "学习端获取课程列表")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "schoolYear", value = "学年", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "term", value = "学期", required = true, paramType="query", dataType = "String")
   })
   @GetMapping(value = "/app/subjectList")
   public Result subjectList(String classId, Integer schoolYear, Integer term) {
      return new Result(true, "success",subjectService.clsSubjectlist(CommonUtils.getClassId(classId), schoolYear, term));
   }
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "学习端获取课程下课件,按创建时间排序")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "sort", value = "排序方式(desc从大到小,asc从小到大)", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "/app/listLectureBySubject")
   public Result listLectureBySubject(String subjectId, String classId, @RequestParam(defaultValue="desc")String sort, Pager pager) {
      return new Result(true, "success",clsLectureService.listLectureBySubjectOrderCreateTime(subjectId, CommonUtils.getClassId(classId), sort, pager));
   }
   /**
    *
    * 学习端获取其他课件统计
    *
    */
   @ApiOperation(value = "学习端获取其他课件统计")
   @GetMapping(value = "/app/otherLectureCount")
   public Result otherLectureCount() {
      return new Result(true, "success", CollectionUtils.newObjectMap("topicCount",
            topicService.getClassTopicCount(ClientUtils.getClassId()), "evaluate", this.evaluateService.queryStuEvaluateCount()));
   }
   /**
    *
    * 学习端获取课程列表
    *
    */
   @ApiOperation(value = "学习端获取课程下课件,按目录分类", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "type", value = "课件类型", required = false, paramType="query", dataType = "String")
    })
   @GetMapping(value = "/app/coursewareList")
   public Result coursewareList(String classId,String subjectId, String type) {
      classId = CommonUtils.getClassId(classId);
      if(StringUtils.isEmpty(subjectId)) {
         return new Result(false, "课程id不能为空");
      }
      return this.clsLectureService.coursewareChapterList(classId, subjectId, type);
   }
    /**
     * 我的公开课列表
    /**
     * 学习端获取 所有课件
     *
    */
     * @param classId
     * @return 状态说明(0, 视频 。 1, 音频 。 2, 文档 。 3, 练习 。)
     */
    @ApiOperation(value = "获取班级所有课件-学习端", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sort", value = "排序方式(desc从大到小,asc从小到大)", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/getCoursewareLstByClassId")
    public Result appCoursewareLst(String classId, @RequestParam(defaultValue = "desc") String sort, Pager pager) {
        System.out.println(classId);
        return clsLectureService.listSubjectLecture(CommonUtils.getClassId(classId), sort, pager);
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "学习端获取课程学年列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/termList")
    public Result termList(String classId) {
        classId = CommonUtils.getClassId(classId);
        if (StringUtils.isEmpty(classId)) {
            return new Result(false, "班级id不能为空");
        }
        //课程
        List<Map<String, Object>> lstSubject = subjectService.clsSubjectlist(classId, null, null);
        //组装的学期和课程
        List<Map<String, Object>> lstTerm = subjectService.termSubjectList(classId, lstSubject);
        return new Result(true, "success", CollectionUtils.newObjectMap("termList", lstTerm, "allSubject", lstSubject));
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "我的课程按学期分类")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/myTermSubjectList")
    public Result myTermSubjectList(String classId) {
        classId = CommonUtils.getClassId(classId);
        System.out.println("vvvvvvvvv" + classId);
        if (StringUtils.isEmpty(classId)) {
            return new Result(false, "班级id不能为空");
        }
        return new Result(true, "success", subjectService.myTermSubjectList(classId));
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "我的课程按时间排序")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/mySubjectList")
    public Result mySubjectList(String classId, Pager pager) {
//      System.out.println("0.0.0.0"+classId);
        classId = CommonUtils.getClassId(classId);
        long count = subjectService.myClsSubjectCount(classId);
        return new Result(true, "success",
                CollectionUtils.newObjectMap("count", count, "listData", subjectService.mySubjectList(classId, pager)));
    }
    /**
     * 我的课程详情
     *
     * @param subjectId
     * @param classId
     * @return
     */
    @ApiOperation(value = "我的课程详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/mySubjectInfo")
    public Result mySubjectInfo(String subjectId, String classId) {
        classId = CommonUtils.getClassId(classId);
        if (StringUtils.isEmpty(classId)) {
            return new Result(false, "班级id不能为空");
        }
        if (StringUtils.isEmpty(subjectId)) {
            return new Result(false, "课程id不能为空");
        }
        return new Result(true, "success", subjectService.mySubjectInfo(subjectId, classId));
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "我的班级信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/myClassInfo")
    public Result myClassInfo(String classId) {
        classId = ClientUtils.getClassId();
        if (StringUtils.isEmpty(classId)) {
            return new Result(false, "班级id不能为空");
        }
        return new Result(true, "success", subjectService.myClassInfo(classId));
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "学习端获取课程列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "schoolYear", value = "学年", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "term", value = "学期", required = true, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "/app/subjectList")
    public Result subjectList(String classId, Integer schoolYear, Integer term) {
        return new Result(true, "success", subjectService.clsSubjectlist(CommonUtils.getClassId(classId), schoolYear, term));
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "学习端获取课程下课件,按创建时间排序")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sort", value = "排序方式(desc从大到小,asc从小到大)", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "/app/listLectureBySubject")
    public Result listLectureBySubject(String subjectId, String classId, @RequestParam(defaultValue = "desc") String sort, Pager pager) {
        return new Result(true, "success", clsLectureService.listLectureBySubjectOrderCreateTime(subjectId, CommonUtils.getClassId(classId), sort, pager));
    }
    /**
     * 学习端获取其他课件统计
     */
    @ApiOperation(value = "学习端获取其他课件统计")
    @GetMapping(value = "/app/otherLectureCount")
    public Result otherLectureCount() {
        return new Result(true, "success", CollectionUtils.newObjectMap("topicCount",
                topicService.getClassTopicCount(ClientUtils.getClassId()), "evaluate", this.evaluateService.queryStuEvaluateCount()));
    }
    /**
     * 学习端获取课程列表
     */
    @ApiOperation(value = "学习端获取课程下课件,按目录分类", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "课件类型", required = false, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "/app/coursewareList")
    public Result coursewareList(String classId, String subjectId, String type) {
        classId = CommonUtils.getClassId(classId);
        if (StringUtils.isEmpty(subjectId)) {
            return new Result(false, "课程id不能为空");
        }
        return this.clsLectureService.coursewareChapterList(classId, subjectId, type);
    }
    /**
     * 我的公开课列表
     */
    @ApiOperation(value = "我的公开课列表", notes = "")
      @GetMapping(value = "/app/myOpenSubjectList")
      public Result myOpenSubjectList(Pager pager, @RequestParam(defaultValue = "")String keyword) {
         return new Result(true, "success", this.subjectService.myOpenSubjectList(pager.getOffset(), pager.getPageSize(), keyword));
      }
    @GetMapping(value = "/app/myOpenSubjectList")
    public Result myOpenSubjectList(Pager pager, @RequestParam(defaultValue = "") String keyword) {
        return new Result(true, "success", this.subjectService.myOpenSubjectList(pager.getOffset(), pager.getPageSize(), keyword));
    }
    /**
     * 公开课列表
     *
    */
     */
    @ApiOperation(value = "公开课列表", notes = "")
      @GetMapping(value = "/app/openSubjectList")
      public Result openSubjectList(Pager pager, @RequestParam(defaultValue = "")String keyword) {
         return new Result(true, "success", this.subjectService.openSubjectList(pager.getOffset(), pager.getPageSize(), keyword));
      }
    @GetMapping(value = "/app/openSubjectList")
    public Result openSubjectList(Pager pager, @RequestParam(defaultValue = "") String keyword) {
        return new Result(true, "success", this.subjectService.openSubjectList(pager.getOffset(), pager.getPageSize(), keyword));
    }
    /**
     * 公开课详情
     *
     */
    @ApiOperation(value = "公开课详情", notes = "")
      @GetMapping(value = "/app/openSubjectInfo")
      public Result openSubjectInfo(@RequestParam(defaultValue = "")String subjectId) {
         return new Result(true, "success", this.subjectService.openSubjectInfo(subjectId));
      }
    @GetMapping(value = "/app/openSubjectInfo")
    public Result openSubjectInfo(@RequestParam(defaultValue = "") String subjectId) {
        return new Result(true, "success", this.subjectService.openSubjectInfo(subjectId));
    }
   //--------------------------------------------------------后台端接口---------------------------------------------------------------------------------------------------
    //--------------------------------------------------------后台端接口---------------------------------------------------------------------------------------------------
   /**
    * 加载课件tree
    */
   @ApiOperation(value = "加载课件tree", notes = "")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "subjectId", value = "班级id", required = false, paramType="query", dataType = "String")
   })
   @GetMapping(value = "categoryTree")
   public Result categoryTree(String subjectId, String parentId) {
    /**
     * 加载课件tree
     */
    @ApiOperation(value = "加载课件tree", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "subjectId", value = "班级id", required = false, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "categoryTree")
    public Result categoryTree(String subjectId, String parentId) {
//      classId = StringUtils.isEmpty(classId)?ClientUtils.getClassId():classId;
      List<SubjectProgressTreeV> chapterLst = clsLectureService.getChapterTreeVList(subjectId, parentId);
        List<SubjectProgressTreeV> chapterLst = clsLectureService.getChapterTreeVList(subjectId, parentId);
      for (SubjectProgressTreeV v : chapterLst) {
         v.setNodeName(v.getNodeName() + "(" + String.format("%.2f", v.getPercent()*100) + "%)"); //保留两位小数
      }
        for (SubjectProgressTreeV v : chapterLst) {
            v.setNodeName(v.getNodeName() + "(" + String.format("%.2f", v.getPercent() * 100) + "%)"); //保留两位小数
        }
      return new Result(true, "success", QBeanUtils.listBean2ListMap(chapterLst, CollectionUtils
            .newStringMap("nodeName", "name", "id.nodeId", "id", "parentId", "parentId", "percent", "percent")));
   }
        return new Result(true, "success", QBeanUtils.listBean2ListMap(chapterLst, CollectionUtils
                .newStringMap("nodeName", "name", "id.nodeId", "id", "parentId", "parentId", "percent", "percent")));
    }
   /**
    * 学习端获取 所有课件
    *
    * @param classId
    * @return 状态说明(0,视频。1,音频。2,文档。3,练习。)
    */
   @ApiOperation(value = "学习端获取 所有课件", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "subjectId", value = "班级id", required = false, paramType="query", dataType = "String")
   })
   @GetMapping(value = "getCoursewareLstByClassId")
   public Result getCoursewareLst(String subjectId) {
      List<ClsSubjectLecture> lectureLst = clsLectureService.listLecture(subjectId);
    /**
     * 学习端获取 所有课件
     *
     * @param classId
     * @return 状态说明(0, 视频 。 1, 音频 。 2, 文档 。 3, 练习 。)
     */
    @ApiOperation(value = "学习端获取 所有课件", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "subjectId", value = "班级id", required = false, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "getCoursewareLstByClassId")
    public Result getCoursewareLst(String subjectId) {
        List<ClsSubjectLecture> lectureLst = clsLectureService.listLecture(subjectId);
      // id为小节id //返回的数据按照tree的小节排序
      return new Result(true, "success",
        // id为小节id //返回的数据按照tree的小节排序
        return new Result(true, "success",
            QBeanUtils.listBean2ListMap(lectureLst, CollectionUtils.newStringMap("name", "name", "lectureId", "id",
                  "lectureType", "type", "chapterId", "chapterId")));
   }
                QBeanUtils.listBean2ListMap(lectureLst, CollectionUtils.newStringMap("name", "name", "lectureId", "id",
                        "lectureType", "type", "chapterId", "chapterId")));
    }
   /**
    * 获取课件列表
    *
    * @param chapterId
    *            章节id
    * @param type
    *            课件类型
    * @param keyword
    *            搜索关键字
    * @param limit
    *            每页显示几条
    * @param pageNum
    *            页码
    * @return 状态说明(0,视频。1,音频。2,文档。3,练习。)
    */
   @ApiOperation(value = "根据章节获取课件列表", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "chapterId", value = "章节id", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "type", value = "课件类型", required = false, paramType="query", dataType = "String")
   })
   @GetMapping(value = "coursewareListByChapterId")
   public Result coursewareList(String chapterId, String type, String keyword, Integer limit, @RequestParam(defaultValue="1")Integer pageNum) {
    /**
     * 获取课件列表
     *
     * @param chapterId 章节id
     * @param type      课件类型
     * @param keyword   搜索关键字
     * @param limit     每页显示几条
     * @param pageNum   页码
     * @return 状态说明(0, 视频 。 1, 音频 。 2, 文档 。 3, 练习 。)
     */
    @ApiOperation(value = "根据章节获取课件列表", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "chapterId", value = "章节id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "课件类型", required = false, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "coursewareListByChapterId")
    public Result coursewareList(String chapterId, String type, String keyword, Integer limit, @RequestParam(defaultValue = "1") Integer pageNum) {
      List<MyLectureV> lectures = clsLectureService.listLectureV(ClientUtils.getUserId(), chapterId, keyword, limit,
            pageNum, type);
        List<MyLectureV> lectures = clsLectureService.listLectureV(ClientUtils.getUserId(), chapterId, keyword, limit,
                pageNum, type);
      return new Result(true, "success",
            CollectionUtils.newObjectMap("coursewareLst",
                  QBeanUtils.listBean2ListMap(lectures,
                        CollectionUtils.newStringMap("lectureName", "name", "id.lectureId", "id", "lectureType",
                              "type", "lectureUpdateTime", "endUpdateTime", "percent", "percent"))));
        return new Result(true, "success",
                CollectionUtils.newObjectMap("coursewareLst",
                        QBeanUtils.listBean2ListMap(lectures,
                                CollectionUtils.newStringMap("lectureName", "name", "id.lectureId", "id", "lectureType",
                                        "type", "lectureUpdateTime", "endUpdateTime", "percent", "percent"))));
   }
    }
   /**
    * 课件学习进度提交 stu/subject/study
    *
    * @param lectureId
    *            课件id
    * @param from
    *            开始学习位置 ,如视频,则为时分秒(00:10:12),如文档,则无需提交该参数
    * @param to
    *            结束学习位置,同to
    */
   @ApiOperation(value = "提交学习进度")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "lectureId", value = "课件id", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "from", value = "开始学习位置 ,如视频,则为时分秒(00:10:12),如文档,则无需提交该参数", required = true, paramType="query", dataType = "Double"),
      @ApiImplicitParam(name = "to", value = "结束学习位置,同to", required = true, paramType="query", dataType = "Double"),
      @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "lectureParentId", value = "父课件id", required = false, paramType="query", dataType = "String"),
   })
   @GetMapping(value = "study")
   public Result study(String lectureId, @RequestParam(defaultValue = "1") Double from,
         @RequestParam(defaultValue = "0") Double to, String subjectId, String classId, String lectureParentId) {
      String userId = ClientUtils.getUserId();
      classId = CommonUtils.getClassId(classId);
      progressDao.putStudyById(userId, subjectId, lectureId, lectureParentId, classId);// 记录学员每个课程的学习位置;
      progressDao.putStudyByUserId(userId, subjectId, lectureId, lectureParentId, classId);// 记录学员上次学习的位置;
      return clsLectureService.doStudy(lectureId, from, to);
   }
    /**
     * 课件学习进度提交 stu/subject/study
     *
     * @param lectureId 课件id
     * @param from      开始学习位置 ,如视频,则为时分秒(00:10:12),如文档,则无需提交该参数
     * @param to        结束学习位置,同to
     */
    @ApiOperation(value = "提交学习进度")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lectureId", value = "课件id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "from", value = "开始学习位置 ,如视频,则为时分秒(00:10:12),如文档,则无需提交该参数", required = true, paramType = "query", dataType = "Double"),
            @ApiImplicitParam(name = "to", value = "结束学习位置,同to", required = true, paramType = "query", dataType = "Double"),
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "lectureParentId", value = "父课件id", required = false, paramType = "query", dataType = "String"),
    })
    @GetMapping(value = "study")
    public Result study(String lectureId, @RequestParam(defaultValue = "1") Double from,
                        @RequestParam(defaultValue = "0") Double to, String subjectId, String classId, String lectureParentId) {
        String userId = ClientUtils.getUserId();
        classId = CommonUtils.getClassId(classId);
        progressDao.putStudyById(userId, subjectId, lectureId, lectureParentId, classId);// 记录学员每个课程的学习位置;
        progressDao.putStudyByUserId(userId, subjectId, lectureId, lectureParentId, classId);// 记录学员上次学习的位置;
        return clsLectureService.doStudy(lectureId, from, to);
    }
   /**
    * 音频时长提交 stu/subject/submitAudioDuration
    *
    * @param lectureId
    *            课件id
    * @param seconds
    *            时长
    */
   @ApiOperation(value = "音频时长提交")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "lectureId", value = "课件id", required = true, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "seconds", value = "时长", required = true, paramType="query", dataType = "Double")
   })
   @CacheEvict(value = "LectureAudioV", key = "#lectureId")
   @GetMapping(value = "submitAudioDuration")
   public Result submitAudioDuration(String lectureId, double seconds) {
    /**
     * 音频时长提交 stu/subject/submitAudioDuration
     *
     * @param lectureId 课件id
     * @param seconds   时长
     */
    @ApiOperation(value = "音频时长提交")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lectureId", value = "课件id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "seconds", value = "时长", required = true, paramType = "query", dataType = "Double")
    })
    @CacheEvict(value = "LectureAudioV", key = "#lectureId")
    @GetMapping(value = "submitAudioDuration")
    public Result submitAudioDuration(String lectureId, double seconds) {
      LectureAudioV audio = lectureService.readAudioLecture(lectureId);
        LectureAudioV audio = lectureService.readAudioLecture(lectureId);
      return audioService.updateDuration(audio.getAudioId(), (int) seconds);
        return audioService.updateDuration(audio.getAudioId(), (int) seconds);
   }
    }
   /**
    * 课程列表
    *
    * @param clssId
    *            班级id
    * @param startTime
    *            开班时间
    */
   @ApiOperation(value = "课程列表")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType="query", dataType = "String"),
      @ApiImplicitParam(name = "startTime", value = "开班时间", required = false, paramType="query", dataType = "String")
   })
   @GetMapping(value = "getSubjectLst")
   public Result getList(String userId,String classId, String startTime, Integer limit, @RequestParam(defaultValue="1")Integer pageNum, HttpServletRequest request) {
      userId = StringUtils.isEmpty(userId)?ClientUtils.getUserId():userId;
      if(userId == null || userId == ""){
         userId = ClientUtils.getUserId();
      }
      classId = StringUtils.isEmpty(classId)?ClientUtils.getClassId():classId;
      List<MySubjectV> result = subjectService.listMySubjectV(classId,userId);
      return new Result(true, "success",
            QBeanUtils.listBean2ListMap(result,
                  CollectionUtils.newStringMap("id.subjectId", "subjectId", "id.classId", "classId",
                        "subjectName", "subjectName,coursewareName", "percent", "percent", "progressValue",
                        "studyTime", "coverPageUrl", "coverPageUrl")));
   }
    /**
     * 课程列表
     *
     * @param clssId    班级id
     * @param startTime 开班时间
     */
    @ApiOperation(value = "课程列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "startTime", value = "开班时间", required = false, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "getSubjectLst")
    public Result getList(String userId, String classId, String startTime, Integer limit, @RequestParam(defaultValue = "1") Integer pageNum, HttpServletRequest request) {
        userId = StringUtils.isEmpty(userId) ? ClientUtils.getUserId() : userId;
        classId = StringUtils.isEmpty(classId) ? ClientUtils.getClassId() : classId;
        List<MySubjectV> resultMs = subjectService.listMySubjectV(classId, userId);
        List<MySubjectV> result = new ArrayList<>();
        List<Object> lecurelist = new ArrayList<>();
        int i = 0;
        for(MySubjectV ms : resultMs){
            SubjectUtils subjectUtils = new SubjectUtils();
            List<MyLectureV> myLectureVList = lectureService.listLectureVBySubjectId(userId, ms.getId().getSubjectId(), "", 1000, 1, null);
            Double percent = 0.0;
            Double progressValue = 0.0;
            Double percentAvg = 0.0;
            if(!myLectureVList.isEmpty()) {
                for (MyLectureV myLectureV : myLectureVList) {
                    if (myLectureV.getPercent() != null && myLectureV.getProgressValue() != null) {
                        percent += myLectureV.getPercent();
                        progressValue += myLectureV.getProgressValue().intValue();
                    }
                }
                percentAvg = percent / myLectureVList.size();
                if (percentAvg.isNaN()) {
                    percentAvg = 0.0;
                }
                subjectUtils.setCoursewareName(myLectureVList.get(0).getLectureName());
                subjectUtils.setSubjectId(myLectureVList.get(0).getSubjectId());
                subjectUtils.setPercent(new BigDecimal(percentAvg));
                subjectUtils.setStudyTime(new BigDecimal(progressValue));
            }else {
                subjectUtils.setCoursewareName(null);
                subjectUtils.setSubjectId(ms.getId().getSubjectId());
                subjectUtils.setPercent(new BigDecimal(percentAvg));
                subjectUtils.setStudyTime(new BigDecimal(progressValue));
            }
            result.add(ms);
            lecurelist.add(subjectUtils);
        }
        return new Result(true, "success",
                CollectionUtils.newObjectMap("subjectList",
                QBeanUtils.listBean2ListMap(result,
                        CollectionUtils.newStringMap("id.subjectId", "subjectId", "id.classId", "classId",
                                "subjectName", "subjectName", "percent", "percent", "progressValue",
                                "studyTime", "coverPageUrl", "coverPageUrl")),"lecurelist",lecurelist));
    }
   /**
    * 进入课程
    *
    * @param subjectId
    *            课程id
    */
   @ApiOperation(value = "课程详情")
   @ApiImplicitParams({
      @ApiImplicitParam(name = "subjectId", value = "课程id", required = false, paramType="query", dataType = "String")
   })
   @GetMapping(value = "getSubjectDetail")
   public Result getSubjectDetail(String subjectId) {
      MySubjectV subject = subjectService.getMy1stSubjectVById(subjectId);
    /**
     * 进入课程
     *
     * @param subjectId 课程id
     */
    @ApiOperation(value = "课程详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "subjectId", value = "课程id", required = false, paramType = "query", dataType = "String")
    })
    @GetMapping(value = "getSubjectDetail")
    public Result getSubjectDetail(String subjectId) {
        MySubjectV subject = subjectService.getMy1stSubjectVById(subjectId);
      List<Map<String, Object>> progressLst = subjectService.listChapterStudyProgress(subjectId);
        List<Map<String, Object>> progressLst = subjectService.listChapterStudyProgress(subjectId);
        List<MyLectureV> myLectureVList = lectureService.listLectureVBySubjectId(ClientUtils.getUserId(), subjectId, "", 1000, 1, null);
        Double percent = 0.0;
        Double progressValue = 0.0;
        String coursewareName = null;
        if(!myLectureVList.isEmpty()) {
             for (MyLectureV myLectureV : myLectureVList) {
                if (myLectureV.getPercent() != null && myLectureV.getProgressValue() != null) {
                    percent += myLectureV.getPercent();
                    progressValue += myLectureV.getProgressValue().intValue();
                }
             }
            Double percentAvg = percent / myLectureVList.size();
            if (percentAvg.isNaN()) {
                percentAvg = 0.0;
        }
            subject.setPercent(percentAvg);
            subject.setProgressValue(new BigDecimal(progressValue));
            progressLst.get(0).put("percent", subject.getPercent());
            progressLst.get(0).put("studyTime", subject.getProgressValue());
            coursewareName = myLectureVList.get(0).getLectureName();
        }else {
      return new Result(true, "success",
            CollectionUtils.newObjectMap("subject", QBeanUtils.bean2Map(subject,
                  CollectionUtils.newStringMap("subjectName", "subjectName", "id.subjectId", "subjectId",
                        "progressValue", "studyTime", "percent", "percent", "coverPageUrl", "coverPageUrl")),
                  "chapterLst",progressLst));
   }
        }
        return new Result(true, "success",
                CollectionUtils.newObjectMap("subject", QBeanUtils.bean2Map(subject,
                        CollectionUtils.newStringMap("subjectName", "subjectName", "id.subjectId", "subjectId",
                                "progressValue", "studyTime", "percent", "percent", "coverPageUrl", "coverPageUrl")),
                        "chapterLst", progressLst,"coursewareName",coursewareName));
    }
}