|
@@ -14,6 +14,7 @@ import com.google.gson.Gson;
|
|
|
import com.itextpdf.text.DocumentException;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
|
+import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
|
|
|
import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
|
|
|
import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
|
|
|
import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
|
|
@@ -170,6 +171,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Resource
|
|
|
private BasicExamService basicExamService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DownloadService downloadService;
|
|
|
+
|
|
|
/**
|
|
|
* 创建pdf前置条件
|
|
|
*
|
|
@@ -391,7 +395,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
int seq = atomicInteger.getAndIncrement();
|
|
|
int mod = seq % examTaskDetail.getDrawCount();
|
|
|
String tempPaperType = paperTypes.get(mod);
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContent, null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule);;
|
|
|
+ BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContent, null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule);
|
|
|
+ ;
|
|
|
if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
|
stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
|
JSONObject object = new JSONObject();
|
|
@@ -642,7 +647,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
jsonObject.put(SystemConstant.PATH, dirName);
|
|
|
jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
|
|
|
map.put(SystemConstant.PATH, jsonObject.toString());
|
|
|
- map.put(SystemConstant.DATA_COUNT,examinationExportDtoList.size());
|
|
|
+ map.put(SystemConstant.DATA_COUNT, examinationExportDtoList.size());
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -1631,6 +1636,161 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception {
|
|
|
+ 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();
|
|
|
+ Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
|
|
|
+ Boolean namedByPaperNumber = downloadPaperFileParam.getNamedByPaperNumber();
|
|
|
+ Boolean namedByOriginalFile = downloadPaperFileParam.getNamedByOriginalFile();
|
|
|
+ PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
|
|
|
+ PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
|
|
|
+
|
|
|
+ String courseName = downloadPaperFileParam.getCourseName();
|
|
|
+ Set<Long> idSet = downloadPaperFileParam.getIdSet();
|
|
|
+
|
|
|
+
|
|
|
+ LocalDateTime nowTime = LocalDateTime.now();
|
|
|
+ String zipJoiner = SystemConstant.TEMP_FILES_DIR + File.separator;
|
|
|
+ String dirName = UploadFileEnum.FILE.getTitle() + File.separator +
|
|
|
+ nowTime.getYear() + File.separator +
|
|
|
+ String.format("%02d", nowTime.getMonthValue()) + File.separator +
|
|
|
+ String.format("%02d", nowTime.getDayOfMonth()) +
|
|
|
+ File.separator + SystemConstant.getUuid() + SystemConstant.ZIP_PREFIX;
|
|
|
+ String dirNameTmp = dirName.replaceAll("\\\\", "/");
|
|
|
+ File zipFile = new File(zipJoiner + dirNameTmp);
|
|
|
+ if (!zipFile.getParentFile().exists()) {
|
|
|
+ boolean mkd = zipFile.getParentFile().mkdirs();
|
|
|
+ boolean cf = zipFile.createNewFile();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 跟文件路径
|
|
|
+ String zipLocalRootPath = SystemConstant.TEMP_FILES_DIR + 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 = "试卷使用清单";
|
|
|
+
|
|
|
+ // 所有试卷信息
|
|
|
+ List<ExamTaskPaperFileDto> examTaskPaperFileDtoList = examTaskPaperDto.getExamTaskPaperFileDtoList();
|
|
|
+ switch (paperFileDownloadExposureStatus) {
|
|
|
+ case EXPOSED_PAPER: // 曝光的
|
|
|
+ excelName = excelName + "(" + paperFileDownloadExposureStatus.getDesc() + ")";
|
|
|
+ examTaskPaperFileDtoList = examTaskPaperFileDtoList.stream().filter(ExamTaskPaperFileDto::getExposureStatus).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case UNEXPOSED_PAPER: // 未曝光的
|
|
|
+ excelName = excelName + "(" + paperFileDownloadExposureStatus.getDesc() + ")";
|
|
|
+ examTaskPaperFileDtoList = examTaskPaperFileDtoList.stream().filter(e -> !e.getExposureStatus()).collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case ALL_PAPER: // 全部试卷
|
|
|
+ excelName = excelName + "(" + paperFileDownloadExposureStatus.getDesc() + ")";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String excelLocalPath = zipLocalRootPath + File.separator + excelName + "." + SystemConstant.XLSX;
|
|
|
+ convertUtil.saveLocal(in,excelLocalPath);
|
|
|
+
|
|
|
+ // 二级路径 课程
|
|
|
+ Set<String> courseSet = examTaskPaperFileDtoList.stream().map(e -> e.getCourseName() + "-" + e.getCourseCode()).collect(Collectors.toSet());
|
|
|
+ for (String course : courseSet) {
|
|
|
+ // 三级路径 课程代码-课程名称/试卷编号
|
|
|
+ Set<String> paperNumberSet = examTaskPaperFileDtoList
|
|
|
+ .stream()
|
|
|
+ .filter(e -> course.equals(e.getCourseName() + "-" + 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;
|
|
|
+
|
|
|
+ Long examCardId = paperCellList.get(0).getExamCardId();
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
|
|
|
+ String htmlContent = examCardDetail.getHtmlContent();
|
|
|
+ byte[] bytes = htmlContent.getBytes();
|
|
|
+ String cardLocalPath = filePath + "题卡-" + examCardService.getById(examCardId).getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
+
|
|
|
+ switch (paperFileDownloadContent) {
|
|
|
+ case ONLY_CARD: // 只下载题卡
|
|
|
+ File localFile = new File(cardLocalPath);
|
|
|
+ if (!localFile.getParentFile().exists()) {
|
|
|
+ boolean mkr = localFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localFile);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
|
|
|
+ String paperPath = examTaskPaperFileDto.getPaperPath();
|
|
|
+ fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case PAPER_AND_CARD: // 全部下载
|
|
|
+ // 题卡
|
|
|
+ File localCardFile = new File(cardLocalPath);
|
|
|
+ if (!localCardFile.getParentFile().exists()) {
|
|
|
+ boolean mkr = localCardFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localCardFile);
|
|
|
+ // 试卷
|
|
|
+ for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
|
|
|
+ String paperName = "试卷-";
|
|
|
+ if (namedByCourseInfo){
|
|
|
+ paperName = paperName + course;
|
|
|
+ }
|
|
|
+ if (namedByPaperNumber){
|
|
|
+ paperName = paperName + paperNumber;
|
|
|
+ }
|
|
|
+ if (namedByOriginalFile){
|
|
|
+ paperName = paperName + examTaskPaperFileDto.getPaperName();
|
|
|
+ }
|
|
|
+ String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
|
|
|
+ String paperPath = examTaskPaperFileDto.getPaperPath();
|
|
|
+ fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), false);
|
|
|
+// ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));
|
|
|
+ fileStoreUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))), fileStoreUtil.getUploadEnumByPath(dirNameTmp).getFssType());
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put(SystemConstant.PATH, dirNameTmp);
|
|
|
+ jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
+ jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
|
|
|
+ tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
|
+ ConvertUtil.delFolder(zipLocalRootPath);
|
|
|
+ zipFile.delete();
|
|
|
+ map.put("count", 1);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public String createTempNumber(SerialNumberParams serialNumberParams) {
|
|
|
return convertUtil.getIncre(serialNumberParams.getPrefix(), serialNumberParams.getModel(), serialNumberParams.getDigit());
|