Browse Source

作业布置优化

zouxuan 3 years ago
parent
commit
0c26a5aad4

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -247,7 +247,9 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @author Joburgess
      * @author Joburgess
      * @date 2019/10/18
      * @date 2019/10/18
      */
      */
-    List<CourseScheduleDto> getTeacherCourseSchedulesWithDate(@Param("classDate") Date classDate, @Param("teacherId") Long teacherId, @Param("type") String type);
+    List<CourseScheduleDto> getTeacherCourseSchedulesWithDate(@Param("classDate") Date classDate,
+                                                              @Param("teacherId") Long teacherId,
+                                                              @Param("type") String type);
 
 
     /**
     /**
      * @param teacherId: 教师编号
      * @param teacherId: 教师编号

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -372,4 +372,18 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
      * @return java.util.Set<java.lang.Integer>
      * @return java.util.Set<java.lang.Integer>
      */
      */
     Set<Integer> getValidVipStudentIds();
     Set<Integer> getValidVipStudentIds();
+
+    /**
+     * 获取课程中学员会员数量
+     * @param courseIds
+     * @return
+     */
+    List<Map<Long, Long>> countCourseStudentMemberNum(@Param("courseIds") Set<Long> courseIds);
+
+    /**
+     * 获取课程生学员声部名称
+     * @param courseIds
+     * @return
+     */
+    List<Map<Long, String>> countCourseStudentSubjectName(@Param("courseIds") Set<Long> courseIds);
 }
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherServeHomeworkDto.java

@@ -10,8 +10,28 @@ public class TeacherServeHomeworkDto extends CourseSchedule {
 
 
     private String subjectName;
     private String subjectName;
 
 
+    private String studentSubjectName;
+
+    private Integer memberNum;
+
     private int homeworkExist;
     private int homeworkExist;
 
 
+    public String getStudentSubjectName() {
+        return studentSubjectName;
+    }
+
+    public void setStudentSubjectName(String studentSubjectName) {
+        this.studentSubjectName = studentSubjectName;
+    }
+
+    public Integer getMemberNum() {
+        return memberNum;
+    }
+
+    public void setMemberNum(Integer memberNum) {
+        this.memberNum = memberNum;
+    }
+
     public String getSubjectName() {
     public String getSubjectName() {
         return subjectName;
         return subjectName;
     }
     }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/TeacherServeHomeworkQueryInfo.java

@@ -16,6 +16,16 @@ public class TeacherServeHomeworkQueryInfo extends QueryInfo {
 
 
     private Integer teacherId;
     private Integer teacherId;
 
 
+    private String courseType;
+
+    public String getCourseType() {
+        return courseType;
+    }
+
+    public void setCourseType(String courseType) {
+        this.courseType = courseType;
+    }
+
     public Date getMonday() {
     public Date getMonday() {
         return monday;
         return monday;
     }
     }

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentExtracurricularExercisesSituationServiceImpl.java

@@ -311,7 +311,10 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 
 
 	@Override
 	@Override
 	public PageInfo<TeacherServeHomeworkDto> queryTeacherServeHomeworkDetail(TeacherServeHomeworkQueryInfo queryInfo) {
 	public PageInfo<TeacherServeHomeworkDto> queryTeacherServeHomeworkDetail(TeacherServeHomeworkQueryInfo queryInfo) {
-		if(Objects.isNull(queryInfo.getMonday())||Objects.isNull(queryInfo.getSunday())||Objects.isNull(queryInfo.getTeacherId())){
+		if(Objects.isNull(queryInfo.getMonday())||Objects.isNull(queryInfo.getSunday())){
+			throw new BizException("请指定课程时间");
+		}
+		if(Objects.isNull(queryInfo.getTeacherId())){
 			throw new BizException("请指定教师");
 			throw new BizException("请指定教师");
 		}
 		}
 		PageInfo<TeacherServeHomeworkDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 		PageInfo<TeacherServeHomeworkDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
@@ -343,6 +346,9 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 		MapUtil.populateMap(params, queryInfo);
 		MapUtil.populateMap(params, queryInfo);
 		params.put("courseIds", courseIds);
 		params.put("courseIds", courseIds);
 
 
+		Map<Long,Long> memberNumMap = MapUtil.convertIntegerMap(studentDao.countCourseStudentMemberNum(courseIds));
+		Map<Long,String> studentSubjectMap = MapUtil.convertMybatisMap(studentDao.countCourseStudentSubjectName(courseIds));
+
 		List<TeacherServeHomeworkDto> dataList = new ArrayList<>();
 		List<TeacherServeHomeworkDto> dataList = new ArrayList<>();
 		int count = courseScheduleDao.countByCourseScheduleIds(params);
 		int count = courseScheduleDao.countByCourseScheduleIds(params);
 		if (count > 0) {
 		if (count > 0) {
@@ -380,6 +386,9 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 				subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectIds));
 				subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectIds));
 			}
 			}
 			for (TeacherServeHomeworkDto teacherServeHomeworkDto : dataList) {
 			for (TeacherServeHomeworkDto teacherServeHomeworkDto : dataList) {
+				Long aLong = memberNumMap.get(teacherServeHomeworkDto.getId());
+				teacherServeHomeworkDto.setMemberNum(aLong==null?0:aLong.intValue());
+				teacherServeHomeworkDto.setStudentSubjectName(studentSubjectMap.get(teacherServeHomeworkDto.getId()));
 				if(idClassGroupMap.containsKey(teacherServeHomeworkDto.getClassGroupId())){
 				if(idClassGroupMap.containsKey(teacherServeHomeworkDto.getClassGroupId())){
 					ClassGroup classGroup = idClassGroupMap.get(teacherServeHomeworkDto.getClassGroupId());
 					ClassGroup classGroup = idClassGroupMap.get(teacherServeHomeworkDto.getClassGroupId());
 					if(StringUtils.isNotBlank(classGroup.getSubjectIdList())){
 					if(StringUtils.isNotBlank(classGroup.getSubjectIdList())){

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3842,6 +3842,9 @@
         <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
         <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
             #{courseId}
             #{courseId}
         </foreach>
         </foreach>
+        <if test="courseType != null and courseType != ''">
+            AND FIND_IN_SET(cs.type_,#{courseType})
+        </if>
         ORDER BY cs.class_date_,cs.start_class_time_,cs.id_
         ORDER BY cs.class_date_,cs.start_class_time_,cs.id_
         <include refid="global.limit"></include>
         <include refid="global.limit"></include>
     </select>
     </select>
@@ -3853,6 +3856,9 @@
         <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
         <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
             #{courseId}
             #{courseId}
         </foreach>
         </foreach>
+        <if test="courseType != null and courseType != ''">
+            AND FIND_IN_SET(cs.type_,#{courseType})
+        </if>
     </select>
     </select>
 
 
     <select id="getMusicGroupHasStartCourseNum" resultType="integer">
     <select id="getMusicGroupHasStartCourseNum" resultType="integer">

+ 21 - 0
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -1220,6 +1220,27 @@
     <select id="getValidVipStudentIds" resultType="java.lang.Integer">
     <select id="getValidVipStudentIds" resultType="java.lang.Integer">
         SELECT user_id_ FROM student WHERE member_rank_setting_id_ IS NOT NULl OR experience_member_rank_setting_id_ IS NOT NULL
         SELECT user_id_ FROM student WHERE member_rank_setting_id_ IS NOT NULl OR experience_member_rank_setting_id_ IS NOT NULL
     </select>
     </select>
+    <select id="countCourseStudentMemberNum" resultType="java.util.Map">
+        SELECT cssp.course_schedule_id_ 'key',COUNT(CASE WHEN s.member_rank_setting_id_ IS NULL THEN NULL ELSE 1 END) 'value'
+        FROM course_schedule_student_payment cssp
+        LEFT JOIN student s ON s.user_id_ = cssp.course_schedule_id_
+        WHERE cssp.course_schedule_id_ IN
+        <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
+            #{courseId}
+        </foreach>
+        GROUP BY cssp.course_schedule_id_
+    </select>
+    <select id="countCourseStudentSubjectName" resultType="java.util.Map">
+        SELECT cssp.course_schedule_id_ 'key',GROUP_CONCAT(DISTINCT st.name_) 'value'
+        FROM course_schedule_student_payment cssp
+        LEFT JOIN student s ON s.user_id_ = cssp.user_id_
+        LEFT JOIN `subject` st ON st.id_ = s.subject_id_list_
+        WHERE cssp.course_schedule_id_ IN
+        <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
+            #{courseId}
+        </foreach>
+        GROUP BY cssp.course_schedule_id_
+    </select>
 
 
     <update id="updateGrade"><![CDATA[
     <update id="updateGrade"><![CDATA[
         UPDATE student SET current_grade_num_=current_grade_num_+1
         UPDATE student SET current_grade_num_=current_grade_num_+1

+ 16 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/ExtracurricularExercisesController.java

@@ -12,8 +12,10 @@ import com.ym.mec.biz.dal.entity.ExtracurricularExercises;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.page.ExtraExercilseQueryInfo;
 import com.ym.mec.biz.dal.page.ExtraExercilseQueryInfo;
+import com.ym.mec.biz.dal.page.TeacherServeHomeworkQueryInfo;
 import com.ym.mec.biz.service.ExtracurricularExercisesReplyService;
 import com.ym.mec.biz.service.ExtracurricularExercisesReplyService;
 import com.ym.mec.biz.service.ExtracurricularExercisesService;
 import com.ym.mec.biz.service.ExtracurricularExercisesService;
+import com.ym.mec.biz.service.StudentExtracurricularExercisesSituationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.yonge.log.model.AuditLogAnnotation;
 import com.yonge.log.model.AuditLogAnnotation;
@@ -21,6 +23,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -44,6 +47,8 @@ public class ExtracurricularExercisesController extends BaseController {
     @Autowired
     @Autowired
     private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
     private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
     @Autowired
     @Autowired
+    private StudentExtracurricularExercisesSituationService studentExtracurricularExercisesSituationService;
+    @Autowired
     private SysUserFeignService sysUserFeignService;
     private SysUserFeignService sysUserFeignService;
     @Autowired
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
     private StudentRegistrationDao studentRegistrationDao;
@@ -52,6 +57,17 @@ public class ExtracurricularExercisesController extends BaseController {
     @Autowired
     @Autowired
     private StudentDao studentDao;
     private StudentDao studentDao;
 
 
+    @ApiOperation(value = "教师服务课后作业")
+    @GetMapping("/queryTeacherServeHomeworkDetail")
+    public HttpResponseResult queryTeacherServeHomeworkDetail(TeacherServeHomeworkQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        queryInfo.setTeacherId(sysUser.getId());
+        return succeed(studentExtracurricularExercisesSituationService.queryTeacherServeHomeworkDetail(queryInfo));
+    }
+
     @ApiOperation(value = "创建课外训练")
     @ApiOperation(value = "创建课外训练")
     @PostMapping("/createExtraExercises")
     @PostMapping("/createExtraExercises")
     @AuditLogAnnotation(operateName = "创建课外训练")
     @AuditLogAnnotation(operateName = "创建课外训练")

+ 2 - 1
mec-util/src/main/java/com/ym/mec/util/collection/MapUtil.java

@@ -131,7 +131,8 @@ public class MapUtil {
 			if(Objects.isNull(stringIntegerMap)){
 			if(Objects.isNull(stringIntegerMap)){
 				return;
 				return;
 			}
 			}
-			result.put(stringIntegerMap.get("key"),stringIntegerMap.get("value").toString());
+			K value = stringIntegerMap.get("value");
+			result.put(stringIntegerMap.get("key"),value == null?"":value.toString());
 		});
 		});
 		return result;
 		return result;
 	}
 	}