|
|
@@ -1173,7 +1173,6 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
return openImResponseDTO;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public OpenImResponseDTO batchSendCourseLimit(BatchSendCourseDTO batchSendCourseDTO) {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
@@ -1285,59 +1284,29 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
// 组装催课消息数据
|
|
|
OpenImBatchMsgDTO openImBatchUrgeCourse = makeOpenImBatchMsgDTO(batchSendCourseDTO, courseUrl, objectMapper, batchUserIds, planSendTimeStamp, "催课");
|
|
|
|
|
|
- //缓存定时催课消息
|
|
|
- int urgSendType;
|
|
|
- if(batchSendCourseDTO.getUrgeTime() != null && batchSendCourseDTO.getUrgeTime().compareTo(new Date()) > 0) {
|
|
|
- urgSendType = 1; //定时
|
|
|
- } else {
|
|
|
- urgSendType = 2; //实时
|
|
|
- }
|
|
|
-
|
|
|
- // 催课也按批次拆分,使用与发课相同的 sendUnionId
|
|
|
- if (urgSendType == 1 && batchUserIds.size() > BATCH_SIZE) {
|
|
|
- log.info("定时催课消息接收人{}人,超过{}人,拆分缓存", batchUserIds.size(), BATCH_SIZE);
|
|
|
-
|
|
|
- // 进一步拆分催课批次(如果必要)
|
|
|
- for (int j = 0; j < batchUserIds.size(); j += BATCH_SIZE) {
|
|
|
- int urgeEnd = Math.min(j + BATCH_SIZE, batchUserIds.size());
|
|
|
- List<String> urgeBatchUserIds = batchUserIds.subList(j, urgeEnd);
|
|
|
+ // 催课使用与发课相同的批次(batchUserIds),不需要再次拆分
|
|
|
+ List<FsImMsgSendDetail> imMsgSendDetailUrgeList = createImMsgSendLog("催课", batchSendCourseDTO, planSendTimeStamp, 1, batchUserIds, sendUnionId);
|
|
|
|
|
|
- OpenImBatchMsgDTO batchUrgeMsgDTO = makeOpenImBatchMsgDTO(batchSendCourseDTO, courseUrl, objectMapper, urgeBatchUserIds, planSendTimeStamp, "催课");
|
|
|
- List<FsImMsgSendDetail> imMsgSendDetailUrgeList = createImMsgSendLog("催课", batchSendCourseDTO, planSendTimeStamp, urgSendType, urgeBatchUserIds, sendUnionId);
|
|
|
+ // 定时催课 - 缓存到 Redis
|
|
|
+ String redisKey = "openIm:batchSendMsg:urgeCourse";
|
|
|
+ Map<String, Object> redisMap = redisCache.getCacheMap(redisKey);
|
|
|
+ if (redisMap == null) {
|
|
|
+ redisMap = new HashMap<>();
|
|
|
+ }
|
|
|
|
|
|
- String redisKey = "openIm:batchSendMsg:urgeCourse";
|
|
|
- Map<String, Object> redisMap = redisCache.getCacheMap(redisKey);
|
|
|
- if (redisMap == null) {
|
|
|
- redisMap = new HashMap<>();
|
|
|
- }
|
|
|
+ BatchSendCourseAllDTO batchSendCourseAllDTO = new BatchSendCourseAllDTO();
|
|
|
+ batchSendCourseAllDTO.setOpenImBatchMsgDTO(openImBatchUrgeCourse)
|
|
|
+ .setImMsgSendDetailList(imMsgSendDetailUrgeList);
|
|
|
|
|
|
- BatchSendCourseAllDTO batchSendCourseAllDTO = new BatchSendCourseAllDTO();
|
|
|
- batchSendCourseAllDTO.setOpenImBatchMsgDTO(batchUrgeMsgDTO)
|
|
|
- .setImMsgSendDetailList(imMsgSendDetailUrgeList);
|
|
|
+ // 使用唯一的 key:课程 ID+ 视频 ID+ 时间戳+logId
|
|
|
+ String batchKey = batchSendCourseDTO.getCourseId() + ":" +
|
|
|
+ batchSendCourseDTO.getVideoId() + ":" +
|
|
|
+ batchSendCourseDTO.getUrgeTime().getTime() + ":" +
|
|
|
+ imMsgSendDetailUrgeList.get(0).getLogId();
|
|
|
|
|
|
- // 使用唯一的 key
|
|
|
- String batchKey = batchSendCourseDTO.getCourseId() + ":" +
|
|
|
- batchSendCourseDTO.getVideoId() + ":" +
|
|
|
- batchSendCourseDTO.getUrgeTime().getTime() + ":" +
|
|
|
- imMsgSendDetailUrgeList.get(0).getLogId();
|
|
|
+ redisMap.put(batchKey, batchSendCourseAllDTO);
|
|
|
+ redisCache.setCacheMap(redisKey, redisMap);
|
|
|
|
|
|
- redisMap.put(batchKey, batchSendCourseAllDTO);
|
|
|
- redisCache.setCacheMap(redisKey, redisMap);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 不超过 100 人或实时发送,按原逻辑,使用与发课相同的 sendUnionId
|
|
|
- List<FsImMsgSendDetail> imMsgSendDetailUrgeList = createImMsgSendLog("催课", batchSendCourseDTO, planSendTimeStamp, urgSendType, batchUserIds, sendUnionId);
|
|
|
- String redisKey = "openIm:batchSendMsg:urgeCourse";
|
|
|
- Map<String, Object> redisMap = new HashMap<>();
|
|
|
- BatchSendCourseAllDTO batchSendCourseAllDTO = new BatchSendCourseAllDTO();
|
|
|
- batchSendCourseAllDTO.setOpenImBatchMsgDTO(openImBatchUrgeCourse)
|
|
|
- .setImMsgSendDetailList(imMsgSendDetailUrgeList);
|
|
|
-
|
|
|
- String batchKey = batchSendCourseDTO.getCourseId()+":"+batchSendCourseDTO.getVideoId()+":"+batchSendCourseDTO.getUrgeTime().getTime()+imMsgSendDetailUrgeList.get(0).getLogId();
|
|
|
-
|
|
|
- redisMap.put(batchKey, batchSendCourseAllDTO);
|
|
|
- redisCache.setCacheMap(redisKey, redisMap);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|