|
@@ -24,6 +24,8 @@ import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.jpa.PageUtils;
|
|
import cn.com.qmth.examcloud.web.jpa.PageUtils;
|
|
import com.mysql.cj.util.StringUtils;
|
|
import com.mysql.cj.util.StringUtils;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
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.Example;
|
|
@@ -71,6 +73,40 @@ public class NoticeServiceImpl implements NoticeService {
|
|
@Autowired
|
|
@Autowired
|
|
private ExamRepo examRepo;
|
|
private ExamRepo examRepo;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public void checkStudentNotice(Long rootOrgId,Long studentId) {
|
|
|
|
+ List <NoticeReceiverRuleEntity> rs=noticeReceiverRuleRepo.findStudentNotice(rootOrgId);
|
|
|
|
+ if(CollectionUtils.isEmpty(rs)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List <ExamStudentEntity> es=examStudentRepo.findByStudentId(studentId);
|
|
|
|
+ Set<Long> examIds=new HashSet<>();
|
|
|
|
+ for(ExamStudentEntity e:es) {
|
|
|
|
+ examIds.add(e.getExamId());
|
|
|
|
+ }
|
|
|
|
+ List<UserNoticeEntity> adds=new ArrayList<>();
|
|
|
|
+ for(NoticeReceiverRuleEntity r:rs) {
|
|
|
|
+ if(NoticeReceiverRuleType.ALL_STUDENTS_OF_ROOT_ORG.equals(r.getRuleType())) {
|
|
|
|
+ if (userNoticeRepo.getNotice(rootOrgId, UserType.STUDENT.name(), studentId)==null) {
|
|
|
|
+ UserNoticeEntity userNotice = initUserNoticeEntity(rootOrgId, studentId, r.getNoticeId(),
|
|
|
|
+ UserType.STUDENT);
|
|
|
|
+ adds.add(userNotice);
|
|
|
|
+ }
|
|
|
|
+ }else if(NoticeReceiverRuleType.STUDENTS_OF_EXAM.equals(r.getRuleType())) {
|
|
|
|
+ if(examIds.contains(Long.valueOf(r.getRuleValue()))) {
|
|
|
|
+ UserNoticeEntity userNotice = initUserNoticeEntity(rootOrgId, studentId, r.getNoticeId(),
|
|
|
|
+ UserType.STUDENT);
|
|
|
|
+ adds.add(userNotice);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(adds.size()>0) {
|
|
|
|
+ userNoticeRepo.saveAll(adds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<UserNoticeInfo> getNoticeList(UserNoticeInfoQuery query) {
|
|
public List<UserNoticeInfo> getNoticeList(UserNoticeInfoQuery query) {
|
|
List<UserNoticeInfo> resultList = new ArrayList<>();
|
|
List<UserNoticeInfo> resultList = new ArrayList<>();
|
|
@@ -314,7 +350,20 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
entity.setPublishTime(date);
|
|
entity.setPublishTime(date);
|
|
- entity.setNoticeStatus(NoticeStatus.TO_BE_PUBLISHED);
|
|
|
|
|
|
+ List <NoticeReceiverRuleEntity> rs=getReceiverRuleList(entity.getRootOrgId(), entity.getId());
|
|
|
|
+ boolean spec=false;
|
|
|
|
+ for(NoticeReceiverRuleEntity r:rs) {
|
|
|
|
+ if(NoticeReceiverRuleType.ALL_STUDENTS_OF_ROOT_ORG.equals(r.getRuleType())
|
|
|
|
+ ||NoticeReceiverRuleType.STUDENTS_OF_EXAM.equals(r.getRuleType())) {
|
|
|
|
+ spec=true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(spec) {
|
|
|
|
+ entity.setNoticeStatus(NoticeStatus.PUBLISHED);
|
|
|
|
+ }else {
|
|
|
|
+ entity.setNoticeStatus(NoticeStatus.TO_BE_PUBLISHED);
|
|
|
|
+ }
|
|
entity.setUpdateTime(date);
|
|
entity.setUpdateTime(date);
|
|
noticeRepo.save(entity);
|
|
noticeRepo.save(entity);
|
|
} else {
|
|
} else {
|