| | |
| | | |
| | | @Service |
| | | public class ClassLectureService extends CommonAppService implements IClassLectureService { |
| | | |
| | | |
| | | private final Logger log = LogManager.getLogger(ClassLectureService.class); |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | ProgressDAO progressDao; |
| | | |
| | | |
| | | @Autowired |
| | | IMsgInfoService msgInfoService; |
| | | |
| | |
| | | @Override |
| | | public List<MyLectureV> listLectureV(String learnerId, String chapterId, String keyword, Integer pageSize, |
| | | Integer pageNum, String type) { |
| | | StringBuffer hql = new StringBuffer("from MyLectureV where chapterId=? and id.userId=? and status=? order by lectureCreateTime desc"); |
| | | List<Object> args = CollectionUtils.newList(chapterId, learnerId,ClsSubjectLecture.STATUS_DRAFT); |
| | | StringBuffer hql = new StringBuffer("from MyLectureV where subjectId=? and id.userId=? order by lectureCreateTime desc"); |
| | | // StringBuffer hql = new StringBuffer("from MyLectureV where chapterId=? and id.userId=? and status=? order by lectureCreateTime desc"); |
| | | |
| | | // List<Object> args = CollectionUtils.newList(chapterId, learnerId,ClsSubjectLecture.STATUS_DRAFT); |
| | | List<Object> args = CollectionUtils.newList(chapterId, learnerId); |
| | | |
| | | |
| | | if (StringUtils.isNotEmpty(type)) { |
| | | hql.append(" and lectureType=?"); |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程课件 |
| | | * |
| | | * |
| | | */ |
| | | @Override |
| | | public Map<String,Object> listLectureBySubjectOrderCreateTime(String subjectId, String classId, String sort, Pager pager) { |
| | |
| | | if(Subject.TYPE_PUBLIC_SUBJECT == subject.getType()) {//公开课课件 |
| | | return this.listOpenLectureBySubjectOrderCreateTime(subjectId, sort, pager); |
| | | } |
| | | |
| | | |
| | | QMyLectureV qMyLectureV = QMyLectureV.myLectureV; |
| | | |
| | | |
| | | OrderSpecifier<Date> order = "desc".equals(sort)?new OrderSpecifier<Date>(Order.DESC, qMyLectureV.lectureCreateTime): |
| | | new OrderSpecifier<Date>(Order.ASC, qMyLectureV.lectureCreateTime); |
| | | |
| | | |
| | | JPAQuery<MyLectureV> query = this.getQueryFactory().selectFrom(qMyLectureV) |
| | | .where(qMyLectureV.subjectId.eq(subjectId). |
| | | and(qMyLectureV.classId.eq(classId)).and(qMyLectureV.id.userId.eq(ClientUtils.getUserId()))); |
| | | |
| | | |
| | | long count = query.fetchCount(); |
| | | |
| | | |
| | | return CollectionUtils.newObjectMap("count", count, "listData", query.limit(pager.getPageSize()).offset(pager.getOffset()) |
| | | .orderBy(order) |
| | | .fetch().stream() |
| | |
| | | return map; |
| | | }).collect(Collectors.toList())); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 公开课课件 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @param sort |
| | | * @param pager |
| | |
| | | public Map<String,Object> listOpenLectureBySubjectOrderCreateTime(String subjectId, String sort, Pager pager) { |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | QProgress qProgress = QProgress.progress; |
| | | |
| | | |
| | | OrderSpecifier<Date> order = "desc".equals(sort)?new OrderSpecifier<Date>(Order.DESC, qSubjectLecture.createTime): |
| | | new OrderSpecifier<Date>(Order.ASC, qSubjectLecture.createTime); |
| | | |
| | | |
| | | JPAQuery<SubjectLecture> query = this.getQueryFactory().selectFrom(qSubjectLecture).where(qSubjectLecture.subjectId.eq(subjectId).and(qSubjectLecture.deleteFlag.isFalse()).and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT))); |
| | | |
| | | |
| | | long count = query.fetchCount(); |
| | | |
| | | |
| | | return CollectionUtils.newObjectMap("count", count, "listData", query.limit(pager.getPageSize()).offset(pager.getOffset()) |
| | | .orderBy(order) |
| | | .fetch().stream() |
| | |
| | | lecture.setClassId(chapter.getClassId()); |
| | | lecture.setStatus(res.getStatus()); |
| | | save(lecture); |
| | | |
| | | |
| | | // 发送消息 |
| | | doPublishMsg(lecture); |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | | |
| | | //添加课程,发送消息 |
| | | private void doPublishMsg(ClsSubjectLecture lecture){ |
| | | Subject subject = this.read(Subject.class, lecture.getSubjectId()); |
| | | |
| | | |
| | | if(!subject.getStatus().equals(Subject.STATUS_ISSUED)){ |
| | | return ; |
| | | } |
| | | |
| | | |
| | | //查询直播关联的班级 |
| | | String hql = "select userId from StuStudent where classId =:classId and deleteFlag is false "; |
| | | |
| | | |
| | | List<String> lstUserIds = this.findByComplexHql(hql, CollectionUtils.newObjectMap("classId",lecture.getClassId()), String.class); |
| | | |
| | | |
| | | if(lstUserIds!=null && lstUserIds.size()>0){ |
| | | Map<String,String> attrs = CollectionUtils.newStringMap("lectureId",lecture.getLectureId(),"lectureName",lecture.getName(),"subjectId",subject.getSubjectId(), |
| | | "lectureType",lecture.getLectureType(),"subjectName",subject.getName()); |
| | | |
| | | |
| | | msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]),MsgInfo.TYPE_COURSEWARE,"发布了课件",attrs); |
| | | } |
| | | } |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> listLectureBySubject(String subjectId, String type, String classId) { |
| | | StringBuffer hql = new StringBuffer("select name as lectureName, " |
| | |
| | | |
| | | return this.findListWithMapByHql(hql.toString(), args); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> listStuLectureBySubject(String subjectId, String classId) { |
| | | if(StringUtils.isEmpty(subjectId) || StringUtils.isEmpty(classId)) { |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的公开课课件查询 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @return |
| | | */ |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询数量 |
| | | * |
| | | * |
| | | * @param subjectId |
| | | * @param classId |
| | | * @return |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public List<SubjectChapter> getListOpenChapter(String subjectId) { |
| | | |
| | | StringBuffer hql = new StringBuffer( |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result doClearLecturesToClass( String classId,String subjectId) { |
| | | this.bulkUpdate("update ClsSubjectLecture set deleteFlag = true where classId=? and subjectId = ? ", |
| | | new String[]{classId,subjectId}); |
| | | |
| | | |
| | | this.bulkUpdate("update ClsSubjectChapter set deleteFlag = true where classId=? and subjectId = ? ", |
| | | new String[]{classId,subjectId}); |
| | | |
| | | |
| | | return new Result(true); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result doCopyLecturesToClass(String origSubjectId, String subjectId, String classId) { |
| | | Map<String, String> subjectIdMap = CollectionUtils.newStringMap(SubjectChapter.ROOT_CHAPTER_ID, |
| | |
| | | |
| | | @Override |
| | | public List<ClsSubjectLecture> listLecture(String subjectId) { |
| | | |
| | | |
| | | StringBuffer hql = new StringBuffer("from ClsSubjectLecture where subjectId = ? and deleteFlag is false"); |
| | | |
| | | List<Object> args = CollectionUtils.newList(subjectId); |
| | |
| | | return find(hql.toString(), args, ClsSubjectLecture.class); |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result listSubjectLecture(String classId, String sort, Pager pager) { |
| | | if(StringUtils.isEmpty(classId)) { |
| | | return new Result(false, "班级id不能为空"); |
| | | } |
| | | QMyLectureV qMyLectureV = QMyLectureV.myLectureV; |
| | | |
| | | |
| | | OrderSpecifier<Date> order = "desc".equals(sort)?new OrderSpecifier<Date>(Order.DESC, qMyLectureV.lectureCreateTime): |
| | | new OrderSpecifier<Date>(Order.ASC, qMyLectureV.lectureCreateTime); |
| | | |
| | | |
| | | JPAQuery<MyLectureV> query = this.getQueryFactory() |
| | | .selectFrom(qMyLectureV) |
| | | .where(new QueryDslOptionBuilder() |
| | | .and(qMyLectureV.classId::eq, classId).and(qMyLectureV.id.userId::eq,ClientUtils.getUserId()) |
| | | .build() |
| | | ); |
| | | |
| | | |
| | | long count = query.fetchCount(); |
| | | |
| | | |
| | | // 获取查询结果集合 |
| | | QueryResults<MyLectureV> results = query.limit(pager.getPageSize()).offset(pager.getOffset()).orderBy(order).fetchResults(); |
| | | |
| | | List<Map<String,Object>> resultLst = |
| | | |
| | | List<Map<String,Object>> resultLst = |
| | | results.getResults() |
| | | .stream() |
| | | .map(tuple -> { |
| | |
| | | return new Result(true); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取章节下的课件 |
| | | * |
| | | * |
| | | * @param chapterLst |
| | | * @param lectures |
| | | * @return |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | this.getTopChapters(chapterLst); |
| | | |
| | | |
| | | for (int i=chapterLst.size()-1;i>=0;i--) { |
| | | ClsSubjectChapter objClsSubjectChapter = chapterLst.get(i); |
| | | if(objClsSubjectChapter.getLectures() == null || objClsSubjectChapter.getLectures().isEmpty()) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return chapterLst; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取章节的第一层数据 |
| | | * |
| | | * |
| | | * @param chapterLst |
| | | * @return |
| | | */ |
| | |
| | | chapterLst = this.getTopChapters(chapterLst); |
| | | } |
| | | } |
| | | |
| | | |
| | | return chapterLst; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int readDocPageCount(String resItemId) { |
| | | ResItemDoc resItemDoc = read(ResItemDoc.class, resItemId); |
| | |
| | | |
| | | return schHandout.getPageCount(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课件按目录分类 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @param subjectId |
| | | * @param type |
| | |
| | | */ |
| | | public Result coursewareChapterList(String classId,String subjectId, String type) { |
| | | Subject subject = this.read(Subject.class, subjectId); |
| | | |
| | | |
| | | if(Subject.TYPE_PUBLIC_SUBJECT == subject.getType() || Subject.TYPE_ORG_SUBJECT == subject.getType()) {//公开课和管理员课程 |
| | | QSubjectLecture qSubjectLecture = QSubjectLecture.subjectLecture; |
| | | //课件 |
| | | List<Map<String, Object>> lectures = this.listStuLectureByOpenSubject(subjectId); |
| | | |
| | | |
| | | List<SubjectChapter> lstSubjectChapterLst = this.getListOpenChapter(subjectId); |
| | | List<ClsSubjectChapter> lstClsSubjectChapter = new ArrayList<>(); |
| | | if(lstSubjectChapterLst != null && !lstSubjectChapterLst.isEmpty()) { |
| | |
| | | } catch (InvocationTargetException e) { |
| | | log.error("拷贝属性失败BeanUtils.copyProperties(objClsSubjectChapter, objSubjectChapter)", e); |
| | | } |
| | | |
| | | |
| | | lstClsSubjectChapter.add(objClsSubjectChapter); |
| | | } |
| | | } |
| | | //章节 |
| | | List<ClsSubjectChapter> chapterLst = this.getChapterLectures(lstClsSubjectChapter, lectures); |
| | | |
| | | |
| | | long count = this.getQueryFactory().selectFrom(qSubjectLecture) |
| | | .where(qSubjectLecture.subjectId.eq(subjectId).and(qSubjectLecture.deleteFlag.isFalse()). |
| | | and(qSubjectLecture.status.eq(SubjectLecture.STATUS_DRAFT))).fetchCount(); |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("count",count, "listData", QBeanUtils.listBean2ListMap(chapterLst, |
| | | CollectionUtils.newStringMap("name", "name", "chapterId", "chapterId", "lectures", "lectures")))); |
| | | |
| | | |
| | | }else{ |
| | | //课件 |
| | | List<Map<String, Object>> lectures = this.listStuLectureBySubject(subjectId, classId); |