|
@@ -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;
|