浏览代码

历史考勤统计 BaseResponse PageResponse添加入参错误方法

肖玮 5 年之前
父节点
当前提交
603e4cdcfe

+ 7 - 0
mec-education/src/main/java/com/ym/mec/education/base/BaseResponse.java

@@ -37,4 +37,11 @@ public class BaseResponse<T> extends Response implements Serializable {
         baseResponse.setDataInfo(dataInfo);
         return baseResponse;
     }
+
+    public static BaseResponse errorParam(){
+        BaseResponse baseResponse = new BaseResponse();
+        baseResponse.setReturnCode(ReturnCodeEnum.CODE_206.getCode());
+        baseResponse.setMessage(ReturnCodeEnum.CODE_206.getValue());
+        return baseResponse;
+    }
 }

+ 6 - 0
mec-education/src/main/java/com/ym/mec/education/base/PageResponse.java

@@ -175,4 +175,10 @@ public class PageResponse<T> extends Response implements Serializable {
         return pg.append(" }").toString();
     }
 
+    public static PageResponse errorParam(){
+        PageResponse pageResponse = new PageResponse();
+        pageResponse.setReturnCode(ReturnCodeEnum.CODE_206.getCode());
+        pageResponse.setMessage(ReturnCodeEnum.CODE_206.getValue());
+        return pageResponse;
+    }
 }

+ 0 - 8
mec-education/src/main/java/com/ym/mec/education/controller/ClassGroupController.java

@@ -1,7 +1,6 @@
 package com.ym.mec.education.controller;
 
 import com.ym.mec.education.base.BaseResponse;
-import com.ym.mec.education.enums.ReturnCodeEnum;
 import com.ym.mec.education.req.ClassGroupReq;
 import com.ym.mec.education.service.IClassGroupService;
 import io.swagger.annotations.Api;
@@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import java.util.Objects;
 
 /**
  * @program: mec
@@ -32,12 +30,6 @@ public class ClassGroupController {
     @PostMapping("/info")
     @ApiOperation("班级详情")
     public BaseResponse getInfo(@RequestBody ClassGroupReq classGroupReq) {
-        if (Objects.isNull(classGroupReq.getGroupId())) {
-            BaseResponse baseResponse = new BaseResponse();
-            baseResponse.setReturnCode(ReturnCodeEnum.CODE_206.getCode());
-            baseResponse.setMessage(ReturnCodeEnum.CODE_206.getValue());
-            return baseResponse;
-        }
         return classGroupService.getInfo(classGroupReq);
     }
 }

+ 6 - 6
mec-education/src/main/java/com/ym/mec/education/controller/CourseScheduleController.java

@@ -42,12 +42,12 @@ public class CourseScheduleController {
     @PostMapping("/info")
     @ApiOperation("课程计划详情")
     public BaseResponse<CourseScheduleResp> getInfo(@RequestBody CourseScheduleReq courseScheduleReq) {
-        if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
-            BaseResponse baseResponse = new BaseResponse();
-            baseResponse.setReturnCode(ReturnCodeEnum.CODE_206.getCode());
-            baseResponse.setMessage(ReturnCodeEnum.CODE_206.getValue());
-            return baseResponse;
-        }
         return courseScheduleService.getInfo(courseScheduleReq);
     }
+
+    @PostMapping("/statisticsInfo")
+    @ApiOperation("历史考勤统计-头信息")
+    public BaseResponse getStatisticsInfo(@RequestBody CourseScheduleReq courseScheduleReq) {
+        return courseScheduleService.getStatisticsInfo(courseScheduleReq);
+    }
 }

+ 6 - 0
mec-education/src/main/java/com/ym/mec/education/controller/StudentAttendanceController.java

@@ -40,4 +40,10 @@ public class StudentAttendanceController {
         return studentAttendanceService.getPageByCourse(courseScheduleReq);
     }
 
+    @PostMapping("/statisticsList")
+    @ApiOperation("根据课程计划查询考勤统计列表")
+    public PageResponse statisticsList(@RequestBody CourseScheduleReq courseScheduleReq) {
+        return studentAttendanceService.statisticsList(courseScheduleReq);
+    }
+
 }

+ 9 - 0
mec-education/src/main/java/com/ym/mec/education/resp/CourseScheduleResp.java

@@ -43,4 +43,13 @@ public class CourseScheduleResp implements Serializable {
 
     @ApiModelProperty(value = "请假人数")
     private Integer leaveNum;
+
+    @ApiModelProperty(value = "已上课时")
+    private String alreadyInClass;
+
+    @ApiModelProperty(value = "学生人数")
+    private Integer studentNum;
+
+    @ApiModelProperty(value = "退团人数")
+    private Integer leagueNum;
 }

+ 3 - 0
mec-education/src/main/java/com/ym/mec/education/resp/StudentAttendanceResp.java

@@ -38,4 +38,7 @@ public class StudentAttendanceResp implements Serializable {
 
     @ApiModelProperty(value = "考勤状态")
     private String status;
+
+    @ApiModelProperty(value = "上课星期")
+    private String classWeek;
 }

+ 41 - 0
mec-education/src/main/java/com/ym/mec/education/resp/StudentAttendanceStatisticsResp.java

@@ -0,0 +1,41 @@
+package com.ym.mec.education.resp;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @program: mec
+ * @description: 考勤统计出参
+ * @author: xw
+ * @create: 2019-09-28 23:29
+ */
+@Data
+@ApiModel(description = "考勤统计出参")
+@Accessors(chain = true)
+public class StudentAttendanceStatisticsResp implements Serializable {
+
+    @ApiModelProperty(value = "学生姓名")
+    private String studentName;
+
+    @ApiModelProperty(value = "是否连续旷课")
+    private boolean isTruant;
+
+    @ApiModelProperty(value = "声部名称")
+    private List<String> subjectName;
+
+    @ApiModelProperty(value = "到课天数")
+    private Integer normalDay;
+
+    @ApiModelProperty(value = "旷课天数")
+    private Integer truantDay;
+
+    @ApiModelProperty(value = "请假天数")
+    private Integer leaveDay;
+
+    @ApiModelProperty(value = "考勤明细列表")
+    private List<StudentAttendanceResp> list;
+}

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

@@ -30,4 +30,11 @@ public interface ICourseScheduleService extends IService<CourseSchedule> {
      * @return
      */
     BaseResponse getInfo(CourseScheduleReq courseScheduleReq);
+
+    /**
+     * 历史考勤统计-头信息
+     * @param courseScheduleReq
+     * @return
+     */
+    BaseResponse getStatisticsInfo(CourseScheduleReq courseScheduleReq);
 }

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

@@ -20,4 +20,6 @@ public interface IStudentAttendanceService extends IService<StudentAttendance> {
 
     PageResponse getPageByCourse(CourseScheduleReq courseScheduleReq);
 
+    PageResponse statisticsList(CourseScheduleReq courseScheduleReq);
+
 }

+ 3 - 0
mec-education/src/main/java/com/ym/mec/education/service/impl/ClassGroupServiceImpl.java

@@ -37,6 +37,9 @@ public class ClassGroupServiceImpl extends ServiceImpl<ClassGroupMapper, ClassGr
 
     @Override
     public BaseResponse<ClassGroupResp> getInfo(ClassGroupReq classGroupReq) {
+        if (Objects.isNull(classGroupReq.getGroupId())) {
+            return BaseResponse.errorParam();
+        }
         BaseResponse<ClassGroupResp> baseResponse = new BaseResponse<>();
         ClassGroup classGroup = getById(classGroupReq.getGroupId());
         if (Objects.isNull(classGroup)) {

+ 7 - 3
mec-education/src/main/java/com/ym/mec/education/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -41,6 +42,9 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
+        if (Objects.isNull(classGroupReq.getGroupId())) {
+            return PageResponse.errorParam();
+        }
         Page<ClassGroupStudentMapper> classGroupStudentMapperPage = new Page<ClassGroupStudentMapper>(classGroupReq.getPageNo(), classGroupReq.getPageSize());
         QueryWrapper<ClassGroupStudentMapper> classGroupStudentMapperQueryWrapper = new QueryWrapper<>();
         classGroupStudentMapperQueryWrapper.lambda().eq(true, ClassGroupStudentMapper::getClassGroupId, classGroupReq.getGroupId());
@@ -66,11 +70,11 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
 
     @Override
     public List<ClassStudentResp> selectStudentPage(ClassGroupReq classGroupReq) {
-        IPage page = new Page(classGroupReq.getPageNo() ==null ? 1 : classGroupReq.getPageNo(),classGroupReq.getPageSize() == null ? 10:classGroupReq.getPageSize());
+        IPage page = new Page(classGroupReq.getPageNo() == null ? 1 : classGroupReq.getPageNo(), classGroupReq.getPageSize() == null ? 10 : classGroupReq.getPageSize());
 
-        List<ClassStudentResp> classStudentResps =  this.baseMapper.selectStudentPage(page,classGroupReq);
+        List<ClassStudentResp> classStudentResps = this.baseMapper.selectStudentPage(page, classGroupReq);
 
-        return  classStudentResps;
+        return classStudentResps;
     }
 
     @Override

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

@@ -49,6 +49,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
+        if (Objects.isNull(classGroupReq.getGroupId())) {
+            return PageResponse.errorParam();
+        }
         Page<CourseSchedule> courseSchedulePage = new Page<CourseSchedule>(classGroupReq.getPageNo(), classGroupReq.getPageSize());
         QueryWrapper<CourseSchedule> courseScheduleQueryWrapper = new QueryWrapper<>();
         courseScheduleQueryWrapper.lambda().eq(true, CourseSchedule::getClassGroupId, classGroupReq.getGroupId());
@@ -91,6 +94,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
 
     @Override
     public BaseResponse<CourseScheduleResp> getInfo(CourseScheduleReq courseScheduleReq) {
+        if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
+            return BaseResponse.errorParam();
+        }
         CourseSchedule courseSchedule = getById(courseScheduleReq.getCourseScheduleId());
         CourseScheduleResp courseScheduleResp = new CourseScheduleResp();
         if (Objects.nonNull(courseSchedule)) {
@@ -134,4 +140,26 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
         }
         return BaseResponse.success(courseScheduleResp);
     }
+
+    @Override
+    public BaseResponse getStatisticsInfo(CourseScheduleReq courseScheduleReq) {
+        if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
+            return BaseResponse.errorParam();
+        }
+        CourseSchedule courseSchedule = getById(courseScheduleReq.getCourseScheduleId());
+        CourseScheduleResp courseScheduleResp = new CourseScheduleResp();
+        if (Objects.nonNull(courseSchedule)) {
+            ClassGroup classGroup = groupService.getById(courseSchedule.getClassGroupId());
+            if (Objects.nonNull(classGroup)) {
+                if (Objects.nonNull(classGroup.getCurrentClassTimes()) && Objects.nonNull(classGroup.getTotalClassTimes())) {
+                    courseScheduleResp.setAlreadyInClass(classGroup.getCurrentClassTimes() + "/" + classGroup.getTotalClassTimes());
+                }
+                if (Objects.nonNull(classGroup.getStudentNum())) {
+                    courseScheduleResp.setStudentNum(classGroup.getStudentNum());
+                }
+            }
+            //TODO 暂缺退团人数
+        }
+        return BaseResponse.success(courseScheduleResp);
+    }
 }

+ 89 - 4
mec-education/src/main/java/com/ym/mec/education/service/impl/StudentAttendanceServiceImpl.java

@@ -5,16 +5,15 @@ 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.biz.dal.enums.ClassGroupStudentStatusEnum;
 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.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.*;
 import com.ym.mec.education.utils.DateUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -44,9 +43,14 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
     private ISubjectService subjectService;
     @Autowired
     private ISysUserService userService;
+    @Autowired
+    private IClassGroupStudentMapperService classGroupStudentMapperService;
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
+        if (Objects.isNull(classGroupReq.getGroupId())){
+            return PageResponse.errorParam();
+        }
         Page<StudentAttendance> pageParam = new Page(classGroupReq.getPageNo(), classGroupReq.getPageSize());
         QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(Objects.nonNull(classGroupReq.getGroupId()),
@@ -94,6 +98,9 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
 
     @Override
     public PageResponse getPageByCourse(CourseScheduleReq courseScheduleReq) {
+        if (Objects.isNull(courseScheduleReq.getCourseScheduleId())) {
+            return PageResponse.errorParam();
+        }
         Page<StudentAttendanceResp> pageResult = new Page<>();
         Page<StudentAttendance> studentAttendancePage = new Page<>(courseScheduleReq.getPageNo(), courseScheduleReq.getPageSize());
         QueryWrapper<StudentAttendance> queryWrapper = new QueryWrapper<>();
@@ -118,4 +125,82 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
         }
         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);
+    }
 }

+ 8 - 2
mec-education/src/main/java/com/ym/mec/education/utils/DateUtil.java

@@ -16,8 +16,9 @@ import java.util.Date;
  */
 public class DateUtil {
 
-    private static final String DATE_FORMAT = "MM月dd日";
+    private static final String DATE_FORMAT_CHINESE = "MM月dd日";
     private static final String TIME_FORMAT = "HH:mm";
+    public static final String DATE_FORMAT = "MM-dd";
     private static ThreadLocal<DateFormat> threadLocal = new ThreadLocal<DateFormat>();
 
     public static DateFormat getDateFormat(String dateFormat) {
@@ -30,7 +31,7 @@ public class DateUtil {
     }
 
     public static String date2String(Date date) {
-        DateFormat dateFormat = getDateFormat(DATE_FORMAT);
+        DateFormat dateFormat = getDateFormat(DATE_FORMAT_CHINESE);
         String format = dateFormat.format(date);
         if (format.startsWith(BigDecimal.ZERO.toString())) {
             format = format.substring(1);
@@ -38,6 +39,11 @@ public class DateUtil {
         return format;
     }
 
+    public static String date2String(Date date, String dateFormatPattern) {
+        DateFormat dateFormat = getDateFormat(dateFormatPattern);
+        return dateFormat.format(date);
+    }
+
     public static String time2String(Time time) {
         String format = time.toLocalTime().format(DateTimeFormatter.ofPattern(TIME_FORMAT));
         return format;