Bladeren bron

Merge branch 'feature/0529-live' into master_saas

yuanliang 2 jaren geleden
bovenliggende
commit
93eeeb155c

+ 11 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseShareDao.java

@@ -1,10 +1,14 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ym.mec.biz.dal.dto.StudentManageListDto;
 import com.ym.mec.biz.dal.entity.CourseShare;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface CourseShareDao extends BaseDAO<Integer, CourseShare> {
 
@@ -25,5 +29,11 @@ public interface CourseShareDao extends BaseDAO<Integer, CourseShare> {
      * @param studentId        用户id
      * @param courseScheduleId 课程id
      */
-    CourseShare getByUserIdAndCourseId(@Param("studentId") Integer studentId, @Param("courseScheduleId") Integer courseScheduleId);
+    CourseShare getByUserIdAndCourseId(@Param("studentId") Integer studentId,
+                                       @Param("courseScheduleId") Integer courseScheduleId);
+
+    <T> IPage<T> selectStudentByParam(Page<StudentManageListDto> page, @Param("param") Map<String, Object> param);
+
+    <T> List<T> selectStudentByParam(@Param("param") Map<String, Object> param);
+
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SysUserDto.java

@@ -2,7 +2,7 @@ package com.ym.mec.biz.dal.dto;
 
 import io.swagger.annotations.ApiModelProperty;
 
-public class SysUserDto {
+public class    SysUserDto {
     @ApiModelProperty(value = "用户ID")
     private Long userId;
 

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/CourseShareQueryInfo.java

@@ -21,4 +21,19 @@ public class CourseShareQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "课程编号")
     private Long courseId;
 
+    @ApiModelProperty(value = "查询条件")
+    private String search;
+
+    @ApiModelProperty(value = "声部ID")
+    private String subjectId;
+
+    @ApiModelProperty(value = "分部ID,多个逗号隔开")
+    private String organIds;
+
+    @ApiModelProperty(value = "群聊ID")
+    private String groupIds;
+
+    @ApiModelProperty(value = "学校ID")
+    private String schoolIds;
+
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseShareService.java

@@ -28,4 +28,6 @@ public interface CourseShareService extends BaseService<Integer, CourseShare> {
      * @return
      */
     CourseShare getByUserIdAndCourseId(Integer studentId, Integer courseScheduleId);
+
+    PageInfo<StudentManageListDto> queryAllCourseShareStudent(CourseShareQueryInfo shareQueryInfo);
 }

+ 24 - 55
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseShareServiceImpl.java

@@ -1,23 +1,20 @@
 package com.ym.mec.biz.service.impl;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.CourseScheduleDao;
 import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
 import com.ym.mec.biz.dal.dao.CourseShareDao;
-import com.ym.mec.biz.dal.dao.ImLiveRoomPurviewDao;
 import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.StudentManageDao;
-import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dto.CourseShareDto;
 import com.ym.mec.biz.dal.dto.StudentManageListDto;
-import com.ym.mec.biz.dal.dto.SysUserDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.dal.entity.CourseShare;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.Student;
-import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.enums.JoinCourseType;
 import com.ym.mec.biz.dal.page.CourseShareQueryInfo;
 import com.ym.mec.biz.service.CourseShareService;
@@ -26,11 +23,11 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.filters.TenantIdThreadLocal;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.excel.POIUtil;
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,12 +80,6 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
     @Autowired
     private OrganizationDao organizationDao;
 
-    @Autowired
-    private ImLiveRoomPurviewDao imLiveRoomPurviewDao;
-
-    @Autowired
-    private SubjectDao subjectDao;
-
     private static final List<String> STUDENT_TEMPLATE_FIELDS = Arrays.asList("分部", "学生姓名", "手机号");
 
     @Override
@@ -105,11 +96,11 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         MapUtil.populateMap(params, courseShareDto);
         List<Integer> userIds = courseShareDto.getUserIds();
         if (params.keySet().isEmpty() && CollectionUtils.isEmpty(userIds)) {
-            throw new BizException("未选择参数");
+            throw new BizException("未选择搜索条件");
         }
-        List<SysUserDto> studentList = imLiveRoomPurviewDao.selectRoomPurviewStudent(params);
+        List<StudentManageListDto> studentList = courseShareDao.selectStudentByParam(params);
         List<Integer> userIdList = studentList.stream()
-                .map(SysUserDto::getUserId).map(Long::intValue).distinct().collect(Collectors.toList());
+                .map(StudentManageListDto::getUserId).distinct().collect(Collectors.toList());
         if (CollectionUtils.isNotEmpty(userIds)) {
             userIds.forEach(next -> {
                 if (!userIdList.contains(next)) {
@@ -150,46 +141,24 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
     @Override
     public PageInfo<StudentManageListDto> queryCourseSharedStudent(CourseShareQueryInfo shareQueryInfo) {
         CourseSchedule courseSchedule = getCourseScheduleById(shareQueryInfo.getCourseId());
-        PageInfo<StudentManageListDto> pageInfo = new PageInfo<>(shareQueryInfo.getPage(), shareQueryInfo.getRows());
         // 查询该课程已经分享的学生列表
-        Map<String, Object> courseParam = new HashMap<>(2);
-        courseParam.put("courseId", shareQueryInfo.getCourseId());
-        courseParam.put(TENANT_ID, courseSchedule.getTenantId());
-        List<CourseShare> courseShareRecords = courseShareDao.findAll(courseParam);
-        if (CollectionUtils.isEmpty(courseShareRecords)) {
-            pageInfo.setTotal(0);
-            pageInfo.setRows(new ArrayList<>());
-            return pageInfo;
-        }
-
-        // 查询学生列表
-        Map<String, Object> param = new HashMap<>(2);
+        Map<String, Object> param = new HashMap<>();
+        MapUtil.populateMap(param, shareQueryInfo);
         param.put(TENANT_ID, courseSchedule.getTenantId());
+        param.put("inExist", 1);
+        Page<StudentManageListDto> pageInfo = PageUtil.getPageInfo(param);
+        return PageUtil.pageInfo(courseShareDao.selectStudentByParam(pageInfo, param));
+    }
+
+    @Override
+    public PageInfo<StudentManageListDto> queryAllCourseShareStudent(CourseShareQueryInfo shareQueryInfo) {
+        CourseSchedule courseSchedule = getCourseScheduleById(shareQueryInfo.getCourseId());
+        // 查询所有未分享的学生
+        Map<String, Object> param = new HashMap<>();
         MapUtil.populateMap(param, shareQueryInfo);
-        param.put("userIds", courseShareRecords.stream().map(CourseShare::getUserId).toArray());
-        int count = studentManageDao.countStudentByOrganId(param);
-        pageInfo.setTotal(count);
-        if (count == 0) {
-            pageInfo.setRows(new ArrayList<>());
-            return pageInfo;
-        }
-        param.put("offset", pageInfo.getOffset());
-        List<StudentManageListDto> studentManageListDtos = studentManageDao.findStudentsByOrganId(param);
-        List<Subject> subjects = subjectDao.findAll(new HashMap<>());
-        Map<Integer, String> subjectIdNameMap = subjects.stream()
-                .collect(Collectors.toMap(Subject::getId, Subject::getName));
-        for (StudentManageListDto next : studentManageListDtos) {
-            String subjectIdList = next.getSubjectIdList();
-            if (StringUtils.isEmpty(subjectIdList)) {
-                continue;
-            }
-            List<String> subjectNames = Arrays.stream(subjectIdList.split(","))
-                    .map(id -> subjectIdNameMap.getOrDefault(Integer.valueOf(id), "")).distinct()
-                    .collect(Collectors.toList());
-            next.setSubjectName(String.join(",", subjectNames));
-        }
-        pageInfo.setRows(studentManageListDtos);
-        return pageInfo;
+        param.put(TENANT_ID, courseSchedule.getTenantId());
+        Page<StudentManageListDto> pageInfo = PageUtil.getPageInfo(param);
+        return PageUtil.pageInfo(courseShareDao.selectStudentByParam(pageInfo, param));
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -353,7 +322,7 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         }
         Object orgName = row.get(STUDENT_TEMPLATE_FIELDS.get(0));
         if (Objects.isNull(orgName) || !orgNames.contains(orgName.toString().trim())) {
-            rowIndexMsg.put(currentRowIndex, String.format("第%s行分部数据格式错误或者所属分部不存在%n", currentRowIndex));
+            rowIndexMsg.put(currentRowIndex, String.format("第%s行分部数据格式错误或者所属分部不存在", currentRowIndex));
         } else {
             student.setOrganName(orgName.toString().trim());
         }
@@ -361,19 +330,19 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         if (Objects.nonNull(studentName)) {
             student.setUsername(studentName.toString().trim());
         } else {
-            rowIndexMsg.put(currentRowIndex, String.format("第%s行学生姓名数据格式错误%n", currentRowIndex));
+            rowIndexMsg.put(currentRowIndex, String.format("第%s行学生姓名数据格式错误", currentRowIndex));
         }
         Object phoneNo = row.get(STUDENT_TEMPLATE_FIELDS.get(2));
         if (Objects.nonNull(phoneNo)) {
             String phone = phoneNo.toString().trim();
             if (phoneNos.contains(phone)) {
-                rowIndexMsg.put(currentRowIndex, String.format("第%s行手机号重复%n", currentRowIndex));
+                rowIndexMsg.put(currentRowIndex, String.format("第%s行手机号重复", currentRowIndex));
                 return null;
             }
             student.setPhone(phone);
             phoneNos.add(phone);
         } else {
-            rowIndexMsg.put(currentRowIndex, String.format("第%s行手机号数据格式错误%n", currentRowIndex));
+            rowIndexMsg.put(currentRowIndex, String.format("第%s行手机号数据格式错误", currentRowIndex));
         }
         return student;
     }

+ 83 - 0
mec-biz/src/main/resources/config/mybatis/CourseShareMapper.xml

@@ -81,6 +81,89 @@
         where course_id_ = #{courseId}
     </select>
 
+    <select id="selectStudentByParam"  parameterType="map" resultType="com.ym.mec.biz.dal.dto.StudentManageListDto">
+        SELECT distinct
+        s.user_id_ userId,
+        su.username_ username,
+        su.phone_ phone,
+        o.name_ organName,
+        co.name_ cooperationOrganName,
+        sb.name_ subjectName
+        FROM student s
+        <choose>
+            <when test="param.groupIds != null and param.groupIds.trim() != ''">
+                INNER JOIN
+            </when>
+            <otherwise>
+                LEFT JOIN
+            </otherwise>
+        </choose>
+        (select
+        b.user_id_,
+        replace(group_concat(a.name_,'|'),',','') imGroupName,
+        group_concat( a.id_ ) as im_group_id_
+        from im_group a
+        left join im_group_member b on a.id_ = b.im_group_id_
+        <where>
+            <if test="param.groupIds != null and param.groupIds.trim() != ''">
+                and find_in_set(a.id_, #{param.groupIds})
+            </if>
+        </where>
+        group by b.user_id_) gm on s.user_id_ = gm.user_id_
+        LEFT JOIN sys_user su ON su.id_ = s.user_id_
+        LEFT JOIN organization o ON o.id_ = su.organ_id_
+        LEFT JOIN `subject` sb ON sb.id_ = s.subject_id_list_
+        LEFT JOIN cooperation_organ co on co.organ_id_ = o.id_
+        <choose>
+            <when test="param.teamIds != null and param.teamIds.trim != ''">
+                INNER JOIN
+            </when>
+            <otherwise>
+                LEFT JOIN
+            </otherwise>
+        </choose>
+        (select
+        user_id_,
+        replace(group_concat(a.name_,'|'),',','') musicGroupName
+        from
+        music_group a left join
+        student_registration b on a.id_ = b.music_group_id_
+        where b.music_group_status_ != 'QUIT'
+        <if test="param.teamIds != null and param.teamIds.trim() != ''">
+            and find_in_set(a.id_ ,#{param.teamIds})
+        </if>
+        group by b.user_id_) sr on sr.user_id_ = s.user_id_
+        <where>
+            <if test="param.tenantId != null ">
+                AND s.tenant_id_ = #{param.tenantId}
+            </if>
+            <choose>
+                <when test="param.inExist != null ">
+                    AND s.user_id_ in (select user_id_ from course_share where course_id_ = #{param.courseId})
+                </when>
+                <otherwise>
+                    AND s.user_id_ not in (select user_id_ from course_share where course_id_ = #{param.courseId})
+                </otherwise>
+            </choose>
+            <if test="param.organIds != null and param.organIds.trim() != ''">
+                AND FIND_IN_SET(su.organ_id_,#{param.organIds})
+            </if>
+            <if test="param.subjectId != null and param.subjectId.trim() != ''">
+                AND FIND_IN_SET(s.subject_id_list_,#{param.subjectId})
+            </if>
+            <if test="param.schoolIds != null and param.schoolIds.trim() != ''">
+                AND FIND_IN_SET(s.cooperation_organ_id_ ,#{param.schoolIds})
+            </if>
+            <if test="param.search != null and param.search.trim() != ''">
+                AND (
+                s.`user_id_` LIKE CONCAT('%', #{param.search},'%')
+                or su.phone_ like concat('%',#{param.search},'%')
+                or su.username_ like concat('%',#{param.search},'%')
+                )
+            </if>
+        </where>
+    </select>
+
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
         INSERT INTO course_share (id_, course_id_, user_id_, create_time_, create_by_, tenant_id_)
         VALUES

+ 9 - 1
mec-web/src/main/java/com/ym/mec/web/controller/CourseShareController.java

@@ -49,10 +49,18 @@ public class CourseShareController extends BaseController {
     @GetMapping("/queryCourseSharedStudent")
     @PreAuthorize("@pcs.hasPermissions('courseShare/queryCourseSharedStudent')")
     public HttpResponseResult<PageInfo<StudentManageListDto>> queryCourseSharedStudent(
-            CourseShareQueryInfo shareQueryInfo) {
+            @Validated CourseShareQueryInfo shareQueryInfo) {
         return succeed(courseShareService.queryCourseSharedStudent(shareQueryInfo));
     }
 
+    @ApiOperation(value = "查询已经分享过的学生")
+    @GetMapping("/queryAllCourseShareStudent")
+    @PreAuthorize("@pcs.hasPermissions('courseShare/queryAllCourseShareStudent')")
+    public HttpResponseResult<PageInfo<StudentManageListDto>> queryAllCourseShareStudent(
+            @Validated CourseShareQueryInfo shareQueryInfo) {
+        return succeed(courseShareService.queryAllCourseShareStudent(shareQueryInfo));
+    }
+
     @ApiOperation(value = "导入学员")
     @PostMapping(value = "/importStudent")
     @PreAuthorize("@pcs.hasPermissions('courseShare/importStudent')")