wangwei 5 jaren geleden
bovenliggende
commit
7ff5c721c8

+ 82 - 18
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -45,6 +45,7 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
 import cn.com.qmth.examcloud.api.commons.enums.CURD;
+import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
@@ -97,6 +98,8 @@ import cn.com.qmth.examcloud.support.cache.bean.ExamOrgPropertyCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamOrgSettingsCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.ExamStudentPropertyCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.ExamStudentSettingsCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
 import cn.com.qmth.examcloud.support.privilege.PrivilegeDefine;
@@ -651,7 +654,7 @@ public class ExamController extends ControllerSupport {
 
 	@ApiOperation(value = "查询考生的考试批次配置")
 	@GetMapping("examOrgSettingsFromCacheByStudentSession/{examId}")
-	public ExamDomain getExamOrgSettingsFromCacheByStudentSession(@PathVariable Long examId) {
+	public ExamDomain getExamSettingsFromCacheByStudentSession(@PathVariable Long examId) {
 
 		User accessUser = getAccessUser();
 		if (!accessUser.getUserType().equals(UserType.STUDENT)) {
@@ -663,27 +666,69 @@ public class ExamController extends ControllerSupport {
 		StudentCacheBean student = CacheHelper.getStudent(studentId);
 		Long orgId = student.getOrgId();
 
-		ExamOrgSettingsCacheBean examCache = CacheHelper.getExamOrgSettings(examId, orgId);
+		ExamSettingsCacheBean examSettings = CacheHelper.getExamSettings(examId);
+
+		Boolean specialSettingsEnabled = examSettings.getSpecialSettingsEnabled();
+		ExamSpecialSettingsType specialSettingsType = examSettings.getSpecialSettingsType();
 
 		ExamDomain domain = new ExamDomain();
-		domain.setBeginTime(examCache.getBeginTime());
-		domain.setDuration(examCache.getDuration());
-		domain.setEnable(examCache.getEnable());
-		domain.setEndTime(examCache.getEndTime());
-		domain.setExamTimes(examCache.getExamTimes());
-		domain.setExamType(ExamType.valueOf(examCache.getExamType()));
-		domain.setId(examCache.getId());
-		domain.setName(examCache.getName());
-		domain.setRemark(examCache.getRemark());
-		domain.setRootOrgId(examCache.getRootOrgId());
-		domain.setStarted(examCache.getBeginTime().before(new Date()));
+
+		if (!specialSettingsEnabled || null == specialSettingsType) {
+
+			domain.setBeginTime(examSettings.getBeginTime());
+			domain.setDuration(examSettings.getDuration());
+			domain.setEnable(examSettings.getEnable());
+			domain.setEndTime(examSettings.getEndTime());
+			domain.setExamTimes(examSettings.getExamTimes());
+			domain.setExamType(ExamType.valueOf(examSettings.getExamType()));
+			domain.setId(examSettings.getId());
+			domain.setName(examSettings.getName());
+			domain.setRemark(examSettings.getRemark());
+			domain.setRootOrgId(examSettings.getRootOrgId());
+			domain.setStarted(examSettings.getBeginTime().before(new Date()));
+
+		} else if (specialSettingsType.equals(ExamSpecialSettingsType.ORG_BASED)) {
+
+			ExamOrgSettingsCacheBean examOrgSettings = CacheHelper.getExamOrgSettings(examId,
+					orgId);
+
+			domain.setBeginTime(examOrgSettings.getBeginTime());
+			domain.setDuration(examOrgSettings.getDuration());
+			domain.setEnable(examOrgSettings.getEnable());
+			domain.setEndTime(examOrgSettings.getEndTime());
+			domain.setExamTimes(examOrgSettings.getExamTimes());
+			domain.setExamType(ExamType.valueOf(examOrgSettings.getExamType()));
+			domain.setId(examOrgSettings.getId());
+			domain.setName(examOrgSettings.getName());
+			domain.setRemark(examOrgSettings.getRemark());
+			domain.setRootOrgId(examOrgSettings.getRootOrgId());
+			domain.setStarted(examOrgSettings.getBeginTime().before(new Date()));
+
+		} else if (specialSettingsType.equals(ExamSpecialSettingsType.STUDENT_BASED)) {
+
+			ExamStudentSettingsCacheBean examStudentSettings = CacheHelper
+					.getExamStudentSettings(examId, studentId);
+
+			domain.setBeginTime(examStudentSettings.getBeginTime());
+			domain.setDuration(examStudentSettings.getDuration());
+			domain.setEnable(examStudentSettings.getEnable());
+			domain.setEndTime(examStudentSettings.getEndTime());
+			domain.setExamTimes(examStudentSettings.getExamTimes());
+			domain.setExamType(ExamType.valueOf(examStudentSettings.getExamType()));
+			domain.setId(examStudentSettings.getId());
+			domain.setName(examStudentSettings.getName());
+			domain.setRemark(examStudentSettings.getRemark());
+			domain.setRootOrgId(examStudentSettings.getRootOrgId());
+			domain.setStarted(examStudentSettings.getBeginTime().before(new Date()));
+
+		}
 
 		return domain;
 	}
 
 	@ApiOperation(value = "查询考生的考试批次属性集")
 	@GetMapping("examOrgPropertyFromCache4StudentSession/{examId}/{keys}")
-	public Map<String, String> examOrgPropertyFromCache4StudentSession(@PathVariable Long examId,
+	public Map<String, String> getExamPropertyFromCache4StudentSession(@PathVariable Long examId,
 			@PathVariable String keys) {
 
 		String[] keyArray = StringUtils.splitByWholeSeparator(keys, ",");
@@ -699,10 +744,29 @@ public class ExamController extends ControllerSupport {
 		Long orgId = student.getOrgId();
 
 		Map<String, String> map = Maps.newHashMap();
-		for (String key : keyArray) {
-			ExamOrgPropertyCacheBean orgExamProperty = CacheHelper.getExamOrgProperty(examId, orgId,
-					key);
-			map.put(key, orgExamProperty.getValue());
+
+		ExamSettingsCacheBean examSettings = CacheHelper.getExamSettings(examId);
+
+		Boolean specialSettingsEnabled = examSettings.getSpecialSettingsEnabled();
+		ExamSpecialSettingsType specialSettingsType = examSettings.getSpecialSettingsType();
+
+		if (!specialSettingsEnabled || null == specialSettingsType) {
+			for (String key : keyArray) {
+				ExamPropertyCacheBean propCache = CacheHelper.getExamProperty(examId, key);
+				map.put(key, propCache.getValue());
+			}
+		} else if (specialSettingsType.equals(ExamSpecialSettingsType.ORG_BASED)) {
+			for (String key : keyArray) {
+				ExamOrgPropertyCacheBean propCache = CacheHelper.getExamOrgProperty(examId,
+						orgId, key);
+				map.put(key, propCache.getValue());
+			}
+		} else if (specialSettingsType.equals(ExamSpecialSettingsType.STUDENT_BASED)) {
+			for (String key : keyArray) {
+				ExamStudentPropertyCacheBean propCache = CacheHelper
+						.getExamStudentProperty(examId, studentId, key);
+				map.put(key, propCache.getValue());
+			}
 		}
 
 		return map;