|
@@ -9,18 +9,19 @@ import com.ym.mec.education.base.PageResponse;
|
|
import com.ym.mec.education.entity.ClassGroup;
|
|
import com.ym.mec.education.entity.ClassGroup;
|
|
import com.ym.mec.education.entity.CourseSchedule;
|
|
import com.ym.mec.education.entity.CourseSchedule;
|
|
import com.ym.mec.education.entity.StudentAttendance;
|
|
import com.ym.mec.education.entity.StudentAttendance;
|
|
|
|
+import com.ym.mec.education.entity.SysUser;
|
|
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.resp.StudentAttendanceResq;
|
|
|
|
-import com.ym.mec.education.service.IClassGroupService;
|
|
|
|
-import com.ym.mec.education.service.ICourseScheduleService;
|
|
|
|
-import com.ym.mec.education.service.IStudentAttendanceService;
|
|
|
|
-import com.ym.mec.education.service.ISubjectService;
|
|
|
|
|
|
+import com.ym.mec.education.req.CourseScheduleReq;
|
|
|
|
+import com.ym.mec.education.resp.StudentAttendanceResp;
|
|
|
|
+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.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
@@ -41,6 +42,8 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
|
|
private IClassGroupService groupService;
|
|
private IClassGroupService groupService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISubjectService subjectService;
|
|
private ISubjectService subjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserService userService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageResponse getPage(ClassGroupReq classGroupReq) {
|
|
public PageResponse getPage(ClassGroupReq classGroupReq) {
|
|
@@ -49,9 +52,9 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
|
|
queryWrapper.lambda().eq(Objects.nonNull(classGroupReq.getGroupId()),
|
|
queryWrapper.lambda().eq(Objects.nonNull(classGroupReq.getGroupId()),
|
|
StudentAttendance::getClassGroupId, classGroupReq.getGroupId());
|
|
StudentAttendance::getClassGroupId, classGroupReq.getGroupId());
|
|
IPage<StudentAttendance> page = page(pageParam, queryWrapper);
|
|
IPage<StudentAttendance> page = page(pageParam, queryWrapper);
|
|
- IPage<StudentAttendanceResq> pageResult = new Page<>();
|
|
|
|
|
|
+ IPage<StudentAttendanceResp> pageResult = new Page<>();
|
|
BeanUtils.copyProperties(page, pageResult);
|
|
BeanUtils.copyProperties(page, pageResult);
|
|
- List<StudentAttendanceResq> list = Lists.newArrayList();
|
|
|
|
|
|
+ List<StudentAttendanceResp> list = Lists.newArrayList();
|
|
QueryWrapper<StudentAttendance> leaveWrapper = new QueryWrapper<>();
|
|
QueryWrapper<StudentAttendance> leaveWrapper = new QueryWrapper<>();
|
|
QueryWrapper<StudentAttendance> normalWrapper = new QueryWrapper<>();
|
|
QueryWrapper<StudentAttendance> normalWrapper = new QueryWrapper<>();
|
|
//总人数
|
|
//总人数
|
|
@@ -65,24 +68,54 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
|
|
.eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.NORMAL.getCode());
|
|
.eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.NORMAL.getCode());
|
|
Integer normalCount = count(normalWrapper);
|
|
Integer normalCount = count(normalWrapper);
|
|
page.getRecords().forEach(item -> {
|
|
page.getRecords().forEach(item -> {
|
|
- StudentAttendanceResq studentAttendanceResq = new StudentAttendanceResq();
|
|
|
|
- studentAttendanceResq.setLeaveNum(leaveCount).setAttendanceRate(normalCount + "/" + totalCount);
|
|
|
|
|
|
+ StudentAttendanceResp studentAttendanceResp = new StudentAttendanceResp();
|
|
|
|
+ studentAttendanceResp.setLeaveNum(leaveCount);
|
|
|
|
+ if (totalCount != 0) {
|
|
|
|
+ studentAttendanceResp.setAttendanceRate(normalCount + "/" + totalCount);
|
|
|
|
+ }
|
|
QueryWrapper<CourseSchedule> courseScheduleQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CourseSchedule> courseScheduleQueryWrapper = new QueryWrapper<>();
|
|
courseScheduleQueryWrapper.lambda().eq(true, CourseSchedule::getClassGroupId, classGroupReq.getGroupId())
|
|
courseScheduleQueryWrapper.lambda().eq(true, CourseSchedule::getClassGroupId, classGroupReq.getGroupId())
|
|
.eq(true, CourseSchedule::getTeacherId, item.getTeacherId());
|
|
.eq(true, CourseSchedule::getTeacherId, item.getTeacherId());
|
|
CourseSchedule courseSchedule = courseScheduleService.getOne(courseScheduleQueryWrapper);
|
|
CourseSchedule courseSchedule = courseScheduleService.getOne(courseScheduleQueryWrapper);
|
|
if (Objects.nonNull(courseSchedule)) {
|
|
if (Objects.nonNull(courseSchedule)) {
|
|
- studentAttendanceResq.setClassDate(DateUtil.date2String(courseSchedule.getClassDate())
|
|
|
|
|
|
+ studentAttendanceResp.setClassDate(DateUtil.date2String(courseSchedule.getClassDate())
|
|
+ " " + DateUtil.date2Week(courseSchedule.getClassDate()))
|
|
+ " " + DateUtil.date2Week(courseSchedule.getClassDate()))
|
|
.setClassTime(courseSchedule.getStartClassTime() + "-" + courseSchedule.getEndClassTime());
|
|
.setClassTime(courseSchedule.getStartClassTime() + "-" + courseSchedule.getEndClassTime());
|
|
}
|
|
}
|
|
ClassGroup classGroup = groupService.getById(classGroupReq.getGroupId());
|
|
ClassGroup classGroup = groupService.getById(classGroupReq.getGroupId());
|
|
if (Objects.nonNull(classGroup)) {
|
|
if (Objects.nonNull(classGroup)) {
|
|
- studentAttendanceResq.setSubjectName(subjectService.getSubjectNameList(classGroup.getSubjectIdList()));
|
|
|
|
- list.add(studentAttendanceResq);
|
|
|
|
|
|
+ studentAttendanceResp.setSubjectName(subjectService.getSubjectNameList(classGroup.getSubjectIdList()));
|
|
|
|
+ list.add(studentAttendanceResp);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
pageResult.setRecords(list);
|
|
pageResult.setRecords(list);
|
|
return PageResponse.success(pageResult);
|
|
return PageResponse.success(pageResult);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PageResponse getPageByCourse(CourseScheduleReq courseScheduleReq) {
|
|
|
|
+ Page<StudentAttendanceResp> pageResult = new Page<>();
|
|
|
|
+ Page<StudentAttendance> studentAttendancePage = new Page<>(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 (StringUtils.isNotBlank(item.getStatus())) {
|
|
|
|
+ studentAttendanceResp.setStatus(StudentAttendanceStatusEnum.getMsgByCode(item.getStatus()));
|
|
|
|
+ }
|
|
|
|
+ list.add(studentAttendanceResp);
|
|
|
|
+ });
|
|
|
|
+ pageResult.setRecords(list);
|
|
|
|
+ }
|
|
|
|
+ return PageResponse.success(pageResult);
|
|
|
|
+ }
|
|
}
|
|
}
|