|  | @@ -5,16 +5,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 |  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  |  import com.google.common.collect.Lists;
 |  |  import com.google.common.collect.Lists;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 | 
											
												
													
														|  |  import com.ym.mec.education.base.PageResponse;
 |  |  import com.ym.mec.education.base.PageResponse;
 | 
											
												
													
														|  | -import com.ym.mec.education.entity.ClassGroup;
 |  | 
 | 
											
												
													
														|  | -import com.ym.mec.education.entity.CourseSchedule;
 |  | 
 | 
											
												
													
														|  | -import com.ym.mec.education.entity.StudentAttendance;
 |  | 
 | 
											
												
													
														|  | -import com.ym.mec.education.entity.SysUser;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.education.entity.*;
 | 
											
												
													
														|  |  import com.ym.mec.education.enums.StudentAttendanceStatusEnum;
 |  |  import com.ym.mec.education.enums.StudentAttendanceStatusEnum;
 | 
											
												
													
														|  |  import com.ym.mec.education.mapper.StudentAttendanceMapper;
 |  |  import com.ym.mec.education.mapper.StudentAttendanceMapper;
 | 
											
												
													
														|  |  import com.ym.mec.education.req.ClassGroupReq;
 |  |  import com.ym.mec.education.req.ClassGroupReq;
 | 
											
												
													
														|  |  import com.ym.mec.education.req.CourseScheduleReq;
 |  |  import com.ym.mec.education.req.CourseScheduleReq;
 | 
											
												
													
														|  |  import com.ym.mec.education.resp.StudentAttendanceResp;
 |  |  import com.ym.mec.education.resp.StudentAttendanceResp;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.education.resp.StudentAttendanceStatisticsResp;
 | 
											
												
													
														|  |  import com.ym.mec.education.service.*;
 |  |  import com.ym.mec.education.service.*;
 | 
											
												
													
														|  |  import com.ym.mec.education.utils.DateUtil;
 |  |  import com.ym.mec.education.utils.DateUtil;
 | 
											
												
													
														|  |  import org.apache.commons.lang3.StringUtils;
 |  |  import org.apache.commons.lang3.StringUtils;
 | 
											
										
											
												
													
														|  | @@ -44,9 +43,14 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
 | 
											
												
													
														|  |      private ISubjectService subjectService;
 |  |      private ISubjectService subjectService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private ISysUserService userService;
 |  |      private ISysUserService userService;
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private IClassGroupStudentMapperService classGroupStudentMapperService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public PageResponse getPage(ClassGroupReq classGroupReq) {
 |  |      public PageResponse getPage(ClassGroupReq classGroupReq) {
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(classGroupReq.getGroupId())){
 | 
											
												
													
														|  | 
 |  | +            return PageResponse.errorParam();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          Page<StudentAttendance> pageParam = new Page(classGroupReq.getPageNo(), classGroupReq.getPageSize());
 |  |          Page<StudentAttendance> pageParam = new Page(classGroupReq.getPageNo(), classGroupReq.getPageSize());
 | 
											
												
													
														|  |          QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
 |  |          QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  |          queryWrapper.lambda().eq(Objects.nonNull(classGroupReq.getGroupId()),
 |  |          queryWrapper.lambda().eq(Objects.nonNull(classGroupReq.getGroupId()),
 | 
											
										
											
												
													
														|  | @@ -94,6 +98,9 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public PageResponse getPageByCourse(CourseScheduleReq courseScheduleReq) {
 |  |      public PageResponse getPageByCourse(CourseScheduleReq courseScheduleReq) {
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
 | 
											
												
													
														|  | 
 |  | +            return PageResponse.errorParam();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          Page<StudentAttendanceResp> pageResult = new Page<>();
 |  |          Page<StudentAttendanceResp> pageResult = new Page<>();
 | 
											
												
													
														|  |          Page<StudentAttendance> studentAttendancePage = new Page<>(courseScheduleReq.getPageNo(), courseScheduleReq.getPageSize());
 |  |          Page<StudentAttendance> studentAttendancePage = new Page<>(courseScheduleReq.getPageNo(), courseScheduleReq.getPageSize());
 | 
											
												
													
														|  |          QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
 |  |          QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
 | 
											
										
											
												
													
														|  | @@ -118,4 +125,82 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return PageResponse.success(pageResult);
 |  |          return PageResponse.success(pageResult);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public PageResponse statisticsList(CourseScheduleReq courseScheduleReq) {
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
 | 
											
												
													
														|  | 
 |  | +            PageResponse.errorParam();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        Page<ClassGroupStudentMapper> classGroupStudentMapperPage = new Page<>(courseScheduleReq.getPageNo(), courseScheduleReq.getPageSize());
 | 
											
												
													
														|  | 
 |  | +        Page<StudentAttendanceStatisticsResp> pageResult = new Page();
 | 
											
												
													
														|  | 
 |  | +        CourseSchedule courseSchedule = courseScheduleService.getById(courseScheduleReq.getCourseScheduleId());
 | 
											
												
													
														|  | 
 |  | +        if (Objects.nonNull(courseSchedule)) {
 | 
											
												
													
														|  | 
 |  | +            ClassGroup classGroup = groupService.getById(courseSchedule.getClassGroupId());
 | 
											
												
													
														|  | 
 |  | +            if (Objects.nonNull(classGroup)) {
 | 
											
												
													
														|  | 
 |  | +                List<String> subjectNameList = subjectService.getSubjectNameList(classGroup.getSubjectIdList());
 | 
											
												
													
														|  | 
 |  | +                QueryWrapper<ClassGroupStudentMapper> classGroupStudentMapperQueryWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  | 
 |  | +                classGroupStudentMapperQueryWrapper.lambda().eq(true, ClassGroupStudentMapper::getClassGroupId, classGroup.getId())
 | 
											
												
													
														|  | 
 |  | +                        .in(true, ClassGroupStudentMapper::getStatus,
 | 
											
												
													
														|  | 
 |  | +                                ClassGroupStudentStatusEnum.NORMAL.getCode(), ClassGroupStudentStatusEnum.LEAVE.getCode());
 | 
											
												
													
														|  | 
 |  | +                IPage<ClassGroupStudentMapper> studentMapperPage = classGroupStudentMapperService.page(classGroupStudentMapperPage, classGroupStudentMapperQueryWrapper);
 | 
											
												
													
														|  | 
 |  | +                if (!CollectionUtils.isEmpty(studentMapperPage.getRecords())) {
 | 
											
												
													
														|  | 
 |  | +                    List<StudentAttendanceStatisticsResp> studentAttendanceStatisticsRespList = Lists.newArrayList();
 | 
											
												
													
														|  | 
 |  | +                    BeanUtils.copyProperties(studentMapperPage, pageResult);
 | 
											
												
													
														|  | 
 |  | +                    studentMapperPage.getRecords().forEach(item -> {
 | 
											
												
													
														|  | 
 |  | +                        StudentAttendanceStatisticsResp resp = new StudentAttendanceStatisticsResp();
 | 
											
												
													
														|  | 
 |  | +                        SysUser user = userService.getById(item.getUserId());
 | 
											
												
													
														|  | 
 |  | +                        if (Objects.nonNull(user) && StringUtils.isNotBlank(user.getRealName())) {
 | 
											
												
													
														|  | 
 |  | +                            resp.setStudentName(user.getRealName());
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                        resp.setSubjectName(subjectNameList);
 | 
											
												
													
														|  | 
 |  | +                        //TODO 暂时缺少是否连续旷课
 | 
											
												
													
														|  | 
 |  | +                        //到课天数
 | 
											
												
													
														|  | 
 |  | +                        QueryWrapper<StudentAttendance> normalWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  | 
 |  | +                        normalWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getUserId, item.getUserId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.NORMAL.getCode());
 | 
											
												
													
														|  | 
 |  | +                        int normalDay = count(normalWrapper);
 | 
											
												
													
														|  | 
 |  | +                        //旷课天数
 | 
											
												
													
														|  | 
 |  | +                        QueryWrapper<StudentAttendance> truantWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  | 
 |  | +                        truantWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getUserId, item.getUserId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.TRUANT.getCode());
 | 
											
												
													
														|  | 
 |  | +                        int truantDay = count(truantWrapper);
 | 
											
												
													
														|  | 
 |  | +                        //请假天数
 | 
											
												
													
														|  | 
 |  | +                        QueryWrapper<StudentAttendance> leaveWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  | 
 |  | +                        leaveWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getUserId, item.getUserId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.LEAVE.getCode());
 | 
											
												
													
														|  | 
 |  | +                        int leaveDay = count(leaveWrapper);
 | 
											
												
													
														|  | 
 |  | +                        resp.setNormalDay(normalDay);
 | 
											
												
													
														|  | 
 |  | +                        resp.setTruantDay(truantDay);
 | 
											
												
													
														|  | 
 |  | +                        resp.setLeaveDay(leaveDay);
 | 
											
												
													
														|  | 
 |  | +                        //每个学生的考勤明细
 | 
											
												
													
														|  | 
 |  | +                        QueryWrapper<StudentAttendance> studentAttendanceQueryWrapper = new QueryWrapper<>();
 | 
											
												
													
														|  | 
 |  | +                        studentAttendanceQueryWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
 | 
											
												
													
														|  | 
 |  | +                                .eq(true, StudentAttendance::getUserId, item.getUserId());
 | 
											
												
													
														|  | 
 |  | +                        List<StudentAttendance> studentAttendanceList = list(studentAttendanceQueryWrapper);
 | 
											
												
													
														|  | 
 |  | +                        List<StudentAttendanceResp> studentAttendanceRespList = Lists.newArrayList();
 | 
											
												
													
														|  | 
 |  | +                        if (!CollectionUtils.isEmpty(studentAttendanceList)) {
 | 
											
												
													
														|  | 
 |  | +                            studentAttendanceList.forEach(studentAttendance -> {
 | 
											
												
													
														|  | 
 |  | +                                StudentAttendanceResp studentAttendanceResp = new StudentAttendanceResp();
 | 
											
												
													
														|  | 
 |  | +                                if (Objects.nonNull(studentAttendance.getCreateTime())) {
 | 
											
												
													
														|  | 
 |  | +                                    studentAttendanceResp.setClassDate(DateUtil.date2String(studentAttendance.getCreateTime(),
 | 
											
												
													
														|  | 
 |  | +                                            DateUtil.DATE_FORMAT)).setClassWeek(DateUtil.date2Week(studentAttendance.getCreateTime()));
 | 
											
												
													
														|  | 
 |  | +                                }
 | 
											
												
													
														|  | 
 |  | +                                if (StringUtils.isNotBlank(studentAttendance.getStatus())) {
 | 
											
												
													
														|  | 
 |  | +                                    studentAttendanceResp.setStatus(StudentAttendanceStatusEnum.getMsgByCode(studentAttendance.getStatus()));
 | 
											
												
													
														|  | 
 |  | +                                }
 | 
											
												
													
														|  | 
 |  | +                                studentAttendanceRespList.add(studentAttendanceResp);
 | 
											
												
													
														|  | 
 |  | +                            });
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                        resp.setList(studentAttendanceRespList);
 | 
											
												
													
														|  | 
 |  | +                        studentAttendanceStatisticsRespList.add(resp);
 | 
											
												
													
														|  | 
 |  | +                    });
 | 
											
												
													
														|  | 
 |  | +                    pageResult.setRecords(studentAttendanceStatisticsRespList);
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return PageResponse.success(pageResult);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  }
 |  |  }
 |