|
|
@@ -26,6 +26,7 @@ import com.fs.course.dto.BatchUrgeCourseDTO;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
+import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.fastGpt.service.AiHookService;
|
|
|
import com.fs.his.domain.FsDoctor;
|
|
|
import com.fs.his.domain.FsFollow;
|
|
|
@@ -1631,14 +1632,37 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
List<Long> rawUserIds = userIds.stream()
|
|
|
.map(id -> Long.parseLong(id.substring(1)))
|
|
|
.collect(Collectors.toList());
|
|
|
- Set<Long> duplicateUserIds = new HashSet<>(
|
|
|
- fsUserCourseMapper.selectUserIdsWithTodayCourseWatchLog(rawUserIds, project, batchSendCourseDTO.getVideoId()));
|
|
|
- if (!duplicateUserIds.isEmpty()) {
|
|
|
+
|
|
|
+ // 确定查询日期:有 sendTime 用 sendTime,否则今天
|
|
|
+ Date checkDate = batchSendCourseDTO.getSendTime() != null ? batchSendCourseDTO.getSendTime() : new Date();
|
|
|
+ String startDate = DateUtils.parseDateToStr("yyyy-MM-dd 00:00:00", checkDate);
|
|
|
+ String endDate = DateUtils.parseDateToStr("yyyy-MM-dd 23:59:59", checkDate);
|
|
|
+ String todayStr = DateUtils.parseDateToStr("yyyy-MM-dd", new Date());
|
|
|
+ String checkDateStr = DateUtils.parseDateToStr("yyyy-MM-dd", checkDate);
|
|
|
+ boolean isToday = todayStr.equals(checkDateStr);
|
|
|
+
|
|
|
+ Set<Long> allDuplicates;
|
|
|
+ String failReason;
|
|
|
+ if (isToday) {
|
|
|
+ // 当天发课:只看课记录
|
|
|
+ allDuplicates = new HashSet<>(
|
|
|
+ fsUserCourseMapper.selectUserIdsWithTodayCourseWatchLog(
|
|
|
+ rawUserIds, project, batchSendCourseDTO.getVideoId(), startDate, endDate));
|
|
|
+ failReason = "同一项目当天已发过课程";
|
|
|
+ } else {
|
|
|
+ // 第二天及以后:查待发送/已发送的IM任务(看课记录还没产生)
|
|
|
+ allDuplicates = new HashSet<>(
|
|
|
+ fsImMsgSendDetailMapper.selectUserIdsWithPendingSendForProject(
|
|
|
+ rawUserIds, project, batchSendCourseDTO.getVideoId(), startDate, endDate));
|
|
|
+ failReason = "该用户在此项目已有相同日期的待发送课程";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!allDuplicates.isEmpty()) {
|
|
|
List<String> filtered = userIds.stream()
|
|
|
- .filter(uid -> duplicateUserIds.contains(Long.parseLong(uid.substring(1))))
|
|
|
+ .filter(uid -> allDuplicates.contains(Long.parseLong(uid.substring(1))))
|
|
|
.collect(Collectors.toList());
|
|
|
userIds.removeAll(filtered);
|
|
|
- createFailedCourseSendDetail(batchSendCourseDTO, filtered, "同一项目当天已发送过不同课程");
|
|
|
+ createFailedCourseSendDetail(batchSendCourseDTO, filtered, failReason);
|
|
|
}
|
|
|
}
|
|
|
|