|
@@ -74,31 +74,60 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void syncCoursePaper(CoursePaper info) {
|
|
|
- Check.isNull(info.getOrgId(), "学校ID不能为空!");
|
|
|
- Check.isNull(info.getExamId(), "考试ID不能为空!");
|
|
|
- Check.isNull(info.getCourseId(), "课程ID不能为空!");
|
|
|
- Check.isEmpty(info.getCourseCode(), "课程代码不能为空!");
|
|
|
- Check.isEmpty(info.getCourseName(), "课程名称不能为空!");
|
|
|
- Check.isNull(info.getPaperId(), "试卷ID不能为空!");
|
|
|
- Check.isEmpty(info.getPaperName(), "试卷名称不能为空!");
|
|
|
- Check.isNull(info.getPaperP(), "试卷页数不能为空!");
|
|
|
- Check.isBlank(info.getPaperFileUrl(), "试卷文件地址不能为空!");
|
|
|
- Check.isBlank(info.getAnswerFileUrl(), "答案文件地址不能为空!");
|
|
|
-
|
|
|
- CoursePaper coursePaper = coursePaperRepository.findByExamIdAndPaperId(info.getExamId(), info.getPaperId());
|
|
|
- if (coursePaper != null) {
|
|
|
+ public void syncCoursePaper(CoursePaper coursePaper) {
|
|
|
+ Check.isNull(coursePaper.getOrgId(), "学校ID不能为空!");
|
|
|
+ Check.isNull(coursePaper.getExamId(), "考试ID不能为空!");
|
|
|
+ Check.isNull(coursePaper.getCourseId(), "课程ID不能为空!");
|
|
|
+ Check.isEmpty(coursePaper.getCourseCode(), "课程代码不能为空!");
|
|
|
+ Check.isEmpty(coursePaper.getCourseName(), "课程名称不能为空!");
|
|
|
+ Check.isNull(coursePaper.getPaperId(), "试卷ID不能为空!");
|
|
|
+ Check.isEmpty(coursePaper.getPaperName(), "试卷名称不能为空!");
|
|
|
+ Check.isNull(coursePaper.getPaperP(), "试卷页数不能为空!");
|
|
|
+ Check.isBlank(coursePaper.getPaperFileUrl(), "试卷文件地址不能为空!");
|
|
|
+ Check.isBlank(coursePaper.getAnswerFileUrl(), "答案文件地址不能为空!");
|
|
|
+
|
|
|
+ CoursePaper oldCoursePaper = coursePaperRepository.findByExamIdAndPaperId(coursePaper.getExamId(), coursePaper.getPaperId());
|
|
|
+ if (oldCoursePaper != null) {
|
|
|
//存在则修改
|
|
|
- coursePaper.setPaperName(info.getPaperName());
|
|
|
- coursePaper.setPaperP(info.getPaperP());
|
|
|
- coursePaper.setPaperFileUrl(info.getPaperFileUrl());
|
|
|
- coursePaper.setAnswerFileUrl(info.getAnswerFileUrl());
|
|
|
- coursePaperRepository.save(coursePaper);
|
|
|
+ oldCoursePaper.setPaperName(coursePaper.getPaperName());
|
|
|
+ oldCoursePaper.setPaperP(coursePaper.getPaperP());
|
|
|
+ oldCoursePaper.setPaperFileUrl(coursePaper.getPaperFileUrl());
|
|
|
+ oldCoursePaper.setAnswerFileUrl(coursePaper.getAnswerFileUrl());
|
|
|
+ coursePaperRepository.save(oldCoursePaper);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
//否则新增
|
|
|
- coursePaperRepository.save(info);
|
|
|
+ coursePaperRepository.save(coursePaper);
|
|
|
+
|
|
|
+ //保存试卷结构
|
|
|
+ //todo
|
|
|
+
|
|
|
+
|
|
|
+ //如果当前考试课程"只有一种试卷类型"且"未分配试卷",则默认分配该试卷
|
|
|
+ SearchBuilder searches = new SearchBuilder()
|
|
|
+ .eq("orgId", coursePaper.getOrgId())
|
|
|
+ .eq("examId", coursePaper.getExamId())
|
|
|
+ .eq("courseId", coursePaper.getCourseId());
|
|
|
+ Specification<CourseStatistic> spec = SpecUtils.buildSearchers(CourseStatistic.class, searches.build());
|
|
|
+ List<CourseStatistic> statistics = courseStatisticRepository.findAll(spec);
|
|
|
+ if (statistics == null || statistics.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (CourseStatistic statistic : statistics) {
|
|
|
+ if (PaperStatus.已有.getIndex() == statistic.getPaperStatus()) {
|
|
|
+ //跳过已分配的
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (statistics.size() == 1) {
|
|
|
+ //只有一种试卷类型,则默认分配
|
|
|
+ statistic.setCoursePaper(coursePaper);
|
|
|
+ statistic.setPaperStatus(PaperStatus.已有.getIndex());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //否则,分配状态改为"未指定"
|
|
|
+ statistic.setPaperStatus(PaperStatus.未指定.getIndex());
|
|
|
+ }
|
|
|
+ courseStatisticRepository.save(statistics);
|
|
|
}
|
|
|
|
|
|
@Override
|