|  |  |  | 
|---|
|  |  |  | public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (dao.exists(studentNo, orgId)) { | 
|---|
|  |  |  | return new Result(false, "学号已存在"); | 
|---|
|  |  |  | return new Result(false, "学号已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User user = userService.insertUser(name, studentNo, phoneNo, "000000", sex, orgId); | 
|---|
|  |  |  | 
|---|
|  |  |  | student.setUserId(user.getUserId()); | 
|---|
|  |  |  | student.setMobilePhone(phoneNo); | 
|---|
|  |  |  | if(StringUtils.isNoneBlank(classId)) { | 
|---|
|  |  |  | bulkUpdate("update ClsClass set studentCount = studentCount + 1  where deleteFlag is false and classId = ?", new Object[]{classId}); | 
|---|
|  |  |  | bulkUpdate("update ClsClass set studentCount = studentCount + 1  where deleteFlag is false and classId = ?", new Object[]{classId}); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | save(student); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId,String comName) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (dao.exists(studentNo, orgId)) { | 
|---|
|  |  |  | return new Result(false, "学号已存在"); | 
|---|
|  |  |  | return new Result(false, "学号已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User user = userService.insertUser(name, studentNo, phoneNo, "000000", sex, orgId); | 
|---|
|  |  |  | 
|---|
|  |  |  | student.setSex(sex); | 
|---|
|  |  |  | student.setUserId(user.getUserId()); | 
|---|
|  |  |  | student.setMobilePhone(phoneNo); | 
|---|
|  |  |  | //公司名称 | 
|---|
|  |  |  | //公司名称 | 
|---|
|  |  |  | student.setSubjectId(comName); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(StringUtils.isNoneBlank(classId)) { | 
|---|
|  |  |  | bulkUpdate("update ClsClass set studentCount = studentCount + 1  where deleteFlag is false and classId = ?", new Object[]{classId}); | 
|---|
|  |  |  | bulkUpdate("update ClsClass set studentCount = studentCount + 1  where deleteFlag is false and classId = ?", new Object[]{classId}); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | save(student); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new Result(true, "success", CollectionUtils.newStringMap("studentId", student.getStudentId(), "password", user.getPassword())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Result updateImgStudent(String studentId){ | 
|---|
|  |  |  | //根据学学员ID,获取用户信息 | 
|---|
|  |  |  | StuStudent stu = this.read(StuStudent.class, studentId); | 
|---|
|  |  |  | stu.setTenantId("1"); | 
|---|
|  |  |  | save(stu); | 
|---|
|  |  |  | return new Result(true, "success"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Result updateImgStudent(String studentId){ | 
|---|
|  |  |  | //根据学学员ID,获取用户信息 | 
|---|
|  |  |  | StuStudent stu = this.read(StuStudent.class, studentId); | 
|---|
|  |  |  | stu.setTenantId("1"); | 
|---|
|  |  |  | save(stu); | 
|---|
|  |  |  | return new Result(true, "success"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Result updateStudent(String studentId, String name,String password, String studentNo, boolean sex, String phoneNo) { | 
|---|
|  |  |  | //根据学学员ID,获取用户信息 | 
|---|
|  |  |  | //根据学学员ID,获取用户信息 | 
|---|
|  |  |  | StuStudent stu = this.read(StuStudent.class, studentId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!stu.getStudentNo().equals(studentNo) && dao.exists(studentNo,ClientUtils.getOrgId())) { | 
|---|
|  |  |  | return new Result(false, "学号已存在"); | 
|---|
|  |  |  | if (!stu.getStudentNo().equals(studentNo) && dao.exists(studentNo,ClientUtils.getOrgId())) { | 
|---|
|  |  |  | return new Result(false, "学号已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stu.setName(name); | 
|---|
|  |  |  | 
|---|
|  |  |  | user.setSex(sex); | 
|---|
|  |  |  | user.setMobilePhone(phoneNo); | 
|---|
|  |  |  | if(!StringUtils.isEmpty(password)){ | 
|---|
|  |  |  | user.setPassword(password); | 
|---|
|  |  |  | user.setPassword(password); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | user.setName(name); | 
|---|
|  |  |  | save(user); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Map<String, Object>> getStudentLst(String classId, String keyword, Pager pager) { | 
|---|
|  |  |  | QUser qUser = QUser.user; | 
|---|
|  |  |  | QStuStudent qStuStudent = QStuStudent.stuStudent; | 
|---|
|  |  |  | return this.getQueryFactory() | 
|---|
|  |  |  | .select(qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex, | 
|---|
|  |  |  | qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score, | 
|---|
|  |  |  | qUser.imgPath) | 
|---|
|  |  |  | .from(qUser, qStuStudent) | 
|---|
|  |  |  | .where(qUser.deleteFlag.isFalse().and(qUser.userId.eq(qStuStudent.userId)) | 
|---|
|  |  |  | .and(qStuStudent.classId.eq(classId)).and(qStuStudent.name.like("%" + keyword + "%")).and(qStuStudent.deleteFlag.isFalse())) | 
|---|
|  |  |  | .limit(pager.getPageSize()).offset(pager.getOffset()).orderBy(qStuStudent.createTime.desc()).fetch().stream().map(tuple -> { | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<String, Object>(); | 
|---|
|  |  |  | map.put("studentId", tuple.get(qStuStudent.studentId)); | 
|---|
|  |  |  | map.put("name", tuple.get(qStuStudent.name)); | 
|---|
|  |  |  | map.put("studentNo", tuple.get(qStuStudent.studentNo)); | 
|---|
|  |  |  | map.put("studentNumber", tuple.get(qStuStudent.studentNo)); | 
|---|
|  |  |  | map.put("sex", tuple.get(qStuStudent.sex)); | 
|---|
|  |  |  | map.put("mobilePhone", tuple.get(qStuStudent.mobilePhone)); | 
|---|
|  |  |  | map.put("status", tuple.get(qStuStudent.status)); | 
|---|
|  |  |  | map.put("studyDuration", tuple.get(qStuStudent.studyDuration)); | 
|---|
|  |  |  | map.put("tenantId", tuple.get(qStuStudent.tenantId)); | 
|---|
|  |  |  | map.put("score", tuple.get(qStuStudent.score)); | 
|---|
|  |  |  | map.put("imgPath", tuple.get(qUser.imgPath)); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | }).collect(Collectors.toList()); | 
|---|
|  |  |  | QUser qUser = QUser.user; | 
|---|
|  |  |  | QStuStudent qStuStudent = QStuStudent.stuStudent; | 
|---|
|  |  |  | return this.getQueryFactory() | 
|---|
|  |  |  | .select(qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex, | 
|---|
|  |  |  | qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score, | 
|---|
|  |  |  | qUser.imgPath) | 
|---|
|  |  |  | .from(qUser, qStuStudent) | 
|---|
|  |  |  | .where(qUser.deleteFlag.isFalse().and(qUser.userId.eq(qStuStudent.userId)) | 
|---|
|  |  |  | .and(qStuStudent.classId.eq(classId)).and(qStuStudent.name.like("%" + keyword + "%")).and(qStuStudent.deleteFlag.isFalse())) | 
|---|
|  |  |  | .limit(pager.getPageSize()).offset(pager.getOffset()).orderBy(qStuStudent.createTime.desc()).fetch().stream().map(tuple -> { | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<String, Object>(); | 
|---|
|  |  |  | map.put("studentId", tuple.get(qStuStudent.studentId)); | 
|---|
|  |  |  | map.put("name", tuple.get(qStuStudent.name)); | 
|---|
|  |  |  | map.put("studentNo", tuple.get(qStuStudent.studentNo)); | 
|---|
|  |  |  | map.put("studentNumber", tuple.get(qStuStudent.studentNo)); | 
|---|
|  |  |  | map.put("sex", tuple.get(qStuStudent.sex)); | 
|---|
|  |  |  | map.put("mobilePhone", tuple.get(qStuStudent.mobilePhone)); | 
|---|
|  |  |  | map.put("status", tuple.get(qStuStudent.status)); | 
|---|
|  |  |  | map.put("studyDuration", tuple.get(qStuStudent.studyDuration)); | 
|---|
|  |  |  | map.put("tenantId", tuple.get(qStuStudent.tenantId)); | 
|---|
|  |  |  | map.put("score", tuple.get(qStuStudent.score)); | 
|---|
|  |  |  | map.put("imgPath", tuple.get(qUser.imgPath)); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | }).collect(Collectors.toList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public int getStudentsCount(String classId, String keyword) { | 
|---|
|  |  |  | //      //TODO 判断是否为补考分组 | 
|---|
|  |  |  | //      //TODO 判断是否为补考分组 | 
|---|
|  |  |  | //      ClsClass cls = clsService.read(classId); | 
|---|
|  |  |  | //      String hql=null; | 
|---|
|  |  |  | //      if(cls!=null && cls.getClassTypes()!=null && "1".equals(cls.getClassTypes())){ | 
|---|
|  |  |  | //         //TODO 补考分组需要另一种查询学员 stu.tenantId = class.classId | 
|---|
|  |  |  | //         //TODO 补考分组需要另一种查询学员 stu.tenantId = class.classId | 
|---|
|  |  |  | //            hql = "from StuStudent where tenantId=:classId and name like :keyword and deleteFlag is false"; | 
|---|
|  |  |  | //      }else { | 
|---|
|  |  |  | String   hql = "from StuStudent where classId=:classId and name like :keyword and deleteFlag is false"; | 
|---|
|  |  |  | String   hql = "from StuStudent where classId=:classId and name like :keyword and deleteFlag is false"; | 
|---|
|  |  |  | //      } | 
|---|
|  |  |  | return findCountByComplexHql(hql, CollectionUtils.newObjectMap("classId", classId, "keyword", "%" + keyword + "%" )); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Result deleteStudent(String classId, String studentId) { | 
|---|
|  |  |  | StuStudent student = read(StuStudent.class, studentId); | 
|---|
|  |  |  | User user = read(User.class, student.getUserId()); | 
|---|
|  |  |  | User user = read(User.class, student.getUserId()); | 
|---|
|  |  |  | if (StuStudent.STATUS_ACTIVE.equals(student.getStatus())) { | 
|---|
|  |  |  | return new Result(false, "已激活学员不能移除"); | 
|---|
|  |  |  | return new Result(false, "已激活学员不能移除"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | TraceUtils.setUpdateTrace(student); | 
|---|
|  |  |  | student.setDeleteFlag(true); | 
|---|
|  |  |  | save(student); | 
|---|
|  |  |  | deleteTrace(user); | 
|---|
|  |  |  | deleteTrace(user); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new Result(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StuStudent student = read(StuStudent.class, studentId); | 
|---|
|  |  |  | if(student == null) { | 
|---|
|  |  |  | return new Result(false, "未查询到学员信息"); | 
|---|
|  |  |  | return new Result(false, "未查询到学员信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new Result(true, "success", CollectionUtils.newObjectMap("studentId", student.getStudentId(), "name", student.getName(), "status", | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<StuStudent> getStudentByclassId(String classId) { | 
|---|
|  |  |  | QStuStudent qClassStudent=QStuStudent.stuStudent; | 
|---|
|  |  |  | return new ArrayList<>(this.getQueryFactory() | 
|---|
|  |  |  | .select(qClassStudent | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .from(qClassStudent) | 
|---|
|  |  |  | .where(qClassStudent.classId.eq(classId)) | 
|---|
|  |  |  | .fetch()); | 
|---|
|  |  |  | QStuStudent qClassStudent=QStuStudent.stuStudent; | 
|---|
|  |  |  | return new ArrayList<>(this.getQueryFactory() | 
|---|
|  |  |  | .select(qClassStudent | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .from(qClassStudent) | 
|---|
|  |  |  | .where(qClassStudent.classId.eq(classId)) | 
|---|
|  |  |  | .fetch()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Result studentProgress(String classId, String studentId) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StuStudent student = read(StuStudent.class, studentId); | 
|---|
|  |  |  | if(student == null) { | 
|---|
|  |  |  | return new Result(false, "未查询到学员信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | StuStudent student = read(StuStudent.class, studentId); | 
|---|
|  |  |  | if(student == null) { | 
|---|
|  |  |  | return new Result(false, "未查询到学员信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String userId = student.getUserId(); | 
|---|
|  |  |  | String userId = student.getUserId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User u = this.read(User.class, userId); | 
|---|
|  |  |  | if(u == null) { | 
|---|
|  |  |  | return new Result(false, "未查询到用户信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | User u = this.read(User.class, userId); | 
|---|
|  |  |  | if(u == null) { | 
|---|
|  |  |  | return new Result(false, "未查询到用户信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; | 
|---|
|  |  |  | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //班级进度 | 
|---|
|  |  |  | SubjectProgressTreeV objSubjectProgressTreeV = this.getQueryFactory().selectFrom(qSubjectProgressTreeV).where(qSubjectProgressTreeV.id.nodeId.eq(classId).and(qSubjectProgressTreeV.id.userId.eq(userId))).fetchOne(); | 
|---|
|  |  |  | //班级进度 | 
|---|
|  |  |  | SubjectProgressTreeV objSubjectProgressTreeV = this.getQueryFactory().selectFrom(qSubjectProgressTreeV).where(qSubjectProgressTreeV.id.nodeId.eq(classId).and(qSubjectProgressTreeV.id.userId.eq(userId))).fetchOne(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(objSubjectProgressTreeV != null) { | 
|---|
|  |  |  | //学员总数 | 
|---|
|  |  |  | long studentCount = this.getQueryFactory().selectFrom(qSubjectProgressTreeV).where(qSubjectProgressTreeV.id.nodeId.eq(classId)).fetchCount(); | 
|---|
|  |  |  | if(objSubjectProgressTreeV != null) { | 
|---|
|  |  |  | //学员总数 | 
|---|
|  |  |  | long studentCount = this.getQueryFactory().selectFrom(qSubjectProgressTreeV).where(qSubjectProgressTreeV.id.nodeId.eq(classId)).fetchCount(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 当前学员排行 | 
|---|
|  |  |  | long studentIndex = this | 
|---|
|  |  |  | .getQueryFactory().selectFrom(qSubjectProgressTreeV).where(qSubjectProgressTreeV.id.nodeId | 
|---|
|  |  |  | .eq(classId).and(qSubjectProgressTreeV.percent.gt(objSubjectProgressTreeV.getPercent()) | 
|---|
|  |  |  | .or(qSubjectProgressTreeV.percent.eq(objSubjectProgressTreeV.getPercent())))) | 
|---|
|  |  |  | .fetchCount(); | 
|---|
|  |  |  | // 当前学员排行 | 
|---|
|  |  |  | long studentIndex = this | 
|---|
|  |  |  | .getQueryFactory().selectFrom(qSubjectProgressTreeV).where(qSubjectProgressTreeV.id.nodeId | 
|---|
|  |  |  | .eq(classId).and(qSubjectProgressTreeV.percent.gt(objSubjectProgressTreeV.getPercent()) | 
|---|
|  |  |  | .or(qSubjectProgressTreeV.percent.eq(objSubjectProgressTreeV.getPercent())))) | 
|---|
|  |  |  | .fetchCount(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //学员的课程 | 
|---|
|  |  |  | List<Map<String, Object>> lstSubject =  this.subjectService.myClsSubjectlist(classId, userId, new Pager(Integer.MAX_VALUE, 0)); | 
|---|
|  |  |  | //学员的课程 | 
|---|
|  |  |  | List<Map<String, Object>> lstSubject =  this.subjectService.myClsSubjectlist(classId, userId, new Pager(Integer.MAX_VALUE, 0)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new Result(true, "success", CollectionUtils.newObjectMap("studentId", student.getStudentId(), "name", student.getName(), "imgPath", u.getImgPath(), | 
|---|
|  |  |  | "status", student.getStatus(), "studentNumber", student.getStudentNo(), "sex", student.getSex(), "mobilePhone", | 
|---|
|  |  |  | student.getMobilePhone(), "subjectList", lstSubject, "studentCount", studentCount, "studentIndex", studentIndex, "studyDuration", objSubjectProgressTreeV.getProgressValue())); | 
|---|
|  |  |  | }{ | 
|---|
|  |  |  | return new Result(true, "success", CollectionUtils.newObjectMap("studentId", student.getStudentId(), "name", student.getName(), "imgPath", u.getImgPath(), | 
|---|
|  |  |  | "status", student.getStatus(), "studentNumber", student.getStudentNo(), "sex", student.getSex(), "mobilePhone", | 
|---|
|  |  |  | student.getMobilePhone(), "subjectList", new ArrayList<Map<String, Object>>(), "studentCount", 0, "studentIndex", 1, "studyDuration", 0)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new Result(true, "success", CollectionUtils.newObjectMap("studentId", student.getStudentId(), "name", student.getName(), "imgPath", u.getImgPath(), | 
|---|
|  |  |  | "status", student.getStatus(), "studentNumber", student.getStudentNo(), "sex", student.getSex(), "mobilePhone", | 
|---|
|  |  |  | student.getMobilePhone(), "subjectList", lstSubject, "studentCount", studentCount, "studentIndex", studentIndex, "studyDuration", objSubjectProgressTreeV.getProgressValue())); | 
|---|
|  |  |  | }{ | 
|---|
|  |  |  | return new Result(true, "success", CollectionUtils.newObjectMap("studentId", student.getStudentId(), "name", student.getName(), "imgPath", u.getImgPath(), | 
|---|
|  |  |  | "status", student.getStatus(), "studentNumber", student.getStudentNo(), "sex", student.getSex(), "mobilePhone", | 
|---|
|  |  |  | student.getMobilePhone(), "subjectList", new ArrayList<Map<String, Object>>(), "studentCount", 0, "studentIndex", 1, "studyDuration", 0)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|