浏览代码

跨团合并,作业声部取学生身上声部

liujc 2 年之前
父节点
当前提交
3fd3a475f4

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.ConditionDto;
 import com.ym.mec.biz.dal.dto.StudentAttendanceViewDto;
+import com.ym.mec.biz.dal.dto.StudentSubjectDto;
 import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.entity.Subject;
@@ -13,6 +14,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public interface SubjectDao extends BaseDAO<Integer, Subject> {
 
@@ -166,4 +168,7 @@ public interface SubjectDao extends BaseDAO<Integer, Subject> {
     int queryPageByIdOrNameCount(Map<String, Object> params);
 
     List<Subject> list();
+
+    List<StudentSubjectDto> getSubjectByStudentId(@Param("studentIds") Set<Long> studentIds);
+
 }

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentSubjectDto.java

@@ -0,0 +1,35 @@
+package com.ym.mec.biz.dal.dto;
+
+public class StudentSubjectDto {
+
+
+    private Integer subjectId;
+
+    private String subjectName;
+
+    private Integer studentId;
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+}

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SubjectService.java

@@ -2,8 +2,10 @@ package com.ym.mec.biz.service;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import com.ym.mec.biz.dal.dto.ConditionDto;
+import com.ym.mec.biz.dal.dto.StudentSubjectDto;
 import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
 import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
 import com.ym.mec.biz.dal.entity.Subject;
@@ -107,4 +109,6 @@ public interface SubjectService extends BaseService<Integer, Subject> {
      * @return
      */
     List<Subject> list();
+
+    Map<Integer, StudentSubjectDto> getSubjectByStudentId(Set<Long> studentIds);
 }

+ 18 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1783,10 +1783,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 .collect(Collectors.toList());
         truantStudent.addAll(otherStudent);
         truantStudent.addAll(leaveStudent);
+        Set<Long> collect = truantStudent.stream().map(e -> e.getStudentId()).collect(Collectors.toSet());
         if (!CollectionUtils.isEmpty(truantStudent)) {
             CourseSchedule schedule = courseScheduleDao.get(courseScheduleId);
             if (schedule.getGroupType() == MUSIC) {
-                Set<Long> collect = truantStudent.stream().map(e -> e.getStudentId()).collect(Collectors.toSet());
                 Map<Integer, String> paymentStatusMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.queryUserCoursePaymentStatus(collect, schedule.getMusicGroupId()));
 
                 Map<Integer, Long> quitMap = MapUtil.convertIntegerMap(musicGroupQuitDao.queryQuitMapByStudentId(collect, schedule.getMusicGroupId()));
@@ -1808,12 +1808,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 List<Map<Integer, Long>> studentSubjectIdMaps = subjectDao.findStudentSubjectIdMaps(tempIds);
                 Map<Integer, Long> studentSubjectIdMap = MapUtil.convertIntegerMap(studentSubjectIdMaps);
                 truantStudent.forEach(studentAttendanceViewDto -> {
-                    if (Objects.nonNull(studentAttendanceViewDto.getBeMerged()) && studentAttendanceViewDto.getBeMerged()) {
-                        studentAttendanceViewDto.setSubjectName("被合并学员");
-                    } else {
-                        studentAttendanceViewDto.setSubjectName(studentSubjectNameMap.get(studentAttendanceViewDto.getStudentId().intValue()));
-                        studentAttendanceViewDto.setSubjectId(studentSubjectIdMap.get(studentAttendanceViewDto.getStudentId().intValue()));
-                    }
+                    studentAttendanceViewDto.setSubjectName(studentSubjectNameMap.get(studentAttendanceViewDto.getStudentId().intValue()));
+                    studentAttendanceViewDto.setSubjectId(studentSubjectIdMap.get(studentAttendanceViewDto.getStudentId().intValue()));
                 });
             } else if (schedule.getGroupType() != MUSIC) {
                 ClassGroup classGroup = classGroupDao.get(schedule.getClassGroupId());
@@ -1824,6 +1820,21 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 });
             }
         }
+
+        // 乐团声部为空,取student的声部
+        if (!CollectionUtils.isEmpty(truantStudent)) {
+
+            Map<Integer, StudentSubjectDto> subjectDtoMap = subjectService.getSubjectByStudentId(collect);
+            truantStudent.forEach(studentAttendanceViewDto -> {
+                if (studentAttendanceViewDto.getSubjectId() == null) {
+                    StudentSubjectDto subjectDto = subjectDtoMap.getOrDefault(studentAttendanceViewDto.getStudentId().intValue(), new StudentSubjectDto());
+                    if (subjectDto.getSubjectId() != null) {
+                        studentAttendanceViewDto.setSubjectName(subjectDto.getSubjectName());
+                        studentAttendanceViewDto.setSubjectId(subjectDto.getSubjectId().longValue());
+                    }
+                }
+            });
+        }
         return truantStudent;
     }
 

+ 22 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectServiceImpl.java

@@ -1,14 +1,11 @@
 package com.ym.mec.biz.service.impl;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.dto.StudentSubjectDto;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -72,11 +69,11 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
 
         Map<Long,BigDecimal> maps = MapUtil.convertIntegerMap(studentRegistrationDao.querySubjectAmount(musicGroupId));
         subApplyDetail.forEach(detail -> {
-        	SubjectApplyDetailDto dto = new SubjectApplyDetailDto();
-        	if(map.containsKey(detail.getSubjectId())){
-        		dto = map.get(detail.getSubjectId());
-        	}
-        	detail.setTotalAmount(maps.get(detail.getSubjectId().longValue()));
+            SubjectApplyDetailDto dto = new SubjectApplyDetailDto();
+            if(map.containsKey(detail.getSubjectId())){
+                dto = map.get(detail.getSubjectId());
+            }
+            detail.setTotalAmount(maps.get(detail.getSubjectId().longValue()));
             detail.setPayNum(dto.getPayNum());
             detail.setApplyStudentNum(dto.getApplyStudentNum());
             detail.setPayingNum(dto.getPayingNum());
@@ -227,4 +224,18 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
     public List<Subject> list() {
         return subjectDao.list();
     }
+
+    @Override
+    public Map<Integer, StudentSubjectDto> getSubjectByStudentId(Set<Long> studentIds) {
+
+        if (CollectionUtils.isEmpty(studentIds)) {
+            return new HashMap<>();
+        }
+        List<StudentSubjectDto> subjects = subjectDao.getSubjectByStudentId(studentIds);
+        Map<Integer, StudentSubjectDto> map = new HashMap<>();
+        if (!CollectionUtils.isEmpty(subjects)) {
+            map = subjects.stream().collect(Collectors.toMap(StudentSubjectDto::getStudentId, Function.identity()));
+        }
+        return map;
+    }
 }

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -272,4 +272,17 @@
         select * from subject where del_flag_ = 0 and parent_subject_id_ != 0
     </select>
 
+    <select id="getSubjectByStudentId" resultType="com.ym.mec.biz.dal.dto.StudentSubjectDto">
+        SELECT
+            sr.user_id_ AS studentId,
+            s.id_ AS subjectId,
+            s.name_ AS subjectName
+        FROM
+            student sr
+            LEFT JOIN `subject` s ON sr.subject_id_list_=s.id_
+        WHERE  sr.user_id_ IN
+        <foreach collection="studentIds" item="userId" open="(" close=")" separator=",">
+            #{userId}
+        </foreach>
+    </select>
 </mapper>

+ 27 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/ClassGroupController.java

@@ -4,12 +4,14 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.StudentSubjectDto;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.ImGroupNoticeQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.CourseScheduleEvaluateService;
 import com.ym.mec.biz.service.ImGroupNoticeService;
+import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
@@ -17,10 +19,14 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @Author Joburgess
@@ -42,6 +48,9 @@ public class ClassGroupController extends BaseController {
     @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
 
+    @Autowired
+    private SubjectService subjectService;
+
     @ApiOperation(value = "教师关联班级获取")
     @GetMapping("/findTeacherClassGroups")
     public Object findTeacherClassGroups(String type,String status, String groupName){
@@ -63,7 +72,24 @@ public class ClassGroupController extends BaseController {
     @ApiOperation(value = "获取课程学员列表")
     @GetMapping("/getCourseStudents")
     public HttpResponseResult<List<BasicUserDto>> getCourseStudents(Long courseScheduleId){
-        return succeed(courseScheduleStudentPaymentDao.getCourseStudents(courseScheduleId));
+        List<BasicUserDto> courseStudents = courseScheduleStudentPaymentDao.getCourseStudents(courseScheduleId);
+
+        // 乐团声部为空,取student的声部
+        if (!CollectionUtils.isEmpty(courseStudents)) {
+            Set<Long> collect = courseStudents.stream().map(o -> o.getUserId()).map(o -> o.longValue()).collect(Collectors.toSet());
+
+            Map<Integer, StudentSubjectDto> subjectDtoMap = subjectService.getSubjectByStudentId(collect);
+            courseStudents.forEach(studentAttendanceViewDto -> {
+                if (studentAttendanceViewDto.getSubjectId() == null) {
+                    StudentSubjectDto subjectDto = subjectDtoMap.getOrDefault(studentAttendanceViewDto.getUserId(), new StudentSubjectDto());
+                    if (subjectDto.getSubjectId() != null) {
+                        studentAttendanceViewDto.setSubjectName(subjectDto.getSubjectName());
+                        studentAttendanceViewDto.setSubjectId(subjectDto.getSubjectId());
+                    }
+                }
+            });
+        }
+        return succeed();
     }
 
     @ApiOperation(value = "提交陪练报告")