|
@@ -1,7 +1,9 @@
|
|
|
package com.fs.im.service.impl;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
@@ -11,6 +13,9 @@ import com.fs.course.dto.BatchSendCourseAllDTO;
|
|
|
import com.fs.course.vo.newfs.FsImSendLogVO;
|
|
|
import com.fs.im.domain.FsImMsgSendDetail;
|
|
|
import com.fs.im.mapper.FsImMsgSendDetailMapper;
|
|
|
+import com.fs.im.vo.FsImMsgSendDetailVO;
|
|
|
+import com.fs.im.vo.FsImMsgSendLogVO;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -131,34 +136,58 @@ public class FsImMsgSendLogServiceImpl extends ServiceImpl<FsImMsgSendLogMapper,
|
|
|
if(fsImMsgSendLog.getSendStatus() == 1){
|
|
|
return ResponseResult.fail(400, "当前任务已完成,不允许删除");
|
|
|
}
|
|
|
- baseMapper.deleteFsImMsgSendLogByLogId(logId);
|
|
|
+
|
|
|
+ // 删除数据
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("send_union_id", fsImMsgSendLog.getSendUnionId());
|
|
|
+ List<FsImMsgSendLog> fsImMsgSendLogs = baseMapper.selectByMap(map);
|
|
|
+ List<Long> logIds = fsImMsgSendLogs.stream().map(FsImMsgSendLog::getLogId).collect(Collectors.toList());
|
|
|
+ baseMapper.deleteBatchIds(logIds);
|
|
|
|
|
|
fsImMsgSendDetailMapper.delete(Wrappers.<FsImMsgSendDetail>query().lambda()
|
|
|
- .eq(FsImMsgSendDetail::getLogId, fsImMsgSendLog.getLogId()));
|
|
|
+ .in(FsImMsgSendDetail::getLogId, logIds));
|
|
|
|
|
|
// 删除redis缓存
|
|
|
- if(fsImMsgSendLog.getMsgType() == 1){
|
|
|
- String redisKey = "openIm:batchSendMsg:sendCourse";
|
|
|
- Map<String, BatchSendCourseAllDTO> cacheMap = redisCache.getCacheMap(redisKey);
|
|
|
+// if(fsImMsgSendLog.getMsgType() == 1){
|
|
|
+ String sendCourseRedisKey = "openIm:batchSendMsg:sendCourse";
|
|
|
+ Map<String, BatchSendCourseAllDTO> sendCourseMap = redisCache.getCacheMap(sendCourseRedisKey);
|
|
|
|
|
|
- if(cacheMap != null && !cacheMap.isEmpty()){
|
|
|
+ if(sendCourseMap != null && !sendCourseMap.isEmpty()){
|
|
|
// 组合key
|
|
|
if(fsImMsgSendLog.getPlanSendTime() != null) {
|
|
|
String key = fsImMsgSendLog.getCourseId() + ":" + fsImMsgSendLog.getVideoId() + ":" + fsImMsgSendLog.getPlanSendTime().getTime();
|
|
|
- redisTemplate.opsForHash().delete(redisKey, key);
|
|
|
+ redisTemplate.opsForHash().delete(sendCourseRedisKey, key);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- String redisKey = "openIm:batchSendMsg:urgeCourse";
|
|
|
- Map<String, BatchSendCourseAllDTO> cacheMap = redisCache.getCacheMap(redisKey);
|
|
|
- if(cacheMap != null && !cacheMap.isEmpty()){
|
|
|
+// } else {
|
|
|
+ String urgeCourseRedisKey = "openIm:batchSendMsg:urgeCourse";
|
|
|
+ Map<String, BatchSendCourseAllDTO> urgeCourseMap = redisCache.getCacheMap(urgeCourseRedisKey);
|
|
|
+ if(urgeCourseMap != null && !urgeCourseMap.isEmpty()){
|
|
|
// 组合key
|
|
|
- if(fsImMsgSendLog.getPlanSendTime() != null) {
|
|
|
- String key = fsImMsgSendLog.getCourseId() + ":" + fsImMsgSendLog.getVideoId() + ":" + fsImMsgSendLog.getPlanSendTime().getTime();
|
|
|
- redisTemplate.opsForHash().delete(redisKey, key);
|
|
|
+ for (FsImMsgSendLog imMsgSendLog : fsImMsgSendLogs) {
|
|
|
+ if(imMsgSendLog.getPlanSendTime() != null && imMsgSendLog.getMsgType() == 2) {
|
|
|
+ String key = imMsgSendLog.getCourseId() + ":" + imMsgSendLog.getVideoId() + ":" + imMsgSendLog.getPlanSendTime().getTime();
|
|
|
+ redisTemplate.opsForHash().delete(urgeCourseRedisKey, key);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+// }
|
|
|
return ResponseResult.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FsImMsgSendLogVO selectFsImMsgSendLogDetail(Long logId) {
|
|
|
+ FsImMsgSendLog fsImMsgSendLog = baseMapper.selectFsImMsgSendLogByLogId(logId);
|
|
|
+ FsImMsgSendLogVO fsImMsgSendLogVO = new FsImMsgSendLogVO();
|
|
|
+ BeanUtils.copyProperties(fsImMsgSendLog, fsImMsgSendLogVO);
|
|
|
+
|
|
|
+ List<FsImMsgSendLog> fsImMsgSendLogs = baseMapper.selectList(Wrappers.<FsImMsgSendLog>query().lambda()
|
|
|
+ .eq(FsImMsgSendLog::getSendUnionId, fsImMsgSendLog.getSendUnionId()).eq(FsImMsgSendLog::getMsgType,2));
|
|
|
+ List<String> urgeContents = fsImMsgSendLogs.stream().map(FsImMsgSendLog::getSendTitle).collect(Collectors.toList());
|
|
|
+ fsImMsgSendLogVO.setUrgeContent(urgeContents);
|
|
|
+
|
|
|
+ List<FsImMsgSendDetailVO> fsImMsgSendDetails = fsImMsgSendDetailMapper.selectSendDetailVOList(logId);
|
|
|
+ fsImMsgSendLogVO.setDetailList(fsImMsgSendDetails);
|
|
|
+ return fsImMsgSendLogVO;
|
|
|
+ }
|
|
|
}
|