|
@@ -8,57 +8,43 @@ import com.google.common.collect.Lists;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
-import com.qmth.distributed.print.business.bean.dto.*;
|
|
|
-import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
|
|
|
-import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
|
|
|
-import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
|
|
|
-import com.qmth.teachcloud.common.bean.result.DictionaryResult;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ExamDetailPdfDownloadDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
|
|
|
import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
|
|
|
-import com.qmth.distributed.print.business.entity.*;
|
|
|
+import com.qmth.distributed.print.business.entity.TCStatisticsTemp;
|
|
|
+import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
|
|
|
+import com.qmth.distributed.print.business.entity.TeachClazz;
|
|
|
import com.qmth.distributed.print.business.enums.ImageTrajectoryEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.PaperFileDownloadContentEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.PaperFileDownloadExposureStatusEnum;
|
|
|
-import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
|
import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
|
-import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
-import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.StatisticsImportDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.SysUserImportDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.export.SysUserErrorExportDto;
|
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
|
-import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
|
|
|
+import com.qmth.teachcloud.common.bean.result.DictionaryResult;
|
|
|
import com.qmth.teachcloud.common.bean.vo.PrintPathVo;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
|
-import com.qmth.teachcloud.common.enums.*;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.LocalCatalogEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.PdfTypeEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
|
import com.qmth.teachcloud.common.service.*;
|
|
|
import com.qmth.teachcloud.common.util.*;
|
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
|
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.commons.lang3.time.DateUtils;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
|
|
-import org.apache.poi.ss.usermodel.Row;
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.FileCopyUtils;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -66,8 +52,6 @@ import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
-import java.lang.reflect.Field;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -268,113 +252,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) {
|
|
|
- String zipLocalRootPath = null;
|
|
|
- File zipFile = null;
|
|
|
- List<File> sourceFileList = null;
|
|
|
- try {
|
|
|
- sourceFileList = new ArrayList<>();
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
-
|
|
|
- Long time = System.currentTimeMillis();
|
|
|
- boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- if (!oss && Objects.nonNull(dictionaryConfig.fssPublicDomain()) && !StringUtils.isBlank(dictionaryConfig.fssPublicDomain().getConfig()) && !dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
- stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
- }
|
|
|
- stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
|
- stringJoiner.add("卷库查询管理试卷、空白题卡批量下载_" + time).add(SystemConstant.ZIP_PREFIX);
|
|
|
-
|
|
|
- String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
|
|
|
- zipFile = SystemConstant.getFileTempDirVar(SystemConstant.ZIP_PREFIX);
|
|
|
- zipLocalRootPath = zipFile.getParent() + File.separator + time;
|
|
|
-
|
|
|
- List<ExamTaskDetailDto> examTasks = (List<ExamTaskDetailDto>) map.get("examTasks");
|
|
|
- for (ExamTaskDetailDto examTask : examTasks) {
|
|
|
- ExamTaskDetailPdfDownloadDto examTaskDetailPdfDownloadDto = examTaskDetailService.findPdfDownload(Long.valueOf(examTask.getId()));
|
|
|
-
|
|
|
- StringJoiner dirPath = new StringJoiner("");
|
|
|
- dirPath = dirPath.add(zipLocalRootPath).add(File.separator)
|
|
|
- .add(examTaskDetailPdfDownloadDto.getSemesterName()).add(File.separator)
|
|
|
- .add(examTaskDetailPdfDownloadDto.getExamName()).add(File.separator)
|
|
|
- .add(examTaskDetailPdfDownloadDto.getCourseNameCode().replaceAll(" ", "")).add(File.separator)
|
|
|
- .add(examTaskDetailPdfDownloadDto.getPaperNumber()).add(File.separator)
|
|
|
- .add(examTaskDetailPdfDownloadDto.getCourseNameCode().replaceAll(" ", "")).add(SystemConstant.HYPHEN)
|
|
|
- .add(examTaskDetailPdfDownloadDto.getPaperNumber()).add(SystemConstant.HYPHEN);
|
|
|
- // 试卷
|
|
|
- String paperAttachmentIds = examTaskDetailPdfDownloadDto.getPaperAttachmentIds();
|
|
|
- if (StringUtils.isNotBlank(paperAttachmentIds)) {
|
|
|
- List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(paperAttachmentIds);
|
|
|
- if (CollectionUtils.isEmpty(paperInfoVoList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
|
- }
|
|
|
- for (PaperInfoVo paperInfoVo : paperInfoVoList) {
|
|
|
- Long attachmentId = Long.valueOf(paperInfoVo.getAttachmentId());
|
|
|
- String name = paperInfoVo.getName();
|
|
|
- if (Objects.nonNull(attachmentId)) {
|
|
|
- BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
|
- if (Objects.nonNull(attachment)) {
|
|
|
- String fileName = dirPath + "试卷" + SystemConstant.HYPHEN + name + attachment.getType();
|
|
|
- File paperFile = fileUploadService.downloadFile(attachment, fileName);
|
|
|
- sourceFileList.add(paperFile);
|
|
|
- }
|
|
|
- }
|
|
|
- Long cardId = Long.valueOf(paperInfoVo.getCardId());
|
|
|
- ExamCard examCard = examCardService.getById(cardId);
|
|
|
- Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
|
|
|
-
|
|
|
- String cardHtmlPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.HTML_PREFIX;
|
|
|
- String cardPdfPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
|
|
|
- // 通用题卡
|
|
|
- String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent(), examCard.getCourseId());
|
|
|
- // html
|
|
|
- File localFile = new File(cardHtmlPath);
|
|
|
- if (!localFile.exists()) {
|
|
|
- localFile.getParentFile().mkdirs();
|
|
|
- localFile.createNewFile();
|
|
|
- }
|
|
|
- // 生成html文件
|
|
|
- FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
|
|
|
- sourceFileList.add(localFile);
|
|
|
- // 转pdf文件
|
|
|
- File file = new File(cardPdfPath);
|
|
|
- if (!file.exists()) {
|
|
|
- file.getParentFile().mkdirs();
|
|
|
- file.createNewFile();
|
|
|
- }
|
|
|
- HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
|
|
|
- sourceFileList.add(file);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
|
- tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
|
- map.put(SystemConstant.DATA_COUNT, examTasks.size());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
- if (e instanceof ApiException) {
|
|
|
- ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
|
- } else {
|
|
|
- ResultUtil.error(e.getMessage());
|
|
|
- }
|
|
|
- } finally {
|
|
|
- if (Objects.nonNull(zipFile)) {
|
|
|
- zipFile.delete();
|
|
|
- }
|
|
|
- if (Objects.nonNull(zipLocalRootPath)) {
|
|
|
- ConvertUtil.delFolder(zipLocalRootPath);
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
|
- for (File file : sourceFileList) {
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Map<String, Object> executeImportSysUserLogic(Map<String, Object> map) throws Exception {
|
|
@@ -685,181 +562,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- @Override
|
|
|
- public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) {
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
- DownloadPaperFileParam downloadPaperFileParam = (DownloadPaperFileParam) map.get("downloadPaperFileParam");
|
|
|
- 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 ((PaperFileDownloadContentEnum.ONLY_PAPER.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent)) && Objects.isNull(paperFileDownloadExposureStatus)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("请选择试卷状态");
|
|
|
- }
|
|
|
- Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
|
|
|
- Boolean namedByPaperNumber = downloadPaperFileParam.getNamedByPaperNumber();
|
|
|
- Boolean namedByOriginalFile = downloadPaperFileParam.getNamedByOriginalFile();
|
|
|
- if (!namedByCourseInfo && !namedByPaperNumber && !namedByOriginalFile) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("请选择至少一种命名规则");
|
|
|
- }
|
|
|
-
|
|
|
- String courseName = downloadPaperFileParam.getCourseName();
|
|
|
- Set<Long> idSet = downloadPaperFileParam.getIdSet();
|
|
|
-
|
|
|
- File zipFile = null;
|
|
|
- String zipLocalRootPath = null;
|
|
|
- try {
|
|
|
- boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- if (!oss && Objects.nonNull(dictionaryConfig.fssPublicDomain()) && !StringUtils.isBlank(dictionaryConfig.fssPublicDomain().getConfig()) && !dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
- stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
- }
|
|
|
- stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
|
- stringJoiner.add("下载管理_批量下载_" + System.currentTimeMillis()).add(SystemConstant.ZIP_PREFIX);
|
|
|
-
|
|
|
- String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
|
|
|
- zipFile = SystemConstant.getFileTempDirVarForZip(SystemConstant.getNanoId(), SystemConstant.ZIP_PREFIX);
|
|
|
- zipLocalRootPath = zipFile.getParent() + File.separator + System.currentTimeMillis();
|
|
|
-
|
|
|
- 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));
|
|
|
-
|
|
|
- SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
- DataPermissionRule dpr = null;
|
|
|
- if (CollectionUtils.isEmpty(idSet)) {
|
|
|
- dpr = basicRoleDataPermissionService.findDataPermission(653L, requestUser);
|
|
|
- }
|
|
|
- // 查询待下载数据
|
|
|
- List<ExamTaskDetailDto> examTaskDetailDtoList = downloadService.listExamQuery(semesterId, examId, orgId, courseName, idSet, dpr);
|
|
|
- List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = new ArrayList<>();
|
|
|
- for (ExamTaskDetailDto examTaskDetailDto : examTaskDetailDtoList) {
|
|
|
- ExamTaskPaperExportDto examTaskPaperExportDto = new ExamTaskPaperExportDto(examTaskDetailDto);
|
|
|
- examTaskPaperExportDtoList.add(examTaskPaperExportDto);
|
|
|
- List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
|
|
|
- // 选择曝光卷型
|
|
|
- if (PaperFileDownloadExposureStatusEnum.EXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
|
|
|
- if (StringUtils.isBlank(examTaskDetailDto.getExposedPaperType())) {
|
|
|
- examTaskPaperExportDto.setResult("没有曝光卷型,下载失败");
|
|
|
- continue;
|
|
|
- } else {
|
|
|
- paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getExposedPaperType());
|
|
|
- }
|
|
|
- }
|
|
|
- // 选择未曝光卷型
|
|
|
- if (PaperFileDownloadExposureStatusEnum.UNEXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
|
|
|
- if (StringUtils.isBlank(examTaskDetailDto.getUnexposedPaperType())) {
|
|
|
- examTaskPaperExportDto.setResult("没有未曝光卷型,下载失败");
|
|
|
- continue;
|
|
|
- } else {
|
|
|
- paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getUnexposedPaperType());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(paperInfoVoList)) {
|
|
|
- examTaskPaperExportDto.setResult("所选试卷状态未查询到上传的试卷信息,下载失败");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 命题规则
|
|
|
- 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();
|
|
|
-
|
|
|
- // 目录规则(课程名称(课程代码)/试卷编号)
|
|
|
- String secondPath = examTaskDetailDto.getCourseName() + SystemConstant.HYPHEN + examTaskDetailDto.getCourseCode() + File.separator + examTaskDetailDto.getPaperNumber();
|
|
|
- for (PaperInfoVo paperInfoVo : paperInfoVoList) {
|
|
|
- // 下载试卷
|
|
|
- if (downloadPaper) {
|
|
|
- // 不管什么命名规则,默认都加上卷型前缀
|
|
|
- fileNamePath = "试卷" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
|
|
|
- // 原文件名
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 下载题卡
|
|
|
- if (downloadCard) {
|
|
|
- Long cardId = Long.valueOf(paperInfoVo.getCardId());
|
|
|
- ExamCard examCard = examCardService.getById(cardId);
|
|
|
- Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
|
|
|
-
|
|
|
- String cardHtmlPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
|
|
|
- String cardPdfPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
|
|
|
- // 原文件名
|
|
|
- if (namedByOriginalFile) {
|
|
|
- cardHtmlPath = StringUtils.deleteWhitespace(cardHtmlPath + SystemConstant.HYPHEN + examCard.getTitle() + SystemConstant.HTML_PREFIX);
|
|
|
- cardPdfPath = StringUtils.deleteWhitespace(cardPdfPath + SystemConstant.HYPHEN + examCard.getTitle() + SystemConstant.PDF_PREFIX);
|
|
|
- } else {
|
|
|
- cardHtmlPath = StringUtils.deleteWhitespace(cardHtmlPath + SystemConstant.HTML_PREFIX);
|
|
|
- cardPdfPath = StringUtils.deleteWhitespace(cardPdfPath + SystemConstant.PDF_PREFIX);
|
|
|
- }
|
|
|
-
|
|
|
- // html
|
|
|
- File localFile = new File(cardHtmlPath);
|
|
|
- if (!localFile.exists()) {
|
|
|
- localFile.getParentFile().mkdirs();
|
|
|
- localFile.createNewFile();
|
|
|
- }
|
|
|
- // 通用题卡
|
|
|
- String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent(), examCard.getCourseId());
|
|
|
- // 生成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("下载成功");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 导出文件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", examTaskDetailDtoList.size());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
- } finally {
|
|
|
- if (Objects.nonNull(zipFile)) {
|
|
|
- zipFile.delete();
|
|
|
- }
|
|
|
- if (Objects.nonNull(zipLocalRootPath)) {
|
|
|
- ConvertUtil.delFolder(zipLocalRootPath);
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 验证机构是否存在
|
|
|
*
|