|
@@ -19,6 +19,7 @@ import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
|
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
|
import com.qmth.distributed.print.business.util.PdfUtil;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.MqDto;
|
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SpringContextHolder;
|
|
@@ -118,6 +119,8 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
@Resource
|
|
|
TeachcloudCommonService teachcloudCommonService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
|
|
/**
|
|
|
* 保存附件
|
|
@@ -148,9 +151,9 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
} else if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.HTML_PREFIX)) {
|
|
|
filePath = (String) jsonObject.get(SystemConstant.PATH);
|
|
|
url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
|
|
|
- UploadFileEnum uploadType = Enum.valueOf(UploadFileEnum.class,(String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
+ UploadFileEnum uploadType = Enum.valueOf(UploadFileEnum.class, (String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
// htmlFile = ossUtil.ossDownload(filePath, url);
|
|
|
- htmlFile = fileStoreUtil.ossDownload(filePath, url,uploadType.getFssType());
|
|
|
+ htmlFile = fileStoreUtil.ossDownload(filePath, url, uploadType.getFssType());
|
|
|
}
|
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
|
StringJoiner pdfStringJoiner = new StringJoiner("");
|
|
@@ -180,7 +183,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
if (oss) {//上传至oss
|
|
|
pdfDto = PdfUtil.addPdfPage(pdfFile);
|
|
|
// ossUtil.ossUpload(pdfDirNameStr, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(pdfFileMd5)));
|
|
|
- fileStoreUtil.ossUpload(pdfDirNameStr, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(pdfFileMd5)),fileStoreUtil.getUploadEnumByPath(pdfDirNameStr).getFssType());
|
|
|
+ fileStoreUtil.ossUpload(pdfDirNameStr, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(pdfFileMd5)), fileStoreUtil.getUploadEnumByPath(pdfDirNameStr).getFssType());
|
|
|
// htmlFile.delete();
|
|
|
}
|
|
|
JSONObject attachmentPath = JSONObject.parseObject(examDetail.getAttachmentPath());
|
|
@@ -251,12 +254,12 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
if (oss) {//上传至oss
|
|
|
String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
|
|
|
// ossUtil.ossUpload(dirName, htmlContent);
|
|
|
- fileStoreUtil.ossUpload(dirName,htmlContent,fileStoreUtil.getUploadEnumByPath(dirName).getFssType());
|
|
|
+ fileStoreUtil.ossUpload(dirName, htmlContent, fileStoreUtil.getUploadEnumByPath(dirName).getFssType());
|
|
|
jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
jsonObject.put(SystemConstant.PATH, dirName);
|
|
|
String url = SystemConstant.TEMP_FILES_DIR + File.separator + dirName;
|
|
|
// File localHtmlFile = ossUtil.ossDownload(dirName, url);
|
|
|
- File localHtmlFile = fileStoreUtil.ossDownload(dirName, url,fileStoreUtil.getUploadEnumByPath(dirName).getFssType());
|
|
|
+ File localHtmlFile = fileStoreUtil.ossDownload(dirName, url, fileStoreUtil.getUploadEnumByPath(dirName).getFssType());
|
|
|
StringJoiner pdfStringJoiner = new StringJoiner("");
|
|
|
pdfStringJoiner.add(UploadFileEnum.PDF.getTitle()).add(File.separator);
|
|
|
pdfStringJoiner.add(String.valueOf(nowTime.getYear())).add(File.separator)
|
|
@@ -279,8 +282,8 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
localFileList.add(new PdfDto(pdfFile.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
|
|
|
fileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
|
|
|
// ossUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)));
|
|
|
- pdfDirName = pdfDirName.replaceAll("\\\\","/");
|
|
|
- fileStoreUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)),fileStoreUtil.getUploadEnumByPath(pdfDirName).getFssType());
|
|
|
+ pdfDirName = pdfDirName.replaceAll("\\\\", "/");
|
|
|
+ fileStoreUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)), fileStoreUtil.getUploadEnumByPath(pdfDirName).getFssType());
|
|
|
// localHtmlFile.delete();
|
|
|
jsonObject.put(SystemConstant.PDF_PATH, pdfDirName);
|
|
|
// htmlMd5
|
|
@@ -391,7 +394,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
stringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(format);
|
|
|
if (oss) {//上传至oss\
|
|
|
String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
|
|
|
- fileStoreUtil.ossUpload(dirName,file.getInputStream(),md5,type.getFssType());
|
|
|
+ fileStoreUtil.ossUpload(dirName, file.getInputStream(), md5, type.getFssType());
|
|
|
|
|
|
jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
jsonObject.put(SystemConstant.PATH, dirName);
|
|
@@ -474,6 +477,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
}
|
|
|
return basicCourseService.removeById(id);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 保存科目
|
|
|
*
|
|
@@ -644,7 +648,9 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
}
|
|
|
map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
|
|
|
map.computeIfAbsent(SystemConstant.USER, v -> sysUserService.getById(tbTask.getCreateId()));
|
|
|
- asyncCreatePdfTempleteService.createPdf(map, null);
|
|
|
+// asyncCreatePdfTempleteService.createPdf(map, null);
|
|
|
+ MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(tbTask.getId()));
|
|
|
+ redisUtil.sendMessage(mqDto.getTopic(), mqDto);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -674,7 +680,9 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
}
|
|
|
map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
|
|
|
map.computeIfAbsent(SystemConstant.USER, v -> sysUserService.getById(tbTask.getCreateId()));
|
|
|
- asyncCreatePdfTempleteService.createPdf(map, null);
|
|
|
+// asyncCreatePdfTempleteService.createPdf(map, null);
|
|
|
+ MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(tbTask.getId()));
|
|
|
+ redisUtil.sendMessage(mqDto.getTopic(), mqDto);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -882,7 +890,9 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
}
|
|
|
|
|
|
Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.CREATE_PDF, examDetail.getPrintPlanId(), user, examDetail.getId());
|
|
|
- asyncCreatePdfTempleteService.createPdf(map, null);
|
|
|
+// asyncCreatePdfTempleteService.createPdf(map, null);
|
|
|
+ MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(map.get(SystemConstant.TB_TASK_ID)));
|
|
|
+ redisUtil.sendMessage(mqDto.getTopic(), mqDto);
|
|
|
}
|
|
|
}
|
|
|
}
|