Bläddra i källkod

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

yonge 4 år sedan
förälder
incheckning
4bfdb55c18

+ 2 - 26
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.StudentSubTotalCourseTimesDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 
 import java.math.BigDecimal;
@@ -94,35 +95,10 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
     List<MusicGroupPaymentStudentCourseDetail> queryByMusicGroupPaymentStudentCourseDetailId(List<Long> musicGroupPaymentCalenderDetailIdList);
 
     /**
-     * 获取乐团学员剩余可排课时长
-     *
-     * @param studentIds
-     * @return
-     */
-    List<Map<Integer, BigDecimal>> queryStudentSubTotalCourseTime(@Param("studentIds") Set<Integer> studentIds, @Param("musicGroupId") String musicGroupId);
-
-    /**
      * 获取学员关联的每种课程类型的剩余可排课时长
      *
-     * @param userId
-     * @param musicGroupId
-     * @return
-     */
-    List<Map<Integer, Integer>> queryStudentSubTotalCourseTimes(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
-
-    /**
-     * 获取有可用时长的学员列表
-     *
-     * @param musicGroupId
-     * @return
-     */
-    List<Integer> queryHasSubTotalCourseTimeStudentIds(@Param("musicGroupId") String musicGroupId, @Param("hasSubCourseTime") Boolean hasSubCourseTime);
-
-    /**
-     * 获取没有可用时长的学员列表
-     *
      * @param musicGroupId
      * @return
      */
-    List<Integer> queryNoSubTotalCourseTimeStudentIds(@Param("musicGroupId") String musicGroupId, @Param("hasSubCourseTime") Boolean hasSubCourseTime);
+    List<StudentSubTotalCourseTimesDto> queryStudentSubTotalCourseTimes(@Param("musicGroupId") String musicGroupId);
 }

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MapDto.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.dal.dto;
+
+public class MapDto {
+    private String key;
+
+    private Integer value;
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public Integer getValue() {
+        return value;
+    }
+
+    public void setValue(Integer value) {
+        this.value = value;
+    }
+}

+ 45 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentSubTotalCourseTimesDto.java

@@ -0,0 +1,45 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.List;
+
+public class StudentSubTotalCourseTimesDto{
+    private Integer userId;
+
+    private String username;
+
+    private String phone;
+
+    private List<MapDto> MapDtos;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public List<MapDto> getMapDtos() {
+        return MapDtos;
+    }
+
+    public void setMapDtos(List<MapDto> mapDtos) {
+        MapDtos = mapDtos;
+    }
+}

+ 0 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupStudentQueryInfo.java

@@ -31,17 +31,6 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
 
   private boolean isExport = false;
 
-  @ApiModelProperty(value = "是否有剩余课时")
-  private Boolean hasSubCourseTime;
-
-  public Boolean getHasSubCourseTime() {
-    return hasSubCourseTime;
-  }
-
-  public void setHasSubCourseTime(Boolean hasSubCourseTime) {
-    this.hasSubCourseTime = hasSubCourseTime;
-  }
-
   public boolean getIsExport() {
     return isExport;
   }

+ 1 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/StudentManageService.java

@@ -203,8 +203,7 @@ public interface StudentManageService {
 
     /**
      * 乐团管理--乐团详情--学员列表--获取学员可排课时长
-     * @param userId
      * @return
      */
-    Map<Integer, Integer> queryStudentSubTotalCourseTimes(Integer userId,String musicGroupId);
+    List<StudentSubTotalCourseTimesDto> queryStudentSubTotalCourseTimes(String musicGroupId);
 }

+ 28 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -5271,6 +5271,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			}
 			if(Objects.isNull(courseMergeInfo.getClassGroupId())&&courseMergeInfo.getId().equals(courseSchedule.getId())){
 				courseMergeInfo.setClassGroupId(courseSchedule.getClassGroupId());
+				courseMergeInfo.setGroupType(courseSchedule.getGroupType());
+				courseMergeInfo.setMusicGroupId(courseSchedule.getMusicGroupId());
 			}
 			courseSchedule.setNote("课程合并");
 		}
@@ -5279,26 +5281,40 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		Set<Integer> allStudentIds = courseScheduleStudentPayments.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toSet());
 
 		Map<Integer, CourseScheduleStudentPayment> mainStudentCourseMap = courseScheduleStudentPayments.stream().filter(c -> courseMergeInfo.getId().equals(c.getCourseScheduleId())).collect(Collectors.toMap(CourseScheduleStudentPayment::getUserId, c -> c, (c1, c2) -> c1));
+
+		Map<Integer, List<CourseScheduleStudentPayment>> otherStudentCourseMap = courseScheduleStudentPayments.stream().filter(c -> !courseMergeInfo.getId().equals(c.getCourseScheduleId())).collect(Collectors.groupingBy(CourseScheduleStudentPayment::getUserId));
+
+
 		List<CourseScheduleStudentPayment> newPayments = new ArrayList<>();
 		List<CourseScheduleStudentPayment> updatePayments = new ArrayList<>();
-		for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
-			CourseScheduleStudentPayment updatePayment = mainStudentCourseMap.get(courseScheduleStudentPayment.getUserId());
-			if(Objects.nonNull(updatePayment)&&updatePayment.getCourseScheduleId().equals(courseScheduleStudentPayment.getCourseScheduleId())){
-				continue;
-			}
-			if(Objects.nonNull(updatePayment)&&updatePayment.getUserId().equals(courseScheduleStudentPayment.getUserId())){
-				updatePayment.setExpectPrice(updatePayment.getExpectPrice().add(courseScheduleStudentPayment.getExpectPrice()));
-				courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
+
+		for (Map.Entry<Integer, List<CourseScheduleStudentPayment>> otherStudentCourseMapEntry : otherStudentCourseMap.entrySet()) {
+			List<CourseScheduleStudentPayment> studentCoursePayments = otherStudentCourseMapEntry.getValue();
+			BigDecimal salary = studentCoursePayments.stream().map(CourseScheduleStudentPayment::getExpectPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
+			if(mainStudentCourseMap.containsKey(otherStudentCourseMapEntry.getKey())){
+				CourseScheduleStudentPayment updatePayment = mainStudentCourseMap.get(otherStudentCourseMapEntry.getKey());
+				updatePayment.setExpectPrice(updatePayment.getExpectPrice().add(salary));
 				updatePayments.add(updatePayment);
-				updatePayments.add(courseScheduleStudentPayment);
+
+				for (CourseScheduleStudentPayment studentCoursePayment : studentCoursePayments) {
+					studentCoursePayment.setExpectPrice(BigDecimal.ZERO);
+					updatePayments.add(studentCoursePayment);
+				}
 				continue;
 			}
 			CourseScheduleStudentPayment newPayment = new CourseScheduleStudentPayment();
-			BeanUtils.copyProperties(courseScheduleStudentPayment, newPayment);
+			BeanUtils.copyProperties(studentCoursePayments.get(0), newPayment);
 			newPayment.setCourseScheduleId(courseMergeInfo.getId());
 			newPayment.setClassGroupId(courseMergeInfo.getClassGroupId());
-			courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
-			updatePayments.add(courseScheduleStudentPayment);
+			newPayment.setMusicGroupId(courseMergeInfo.getMusicGroupId());
+			newPayment.setGroupType(courseMergeInfo.getGroupType());
+			newPayment.setExpectPrice(salary);
+			newPayment.setId(null);
+			newPayments.add(newPayment);
+			for (CourseScheduleStudentPayment studentCoursePayment : studentCoursePayments) {
+				studentCoursePayment.setExpectPrice(BigDecimal.ZERO);
+				updatePayments.add(studentCoursePayment);
+			}
 		}
 
 		List<CourseSchedule> courseSchedules=new ArrayList<>();

+ 2 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -416,20 +416,6 @@ public class StudentManageServiceImpl implements StudentManageService {
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         List<MusicGroupStudentsDto> dataList = null;
-        String musicGroupId = queryInfo.getMusicGroupId();
-        //是否有剩余课时
-        if(queryInfo.getHasSubCourseTime() != null){
-            List<Integer> students = new ArrayList<>();
-            if(queryInfo.getHasSubCourseTime()){
-                students = musicGroupPaymentStudentCourseDetailDao.queryHasSubTotalCourseTimeStudentIds(musicGroupId,queryInfo.getHasSubCourseTime());
-            }else {
-                students = musicGroupPaymentStudentCourseDetailDao.queryNoSubTotalCourseTimeStudentIds(musicGroupId,queryInfo.getHasSubCourseTime());
-            }
-            if (students.size() == 0){
-                return pageInfo;
-            }
-            params.put("studentIds", students);
-        }
         int count = studentManageDao.countMusicGroupStudent(params);
         if (queryInfo.getIsExport() && count > 50000) {
             throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
@@ -440,11 +426,6 @@ public class StudentManageServiceImpl implements StudentManageService {
             dataList = studentManageDao.queryMusicGroupStudent(params);
             //退团的学生
             List<Integer> quitUserIds = dataList.stream().filter(e -> e.getStudentStatus().equals("QUIT")).map(MusicGroupStudentsDto::getUserId).collect(Collectors.toList());
-            Set<Integer> studentIds = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
-            Map<Integer, BigDecimal> subTotalCourseTimeMap = MapUtil.convertIntegerMap(musicGroupPaymentStudentCourseDetailDao.queryStudentSubTotalCourseTime(studentIds,musicGroupId));
-            for (MusicGroupStudentsDto musicGroupStudentsDto : dataList) {
-                musicGroupStudentsDto.setSubTotalCourseTime(subTotalCourseTimeMap.get(musicGroupStudentsDto.getUserId()));
-            }
             if (quitUserIds.size() > 0) {
                 List<MusicGroupQuit> quits = musicGroupQuitDao.getQuits(queryInfo.getMusicGroupId(), quitUserIds);
                 for (MusicGroupStudentsDto musicGroupStudentsDto : dataList) {
@@ -739,7 +720,7 @@ public class StudentManageServiceImpl implements StudentManageService {
     }
 
     @Override
-    public Map<Integer, Integer> queryStudentSubTotalCourseTimes(Integer userId,String musicGroupId) {
-        return MapUtil.convertIntegerMap(musicGroupPaymentStudentCourseDetailDao.queryStudentSubTotalCourseTimes(userId,musicGroupId));
+    public List<StudentSubTotalCourseTimesDto> queryStudentSubTotalCourseTimes(String musicGroupId) {
+        return musicGroupPaymentStudentCourseDetailDao.queryStudentSubTotalCourseTimes(musicGroupId);
     }
 }

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -454,9 +454,9 @@ public class StudentServeServiceImpl implements StudentServeService {
                     if(codeServeMap.containsKey(result.getStuAndTeaCode())){
                         StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
                         Set<Long> courseIds = new HashSet<>();
-                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
-                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
-                        }
+//                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
+//                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
+//                        }
                         if(StringUtils.isNotBlank(result.getCourseIds())){
                             courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
                         }

+ 14 - 34
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -226,42 +226,22 @@
         )
     </delete>
 
-    <select id="queryStudentSubTotalCourseTime" resultType="java.util.Map">
-        SELECT mgpscd.user_id_ 'key',SUM(CASE WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_ ELSE 0 END) 'value'
+    <resultMap id="StudentSubTotalCourseTimesDto" type="com.ym.mec.biz.dal.dto.StudentSubTotalCourseTimesDto">
+        <result property="userId" column="user_id_"/>
+        <result property="username" column="username_"/>
+        <result property="phone" column="phone_"/>
+        <collection property="mapDtos" ofType="com.ym.mec.biz.dal.dto.MapDto">
+            <result property="key" column="key"/>
+            <result property="value" column="value"/>
+        </collection>
+    </resultMap>
+    <select id="queryStudentSubTotalCourseTimes" resultMap="StudentSubTotalCourseTimesDto">
+        SELECT mgpscd.user_id_,su.username_,su.phone_,mgpscd.course_type_ 'key',
+               SUM(CASE WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_ ELSE 0 END) 'value'
         FROM music_group_payment_student_course_detail mgpscd
         LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
+        LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
         WHERE mgpc.music_group_id_ = #{musicGroupId}
-        <if test="studentIds != null">
-            AND mgpscd.user_id_ IN
-            <foreach collection="studentIds" open="(" close=")" item="item" separator=",">
-                #{item}
-            </foreach>
-        </if>
-        GROUP BY mgpscd.user_id_
-    </select>
-
-    <select id="queryStudentSubTotalCourseTimes" resultType="java.util.Map">
-        SELECT mgpscd.course_type_ 'key',SUM(CASE WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_ ELSE 0 END) 'value'
-        FROM music_group_payment_student_course_detail mgpscd
-        LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.user_id_ = #{userId}
-        GROUP BY mgpscd.course_type_
-    </select>
-
-    <select id="queryHasSubTotalCourseTimeStudentIds" resultType="java.lang.Integer">
-        SELECT DISTINCT mgpscd.user_id_
-        FROM music_group_payment_student_course_detail mgpscd
-        LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.used_course_minutes_ = 0
-    </select>
-
-    <select id="queryNoSubTotalCourseTimeStudentIds" resultType="java.lang.Integer">
-        SELECT DISTINCT mgpscd.user_id_ FROM music_group_payment_student_course_detail mgpscd
-        LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
-        WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.user_id_ NOT IN (
-                SELECT DISTINCT mgpscd1.user_id_
-                FROM music_group_payment_student_course_detail mgpscd1
-                LEFT JOIN music_group_payment_calender mgpc1 ON mgpc1.id_ = mgpscd1.music_group_payment_calender_id_
-                WHERE mgpc1.music_group_id_ = #{musicGroupId} AND mgpscd1.used_course_minutes_ = 0)
+        GROUP BY mgpscd.user_id_,mgpscd.course_type_
     </select>
 </mapper>

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

@@ -418,12 +418,6 @@
 
     <sql id="queryMusicGroupStudentSql">
         <where>
-            <if test="studentIds != null">
-                AND su.id_ IN
-                <foreach collection="studentIds" open="(" close=")" separator="," item="item">
-                    #{item}
-                </foreach>
-            </if>
             <if test="search != null and search != ''">
                 AND (su.id_ = #{search} OR su.username_ LIKE CONCAT("%",#{search},"%") OR su.phone_ LIKE CONCAT("%",#{search},"%"))
             </if>

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/StudentManageController.java

@@ -124,8 +124,8 @@ public class StudentManageController extends BaseController {
     @ApiOperation(value = "乐团管理--乐团详情--学员列表--获取学员可排课时长")
     @GetMapping("/queryStudentSubTotalCourseTimes")
     @PreAuthorize("@pcs.hasPermissions('studentManage/queryStudentSubTotalCourseTimes')")
-    public Object queryStudentSubTotalCourseTimes(Integer userId,String musicGroupId){
-        return succeed(studentManageService.queryStudentSubTotalCourseTimes(userId,musicGroupId));
+    public Object queryStudentSubTotalCourseTimes(String musicGroupId){
+        return succeed(studentManageService.queryStudentSubTotalCourseTimes(musicGroupId));
     }
 
     @ApiOperation(value = "乐团修改--学员缴费记录--可新增学员列表")