|
@@ -3,9 +3,11 @@ package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
@@ -163,6 +165,25 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
@Autowired
|
|
|
private ExamIpLimitRepo examIpLimitRepo;
|
|
|
|
|
|
+ private Set<String> hasValueProperties(Long rootOrgId, String examCode) {
|
|
|
+ Set<String> ret = new HashSet<>();
|
|
|
+ ExamEntity exam = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
|
|
|
+ if (exam == null) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ List<ExamPropertyEntity> ps = examPropertyRepo.findByExamId(exam.getId());
|
|
|
+ if (CollectionUtils.isEmpty(ps)) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
+ for (ExamPropertyEntity p : ps) {
|
|
|
+ if (StringUtils.isNotBlank(p.getValue())) {
|
|
|
+ ret.add(manager.getNameById(p.getKeyId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "保存考试批次", notes = "保存")
|
|
|
@PostMapping("saveExam")
|
|
|
@Transactional
|
|
@@ -182,17 +203,19 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
examInfo.setRemark(req.getRemark());
|
|
|
examInfo.setRootOrgId(req.getRootOrgId());
|
|
|
examInfo.setExamLimit(req.getExamLimit());
|
|
|
-
|
|
|
+ Set<String> hasValueProperties = hasValueProperties(req.getRootOrgId(), req.getCode());
|
|
|
Map<String, String> properties = req.getProperties();
|
|
|
if (properties == null) {
|
|
|
properties = new HashMap<>();
|
|
|
}
|
|
|
|
|
|
- if (properties.get(ExamProperties.FREEZE_TIME.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.FREEZE_TIME.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.FREEZE_TIME.name())) {
|
|
|
properties.put(ExamProperties.FREEZE_TIME.name(), "0");
|
|
|
}
|
|
|
String freezeTimeTypeVal = properties.get(ExamProperties.FREEZE_TIME_TYPE.name());
|
|
|
- if (StringUtils.isBlank(freezeTimeTypeVal)) {
|
|
|
+ if (StringUtils.isBlank(freezeTimeTypeVal)
|
|
|
+ && !hasValueProperties.contains(ExamProperties.FREEZE_TIME_TYPE.name())) {
|
|
|
properties.put(ExamProperties.FREEZE_TIME_TYPE.name(), FreezeTimeType.DURATION.name());
|
|
|
} else {
|
|
|
try {
|
|
@@ -201,24 +224,29 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
throw new StatusException("FREEZE_TIME_TYPE 参数值错误,只能是DURATION、BEGINTIME");
|
|
|
}
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.EXAM_RECONNECT_TIME.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.EXAM_RECONNECT_TIME.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.EXAM_RECONNECT_TIME.name())) {
|
|
|
properties.put(ExamProperties.EXAM_RECONNECT_TIME.name(), "30");
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.IS_OBJ_SCORE_VIEW.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.IS_OBJ_SCORE_VIEW.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.IS_OBJ_SCORE_VIEW.name())) {
|
|
|
properties.put(ExamProperties.IS_OBJ_SCORE_VIEW.name(), "true");
|
|
|
}
|
|
|
if ("true".equals(properties.get(ExamProperties.IP_LIMIT.name()))
|
|
|
&& CollectionUtils.isNotEmpty(req.getIpWhitelist())) {
|
|
|
properties.put(ExamProperties.IP_TOTAL_LIMIT.name(), "true");
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.AUDIT_ALL_PASS.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.AUDIT_ALL_PASS.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.AUDIT_ALL_PASS.name())) {
|
|
|
properties.put(ExamProperties.AUDIT_ALL_PASS.name(), "false");
|
|
|
}
|
|
|
if ("true".equals(properties.get(ExamProperties.IS_FACE_ENABLE.name()))) {
|
|
|
- if (properties.get(ExamProperties.IS_FACE_CHECK.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.IS_FACE_CHECK.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.IS_FACE_CHECK.name())) {
|
|
|
properties.put(ExamProperties.IS_FACE_CHECK.name(), "true");
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.SNAPSHOT_INTERVAL.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.SNAPSHOT_INTERVAL.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.SNAPSHOT_INTERVAL.name())) {
|
|
|
properties.put(ExamProperties.SNAPSHOT_INTERVAL.name(), "30");
|
|
|
} else {
|
|
|
try {
|
|
@@ -230,14 +258,17 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
throw new StatusException("SNAPSHOT_INTERVAL 参数只能是整数");
|
|
|
}
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.WARN_THRESHOLD.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.WARN_THRESHOLD.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.WARN_THRESHOLD.name())) {
|
|
|
properties.put(ExamProperties.WARN_THRESHOLD.name(), "50");
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.LIVING_WARN_THRESHOLD.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.LIVING_WARN_THRESHOLD.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.LIVING_WARN_THRESHOLD.name())) {
|
|
|
properties.put(ExamProperties.LIVING_WARN_THRESHOLD.name(), "50");
|
|
|
}
|
|
|
}
|
|
|
- if (properties.get(ExamProperties.MARKING_TYPE.name()) == null) {
|
|
|
+ if (properties.get(ExamProperties.MARKING_TYPE.name()) == null
|
|
|
+ && !hasValueProperties.contains(ExamProperties.MARKING_TYPE.name())) {
|
|
|
properties.put(ExamProperties.MARKING_TYPE.name(), "ALL");
|
|
|
}
|
|
|
|