|
@@ -15,6 +15,7 @@ import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
|
|
import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
|
|
import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
|
|
import com.qmth.distributed.print.business.bean.result.DictionaryResult;
|
|
import com.qmth.distributed.print.business.bean.result.DictionaryResult;
|
|
import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
|
|
import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
|
|
|
|
+import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
|
|
import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
|
|
import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
@@ -22,7 +23,6 @@ import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
-import com.qmth.teachcloud.common.util.RedisCounterUtil;
|
|
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
@@ -37,6 +37,7 @@ import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.util.*;
|
|
import com.qmth.teachcloud.common.util.*;
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
@@ -54,7 +55,6 @@ import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
@@ -269,16 +269,16 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
JSONArray jsonArray = new JSONArray();
|
|
JSONArray jsonArray = new JSONArray();
|
|
JSONArray stuJsonArray = new JSONArray();
|
|
JSONArray stuJsonArray = new JSONArray();
|
|
Map<String, ExamCard> examCardMap = new HashMap<>();
|
|
Map<String, ExamCard> examCardMap = new HashMap<>();
|
|
- JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
|
|
+ List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
|
|
ExamCard examCard;
|
|
ExamCard examCard;
|
|
- for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
- JSONObject object = jsonArrayPaper.getJSONObject(i);
|
|
|
|
- if (Objects.nonNull(object.get("cardId")) && !Objects.equals("", object.get("cardId"))) {
|
|
|
|
- examCard = examCardService.getById(Long.parseLong((String) object.get("cardId")));
|
|
|
|
|
|
+ for (PaperInfoVo paperInfoVo : paperInfoVoList) {
|
|
|
|
+ Long cardId = paperInfoVo.getCardId();
|
|
|
|
+ if (Objects.nonNull(cardId)) {
|
|
|
|
+ examCard = examCardService.getById(cardId);
|
|
if (Objects.isNull(examCard)) {
|
|
if (Objects.isNull(examCard)) {
|
|
throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
}
|
|
}
|
|
- examCardMap.put((String) object.get("name"), examCard);
|
|
|
|
|
|
+ examCardMap.put(paperInfoVo.getName(), examCard);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -296,11 +296,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
paperType = paperTypeParam;
|
|
paperType = paperTypeParam;
|
|
CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
} else {
|
|
} else {
|
|
-// if (StringUtils.isBlank(examDetailCourse.getPaperType())) {
|
|
|
|
paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
|
|
paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
|
|
-// } else {
|
|
|
|
-// paperType = examDetailCourse.getPaperType();
|
|
|
|
-// }
|
|
|
|
}
|
|
}
|
|
//查询考生
|
|
//查询考生
|
|
QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
@@ -1175,18 +1171,19 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
// 收集处理试卷和题卡
|
|
// 收集处理试卷和题卡
|
|
- List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), ExamPaperInfoDto.class);
|
|
|
|
- if (Objects.isNull(paperInfoDtoList)) {
|
|
|
|
|
|
+ List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
+ if (CollectionUtils.isEmpty(paperInfoVos)) {
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务未上传试卷或题卡", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务未上传试卷或题卡", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
}
|
|
}
|
|
|
|
|
|
- for (ExamPaperInfoDto examPaperInfoDto : paperInfoDtoList) {
|
|
|
|
|
|
+ for (PaperInfoVo paperInfoVo : paperInfoVos) {
|
|
// 下载试卷
|
|
// 下载试卷
|
|
- if (examPaperInfoDto.getAttachmentId() != null) {
|
|
|
|
- BasicAttachment paperAttachment = basicAttachmentService.getById(examPaperInfoDto.getAttachmentId());
|
|
|
|
|
|
+ Long attachmentId = paperInfoVo.getAttachmentId();
|
|
|
|
+ if (Objects.nonNull(attachmentId)) {
|
|
|
|
+ BasicAttachment paperAttachment = basicAttachmentService.getById(attachmentId);
|
|
JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
|
|
JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
|
|
UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
- String paperPath = firstPath + File.separator + "试卷" + File.separator + examPaperInfoDto.getName() + "-" + paperAttachment.getName() + paperAttachment.getType();
|
|
|
|
|
|
+ String paperPath = firstPath + File.separator + "试卷" + File.separator + paperInfoVo.getName() + "-" + paperAttachment.getName() + paperAttachment.getType();
|
|
if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath, uploadFileEnum.getFssType());
|
|
fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath, uploadFileEnum.getFssType());
|
|
} else {
|
|
} else {
|
|
@@ -1195,20 +1192,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
// 下载题卡
|
|
// 下载题卡
|
|
- Long cardId = examPaperInfoDto.getCardId();
|
|
|
|
|
|
+ Long cardId = paperInfoVo.getCardId();
|
|
if (cardId != null) {
|
|
if (cardId != null) {
|
|
- String paperType = examPaperInfoDto.getName();
|
|
|
|
|
|
+ String paperType = paperInfoVo.getName();
|
|
ExamCard examCard = examCardService.getById(cardId);
|
|
ExamCard examCard = examCardService.getById(cardId);
|
|
if (Objects.isNull(examCard)) {
|
|
if (Objects.isNull(examCard)) {
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
}
|
|
}
|
|
MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
- Long attachmentId = examCard.getAttachmentId();
|
|
|
|
- if (attachmentId == null || attachmentId == 0) {
|
|
|
|
|
|
+ Long cardAttachmentId = examCard.getAttachmentId();
|
|
|
|
+ if (cardAttachmentId == null) {
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
}
|
|
}
|
|
- BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
|
|
+ BasicAttachment cardAttachment = basicAttachmentService.getById(cardAttachmentId);
|
|
if (Objects.isNull(cardAttachment)) {
|
|
if (Objects.isNull(cardAttachment)) {
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未找到上传附件数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未找到上传附件数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
}
|
|
}
|
|
@@ -1241,8 +1238,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (Objects.isNull(confirmMap.get("attachmentId"))) {
|
|
if (Objects.isNull(confirmMap.get("attachmentId"))) {
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
}
|
|
}
|
|
- Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
|
|
|
|
- BasicAttachment confirmAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
|
|
+ Long confirmAttachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
|
|
|
|
+ BasicAttachment confirmAttachment = basicAttachmentService.getById(confirmAttachmentId);
|
|
if (confirmAttachment == null) {
|
|
if (confirmAttachment == null) {
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未找到上传数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未找到上传数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
}
|
|
}
|
|
@@ -1316,27 +1313,28 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
// 试卷
|
|
// 试卷
|
|
String paperAttachmentIds = examTaskDetailPdfDownloadDto.getPaperAttachmentIds();
|
|
String paperAttachmentIds = examTaskDetailPdfDownloadDto.getPaperAttachmentIds();
|
|
if (StringUtils.isNotBlank(paperAttachmentIds)) {
|
|
if (StringUtils.isNotBlank(paperAttachmentIds)) {
|
|
- List<Map> paperInfo = JSONObject.parseArray(paperAttachmentIds, Map.class);
|
|
|
|
- if (Objects.isNull(paperInfo)) {
|
|
|
|
|
|
+ List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(paperAttachmentIds);
|
|
|
|
+ if (CollectionUtils.isEmpty(paperInfoVoList)) {
|
|
throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
}
|
|
}
|
|
- for (Map paperMap : paperInfo) {
|
|
|
|
- if (Objects.nonNull(paperMap.get("attachmentId")) && String.valueOf(paperMap.get("attachmentId")).length() > 0 && !String.valueOf(paperMap.get("attachmentId")).equals("null")) {
|
|
|
|
- String name = paperMap.get("name").toString();
|
|
|
|
- Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
|
|
|
|
|
|
+ for (PaperInfoVo paperInfoVo : paperInfoVoList) {
|
|
|
|
+ Long attachmentId = paperInfoVo.getAttachmentId();
|
|
|
|
+ String name = paperInfoVo.getName();
|
|
|
|
+ if (Objects.nonNull(attachmentId)) {
|
|
BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
if (Objects.nonNull(attachment)) {
|
|
if (Objects.nonNull(attachment)) {
|
|
File paperFile = getAttachmentFile(attachment, dirPath.toString() + "试卷" + SystemConstant.HYPHEN + name + attachment.getType());
|
|
File paperFile = getAttachmentFile(attachment, dirPath.toString() + "试卷" + SystemConstant.HYPHEN + name + attachment.getType());
|
|
sourceFileList.add(paperFile);
|
|
sourceFileList.add(paperFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ExamCard examCard = examCardService.getById(Long.parseLong((String) paperMap.get("cardId")));
|
|
|
|
|
|
+ Long cardId = paperInfoVo.getCardId();
|
|
|
|
+ ExamCard examCard = examCardService.getById(cardId);
|
|
Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
|
|
Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
|
|
|
|
|
|
MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
|
|
|
|
- String cardHtmlPath = dirPath.toString() + "题卡" + SystemConstant.HYPHEN + paperMap.get("name") + SystemConstant.HTML_PREFIX;
|
|
|
|
- String cardPdfPath = dirPath.toString() + "题卡" + SystemConstant.HYPHEN + paperMap.get("name") + SystemConstant.PDF_PREFIX;
|
|
|
|
|
|
+ String cardHtmlPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.HTML_PREFIX;
|
|
|
|
+ String cardPdfPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
|
|
// 通用题卡
|
|
// 通用题卡
|
|
String htmlContent;
|
|
String htmlContent;
|
|
if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
|
|
if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
|