| | |
| | | |
| | | @Autowired |
| | | ILectureService lectureService; |
| | | |
| | | |
| | | @Autowired |
| | | IClassLectureService clsLectureService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ITeacherService teacherService; |
| | | |
| | | |
| | | @Autowired |
| | | private IMediaLiveService mediaLiveService; |
| | | |
| | |
| | | subject.setOrgId(ClientUtils.getOrgId()); |
| | | |
| | | save(subject); |
| | | |
| | | |
| | | //初始化创建 根节点 |
| | | SubjectChapter chapter = new SubjectChapter(); |
| | | TraceUtils.setCreateTrace(chapter); |
| | |
| | | subject.setType(type); |
| | | |
| | | save(subject); |
| | | |
| | | |
| | | //更新所有关联的课程 |
| | | if(subject.getType()==Subject.TYPE_ORG_SUBJECT){ |
| | | this.bulkUpdate("update Subject t set t.name=?,t.contentFileId=?," |
| | | + "t.coverPageFileId=?,t.coverPageUrl=? where t.deleteFlag is false and t.origSubjectId=? ",new Object[]{subject.getName(), |
| | | subject.getContentFileId(),subject.getCoverPageFileId(),subject.getCoverPageUrl(),subject.getSubjectId()} ); |
| | | } |
| | | |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | |
| | | public Result delete(String[] subjectIds) { |
| | | for (String subjectId : subjectIds) { |
| | | deleteSubject(subjectId); |
| | | |
| | | |
| | | //删除班级课程 |
| | | List<Map<String,Object>> result = this.findListWithMapByHql( |
| | | "select r.classId as classId,r.subjectId as subjectId from ClsClassReSubject r,Subject j " |
| | | + "where r.subjectId = j.subjectId and j.origSubjectId=:origSubjectId and r.deleteFlag is false and j.deleteFlag is false", |
| | | + "where r.subjectId = j.subjectId and j.origSubjectId=:origSubjectId and r.deleteFlag is false and j.deleteFlag is false", |
| | | CollectionUtils.newObjectMap("origSubjectId",subjectId)); |
| | | |
| | | |
| | | if(result!=null && result.size()>0){ |
| | | for(Map<String,Object> map : result){ |
| | | this.deleteClsSubject((String)map.get("classId"), new String []{(String)map.get("subjectId")}); |
| | |
| | | |
| | | /** |
| | | * 删除单个课程 |
| | | * |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @return |
| | |
| | | hql.append(" and type=?"); |
| | | args.add(type); |
| | | } |
| | | |
| | | |
| | | if (!StringUtils.isEmpty(status)) { |
| | | hql.append(" and status=?"); |
| | | args.add(status); |
| | |
| | | } |
| | | hql.append(" order by createTime desc"); |
| | | List<Subject> result = findList(hql.toString(), new Pager(pageSize, pageNum), args, Subject.class); |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * app教师端课程列表 |
| | | * |
| | | * |
| | | * @param text |
| | | * @param status |
| | | * @param type |
| | |
| | | if(StringUtils.isEmpty(teacherId)) { |
| | | return new Result(false, "当前用户无老师角色"); |
| | | } |
| | | |
| | | |
| | | QSubject qSubject = QSubject.subject; |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | QProgress qProgress = QProgress.progress; |
| | | QClsClassReSubject qClsClassReSubject = QClsClassReSubject.clsClassReSubject; |
| | | |
| | | |
| | | JPAQuery<Tuple> query = this.getQueryFactory() |
| | | .select(qSubject.subjectId, qSubject.name, qSubject.term,qSubject.coverPageUrl, qSubject.schoolYear, qSubject.createTime, qSubject.type) |
| | | .from(qSubject) |
| | |
| | | .and(qSubject.status.eq(Subject.STATUS_ISSUED)).and(qSubject.type.eq(type)) |
| | | .and(qSubject.createId.eq(ClientUtils.getUserId())) |
| | | .and(qSubject.name.like("%" + keyword + "%"))); |
| | | |
| | | |
| | | long count = query.fetchCount(); |
| | | |
| | | |
| | | List<Map<String, Object>> listData = query.orderBy(qSubject.createTime.desc()).limit(pager.getPageSize()) |
| | | .offset(pager.getOffset()).fetch().stream().map(tuple -> { |
| | | Map<String, Object> map = new HashMap<String, Object>(10); |
| | |
| | | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | return new Result(true, "", CollectionUtils.newObjectMap("count", count, "listData", listData)); |
| | | } |
| | | |
| | | @Override |
| | | public int listCount(String text, String teacherId, String status,Integer type) { |
| | | StringBuffer hql = new StringBuffer("from Subject where name like ? and orgId=? and deleteFlag is false and origSubjectId is null "); |
| | | List<Object> args = CollectionUtils.newList(text + "%",ClientUtils.getOrgId()); |
| | | |
| | | List<Object> args = CollectionUtils.newList(text + "%",ClientUtils.getOrgId()); |
| | | |
| | | if(type!=null){ |
| | | hql.append(" and type=?"); |
| | | args.add(type); |
| | | } |
| | | |
| | | |
| | | if (StringUtils.isNotBlank(status)) { |
| | | hql = hql.append(" and status = ?"); |
| | | args.add(status); |
| | |
| | | public String readSubjectContent(String subjectId) { |
| | | |
| | | Subject sub = read(subjectId); |
| | | |
| | | |
| | | //读取原课程 |
| | | if(StringUtils.isNotBlank(sub.getOrigSubjectId())) { |
| | | sub = read(sub.getOrigSubjectId()); |
| | |
| | | |
| | | /** |
| | | * 发布单个课程 |
| | | * |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @return |
| | |
| | | subject.setStatus(Subject.STATUS_ISSUED); |
| | | |
| | | save(subject); |
| | | |
| | | |
| | | //更新所有关联的课程 |
| | | this.bulkUpdate("update Subject set status='" + Subject.STATUS_ISSUED + "' where origSubjectId=? and deleteFlag is false ",new Object[]{subjectId}); |
| | | |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | | /** |
| | | * 发布单个课程 |
| | | * |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @return |
| | |
| | | subject.setStatus(Subject.STATUS_OFFLINE); |
| | | |
| | | save(subject); |
| | | |
| | | |
| | | //更新所有关联的课程 |
| | | this.bulkUpdate("update Subject set status='" + Subject.STATUS_OFFLINE + "' where origSubjectId=? and deleteFlag is false ",new Object[]{subjectId}); |
| | | |
| | |
| | | public List<Map<String, Object>> listChapterStudyProgress(String subjectId) { |
| | | |
| | | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; |
| | | |
| | | List<Map<String, Object>> lstResult = this.getQueryFactory().selectFrom(qSubjectProgressTreeV). |
| | | where(qSubjectProgressTreeV.parentId.eq(subjectId).and(qSubjectProgressTreeV.id.userId.eq(ClientUtils.getUserId()))) |
| | | where(qSubjectProgressTreeV.id.nodeId.eq(subjectId).and(qSubjectProgressTreeV.id.userId.eq(ClientUtils.getUserId()))) |
| | | .fetch().stream().map(objSubjectProgressTreeV ->{ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("chapterName", objSubjectProgressTreeV.getNodeName()); |
| | | map.put("chapterId", objSubjectProgressTreeV.getId().getNodeId()); |
| | | map.put("percent", objSubjectProgressTreeV.getPercent()); |
| | | map.put("studyTime", objSubjectProgressTreeV.getProgressValue()); |
| | | |
| | | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | return lstResult; |
| | | } |
| | | |
| | |
| | | Subject origSubject = this.read(origSubjectId); |
| | | UserTeacher teacher = this.read(UserTeacher.class, teacherId); |
| | | BeanUtils.copyProperties(newSubject,origSubject); |
| | | |
| | | |
| | | TraceUtils.setCreateTrace(newSubject); |
| | | newSubject.setSubjectId(null); |
| | | newSubject.setTeacherId(teacherId); |
| | |
| | | newSubject.setTeacherName(teacher.getName()); |
| | | newSubject.setOrgId(ClientUtils.getOrgId()); |
| | | save(newSubject); |
| | | |
| | | |
| | | //添加班级课程关系 |
| | | addClassReSubject(newSubject.getSubjectId(),classId); |
| | | |
| | | |
| | | //复制课件 |
| | | clsLectureService.doCopyLecturesToClass(origSubjectId,newSubject.getSubjectId(),classId); |
| | | |
| | | |
| | | return new Result(true, "success",CollectionUtils.newStringMap("subjectId",newSubject.getSubjectId())); |
| | | } |
| | | |
| | | |
| | | private void addClassReSubject(String subjectId, String classId) { |
| | | ClsClassReSubject re = new ClsClassReSubject(); |
| | | TraceUtils.setCreateTrace(re); |
| | | re.setClassId(classId); |
| | | re.setSubjectId(subjectId); |
| | | save(re); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Result updateClsSubject(String classId,String subjectId,String origSubjectId, String teacherId, Integer schoolYear,Integer term) { |
| | | Subject origSubject = this.read(origSubjectId); |
| | | Subject subject = this.read(subjectId); |
| | | UserTeacher teacher = this.read(UserTeacher.class, teacherId); |
| | | |
| | | |
| | | //如果原课程做出了修改 |
| | | if(!origSubjectId.equals(subject.getOrigSubjectId())){ |
| | | subject.setContentFileId(origSubject.getCoverPageFileId()); |
| | |
| | | subject.setName(origSubject.getName()); |
| | | subject.setOrigSubjectId(origSubjectId); |
| | | subject.setOrigCopySubjectId(origSubjectId); |
| | | |
| | | |
| | | //清理并复制原课程 |
| | | clsLectureService.doClearLecturesToClass(classId,subjectId); |
| | | clsLectureService.doCopyLecturesToClass(origSubjectId, subjectId, classId); |
| | | } |
| | | |
| | | |
| | | TraceUtils.setUpdateTrace(subject); |
| | | subject.setTeacherId(teacherId); |
| | | subject.setTeacherName(teacher.getName()); |
| | | subject.setSchoolYear(schoolYear); |
| | | subject.setTerm(term); |
| | | |
| | | |
| | | save(subject); |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result deleteClsSubject(String classId,String[] subjectIds) { |
| | | Map<String,Object> paramMap = new HashMap<String,Object>(); |
| | | paramMap.put("classId", classId); |
| | | paramMap.put("subjectIds", subjectIds); |
| | | |
| | | |
| | | List<String> reIdLst = this.findByComplexHql("select r.clsReSubjectId from ClsClassReSubject r where r.deleteFlag is false and r.classId=:classId and r.subjectId in (:subjectIds) ", |
| | | paramMap, String.class); |
| | | |
| | | |
| | | //删除关联关系 |
| | | if(reIdLst!=null && reIdLst.size()>0){ |
| | | this.bulkUpdateInLoop("update ClsClassReSubject set deleteFlag = true where clsReSubjectId=?", reIdLst.toArray()); |
| | | } |
| | | |
| | | |
| | | this.delete(subjectIds); |
| | | return new Result(true, "success"); |
| | | } |
| | |
| | | QUser qUser = QUser.user; |
| | | String nodeId = StringUtils.isNotEmpty(subjectId)?subjectId:classId; |
| | | String nodeType = StringUtils.isNotEmpty(subjectId)?Progress.PROGRESS_TYPE_SUBJECT:Progress.PROGRESS_TYPE_CLASS; |
| | | |
| | | |
| | | List<Map<String, Object>> lstMap = this.getQueryFactory().select(qSubjectProgressTreeV.progressValue, |
| | | qSubjectProgressTreeV.percent, qUser.name, qUser.userId,qSubjectProgressTreeV.id.nodeId).from(qSubjectProgressTreeV, qUser). |
| | | where(qSubjectProgressTreeV.id.userId.eq(qUser.userId).and(qSubjectProgressTreeV.nodeType.eq(nodeType)) |
| | |
| | | .when(qExerciseResultV.completeStatus.eq(ExerciseCompleteInfo.STATUS_CHECKED) |
| | | .or(qExerciseResultV.completeStatus.eq(ExerciseCompleteInfo.STATUS_COMMIT))) |
| | | .then(BigDecimal.ONE).otherwise(BigDecimal.ZERO).sum(); |
| | | |
| | | |
| | | //case分数 |
| | | NumberExpression<BigDecimal> caseScoreSum = new CaseBuilder() |
| | | .when(qExerciseResultV.completeStatus.eq(ExerciseCompleteInfo.STATUS_CHECKED) |
| | | .or(qExerciseResultV.completeStatus.eq(ExerciseCompleteInfo.STATUS_COMMIT))) |
| | | .then(qExerciseResultV.score).otherwise(BigDecimal.ZERO).sum(); |
| | | |
| | | |
| | | List<Map<String, Object>> lstMap = this.getQueryFactory().select(qExerciseResultV.userId,qExerciseResultV.studentName, |
| | | caseScoreSum.divide(caseCount), qExerciseResultV.count(), caseCount).from(qExerciseResultV).where(predicate). |
| | | groupBy(qExerciseResultV.userId). |
| | |
| | | map.put("avgScore", tuple.get(2, BigDecimal.class)); |
| | | map.put("exerciseCount",tuple.get(3, BigDecimal.class)); |
| | | map.put("commitExerciseCount", tuple.get(4, BigDecimal.class)); |
| | | |
| | | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | return lstMap; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * |
| | | */ |
| | | private List<Map<String, Object>> examInfoDesc(String classId, String subjectId) { |
| | | |
| | | |
| | | QExamResultV qExamResultV = QExamResultV.examResultV; |
| | | //查询条件 |
| | | Predicate predicate = StringUtils.isEmpty(subjectId)?qExamResultV.id.classId.eq(classId): |
| | |
| | | //case分数 |
| | | NumberExpression<BigDecimal> caseScoreSum = new CaseBuilder() |
| | | .when(qExamResultV.status.eq("0")).then(BigDecimal.ZERO).otherwise(qExamResultV.score).sum(); |
| | | |
| | | |
| | | List<Map<String, Object>> lstMap = this.getQueryFactory().select(qExamResultV.userId,qExamResultV.studentName, |
| | | caseScoreSum.divide(caseCount), qExamResultV.count(), caseCount).from(qExamResultV).where(predicate). |
| | | groupBy(qExamResultV.userId). |
| | |
| | | map.put("avgScore", tuple.get(2, BigDecimal.class)); |
| | | map.put("examCount",tuple.get(3, BigDecimal.class)); |
| | | map.put("commitExamCount", tuple.get(4, BigDecimal.class)); |
| | | |
| | | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | return lstMap; |
| | |
| | | } |
| | | return new Result(true, "success", map); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String,Object>> queryAvailableSubjectIdAndName(String teacherId,Integer subjectType){ |
| | | List<Map<String,Object>> result = null; |
| | | |
| | | |
| | | if(subjectType==Subject.TYPE_PUBLIC_SUBJECT){ |
| | | result = this.findListWithMapByHql( |
| | | "select subjectId as subjectId ,name as subjectName from Subject where deleteFlag is false and type=" + Subject.TYPE_PUBLIC_SUBJECT + " and orgId='" + ClientUtils.getOrgId() + "'" , null); |
| | |
| | | "select subjectId as subjectId ,name as subjectName from Subject where deleteFlag is false and type=" + Subject.TYPE_ORG_SUBJECT + " and orgId='" + ClientUtils.getOrgId() + "'", null); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return lstMap; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String,Object>> clsSubjectlist(String classId, Integer schoolYear, Integer term) { |
| | | QSubject qSubject = QSubject.subject; |
| | | QClsClassReSubject qClsClassReSubject = QClsClassReSubject.clsClassReSubject; |
| | | |
| | | |
| | | QueryDslOptionBuilder builder = new QueryDslOptionBuilder(). |
| | | and(qSubject.deleteFlag::eq, false) |
| | | .and(qClsClassReSubject.classId::eq, classId) |
| | |
| | | if(term != null && term != 0){//学期 |
| | | builder = builder.and(qSubject.term::eq, term); |
| | | } |
| | | |
| | | |
| | | return this.getQueryFactory().select(qSubject.name,qSubject.origSubjectId,qSubject.subjectId,qSubject.schoolYear, qSubject.term).distinct() |
| | | .from(qSubject, qClsClassReSubject) |
| | | .where(builder.build()) |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String,Object>> termList(String classId) { |
| | | QSubject qSubject = QSubject.subject; |
| | | QClsClassReSubject qClsClassReSubject = QClsClassReSubject.clsClassReSubject; |
| | | |
| | | |
| | | QueryDslOptionBuilder builder = new QueryDslOptionBuilder(). |
| | | and(qSubject.deleteFlag::eq, false) |
| | | .and(qClsClassReSubject.classId::eq, classId) |
| | | .and(qClsClassReSubject.subjectId::eq, qSubject.subjectId) |
| | | .and(qClsClassReSubject.deleteFlag::eq, false).and(qSubject.status::eq, Subject.STATUS_ISSUED); |
| | | |
| | | |
| | | return this.getQueryFactory().select(qSubject.schoolYear.as("schoolYear"),qSubject.term.as("term")) |
| | | .from(qSubject, qClsClassReSubject) |
| | | .where(builder.build().and(qSubject.schoolYear.isNotNull()) |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的班级信息 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | | public Map<String,Object> myClassInfo(String classId){ |
| | | ClsClass objClsClass = this.read(ClsClass.class, classId); |
| | | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; |
| | | |
| | | |
| | | List<Subject> lstSubject = objClsClass.getSubjects(); |
| | | |
| | | |
| | | //过滤掉状态为草稿的 |
| | | List<String> teachers = lstSubject.stream().filter(u->u.getStatus().equals(Subject.STATUS_ISSUED)).map(tuple -> { |
| | | return tuple.getTeacherName(); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | SubjectProgressTreeV objSubjectProgressTreeV = this.getQueryFactory().selectFrom(qSubjectProgressTreeV) |
| | | .where(qSubjectProgressTreeV.id.nodeId.eq(classId).and(qSubjectProgressTreeV.id.userId.eq(ClientUtils.getUserId())).and(qSubjectProgressTreeV.nodeType.eq("class"))).fetchOne(); |
| | | |
| | | |
| | | if(objSubjectProgressTreeV != null) { |
| | | |
| | | |
| | | long allCount = this.getQueryFactory().selectFrom(qSubjectProgressTreeV) |
| | | .where(qSubjectProgressTreeV.id.nodeId.eq(classId)).fetchCount(); |
| | | |
| | | |
| | | long lgCount = this.getQueryFactory().selectFrom(qSubjectProgressTreeV) |
| | | .where(qSubjectProgressTreeV.id.nodeId.eq(classId).and(qSubjectProgressTreeV.percent.gt(objSubjectProgressTreeV.getPercent()))).fetchCount(); |
| | | //排行 |
| | | float rank = (allCount-lgCount)/allCount; |
| | | |
| | | |
| | | return CollectionUtils.newObjectMap("className", objClsClass.getName(), "progressPercent", |
| | | objSubjectProgressTreeV.getPercent(), "progressValue", objSubjectProgressTreeV.getProgressValue(), "rank", rank, "teacherName", teachers); |
| | | }else { |
| | |
| | | 0, "progressValue", 0, "rank", 0, teachers); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取我的课程进度 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | | public List<Map<String,Object>> myClsSubjectlist(String classId, String userId, Pager pager){ |
| | | String teacherId = this.teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | QMySubjectV qMySubjectV = QMySubjectV.mySubjectV; |
| | | |
| | | |
| | | Predicate predicate = null; |
| | | if(StringUtils.isNotEmpty(teacherId)) { |
| | | predicate = qMySubjectV.id.classId.eq(classId).and(qMySubjectV.id.userId.eq(userId)).and(qMySubjectV.teacherId.eq(teacherId).and(qMySubjectV.subjectStatus.eq(Subject.STATUS_ISSUED))); |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取我的课程数量 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | | public long myClsSubjectCount(String classId){ |
| | | QMySubjectV qMySubjectV = QMySubjectV.mySubjectV; |
| | | |
| | | |
| | | return this.getQueryFactory().select(qMySubjectV.id.subjectId, |
| | | qMySubjectV.subjectName,qMySubjectV.term, |
| | | qMySubjectV.schoolYear,qMySubjectV.percent) |
| | |
| | | .where(qMySubjectV.id.classId.eq(classId).and(qMySubjectV.id.userId.eq(ClientUtils.getUserId())).and(qMySubjectV.subjectStatus.eq(Subject.STATUS_ISSUED))) |
| | | .fetchCount(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取学员的课程进度 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | | public List<Map<String,Object>> studentSubjectProgress(String classId, Pager pager){ |
| | | String teacherId = this.teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; |
| | | |
| | | |
| | | QMySubjectV qMySubjectV = QMySubjectV.mySubjectV; |
| | | return this.getQueryFactory().select(qMySubjectV.id.subjectId, |
| | | qMySubjectV.subjectName,qMySubjectV.term,qMySubjectV.coverPageUrl, |
| | |
| | | .where(qSubjectProgressTreeV.id.nodeId.eq(tuple.get(qMySubjectV.id.subjectId)) |
| | | .and(qSubjectProgressTreeV.nodeType.eq(Progress.PROGRESS_TYPE_SUBJECT))) |
| | | .groupBy(qSubjectProgressTreeV.id.nodeId).fetchOne()); |
| | | |
| | | |
| | | map.put("coverPageUrl", tuple.get(qMySubjectV.coverPageUrl)); |
| | | map.put("lectureCount", this.getLectureCount(tuple.get(qMySubjectV.id.subjectId))); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课件数量 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @return |
| | | */ |
| | | public long getLectureCount(String subjectId) { |
| | | |
| | | |
| | | Subject subject = this.read(subjectId); |
| | | if(subject == null) { |
| | | return 0l; |
| | |
| | | if(subject.getType() == Subject.TYPE_CLS_SUBJECT) {//班级课程 |
| | | |
| | | QClsSubjectLecture qSubjectLecture = QClsSubjectLecture.clsSubjectLecture; |
| | | |
| | | |
| | | return this.getQueryFactory().selectFrom(qSubjectLecture).where(qSubjectLecture.deleteFlag.isFalse() |
| | | .and(qSubjectLecture.subjectId.eq(subjectId)).and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT))).fetchCount(); |
| | | }else { |
| | | |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | |
| | | |
| | | return this.getQueryFactory().selectFrom(qSubjectLecture).where(qSubjectLecture.deleteFlag.isFalse() |
| | | .and(qSubjectLecture.subjectId.eq(subjectId)).and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT))).fetchCount(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 我的公开课列表 |
| | | * |
| | | * |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @param keyword |
| | |
| | | QSubject qSubject = QSubject.subject; |
| | | QProgress qProgress = QProgress.progress; |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | |
| | | |
| | | JPAQuery<Tuple> query = this.getQueryFactory() |
| | | .select(qSubject.subjectId, qSubject.name, qSubject.term,qSubject.coverPageUrl, qSubject.schoolYear, |
| | | qProgress.progressPercent.avg().as(qProgress.progressPercent), qProgress.progressValue.sum().as(qProgress.progressValue)) |
| | |
| | | .and(qProgress.learnerId.eq(ClientUtils.getUserId())) |
| | | .and(qSubject.name.like("%" + keyword + "%").and(qProgress.deleteFlag.isFalse())) |
| | | .and(qProgress.type.eq(Progress.PROGRESS_TYPE_LECTURE)).and(qSubject.status.eq(Subject.STATUS_ISSUED))).groupBy(qSubject.subjectId); |
| | | |
| | | |
| | | long count = query.fetchCount(); |
| | | List<Map<String, Object>> listData = query.orderBy(qProgress.createTime.desc()).limit(pageSize).offset(pageNum).fetch().stream().map(tuple -> { |
| | | Map<String, Object> map = new HashMap<String, Object>(7); |
| | | String subjectId = tuple.get(qSubject.subjectId); |
| | | |
| | | |
| | | map.put("name", tuple.get(qSubject.name)); |
| | | map.put("subjectId", subjectId); |
| | | map.put("schoolYear", tuple.get(qSubject.schoolYear)); |
| | |
| | | map.put("progressValue", tuple.get(qProgress.progressValue)); |
| | | |
| | | Map<String,Object> openSubjectDetail = this.openSubjectDetail(subjectId); |
| | | |
| | | |
| | | // 直播数量 |
| | | map.put("mediaVideoLiveCount",openSubjectDetail.get("mediaVideoLiveCount")); |
| | | |
| | | // 课件数量 |
| | | map.put("subjectLectureCount",openSubjectDetail.get("subjectLectureCount")); |
| | | |
| | | |
| | | //学习人次 |
| | | map.put("studyCount",openSubjectDetail.get("studyCount")); |
| | | |
| | | |
| | | map.put("content",openSubjectDetail.get("content")); |
| | | |
| | | // 已观看完成课件数量 |
| | |
| | | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | return CollectionUtils.newObjectMap("count", count, "listData", listData); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程统计详情 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @return |
| | | */ |
| | |
| | | QMediaVideoLive qMediaVideoLive = QMediaVideoLive.mediaVideoLive; |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | QProgress qProgress = QProgress.progress; |
| | | |
| | | |
| | | // 直播数量 |
| | | map.put("mediaVideoLiveCount", |
| | | this.getQueryFactory().select(qMediaVideoLive).from(qMediaVideoLive) |
| | |
| | | .where(qSubjectLecture.deleteFlag.isFalse() |
| | | .and(qSubjectLecture.subjectId.eq(subjectId)).and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT))) |
| | | .fetchCount()); |
| | | |
| | | |
| | | //学习人次 |
| | | map.put("studyCount", |
| | | this.getQueryFactory().selectDistinct(qProgress.learnerId).from(qProgress, qSubjectLecture) |
| | | .where(qProgress.deleteFlag.isFalse().and(qSubjectLecture.deleteFlag.isFalse()).and(qSubjectLecture.subjectId.eq(subjectId)).and(qProgress.type.eq(Progress.PROGRESS_TYPE_LECTURE)) |
| | | .and(qProgress.targetId.eq(qSubjectLecture.lectureId))) |
| | | .fetchCount()); |
| | | |
| | | |
| | | map.put("content", this.readSubjectContent(subjectId)); |
| | | |
| | | // 已观看完成课件数量 |
| | |
| | | .and(qProgress.progressPercent.gt(0.95)).and(qProgress.targetId.eq(qSubjectLecture.lectureId)) |
| | | .and(qSubjectLecture.subjectId.eq(subjectId))) |
| | | .fetchCount()); |
| | | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 公开课详情 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @return |
| | | */ |
| | | public Map<String,Object> openSubjectInfo(String subjectId){ |
| | | QProgress qProgress = QProgress.progress; |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | |
| | | |
| | | Subject objSubject = this.read(subjectId); |
| | | |
| | | |
| | | Tuple progress = this.getQueryFactory() |
| | | .select(qProgress.progressPercent.sum().as(qProgress.progressPercent), qProgress.progressValue.sum().as(qProgress.progressValue)).from(qProgress,qSubjectLecture).where(qProgress.learnerId.eq(ClientUtils.getUserId()) |
| | | .and(qProgress.targetId.eq(qSubjectLecture.lectureId)) |
| | | .and(qProgress.deleteFlag.isFalse()).and(qSubjectLecture.deleteFlag.isFalse()).and(qSubjectLecture.subjectId.eq(subjectId)) |
| | | .and(qProgress.type.eq(Progress.PROGRESS_TYPE_LECTURE))).fetchOne(); |
| | | |
| | | |
| | | Map<String, Object> subjectInfo = new HashMap<String, Object>(7); |
| | | |
| | | |
| | | subjectInfo.put("name", objSubject.getName()); |
| | | subjectInfo.put("subjectId", subjectId); |
| | | subjectInfo.put("schoolYear", objSubject.getSchoolYear()); |
| | | subjectInfo.put("term", objSubject.getTerm()); |
| | | subjectInfo.put("coverPageUrl", objSubject.getCoverPageUrl()); |
| | | subjectInfo.put("teacherName", objSubject.getTeacherName()); |
| | | |
| | | |
| | | |
| | | Map<String,Object> openSubjectDetail = this.openSubjectDetail(subjectId); |
| | | |
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>(7); |
| | | |
| | | |
| | | // 直播数量 |
| | | map.put("mediaVideoLiveCount",openSubjectDetail.get("mediaVideoLiveCount")); |
| | | |
| | | // 课件数量 |
| | | map.put("subjectLectureCount",openSubjectDetail.get("subjectLectureCount")); |
| | | |
| | | |
| | | //学习人次 |
| | | map.put("studyCount",openSubjectDetail.get("studyCount")); |
| | | |
| | | |
| | | subjectInfo.put("content",openSubjectDetail.get("content")); |
| | | |
| | | // 已观看完成课件数量 |
| | | map.put("subjectLectureDoCount",openSubjectDetail.get("subjectLectureDoCount")); |
| | | |
| | | |
| | | map.put("subjectInfo", subjectInfo); |
| | | |
| | | |
| | | if(openSubjectDetail.get("subjectLectureCount") == null || progress == null || progress.get(qProgress.progressPercent) == null) { |
| | | subjectInfo.put("progressPercent", 0); |
| | | }else { |
| | |
| | | |
| | | /** |
| | | * 公开课列表 |
| | | * |
| | | * |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @param keyword |
| | |
| | | */ |
| | | public Map<String,Object> openSubjectList(Integer pageNum, Integer pageSize, String keyword){ |
| | | QOpenSubjectV qOpenSubjectV = QOpenSubjectV.openSubjectV; |
| | | |
| | | |
| | | JPAQuery<OpenSubjectV> query = this.getQueryFactory().selectFrom(qOpenSubjectV).where(qOpenSubjectV.subjectName.like("%" + keyword + "%")); |
| | | |
| | | long count = query.fetchCount(); |
| | |
| | | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | return CollectionUtils.newObjectMap("count", count, "listData", listData); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 班级学员课件总体进度 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @param classId |
| | | * @return |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 学员课程作业进度 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @param subjectId |
| | | * @return |
| | |
| | | .and(qHomeworkScoreV.userId.eq(student.getUserId())) |
| | | .and(qHomeworkScoreV.exerciseStatus.eq(ExerciseInfo.EXERCISE_STATUS_PUBLISHED))) |
| | | .groupBy(qHomeworkScoreV.userId).fetchOne(); |
| | | |
| | | |
| | | Map<String,Object> map = new HashMap<String,Object>(4); |
| | | if(tuple == null) { |
| | | map.put("subjectId", subjectId); |
| | |
| | | map.put("avgScore", String.valueOf(commitHomeworkCount == 0 || tuple.get(2, BigDecimal.class) == null?BigDecimal.ZERO:tuple.get(2, BigDecimal.class).divide(BigDecimal.valueOf(commitHomeworkCount), 2, BigDecimal.ROUND_HALF_UP))); |
| | | map.put("commitHomeworkCount", commitHomeworkCount); |
| | | } |
| | | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 学员考试作业进度 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @param subjectId |
| | | * @return |
| | |
| | | |
| | | StuStudent student = read(StuStudent.class, studentId); |
| | | Subject subject = read(Subject.class, subjectId); |
| | | |
| | | |
| | | Tuple tuple = this.getQueryFactory().select(qExamScoreV.subjectId, qExamScoreV.count(), new CaseBuilder() |
| | | .when(qExamScoreV.status.eq("0")).then(BigDecimal.ZERO).otherwise(qExamScoreV.score).sum(), new CaseBuilder() |
| | | .when(qExamScoreV.status.eq("0")).then(0).otherwise(1).sum()). |
| | |
| | | map.put("commitExamCount", 0); |
| | | }else { |
| | | int commitExamCount = tuple.get(3, Integer.class) == null?0:tuple.get(3, Integer.class); |
| | | |
| | | |
| | | map.put("examCount", tuple.get(1, Integer.class) == null?0:tuple.get(1, Integer.class)); |
| | | map.put("avgScore", String.valueOf(commitExamCount == 0 || tuple.get(2, BigDecimal.class) == null?BigDecimal.ZERO:tuple.get(2, BigDecimal.class).divide(new BigDecimal(commitExamCount), 2, BigDecimal.ROUND_HALF_UP))); |
| | | map.put("commitExamCount", tuple.get(3, Integer.class) == null?0:tuple.get(3, Integer.class)); |
| | | } |
| | | |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的课件情况 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的课程,按时间排序 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | |
| | | clsSubject.put("homework", CollectionUtils.newObjectMap("homeworkCount", exerciseInfoService.queryStuExerciseListCount("", null, ClientUtils.getUserId(), origSubjectId, null))); |
| | | clsSubject.put("lecture", CollectionUtils.newObjectMap("lectureCount", 0, "completeLectureCount", 0)); |
| | | clsSubject.put("mediaVideoLive", CollectionUtils.newObjectMap("mediaVideoLiveCount", this.mediaLiveService.listCount("", new String[] {classId}, origSubjectId, null))); |
| | | |
| | | |
| | | this.setSubjectStatistics("lecture", clsSubject, lectures); |
| | | } |
| | | |
| | | |
| | | return clsSubjectlist; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 统计课程的数据 |
| | | * |
| | | * |
| | | * @param type 类型 |
| | | * @param clsSubject 课程 |
| | | * @param lstStatistics 统计信息 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的课程详情 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | | public Map<String,Object> mySubjectInfo(String subjectId, String classId,HttpServletRequest request) { |
| | | |
| | | |
| | | QMySubjectV qMySubjectV = QMySubjectV.mySubjectV; |
| | | QMyLectureV qMyLectureV = QMyLectureV.myLectureV; |
| | | Object userId = request.getSession().getAttribute("userId"); |
| | |
| | | .where(qMySubjectV.id.classId.eq(classId).and(qMySubjectV.id.userId.eq(ClientUtils.getUserId())) |
| | | .and(qMySubjectV.id.subjectId.eq(subjectId))) |
| | | .fetchOne(); |
| | | |
| | | |
| | | Subject objSubject = this.read(subjectId); |
| | | |
| | | Map<String, Object> subject = new HashMap<String, Object>(5); |
| | |
| | | } |
| | | |
| | | String origSubjectId = objSubject.getOrigSubjectId(); |
| | | |
| | | |
| | | // 考试统计 |
| | | long examsCount = this.examService.listStudentExamCount("", new String[] {classId}, origSubjectId, null); |
| | | |
| | |
| | | |
| | | return CollectionUtils.newObjectMap("mediaVideoLivesCount", mediaVideoLivesCount, "examsCount", examsCount, |
| | | "homeworksCount", homeworksCount, "subjectInfo", subject, "lectureCount", |
| | | tupleLecture == null?0:tupleLecture.get(0, Long.class), |
| | | tupleLecture == null?0:tupleLecture.get(0, Long.class), |
| | | "completeLectureCount", tupleLecture == null?0:tupleLecture.get(1,Integer.class)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的课程按学期分类 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 课程按学期分类 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | |
| | | public List<Map<String,Object>> termSubjectList(String classId, List<Map<String,Object>> clsSubjectlist) { |
| | | //学期 |
| | | List<Map<String,Object>> termList = this.termList(classId); |
| | | |
| | | |
| | | if(termList != null && !termList.isEmpty()) { |
| | | for(Map<String,Object> term : termList) { |
| | | if(termList != null && !termList.isEmpty()) { |
| | |
| | | } |
| | | return termList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询课程关联的班级课程信息 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | |
| | | + " s.schoolYear as schoolYear,s.term as term,c.classId as classId,c.name as className" |
| | | + " from Subject s ,ClsClassReSubject r ,ClsClass c where s.subjectId = r.subjectId " |
| | | + " and r.classId = c.classId and s.origSubjectId =:origSubjectId and s.deleteFlag is false"; |
| | | |
| | | return this.findListWithMapByHql(hql,CollectionUtils.newObjectMap("origSubjectId",origSubjectId)); |
| | | } |
| | | |
| | | }; |
| | | |
| | | return this.findListWithMapByHql(hql,CollectionUtils.newObjectMap("origSubjectId",origSubjectId)); |
| | | } |
| | | |
| | | }; |