|
@@ -53,6 +53,7 @@ import com.qmth.teachcloud.mark.service.MarkStudentService;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.commons.io.FilenameUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
@@ -1798,41 +1799,30 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception {
|
|
|
+ public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) {
|
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
DownloadPaperFileParam downloadPaperFileParam = (DownloadPaperFileParam) map.get("downloadPaperFileParam");
|
|
|
- Long schoolId = tbTask.getSchoolId();
|
|
|
Long semesterId = downloadPaperFileParam.getSemesterId();
|
|
|
Long examId = downloadPaperFileParam.getExamId();
|
|
|
Long orgId = downloadPaperFileParam.getOrgId();
|
|
|
+ PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
|
|
|
+ if (paperFileDownloadContent == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择下载文件");
|
|
|
+ }
|
|
|
+ PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
|
|
|
+ if (Objects.isNull(paperFileDownloadExposureStatus)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择试卷状态");
|
|
|
+ }
|
|
|
Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
|
|
|
Boolean namedByPaperNumber = downloadPaperFileParam.getNamedByPaperNumber();
|
|
|
Boolean namedByOriginalFile = downloadPaperFileParam.getNamedByOriginalFile();
|
|
|
- PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
|
|
|
- PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
|
|
|
- String specialSuccessMessage = "";
|
|
|
- if (Objects.nonNull(paperFileDownloadExposureStatus)) {
|
|
|
- switch (paperFileDownloadExposureStatus) {
|
|
|
- case EXPOSED_PAPER: // 曝光的
|
|
|
- specialSuccessMessage = "所选择的命题任务中没有已曝光的试卷";
|
|
|
- break;
|
|
|
- case UNEXPOSED_PAPER: // 未曝光的
|
|
|
- specialSuccessMessage = "所选择的命题任务中没有未曝光的试卷";
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (!namedByCourseInfo && !namedByPaperNumber && !namedByOriginalFile) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择至少一种命名规则");
|
|
|
}
|
|
|
|
|
|
String courseName = downloadPaperFileParam.getCourseName();
|
|
|
Set<Long> idSet = downloadPaperFileParam.getIdSet();
|
|
|
|
|
|
- // 如果idSet集合为空且查询条件的机构id也为空,则请求用户的机构id作为机构数据权限带入查询
|
|
|
- SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
- if ((idSet == null || idSet.size() == 0) && !SystemConstant.longNotNull(orgId)) {
|
|
|
- orgId = requestUser.getOrgId();
|
|
|
- }
|
|
|
-
|
|
|
File zipFile = null;
|
|
|
String zipLocalRootPath = null;
|
|
|
try {
|
|
@@ -1848,219 +1838,125 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
zipFile = SystemConstant.getFileTempDirVarForZip(SystemConstant.getNanoId(), SystemConstant.ZIP_PREFIX);
|
|
|
zipLocalRootPath = zipFile.getParent() + File.separator + System.currentTimeMillis();
|
|
|
|
|
|
- ExamTaskPaperDto examTaskPaperDto = downloadService.findDownloadContent(schoolId, semesterId, examId, orgId, courseName, idSet);
|
|
|
- // 导出文件excel
|
|
|
- List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = examTaskPaperDto.getExamTaskPaperExportDtoList();
|
|
|
-
|
|
|
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
- ExcelUtil.excelMake(ExamTaskPaperExportDto.class, examTaskPaperExportDtoList, outputStream);
|
|
|
- InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
|
|
|
-
|
|
|
- String excelName = "试卷使用清单";
|
|
|
- if (Objects.nonNull(paperFileDownloadExposureStatus)) {
|
|
|
- excelName = excelName + paperFileDownloadExposureStatus.getDesc();
|
|
|
- }
|
|
|
- String excelLocalPath = zipLocalRootPath + File.separator + excelName + "." + SystemConstant.XLSX;
|
|
|
- FileUtils.copyInputStreamToFile(in, new File(excelLocalPath));
|
|
|
-
|
|
|
- // 所有试卷信息
|
|
|
- List<ExamTaskPaperFileDto> examTaskPaperFileDtoList = examTaskPaperDto.getExamTaskPaperFileDtoList();
|
|
|
- if (examTaskPaperFileDtoList.size() == 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("没有找到任何试卷信息");
|
|
|
- }
|
|
|
- // 二级路径 课程
|
|
|
- Set<String> courseSet = examTaskPaperFileDtoList.stream().map(e -> e.getCourseName().replaceAll(" ", "") + SystemConstant.HYPHEN + e.getCourseCode()).collect(Collectors.toSet());
|
|
|
- // 文件数以一级目录文件为准(初始1是excel)
|
|
|
- int count = 1;
|
|
|
- for (String course : courseSet) {
|
|
|
- // 三级路径 课程代码-课程名称/试卷编号
|
|
|
- int courseCount = 0;
|
|
|
- Set<String> paperNumberSet = examTaskPaperFileDtoList
|
|
|
- .stream()
|
|
|
- .filter(e -> course.equals(e.getCourseName().replaceAll(" ", "") + SystemConstant.HYPHEN + e.getCourseCode()))
|
|
|
- .map(ExamTaskPaperFileDto::getPaperNumber)
|
|
|
- .collect(Collectors.toSet());
|
|
|
- for (String paperNumber : paperNumberSet) {
|
|
|
- // 试卷下文件集
|
|
|
- List<ExamTaskPaperFileDto> paperCellList = examTaskPaperFileDtoList
|
|
|
- .stream()
|
|
|
- .filter(e -> paperNumber.equals(e.getPaperNumber()))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- // 文件路径
|
|
|
- String filePath = zipLocalRootPath + File.separator + course + File.separator + paperNumber + File.separator;
|
|
|
-
|
|
|
- // 试卷文件曝光度筛选
|
|
|
- if (Objects.nonNull(paperFileDownloadExposureStatus)) {
|
|
|
- switch (paperFileDownloadExposureStatus) {
|
|
|
- case EXPOSED_PAPER: // 曝光的
|
|
|
- paperCellList = paperCellList.stream().filter(ExamTaskPaperFileDto::getExposureStatus).collect(Collectors.toList());
|
|
|
- if (paperCellList.size() > 0) {
|
|
|
- specialSuccessMessage = "";
|
|
|
- }
|
|
|
- break;
|
|
|
- case UNEXPOSED_PAPER: // 未曝光的
|
|
|
- paperCellList = paperCellList.stream().filter(e -> !e.getExposureStatus()).collect(Collectors.toList());
|
|
|
- if (paperCellList.size() > 0) {
|
|
|
- specialSuccessMessage = "";
|
|
|
- }
|
|
|
- break;
|
|
|
- case ALL_PAPER: // 全部试卷
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ boolean downloadPaper = paperFileDownloadContent != null && (PaperFileDownloadContentEnum.ONLY_PAPER.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent));
|
|
|
+ boolean downloadCard = paperFileDownloadContent != null && (PaperFileDownloadContentEnum.ONLY_CARD.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent));
|
|
|
+
|
|
|
+ // 查询待下载数据
|
|
|
+ List<ExamTaskDetailDto> examTaskDetailDtoList = downloadService.listExamQuery(semesterId, examId, orgId, courseName, idSet);
|
|
|
+ List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = new ArrayList<>();
|
|
|
+ for (ExamTaskDetailDto examTaskDetailDto : examTaskDetailDtoList) {
|
|
|
+ ExamTaskPaperExportDto examTaskPaperExportDto = new ExamTaskPaperExportDto(examTaskDetailDto);
|
|
|
+ examTaskPaperExportDtoList.add(examTaskPaperExportDto);
|
|
|
+ List<PaperInfoVo> paperInfoVoList = new ArrayList<>();
|
|
|
+ // 选择曝光卷型
|
|
|
+ if (PaperFileDownloadExposureStatusEnum.EXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
|
|
|
+ if (StringUtils.isBlank(examTaskDetailDto.getExposedPaperType())) {
|
|
|
+ examTaskPaperExportDto.setResult("没有曝光卷型,下载失败");
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getExposedPaperType());
|
|
|
}
|
|
|
-
|
|
|
- if (Objects.isNull(paperFileDownloadContent)) {
|
|
|
+ }
|
|
|
+ // 选择未曝光卷型
|
|
|
+ if (PaperFileDownloadExposureStatusEnum.UNEXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
|
|
|
+ if (StringUtils.isBlank(examTaskDetailDto.getUnexposedPaperType())) {
|
|
|
+ examTaskPaperExportDto.setResult("没有未曝光卷型,下载失败");
|
|
|
continue;
|
|
|
+ } else {
|
|
|
+ paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getUnexposedPaperType());
|
|
|
}
|
|
|
- switch (paperFileDownloadContent) {
|
|
|
- case ONLY_CARD: // 只下载题卡
|
|
|
- for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
|
- Long examCardId = examTaskPaperFileDto.getExamCardId();
|
|
|
- Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
|
|
|
- ExamCard examCard = examCardService.getById(examCardId);
|
|
|
- if (examCard != null) {
|
|
|
- String htmlContent;
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
|
|
|
- } else {
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 选择全部卷型
|
|
|
+ if (PaperFileDownloadExposureStatusEnum.ALL_PAPER.equals(paperFileDownloadExposureStatus)) {
|
|
|
+ paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
|
|
|
+ }
|
|
|
|
|
|
- byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
- String cardName = "题卡-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- cardName = cardName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- cardName = cardName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
- }
|
|
|
- cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
- String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
- String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
+ if (CollectionUtils.isEmpty(paperInfoVoList)) {
|
|
|
+ examTaskPaperExportDto.setResult("所选试卷状态未查询到上传的试卷信息,下载失败");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- File localFile = new File(cardLocalHtmlPath);
|
|
|
- if (!localFile.getParentFile().exists()) {
|
|
|
- boolean mkr = localFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localFile);
|
|
|
+ // 命题规则
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.HYPHEN);
|
|
|
+ if (namedByCourseInfo) {
|
|
|
+ sj.add(examTaskDetailDto.getCourseName()).add(examTaskDetailDto.getCourseCode());
|
|
|
+ }
|
|
|
+ if (namedByPaperNumber) {
|
|
|
+ sj.add(examTaskDetailDto.getPaperNumber());
|
|
|
+ }
|
|
|
+ String fileNamePath = sj.toString();
|
|
|
|
|
|
- File pdfFile = new File(cardLocalPdfPath);
|
|
|
- if (!pdfFile.exists()) {
|
|
|
- boolean cf = pdfFile.createNewFile();
|
|
|
- }
|
|
|
- HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
- }
|
|
|
- specialSuccessMessage = "";
|
|
|
- courseCount = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- case ONLY_PAPER: // 只下载试卷
|
|
|
- for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
|
- String paperName = "试卷-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- paperName = paperName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- paperName = paperName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- paperName = paperName + examTaskPaperFileDto.getPaperName();
|
|
|
- }
|
|
|
- paperName = paperName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
- String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
|
|
|
- String paperPath = examTaskPaperFileDto.getPaperPath();
|
|
|
- if (StringUtils.isNotBlank(paperPath)) {
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(paperPath, paperLocalPath);
|
|
|
- }
|
|
|
- }
|
|
|
- courseCount = 1;
|
|
|
+ // 目录规则(课程名称(课程代码)/试卷编号)
|
|
|
+ String secondPath = examTaskDetailDto.getCourseName() + SystemConstant.HYPHEN + examTaskDetailDto.getCourseCode() + File.separator + examTaskDetailDto.getPaperNumber();
|
|
|
+ for (PaperInfoVo paperInfoVo : paperInfoVoList) {
|
|
|
+ // 不管什么命名规则,默认都加上卷型前缀
|
|
|
+ fileNamePath = "试卷" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
|
|
|
+ // 下载试卷
|
|
|
+ if (downloadPaper) {
|
|
|
+ // 原文件名
|
|
|
+ if (namedByOriginalFile) {
|
|
|
+ fileNamePath = fileNamePath + File.separator + paperInfoVo.getFilename();
|
|
|
+ } else {
|
|
|
+ fileNamePath = fileNamePath + "." + FilenameUtils.getExtension(paperInfoVo.getFilename());
|
|
|
+ }
|
|
|
+ Long attachmentId = Long.valueOf(paperInfoVo.getAttachmentId());
|
|
|
+ if (Objects.nonNull(attachmentId)) {
|
|
|
+ BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
|
+ if (Objects.nonNull(attachment)) {
|
|
|
+ String fileName = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + fileNamePath);
|
|
|
+ fileUploadService.downloadFile(attachment, fileName);
|
|
|
}
|
|
|
- break;
|
|
|
- case PAPER_AND_CARD: // 全部下载
|
|
|
- for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
|
- // 题卡
|
|
|
- Long examCardId = examTaskPaperFileDto.getExamCardId();
|
|
|
- Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
|
|
|
- ExamCard examCard = examCardService.getById(examCardId);
|
|
|
- if (examCard != null) {
|
|
|
- String htmlContent;
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
|
|
|
- } else {
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 下载题卡
|
|
|
+ if (downloadCard) {
|
|
|
+ Long cardId = Long.valueOf(paperInfoVo.getCardId());
|
|
|
+ ExamCard examCard = examCardService.getById(cardId);
|
|
|
+ Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
|
|
|
|
|
|
- byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
- String cardName = "题卡-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- cardName = cardName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- cardName = cardName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- cardName = cardName + examCardService.getById(examCardId).getTitle();
|
|
|
- }
|
|
|
- cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
- String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
|
|
|
- String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
|
|
|
- File localCardFile = new File(cardLocalHtmlPath);
|
|
|
- if (!localCardFile.getParentFile().exists()) {
|
|
|
- boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localCardFile);
|
|
|
+ MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
|
|
|
|
- File cardPdfFile = new File(cardLocalPdfPath);
|
|
|
- if (!cardPdfFile.exists()) {
|
|
|
- boolean cf = cardPdfFile.createNewFile();
|
|
|
- }
|
|
|
- HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
|
|
|
- }
|
|
|
- // 试卷
|
|
|
- String paperName = "试卷-";
|
|
|
- if (namedByCourseInfo) {
|
|
|
- paperName = paperName + course;
|
|
|
- }
|
|
|
- if (namedByPaperNumber) {
|
|
|
- paperName = paperName + paperNumber;
|
|
|
- }
|
|
|
- if (namedByOriginalFile) {
|
|
|
- paperName = paperName + examTaskPaperFileDto.getPaperName();
|
|
|
- }
|
|
|
- paperName = paperName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
|
|
|
- String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
|
|
|
- String paperPath = examTaskPaperFileDto.getPaperPath();
|
|
|
- if (StringUtils.isNotBlank(paperPath)) {
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(paperPath, paperLocalPath);
|
|
|
- }
|
|
|
- }
|
|
|
- courseCount = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ String cardHtmlPath = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + examCard.getTitle() + SystemConstant.HTML_PREFIX);
|
|
|
+ String cardPdfPath = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + examCard.getTitle() +SystemConstant.PDF_PREFIX);
|
|
|
+ // 通用题卡
|
|
|
+ String htmlContent;
|
|
|
+ if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
|
|
|
+ } else {
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(examTaskDetailDto.getCardRuleId());
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
|
|
|
+ }
|
|
|
+ // html
|
|
|
+ File localFile = new File(cardHtmlPath);
|
|
|
+ if (!localFile.exists()) {
|
|
|
+ localFile.getParentFile().mkdirs();
|
|
|
+ localFile.createNewFile();
|
|
|
+ }
|
|
|
+ // 生成html文件
|
|
|
+ FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
|
|
|
+ // 转pdf文件
|
|
|
+ File file = new File(cardPdfPath);
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ file.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
|
|
|
}
|
|
|
+ examTaskPaperExportDto.setResult("下载成功");
|
|
|
}
|
|
|
- count = count + courseCount;
|
|
|
}
|
|
|
+
|
|
|
+ // 导出文件excel
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ ExcelUtil.excelMake(ExamTaskPaperExportDto.class, examTaskPaperExportDtoList, outputStream);
|
|
|
+ InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
|
|
|
+
|
|
|
+ String excelLocalPath = zipLocalRootPath + File.separator + "下载清单" + "." + SystemConstant.XLSX;
|
|
|
+ FileUtils.copyInputStreamToFile(in, new File(excelLocalPath));
|
|
|
+ // 所有试卷
|
|
|
JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
|
- map.put("count", count);
|
|
|
- map.put("specialSuccessMessage", specialSuccessMessage);
|
|
|
+ map.put("count", examTaskDetailDtoList.size());
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
|
} finally {
|
|
@@ -2392,7 +2288,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
// 1.题号重复校验
|
|
|
if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
|
|
|
- logicErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ",courseCode, paperNumber, mainNumber,
|
|
|
+ logicErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", courseCode, paperNumber, mainNumber,
|
|
|
subNumber);
|
|
|
String questionNumberKey = courseCode + SystemConstant.HYPHEN + paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
|
|
|
if (questionNumberCheckSet.contains(questionNumberKey)) {
|
|
@@ -2458,20 +2354,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
// 4.判断答案是否符合题型
|
|
|
if (questionType != null && SystemConstant.strNotNull(answer)) {
|
|
|
switch (questionType) {
|
|
|
- case 1:
|
|
|
- if (answer.length() > 1) {
|
|
|
- logicErrorList.add("单选题答案只能有一个");
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- if (optionCount != 2) {
|
|
|
- logicErrorList.add("判断题[选项个数]只能为2");
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- logicErrorList.add("[题型(1-单选,2-多选,3-判断)]必须从1、2、3中填写");
|
|
|
+ case 1:
|
|
|
+ if (answer.length() > 1) {
|
|
|
+ logicErrorList.add("单选题答案只能有一个");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if (optionCount != 2) {
|
|
|
+ logicErrorList.add("判断题[选项个数]只能为2");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ logicErrorList.add("[题型(1-单选,2-多选,3-判断)]必须从1、2、3中填写");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2574,7 +2470,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
// 1.题号重复校验
|
|
|
if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
|
|
|
- excelErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ",courseCode, paperNumber, mainNumber,
|
|
|
+ excelErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", courseCode, paperNumber, mainNumber,
|
|
|
subNumber);
|
|
|
String questionNumberKey = courseCode + SystemConstant.HYPHEN + paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
|
|
|
if (questionNumberCheckSet.contains(questionNumberKey)) {
|
|
@@ -2733,7 +2629,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
userSaveParams.setPassword(SystemConstant.DEFAULT_PASSWORD);
|
|
|
userSaveParams.setOrgId(orgId);
|
|
|
userSaveParams.setEnable(true);
|
|
|
- userSaveParams.setRoleIds(new Long[] { markerRole.getId() });
|
|
|
+ userSaveParams.setRoleIds(new Long[]{markerRole.getId()});
|
|
|
try {
|
|
|
markUser.setUserId(sysUserService.saveUser(userSaveParams));
|
|
|
markUser.setName(markerCode);
|