WANG 6 năm trước cách đây
mục cha
commit
45a5261daa

+ 6 - 6
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticePublishScheduleRepo.java

@@ -1,7 +1,7 @@
 package cn.com.qmth.examcloud.core.examwork.dao;
 
 import cn.com.qmth.examcloud.api.commons.enums.NoticePublishStatus;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticePublishScheduleEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeRulePublishProgressEntity;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -11,13 +11,13 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
-public interface NoticePublishScheduleRepo extends JpaRepository<NoticePublishScheduleEntity, Long>,
-        QueryByExampleExecutor<NoticePublishScheduleEntity>, JpaSpecificationExecutor<NoticePublishScheduleEntity> {
-    List<NoticePublishScheduleEntity> findByRootOrgIdAndPublishStatus(Long rootOrgId, NoticePublishStatus publishStatus);
+public interface NoticePublishScheduleRepo extends JpaRepository<NoticeRulePublishProgressEntity, Long>,
+        QueryByExampleExecutor<NoticeRulePublishProgressEntity>, JpaSpecificationExecutor<NoticeRulePublishProgressEntity> {
+    List<NoticeRulePublishProgressEntity> findByRootOrgIdAndPublishStatus(Long rootOrgId, NoticePublishStatus publishStatus);
 
-    NoticePublishScheduleEntity findByRootOrgIdAndNoticeId(Long rootOrgId,Long noticeId);
+    NoticeRulePublishProgressEntity findByRootOrgIdAndNoticeId(Long rootOrgId,Long noticeId);
 
-    List<NoticePublishScheduleEntity> findByPublishStatus(NoticePublishStatus publishStatus);
+    List<NoticeRulePublishProgressEntity> findByPublishStatus(NoticePublishStatus publishStatus);
 
     @Transactional
     @Modifying

+ 26 - 21
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/NoticePublishScheduleEntity.java → examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/NoticeRulePublishProgressEntity.java

@@ -1,21 +1,25 @@
 package cn.com.qmth.examcloud.core.examwork.dao.entity;
 
-import cn.com.qmth.examcloud.api.commons.enums.NoticePublishStatus;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Index;
+import javax.persistence.Table;
+
+import cn.com.qmth.examcloud.api.commons.enums.NoticeReceiverRuleType;
 import cn.com.qmth.examcloud.web.jpa.WithIdJpaEntity;
 
-import javax.persistence.*;
-
 /**
- * 公告发布进度实体
+ * 公告发布规则进度
  * 
  * @author lideyin
  * @date 20100701
  */
 @Entity
-@Table(name = "EC_E_NOTICE_PUBLISH_SCHEDULE", indexes = {
-		@Index(name = "IDX_E_NOTICE_PUBLISH_SCHEDULE_001001", columnList = "rootOrgId", unique = false),
-		@Index(name = "IDX_E_NOTICE_PUBLISH_SCHEDULE_001002", columnList = "rootOrgId,noticeId", unique = true)})
-public class NoticePublishScheduleEntity extends WithIdJpaEntity {
+@Table(name = "EC_E_NOTICE_RULE_PUBLISH_PROGRESS", indexes = {
+		@Index(name = "IDX_E_NOTICE_R_P_R_001001", columnList = "noticeId,noticeReceiverRuleType", unique = true)})
+public class NoticeRulePublishProgressEntity extends WithIdJpaEntity {
 
 	private static final long serialVersionUID = 7071809872436511009L;
 
@@ -25,17 +29,17 @@ public class NoticePublishScheduleEntity extends WithIdJpaEntity {
 	private Long noticeId;
 
 	/**
-	 * 学校id
+	 * 规则类型
 	 */
 	@Column(nullable = false)
-	private Long rootOrgId;
+	@Enumerated(EnumType.STRING)
+	private NoticeReceiverRuleType noticeReceiverRuleType;
 
 	/**
-	 * 发布状态
+	 * 学校id
 	 */
 	@Column(nullable = false)
-	@Enumerated(EnumType.STRING)
-	private NoticePublishStatus publishStatus;
+	private Long rootOrgId;
 
 	/**
 	 * 已发布的最大用户id
@@ -55,20 +59,20 @@ public class NoticePublishScheduleEntity extends WithIdJpaEntity {
 		this.noticeId = noticeId;
 	}
 
-	public Long getRootOrgId() {
-		return rootOrgId;
+	public NoticeReceiverRuleType getNoticeReceiverRuleType() {
+		return noticeReceiverRuleType;
 	}
 
-	public void setRootOrgId(Long rootOrgId) {
-		this.rootOrgId = rootOrgId;
+	public void setNoticeReceiverRuleType(NoticeReceiverRuleType noticeReceiverRuleType) {
+		this.noticeReceiverRuleType = noticeReceiverRuleType;
 	}
 
-	public NoticePublishStatus getPublishStatus() {
-		return publishStatus;
+	public Long getRootOrgId() {
+		return rootOrgId;
 	}
 
-	public void setPublishStatus(NoticePublishStatus publishStatus) {
-		this.publishStatus = publishStatus;
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
 	}
 
 	public Long getMaxStudentId() {
@@ -86,4 +90,5 @@ public class NoticePublishScheduleEntity extends WithIdJpaEntity {
 	public void setMaxCommonUserId(Long maxCommonUserId) {
 		this.maxCommonUserId = maxCommonUserId;
 	}
+
 }

+ 2 - 2
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/NoticeService.java

@@ -9,7 +9,7 @@ package cn.com.qmth.examcloud.core.examwork.service;
 
 import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
 import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticePublishScheduleEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeRulePublishProgressEntity;
 import cn.com.qmth.examcloud.core.examwork.service.bean.*;
 
 import java.util.List;
@@ -74,7 +74,7 @@ public interface NoticeService {
 	 * @param info
 	 * @return
 	 */
-	NoticePublishScheduleEntity updateNotice(UpdateNoticeInfo info);
+	NoticeRulePublishProgressEntity updateNotice(UpdateNoticeInfo info);
 
 	/**
 	 * 处理待发送的用户通知(自动服务调用)

+ 19 - 19
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/NoticeServiceImpl.java

@@ -46,7 +46,7 @@ import cn.com.qmth.examcloud.core.examwork.dao.NoticeRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.UserNoticeRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticePublishScheduleEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeRulePublishProgressEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeReceiverRuleEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.UserNoticeEntity;
 import cn.com.qmth.examcloud.core.examwork.service.NoticeService;
@@ -162,7 +162,7 @@ public class NoticeServiceImpl implements NoticeService {
 						DBUtil.toSqlSearchPattern(infoQuery.getTitle())));
 			}
 			if (null != infoQuery.getPublishStatus()) {
-				List<NoticePublishScheduleEntity> byPublishStatusNoticeScheduleList = noticePublishScheduleRepo
+				List<NoticeRulePublishProgressEntity> byPublishStatusNoticeScheduleList = noticePublishScheduleRepo
 						.findByRootOrgIdAndPublishStatus(rootOrgId, infoQuery.getPublishStatus());
 				if (null == byPublishStatusNoticeScheduleList
 						|| byPublishStatusNoticeScheduleList.isEmpty()) {
@@ -170,7 +170,7 @@ public class NoticeServiceImpl implements NoticeService {
 				}
 				// 获取相应发布状态的通知id集合
 				List<Long> noticeIdList = byPublishStatusNoticeScheduleList.stream()
-						.map(NoticePublishScheduleEntity::getNoticeId).collect(Collectors.toList());
+						.map(NoticeRulePublishProgressEntity::getNoticeId).collect(Collectors.toList());
 				CriteriaBuilder.In<Object> inCriteriaBuilder = cb.in(root.get("id"));
 				for (Long nid : noticeIdList) {
 					inCriteriaBuilder.value(nid);
@@ -233,7 +233,7 @@ public class NoticeServiceImpl implements NoticeService {
 		noticeReceiverRuleRepo.saveAll(ruleList);
 
 		// 保存公告发布进度
-		NoticePublishScheduleEntity publishScheduleEntity = getNoticePublishScheduleEntityFrom(
+		NoticeRulePublishProgressEntity publishScheduleEntity = getNoticePublishScheduleEntityFrom(
 				addNoticeInfo, noticeId);
 		noticePublishScheduleRepo.save(publishScheduleEntity);
 
@@ -243,11 +243,11 @@ public class NoticeServiceImpl implements NoticeService {
 
 	@Transactional
 	@Override
-	public NoticePublishScheduleEntity updateNotice(UpdateNoticeInfo info) {
+	public NoticeRulePublishProgressEntity updateNotice(UpdateNoticeInfo info) {
 		Long rootOrgId = info.getRootOrgId();
 		List<Long> noticeIdList = Collections.singletonList(info.getId());
 		// 校验通知状态,正在发送的通知不允许修改
-		NoticePublishScheduleEntity publishSchedule = noticePublishScheduleRepo
+		NoticeRulePublishProgressEntity publishSchedule = noticePublishScheduleRepo
 				.findByRootOrgIdAndNoticeId(info.getRootOrgId(), info.getId());
 		if (publishSchedule == null) {
 			throw new StatusException("501007", "找不到通知id为:" + info.getId() + "的通知进度数据");
@@ -279,16 +279,16 @@ public class NoticeServiceImpl implements NoticeService {
 
 		// 更新公告发布进度实体
 		noticePublishScheduleRepo.deleteByRootOrgIdAndNoticeIdIn(rootOrgId, noticeIdList);
-		NoticePublishScheduleEntity publishScheduleEntity = getNoticePublishScheduleEntityFrom(
+		NoticeRulePublishProgressEntity publishScheduleEntity = getNoticePublishScheduleEntityFrom(
 				info);
-		NoticePublishScheduleEntity saved = noticePublishScheduleRepo.save(publishScheduleEntity);
+		NoticeRulePublishProgressEntity saved = noticePublishScheduleRepo.save(publishScheduleEntity);
 
 		return saved;
 	}
 
 	@Override
 	public void disposePublishingUserNotice() {
-		List<NoticePublishScheduleEntity> publishingScheduleList = noticePublishScheduleRepo
+		List<NoticeRulePublishProgressEntity> publishingScheduleList = noticePublishScheduleRepo
 				.findByPublishStatus(NoticePublishStatus.PUBLISHING);
 		// 如果没有状态为发布中的数据,则直接返回
 		if (publishingScheduleList == null || publishingScheduleList.isEmpty()) {
@@ -296,7 +296,7 @@ public class NoticeServiceImpl implements NoticeService {
 		}
 		// 发布通知每次处理的用户id数量 // TODO: 2019/7/10 需要将参数放到配置文件
 		int rowNumber = PropertyHolder.getInt("notice.dispose.userId.size", 100);
-		for (NoticePublishScheduleEntity publishSchedule : publishingScheduleList) {
+		for (NoticeRulePublishProgressEntity publishSchedule : publishingScheduleList) {
 			Long rootOrgId = publishSchedule.getRootOrgId();
 			Long noticeId = publishSchedule.getNoticeId();
 			List<NoticeReceiverRuleEntity> ruleList = getReceiverRuleList(rootOrgId, noticeId);
@@ -369,7 +369,7 @@ public class NoticeServiceImpl implements NoticeService {
 	 */
 	private void batchAddUserNotice(Long rootOrgId, Long noticeId, int rowNumber, Long startUserId,
 			NoticeReceiverRuleType ruleType, List<NoticeReceiverRuleEntity> ruleList,
-			NoticePublishScheduleEntity publishSchedule) {
+			NoticeRulePublishProgressEntity publishSchedule) {
 		if (rowNumber < 1) {
 			throw new StatusException("501010", "读取的数据行数不得少于1行");
 		}
@@ -399,7 +399,7 @@ public class NoticeServiceImpl implements NoticeService {
 	 */
 	@Transactional
 	void saveUserNoticeAndUpdatePublishSchedule(Long rootOrgId, Long noticeId,
-			NoticeReceiverRuleType ruleType, NoticePublishScheduleEntity publishSchedule,
+			NoticeReceiverRuleType ruleType, NoticeRulePublishProgressEntity publishSchedule,
 			List<Long> limitStudentIdList, Long maxUserId) {
 		// 保存并更新发布状态为发布完成
 		List<UserNoticeEntity> userNoticeList = new ArrayList<>();
@@ -422,7 +422,7 @@ public class NoticeServiceImpl implements NoticeService {
 	 * @param publishSchedule
 	 * @param limitStudentIdList
 	 */
-	private void finishNoticePublishSchedule(NoticePublishScheduleEntity publishSchedule) {
+	private void finishNoticePublishSchedule(NoticeRulePublishProgressEntity publishSchedule) {
 		publishSchedule.setPublishStatus(NoticePublishStatus.PUBLISHED);
 		noticePublishScheduleRepo.save(publishSchedule);
 	}
@@ -572,7 +572,7 @@ public class NoticeServiceImpl implements NoticeService {
 	 * @return
 	 */
 	private Long getLastMaxUserId(NoticeReceiverRuleType ruleType,
-			NoticePublishScheduleEntity publishSchedule) {
+			NoticeRulePublishProgressEntity publishSchedule) {
 		if (ruleType == NoticeReceiverRuleType.ALL_STUDENTS_OF_ROOT_ORG
 				|| ruleType == NoticeReceiverRuleType.STUDENTS_OF_EXAM) {
 			return publishSchedule.getMaxStudentId();
@@ -589,7 +589,7 @@ public class NoticeServiceImpl implements NoticeService {
 	 * @return 发布状态枚举
 	 */
 	private NoticePublishStatus getNoticePublishStatus(Long rootOrgId, NoticeEntity ne) {
-		NoticePublishScheduleEntity publishSchedule = noticePublishScheduleRepo
+		NoticeRulePublishProgressEntity publishSchedule = noticePublishScheduleRepo
 				.findByRootOrgIdAndNoticeId(rootOrgId, ne.getId());
 
 		if (publishSchedule == null) {
@@ -705,9 +705,9 @@ public class NoticeServiceImpl implements NoticeService {
 		}
 	}
 
-	private NoticePublishScheduleEntity getNoticePublishScheduleEntityFrom(
+	private NoticeRulePublishProgressEntity getNoticePublishScheduleEntityFrom(
 			AddNoticeInfo addNoticeInfo, Long noticeId) {
-		NoticePublishScheduleEntity publishScheduleEntity = new NoticePublishScheduleEntity();
+		NoticeRulePublishProgressEntity publishScheduleEntity = new NoticeRulePublishProgressEntity();
 		publishScheduleEntity.setRootOrgId(addNoticeInfo.getRootOrgId());
 		publishScheduleEntity.setNoticeId(noticeId);
 		if (addNoticeInfo.getNoticeStatus() == NoticeStatus.PUBLISH) {
@@ -778,8 +778,8 @@ public class NoticeServiceImpl implements NoticeService {
 		return strIds;
 	}
 
-	private NoticePublishScheduleEntity getNoticePublishScheduleEntityFrom(UpdateNoticeInfo info) {
-		NoticePublishScheduleEntity publishScheduleEntity = new NoticePublishScheduleEntity();
+	private NoticeRulePublishProgressEntity getNoticePublishScheduleEntityFrom(UpdateNoticeInfo info) {
+		NoticeRulePublishProgressEntity publishScheduleEntity = new NoticeRulePublishProgressEntity();
 		publishScheduleEntity.setRootOrgId(info.getRootOrgId());
 		publishScheduleEntity.setNoticeId(info.getId());
 		if (info.getNoticeStatus() == NoticeStatus.PUBLISH) {