WANG 5 年之前
父节点
当前提交
4575616fe9

+ 78 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/cache/OrgExamConfigCache.java

@@ -0,0 +1,78 @@
+package cn.com.qmth.examcloud.core.examwork.service.cache;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamSpecialSettingsRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamSpecialSettingsEntity;
+import cn.com.qmth.examcloud.support.cache.bean.OrgExamConfigCacheBean;
+import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+
+@Service
+public class OrgExamConfigCache extends RandomObjectRedisCache<OrgExamConfigCacheBean> {
+
+	@Autowired
+	ExamRepo examRepo;
+
+	@Autowired
+	ExamSpecialSettingsRepo examSpecialSettingsRepo;
+
+	@Override
+	public OrgExamConfigCacheBean loadFromResource(Object... keys) {
+		Long examId = (Long) keys[0];
+		Long orgId = (Long) keys[1];
+
+		ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
+
+		if (null == exam) {
+			throw new StatusException("002005", "考试不存在");
+		}
+
+		OrgExamConfigCacheBean bean = new OrgExamConfigCacheBean();
+
+		bean.setId(exam.getId());
+		bean.setBeginTime(exam.getBeginTime());
+		bean.setDuration(exam.getDuration());
+		bean.setEnable(exam.getEnable());
+		bean.setEndTime(exam.getEndTime());
+		bean.setExamTimes(exam.getExamTimes());
+		bean.setExamType(exam.getExamType().name());
+		bean.setName(exam.getName());
+		bean.setCode(exam.getCode());
+		bean.setRemark(exam.getRemark());
+		bean.setRootOrgId(exam.getRootOrgId());
+		bean.setExamLimit(exam.getExamLimit());
+
+		ExamSpecialSettingsEntity examOrgEntity = examSpecialSettingsRepo
+				.findByExamIdAndOrgIdAndCourseIdIsNull(exam.getId(), orgId);
+		if (null != examOrgEntity) {
+			if (null != examOrgEntity.getBeginTime()) {
+				bean.setBeginTime(examOrgEntity.getBeginTime());
+			}
+			if (null != examOrgEntity.getEndTime()) {
+				bean.setEndTime(examOrgEntity.getEndTime());
+			}
+			if (null != examOrgEntity.getExamLimit()) {
+				bean.setExamLimit(examOrgEntity.getExamLimit());
+			}
+		}
+
+		return bean;
+	}
+
+	@Override
+	protected String getKeyPrefix() {
+		return "E_ORG_EXAM_CONF:";
+	}
+
+	@Override
+	protected int getTimeout() {
+		// 5分钟
+		return 60 * 5;
+	}
+
+}

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

@@ -348,8 +348,7 @@ public class NoticeServiceImpl implements NoticeService {
                                                       Long startUserId, NoticeReceiverRuleType ruleType,
                                                       List<NoticeReceiverRuleEntity> ruleList) {
         GetLimitUserIdResp resultResp = new GetLimitUserIdResp();
-        List<Long> limitUserIdList = null;
-        long nextUserId = 0;
+        
         switch (ruleType) {
             case TEACHER_OF_MARK_WORK:
                 return getGetLimitUserIdByMarkWork(rootOrgId, rowNumber, startUserId, ruleList);