Browse Source

点名详情-考勤列表添加参数课程计划id

肖玮 5 years ago
parent
commit
f172311a89

+ 7 - 0
mec-education/src/main/java/com/ym/mec/education/service/ICourseScheduleService.java

@@ -37,4 +37,11 @@ public interface ICourseScheduleService extends IService<CourseSchedule> {
      * @return
      */
     BaseResponse getStatisticsInfo(ClassGroupReq classGroupReq);
+
+    /**
+     * 根据班级id获取最新你的课程计划
+     * @param classGroupId
+     * @return
+     */
+    CourseSchedule getLastCourseSchedule(Integer classGroupId);
 }

+ 1 - 1
mec-education/src/main/java/com/ym/mec/education/service/IStudentAttendanceService.java

@@ -18,7 +18,7 @@ public interface IStudentAttendanceService extends IService<StudentAttendance> {
     PageResponse getPage(ClassGroupReq classGroupReq);
 
     /**
-     * 点名详情-学生考勤列表
+     * 点名详情-最新学生考勤列表
      *
      * @param classGroupReq
      * @return

+ 1 - 0
mec-education/src/main/java/com/ym/mec/education/service/impl/CourseScheduleServiceImpl.java

@@ -171,6 +171,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
      * @param classGroupId
      * @return
      */
+    @Override
     public CourseSchedule getLastCourseSchedule(Integer classGroupId) {
         QueryWrapper<CourseSchedule> courseScheduleQueryWrapper = new QueryWrapper<>();
         courseScheduleQueryWrapper.lambda().eq(true, CourseSchedule::getClassGroupId, classGroupId)

+ 24 - 19
mec-education/src/main/java/com/ym/mec/education/service/impl/StudentAttendanceServiceImpl.java

@@ -20,6 +20,7 @@ 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;
 
@@ -102,27 +103,31 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
         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>(classGroupReq.getPageNo(), classGroupReq.getPageSize());
-        QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(true, StudentAttendance::getClassGroupId, classGroupReq.getGroupId());
-        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);
     }