|
@@ -11,7 +11,6 @@ import com.ym.mec.education.entity.*;
|
|
|
import com.ym.mec.education.enums.StudentAttendanceStatusEnum;
|
|
|
import com.ym.mec.education.mapper.StudentAttendanceMapper;
|
|
|
import com.ym.mec.education.req.ClassGroupReq;
|
|
|
-import com.ym.mec.education.req.CourseScheduleReq;
|
|
|
import com.ym.mec.education.resp.StudentAttendanceResp;
|
|
|
import com.ym.mec.education.resp.StudentAttendanceStatisticsResp;
|
|
|
import com.ym.mec.education.service.*;
|
|
@@ -24,7 +23,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -101,117 +99,118 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageResponse getPageByCourse(CourseScheduleReq courseScheduleReq) {
|
|
|
- if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
|
|
|
+ public PageResponse getPageRollCall(ClassGroupReq classGroupReq) {
|
|
|
+ if (Objects.isNull(classGroupReq.getGroupId())) {
|
|
|
return PageResponse.errorParam();
|
|
|
}
|
|
|
+ CourseSchedule courseSchedule = courseScheduleService.getLastCourseSchedule(classGroupReq.getGroupId());
|
|
|
Page<StudentAttendanceResp> pageResult = new Page<>();
|
|
|
- Page<StudentAttendance> studentAttendancePage = new Page<StudentAttendance>(courseScheduleReq.getPageNo(), courseScheduleReq.getPageSize());
|
|
|
- QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId());
|
|
|
- IPage<StudentAttendance> page = page(studentAttendancePage, queryWrapper);
|
|
|
- if (!CollectionUtils.isEmpty(page.getRecords())) {
|
|
|
- List<StudentAttendanceResp> list = Lists.newArrayList();
|
|
|
- page.getRecords().forEach(item -> {
|
|
|
- StudentAttendanceResp studentAttendanceResp = new StudentAttendanceResp();
|
|
|
- if (Objects.nonNull(item.getUserId())) {
|
|
|
- SysUser user = userService.getById(item.getUserId());
|
|
|
- if (Objects.nonNull(user) && StringUtils.isNotBlank(user.getRealName())) {
|
|
|
- studentAttendanceResp.setStudentName(user.getRealName());
|
|
|
+ if (Objects.nonNull(courseSchedule)) {
|
|
|
+ Page<StudentAttendance> studentAttendancePage = new Page<StudentAttendance>(classGroupReq.getPageNo(), classGroupReq.getPageSize());
|
|
|
+ QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(true, StudentAttendance::getClassGroupId, classGroupReq.getGroupId())
|
|
|
+ .eq(true, StudentAttendance::getCourseScheduleId, courseSchedule.getId());
|
|
|
+ IPage<StudentAttendance> page = page(studentAttendancePage, queryWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(page.getRecords())) {
|
|
|
+ List<StudentAttendanceResp> list = Lists.newArrayList();
|
|
|
+ page.getRecords().forEach(item -> {
|
|
|
+ StudentAttendanceResp studentAttendanceResp = new StudentAttendanceResp();
|
|
|
+ if (Objects.nonNull(item.getUserId())) {
|
|
|
+ SysUser user = userService.getById(item.getUserId());
|
|
|
+ if (Objects.nonNull(user) && StringUtils.isNotBlank(user.getRealName())) {
|
|
|
+ studentAttendanceResp.setStudentName(user.getRealName());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(item.getStatus())) {
|
|
|
- studentAttendanceResp.setStatus(StudentAttendanceStatusEnum.getMsgByCode(item.getStatus()));
|
|
|
- }
|
|
|
- list.add(studentAttendanceResp);
|
|
|
- });
|
|
|
- pageResult.setRecords(list);
|
|
|
+ if (StringUtils.isNotBlank(item.getStatus())) {
|
|
|
+ studentAttendanceResp.setStatus(StudentAttendanceStatusEnum.getMsgByCode(item.getStatus()));
|
|
|
+ }
|
|
|
+ list.add(studentAttendanceResp);
|
|
|
+ });
|
|
|
+ pageResult.setRecords(list);
|
|
|
+ }
|
|
|
}
|
|
|
return PageResponse.success(pageResult);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageResponse statisticsList(CourseScheduleReq courseScheduleReq) {
|
|
|
- if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
|
|
|
+ public PageResponse statisticsList(ClassGroupReq classGroupReq) {
|
|
|
+ if (Objects.isNull(classGroupReq.getGroupId())) {
|
|
|
PageResponse.errorParam();
|
|
|
}
|
|
|
- Page<ClassGroupStudentMapper> classGroupStudentMapperPage = new Page<ClassGroupStudentMapper>(courseScheduleReq.getPageNo(), courseScheduleReq.getPageSize());
|
|
|
+ Page<ClassGroupStudentMapper> classGroupStudentMapperPage = new Page<ClassGroupStudentMapper>(classGroupReq.getPageNo(), classGroupReq.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());
|
|
|
+ ClassGroup classGroup = groupService.getById(classGroupReq.getGroupId());
|
|
|
+ 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);
|
|
|
+ //是否连续旷课
|
|
|
+ QueryWrapper<MusicGroupStudentFee> musicGroupStudentFeeQueryWrapper = new QueryWrapper<MusicGroupStudentFee>();
|
|
|
+ musicGroupStudentFeeQueryWrapper.lambda().eq(true, MusicGroupStudentFee::getMusicGroupId, classGroup.getMusicGroupId())
|
|
|
+ .eq(true, MusicGroupStudentFee::getUserId, item.getUserId());
|
|
|
+ MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeService.getOne(musicGroupStudentFeeQueryWrapper);
|
|
|
+ if (Objects.nonNull(musicGroupStudentFee) && Objects.nonNull(musicGroupStudentFee.getContinuousAbsenteeismTimes())) {
|
|
|
+ if (musicGroupStudentFee.getContinuousAbsenteeismTimes() > 1) {
|
|
|
+ resp.setTruant(true);
|
|
|
}
|
|
|
- resp.setSubjectName(subjectNameList);
|
|
|
- //是否连续旷课
|
|
|
- QueryWrapper<MusicGroupStudentFee> musicGroupStudentFeeQueryWrapper = new QueryWrapper<MusicGroupStudentFee>();
|
|
|
- musicGroupStudentFeeQueryWrapper.lambda().eq(true, MusicGroupStudentFee::getMusicGroupId, classGroup.getMusicGroupId())
|
|
|
- .eq(true, MusicGroupStudentFee::getUserId, item.getUserId());
|
|
|
- MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeService.getOne(musicGroupStudentFeeQueryWrapper);
|
|
|
- if (Objects.nonNull(musicGroupStudentFee) && Objects.nonNull(musicGroupStudentFee.getContinuousAbsenteeismTimes())) {
|
|
|
- if (musicGroupStudentFee.getContinuousAbsenteeismTimes() > 1) {
|
|
|
- resp.setTruant(true);
|
|
|
+ }
|
|
|
+ //到课天数
|
|
|
+ QueryWrapper<StudentAttendance> normalWrapper = new QueryWrapper<>();
|
|
|
+ normalWrapper.lambda().eq(true, StudentAttendance::getClassGroupId, classGroupReq.getGroupId())
|
|
|
+ .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, classGroupReq.getGroupId())
|
|
|
+ .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, classGroupReq.getGroupId())
|
|
|
+ .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::getClassGroupId, classGroupReq.getGroupId())
|
|
|
+ .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()));
|
|
|
}
|
|
|
- }
|
|
|
- //到课天数
|
|
|
- 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);
|
|
|
- }
|
|
|
+ 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);
|