| | |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.qxueyou.scc.admin.classes.model.ClsClassReSubject; |
| | | import com.qxueyou.scc.admin.classes.service.IClassLectureService; |
| | | import com.qxueyou.scc.teach.subject.model.Subject; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | |
| | | import com.qxueyou.scc.teach.subject.model.view.MyLectureV; |
| | | import com.qxueyou.scc.teach.subject.service.ILectureService; |
| | | import com.qxueyou.scc.teach.subject.service.ISubjectService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Service |
| | | public class SubjectLectureService extends CommonAppService implements ILectureService { |
| | |
| | | |
| | | @Autowired |
| | | IProgressService progressService; |
| | | |
| | | @Autowired |
| | | IClassLectureService clsLectureService; |
| | | |
| | | @Override |
| | | public Result addChapter(String subjectId, String parentChapterId, String name) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除单个章节 |
| | | * |
| | | * 删除单个章节 |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * 章节id |
| | | * @return |
| | | */ |
| | | private Result deleteChapter(String chapterId) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 初始化 |
| | | * |
| | | * 初始化 |
| | | * |
| | | * @param subjectId |
| | | * @return |
| | | */ |
| | |
| | | SubjectChapter chapter = new SubjectChapter(); |
| | | |
| | | TraceUtils.setCreateTrace(chapter); |
| | | chapter.setName("根节点"); |
| | | chapter.setName("根节点"); |
| | | chapter.setSubjectId(subjectId); |
| | | chapter.setParentChapterId(SubjectChapter.ROOT_CHAPTER_ID); |
| | | |
| | |
| | | lecture.setRemark(res.getRemark()); |
| | | lecture.setSubjectId(chapter.getSubjectId()); |
| | | lecture.setResItemId(res.getResId()); |
| | | |
| | | save(lecture); |
| | | subjectService.addLectureCount(lecture.getSubjectId(), 1); |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | | subjectService.addLectureCount(chapter.getSubjectId(), 1); |
| | | |
| | | @Override |
| | | public Result addLectureLoad(String sectionId){ |
| | | SubjectChapter chapter = read(SubjectChapter.class, sectionId); |
| | | String hql = "from Subject where subjectId = ? and deleteFlag is false"; |
| | | String subjectId = chapter.getSubjectId(); |
| | | Subject subjectOne = findUnique(hql,CollectionUtils.newList(subjectId),Subject.class); |
| | | String hqlOne = "from Subject where name = ? and deleteFlag is false"; |
| | | List<Subject> subjectTwo = find(hqlOne,CollectionUtils.newList(subjectOne.getName()),Subject.class); |
| | | for (Subject s : subjectTwo){ |
| | | String hqlTwo = "from ClsClassReSubject where subjectId = ? and deleteFlag is false"; |
| | | ClsClassReSubject subject = findUnique(hqlTwo,CollectionUtils.newList(s.getSubjectId()),ClsClassReSubject.class); |
| | | if(subject != null){ |
| | | subjectService.updateClsSubject(subject.getClassId(),s.getSubjectId(),s.getOrigSubjectId(),s.getTeacherId(),s.getSchoolYear(),s.getTerm()); |
| | | } |
| | | } |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | |
| | | for (String lectureId : lectureIds) { |
| | | deleteLecture(lectureId); |
| | | } |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | | @Override |
| | | public Result deleteLectureLoad(String[] lectureIds){ |
| | | SubjectLecture lecture = read(SubjectLecture.class, lectureIds[0]); |
| | | String hql = "from Subject where subjectId = ? and deleteFlag is false"; |
| | | String subjectId = lecture.getSubjectId(); |
| | | Subject subjectOne = findUnique(hql,CollectionUtils.newList(subjectId),Subject.class); |
| | | String hqlOne = "from Subject where name = ? and deleteFlag is false"; |
| | | List<Subject> subjectTwo = find(hqlOne,CollectionUtils.newList(subjectOne.getName()),Subject.class); |
| | | for (Subject s : subjectTwo){ |
| | | String hqlTwo = "from ClsClassReSubject where subjectId = ? and deleteFlag is false"; |
| | | ClsClassReSubject subject = findUnique(hqlTwo,CollectionUtils.newList(s.getSubjectId()),ClsClassReSubject.class); |
| | | if(subject != null){ |
| | | subjectService.updateClsSubject(subject.getClassId(),s.getSubjectId(),s.getOrigSubjectId(),s.getTeacherId(),s.getSchoolYear(),s.getTerm()); |
| | | } |
| | | } |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * |
| | | * @param lectureId |
| | | * 课件id |
| | | * 课件id |
| | | * @return |
| | | */ |
| | | private Result deleteLecture(String lectureId) { |
| | |
| | | |
| | | TraceUtils.setUpdateTrace(lecture); |
| | | lecture.setDeleteFlag(true); |
| | | |
| | | save(lecture); |
| | | |
| | | subjectService.addLectureCount(lecture.getSubjectId(), -1); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<MyLectureV> listLectureVBySubjectId(String learnerId, String subjectId, String keyword, Integer pageSize, |
| | | Integer pageNum, String type) { |
| | | StringBuffer hql = new StringBuffer("from MyLectureV where subjectId=? and id.userId=? order by lectureUpdateTime desc"); |
| | | List<Object> args = CollectionUtils.newList(subjectId, learnerId); |
| | | |
| | | if (StringUtils.isNotEmpty(type)) { |
| | | hql.append(" and lectureType=?"); |
| | | args.add(type); |
| | | } |
| | | |
| | | List<MyLectureV> result = findList(hql.toString(), new Pager(pageSize, pageNum), args, MyLectureV.class); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public int listLectureCount(String chapterId, String keyword, String type) { |
| | | StringBuffer hql = new StringBuffer("from SubjectLecture where chapterId=? and name like ? and deleteFlag is false"); |
| | | |
| | | |
| | | List<Object> args = CollectionUtils.newList(chapterId,'%' + keyword.trim() + '%'); |
| | | |
| | | if (StringUtils.isNotEmpty(type)) { |
| | | hql.append(" and lectureType=?"); |
| | | args.add(type); |
| | | } |
| | | |
| | | |
| | | return findCount(hql.toString(),args); |
| | | |
| | | } |
| | |
| | | SubjectLecture lecture = read(SubjectLecture.class, lectureId); |
| | | String resItemId = null; |
| | | if(lecture == null) { |
| | | resItemId = read(ClsSubjectLecture.class, lectureId).getResItemId();//班级课件 |
| | | resItemId = read(ClsSubjectLecture.class, lectureId).getResItemId();//班级课件 |
| | | }else { |
| | | resItemId = lecture.getResItemId(); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 监控resId转码状态同步Lecture的状态 |
| | | * 监控resId转码状态同步Lecture的状态 |
| | | */ |
| | | @Scheduled(cron = "0/2 * * * * ?") // 每2秒执行一次 |
| | | @Scheduled(cron = "0/2 * * * * ?") // 每2秒执行一次 |
| | | public void doTimer() { |
| | | String resId = cacheService.lstLeftPop(RES_LECTURE_CONVER_LST); |
| | | if (StringUtils.isBlank(resId)) { |