Joburgess 4 سال پیش
والد
کامیت
9618b4f98b

+ 10 - 10
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseScheduleStudentListDto.java

@@ -18,10 +18,10 @@ public class CourseScheduleStudentListDto {
     private String studentName;
 
     @ApiModelProperty(value = "声部编号")
-    private Integer subjectId;
+    private String subjectIds;
 
     @ApiModelProperty(value = "声部名称")
-    private String subjectName;
+    private String subjectNames;
 
     @ApiModelProperty(value = "手机号")
     private String phone;
@@ -51,20 +51,20 @@ public class CourseScheduleStudentListDto {
         this.studentName = studentName;
     }
 
-    public Integer getSubjectId() {
-        return subjectId;
+    public String getSubjectIds() {
+        return subjectIds;
     }
 
-    public void setSubjectId(Integer subjectId) {
-        this.subjectId = subjectId;
+    public void setSubjectIds(String subjectIds) {
+        this.subjectIds = subjectIds;
     }
 
-    public String getSubjectName() {
-        return subjectName;
+    public String getSubjectNames() {
+        return subjectNames;
     }
 
-    public void setSubjectName(String subjectName) {
-        this.subjectName = subjectName;
+    public void setSubjectNames(String subjectNames) {
+        this.subjectNames = subjectNames;
     }
 
     public String getPhone() {

+ 30 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -49,6 +49,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private TeacherDao teacherDao;
 	@Autowired
 	private StudentDao studentDao;
+	@Autowired
+	private SubjectDao subjectDao;
 
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -296,11 +298,38 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			List<StudentAttendance> studentAttendances = studentAttendanceDao.findByCourseId(queryInfo.getCourseScheduleId().longValue());
 			List<SimpleUserDto> usersSimpleInfo = teacherDao.getUsersSimpleInfo(new ArrayList<>(studentIds));
 			List<Student> students = studentDao.findByStudentIds(new ArrayList<>(studentIds));
+			Set<Integer> subjectIds = new HashSet<>();
 			for (Student student : students) {
 				if(StringUtils.isBlank(student.getSubjectIdList())){
 					continue;
 				}
-				List<Integer> collect = Arrays.stream(student.getSubjectIdList().split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toList());
+				Set<Integer> studentSubjectIds = Arrays.stream(student.getSubjectIdList().split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
+				subjectIds.addAll(studentSubjectIds);
+			}
+			List<Subject> subjects = new ArrayList<>();
+			if(!CollectionUtils.isEmpty(subjectIds)){
+				subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectIds));
+			}
+			Map<Integer, StudentAttendance> studentAttendanceMap = studentAttendances.stream().collect(Collectors.toMap(StudentAttendance::getUserId, s -> s, (s1, s2) -> s1));
+			Map<Integer, SimpleUserDto> studentInfoMap = usersSimpleInfo.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, s -> s, (s1, s2) -> s1));
+			Map<Integer, Student> studentMap = students.stream().collect(Collectors.toMap(Student::getUserId, s -> s, (s1, s2) -> s1));
+			for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
+				CourseScheduleStudentListDto cssld=new CourseScheduleStudentListDto();
+				cssld.setStudentId(courseScheduleStudentPayment.getUserId());
+				cssld.setPhone(studentInfoMap.containsKey(cssld.getStudentId())?studentInfoMap.get(cssld.getStudentId()).getPhone():"");
+				cssld.setSubjectIds(studentMap.containsKey(cssld.getStudentId())?studentMap.get(cssld.getStudentId()).getSubjectIdList():"");
+				if(StringUtils.isNotBlank(cssld.getSubjectIds())){
+					Set<Integer> studentSubjectIds = Arrays.stream(cssld.getSubjectIds().split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
+					List<String> subjectNames = subjects.stream().filter(s -> studentSubjectIds.contains(s.getId())).map(Subject::getName).collect(Collectors.toList());
+					cssld.setSubjectNames(StringUtils.join(subjectNames, ","));
+				}
+				if(studentAttendanceMap.containsKey(cssld.getStudentId())){
+					StudentAttendance studentAttendance = studentAttendanceMap.get(cssld.getStudentId());
+					cssld.setSignInTime(studentAttendance.getSignInTime());
+					cssld.setSignOutTime(studentAttendance.getSignOutTime());
+					cssld.setStatus(studentAttendance.getStatus());
+				}
+				dataList.add(cssld);
 			}
 		}
 		pageInfo.setRows(dataList);

+ 56 - 0
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleStudentPaymentController.java

@@ -0,0 +1,56 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.dto.CourseScheduleStudentListDto;
+import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
+import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
+import com.ym.mec.biz.dal.page.CourseScheduleTeacherSalaryQueryInfo;
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/11/17 0017
+ */
+@RestController
+@RequestMapping("courseScheduleStudentPayment")
+@Api(tags = "学生课程之缴费记录服务")
+public class CourseScheduleStudentPaymentController extends BaseController {
+
+    @Autowired
+    private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
+
+    @ApiOperation(value = "分页查询指定课程上的学员")
+    @GetMapping("/queryCourseStudentList")
+    @PreAuthorize("@pcs.hasPermissions('courseScheduleStudentPayment/queryCourseStudentList')")
+    public HttpResponseResult queryCourseStudentList(CourseScheduleStudentPaymentQueryInfo queryInfo) {
+        PageInfo<CourseScheduleStudentListDto> pageInfo = courseScheduleStudentPaymentService.queryCourseStudentList(queryInfo);
+        List<CourseScheduleStudentListDto> courseScheduleStudentList = pageInfo.getRows();
+
+        Map<String, Integer> countInfo = new HashMap<>();
+        countInfo.put("totalStudentNum", courseScheduleStudentList.size());
+        countInfo.put("signInStudentNum", (int) courseScheduleStudentList.stream().filter(s -> Objects.nonNull(s.getSignInTime())).count());
+        countInfo.put("leaveStudentNum", (int) courseScheduleStudentList.stream().filter(s -> StudentAttendanceStatusEnum.LEAVE.equals(s.getStatus())).count());
+        countInfo.put("truantStudentNum", (int) courseScheduleStudentList.stream().filter(s -> StudentAttendanceStatusEnum.TRUANT.equals(s.getStatus())).count());
+
+        Map<String, Object> result = new HashMap<>();
+        result.put("pageInfo", pageInfo);
+        result.put("countInfo", countInfo);
+
+        return succeed(result);
+    }
+
+}