| | |
| | | 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; |
| | |
| | | import com.qxueyou.scc.teach.subject.model.Subject; |
| | | |
| | | /** |
| | | * 班级服务类 |
| | | * 班级服务类 |
| | | * |
| | | * @author xiadehu |
| | | */ |
| | |
| | | @Autowired |
| | | ITeacherService teacherService; |
| | | |
| | | @Autowired |
| | | ILectureService lectureService; |
| | | |
| | | /** |
| | | * 添加班级 |
| | | * 添加班级 |
| | | */ |
| | | @Override |
| | | public Result insertClass(String className, String classNumber, Date startTime, Date endTime, String subjectId, |
| | |
| | | return new Result(true, "success",CollectionUtils.newStringMap("classId",cls.getClassId())); |
| | | } |
| | | /** |
| | | * 添加补考班级班级 |
| | | * 添加补考班级班级 |
| | | */ |
| | | @Override |
| | | public Result insertReClass(String className, String classNumber, Date startTime, Date endTime, String subjectId, |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取班级列表 |
| | | * 获取班级列表 |
| | | */ |
| | | @Override |
| | | public List<ClsClass> getClassLst(String keyword, String teacherId, Integer pageSize, Integer pageNum, Integer pageType) { |
| | |
| | | |
| | | String hql = "select c from ClsClass c,StuStudent s where c.classId=s.classId and s.userId=? and s.status=?"; |
| | | |
| | | System.out.println(ClientUtils.getUserId()); |
| | | |
| | | List<ClsClass> result = find(hql, CollectionUtils.newList(ClientUtils.getUserId(), StuStudent.STATUS_ACTIVE), |
| | | ClsClass.class); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除班级 |
| | | * 删除班级 |
| | | */ |
| | | @Override |
| | | public Result deleteClass(String[] classIds) { |
| | | for (String classId : classIds) { |
| | | deleteClass(classId); |
| | | //删除班级学员 |
| | | //删除班级学员 |
| | | this.deleteStudent(classId); |
| | | //删除班级课程 |
| | | //删除班级课程 |
| | | this.deleteClassSubject(classId); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除班级学员 |
| | | * 删除班级学员 |
| | | */ |
| | | private void deleteStudent(String classId) { |
| | | this.bulkUpdate("update StuStudent set deleteFlag = 1 where classId = ?", new Object[] {classId}); |
| | | } |
| | | |
| | | /** |
| | | * 删除班级课程 |
| | | * 删除班级课程 |
| | | */ |
| | | private void deleteClassSubject(String classId) { |
| | | this.bulkUpdate("delete from ClsClassReSubject where classId=?", new Object[] {classId}); |
| | | } |
| | | |
| | | /** |
| | | * @param classId 班级id |
| | | * @param classId 班级id |
| | | * @return |
| | | */ |
| | | private Result deleteClass(String classId) { |
| | |
| | | |
| | | @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; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<Map<String,Object>> queryAvailableClassIdAndName(String teacherId,String subjectId) { |
| | | StringBuffer hql = new StringBuffer(1000); |
| | | // and c.endTime>=sysdate() 增加条件过滤掉历史班级 |
| | | // and c.endTime>=sysdate() 增加条件过滤掉历史班级 |
| | | hql.append("select c.classId as classId ,c.name as className from ClsClass c where c.deleteFlag is false and c.orgId=:orgId and c.createId=:createId " ); |
| | | Map<String,Object> queryParam = new HashMap<String,Object>(); |
| | | queryParam.put("orgId", ClientUtils.getOrgId()); |
| | |
| | | |
| | | |
| | | /** |
| | | * 查询班级 |
| | | * 查询班级 |
| | | * |
| | | * type 1正常班級,2历史班級 |
| | | * type 1正常班級,2历史班級 |
| | | */ |
| | | public Result classList(String keyword, Pager pager, int type) { |
| | | //获取老师id |
| | | //获取老师id |
| | | String teacherId = teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | if (StringUtils.isEmpty(teacherId)) { |
| | | return new Result(false, "非老师角色无法查看班级"); |
| | | return new Result(false, "非老师角色无法查看班级"); |
| | | } |
| | | QClsClass qClsClass = QClsClass.clsClass; |
| | | QSubject qSubject = QSubject.subject; |
| | | QClsClassReSubject qClsClassReSubject = QClsClassReSubject.clsClassReSubject; |
| | | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; |
| | | |
| | | //查询脚本 |
| | | //查询脚本 |
| | | JPAQuery<Tuple> queryDsl = this.getQueryFactory() |
| | | .select(qClsClass.name, qClsClass.classId, qClsClass.classNumber, qClsClass.studentCount, |
| | | qClsClass.createTime, qClsClass.startTime, qClsClass.endTime, qSubject) |
| | |
| | | .and(qClsClassReSubject.subjectId.eq(qSubject.subjectId))) |
| | | .groupBy(qClsClass.classId); |
| | | |
| | | //总数 |
| | | //总数 |
| | | long count = queryDsl.fetchCount(); |
| | | |
| | | //listData |
| | |
| | | .and(qSubjectProgressTreeV.nodeType.eq(Progress.PROGRESS_TYPE_SUBJECT))) |
| | | .groupBy(qSubjectProgressTreeV.id.nodeId).fetchOne()); |
| | | } else { |
| | | map.put("subjectName", "暂无开班课程"); |
| | | map.put("subjectName", "暂无开班课程"); |
| | | map.put("progressPercent", 0); |
| | | } |
| | | return map; |