| | |
| | | <version>4.0.5.Final</version> |
| | | </dependency> |
| | | |
| | | <!-- mp3文件支持(如语音时长)--> |
| | | <dependency> |
| | | <groupId>org</groupId> |
| | | <artifactId>jaudiotagger</artifactId> |
| | | <version>2.0.1</version> |
| | | </dependency> |
| | | |
| | | <!-- mp4文件支持(如语音时长)--> |
| | | <dependency> |
| | | <groupId>com.googlecode.mp4parser</groupId> |
| | | <artifactId>isoparser</artifactId> |
| | | <version>1.1.22</version> |
| | | </dependency> |
| | | <!-- hibernate-core-4.3.7.Final.jar --> |
| | | <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> |
| | | <dependency> |
| | |
| | | } |
| | | } |
| | | |
| | | public Result updateLecturetime(String targetId) { |
| | | |
| | | ClsSubjectLecture lecture = read(ClsSubjectLecture.class, targetId); |
| | | |
| | | |
| | | TraceUtils.setUpdateTrace(lecture); |
| | | |
| | | lecture.setUpdateTime(new Date()); |
| | | lecture.setUpdator(ClientUtils.getUserId()); |
| | | save(lecture); |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | | @Override |
| | | public Result updateLecture(String lectureId, String resId) { |
| | | |
| | |
| | | |
| | | @Override |
| | | public Result doStudy(String clsLectureId, Double from, Double to) { |
| | | return progressService.addProgress(Progress.PROGRESS_TYPE_LECTURE, clsLectureId, from.doubleValue(), to.doubleValue(), |
| | | return progressService.addProgress(Progress.PROGRESS_TYPE_LECTURE, clsLectureId, from.intValue(), to.intValue(), |
| | | ClientUtils.getUserId()); |
| | | } |
| | | |
| | |
| | | package com.qxueyou.scc.admin.classes.service.impl; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | 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 org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | |
| | | |
| | | @Autowired |
| | | ITeacherService teacherService; |
| | | |
| | | @Autowired |
| | | ILectureService lectureService; |
| | | |
| | | /** |
| | | * 添加班级 |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getSubjectLstByClsId(String classId) { |
| | | String hql = "from MySubjectV where classId = ?"; |
| | | List<MySubjectV> mySubjectVList = find(hql,CollectionUtils.newList(classId),MySubjectV.class); |
| | | List<Map<String,Object>> maps = new ArrayList<>(); |
| | | for(MySubjectV mySubjectV : mySubjectVList){ |
| | | List<MyLectureV> myLectureVList = lectureService.listLectureVBySubjectId(mySubjectV.getId().getUserId(),mySubjectV.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; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Cacheable(value = "progress", key = "#targetId+#learnerId") |
| | | public Double[][] getProgress(String targetId, String learnerId) { |
| | | public int[][] getProgress(String targetId, String learnerId) { |
| | | List<SubjectLectureProgressDetail> lstDetail = this.find("from SubjectLectureProgressDetail where targetId = ? and learnerId = ? and deleteFlag is false", CollectionUtils.newList(targetId, learnerId), SubjectLectureProgressDetail.class); |
| | | if(lstDetail == null || lstDetail.isEmpty()) { |
| | | return new Double[][] {}; |
| | | return new int[][] {}; |
| | | }else { |
| | | Double[][] progress = new Double[lstDetail.size()][2]; |
| | | int[][] progress = new int[lstDetail.size()][2]; |
| | | int i = 0; |
| | | for(SubjectLectureProgressDetail objDetail : lstDetail) { |
| | | progress[i++] = new Double[] {objDetail.getStart(), objDetail.getEnd()}; |
| | | progress[i++] = new int[] {objDetail.getStart(), objDetail.getEnd()}; |
| | | } |
| | | |
| | | return progress; |
| | |
| | | } |
| | | |
| | | @CachePut(value = "progress", key = "#targetId+#learnerId") |
| | | public Double[][] mergeProgress(String targetId, String learnerId, Double start, Double end, Double[][] origProgress) { |
| | | public int[][] mergeProgress(String targetId, String learnerId, int start, int end, int[][] origProgress) { |
| | | return StudyProgressUtils.merge(origProgress, start, end); |
| | | } |
| | | |
| | |
| | | private static final long serialVersionUID = -1565188126862586738L; |
| | | private String detailId; |
| | | private String progressId; |
| | | private Double start; |
| | | private Double end; |
| | | private int start; |
| | | private int end; |
| | | private String learnerId; |
| | | private String targetId; |
| | | private Date createTime; |
| | |
| | | this.progressId = progressId; |
| | | } |
| | | |
| | | public Double getStart() { |
| | | public int getStart() { |
| | | return start; |
| | | } |
| | | |
| | | |
| | | |
| | | public void setStart(Double start) { |
| | | public void setStart(int start) { |
| | | this.start = start; |
| | | } |
| | | |
| | | |
| | | |
| | | public Double getEnd() { |
| | | public int getEnd() { |
| | | return end; |
| | | } |
| | | |
| | | |
| | | |
| | | public void setEnd(Double end) { |
| | | public void setEnd(int end) { |
| | | this.end = end; |
| | | } |
| | | |
| | |
| | | * @param end 学习结束位置 |
| | | * @return |
| | | */ |
| | | Result addProgress(String targetId,String learnerId,Double start,Double end); |
| | | Result addProgress(String targetId,String learnerId,int start,int end); |
| | | |
| | | /** |
| | | * 返回进度类型 |
| | |
| | | * 学习结束位置 |
| | | * @return |
| | | */ |
| | | Result addProgress(String type, String targetId, Double start, Double end, String userId); |
| | | Result addProgress(String type, String targetId, int start, int end, String userId); |
| | | |
| | | List<SubjectProgressTreeV> getSubjectChapterTreeVList(String parentId,String userId); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result addProgress(String type, String targetId, Double start, Double end, String userId) { |
| | | public Result addProgress(String type, String targetId, int start, int end, String userId) { |
| | | String userId_ = StringUtils.isBlank(userId) ? ClientUtils.getUserId() : userId; |
| | | return resItemServiceMap.get(type).addProgress(targetId, userId_, start, end); |
| | | } |
| | |
| | | BigDecimal progressValue = new BigDecimal(itemProgress.get("progressValue").toString()); |
| | | if (progress == null) { |
| | | String nodeType = subjectProgressTreeV.getNodeType(); |
| | | this.addProgress(nodeType, nodeId, 0.0, 0.0, userId); |
| | | this.addProgress(nodeType, nodeId, 0, 0, userId); |
| | | cacheService.lstRightPush(SUBJECT_PROGRESS_STATISTIC, nodeIdOrUserId); |
| | | return; |
| | | } |
| | |
| | | * 结束位置 |
| | | * @return |
| | | */ |
| | | public static Double[][] merge(Double[][] orig, Double start, Double end) { |
| | | public static int[][] merge(int[][] orig, int start, int end) { |
| | | |
| | | // 中间合并结果 |
| | | Double[][] result = new Double[orig.length + 1][2]; |
| | | int[][] result = new int[orig.length + 1][2]; |
| | | |
| | | int j = 0; |
| | | int i = 0; |
| | |
| | | |
| | | switch (action) { |
| | | case ACTION_INSERT: { |
| | | result[j++] = new Double[] { start, end }; |
| | | result[j++] = new int[] { start, end }; |
| | | result[j++] = orig[i]; |
| | | breakFlag = true; |
| | | break; |
| | | } |
| | | case ACTION_MERGE_01: { |
| | | result[j++] = new Double[] { start, orig[i][1] }; |
| | | result[j++] = new int[] { start, orig[i][1] }; |
| | | breakFlag = true; |
| | | break; |
| | | } |
| | |
| | | } |
| | | |
| | | // 如果本次学习终止位置超出以往所有学习进度,则添加到最后 |
| | | if (orig.length == 0 ) { |
| | | result[j++] = new Double[] { start, end }; |
| | | }else if(pos(end, orig[orig.length - 1]) == POS_AFTER){ |
| | | result[j++] = new Double[] { start, end }; |
| | | if (orig.length == 0 || pos(end, orig[orig.length - 1]) == POS_AFTER) { |
| | | result[j++] = new int[] { start, end }; |
| | | } |
| | | |
| | | // 最终合并结果,去掉中间合并结果的多出为空的元素 |
| | | Double[][] finalResult = new Double[j][2]; |
| | | int[][] finalResult = new int[j][2]; |
| | | |
| | | for (int k = 0; k < result.length; k++) { |
| | | if (result[k][0] == 0 && result[k][1] == 0 && k>0) { |
| | |
| | | * 全部学习进度 |
| | | * @return |
| | | */ |
| | | public static Double sum(Double[][] orig) { |
| | | public static int sum(int[][] orig) { |
| | | |
| | | Double sum = 0.0; |
| | | int sum = 0; |
| | | |
| | | for (Double[] item : orig) { |
| | | for (int[] item : orig) { |
| | | sum += (item[1] - item[0] + 1); |
| | | } |
| | | return sum; |
| | | |
| | | } |
| | | |
| | | private static int action(Double[] segment, Double start, Double end) { |
| | | private static int action(int[] segment, int start, int end) { |
| | | int startPos = pos(start, segment); |
| | | int endPos = pos(end, segment); |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | private static int pos(Double index, Double[] range) { |
| | | private static int pos(int index, int[] range) { |
| | | if (index < range[0]) { |
| | | return POS_BEFORE; |
| | | } |
| | |
| | | package com.qxueyou.scc.admin.progress.service.impl.item; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | public class ChapterProgressService extends CommonAppService implements IDetailProgressService { |
| | | |
| | | @Override |
| | | public Result addProgress(String targetId, String learnerId, Double start, Double end) { |
| | | public Result addProgress(String targetId, String learnerId, int start, int end) { |
| | | Progress p = new Progress(); |
| | | TraceUtils.setCreateTrace(p); |
| | | p.setLearnerId(learnerId); |
| | |
| | | p.setTargetId(targetId); |
| | | p.setType(Progress.PROGRESS_TYPE_CHAPTER); |
| | | p.setProgressPercent(0d); |
| | | p.setDeleteFlag(false); |
| | | p.setCreator(ClientUtils.getUserName()); |
| | | p.setCreateId(ClientUtils.getUserId()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdator(ClientUtils.getUserName()); |
| | | p.setUpdateId(ClientUtils.getUserId()); |
| | | p.setUpdateTime(new Date()); |
| | | save(p); |
| | | return new Result(true); |
| | | } |
| | |
| | | package com.qxueyou.scc.admin.progress.service.impl.item; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | public class ClassProgressService extends CommonAppService implements IDetailProgressService { |
| | | |
| | | @Override |
| | | public Result addProgress(String targetId, String learnerId, Double start, Double end) { |
| | | public Result addProgress(String targetId, String learnerId, int start, int end) { |
| | | Progress p = new Progress(); |
| | | TraceUtils.setCreateTrace(p); |
| | | p.setLearnerId(learnerId); |
| | |
| | | p.setTargetId(targetId); |
| | | p.setType(Progress.PROGRESS_TYPE_CLASS); |
| | | p.setProgressPercent(0d); |
| | | p.setDeleteFlag(false); |
| | | p.setCreator(ClientUtils.getUserName()); |
| | | p.setCreateId(ClientUtils.getUserId()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdator(ClientUtils.getUserName()); |
| | | p.setUpdateId(ClientUtils.getUserId()); |
| | | p.setUpdateTime(new Date()); |
| | | save(p); |
| | | return new Result(true); |
| | | } |
| | |
| | | |
| | | |
| | | @Override |
| | | public Result addProgress(String targetId,String learnerId, Double start, Double end) { |
| | | public Result addProgress(String targetId,String learnerId, int start, int end) { |
| | | ClsSubjectLecture lecture = lectureService.readClsLecture(targetId); |
| | | |
| | | String lectureType = null; |
| | |
| | | package com.qxueyou.scc.admin.progress.service.impl.item; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | public class SubjectProgressService extends CommonAppService implements IDetailProgressService { |
| | | |
| | | @Override |
| | | public Result addProgress(String targetId, String learnerId, Double start, Double end) { |
| | | public Result addProgress(String targetId, String learnerId, int start, int end) { |
| | | Progress p = new Progress(); |
| | | TraceUtils.setCreateTrace(p); |
| | | p.setLearnerId(learnerId); |
| | |
| | | p.setTargetId(targetId); |
| | | p.setType(Progress.PROGRESS_TYPE_SUBJECT); |
| | | p.setProgressPercent(0d); |
| | | p.setDeleteFlag(false); |
| | | p.setCreator(ClientUtils.getUserName()); |
| | | p.setCreateId(ClientUtils.getUserId()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdator(ClientUtils.getUserName()); |
| | | p.setUpdateId(ClientUtils.getUserId()); |
| | | p.setUpdateTime(new Date()); |
| | | save(p); |
| | | return new Result(true); |
| | | } |
| | |
| | | package com.qxueyou.scc.admin.progress.service.impl.lecture; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import com.qxueyou.scc.admin.classes.model.ClsSubjectLecture; |
| | | import com.qxueyou.scc.admin.classes.service.impl.ClassLectureService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Autowired |
| | | ProgressDAO dao; |
| | | |
| | | @Autowired |
| | | ClassLectureService classLectureService; |
| | | |
| | | @Override |
| | | public Result addProgress(String targetId, String learnerId, Double start, Double end) { |
| | | public Result addProgress(String targetId, String learnerId, int start, int end) { |
| | | |
| | | if (start > end || start < 0 || end < 0) { |
| | | return new Result(false, "invalid arguments"); |
| | | } |
| | | |
| | | Double[][] progress = dao.mergeProgress(targetId, learnerId, start, end , dao.getProgress(targetId, learnerId)); |
| | | int[][] progress = dao.mergeProgress(targetId, learnerId, start, end , dao.getProgress(targetId, learnerId)); |
| | | |
| | | if (!checkLecture(targetId).isSuccess()) { |
| | | return checkLecture(targetId); |
| | | } |
| | | |
| | | Double sum = StudyProgressUtils.sum(progress); |
| | | int sum = StudyProgressUtils.sum(progress); |
| | | |
| | | Progress p = dao.getProgress(Progress.PROGRESS_TYPE_LECTURE, targetId, learnerId); |
| | | |
| | |
| | | |
| | | //保存学习记录明细 |
| | | this.saveProgressDetail(start, end, targetId, p.getProgressId(), learnerId); |
| | | |
| | | classLectureService.updateLecturetime(targetId); |
| | | |
| | | SubjectProgressTreeV subjectProgressTreeV = dao.getSubjectProgressTreeV(targetId, learnerId); |
| | | |
| | |
| | | * @param progressId |
| | | * @param learnerId |
| | | */ |
| | | private void saveProgressDetail(Double start, Double end, String targetId, String progressId, String learnerId) { |
| | | private void saveProgressDetail(int start, int end, String targetId, String progressId, String learnerId) { |
| | | SubjectLectureProgressDetail detail = new SubjectLectureProgressDetail(); |
| | | detail.setDeleteFlag(false); |
| | | detail.setEnd(end); |
| | |
| | | detail.setTargetId(targetId); |
| | | detail.setProgressId(progressId); |
| | | detail.setLearnerId(learnerId); |
| | | detail.setCreator(ClientUtils.getUserName()); |
| | | detail.setCreateId(ClientUtils.getUserId()); |
| | | detail.setCreateTime(new Date()); |
| | | detail.setUpdateTime(new Date()); |
| | | |
| | | TraceUtils.setCreateTrace(detail); |
| | | |
| | | this.save(detail); |
| | | save(detail); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param sum |
| | | * @return |
| | | */ |
| | | protected double getProgressPercent(String targetId, Double sum) { |
| | | protected double getProgressPercent(String targetId, int sum) { |
| | | |
| | | return 1.00d; |
| | | } |
| | | |
| | |
| | | return Progress.PROGRESS_TYPE_LECTURE; |
| | | } |
| | | |
| | | protected void updateProgress(String targetId, Progress p, Double sum) { |
| | | protected void updateProgress(String targetId, Progress p, int sum) { |
| | | |
| | | TraceUtils.setUpdateTrace(p); |
| | | p.setProgressValue(BigDecimal.valueOf(Double.valueOf(sum))); |
| | | p.setProgressValue(BigDecimal.valueOf(Long.valueOf(sum))); |
| | | p.setProgressPercent(1d); |
| | | |
| | | save(p); |
| | | |
| | | } |
| | | |
| | | protected Progress newProgress(String targetId, String learnerId, Double sum) { |
| | | protected Progress newProgress(String targetId, String learnerId, int sum) { |
| | | |
| | | Progress p = new Progress(); |
| | | TraceUtils.setCreateTrace(p); |
| | |
| | | p.setLearnerId(learnerId); |
| | | p.setLearnerName(ClientUtils.getUserName()); |
| | | p.setProgressUnit("s"); |
| | | p.setProgressValue(BigDecimal.valueOf(Double.valueOf(sum))); |
| | | p.setProgressValue(BigDecimal.valueOf(Long.valueOf(sum))); |
| | | p.setTargetId(targetId); |
| | | p.setType(Progress.PROGRESS_TYPE_LECTURE); |
| | | p.setProgressPercent(1d); |
| | | p.setDeleteFlag(false); |
| | | p.setCreator(ClientUtils.getUserName()); |
| | | p.setCreateId(ClientUtils.getUserId()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdator(ClientUtils.getUserName()); |
| | | p.setUpdateId(ClientUtils.getUserId()); |
| | | p.setUpdateTime(new Date()); |
| | | save(p); |
| | | |
| | | return p; |
| | |
| | | package com.qxueyou.scc.admin.progress.service.impl.lecture; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public double getProgressPercent(String targetId, Double sum) { |
| | | public double getProgressPercent(String targetId, int sum) { |
| | | |
| | | LectureDocV LectureDoc = lectureService.readDocLecture(targetId); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Progress newProgress(String targetId, String learnerId, Double sum) { |
| | | public Progress newProgress(String targetId, String learnerId, int sum) { |
| | | |
| | | Progress p = new Progress(); |
| | | TraceUtils.setCreateTrace(p); |
| | |
| | | p.setLearnerId(learnerId); |
| | | p.setLearnerName(ClientUtils.getUserName()); |
| | | p.setProgressUnit("s"); |
| | | p.setProgressValue(BigDecimal.valueOf(Double.valueOf(sum))); |
| | | p.setProgressValue(BigDecimal.valueOf(Long.valueOf(sum))); |
| | | p.setTargetId(targetId); |
| | | p.setType(Progress.PROGRESS_TYPE_LECTURE); |
| | | p.setProgressPercent(getProgressPercent(targetId, sum)); |
| | | p.setDeleteFlag(false); |
| | | p.setCreator(ClientUtils.getUserName()); |
| | | p.setCreateId(ClientUtils.getUserId()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdator(ClientUtils.getUserName()); |
| | | p.setUpdateId(ClientUtils.getUserId()); |
| | | p.setUpdateTime(new Date()); |
| | | |
| | | save(p); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateProgress(String targetId, Progress p, Double sum) { |
| | | public void updateProgress(String targetId, Progress p, int sum) { |
| | | |
| | | TraceUtils.setUpdateTrace(p); |
| | | p.setProgressValue(BigDecimal.valueOf(Double.valueOf(sum))); |
| | | p.setProgressValue(BigDecimal.valueOf(Long.valueOf(sum))); |
| | | if(p.getProgressPercent() == null || getProgressPercent(targetId, sum)>p.getProgressPercent()) { |
| | | p.setProgressPercent(getProgressPercent(targetId, sum)); |
| | | } |
| | |
| | | package com.qxueyou.scc.admin.progress.service.impl.lecture; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Progress newProgress(String targetId, String learnerId, Double sum) { |
| | | public Progress newProgress(String targetId, String learnerId, int sum) { |
| | | |
| | | Progress p = new Progress(); |
| | | TraceUtils.setCreateTrace(p); |
| | |
| | | p.setLearnerId(learnerId); |
| | | p.setLearnerName(ClientUtils.getUserName()); |
| | | p.setProgressUnit("s"); |
| | | p.setProgressValue(BigDecimal.valueOf(Double.valueOf(sum))); |
| | | p.setProgressValue(BigDecimal.valueOf(Long.valueOf(sum))); |
| | | p.setTargetId(targetId); |
| | | p.setType(Progress.PROGRESS_TYPE_LECTURE); |
| | | p.setProgressPercent(getProgressPercent(targetId, sum)); |
| | | p.setDeleteFlag(false); |
| | | p.setCreator(ClientUtils.getUserName()); |
| | | p.setCreateId(ClientUtils.getUserId()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdator(ClientUtils.getUserName()); |
| | | p.setUpdateId(ClientUtils.getUserId()); |
| | | p.setUpdateTime(new Date()); |
| | | |
| | | save(p); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateProgress(String targetId, Progress p, Double sum) { |
| | | public void updateProgress(String targetId, Progress p, int sum) { |
| | | |
| | | TraceUtils.setUpdateTrace(p); |
| | | p.setProgressValue(BigDecimal.valueOf(Double.valueOf(sum))); |
| | |
| | | import com.qxueyou.scc.base.service.ICacheService; |
| | | import com.qxueyou.scc.base.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 阿里云OCS缓存服务 |
| | | * |
| | |
| | | private static final Logger log = LogManager.getLogger("RedisCacheService"); |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | @Autowired |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @SuppressWarnings("unchecked") |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | 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.web.bind.annotation.GetMapping; |
| | |
| | | @GetMapping(value = "deleteCourseware") |
| | | public Result deleteCourseware(String id) { |
| | | |
| | | return lectureService.deleteLecture(id.split(",")); |
| | | Result result = lectureService.deleteLecture(id.split(",")); |
| | | lectureService.deleteLectureLoad(id.split(",")); |
| | | return result; |
| | | |
| | | } |
| | | |
| | |
| | | result = lectureService.addLecture(sectionId, resId_); |
| | | successCount = result.isSuccess() ? 1 : 0; |
| | | } |
| | | lectureService.addLectureLoad(sectionId); |
| | | |
| | | return new Result(true, null, successCount); |
| | | } |
| | |
| | | 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.SubjectUtils; |
| | | 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; |
| | |
| | | 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= "课程管理-学员端") |
| | | @RestController |
| | |
| | | IEvaluateService evaluateService; |
| | | |
| | | //--------------------------------------------------------------app端接口--------------------------------------------------------------------------------------------------- |
| | | |
| | | /** |
| | | * 学习端获取 所有课件 |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "学习端获取课程学年列表") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "我的课程按学期分类") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "我的课程按时间排序") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "我的班级信息") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "学习端获取课程列表") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "学习端获取课程下课件,按创建时间排序") |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取其他课件统计 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "学习端获取其他课件统计") |
| | | @GetMapping(value = "/app/otherLectureCount") |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 学习端获取课程列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "学习端获取课程下课件,按目录分类", notes = "") |
| | | @ApiImplicitParams({ |
| | |
| | | |
| | | /** |
| | | * 我的公开课列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "我的公开课列表", notes = "") |
| | | @GetMapping(value = "/app/myOpenSubjectList") |
| | |
| | | |
| | | /** |
| | | * 公开课列表 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "公开课列表", notes = "") |
| | | @GetMapping(value = "/app/openSubjectList") |
| | |
| | | |
| | | /** |
| | | * 公开课详情 |
| | | * |
| | | */ |
| | | @ApiOperation(value = "公开课详情", notes = "") |
| | | @GetMapping(value = "/app/openSubjectInfo") |
| | |
| | | /** |
| | | * 获取课件列表 |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @param type |
| | | * 课件类型 |
| | | * @param keyword |
| | | * 搜索关键字 |
| | | * @param limit |
| | | * 每页显示几条 |
| | | * @param pageNum |
| | | * 页码 |
| | | * @param chapterId 章节id |
| | | * @param type 课件类型 |
| | | * @param keyword 搜索关键字 |
| | | * @param limit 每页显示几条 |
| | | * @param pageNum 页码 |
| | | * @return 状态说明(0,视频。1,音频。2,文档。3,练习。) |
| | | */ |
| | | @ApiOperation(value = "根据章节获取课件列表", notes = "状态说明(0,视频。1,音频。2,文档。3,练习。)") |
| | |
| | | /** |
| | | * 课件学习进度提交 stu/subject/study |
| | | * |
| | | * @param lectureId |
| | | * 课件id |
| | | * @param from |
| | | * 开始学习位置 ,如视频,则为时分秒(00:10:12),如文档,则无需提交该参数 |
| | | * @param to |
| | | * 结束学习位置,同to |
| | | * @param lectureId 课件id |
| | | * @param from 开始学习位置 ,如视频,则为时分秒(00:10:12),如文档,则无需提交该参数 |
| | | * @param to 结束学习位置,同to |
| | | */ |
| | | @ApiOperation(value = "提交学习进度") |
| | | @ApiImplicitParams({ |
| | |
| | | /** |
| | | * 音频时长提交 stu/subject/submitAudioDuration |
| | | * |
| | | * @param lectureId |
| | | * 课件id |
| | | * @param seconds |
| | | * 时长 |
| | | * @param lectureId 课件id |
| | | * @param seconds 时长 |
| | | */ |
| | | @ApiOperation(value = "音频时长提交") |
| | | @ApiImplicitParams({ |
| | |
| | | /** |
| | | * 课程列表 |
| | | * |
| | | * @param clssId |
| | | * 班级id |
| | | * @param startTime |
| | | * 开班时间 |
| | | * @param clssId 班级id |
| | | * @param startTime 开班时间 |
| | | */ |
| | | @ApiOperation(value = "课程列表") |
| | | @ApiImplicitParams({ |
| | |
| | | @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); |
| | | List<MySubjectV> resultMs = subjectService.listMySubjectV(classId, userId); |
| | | List<MySubjectV> result = new ArrayList<>(); |
| | | List<Object> lecurelist = new ArrayList<>(); |
| | | int i = 0; |
| | | 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); |
| | | } |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("subjectList", |
| | | QBeanUtils.listBean2ListMap(result, |
| | | CollectionUtils.newStringMap("id.subjectId", "subjectId", "id.classId", "classId", |
| | | "subjectName", "subjectName,coursewareName", "percent", "percent", "progressValue", |
| | | "studyTime", "coverPageUrl", "coverPageUrl"))); |
| | | "subjectName", "subjectName", "percent", "percent", "progressValue", |
| | | "studyTime", "coverPageUrl", "coverPageUrl")),"lecurelist",lecurelist)); |
| | | } |
| | | |
| | | /** |
| | | * 进入课程 |
| | | * |
| | | * @param subjectId |
| | | * 课程id |
| | | * @param subjectId 课程id |
| | | */ |
| | | @ApiOperation(value = "课程详情") |
| | | @ApiImplicitParams({ |
| | |
| | | MySubjectV subject = subjectService.getMy1stSubjectVById(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; |
| | | if(!myLectureVList.isEmpty()) { |
| | | 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.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 { |
| | | |
| | | } |
| | | 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)); |
| | | "chapterLst", progressLst,"coursewareName",coursewareName)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.sys.utils; |
| | | |
| | | import org.jaudiotagger.audio.AudioFileIO; |
| | | import org.jaudiotagger.audio.mp3.MP3AudioHeader; |
| | | import org.jaudiotagger.audio.mp3.MP3File; |
| | | |
| | | |
| | | import javax.sound.sampled.AudioFormat; |
| | | import javax.sound.sampled.AudioInputStream; |
| | | import javax.sound.sampled.AudioSystem; |
| | | import java.io.File; |
| | | |
| | | public class AudioUtil { |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取语音文件播放时长(秒) 支持wav 格式 |
| | | * @param filePath |
| | | * @return |
| | | */ |
| | | public static Float getDuration(String filePath){ |
| | | try{ |
| | | |
| | | File destFile = new File(filePath); |
| | | AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(destFile); |
| | | AudioFormat format = audioInputStream.getFormat(); |
| | | long audioFileLength = destFile.length(); |
| | | int frameSize = format.getFrameSize(); |
| | | float frameRate = format.getFrameRate(); |
| | | float durationInSeconds = (audioFileLength / (frameSize * frameRate)); |
| | | return durationInSeconds; |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return 0f; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取mp3语音文件播放时长(秒) mp3 |
| | | * @param filePath |
| | | * @return |
| | | */ |
| | | public static Float getMp3Duration(String filePath){ |
| | | |
| | | try { |
| | | File mp3File = new File(filePath); |
| | | MP3File f = (MP3File) AudioFileIO.read(mp3File); |
| | | MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader(); |
| | | return Float.parseFloat(audioHeader.getTrackLength()+""); |
| | | } catch(Exception e) { |
| | | e.printStackTrace(); |
| | | return 0f; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取mp3语音文件播放时长(秒) |
| | | * @param mp3File |
| | | * @return |
| | | */ |
| | | public static Float getMp3Duration(File mp3File){ |
| | | |
| | | try { |
| | | //File mp3File = new File(filePath); |
| | | MP3File f = (MP3File) AudioFileIO.read(mp3File); |
| | | MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader(); |
| | | return Float.parseFloat(audioHeader.getTrackLength()+""); |
| | | } catch(Exception e) { |
| | | e.printStackTrace(); |
| | | return 0f; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 得到pcm文件的毫秒数 |
| | | * |
| | | * pcm文件音频时长计算 |
| | | * 同图像bmp文件一样,pcm文件保存的是未压缩的音频信息。 16bits 编码是指,每次采样的音频信息用2个字节保存。可以对比下bmp文件用分别用2个字节保存RGB颜色的信息。 16000采样率 是指 1秒钟采样 16000次。常见的音频是44100HZ,即一秒采样44100次。 单声道: 只有一个声道。 |
| | | * |
| | | * 根据这些信息,我们可以计算: 1秒的16000采样率音频文件大小是 2*16000 = 32000字节 ,约为32K 1秒的8000采样率音频文件大小是 2*8000 = 16000字节 ,约为 16K |
| | | * |
| | | * 如果已知录音时长,可以根据文件的大小计算采样率是否正常。 |
| | | * @param filePath |
| | | * @return |
| | | */ |
| | | public static long getPCMDurationMilliSecond(String filePath) { |
| | | File file = new File(filePath); |
| | | |
| | | //得到多少秒 |
| | | long second = file.length() / 32000 ; |
| | | |
| | | long milliSecond = Math.round((file.length() % 32000) / 32000.0 * 1000 ) ; |
| | | |
| | | return second * 1000 + milliSecond; |
| | | } |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.qxueyou.scc.sys.utils; |
| | | |
| | | import com.coremedia.iso.IsoFile; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | |
| | | public class VideoUtil { |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取视频文件的播放长度(mp4、mov格式) |
| | | * @param videoPath |
| | | * @return 单位为毫秒 |
| | | */ |
| | | public static long getMp4Duration(String videoPath) throws IOException { |
| | | IsoFile isoFile = new IsoFile(videoPath); |
| | | long lengthInSeconds = |
| | | isoFile.getMovieBox().getMovieHeaderBox().getDuration() / |
| | | isoFile.getMovieBox().getMovieHeaderBox().getTimescale(); |
| | | return lengthInSeconds; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 得到语音或视频文件时长,单位秒 |
| | | * @param filePath |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | public static long getDuration(String filePath) throws IOException { |
| | | String format = getVideoFormat(filePath); |
| | | long result = 0; |
| | | if("wav".equals(format)){ |
| | | result = AudioUtil.getDuration(filePath).intValue(); |
| | | }else if("mp3".equals(format)){ |
| | | result = AudioUtil.getMp3Duration(filePath).intValue(); |
| | | }else if("m4a".equals(format)) { |
| | | result = VideoUtil.getMp4Duration(filePath); |
| | | }else if("mov".equals(format)){ |
| | | result = VideoUtil.getMp4Duration(filePath); |
| | | }else if("mp4".equals(format)){ |
| | | result = VideoUtil.getMp4Duration(filePath); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 得到语音或视频文件时长,单位秒 |
| | | * @param filePath |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | public static long getDuration(String filePath,String format) throws IOException { |
| | | long result = 0; |
| | | if("wav".equals(format)){ |
| | | result = AudioUtil.getDuration(filePath).intValue(); |
| | | }else if("mp3".equals(format)){ |
| | | result = AudioUtil.getMp3Duration(filePath).intValue(); |
| | | }else if("m4a".equals(format)) { |
| | | result = VideoUtil.getMp4Duration(filePath); |
| | | }else if("mov".equals(format)){ |
| | | result = VideoUtil.getMp4Duration(filePath); |
| | | }else if("mp4".equals(format)){ |
| | | result = VideoUtil.getMp4Duration(filePath); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 得到文件格式 |
| | | * @param path |
| | | * @return |
| | | */ |
| | | public static String getVideoFormat(String path){ |
| | | return path.toLowerCase().substring(path.toLowerCase().lastIndexOf(".") + 1); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.qxueyou.scc.sys.utils.AudioUtil; |
| | | import com.qxueyou.scc.sys.utils.VideoUtil; |
| | | import com.qxueyou.scc.teach.res.model.ResItemVideo; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.qxueyou.scc.base.model.Result; |
| | |
| | | @Autowired |
| | | ICacheService cacheService; |
| | | |
| | | @Value("${scc.resRootPath}") |
| | | String resRootPath; |
| | | |
| | | @Override |
| | | public String add(String fileId, String name) { |
| | | ResFile file = fileService.read(fileId); |
| | | String mediaVideoId = addVideoConverTask(file); |
| | | ResItemAudio audio = new ResItemAudio(); |
| | | TraceUtils.setCreateTrace(audio); |
| | | try { |
| | | audio.setStatus(ResItemAudio.STATUS_LINEUP); |
| | | audio.setPlayTime(AudioUtil.getMp3Duration(resRootPath+"/"+file.getPath()).intValue()); |
| | | audio.setFileId(fileId); |
| | | audio.setName(name); |
| | | audio.setMediaVideoId(mediaVideoId); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | // 将mediaVideoId放进缓存 |
| | | cacheService.lstRightPush(ResItemVideoService.RES_VIDEO_CONVER_LST, mediaVideoId); |
| | | save(audio); |
| | |
| | | TraceUtils.setCreateTrace(video); |
| | | |
| | | video.setDeleteFlag(false); |
| | | try { |
| | | video.setDeleteFlag(false); |
| | | video.setPlayTime((int) VideoUtil.getMp4Duration(resRootPath +"/"+ file.getPath())); |
| | | video.setName(file.getFileName()); |
| | | video.setOrigUrl(file.getPath()); |
| | | video.setStatus(MediaVideo.STATUS_LINEUP); |
| | | video.setType(MediaVideo.MEDIA_AUDIO); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | save(video); |
| | | |
| | |
| | | |
| | | package com.qxueyou.scc.teach.res.service.impl.resitem; |
| | | |
| | | import java.io.File; |
| | | import java.util.Date; |
| | | |
| | | import com.qxueyou.scc.sys.utils.VideoUtil; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Autowired |
| | | ICacheService cacheService; |
| | | |
| | | @Value("${scc.resRootPath}") |
| | | String resRootPath; |
| | | |
| | | @Override |
| | | public String add(String fileId, String name) { |
| | | |
| | | ResFile file = fileService.read(fileId); |
| | | String mediaVideoId = addVideoConverTask(file); |
| | | |
| | | ResItemVideo resVideo = new ResItemVideo(); |
| | | |
| | | TraceUtils.setCreateTrace(resVideo); |
| | | |
| | | try { |
| | | resVideo.setFileId(fileId); |
| | | resVideo.setPlayTime((int) VideoUtil.getMp4Duration(resRootPath +"/"+ file.getPath())); |
| | | resVideo.setName(name); |
| | | resVideo.setMediaVideoId(mediaVideoId); |
| | | resVideo.setStatus(ResItemVideo.STATUS_LINEUP); |
| | |
| | | |
| | | // 将mediaVideoId放进缓存 |
| | | cacheService.lstRightPush(RES_VIDEO_CONVER_LST, mediaVideoId); |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return resVideo.getVideoId(); |
| | | } |
| | | |
| | |
| | | |
| | | TraceUtils.setCreateTrace(video); |
| | | |
| | | try { |
| | | video.setDeleteFlag(false); |
| | | video.setPlayTime((int) VideoUtil.getMp4Duration(resRootPath +"/"+ file.getPath())); |
| | | video.setName(file.getFileName()); |
| | | video.setOrigUrl(file.getPath()); |
| | | video.setStatus(MediaVideo.STATUS_LINEUP); |
| | | video.setType(MediaVideo.MEDIA_VIDEO); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | save(video); |
| | | |
New file |
| | |
| | | package com.qxueyou.scc.teach.subject.model; |
| | | |
| | | import javax.persistence.Entity; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 工具类 用来缓存课程信息 |
| | | */ |
| | | public class SubjectUtils implements java.io.Serializable { |
| | | private String subjectId; |
| | | private BigDecimal percent; |
| | | private BigDecimal studyTime; |
| | | private String coursewareName; |
| | | |
| | | public String getSubjectId() { |
| | | return subjectId; |
| | | } |
| | | |
| | | public void setSubjectId(String subjectId) { |
| | | this.subjectId = subjectId; |
| | | } |
| | | |
| | | public BigDecimal getPercent() { |
| | | return percent; |
| | | } |
| | | |
| | | public void setPercent(BigDecimal percent) { |
| | | this.percent = percent; |
| | | } |
| | | |
| | | public BigDecimal getStudyTime() { |
| | | return studyTime; |
| | | } |
| | | |
| | | public void setStudyTime(BigDecimal studyTime) { |
| | | this.studyTime = studyTime; |
| | | } |
| | | |
| | | public String getCoursewareName() { |
| | | return coursewareName; |
| | | } |
| | | |
| | | public void setCoursewareName(String coursewareName) { |
| | | this.coursewareName = coursewareName; |
| | | } |
| | | } |
| | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * MySubjectV generated by hbm2java |
| | | */ |
| | | @Entity |
| | | @Table(name = "my_lecture_v") |
| | | @Transactional(readOnly = true) |
| | | public class MyLectureV implements java.io.Serializable { |
| | | |
| | | private static final long serialVersionUID = -332455459706490649L; |
| | |
| | | */ |
| | | Result addLecture(String chapterId, String resId); |
| | | |
| | | |
| | | /** |
| | | * 新增后刷新课件 |
| | | */ |
| | | Result addLectureLoad(String sectionId); |
| | | /** |
| | | * 读取课件 |
| | | * |
| | |
| | | * @return 上传结果:{"success":true,msg:"success",attrs:{}} |
| | | */ |
| | | Result deleteLecture(String[] lectureIds); |
| | | |
| | | Result deleteLectureLoad(String[] lectureIds); |
| | | |
| | | /** |
| | | * 复制课件 |
| | |
| | | * 读取文档课件 |
| | | */ |
| | | LectureDocV readDocLecture(String handoutId); |
| | | |
| | | /** |
| | | * 课件详情查询 |
| | | * @param learnerId |
| | | * @param subjectId |
| | | * @param keyword |
| | | * @param pageSize |
| | | * @param pageNum |
| | | * @param type |
| | | * @return |
| | | */ |
| | | List<MyLectureV> listLectureVBySubjectId(String learnerId, String subjectId, String keyword, Integer pageSize, |
| | | Integer pageNum, String type); |
| | | } |
| | |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.teach.subject.model.Subject; |
| | | import com.qxueyou.scc.teach.subject.model.view.MySubjectV; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | public interface ISubjectService { |
| | | |
| | |
| | | |
| | | 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 { |
| | |
| | | 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"); |
| | | } |
| | | |
| | |
| | | |
| | | TraceUtils.setUpdateTrace(lecture); |
| | | lecture.setDeleteFlag(true); |
| | | |
| | | save(lecture); |
| | | |
| | | subjectService.addLectureCount(lecture.getSubjectId(), -1); |
| | |
| | | Integer pageNum, String type) { |
| | | StringBuffer hql = new StringBuffer("from MyLectureV where chapterId=? and id.userId=?"); |
| | | List<Object> args = CollectionUtils.newList(chapterId, 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 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=?"); |
| | |
| | | @Override |
| | | public Result doStudy(String lectureId, Double from, Double to) { |
| | | String userId = null; |
| | | return progressService.addProgress(Progress.PROGRESS_TYPE_LECTURE, lectureId, from.doubleValue(), to.doubleValue(), |
| | | return progressService.addProgress(Progress.PROGRESS_TYPE_LECTURE, lectureId, from.intValue(), to.intValue(), |
| | | userId); |
| | | } |
| | | |
| | |
| | | |
| | | import com.qxueyou.scc.base.model.UserInfoWrapper; |
| | | import com.qxueyou.scc.sys.model.CacheParamters; |
| | | import com.qxueyou.scc.teach.subject.model.view.*; |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | 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.view.MySubjectV; |
| | | import com.qxueyou.scc.teach.subject.model.view.OpenSubjectV; |
| | | import com.qxueyou.scc.teach.subject.model.view.QMyLectureV; |
| | | import com.qxueyou.scc.teach.subject.model.view.QMySubjectV; |
| | | import com.qxueyou.scc.teach.subject.model.view.QOpenSubjectV; |
| | | import com.qxueyou.scc.teach.subject.service.ILectureService; |
| | | import com.qxueyou.scc.teach.subject.service.ISubjectService; |
| | | import com.qxueyou.scc.user.model.QUser; |
| | | import com.qxueyou.scc.user.model.UserTeacher; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | |
| | | /** |
| | | * 删除单个课程 |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @param chapterId 章节id |
| | | * @return |
| | | */ |
| | | private Result deleteSubject(String subjectId) { |
| | |
| | | /** |
| | | * 发布单个课程 |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @param chapterId 章节id |
| | | * @return |
| | | */ |
| | | private Result releaseSubject(String subjectId) { |
| | |
| | | /** |
| | | * 发布单个课程 |
| | | * |
| | | * @param chapterId |
| | | * 章节id |
| | | * @param chapterId 章节id |
| | | * @return |
| | | */ |
| | | private Result cancelSubject(String subjectId) { |
| | |
| | | String UserId = ClientUtils.getUserId(); |
| | | MySubjectV result = findUnique(hql, CollectionUtils.newList(UserId, subjectId), |
| | | MySubjectV.class); |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | String classId = (String) subject.get("classId"); |
| | | String subjectId = (String) subject.get("subjectId"); |
| | | Map<String, Object> map = progressDao.getStudyById(userId, subjectId, classId); |
| | | List<MyLectureV> myLectureVList = lectureService.listLectureVBySubjectId(userId, subjectId, "", 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; |
| | | } |
| | | } |
| | | subject.put("percent", new BigDecimal(percentAvg)); |
| | | subject.put("progressValue", new BigDecimal(progressValue)); |
| | | |
| | | subject.put("lectureParentId", map.get("lectureParentId")); |
| | | subject.put("lectureId", map.get("lectureId")); |
| | | subject.put("unCommitExerciseCount", exerciseInfoService.getUnCommitExerciseCount(classId, userId)); |
| | |
| | | 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)) |
| | | .and(qSubjectProgressTreeV.id.nodeId.eq(nodeId))).orderBy(order).fetch().stream().map(tuple -> { |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("userName", tuple.get(qUser.name)); |
| | | map.put("userId", tuple.get(qUser.userId)); |
| | |
| | | |
| | | /** |
| | | * 通过作业完成个数排序 |
| | | * |
| | | */ |
| | | private List<Map<String, Object>> exerciseInfoDesc(String classId, String subjectId) { |
| | | QExerciseResultV qExerciseResultV = QExerciseResultV.exerciseResultV; |
| | |
| | | System.out.println("clsSubjectlistaaaaaa"+clsSubjectlist); |
| | | return this.termSubjectList(classId, clsSubjectlist); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | public static final QStuStudent stuStudent = new QStuStudent("stuStudent"); |
| | | |
| | | public final StringPath attendanceStatus = createString("attendanceStatus"); |
| | | |
| | | public final StringPath classId = createString("classId"); |
| | | |
| | | public final StringPath createId = createString("createId"); |
| | |
| | | |
| | | public final StringPath studentNo = createString("studentNo"); |
| | | |
| | | public final StringPath studentNumber = createString("studentNumber"); |
| | | |
| | | public final NumberPath<java.math.BigDecimal> studyDuration = createNumber("studyDuration", java.math.BigDecimal.class); |
| | | |
| | | public final StringPath subjectId = createString("subjectId"); |
| | |
| | | |
| | | public final NumberPath<java.math.BigDecimal> progressValue = createNumber("progressValue", java.math.BigDecimal.class); |
| | | |
| | | public final StringPath status = createString("status"); |
| | | |
| | | public final StringPath subjectId = createString("subjectId"); |
| | | |
| | | public final StringPath subjectName = createString("subjectName"); |
| | | |
| | | public final StringPath userName = createString("userName"); |
| | | |
| | | public final StringPath deleteFlag = createString("deleteFlag"); |
| | | |
| | | |
| | | public QMyLectureV(String variable) { |
| | | this(MyLectureV.class, forVariable(variable), INITS); |
| | | } |