wangwei 5 éve
szülő
commit
af4b12b50c

+ 17 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamCloudServiceProvider.java

@@ -46,6 +46,7 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamSpecialSettingsEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamSpecialSettingsInfo;
 import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamCourseRelationBean;
@@ -857,6 +858,22 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 	@Override
 	public SaveStudentSpecialSettingsResp saveStudentSpecialSettings(
 			@RequestBody SaveStudentSpecialSettingsReq req) {
+
+		Long rootOrgId = req.getRootOrgId();
+		Long studentId = req.getStudentId();
+		Long examId = req.getExamId();
+		Date beginTime = req.getBeginTime();
+		Date endTime = req.getEndTime();
+
+		ExamSpecialSettingsInfo examSpecialInfo = new ExamSpecialSettingsInfo();
+		examSpecialInfo.setBeginTime(beginTime);
+		examSpecialInfo.setEndTime(endTime);
+		examSpecialInfo.setExamId(examId);
+		examSpecialInfo.setExamLimit(false);
+		examSpecialInfo.setRootOrgId(rootOrgId);
+		examSpecialInfo.setStudentId(studentId);
+
+		examService.saveExamSpecialSettings(examSpecialInfo);
 		return null;
 	}
 

+ 3 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamSpecialSettingsRepo.java

@@ -21,6 +21,9 @@ public interface ExamSpecialSettingsRepo
 	ExamSpecialSettingsEntity findByExamIdAndOrgIdAndCourseIdIsNullAndStudentIdIsNull(Long examId,
 			Long orgId);
 
+	ExamSpecialSettingsEntity findByExamIdAndStudentIdAndOrgIdIsNullAndCourseIdIsNull(Long examId,
+			Long studentId);
+
 	ExamSpecialSettingsEntity findAllByExamIdAndOrgIdIsNullAndCourseIdIsNullAndStudentIdIsNull(
 			Long examId);
 

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

@@ -32,10 +32,10 @@ public interface ExamService {
 	 * 保存考试机构设置
 	 *
 	 * @author WANGWEI
-	 * @param examInfo
+	 * @param examSpecialInfo
 	 * @return
 	 */
-	ExamSpecialSettingsEntity saveExamSpecialSettings(ExamSpecialSettingsInfo examOrgInfo);
+	ExamSpecialSettingsEntity saveExamSpecialSettings(ExamSpecialSettingsInfo examSpecialInfo);
 
 	/**
 	 * 查询考试机构属性

+ 28 - 16
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -51,6 +51,8 @@ import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamSpecialSettingsInfo;
 import cn.com.qmth.examcloud.core.examwork.service.cache.ExamPropertyCache;
 import cn.com.qmth.examcloud.core.examwork.service.cache.ExamSettingsCache;
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
+import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
 import cn.com.qmth.examcloud.support.privilege.PrivilegeDefine;
 import cn.com.qmth.examcloud.support.privilege.PrivilegeManager;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
@@ -439,17 +441,14 @@ public class ExamServiceImpl implements ExamService {
 		Long studentId = examSpecialInfo.getStudentId();
 		Long courseId = examSpecialInfo.getCourseId();
 
-		if (null != orgId && null == courseId && null == studentId) {
-
-		}
-
 		int trueNum = BooleanUtil.countTrue(null != orgId, null != courseId, null != studentId);
 		if (1 < trueNum) {
 			throw new StatusException("001502", "参数错误");
 		}
 
 		// 上锁
-		Object[] locker = new Object[]{"E_EXAM_SPECIAL_SETTINGS", examId};
+		Object[] locker = new Object[]{"E_EXAM_SPECIAL_SETTINGS", examId, "ORG" + orgId,
+				"COURSE" + courseId, "Student" + studentId};
 		SequenceLockHelper.getLock(locker);
 
 		if (!new Boolean(null == beginTime).equals(new Boolean(null == endTime))) {
@@ -457,17 +456,26 @@ public class ExamServiceImpl implements ExamService {
 		}
 
 		ExamEntity examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
+		GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
+
+		StudentCacheBean student = null;
+		if (null != studentId) {
+			student = CacheHelper.getStudent(studentId);
+			GlobalHelper.uniformRootOrg(student.getRootOrgId(), rootOrgId);
+		}
 
 		if (null == examSpecialInfo.getId()) {
 			// 机构特殊设置
 			if (null != orgId && null == courseId && null == studentId) {
 				examSpecialSettingsEntity = examSpecialSettingsRepo
 						.findByExamIdAndOrgIdAndCourseIdIsNullAndStudentIdIsNull(
-								examSpecialInfo.getExamId(), examSpecialInfo.getOrgId());
+								examSpecialInfo.getExamId(), orgId);
 			}
 			// 学生特殊设置
 			else if (null == orgId && null == courseId && null != studentId) {
-
+				examSpecialSettingsEntity = examSpecialSettingsRepo
+						.findByExamIdAndStudentIdAndOrgIdIsNullAndCourseIdIsNull(
+								examSpecialInfo.getExamId(), studentId);
 			}
 			// 课程特殊设置
 			else if (null == orgId && null != courseId && null == studentId) {
@@ -485,6 +493,19 @@ public class ExamServiceImpl implements ExamService {
 			if (null == examSpecialSettingsEntity) {
 				examSpecialSettingsEntity = new ExamSpecialSettingsEntity();
 			}
+
+			examSpecialSettingsEntity.setRootOrgId(rootOrgId);
+			examSpecialSettingsEntity.setExamId(examId);
+			examSpecialSettingsEntity.setExamType(examEntity.getExamType());
+			examSpecialSettingsEntity.setExamEnable(examEntity.getEnable());
+
+			examSpecialSettingsEntity.setOrgId(orgId);
+			examSpecialSettingsEntity.setCourseId(courseId);
+			examSpecialSettingsEntity.setStudentId(studentId);
+			if (null != studentId) {
+				examSpecialSettingsEntity.setIdentityNumber(student.getIdentityNumber());
+			}
+
 		} else {
 			examSpecialSettingsEntity = GlobalHelper.getEntity(examSpecialSettingsRepo,
 					examSpecialInfo.getId(), ExamSpecialSettingsEntity.class);
@@ -493,15 +514,6 @@ public class ExamServiceImpl implements ExamService {
 			}
 		}
 
-		examSpecialSettingsEntity.setRootOrgId(rootOrgId);
-		examSpecialSettingsEntity.setExamId(examId);
-		examSpecialSettingsEntity.setExamType(examEntity.getExamType());
-		examSpecialSettingsEntity.setExamEnable(examEntity.getEnable());
-
-		examSpecialSettingsEntity.setOrgId(orgId);
-		examSpecialSettingsEntity.setCourseId(courseId);
-		examSpecialSettingsEntity.setStudentId(studentId);
-
 		examSpecialSettingsEntity.setBeginTime(examSpecialInfo.getBeginTime());
 		examSpecialSettingsEntity.setEndTime(examSpecialInfo.getEndTime());