Selaa lähdekoodia

考试特殊设置

WANG 6 vuotta sitten
vanhempi
commit
d99ea75e6a

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

@@ -956,7 +956,7 @@ public class ExamController extends ControllerSupport {
 		if (null == properties) {
 			properties = Maps.newHashMap();
 		}
-		info.setProperties(domain.getProperties());
+		info.setOrgProperties(domain.getProperties());
 
 		ExamSpecialSettingsEntity ret = examService.saveExamSpecialSettings(info);
 		return ret;

+ 5 - 5
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamSpecialSettingsInfo.java

@@ -48,7 +48,7 @@ public class ExamSpecialSettingsInfo implements JsonSerializable {
 	 */
 	private Boolean examLimit;
 
-	private Map<String, String> properties;
+	private Map<String, String> orgProperties;
 
 	public Long getId() {
 		return id;
@@ -106,12 +106,12 @@ public class ExamSpecialSettingsInfo implements JsonSerializable {
 		this.examLimit = examLimit;
 	}
 
-	public Map<String, String> getProperties() {
-		return properties;
+	public Map<String, String> getOrgProperties() {
+		return orgProperties;
 	}
 
-	public void setProperties(Map<String, String> properties) {
-		this.properties = properties;
+	public void setOrgProperties(Map<String, String> orgProperties) {
+		this.orgProperties = orgProperties;
 	}
 
 }

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

@@ -171,6 +171,7 @@ public class ExamServiceImpl implements ExamService {
 			exam.setRootOrgId(rootOrgId);
 			exam.setExamType(examType);
 			exam.setEnable(true);
+			exam.setExamLimit(false);
 		} else if (realStatus.equals(CURD.UPDATE)) {
 			if (!exam.getRootOrgId().equals(rootOrgId)) {
 				throw new StatusException("002003", "rootOrgId is wrong");
@@ -205,6 +206,9 @@ public class ExamServiceImpl implements ExamService {
 			exam.setName(examInfo.getRemark());
 		}
 
+		// 数据订正代码
+		exam.setExamLimit(false);
+
 		ExamEntity saved = examRepo.saveAndFlush(exam);
 
 		for (Entry<DynamicEnum, String> entry : map.entrySet()) {
@@ -229,6 +233,7 @@ public class ExamServiceImpl implements ExamService {
 		examSpecialInfo.setExamId(saved.getId());
 		examSpecialInfo.setExamLimit(saved.getExamLimit());
 		examSpecialInfo.setRootOrgId(saved.getRootOrgId());
+		examSpecialInfo.setExamLimit(saved.getExamLimit());
 		this.saveExamSpecialSettings(examSpecialInfo);
 
 		examSpecialSettingsRepo.updateExamEnableByExamId(saved.getId(), saved.getEnable());
@@ -311,11 +316,12 @@ public class ExamServiceImpl implements ExamService {
 	@Override
 	public ExamSpecialSettingsEntity saveExamSpecialSettings(
 			ExamSpecialSettingsInfo examSpecialInfo) {
-		ExamSpecialSettingsEntity examOrgEntity = null;
+		ExamSpecialSettingsEntity examSpecialSettingsEntity = null;
 
 		Long examId = examSpecialInfo.getExamId();
 		Date beginTime = examSpecialInfo.getBeginTime();
 		Date endTime = examSpecialInfo.getEndTime();
+		Long orgId = examSpecialInfo.getOrgId();
 
 		if (!new Boolean(null == beginTime).equals(new Boolean(null == endTime))) {
 			throw new StatusException("001101", "beginTime & endTime  wrong");
@@ -324,53 +330,60 @@ public class ExamServiceImpl implements ExamService {
 		ExamEntity examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
 
 		if (null == examSpecialInfo.getId()) {
-			examOrgEntity = examSpecialSettingsRepo.findByExamIdAndOrgIdAndCourseIdIsNull(
-					examSpecialInfo.getExamId(), examSpecialInfo.getOrgId());
-			if (null == examOrgEntity) {
-				examOrgEntity = new ExamSpecialSettingsEntity();
+			if (null != orgId) {
+				examSpecialSettingsEntity = examSpecialSettingsRepo
+						.findByExamIdAndOrgIdAndCourseIdIsNull(examSpecialInfo.getExamId(),
+								examSpecialInfo.getOrgId());
+			}
+			if (null == examSpecialSettingsEntity) {
+				examSpecialSettingsEntity = new ExamSpecialSettingsEntity();
 			}
 		} else {
-			examOrgEntity = GlobalHelper.getEntity(examSpecialSettingsRepo, examSpecialInfo.getId(),
-					ExamSpecialSettingsEntity.class);
-			if (null == examOrgEntity) {
+			examSpecialSettingsEntity = GlobalHelper.getEntity(examSpecialSettingsRepo,
+					examSpecialInfo.getId(), ExamSpecialSettingsEntity.class);
+			if (null == examSpecialSettingsEntity) {
 				throw new StatusException("001101", "id is wrong");
 			}
 		}
 
-		examOrgEntity.setBeginTime(examSpecialInfo.getBeginTime());
-		examOrgEntity.setEndTime(examSpecialInfo.getEndTime());
-		examOrgEntity.setRootOrgId(examSpecialInfo.getRootOrgId());
-		examOrgEntity.setExamId(examSpecialInfo.getExamId());
-		examOrgEntity.setOrgId(examSpecialInfo.getOrgId());
-		examOrgEntity.setExamType(examEntity.getExamType());
-		examOrgEntity.setExamEnable(examEntity.getEnable());
+		examSpecialSettingsEntity.setBeginTime(examSpecialInfo.getBeginTime());
+		examSpecialSettingsEntity.setEndTime(examSpecialInfo.getEndTime());
+		examSpecialSettingsEntity.setRootOrgId(examSpecialInfo.getRootOrgId());
+		examSpecialSettingsEntity.setExamId(examSpecialInfo.getExamId());
+		examSpecialSettingsEntity.setOrgId(examSpecialInfo.getOrgId());
+		examSpecialSettingsEntity.setExamType(examEntity.getExamType());
+		examSpecialSettingsEntity.setExamEnable(examEntity.getEnable());
 		Boolean examLimit = examSpecialInfo.getExamLimit();
 		examLimit = null == examLimit ? false : examLimit;
-		examOrgEntity.setExamLimit(examLimit);
+		examSpecialSettingsEntity.setExamLimit(examLimit);
 
-		Map<DynamicEnum, String> map = checkAndGetExamProperties(examSpecialInfo.getProperties());
+		ExamSpecialSettingsEntity saved = examSpecialSettingsRepo.save(examSpecialSettingsEntity);
 
-		ExamSpecialSettingsEntity saved = examSpecialSettingsRepo.save(examOrgEntity);
+		Map<String, String> orgProperties = examSpecialInfo.getOrgProperties();
 
-		for (Entry<DynamicEnum, String> entry : map.entrySet()) {
-			DynamicEnum de = entry.getKey();
-			String value = entry.getValue();
-			if (StringUtils.isBlank(value)) {
-				value = null;
-			} else {
-				value = value.trim();
-			}
-			ExamOrgPropertyEntity entity = examOrgPropertyRepo
-					.findByexamIdAndOrgIdAndKeyId(saved.getExamId(), saved.getOrgId(), de.getId());
-			if (null == entity) {
-				entity = new ExamOrgPropertyEntity();
-				entity.setExamId(saved.getExamId());
-				entity.setOrgId(saved.getOrgId());
-				entity.setKeyId(de.getId());
-			}
-			entity.setValue(value);
+		if (null != orgProperties) {
+			Map<DynamicEnum, String> map = checkAndGetExamProperties(orgProperties);
+
+			for (Entry<DynamicEnum, String> entry : map.entrySet()) {
+				DynamicEnum de = entry.getKey();
+				String value = entry.getValue();
+				if (StringUtils.isBlank(value)) {
+					value = null;
+				} else {
+					value = value.trim();
+				}
+				ExamOrgPropertyEntity entity = examOrgPropertyRepo.findByexamIdAndOrgIdAndKeyId(
+						saved.getExamId(), saved.getOrgId(), de.getId());
+				if (null == entity) {
+					entity = new ExamOrgPropertyEntity();
+					entity.setExamId(saved.getExamId());
+					entity.setOrgId(saved.getOrgId());
+					entity.setKeyId(de.getId());
+				}
+				entity.setValue(value);
 
-			examOrgPropertyRepo.save(entity);
+				examOrgPropertyRepo.save(entity);
+			}
 		}
 
 		return saved;