From 691f717df93c32d89b13f7f73f0678441d60c840 Mon Sep 17 00:00:00 2001
From: EricsHu <hrr145632>
Date: 星期五, 24 十一月 2023 10:17:40 +0800
Subject: [PATCH] 新增班级班主任字段

---
 src/main/java/com/qxueyou/scc/stucontroller/StuSubjectController.java |  936 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 544 insertions(+), 392 deletions(-)

diff --git a/src/main/java/com/qxueyou/scc/stucontroller/StuSubjectController.java b/src/main/java/com/qxueyou/scc/stucontroller/StuSubjectController.java
index fe85608..3303d50 100644
--- a/src/main/java/com/qxueyou/scc/stucontroller/StuSubjectController.java
+++ b/src/main/java/com/qxueyou/scc/stucontroller/StuSubjectController.java
@@ -1,12 +1,25 @@
 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.Subject;
+import com.qxueyou.scc.teach.subject.model.SubjectChapter;
+import com.qxueyou.scc.teach.subject.model.SubjectLecture;
+import com.qxueyou.scc.teach.subject.model.SubjectUtils;
+import com.qxueyou.scc.teach.subject.model.view.*;
 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;
@@ -23,9 +36,6 @@
 import com.qxueyou.scc.evaluate.service.IEvaluateService;
 import com.qxueyou.scc.operation.topic.service.ITopicService;
 import com.qxueyou.scc.teach.res.service.IResAudioService;
-import com.qxueyou.scc.teach.subject.model.view.LectureAudioV;
-import com.qxueyou.scc.teach.subject.model.view.MyLectureV;
-import com.qxueyou.scc.teach.subject.model.view.MySubjectV;
 import com.qxueyou.scc.teach.subject.service.ILectureService;
 import com.qxueyou.scc.teach.subject.service.ISubjectService;
 
@@ -34,436 +44,578 @@
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 /**
- * 学习端 课程前端控制器
+ * 瀛︿範绔� 璇剧▼鍓嶇鎺у埗鍣�
  *
  * @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);
-	}
-
-	/**
-	 *
-	 * 学习端获取课程列表
-	 *
-	 */
-	@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));
-   	}
+    //--------------------------------------------------------------app绔帴鍙�---------------------------------------------------------------------------------------------------
 
     /**
-     * 公开课列表
+     * 瀛︿範绔幏鍙� 鎵�鏈夎浠�
      *
-    */
-    @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));
-   	}
-
-    /**
-     * 公开课详情
-     *
+     * @param classId
+     * @return 鐘舵�佽鏄�(0, 瑙嗛 銆� 1, 闊抽 銆� 2, 鏂囨。 銆� 3, 缁冧範 銆�)
      */
-    @ApiOperation(value = "公开课详情", notes = "")
-   	@GetMapping(value = "/app/openSubjectInfo")
-   	public Result openSubjectInfo(@RequestParam(defaultValue = "")String subjectId) {
-	   	return new Result(true, "success", this.subjectService.openSubjectInfo(subjectId));
-   	}
+    @ApiOperation(value = "鑾峰彇鐝骇鎵�鏈夎浠�-瀛︿範绔�", notes = "鐘舵�佽鏄�(0,瑙嗛銆�1,闊抽銆�2,鏂囨。銆�3,缁冧範銆�)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "classId", value = "鐝骇id", required = false, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "sort", value = "鎺掑簭鏂瑰紡锛坉esc浠庡ぇ鍒板皬,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);
 
-	/**
-	 * 加载课件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);
+        return new Result(true, "success", CollectionUtils.newObjectMap("termList", lstTerm, "allSubject", lstSubject));
+    }
 
-		for (SubjectProgressTreeV v : chapterLst) {
-			v.setNodeName(v.getNodeName() + "(" + String.format("%.2f", v.getPercent()*100) + "%)"); //保留两位小数
-		}
+    /**
+     * 瀛︿範绔幏鍙栬绋嬪垪琛�
+     */
+    @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));
+    }
 
-		return new Result(true, "success", QBeanUtils.listBean2ListMap(chapterLst, CollectionUtils
-				.newStringMap("nodeName", "name", "id.nodeId", "id", "parentId", "parentId", "percent", "percent")));
-	}
+    /**
+     * 瀛︿範绔幏鍙栬绋嬪垪琛�
+     */
+    @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 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 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));
+    }
 
-		// id为小节id //返回的数据按照tree的小节排序
-		return new Result(true, "success",
+    /**
+     * 瀛︿範绔幏鍙栬绋嬪垪琛�
+     */
+    @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));
+    }
 
-				QBeanUtils.listBean2ListMap(lectureLst, CollectionUtils.newStringMap("name", "name", "lectureId", "id",
-						"lectureType", "type", "chapterId", "chapterId")));
-	}
+    /**
+     * 瀛︿範绔幏鍙栬绋嬪垪琛�
+     */
+    @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));
+    }
 
-	/**
-	 * 获取课件列表
-	 *
-	 * @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) {
+    /**
+     * 瀛︿範绔幏鍙栬绋嬪垪琛�
+     */
+    @ApiOperation(value = "瀛︿範绔幏鍙栬绋嬩笅璇句欢锛屾寜鍒涘缓鏃堕棿鎺掑簭")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "subjectId", value = "璇剧▼id", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "sort", value = "鎺掑簭鏂瑰紡锛坉esc浠庡ぇ鍒板皬,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));
+    }
 
-		List<MyLectureV> lectures = clsLectureService.listLectureV(ClientUtils.getUserId(), chapterId, keyword, limit,
-				pageNum, type);
+    /**
+     * 瀛︿範绔幏鍙栧叾浠栬浠剁粺璁�
+     */
+    @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()));
+    }
 
-		return new Result(true, "success",
-				CollectionUtils.newObjectMap("coursewareLst",
-						QBeanUtils.listBean2ListMap(lectures,
-								CollectionUtils.newStringMap("lectureName", "name", "id.lectureId", "id", "lectureType",
-										"type", "lectureUpdateTime", "endUpdateTime", "percent", "percent"))));
+    /**
+     * 瀛︿範绔幏鍙栬绋嬪垪琛�
+     */
+    @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涓嶈兘涓虹┖");
+        }
 
-	/**
-	 * 课件学习进度提交 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);
-	}
+        return this.clsLectureService.coursewareChapterList(classId, subjectId, type);
 
-	/**
-	 * 音频时长提交 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);
+    /**
+     * 鎴戠殑鍏紑璇惧垪琛�
+     */
+    @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));
+    }
 
-		return audioService.updateDuration(audio.getAudioId(), (int) seconds);
+    /**
+     * 鍏紑璇惧垪琛�
+     */
+    @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));
+    }
 
-	}
+    /**
+     * 鍏紑璇捐鎯�
+     */
+    @ApiOperation(value = "鍏紑璇捐鎯�", notes = "")
+    @GetMapping(value = "/app/openSubjectInfo")
+    public Result openSubjectInfo(@RequestParam(defaultValue = "") String subjectId) {
+        return new Result(true, "success", this.subjectService.openSubjectInfo(subjectId));
+    }
 
-	/**
-	 * 课程列表
-	 *
-	 * @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 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);
+    /**
+     * 鍔犺浇璇句欢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) {
+        Subject subject = subjectService.read(subjectId);
+        if (subject.getType() == 3) {
+            List<SubjectChapter> openChapterLst = lectureService.getListChapter(subjectId, parentId);
+            return new Result(true, "success", QBeanUtils.listBean2ListMap(openChapterLst, CollectionUtils
+                    .newStringMap("name", "name", "chapterId", "id", "parentChapterId", "parentId")));
 
-		List<Map<String, Object>> progressLst = subjectService.listChapterStudyProgress(subjectId);
+        } else {
+//           classId = StringUtils.isEmpty(classId)?ClientUtils.getClassId():classId;
+            List<SubjectProgressTreeV> chapterLst = clsLectureService.getChapterTreeVList(subjectId, parentId);
 
-		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));
-	}
+            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")));
+
+        }
+    }
+
+    /**
+     * 瀛︿範绔幏鍙� 鎵�鏈夎浠�
+     *
+     * @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);
+        if (lectureLst.size() > 0) {
+            // id涓哄皬鑺俰d //杩斿洖鐨勬暟鎹寜鐓ree鐨勫皬鑺傛帓搴�
+            return new Result(true, "success",
+
+                    QBeanUtils.listBean2ListMap(lectureLst, CollectionUtils.newStringMap("name", "name", "lectureId", "id",
+                            "lectureType", "type", "chapterId", "chapterId")));
+        } else {
+            List<SubjectLecture> lectureList = lectureService.listLectureBySubjectId(subjectId);
+            // id涓哄皬鑺俰d //杩斿洖鐨勬暟鎹寜鐓ree鐨勫皬鑺傛帓搴�
+            return new Result(true, "success",
+
+                    QBeanUtils.listBean2ListMap(lectureList, 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) {
+
+        List<MyLectureV> lectures = clsLectureService.listLectureV(ClientUtils.getUserId(), chapterId, keyword, limit,
+                pageNum, type);
+        if (lectures.size() == 0) {
+            List<SubjectLecture> lecturesTwo = lectureService.getSubjectLectureVByChapterId(chapterId, keyword, limit, pageNum);
+            List<MyOpenLectureV> lecturesThree = lectureService.getMyOpenLectureVByChapterId(ClientUtils.getUserId(), chapterId, keyword, limit, pageNum);
+            for (SubjectLecture subjectLecture : lecturesTwo) {
+                boolean isNull = true;
+                MyLectureV myLectureV = new MyLectureV(new MyLectureVId());
+                for (MyOpenLectureV myOpenLectureV : lecturesThree) {
+                    if (subjectLecture.getLectureId().equals(myOpenLectureV.getLectureId())) {
+                        isNull = false;
+                        myLectureV.setLectureName(myOpenLectureV.getLectureName());
+                        myLectureV.getId().setLectureId(myOpenLectureV.getLectureId());
+                        myLectureV.setLectureType(myOpenLectureV.getLectureType());
+                        myLectureV.setLectureUpdateTime(myOpenLectureV.getLectureUpdateTime());
+                        myLectureV.setPercent(myOpenLectureV.getPercent());
+                        lectures.add(myLectureV);
+                    }
+                }
+                if (isNull) {
+                    myLectureV.setLectureName(subjectLecture.getName());
+                    myLectureV.getId().setLectureId(subjectLecture.getLectureId());
+                    myLectureV.setLectureType(subjectLecture.getLectureType());
+                    myLectureV.setLectureUpdateTime(subjectLecture.getUpdateTime());
+                    myLectureV.setPercent(0.0);
+                    lectures.add(myLectureV);
+                }
+            }
+            return new Result(true, "success",
+                    CollectionUtils.newObjectMap("coursewareLst",
+                            QBeanUtils.listBean2ListMap(lectures,
+                                    CollectionUtils.newStringMap("lectureName", "name", "id.lectureId", "id", "lectureType",
+                                            "type", "lectureUpdateTime", "endUpdateTime", "percent", "percent"))));
+
+        } else {
+            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),濡傛枃妗o紝鍒欐棤闇�鎻愪氦璇ュ弬鏁�
+     * @param to        缁撴潫瀛︿範浣嶇疆锛屽悓to
+     */
+    @ApiOperation(value = "鎻愪氦瀛︿範杩涘害")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "lectureId", value = "璇句欢id", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "from", value = "寮�濮嬪涔犱綅缃� 锛屽瑙嗛锛屽垯涓烘椂鍒嗙(00:10:12),濡傛枃妗o紝鍒欐棤闇�鎻愪氦璇ュ弬鏁�", 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 = "鐖惰浠秈d", 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) {
+
+        LectureAudioV audio = lectureService.readAudioLecture(lectureId);
+
+        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;
+        classId = StringUtils.isEmpty(classId) ? ClientUtils.getClassId() : classId;
+        List<MySubjectV> resultMs = subjectService.listMySubjectV(classId, userId);
+        List<MySubjectV> result = new ArrayList<>();
+        List<Object> lecurelist = new ArrayList<>();
+        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);
+        }
+        List<OpenSubjectV> openSubjects = subjectService.listOpenSubjectV();
+        for (OpenSubjectV openSubjectV : openSubjects) {
+            MySubjectV mySubjectV = new MySubjectV(new MySubjectVId());
+            SubjectUtils subjectUtils = new SubjectUtils();
+            List<SubjectLecture> subjectLectureList = lectureService.listLectureBySubjectId(openSubjectV.getSubjectId());
+            List<MyOpenLectureV> myLectureVList = lectureService.listOpenLectureVBySubjectId(userId, openSubjectV.getSubjectId(), "", 1000, 1, null);
+            Double percent = 0.0;
+            Double progressValue = 0.0;
+            Double percentAvg = 0.0;
+            if (!myLectureVList.isEmpty()) {
+                for (MyOpenLectureV myOpenLectureV : myLectureVList) {
+                    if (myOpenLectureV.getPercent() != null && myOpenLectureV.getProgressValue() != null) {
+                        percent += myOpenLectureV.getPercent();
+                        progressValue += myOpenLectureV.getProgressValue().intValue();
+                    }
+                }
+                percentAvg = percent / subjectLectureList.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(openSubjectV.getSubjectId());
+                subjectUtils.setPercent(new BigDecimal(percentAvg));
+                subjectUtils.setStudyTime(new BigDecimal(progressValue));
+            }
+            mySubjectV.setSubjectName(openSubjectV.getSubjectName());
+            mySubjectV.setCoverPageUrl(openSubjectV.getCoverPageUrl());
+            mySubjectV.getId().setSubjectId(openSubjectV.getSubjectId());
+            result.add(mySubjectV);
+            lecurelist.add(subjectUtils);
+        }
+        for (MySubjectV mySubjectV:
+        result) {
+            System.out.println(mySubjectV);
+        }
+        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);
+        Subject subject1 = subjectService.read(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;
+        List<MyOpenLectureV> myOpenLectureVList = lectureService.listOpenLectureVBySubjectId(ClientUtils.getUserId(), subjectId, "", 100, 1, null);
+        List<SubjectLecture> subjectLectureList = lectureService.listLectureBySubjectId(subjectId);
+        if (myLectureVList.size() > 0) {
+            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.setCoverPageUrl(subject1.getCoverPageUrl());
+            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 if (subjectLectureList.size() > 0) {
+            if (myOpenLectureVList.size() > 0) {
+                for (MyOpenLectureV myLectureV : myOpenLectureVList) {
+                    if (myLectureV.getPercent() != null && myLectureV.getProgressValue() != null) {
+                        percent += myLectureV.getPercent();
+                        progressValue += myLectureV.getProgressValue().intValue();
+                    }
+                }
+                coursewareName = myOpenLectureVList.get(0).getLectureName();
+            }
+            if (subject == null) {
+                subject = new MySubjectV(new MySubjectVId());
+            }
+            Double percentAvg = percent / subjectLectureList.size();
+            if (percentAvg.isNaN()) {
+                percentAvg = 0.0;
+            }
+            subject.setCoverPageUrl(subject1.getCoverPageUrl());
+            subject.setPercent(percentAvg);
+            subject.setProgressValue(new BigDecimal(progressValue));
+            subject.setSubjectName(subject1.getName());
+            subject.getId().setSubjectId(subjectLectureList.get(0).getSubjectId());
+            Map<String, Object> map = new HashMap<>();
+            map.put("percent", subject.getPercent());
+            map.put("studyTime", subject.getProgressValue());
+            map.put("chapterId", subjectLectureList.get(0).getSubjectId());
+            map.put("chapterName", subject1.getName());
+            progressLst.add(map);
+        }
+        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));
+    }
 
 }

--
Gitblit v1.8.0