Jelajahi Sumber

Merge remote-tracking branch 'origin/master_saas' into master_saas

zouxuan 2 tahun lalu
induk
melakukan
24a1e4a48b

+ 23 - 18
mec-biz/pom.xml

@@ -13,7 +13,7 @@
 	<url>http://maven.apache.org</url>
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <redisson.version>3.16.4</redisson.version>
+		<redisson.version>3.16.4</redisson.version>
 	</properties>
 
 	<dependencies>
@@ -26,31 +26,31 @@
 			<groupId>com.ym</groupId>
 			<artifactId>mec-auth-api</artifactId>
 		</dependency>
-        <dependency>
-            <groupId>com.ym</groupId>
-            <artifactId>mec-client-api</artifactId>
-        </dependency>
+		<dependency>
+			<groupId>com.ym</groupId>
+			<artifactId>mec-client-api</artifactId>
+		</dependency>
 
 		<dependency>
 			<groupId>com.ym</groupId>
 			<artifactId>mec-thirdparty</artifactId>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>com.ym</groupId>
 			<artifactId>snakerflowy</artifactId>
 		</dependency>
 
-        <dependency>
-            <groupId>org.redisson</groupId>
-            <artifactId>redisson-spring-boot-starter</artifactId>
-            <version>${redisson.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>net.coobird</groupId>
-            <artifactId>thumbnailator</artifactId>
-            <version>0.4.11</version>
-        </dependency>
+		<dependency>
+			<groupId>org.redisson</groupId>
+			<artifactId>redisson-spring-boot-starter</artifactId>
+			<version>${redisson.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>net.coobird</groupId>
+			<artifactId>thumbnailator</artifactId>
+			<version>0.4.11</version>
+		</dependency>
 
 		<dependency>
 			<groupId>com.microsvc.toolkit.middleware</groupId>
@@ -62,6 +62,11 @@
 			<artifactId>microsvc-common-response</artifactId>
 			<version>1.0.0</version>
 		</dependency>
+		<dependency>
+			<groupId>com.microsvc.toolkit.middleware</groupId>
+			<artifactId>microsvc-middleware-rtc</artifactId>
+			<version>1.0.0</version>
+		</dependency>
 
 		<!--修复依赖冲突-->
 		<dependency>
@@ -69,5 +74,5 @@
 			<artifactId>kotlin-stdlib</artifactId>
 		</dependency>
 
-    </dependencies>
-</project>
+	</dependencies>
+</project>

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentCourseHomeworkDao.java

@@ -216,4 +216,6 @@ public interface StudentCourseHomeworkDao extends BaseDAO<Long, StudentCourseHom
 
     StudentCourseHomework getHomeworkByUserIdAndCourseHomeworkId(@Param("userId") Long userId, @Param(
         "courseHomeworkId") Long courseHomeworkId);
+
+    int queryNotSuccessExtraHomeworkList2(@Param("userId") Integer userId);
 }

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

@@ -177,7 +177,7 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
             Integer studentId = extracurricularExercisesReply.getUserId();
             if (exercises.getVersionTag().equals("v2")) {
 
-                String notifyUrl = "homeworkId=" + exercises.getId() + "&type=" +exercises.getGroupType();
+                String notifyUrl = "homeworkId=" + exercises.getId() + "&homeworkType=" +exercises.getGroupType();
                 String extra = "dayaedu?type=homework&" + notifyUrl ;
                 sysMessageService.batchSendImMessage(MessageTypeEnum.EXTRA_REMIND_IM_DETAIL_V2, exercises.getTeacherId().toString(), extra,
                         new String[]{studentId.toString()},

+ 4 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java

@@ -362,7 +362,7 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         List<StudentCourseHomework> list = studentCourseHomeworkDao.queryNotDoneHomeworkList();
         StringBuffer sb;
         for (StudentCourseHomework sch : list) {
-            sb = new StringBuffer("homeworkId=").append(sch.getCourseScheduleId()).append("&type=HOMEWORK");
+            sb = new StringBuffer("homeworkId=").append(sch.getCourseScheduleId()).append("&homeworkType=HOMEWORK");
             Map<Integer, String> receivers = new HashMap<Integer, String>(1);
             receivers.put(sch.getUserId(), sch.getUserId() + "");
             sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_JOB_MESSAGE_V2, receivers, null, 0, "homework?" + sb, "STUDENT");
@@ -372,7 +372,7 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         List<ExtracurricularExercisesReply> extraList =  extracurricularExercisesReplyDao.queryNotDoneHomeworkList();
         for (ExtracurricularExercisesReply reply : extraList) {
             sb = new StringBuffer("homeworkId=").append(reply.getExtracurricularExercisesId())
-                    .append("&type=")
+                    .append("&homeworkType=")
                     .append(reply.getExtracurricularExercises().getGroupType());
             Map<Integer, String> receivers = new HashMap<Integer, String>(1);
             receivers.put(reply.getUserId(), reply.getUserId() + "");
@@ -1122,7 +1122,7 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         StringBuffer sb;
         for (CourseHomeworkListDto courseHomework : courseHomeworks) {
             sb = new StringBuffer("homeworkId=").append(courseHomework.getCourseScheduleId())
-                    .append("&type=HOMEWORK");
+                    .append("&homeworkType=HOMEWORK");
             Map<Integer, String> receivers = new HashMap<Integer, String>(1);
             String dateToString = DateUtil.dateToString(courseHomework.getCreateTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
             receivers.put(courseHomework.getTeacherId(), courseHomework.getTeacherId() + "");
@@ -1138,7 +1138,7 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         List<ExtracurricularExercises> extracurricularExercises = extracurricularExercisesDao.findEndHomework();
         for (ExtracurricularExercises exercises : extracurricularExercises) {
             sb = new StringBuffer("homeworkId=").append(exercises.getId())
-                    .append("&type=")
+                    .append("&homeworkType=")
                     .append(exercises.getGroupType());
             Map<Integer, String> receivers = new HashMap<Integer, String>(1);
             String dateToString = DateUtil.dateToString(exercises.getCreateTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);

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

@@ -837,7 +837,7 @@ public class StudentServeServiceImpl implements StudentServeService {
 
         // 作业按钮红点
         int num = studentCourseHomeworkDao.queryNotSuccessHomeworkList(userId);
-
+        num+= studentCourseHomeworkDao.queryNotSuccessExtraHomeworkList2(userId);
         HomeworkStat homeworkStat = new HomeworkStat();
         homeworkStat.setType("HOMEWORK");
         homeworkStatList.add(homeworkStat);

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

@@ -439,7 +439,7 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
                             if (versionTag.equals("v2")) {
                                 Map<Integer, String> userMap = new HashMap<>();
                                 userMap.put(studentCourseHomework.getUserId(), studentCourseHomework.getUserId().toString());
-                                String notifyUrl = "homeworkId=" + courseHomework.getCourseScheduleId() + "&type=" + ELessonTrainingType.HOMEWORK.getCode();
+                                String notifyUrl = "homeworkId=" + courseHomework.getCourseScheduleId() + "&homeworkType=" + ELessonTrainingType.HOMEWORK.getCode();
                                 String extra = "dayaedu?type=homework&" + notifyUrl ;
 
                                 sysMessageService.batchSendImMessage(MessageTypeEnum.IM_HOMEWORK_REMIND_V2, courseSchedule.getActualTeacherId().toString(), extra,

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

@@ -365,7 +365,7 @@
         <if test="versionTag != null">
             and version_tag_ = #{versionTag}
         </if>
-        <if test="musicGroupId != null">
+        <if test="musicGroupId!=null and musicGroupId!=''">
             and music_group_id_ = #{musicGroupId}
         </if>
 	</sql>

+ 15 - 1
mec-biz/src/main/resources/config/mybatis/StudentCourseHomeworkMapper.xml

@@ -732,7 +732,8 @@
         WHERE
             sch.user_id_ = #{userId}
                 AND (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
-        and ch.expiry_date_ &gt;= #{now}
+        and ch.expiry_date_ &gt;= now()
+        and ch.version_tag_ = 'v2'
     </select>
 
     <select id="getHomeworkByUserIdAndCourseHomeworkId" resultMap="StudentCourseHomework">
@@ -759,4 +760,17 @@
                 AND (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
             and ch.version_tag_ = 'v2'
     </select>
+
+    <select id="queryNotSuccessExtraHomeworkList2" resultType="int">
+        SELECT
+            count(ee.id_)
+        FROM
+            extracurricular_exercises ee
+        left join extracurricular_exercises_reply eer on eer.extracurricular_exercises_id_ = ee.id_
+        WHERE
+        eer.user_id_ = #{userId}
+                AND (eer.standard_flag_ not in ('STANDARD','EXCELLENT') or eer.standard_flag_ is null)
+            and ee.expire_date_ &gt;= now()
+            and ee.version_tag_ = 'v2'
+    </select>
 </mapper>

+ 21 - 0
mec-im/src/main/java/com/ym/pojo/RoomResult.java

@@ -2,7 +2,9 @@ package com.ym.pojo;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.microsvc.toolkit.middleware.rtc.message.RTCRoomConfig;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Getter;
 import lombok.Setter;
@@ -35,6 +37,23 @@ public class RoomResult {
     private @Getter @Setter MemberResult userInfo;
     private @Getter @Setter String randomNumeric = "0";
 
+    @ApiModelProperty("RTC接入参数")
+    private @Getter @Setter RTCRoomConfig rtcRoomConfig;
+    @ApiModelProperty("直播间用户签名")
+    private @Getter @Setter String userSig;
+    @ApiModelProperty("群组id")
+    private @Getter @Setter String groupId;
+
+    public RoomResult rtcRoomConfig(RTCRoomConfig rtcRoomConfig) {
+        this.rtcRoomConfig = rtcRoomConfig;
+        return this;
+    }
+
+    public RoomResult userSig(String userSig) {
+        this.userSig = userSig;
+        return this;
+    }
+
     @Data
     public static class MemberResult {
         String userId;
@@ -93,4 +112,6 @@ public class RoomResult {
             whiteboards.add(r);
         }
     }
+
+
 }

+ 57 - 1
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -3,6 +3,9 @@ package com.ym.service.Impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginContext;
+import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginService;
+import com.microsvc.toolkit.middleware.rtc.impl.TencentCloudRTCPlugin;
 import com.ym.common.ApiException;
 import com.ym.common.BaseResponse;
 import com.ym.common.DisplayEnum;
@@ -105,6 +108,8 @@ public class RoomServiceImpl implements RoomService {
     private TenantAssetsInfoService tenantAssetsInfoService;
     @Autowired
     private RedisTemplate<String, String> redisTemplate;
+    @Autowired
+    private RTCRoomPluginContext rtcRoomPluginContext;
 
     @Override
     public Integer getCurrentCourseId(String roomId) {
@@ -247,7 +252,58 @@ public class RoomServiceImpl implements RoomService {
             userResult.setJoinTime(member.getJoinDt());
         }
 //        imHelper.joinGroup(new String[]{userId}, roomId, roomId);
-        this.joinImGroup(roomId,courseSchedule.getActualTeacherId());
+
+        // 获取RTC服务提供方
+        String rtcServiceProvider = Optional.ofNullable(sysConfigDao.findConfigValue("rtc_service_provider")).orElse("rongCloud");
+
+        RTCRoomPluginService pluginService = rtcRoomPluginContext.getPluginService(rtcServiceProvider);
+        if (TencentCloudRTCPlugin.PLUGIN_NAME.equals(rtcServiceProvider)) {
+            // 腾讯云RTC
+            // 用户IM帐号创建
+            String userSig = "";
+            try {
+                userSig = pluginService.register(String.valueOf(sysUser.getId()), sysUser.getUsername(), sysUser.getAvatar());
+            } catch (Exception e) {
+                log.error("直播房间用户注册失败: userId={}", sysUser.getId(), e);
+            }
+
+            // 主讲老师信息
+            SysUser teacherInfo = sysUserFeignService.queryUserById(courseSchedule.getActualTeacherId());
+            if (Objects.isNull(teacherInfo)) {
+                throw new BizException("主讲老师不存在");
+            }
+
+            String joinImGroupKey = "joinImGroup:" + roomId;
+            // VIP课或网络课,IM群聊已创建标识
+            Boolean exists = redisTemplate.opsForValue().setIfAbsent(joinImGroupKey, roomId, 1L, TimeUnit.DAYS);
+
+            // 缓存RTC服务提供方
+            String rtcRoomPluginKey = "rtcRoomPlugin:" + roomId;
+            redisTemplate.opsForValue().setIfAbsent(rtcRoomPluginKey, pluginService.pluginName(), 1L, TimeUnit.DAYS);
+
+            if (Optional.ofNullable(exists).orElse(false)) {
+                // 创建群组
+                log.info("createImGroup: roomId = {}, userId = {}", roomId, teacherInfo.getId());
+                pluginService.chatRoomCreate(roomId, courseSchedule.getName(), teacherInfo.getAvatar());
+
+                List<CourseScheduleStudentPayment> payments = courseScheduleStudentPaymentDao.findByCourseSchedule(Long.parseLong(roomId.substring(1)));
+                // 学生信息
+                List<String> collect = payments.stream().map(e -> e.getUserId().toString()).collect(Collectors.toList());
+                // 老师信息
+                collect.add(teacherInfo.getId().toString());
+                // 加入群组成员
+                log.info("joinImGroup: roomId = {}, userIds = {}", roomId, collect);
+            }
+
+            // 返回配置参数
+            roomResult.userSig(userSig)
+                    .rtcRoomConfig(rtcRoomPluginContext.getPluginService().getRTCRoomConfig(String.valueOf(sysUser.getId())))
+                    .setGroupId(roomId);
+        } else {
+            // 融云RTC
+            // 创建IM群聊
+            this.joinImGroup(roomId, courseSchedule.getActualTeacherId());
+        }
 
         List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(null, courseId, null, null, null);
         Room room = roomDao.findByRid(roomId);

+ 1 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java

@@ -70,6 +70,7 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @ApiOperation("后台-分页查询直播间列表")
     @PostMapping("/queryPage")
     public HttpResponseResult<PageInfo<ImLiveBroadcastRoomVo>> queryPage(@RequestBody Map<String, Object> param) {
+        param.put("sort",1);
         return succeed(imLiveBroadcastRoomService.queryPage(param));
     }
 

+ 0 - 16
mec-web/src/main/resources/bootstrap-local.properties

@@ -1,16 +0,0 @@
-#\u6307\u5b9a\u5f00\u53d1\u73af\u5883
-#spring.profiles.active=dev
-#\u670d\u52a1\u5668\u5730\u5740
-spring.cloud.nacos.config.server-addr=43.137.4.92:8848
-#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
-spring.cloud.nacos.config.namespace=fcc00e52-a464-4ab8-96aa-3469b3f66062
-#\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e
-spring.cloud.nacos.config.group=DEFAULT_GROUP
-#\u6587\u4ef6\u540d -- \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u9ed8\u8ba4\u4e3a ${spring.appliction.name}
-spring.cloud.nacos.config.prefix=web
-#\u6307\u5b9a\u6587\u4ef6\u540e\u7f00
-spring.cloud.nacos.config.file-extension=yaml
-#\u662f\u5426\u52a8\u6001\u5237\u65b0
-spring.cloud.nacos.config.refresh.enabled=true
-#\u662f\u5426\u542f\u7528nacos\u914d\u7f6e\u4e2d\u5fc3
-spring.cloud.nacos.config.enabled=true