|
@@ -5,22 +5,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.ym.mec.education.base.BaseResponse;
|
|
|
import com.ym.mec.education.base.PageResponse;
|
|
|
-import com.ym.mec.education.entity.ClassGroup;
|
|
|
-import com.ym.mec.education.entity.ClassGroupTeacherMapper;
|
|
|
-import com.ym.mec.education.entity.CourseSchedule;
|
|
|
-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.TeachTypeEnum;
|
|
|
import com.ym.mec.education.mapper.CourseScheduleMapper;
|
|
|
import com.ym.mec.education.req.ClassGroupReq;
|
|
|
+import com.ym.mec.education.req.CourseScheduleReq;
|
|
|
import com.ym.mec.education.resp.CourseScheduleResp;
|
|
|
import com.ym.mec.education.service.*;
|
|
|
import com.ym.mec.education.utils.DateUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -41,6 +44,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
|
|
|
private ISysUserService sysUserService;
|
|
|
@Autowired
|
|
|
private ISubjectService subjectService;
|
|
|
+ @Autowired
|
|
|
+ private IStudentAttendanceService studentAttendanceService;
|
|
|
|
|
|
@Override
|
|
|
public PageResponse getPage(ClassGroupReq classGroupReq) {
|
|
@@ -54,10 +59,20 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
|
|
|
ClassGroup classGroup = groupService.getById(classGroupReq.getGroupId());
|
|
|
courseScheduleIPage.getRecords().forEach(item -> {
|
|
|
CourseScheduleResp courseScheduleResp = new CourseScheduleResp();
|
|
|
- courseScheduleResp.setClassDate(DateUtil.date2String(item.getClassDate())
|
|
|
- + " " + DateUtil.date2Week(item.getClassDate()))
|
|
|
- .setClassTime(DateUtil.time2String(item.getStartClassTime()) + "-" + DateUtil.time2String(item.getEndClassTime()))
|
|
|
- .setSubjectName(subjectService.getSubjectNameList(classGroup.getSubjectIdList()));
|
|
|
+ if (Objects.nonNull(item.getClassDate())) {
|
|
|
+ courseScheduleResp.setClassDate(DateUtil.date2String(item.getClassDate())
|
|
|
+ + " " + DateUtil.date2Week(item.getClassDate()));
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(item.getStartClassTime()) && Objects.nonNull(item.getEndClassTime())) {
|
|
|
+ courseScheduleResp.setClassTime(DateUtil.time2String(item.getStartClassTime()) + "-" +
|
|
|
+ DateUtil.time2String(item.getEndClassTime()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(classGroup.getSubjectIdList())) {
|
|
|
+ List<String> subjectNameList = subjectService.getSubjectNameList(classGroup.getSubjectIdList());
|
|
|
+ if (!CollectionUtils.isEmpty(subjectNameList)) {
|
|
|
+ courseScheduleResp.setSubjectName(subjectNameList);
|
|
|
+ }
|
|
|
+ }
|
|
|
QueryWrapper<ClassGroupTeacherMapper> classGroupTeacherMapperQueryWrapper = new QueryWrapper<>();
|
|
|
classGroupTeacherMapperQueryWrapper.lambda().eq(true, ClassGroupTeacherMapper::getClassGroupId, item.getClassGroupId())
|
|
|
.eq(true, ClassGroupTeacherMapper::getTeacherRole, TeachTypeEnum.BISHOP.getCode());
|
|
@@ -73,4 +88,50 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
|
|
|
pageResult.setRecords(courseScheduleRespList);
|
|
|
return PageResponse.success(pageResult);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResponse<CourseScheduleResp> getInfo(CourseScheduleReq courseScheduleReq) {
|
|
|
+ CourseSchedule courseSchedule = getById(courseScheduleReq.getCourseScheduleId());
|
|
|
+ CourseScheduleResp courseScheduleResp = new CourseScheduleResp();
|
|
|
+ if (Objects.nonNull(courseSchedule)) {
|
|
|
+ if (Objects.nonNull(courseSchedule.getClassDate())) {
|
|
|
+ courseScheduleResp.setClassDate(DateUtil.date2String(courseSchedule.getClassDate()) + "(" +
|
|
|
+ DateUtil.date2Week(courseSchedule.getClassDate()) + ")");
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(courseSchedule.getStartClassTime()) &&
|
|
|
+ Objects.nonNull(courseSchedule.getEndClassTime())) {
|
|
|
+ courseScheduleResp.setClassTime(DateUtil.time2String(courseSchedule.getStartClassTime()) + "-" +
|
|
|
+ DateUtil.time2String(courseSchedule.getEndClassTime()));
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(courseSchedule.getTeacherId())) {
|
|
|
+ Optional.of(sysUserService.getById(courseSchedule.getTeacherId())).
|
|
|
+ ifPresent(sysUser -> courseScheduleResp.setTeacher(sysUser.getRealName()));
|
|
|
+ }
|
|
|
+ QueryWrapper<StudentAttendance> studentAttendanceQueryWrapper = new QueryWrapper<>();
|
|
|
+ studentAttendanceQueryWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
|
|
|
+ .orderByDesc(true, StudentAttendance::getCreateTime);
|
|
|
+ List<StudentAttendance> studentAttendanceList = studentAttendanceService.list(studentAttendanceQueryWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(studentAttendanceList)) {
|
|
|
+ studentAttendanceList.stream().findFirst().ifPresent(studentAttendance ->
|
|
|
+ courseScheduleResp.setLastCommitDate(studentAttendance.getCreateTime()));
|
|
|
+ }
|
|
|
+ QueryWrapper<StudentAttendance> leaveWrapper = new QueryWrapper<>();
|
|
|
+ QueryWrapper<StudentAttendance> normalWrapper = new QueryWrapper<>();
|
|
|
+ //总人数
|
|
|
+ Integer totalCount = count();
|
|
|
+ //请假
|
|
|
+ leaveWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
|
|
|
+ .eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.LEAVE.getCode());
|
|
|
+ Integer leaveCount = studentAttendanceService.count(leaveWrapper);
|
|
|
+ //正常
|
|
|
+ normalWrapper.lambda().eq(true, StudentAttendance::getCourseScheduleId, courseScheduleReq.getCourseScheduleId())
|
|
|
+ .eq(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.NORMAL.getCode());
|
|
|
+ Integer normalCount = studentAttendanceService.count(normalWrapper);
|
|
|
+ courseScheduleResp.setLeaveNum(leaveCount);
|
|
|
+ if (totalCount != 0) {
|
|
|
+ courseScheduleResp.setAttendanceRate(normalCount + "/" + totalCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return BaseResponse.success(courseScheduleResp);
|
|
|
+ }
|
|
|
}
|