|
@@ -293,29 +293,33 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
ExamTask examTask = examTaskService.getById(examTaskId);
|
|
|
List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, examTask.getCourseCode(), examTask.getPaperNumber());
|
|
|
if (!CollectionUtils.isEmpty(examDetailCourses)) {
|
|
|
+ Set<String> relatePaperTypes = examDetailCourses.stream().filter(m -> StringUtils.isNotBlank(m.getPaperType())).map(m -> m.getPaperType()).collect(Collectors.toSet());
|
|
|
List<Map<String, String>> paperList = new ArrayList<>();
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourses) {
|
|
|
- QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
- ExamTaskDetail examTaskDetail = this.getOne(examTaskDetailQueryWrapper);
|
|
|
- if (examTaskDetail != null) {
|
|
|
- String relatePaperType = examDetailCourse.getPaperType();
|
|
|
- if (StringUtils.isNotBlank(relatePaperType)) {
|
|
|
- String[] paperTypes = relatePaperType.split(",");
|
|
|
- String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
|
- List<Map> list = JSONObject.parseArray(paperAttachmentIds, Map.class);
|
|
|
- String attachmentId;
|
|
|
- for (Map map : list) {
|
|
|
- String name = map.get("name").toString();
|
|
|
- for (String paperType : paperTypes) {
|
|
|
- if (name.equals(paperType)) {
|
|
|
- attachmentId = map.get("attachmentId").toString();
|
|
|
- if (StringUtils.isNotBlank(attachmentId)) {
|
|
|
- paperList.add(teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(attachmentId), false));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
+ examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
+ ExamTaskDetail examTaskDetail = this.getOne(examTaskDetailQueryWrapper);
|
|
|
+ if (Objects.isNull(examTaskDetail)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未查询到卷库中的试卷");
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(relatePaperTypes)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到关联的试卷卷型");
|
|
|
+ }
|
|
|
+ String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
|
+ List<Map> list = JSONObject.parseArray(paperAttachmentIds, Map.class);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到关联的试卷文件");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> paperMap = list.stream().collect(Collectors.toMap(m -> m.get("name").toString(), m -> m.get("attachmentId").toString()));
|
|
|
+ for (String relatePaperType : relatePaperTypes) {
|
|
|
+ String[] paperTypes = relatePaperType.split(",");
|
|
|
+ for (String paperType : paperTypes) {
|
|
|
+ if (!paperMap.containsKey(paperType)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String attachmentId = paperMap.get(paperType);
|
|
|
+ if (StringUtils.isNotBlank(attachmentId)) {
|
|
|
+ paperList.add(teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(attachmentId), false));
|
|
|
}
|
|
|
}
|
|
|
}
|