Browse Source

云教练作业优化

zouxuan 3 years ago
parent
commit
5068f0f12a

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentExtracurricularExercisesSituationDao.java

@@ -146,4 +146,11 @@ public interface StudentExtracurricularExercisesSituationDao extends BaseDAO<Lon
     List<Long> queryCourseIdByClassDate(@Param("firstDayOfMonth") Date firstDayOfMonth,
                                        @Param("lastDayOfMonth") Date lastDayOfMonth,
                                        @Param("teacherId") Integer teacherId);
+
+    /**
+     * 统计服务周期内可布置的作业和训练数量
+     * @param teacherId
+     * @return
+     */
+    int countWaitCreateHomeworkNum(Integer teacherId);
 }

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

@@ -540,22 +540,6 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 		if (sysUser == null) {
 			throw new BizException("用户信息获取失败");
 		}
-		List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(null, sysUser.getId(), null);
-		if(weekServiceWithStudents == null || weekServiceWithStudents.size() == 0){
-			return 0;
-		}
-		List<StudentExtracurricularExercisesSituation> containsList = weekServiceWithStudents.stream().filter(e -> StringUtils.isNotEmpty(e.getCourseIds()) && e.getCourseIds().contains(",")).collect(Collectors.toList());
-		int num = 0;
-		if(containsList != null && containsList.size() > 0){
-			for (StudentExtracurricularExercisesSituation e : containsList) {
-				String[] split = e.getCourseIds().split(",");
-				if(e.getNotOverCourseNum() == 0){
-					num = num + split.length - e.getNotOverCourseNum();
-				}
-			}
-		}
-		List<StudentExtracurricularExercisesSituation> situationList = weekServiceWithStudents.stream().filter(e -> StringUtils.isEmpty(e.getCourseIds()) || !e.getCourseIds().contains(",") && e.getNotOverCourseNum() == 0).collect(Collectors.toList());
-		num += situationList.size();
-		return num;
+		return studentExtracurricularExercisesSituationDao.countWaitCreateHomeworkNum(sysUser.getId());
 	}
 }

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/ImUserFriendMapper.xml

@@ -105,7 +105,11 @@
 	</select>
 	
 	<select id="queryFriendDetail" resultMap="ImUserFriendDto" parameterType="map">
-		SELECT iuf.*,u.real_name_,u.avatar_,u.phone_,u.user_type_ FROM im_user_friend iuf left join sys_user u on iuf.friend_id_ = u.id_
-		where iuf.user_id_ = #{userId} and iuf.friend_id_ = #{friendUserId}
+		SELECT iuf.*,u.real_name_,u.avatar_,u.phone_,u.user_type_,s.subject_id_list_ subject_id_,s.member_rank_setting_id_,sb.name_ subject_name_
+		FROM im_user_friend iuf
+		LEFT JOIN sys_user u ON iuf.friend_id_ = u.id_
+		LEFT JOIN student s ON s.user_id_ = u.id_
+		LEFT JOIN subject sb ON s.subject_id_list_ = sb.id_
+		WHERE iuf.user_id_ = #{userId} AND iuf.friend_id_ = #{friendUserId}
 	</select>
 </mapper>

+ 6 - 1
mec-biz/src/main/resources/config/mybatis/StudentExtracurricularExercisesSituationMapper.xml

@@ -478,7 +478,7 @@
 		SELECT * FROM student_extracurricular_exercises_situation_
 		<where>
 			<if test="monday != null and monday != ''">
-				AND monday_=#{monday}
+				AND monday_ = #{monday}
 			</if>
 			<if test="teacherId!=null">
 				AND teacher_id_=#{teacherId}
@@ -728,4 +728,9 @@
 		WHERE csts.user_id_ = #{teacherId} AND cs.class_date_ BETWEEN #{firstDayOfMonth} AND #{lastDayOfMonth}
 		AND FIND_IN_SET(cs.id_,se.course_ids_) AND se.serve_type_ = 'HOMEWORK'
 	</select>
+	<select id="countWaitCreateHomeworkNum" resultType="java.lang.Integer">
+		SELECT COUNT(id_) FROM student_extracurricular_exercises_situation_ WHERE teacher_id_ = #{teacherId}
+		AND ((serve_type_ = 'EXERCISE' AND expect_exercises_num_ > actual_exercises_num_)
+		OR (serve_type_ = 'HOMEWORK' AND expect_exercises_num_ > not_over_course_num_)) AND DATE_FORMAT(NOW(), '%Y-%m-%d') BETWEEN monday_ AND sunday_
+	</select>
 </mapper>

+ 0 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/ImGroupController.java

@@ -84,7 +84,6 @@ public class ImGroupController extends BaseController {
 		if (Objects.isNull(sysUser)) {
 			return failed(HttpStatus.FORBIDDEN, "请登录");
 		}
-
 		ImUserFriendDto dto = imUserFriendService.queryFriendDetail(sysUser.getId(), userId);
 		if (dto == null) {
 			dto = new ImUserFriendDto();