派生自 projectDept/qhighschool

Administrator
2022-12-06 92027c9960c8e4e8d84db11c2c422254a5b7d38c
src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectLectureService.java
@@ -2,6 +2,9 @@
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;
@@ -29,6 +32,7 @@
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 {
@@ -46,6 +50,9 @@
   @Autowired
   IProgressService progressService;
   @Autowired
   IClassLectureService clsLectureService;
   @Override
   public Result addChapter(String subjectId, String parentChapterId, String name) {
@@ -86,10 +93,10 @@
   }
   /**
    * 删除单个章节
    *
    * 删除单个章节
    *
    * @param chapterId
    *            章节id
    *            章节id
    * @return
    */
   private Result deleteChapter(String chapterId) {
@@ -137,8 +144,8 @@
   }
   /**
    * 初始化
    *
    * 初始化
    *
    * @param subjectId
    * @return
    */
@@ -147,7 +154,7 @@
      SubjectChapter chapter = new SubjectChapter();
      TraceUtils.setCreateTrace(chapter);
      chapter.setName("根节点");
      chapter.setName("根节点");
      chapter.setSubjectId(subjectId);
      chapter.setParentChapterId(SubjectChapter.ROOT_CHAPTER_ID);
@@ -173,11 +180,26 @@
      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");
   }
@@ -204,14 +226,30 @@
      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) {
@@ -220,7 +258,6 @@
      TraceUtils.setUpdateTrace(lecture);
      lecture.setDeleteFlag(true);
      save(lecture);
      subjectService.addLectureCount(lecture.getSubjectId(), -1);
@@ -275,16 +312,32 @@
   }
   @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);
   }
@@ -294,7 +347,7 @@
      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();
      }
@@ -340,9 +393,9 @@
   }
   /**
    * 监控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)) {