Ver código fonte

Merge branch 'master' of git.dayaedu.com:yonge/mec

chengpeng 5 anos atrás
pai
commit
b9e0cfd3f5

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

@@ -0,0 +1,36 @@
+package com.ym.mec.education.controller;
+
+import com.ym.mec.education.base.PageResponse;
+import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.service.ICourseScheduleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+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 javax.validation.Valid;
+
+/**
+ * @program: mec
+ * @description: 课表
+ * @author: xw
+ * @create: 2019-09-26 21:04
+ */
+@RestController
+@RequestMapping("api/courseSchedule")
+@Api(tags = "课表")
+@Slf4j
+public class CourseScheduleController {
+
+    @Autowired
+    private ICourseScheduleService courseScheduleService;
+
+    @PostMapping("/list")
+    @ApiOperation("课表列表")
+    public PageResponse list(@RequestBody @Valid ClassGroupReq classGroupReq) {
+        return courseScheduleService.getPage(classGroupReq);
+    }
+}

+ 3 - 0
mec-education/src/main/java/com/ym/mec/education/req/ClassGroupReq.java

@@ -4,6 +4,8 @@ import com.ym.mec.education.base.BaseQuery;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -17,6 +19,7 @@ import java.io.Serializable;
 public class ClassGroupReq extends BaseQuery implements Serializable {
 
     @ApiModelProperty(value = "班级id",required = true)
+    @NotNull(message = "班级id不能为空")
     private Integer groupId;
 
     private Integer type = 0;

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

@@ -0,0 +1,33 @@
+package com.ym.mec.education.resp;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+
+/**
+ * @program: mec
+ * @description: 课表出参
+ * @author: xw
+ * @create: 2019-09-26 20:58
+ */
+@Data
+@ToString
+@ApiModel(description = "课表出参")
+@Accessors(chain = true)
+public class CourseScheduleResp implements Serializable {
+
+    @ApiModelProperty(value = "上课日期",required = true)
+    private String classDate;
+
+    @ApiModelProperty(value = "上课时间",required = true)
+    private String classTime;
+
+    @ApiModelProperty(value = "班级名称",required = true)
+    private String classGroupName;
+
+    @ApiModelProperty(value = "上课老师",required = true)
+    private String teacher;
+}

+ 6 - 9
mec-education/src/main/java/com/ym/mec/education/resp/StudentAttendanceResq.java

@@ -4,9 +4,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
-import org.springframework.format.annotation.DateTimeFormat;
 import java.io.Serializable;
-import java.util.Date;
 
 /**
  * @program: mec
@@ -19,19 +17,18 @@ import java.util.Date;
 @Accessors(chain = true)
 public class StudentAttendanceResq implements Serializable {
 
-    @ApiModelProperty(value = "上课日期",required = true)
-    @DateTimeFormat(pattern = "MM月dd日")
-    private Date classDate;
+    @ApiModelProperty(value = "上课日期", required = true)
+    private String classDate;
 
-    @ApiModelProperty(value = "上课时间",required = true)
+    @ApiModelProperty(value = "上课时间", required = true)
     private String classTime;
 
-    @ApiModelProperty(value = "班级名称",required = true)
+    @ApiModelProperty(value = "班级名称", required = true)
     private String classGroupName;
 
-    @ApiModelProperty(value = "到课比",required = true)
+    @ApiModelProperty(value = "到课比", required = true)
     private String attendanceRate;
 
-    @ApiModelProperty(value = "请假人数",required = true)
+    @ApiModelProperty(value = "请假人数", required = true)
     private Integer leaveNum;
 }

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

@@ -1,7 +1,9 @@
 package com.ym.mec.education.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.CourseSchedule;
+import com.ym.mec.education.req.ClassGroupReq;
 
 /**
  * <p>
@@ -13,4 +15,5 @@ import com.ym.mec.education.entity.CourseSchedule;
  */
 public interface ICourseScheduleService extends IService<CourseSchedule> {
 
+    PageResponse getPage(ClassGroupReq classGroupReq);
 }

+ 5 - 6
mec-education/src/main/java/com/ym/mec/education/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -9,6 +9,7 @@ import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.ClassGroupStudentMapper;
 import com.ym.mec.education.entity.StudentAttendance;
 import com.ym.mec.education.entity.StudentRegistration;
+import com.ym.mec.education.entity.SysUser;
 import com.ym.mec.education.enums.StudentAttendanceStatusEnum;
 import com.ym.mec.education.mapper.ClassGroupStudentMapperMapper;
 import com.ym.mec.education.req.ClassGroupReq;
@@ -16,6 +17,7 @@ import com.ym.mec.education.resp.StudentListResp;
 import com.ym.mec.education.service.IClassGroupStudentMapperService;
 import com.ym.mec.education.service.IStudentAttendanceService;
 import com.ym.mec.education.service.IStudentRegistrationService;
+import com.ym.mec.education.service.ISysUserService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,7 +37,7 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
     @Autowired
     private IStudentAttendanceService studentAttendanceService;
     @Autowired
-    private IStudentRegistrationService studentRegistrationService;
+    private ISysUserService sysUserService;
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
@@ -53,12 +55,9 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
                     .in(true, StudentAttendance::getStatus, StudentAttendanceStatusEnum.TRUANT.getCode(),
                             StudentAttendanceStatusEnum.LEAVE.getCode());
             int count = studentAttendanceService.count(queryWrapper);
-            QueryWrapper<StudentRegistration> studentRegistrationQueryWrapper = new QueryWrapper<>();
-            studentRegistrationQueryWrapper.lambda().eq(true, StudentRegistration::getClassGroupId, item.getClassGroupId())
-                    .eq(true, StudentRegistration::getUserId, item.getUserId());
-            StudentRegistration studentRegistration = studentRegistrationService.getOne(studentRegistrationQueryWrapper);
+            SysUser sysUser = sysUserService.getById(item.getUserId());
             StudentListResp studentRegistrationResp = new StudentListResp()
-                    .setStudentName(studentRegistration.getName()).setStudentAttendance("连续缺到" + count + "次");
+                    .setStudentName(sysUser.getRealName()).setStudentAttendance("连续缺到" + count + "次");
             list.add(studentRegistrationResp);
         });
         studentListRespPage.setRecords(list);

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

@@ -1,10 +1,29 @@
 package com.ym.mec.education.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.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.enums.TeachTypeEnum;
 import com.ym.mec.education.mapper.CourseScheduleMapper;
+import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.resp.CourseScheduleResp;
+import com.ym.mec.education.service.IClassGroupService;
+import com.ym.mec.education.service.IClassGroupTeacherMapperService;
 import com.ym.mec.education.service.ICourseScheduleService;
+import com.ym.mec.education.service.ISysUserService;
+import com.ym.mec.education.utils.DateUtil;
+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>
@@ -17,4 +36,42 @@ import org.springframework.stereotype.Service;
 @Service
 public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper, CourseSchedule> implements ICourseScheduleService {
 
+    @Autowired
+    private IClassGroupService groupService;
+    @Autowired
+    private IClassGroupTeacherMapperService classGroupTeacherMapperService;
+    @Autowired
+    private ISysUserService sysUserService;
+
+    @Override
+    public PageResponse getPage(ClassGroupReq classGroupReq) {
+        Page<CourseSchedule> courseSchedulePage = new Page<>(classGroupReq.getPageNo(), classGroupReq.getPageSize());
+        QueryWrapper<CourseSchedule> courseScheduleQueryWrapper = new QueryWrapper<>();
+        courseScheduleQueryWrapper.lambda().eq(true, CourseSchedule::getClassGroupId, classGroupReq.getGroupId());
+        IPage<CourseSchedule> courseScheduleIPage = page(courseSchedulePage, courseScheduleQueryWrapper);
+        Page<CourseScheduleResp> pageResult = new Page<>();
+        List<CourseScheduleResp> courseScheduleRespList = Lists.newArrayList();
+        BeanUtils.copyProperties(courseScheduleIPage, pageResult);
+        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(item.getStartClassTime() + "-" + item.getEndClassTime())
+                    .setClassGroupName(classGroup.getName());
+            QueryWrapper<ClassGroupTeacherMapper> classGroupTeacherMapperQueryWrapper = new QueryWrapper<>();
+            classGroupTeacherMapperQueryWrapper.lambda().eq(true, ClassGroupTeacherMapper::getClassGroupId, item.getClassGroupId())
+                    .eq(true, ClassGroupTeacherMapper::getTeacherRole, TeachTypeEnum.BISHOP.getCode());
+            ClassGroupTeacherMapper classGroupTeacherMapper = classGroupTeacherMapperService.getOne(classGroupTeacherMapperQueryWrapper);
+            if (Objects.nonNull(classGroupTeacherMapper)){
+                SysUser sysUser = sysUserService.getById(classGroupTeacherMapper.getUserId());
+                if (Objects.nonNull(sysUser)){
+                    courseScheduleResp.setTeacher(sysUser.getRealName());
+                }
+            }
+            courseScheduleRespList.add(courseScheduleResp);
+        });
+        pageResult.setRecords(courseScheduleRespList);
+        return PageResponse.success(pageResult);
+    }
 }

+ 3 - 1
mec-education/src/main/java/com/ym/mec/education/service/impl/StudentAttendanceServiceImpl.java

@@ -16,6 +16,7 @@ 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.utils.DateUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -70,7 +71,8 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
             courseScheduleQueryWrapper.lambda().eq(true, CourseSchedule::getClassGroupId, studentAttendanceReq.getClassGroupId());
             CourseSchedule courseSchedule = courseScheduleService.getOne(courseScheduleQueryWrapper);
             ClassGroup classGroup = groupService.getById(studentAttendanceReq.getClassGroupId());
-            studentAttendanceResq.setClassDate(courseSchedule.getClassDate())
+            studentAttendanceResq.setClassDate(DateUtil.date2String(courseSchedule.getClassDate())
+                    + "" + DateUtil.date2Week(courseSchedule.getClassDate()))
                     .setClassTime(courseSchedule.getStartClassTime() + "-" + courseSchedule.getEndClassTime())
                     .setClassGroupName(classGroup.getName())
                     .setLeaveNum(leaveCount).setAttendanceRate(normalCount + "/" + totalCount);

+ 61 - 0
mec-education/src/main/java/com/ym/mec/education/utils/DateUtil.java

@@ -0,0 +1,61 @@
+package com.ym.mec.education.utils;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @program: mec
+ * @description: 时间工具类
+ * @author: xw
+ * @create: 2019-09-26 21:22
+ */
+public class DateUtil {
+
+    private static final String DATE_FORMAT = "MM月dd日";
+    private static ThreadLocal<DateFormat> threadLocal = new ThreadLocal<DateFormat>();
+
+    public static DateFormat getDateFormat(String dateFormat) {
+        DateFormat df = threadLocal.get();
+        if (df == null) {
+            df = new SimpleDateFormat(dateFormat);
+            threadLocal.set(df);
+        }
+        return df;
+    }
+
+    public static String date2String(Date date) {
+        DateFormat dateFormat = getDateFormat(DATE_FORMAT);
+        String format = dateFormat.format(date);
+        if (format.startsWith(BigDecimal.ZERO.toString())) {
+            format = format.substring(1);
+        }
+        return format;
+    }
+
+    public static String date2Week(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int i = calendar.get(Calendar.DAY_OF_WEEK);
+        switch (i) {
+            case 1:
+                return "星期日";
+            case 2:
+                return "星期一";
+            case 3:
+                return "星期二";
+            case 4:
+                return "星期三";
+            case 5:
+                return "星期四";
+            case 6:
+                return "星期五";
+            case 7:
+                return "星期六";
+            default:
+                return "";
+        }
+    }
+}