zouxuan 5 年之前
父節點
當前提交
d81f887d69

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -17,6 +17,7 @@ import org.apache.ibatis.annotations.Select;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
 
@@ -821,4 +822,19 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     List<Map<String, Long>> countCourseScheduleNum(@Param("vipGroupIds")List<String> vipGroupIds,@Param("groupType") String groupType);
+
+    /**
+     * 根据班级编号count总课时
+     * @param classGroupIds
+     * @return
+     */
+    List<Map<Integer, Integer>> countTotalNumByClassGroupId(@Param("classGroupIds") Set<Integer> classGroupIds, @Param("classDate") Date classDate);
+
+    /**
+     * 根据班级编号count剩余课时
+     * @param classGroupIds
+     * @param classDate
+     * @return
+     */
+    List<Map<Integer, Integer>> countCurrentNumByClassGroupId(@Param("classGroupIds") Set<Integer> classGroupIds, @Param("classDate") Date classDate);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCourseScheduleRecordDto.java

@@ -19,6 +19,9 @@ public class StudentCourseScheduleRecordDto {
     @ApiModelProperty(value = "课程ID")
     private Long courseScheduleId;
 
+    @ApiModelProperty(value = "班级ID")
+    private Integer classGroupId;
+
     @ApiModelProperty(value = "课程名称",required = false)
     private String courseName;
 
@@ -52,6 +55,14 @@ public class StudentCourseScheduleRecordDto {
     @ApiModelProperty(value = "教学形式")
     private TeachModeEnum teachMode;
 
+    public Integer getClassGroupId() {
+        return classGroupId;
+    }
+
+    public void setClassGroupId(Integer classGroupId) {
+        this.classGroupId = classGroupId;
+    }
+
     public TeachModeEnum getTeachMode() {
         return teachMode;
     }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1782,6 +1782,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             params.put("offset", pageInfo.getOffset());
             dataList = classGroupDao.queryMusicGroupClassGroup(params);
             Set<Integer> classGroups = dataList.stream().map(e -> e.getClassGroupId()).collect(Collectors.toSet());
+//            courseScheduleDao.countTotalCourseNum(classGroups,"MUSIC");
             String join = StringUtils.join(classGroups, ",");
             //获取主教老师
             Map<Integer, String> masterTeachers = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertMybatisMap(classGroupDao.countStudentNum(join, "BISHOP"))), HashMap.class);

+ 14 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1502,12 +1502,24 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 
 		if(queryInfo.getIsAttend()== YesOrNoEnum.YES){
-			pageInfo.setRows(courseScheduleDao.findStudentCourseScheduleNotStartRecords(user.getId().longValue(),
-					queryInfo.getDate()));
+			List<StudentCourseScheduleRecordDto> notStartRecords = courseScheduleDao.findStudentCourseScheduleNotStartRecords(user.getId().longValue(),
+					queryInfo.getDate());
+			if(notStartRecords != null && notStartRecords.size() > 0){
+//				Set<Integer> classGroupIds = notStartRecords.stream().map(e -> e.getClassGroupId()).collect(Collectors.toSet());
+//				Map<Integer,Integer> totalNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countTotalNumByClassGroupId(classGroupIds,queryInfo.getDate()));
+//				Map<Integer,Integer> currentNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countCurrentNumByClassGroupId(classGroupIds,queryInfo.getDate()));
+				notStartRecords.forEach(e->{
+					e.setRestOfClass(notStartRecords.size());
+				});
+			}
+			pageInfo.setRows(notStartRecords);
 			return pageInfo;
 		}
 
 		Map<String, Object> params = new HashMap<String, Object>();
+		if(queryInfo.getType() != null && queryInfo.getType().equals("MUSICGROUP")){
+			queryInfo.setType("MUSIC");
+		}
 		MapUtil.populateMap(params, queryInfo);
 
 		List dataList = null;

+ 25 - 4
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -65,6 +65,7 @@
         <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="rest_of_class_" property="restOfClass"/>
+        <result column="class_group_id_" property="classGroupId"/>
     </resultMap>
     
     <resultMap type="com.ym.mec.biz.dal.entity.StudentAttendance" id="StudentAttendance">
@@ -709,7 +710,7 @@
                 AND cs.teach_mode_=#{teachMode}
             </if>
             <if test="type!=null and type!=''">
-                AND cs.type_=#{type}
+                AND cs.group_type_ = #{type}
             </if>
             <if test="status!=null and status!=''">
                 AND sa.status_=#{status}
@@ -757,15 +758,14 @@
             CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
             CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
             cs.teach_mode_,
-            (cg.total_class_times_-cg.current_class_times_) rest_of_class_
+            cs.class_group_id_
         FROM
             class_group_student_mapper cgsm
             LEFT JOIN course_schedule cs ON cs.class_group_id_=cgsm.class_group_id_
             LEFT JOIN sys_user su ON cs.teacher_id_ = su.id_
-            LEFT JOIN class_group cg ON cgsm.class_group_id_=cg.id_
         WHERE
             (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
-            AND cs.status_='NOT_START' AND cgsm.user_id_=#{userId}
+            AND cs.status_ = 'NOT_START' AND cgsm.user_id_=#{userId}
             AND cs.class_date_=DATE_FORMAT(#{date},'%Y%m%d') AND cgsm.status_ != 'QUIT'
         ORDER BY cs.class_date_,cs.start_class_time_
     </select>
@@ -1659,4 +1659,25 @@
         AND cs.group_type_ = 'VIP' AND cs.status_ != 'NOT_START'
         GROUP BY cs.music_group_id_
     </select>
+    <select id="countTotalNumByClassGroupId" resultType="java.util.Map">
+        SELECT COUNT(cs.id_) FROM course_schedule cs
+        WHERE cs.class_group_id_ IN
+        <foreach collection="classGroupIds" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        <if test="classDate != null">
+            AND cs.class_date_ = DATE_FORMAT(#{classDate}, '%Y%m%d')
+        </if>
+    </select>
+    <select id="countCurrentNumByClassGroupId" resultType="java.util.Map">
+        SELECT COUNT(cs.id_) FROM course_schedule cs
+        WHERE cs.class_group_id_ IN
+        <foreach collection="classGroupIds" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        <if test="classDate != null">
+            AND cs.class_date_ = DATE_FORMAT(#{classDate}, '%Y%m%d')
+        </if>
+        AND cs.status_ != 'NOT_START'
+    </select>
 </mapper>