From 26780c533f2c2af6b9216306f649c1bcede94e4a Mon Sep 17 00:00:00 2001 From: yn147 <2270338776@qq.com> Date: 星期五, 24 十一月 2023 16:43:37 +0800 Subject: [PATCH] 学生、课程 --- src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectService.java | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 100 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectService.java b/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectService.java index 66d943d..bd4ffc1 100644 --- a/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectService.java +++ b/src/main/java/com/qxueyou/scc/teach/subject/service/impl/SubjectService.java @@ -2,10 +2,7 @@ import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import com.qxueyou.scc.base.model.UserInfoWrapper; @@ -107,7 +104,7 @@ @Override - public Result add(String subjectName, String coverPageFileId, String contentFileId, int type) { + public Result add(String subjectName, String coverPageFileId, String contentFileId, int type, Date startTime, Date endTime) { Subject subject = new Subject(); if (StringUtils.isNotEmpty(coverPageFileId)) { @@ -122,6 +119,9 @@ subject.setStatus(Subject.STATUS_DRAFT); subject.setLectureCount(0); subject.setType(type); + //绛惧埌鏃堕棿 + subject.setStartTime(startTime); + subject.setEndTime(endTime); subject.setOrgId(ClientUtils.getOrgId()); save(subject); @@ -207,8 +207,8 @@ @Override public List<Subject> list(String text, String teacherId, String status, Integer type, Integer pageSize, Integer pageNum) { - - StringBuffer hql = new StringBuffer("from Subject where name like ? and orgId=? and deleteFlag is false and origSubjectId is null "); + //and origSubjectId is null + StringBuffer hql = new StringBuffer("from Subject where name like ? and orgId=? and deleteFlag is false "); List<Object> args = CollectionUtils.newList(text + "%", ClientUtils.getOrgId()); @@ -222,8 +222,12 @@ args.add(status); } +// if (!StringUtils.isEmpty(teacherId)) { +// hql.append(" and createId=?"); +// args.add(teacherId); +// } if (!StringUtils.isEmpty(teacherId)) { - hql.append(" and createId=?"); + hql.append(" and teacherId=?"); args.add(teacherId); } hql.append(" order by createTime desc"); @@ -419,6 +423,19 @@ } @Override + public List<OpenSubjectV> listOpenSubjectV() { + StringBuffer hql = new StringBuffer("from OpenSubjectV p where 1 = ?"); + int param = 1; + List<Object> args = CollectionUtils.newList(param); + + + List<OpenSubjectV> result = find(hql.toString(), args, OpenSubjectV.class); + + return result; + } + + + @Override public List<Map<String, Object>> listChapterStudyProgress(String subjectId) { QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; @@ -463,20 +480,21 @@ @Override public Result addClsSubject(String classId, String origSubjectId, String teacherId, Integer schoolYear, Integer term) throws IllegalAccessException, InvocationTargetException { //鏂板鑰佸笀璇剧▼ - Subject newSubject = new Subject(); - Subject origSubject = this.read(origSubjectId); +// Subject newSubject = new Subject(); + Subject newSubject = this.read(origSubjectId); UserTeacher teacher = this.read(UserTeacher.class, teacherId); - BeanUtils.copyProperties(newSubject, origSubject); +// BeanUtils.copyProperties(newSubject, origSubject); TraceUtils.setCreateTrace(newSubject); - newSubject.setSubjectId(null); +// newSubject.setSubjectId(null); newSubject.setTeacherId(teacherId); newSubject.setSchoolYear(schoolYear); newSubject.setTerm(term); - newSubject.setStatus(origSubject.getStatus()); +// newSubject.setStatus(origSubject.getStatus()); newSubject.setOrigSubjectId(origSubjectId); newSubject.setOrigCopySubjectId(origSubjectId); - newSubject.setType(Subject.TYPE_CLS_SUBJECT); +// newSubject.setType(Subject.TYPE_CLS_SUBJECT); + newSubject.setType(Subject.TYPE_ORG_SUBJECT); newSubject.setTeacherName(teacher.getName()); newSubject.setOrgId(ClientUtils.getOrgId()); save(newSubject); @@ -594,7 +612,6 @@ } 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)); @@ -606,6 +623,48 @@ subject.put("commitExamCount", examService.getCommitExamCount(classId, userId)); subject.put("toBeCommitExamCount", examService.getToBeCommitExamCount(classId, userId)); + } + List<OpenSubjectV> subjects = listOpenSubjectV(); + for(OpenSubjectV subject : subjects){ + Map<String, Object> subjectMap = new HashMap<>(); + String classId = ClientUtils.getClassId(); + String subjectId = subject.getSubjectId(); + Map<String, Object> map = progressDao.getStudyById(userId, subjectId, null); + List<MyOpenLectureV> myLectureVList = lectureService.listOpenLectureVBySubjectId(userId, subjectId, "", 1000, 1, null); + Double percent = 0.0; + Double progressValue = 0.0; + Double percentAvg = 0.0; + if (!myLectureVList.isEmpty()) { + for (MyOpenLectureV myOpenLectureV : myLectureVList) { + if (myOpenLectureV.getPercent() != null && myOpenLectureV.getProgressValue() != null) { + percent += myOpenLectureV.getPercent(); + progressValue += myOpenLectureV.getProgressValue().intValue(); + } + } + percentAvg = percent / myLectureVList.size(); + if (percentAvg.isNaN()) { + percentAvg = 0.0; + } + } + String className = "鍏紑璇�"; + subjectMap.put("subjectName",subject.getSubjectName()); + subjectMap.put("subjectId",subject.getSubjectId()); + subjectMap.put("coverPageUrl",subject.getCoverPageUrl()); + subjectMap.put("percent", new BigDecimal(percentAvg)); + subjectMap.put("progressValue", new BigDecimal(progressValue)); + subjectMap.put("className",className); + subjectMap.put("lectureParentId", map.get("lectureParentId")); + subjectMap.put("lectureId", map.get("lectureId")); + subjectMap.put("unCommitExerciseCount", exerciseInfoService.getUnCommitExerciseCount(classId, userId)); + subjectMap.put("toBeCommitExerciseCount", exerciseInfoService.getToBeCommitExerciseCount(classId, userId)); + subjectMap.put("CommitExerciseCount", exerciseInfoService.getCommitExerciseCount(classId, userId)); + subjectMap.put("exerciseCount", exerciseInfoService.getExerciseCount(classId, userId)); + subjectMap.put("examCount", examService.getExamCount(classId, userId)); + subjectMap.put("unCommitExamCount", examService.getUnCommitExamCount(classId, userId)); + subjectMap.put("commitExamCount", examService.getCommitExamCount(classId, userId)); + subjectMap.put("toBeCommitExamCount", examService.getToBeCommitExamCount(classId, userId)); + + subjectLstMap.add(subjectMap); } return new Result(true, "success", subjectLstMap); } @@ -646,6 +705,8 @@ .and(qSubjectProgressTreeV.id.nodeId.eq(nodeId))).orderBy(order).fetch().stream().map(tuple -> { List<ClsClassReSubject> clsClassReSubjects = find("from ClsClassReSubject where classId = ?",CollectionUtils.newList(nodeId),ClsClassReSubject.class); + int type = 3; + List<Subject> subjects = find("from Subject where type = ?",CollectionUtils.newList(type),Subject.class); Double percent = 0.0; Double progressValue = 0.0; Double percentAvg = 0.0; @@ -660,6 +721,21 @@ } } size += myLectureVList.size(); + if (percentAvg.isNaN()) { + percentAvg += 0.0; + } + } + } + for(Subject subject : subjects){ + List<MyOpenLectureV> myOpenLectureVList = lectureService.listOpenLectureVBySubjectId(tuple.get(qUser.userId), subject.getSubjectId(), "", 1000, 1, null); + if(!myOpenLectureVList.isEmpty()){ + for(MyOpenLectureV myOpenLecture : myOpenLectureVList){ + if (myOpenLecture.getPercent() != null && myOpenLecture.getProgressValue() != null) { + percent += myOpenLecture.getPercent(); + progressValue += myOpenLecture.getProgressValue().intValue(); + } + } + size += myOpenLectureVList.size(); if (percentAvg.isNaN()) { percentAvg += 0.0; } @@ -774,7 +850,9 @@ } else { if (StringUtils.isNotEmpty(teacherId)) { result = this.findListWithMapByHql( - "select distinct origSubjectId as subjectId ,name as subjectName from Subject where deleteFlag is false and type=" + Subject.TYPE_CLS_SUBJECT + " and teacherId='" + teacherId + "'", null); +// "select distinct origSubjectId as subjectId ,name as subjectName from Subject where deleteFlag is false and type=" + Subject.TYPE_CLS_SUBJECT + " and teacherId='" + teacherId + "'", null); + "select distinct origSubjectId as subjectId ,name as subjectName from Subject where deleteFlag is false and type=" + Subject.TYPE_ORG_SUBJECT + " and teacherId='" + teacherId + "'", null); + } else { result = this.findListWithMapByHql( "select subjectId as subjectId ,name as subjectName from Subject where deleteFlag is false and type=" + Subject.TYPE_ORG_SUBJECT + " and orgId='" + ClientUtils.getOrgId() + "'", null); @@ -1022,6 +1100,12 @@ } } + @Override + public String findSubjectName(String subjectId) { + Subject subject = findUnique("from Subject where subjectId = ? ",CollectionUtils.newList(subjectId),Subject.class); + return subject.getName(); + } + /** * 鎴戠殑鍏紑璇惧垪琛� -- Gitblit v1.8.0