|
@@ -12,7 +12,6 @@ import cn.com.qmth.examcloud.core.print.common.jpa.OrderBuilder;
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
-import cn.com.qmth.examcloud.core.print.common.utils.JsonMapper;
|
|
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamQuestionStructure;
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamQuestionStructure;
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamStructure;
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamStructure;
|
|
import cn.com.qmth.examcloud.core.print.enums.ExamType;
|
|
import cn.com.qmth.examcloud.core.print.enums.ExamType;
|
|
@@ -34,10 +33,10 @@ import org.springframework.stereotype.Service;
|
|
import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
|
|
import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * @author: weiwenhai
|
|
|
|
+ * @since: 2018.10.30
|
|
* @author: fengdesheng
|
|
* @author: fengdesheng
|
|
- * @since: 2018/10/17
|
|
|
|
- * @update: weiwenhai
|
|
|
|
- * @date: 2018.10.30
|
|
|
|
|
|
+ * @update: 2018/11/22
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ExamStructureServiceImpl implements ExamStructureService {
|
|
public class ExamStructureServiceImpl implements ExamStructureService {
|
|
@@ -50,10 +49,11 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
@Override
|
|
@Override
|
|
public Page<ExamStructureInfo> getExamStructureList(ExamStructureQuery query) {
|
|
public Page<ExamStructureInfo> getExamStructureList(ExamStructureQuery query) {
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
- Check.isEmpty(query.getOrgId(), "学校ID不能为空!");
|
|
|
|
//查询条件
|
|
//查询条件
|
|
SearchBuilder searches = new SearchBuilder();
|
|
SearchBuilder searches = new SearchBuilder();
|
|
- searches.eq("orgId", query.getOrgId());
|
|
|
|
|
|
+ if (query.getOrgId() != null) {
|
|
|
|
+ searches.eq("orgId", query.getOrgId());
|
|
|
|
+ }
|
|
if (query.getExamId() != null) {
|
|
if (query.getExamId() != null) {
|
|
searches.eq("examId", query.getExamId());
|
|
searches.eq("examId", query.getExamId());
|
|
}
|
|
}
|
|
@@ -67,11 +67,10 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ExamStructureInfo getExamStructure(ExamStructureQuery query) {
|
|
|
|
- Check.isNull(query, "查询参数不能为空!");
|
|
|
|
- Check.isEmpty(query.getOrgId(), "学校ID不能为空!");
|
|
|
|
- Check.isEmpty(query.getExamId(), "考试ID不能为空!");
|
|
|
|
- ExamStructure entity = examStructureRepository.findByOrgIdAndExamId(query.getOrgId(), query.getExamId());
|
|
|
|
|
|
+ public ExamStructureInfo getExamStructure(Long orgId, Long examId) {
|
|
|
|
+ Check.isEmpty(orgId, "学校ID不能为空!");
|
|
|
|
+ Check.isEmpty(examId, "考试ID不能为空!");
|
|
|
|
+ ExamStructure entity = examStructureRepository.findByOrgIdAndExamId(orgId, examId);
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -96,6 +95,52 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
examStructureRepository.save(entity);
|
|
examStructureRepository.save(entity);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void cloneExamStructure(ExamStructureInfo info) {
|
|
|
|
+ //数据校验
|
|
|
|
+ Check.isNull(info.getOrgId(), "原学校ID不能为空!");
|
|
|
|
+ Check.isNull(info.getExamId(), "原考试ID不能为空!");
|
|
|
|
+ Check.isNull(info.getNewOrgId(), "新学校ID不能为空!");
|
|
|
|
+ Check.isBlank(info.getNewOrgName(), "新学校名称不能为空!");
|
|
|
|
+ Check.isNull(info.getExamId(), "新考试ID不能为空!");
|
|
|
|
+ Check.isBlank(info.getNewExamName(), "新考试名称不能为空!");
|
|
|
|
+
|
|
|
|
+ ExamStructure newStructure = examStructureRepository.findByOrgIdAndExamId(info.getNewOrgId(), info.getNewExamId());
|
|
|
|
+ if (newStructure != null) {
|
|
|
|
+ throw new StatusException(PRT_CODE_500, "新学校考试下已有结构信息,不可复用!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamStructure oldStructure = examStructureRepository.findByOrgIdAndExamId(info.getOrgId(), info.getExamId());
|
|
|
|
+ if (oldStructure == null) {
|
|
|
|
+ throw new StatusException(PRT_CODE_500, "原结构信息不存在!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ newStructure = new ExamStructure();
|
|
|
|
+ newStructure.setId(null);
|
|
|
|
+ newStructure.setOrgId(info.getNewOrgId());
|
|
|
|
+ newStructure.setOrgName(info.getNewOrgName());
|
|
|
|
+ newStructure.setExamId(info.getNewExamId());
|
|
|
|
+ newStructure.setExamName(info.getNewExamName());
|
|
|
|
+ newStructure.setExamType(oldStructure.getExamType());
|
|
|
|
+ newStructure.setStruct(oldStructure.getStruct());
|
|
|
|
+ examStructureRepository.save(newStructure);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteExamStructure(Long[] ids) {
|
|
|
|
+ if (ids == null || ids.length == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (Long id : ids) {
|
|
|
|
+ try {
|
|
|
|
+ examStructureRepository.delete(id);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // ignore: record not exist
|
|
|
|
+ log.warn(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void checkExamStructure(Long orgId, Long examId, String paperId) {
|
|
public void checkExamStructure(Long orgId, Long examId, String paperId) {
|
|
Check.isNull(orgId, "学校ID不能为空!");
|
|
Check.isNull(orgId, "学校ID不能为空!");
|
|
@@ -108,7 +153,7 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
}
|
|
}
|
|
|
|
|
|
//考试结构设置的客观题数量
|
|
//考试结构设置的客观题数量
|
|
- ExamQuestionStructure questionStructure = new JsonMapper().fromJson(entity.getStruct(), ExamQuestionStructure.class);
|
|
|
|
|
|
+ //ExamQuestionStructure questionStructure = new JsonMapper().fromJson(entity.getStruct(), ExamQuestionStructure.class);
|
|
|
|
|
|
//校验考试结构中的单选题数量
|
|
//校验考试结构中的单选题数量
|
|
/*long singleChoiceSize = objectiveQuestionStructureRepository.countByExamIdAndPaperIdAndQuestionType(examId, paperId, QuesStructType.SINGLE_ANSWER_QUESTION.name());
|
|
/*long singleChoiceSize = objectiveQuestionStructureRepository.countByExamIdAndPaperIdAndQuestionType(examId, paperId, QuesStructType.SINGLE_ANSWER_QUESTION.name());
|
|
@@ -129,52 +174,6 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
}*/
|
|
}*/
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void deleteExamStructure(Long[] ids) {
|
|
|
|
- if (ids == null || ids.length == 0) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- for (Long id : ids) {
|
|
|
|
- try {
|
|
|
|
- examStructureRepository.delete(id);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // ignore: record not exist
|
|
|
|
- log.warn(e.getMessage());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void copyExamStructure(ExamStructureInfo info) {
|
|
|
|
- //数据校验
|
|
|
|
- Check.isNull(info.getOrgId(), "原学校ID不能为空!");
|
|
|
|
- Check.isNull(info.getExamId(), "原考试ID不能为空!");
|
|
|
|
- Check.isNull(info.getNewOrgId(), "新学校ID不能为空!");
|
|
|
|
- Check.isBlank(info.getNewOrgName(), "新学校名称不能为空!");
|
|
|
|
- Check.isNull(info.getExamId(), "新考试ID不能为空!");
|
|
|
|
- Check.isBlank(info.getNewExamName(), "新考试名称不能为空!");
|
|
|
|
-
|
|
|
|
- ExamStructure newStructure = examStructureRepository.findByOrgIdAndExamId(info.getNewOrgId(), info.getNewExamId());
|
|
|
|
- if (newStructure != null) {
|
|
|
|
- throw new StatusException(PRT_CODE_500, "新学校考试下已有结构信息,不可复用!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ExamStructure oldStructure = examStructureRepository.findByOrgIdAndExamId(info.getOrgId(), info.getExamId());
|
|
|
|
- if (oldStructure == null) {
|
|
|
|
- throw new StatusException(PRT_CODE_500, "原结构信息不存在!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- newStructure = new ExamStructure();
|
|
|
|
- newStructure.setId(null);
|
|
|
|
- newStructure.setOrgId(info.getNewOrgId());
|
|
|
|
- newStructure.setOrgName(info.getNewOrgName());
|
|
|
|
- newStructure.setExamId(info.getNewExamId());
|
|
|
|
- newStructure.setExamName(info.getNewExamName());
|
|
|
|
- newStructure.setExamType(oldStructure.getExamType());
|
|
|
|
- newStructure.setStruct(oldStructure.getStruct());
|
|
|
|
- examStructureRepository.save(newStructure);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void syncOrgNameByOrgId(Long orgId, String orgName) {
|
|
public void syncOrgNameByOrgId(Long orgId, String orgName) {
|
|
if (orgId == null || StringUtils.isBlank(orgName)) {
|
|
if (orgId == null || StringUtils.isBlank(orgName)) {
|