|
@@ -25,6 +25,7 @@ import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import com.mysql.cj.util.StringUtils;
|
|
import com.mysql.cj.util.StringUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
@@ -236,7 +237,6 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<NoticeRulePublishProgressEntity> getToBeDisposedNoticeRulePublishProgressList() {
|
|
public List<NoticeRulePublishProgressEntity> getToBeDisposedNoticeRulePublishProgressList() {
|
|
- List<NoticeRulePublishProgressEntity> resultList = null;
|
|
|
|
List<NoticeEntity> publishingNoticeList = noticeRepo
|
|
List<NoticeEntity> publishingNoticeList = noticeRepo
|
|
.findByNoticeStatus(NoticeStatus.PUBLISHING);
|
|
.findByNoticeStatus(NoticeStatus.PUBLISHING);
|
|
List<NoticeEntity> toBePublishedNoticeList = noticeRepo
|
|
List<NoticeEntity> toBePublishedNoticeList = noticeRepo
|
|
@@ -250,10 +250,10 @@ public class NoticeServiceImpl implements NoticeService {
|
|
noticeIdList.addAll(toBePublishedNoticeList.stream().map(p -> p.getId())
|
|
noticeIdList.addAll(toBePublishedNoticeList.stream().map(p -> p.getId())
|
|
.collect(Collectors.toList()));
|
|
.collect(Collectors.toList()));
|
|
}
|
|
}
|
|
- if (!noticeIdList.isEmpty()) {
|
|
|
|
- resultList = noticeRulePublishProgressRepo.findByNoticeIdIn(noticeIdList);
|
|
|
|
|
|
+ if (noticeIdList.isEmpty()) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- return resultList;
|
|
|
|
|
|
+ return noticeRulePublishProgressRepo.findByNoticeIdIn(noticeIdList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -329,11 +329,27 @@ public class NoticeServiceImpl implements NoticeService {
|
|
// 保存并更新发布状态为发布完成
|
|
// 保存并更新发布状态为发布完成
|
|
List<UserNoticeEntity> userNoticeList = new ArrayList<>();
|
|
List<UserNoticeEntity> userNoticeList = new ArrayList<>();
|
|
for (Long userId : limitStudentIdList) {
|
|
for (Long userId : limitStudentIdList) {
|
|
- UserNoticeEntity userNotice = initUserNoticeEntity(rootOrgId, userId, noticeId,
|
|
|
|
- ruleType);
|
|
|
|
- userNoticeList.add(userNotice);
|
|
|
|
|
|
+ //构建查询条件,判断当前用户是否已发过当前通知
|
|
|
|
+ UserNoticeEntity query = new UserNoticeEntity();
|
|
|
|
+ query.setUserId(userId);
|
|
|
|
+ query.setNoticeId(noticeId);
|
|
|
|
+ UserType userType = (ruleType == NoticeReceiverRuleType.STUDENTS_OF_EXAM
|
|
|
|
+ || ruleType == NoticeReceiverRuleType.ALL_STUDENTS_OF_ROOT_ORG)
|
|
|
|
+ ? UserType.STUDENT
|
|
|
|
+ : UserType.COMMON;
|
|
|
|
+ query.setUserType(userType);
|
|
|
|
+ Example<UserNoticeEntity> queryExample = Example.of(query);
|
|
|
|
+
|
|
|
|
+ //如果用户未发过当前通知,则添加相当通知数据,否则跳过
|
|
|
|
+ if (!userNoticeRepo.exists(queryExample)){
|
|
|
|
+ UserNoticeEntity userNotice = initUserNoticeEntity(rootOrgId, userId, noticeId,
|
|
|
|
+ userType);
|
|
|
|
+ userNoticeList.add(userNotice);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
userNoticeRepo.saveAll(userNoticeList);
|
|
userNoticeRepo.saveAll(userNoticeList);
|
|
|
|
+
|
|
|
|
+ //更新通知通知进度的最大用户id
|
|
rulePublishProgress.setMaxStudentId(maxUserId);
|
|
rulePublishProgress.setMaxStudentId(maxUserId);
|
|
noticeRulePublishProgressRepo.save(rulePublishProgress);
|
|
noticeRulePublishProgressRepo.save(rulePublishProgress);
|
|
}
|
|
}
|
|
@@ -453,11 +469,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|
}
|
|
}
|
|
|
|
|
|
private UserNoticeEntity initUserNoticeEntity(Long rootOrgId, Long userId, Long noticeId,
|
|
private UserNoticeEntity initUserNoticeEntity(Long rootOrgId, Long userId, Long noticeId,
|
|
- NoticeReceiverRuleType ruleType) {
|
|
|
|
- UserType userType = (ruleType == NoticeReceiverRuleType.STUDENTS_OF_EXAM
|
|
|
|
- || ruleType == NoticeReceiverRuleType.ALL_STUDENTS_OF_ROOT_ORG)
|
|
|
|
- ? UserType.STUDENT
|
|
|
|
- : UserType.COMMON;
|
|
|
|
|
|
+ UserType userType) {
|
|
UserNoticeEntity userNotice = new UserNoticeEntity();
|
|
UserNoticeEntity userNotice = new UserNoticeEntity();
|
|
userNotice.setRootOrgId(rootOrgId);
|
|
userNotice.setRootOrgId(rootOrgId);
|
|
userNotice.setHasRead(false);
|
|
userNotice.setHasRead(false);
|