Browse Source

课程 考勤添加声部

肖玮 5 năm trước cách đây
mục cha
commit
45bcb2de4c

+ 3 - 2
mec-education/src/main/java/com/ym/mec/education/resp/CourseScheduleResp.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.ToString;
 import lombok.experimental.Accessors;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @program: mec
@@ -25,8 +26,8 @@ public class CourseScheduleResp implements Serializable {
     @ApiModelProperty(value = "上课时间",required = true)
     private String classTime;
 
-    @ApiModelProperty(value = "班级名称",required = true)
-    private String classGroupName;
+    @ApiModelProperty(value = "声部名称",required = true)
+    private List<String> subjectName;
 
     @ApiModelProperty(value = "上课老师",required = true)
     private String teacher;

+ 3 - 2
mec-education/src/main/java/com/ym/mec/education/resp/StudentAttendanceResq.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @program: mec
@@ -23,8 +24,8 @@ public class StudentAttendanceResq implements Serializable {
     @ApiModelProperty(value = "上课时间", required = true)
     private String classTime;
 
-    @ApiModelProperty(value = "班级名称", required = true)
-    private String classGroupName;
+    @ApiModelProperty(value = "声部名称",required = true)
+    private List<String> subjectName;
 
     @ApiModelProperty(value = "到课比", required = true)
     private String attendanceRate;

+ 8 - 0
mec-education/src/main/java/com/ym/mec/education/service/ISubjectService.java

@@ -2,6 +2,7 @@ package com.ym.mec.education.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.education.entity.Subject;
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +14,11 @@ import com.ym.mec.education.entity.Subject;
  */
 public interface ISubjectService extends IService<Subject> {
 
+    /**
+     * 根据声部id List查询声部名称
+     * @param subjectIdArr
+     * @return
+     */
+    List<String> getSubjectNameList(String subjectIdArr);
+
 }

+ 7 - 8
mec-education/src/main/java/com/ym/mec/education/service/impl/CourseScheduleServiceImpl.java

@@ -14,10 +14,7 @@ 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.service.*;
 import com.ym.mec.education.utils.DateUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +39,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
     private IClassGroupTeacherMapperService classGroupTeacherMapperService;
     @Autowired
     private ISysUserService sysUserService;
+    @Autowired
+    private ISubjectService subjectService;
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
@@ -53,19 +52,19 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleMapper,
         List<CourseScheduleResp> courseScheduleRespList = Lists.newArrayList();
         BeanUtils.copyProperties(courseScheduleIPage, pageResult);
         ClassGroup classGroup = groupService.getById(classGroupReq.getGroupId());
-        courseScheduleIPage.getRecords().forEach(item ->{
+        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()))
-                    .setClassGroupName(classGroup.getName());
+                    .setSubjectName(subjectService.getSubjectNameList(classGroup.getSubjectIdList()));
             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)){
+            if (Objects.nonNull(classGroupTeacherMapper)) {
                 SysUser sysUser = sysUserService.getById(classGroupTeacherMapper.getUserId());
-                if (Objects.nonNull(sysUser)){
+                if (Objects.nonNull(sysUser)) {
                     courseScheduleResp.setTeacher(sysUser.getRealName());
                 }
             }

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

@@ -16,11 +16,11 @@ 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.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;
 
@@ -39,6 +39,8 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
     private ICourseScheduleService courseScheduleService;
     @Autowired
     private IClassGroupService groupService;
+    @Autowired
+    private ISubjectService subjectService;
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
@@ -76,7 +78,7 @@ public class StudentAttendanceServiceImpl extends ServiceImpl<StudentAttendanceM
             }
             ClassGroup classGroup = groupService.getById(classGroupReq.getGroupId());
             if (Objects.nonNull(classGroup)) {
-                studentAttendanceResq.setClassGroupName(classGroup.getName());
+                studentAttendanceResq.setSubjectName(subjectService.getSubjectNameList(classGroup.getSubjectIdList()));
                 list.add(studentAttendanceResq);
             }
         });

+ 23 - 0
mec-education/src/main/java/com/ym/mec/education/service/impl/SubjectServiceImpl.java

@@ -1,11 +1,18 @@
 package com.ym.mec.education.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.ym.mec.education.entity.Subject;
 import com.ym.mec.education.mapper.SubjectMapper;
 import com.ym.mec.education.service.ISubjectService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
 /**
  * <p>
  * 科目(声部) 服务实现类
@@ -17,4 +24,20 @@ import org.springframework.stereotype.Service;
 @Service("ISubjectService")
 public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements ISubjectService {
 
+    @Override
+    public List<String> getSubjectNameList(String subjectIdArr) {
+        if (StringUtils.isNotBlank(subjectIdArr)) {
+            List<String> subjectName = Lists.newArrayList();
+            List<String> subjectIdList = Arrays.asList(subjectIdArr.split(","));
+            subjectIdList.forEach(subjectId -> {
+                Subject subject = getById(Integer.parseInt(subjectId));
+                if (Objects.nonNull(subject)) {
+                    subjectName.add(subject.getName());
+                }
+            });
+            return subjectName;
+        } else {
+            return Collections.emptyList();
+        }
+    }
 }