|
@@ -0,0 +1,513 @@
|
|
|
+package org.springblade.archive.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.util.IOUtils;
|
|
|
+import org.springblade.archive.entity.ArchiveFormulaConfig;
|
|
|
+import org.springblade.archive.entity.ArchiveProjectConfig;
|
|
|
+import org.springblade.archive.entity.ArchivesAuto;
|
|
|
+import org.springblade.archive.service.IArchiveAutoPdfService;
|
|
|
+import org.springblade.archive.service.IArchiveFormulaConfigService;
|
|
|
+import org.springblade.archive.service.IArchiveProjectConfigService;
|
|
|
+import org.springblade.archive.utils.FileUtils;
|
|
|
+import org.springblade.archive.utils.FormulaUtil;
|
|
|
+import org.springblade.business.entity.ArchiveFile;
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.common.vo.DataVO;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
|
+
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
+
|
|
|
+ private final IArchiveProjectConfigService archiveProjectConfigService;
|
|
|
+
|
|
|
+ private final IArchiveFormulaConfigService archiveFormulaConfigService;
|
|
|
+
|
|
|
+ public static final String[] ARCHIVE_NUMBER = new String[]{"r_Archives_front","r_Archives_catalog","r_Archives_spare","r_Archives_back"};
|
|
|
+
|
|
|
+ public static final Map<String, String> URL_MAP = new HashMap<>();
|
|
|
+
|
|
|
+ static {
|
|
|
+ URL_MAP.put("r_Archives_front", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230413/306c87ffc640699aa92d53a5f4e6d632.xlsx");
|
|
|
+ URL_MAP.put("r_Archives_catalog", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230413/f2a083fca685c646e4a47daaaa46f04b.xlsx");
|
|
|
+ URL_MAP.put("r_Archives_spare", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230414/3798f8c3db6f94c8fce63eec8c716d6c.xlsx");
|
|
|
+ URL_MAP.put("r_Archives_back", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230413/31081917b41e12b9b0359f6a9c1755bd.xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static final String LocalPath = "/www/wwwroot/Users/hongchuangyanfa/Desktop/";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void test1() {
|
|
|
+
|
|
|
+ Long pkeyId = SnowFlakeUtil.getId();
|
|
|
+
|
|
|
+ String file_path = "D:\\tmp";
|
|
|
+ String excelUrl = file_path + "\\备考表.xlsx";
|
|
|
+
|
|
|
+ Map<String, Object> DataInfo = new HashMap<>();
|
|
|
+
|
|
|
+ DataVO dataVO = FormulaUtil.convertCellToIndex("C2");
|
|
|
+ String key = "1__"+ dataVO.getY() + "_" + dataVO.getX();
|
|
|
+ DataInfo.put(key,"档号123456");
|
|
|
+
|
|
|
+ DataVO dataVO1 = FormulaUtil.convertCellToIndex("A9");
|
|
|
+ String key1 = "2__"+ dataVO1.getY() + "_" + dataVO1.getX();
|
|
|
+ DataInfo.put(key1,"hahahahaa");
|
|
|
+ try {
|
|
|
+ String url = getBussPdfInfo(pkeyId,DataInfo,excelUrl,file_path);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void test() {
|
|
|
+
|
|
|
+ Long projectId = 1578599210897772545L;
|
|
|
+
|
|
|
+ ArchivesAuto archivesAuto = new ArchivesAuto();
|
|
|
+ archivesAuto.setProjectId(projectId);
|
|
|
+ archivesAuto.setName("案卷提名");
|
|
|
+ archivesAuto.setFileNumber("档号");
|
|
|
+ archivesAuto.setMicron("缩微号");
|
|
|
+ archivesAuto.setUnit("单位");
|
|
|
+ archivesAuto.setQuantity("数量/单位");
|
|
|
+ archivesAuto.setSpecification("规格");
|
|
|
+ archivesAuto.setStorageTime("1");
|
|
|
+ archivesAuto.setSecretLevel("1");
|
|
|
+ archivesAuto.setCarrierType("载体类型");
|
|
|
+ archivesAuto.setKeywords("主题词");
|
|
|
+ archivesAuto.setReviewer("审核人");
|
|
|
+ archivesAuto.setReviewDate(LocalDateTime.now());
|
|
|
+ archivesAuto.setStartDate(LocalDateTime.now());
|
|
|
+ archivesAuto.setEndDate(LocalDateTime.now());
|
|
|
+ archivesAuto.setStorageLocation("存放位置");
|
|
|
+ archivesAuto.setIsArchive(0);
|
|
|
+ archivesAuto.setRemark("备注");
|
|
|
+ archivesAuto.setRollDate(LocalDateTime.now().minusDays(1));
|
|
|
+ archivesAuto.setRollor("立卷人");
|
|
|
+ archivesAuto.setNodeId(123L);
|
|
|
+ archivesAuto.setOutUrl("http://example.com");
|
|
|
+ archivesAuto.setCdId(456L);
|
|
|
+ archivesAuto.setFileN(2);
|
|
|
+ archivesAuto.setPageN(100);
|
|
|
+ archivesAuto.setMileage("统一里程信息");
|
|
|
+ archivesAuto.setFileType(1);
|
|
|
+ archivesAuto.setSize(1024);
|
|
|
+ archivesAuto.setTreeSort("ABC");
|
|
|
+ archivesAuto.setIsOpen(1);
|
|
|
+ archivesAuto.setIscheck(1);
|
|
|
+ archivesAuto.setIsAutoFile(0);
|
|
|
+ archivesAuto.setAutoFileSort(1);
|
|
|
+ archivesAuto.setFilingUnit("立卷单位");
|
|
|
+ archivesAuto.setIsLock(0);
|
|
|
+
|
|
|
+ ArchiveFile archiveFile = new ArchiveFile();
|
|
|
+ archiveFile.setProjectId(projectId.toString());
|
|
|
+ archiveFile.setContractId("合同段ID");
|
|
|
+ archiveFile.setNodeId("文件绑定的节点ID");
|
|
|
+ archiveFile.setFileNumber("");
|
|
|
+ archiveFile.setFileName("文件名称");
|
|
|
+ archiveFile.setFileTime("20230413");
|
|
|
+ archiveFile.setFileUrl("http://example.com/file");
|
|
|
+ archiveFile.setPdfFileUrl("http://example.com/pdf");
|
|
|
+ archiveFile.setFilePage(10);
|
|
|
+ archiveFile.setIsApproval(1);
|
|
|
+ archiveFile.setIsNeedCertification(1);
|
|
|
+ archiveFile.setIsCertification(1);
|
|
|
+ archiveFile.setCertificationTime("2023-04-13 14:30:00");
|
|
|
+ archiveFile.setDutyUser("责任者");
|
|
|
+ archiveFile.setSheetType("图幅");
|
|
|
+ archiveFile.setSheetSource("图表来源");
|
|
|
+ archiveFile.setDrawingNo("图号");
|
|
|
+ archiveFile.setCiteChangeNumber("引用变更令编号");
|
|
|
+ archiveFile.setEVisaFile("http://example.com/evisa");
|
|
|
+ archiveFile.setNodeExtId(123L);
|
|
|
+ archiveFile.setFileType(1L);
|
|
|
+ archiveFile.setArchiveId(456L);
|
|
|
+ archiveFile.setOriginId(789L);
|
|
|
+ archiveFile.setFilmingTime(LocalDateTime.now().minusDays(2));
|
|
|
+ archiveFile.setFilmingorTime(LocalDateTime.now().minusDays(1));
|
|
|
+ archiveFile.setTagId("标签ID");
|
|
|
+ archiveFile.setPicCode("相片号");
|
|
|
+ archiveFile.setReferCode("参见号");
|
|
|
+ archiveFile.setFilmCode("底片号");
|
|
|
+ archiveFile.setWidth(800);
|
|
|
+ archiveFile.setHeight(600);
|
|
|
+
|
|
|
+ List<ArchiveFile> archiveFiles = new ArrayList<>();
|
|
|
+
|
|
|
+ for (int i = 0; i < 20;i++) {
|
|
|
+ archiveFiles.add(archiveFile);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ buildArchiveFrontPdfs(projectId,archivesAuto,archiveFiles);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param projectId
|
|
|
+ * @param archivesAuto
|
|
|
+ * @param archiveFileList
|
|
|
+ */
|
|
|
+ public void buildArchiveFrontPdfs(Long projectId, ArchivesAuto archivesAuto,List<ArchiveFile> archiveFileList) {
|
|
|
+ // 调用 getByProjectIdOrNew 方法获取 ArchiveProjectConfig 对象,并从中取得 factorType 的值
|
|
|
+ ArchiveProjectConfig config = archiveProjectConfigService.getByProjectIdOrNew(projectId);
|
|
|
+
|
|
|
+ // 根据 factorType 字符串生成档案号码字符串链表
|
|
|
+ List<String> numberFronts = new ArrayList<>();
|
|
|
+ List<String> numberBacks = new ArrayList<>();
|
|
|
+ if (config.getFactorType().contains("1")) {
|
|
|
+ numberFronts.add(ARCHIVE_NUMBER[0]);
|
|
|
+ }
|
|
|
+ if (config.getFactorType().contains("2")) {
|
|
|
+ numberFronts.add(ARCHIVE_NUMBER[1]);
|
|
|
+ }
|
|
|
+ if (config.getFactorType().contains("3")) {
|
|
|
+ numberBacks.add(ARCHIVE_NUMBER[2]);
|
|
|
+ }
|
|
|
+ if (config.getFactorType().contains("4")) {
|
|
|
+ numberBacks.add(ARCHIVE_NUMBER[3]);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> variables = dataSourceBuilder(archivesAuto,archiveFileList);
|
|
|
+
|
|
|
+ // 使用生成的档案号码字符串链表生成档案 PDF 文件
|
|
|
+ List<String> frontUrls = new ArrayList<>();
|
|
|
+ List<String> backUrls = new ArrayList<>();
|
|
|
+ for (String number : numberFronts) {
|
|
|
+ // 具体实现省略
|
|
|
+ buildFrontPdf(number, variables,frontUrls);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String number : numberBacks) {
|
|
|
+ // 具体实现省略
|
|
|
+ buildFrontPdf(number, variables,backUrls);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void buildFrontPdf(String number, Map<String,Object> variables,List<String> urls) {
|
|
|
+ // Step 1: Get the list of formulas using archiveFormulaConfigService
|
|
|
+ List<ArchiveFormulaConfig> formulaConfigs = archiveFormulaConfigService.getByNumber(number);
|
|
|
+
|
|
|
+ String file_path = LocalPath;
|
|
|
+ String excelUrl = getUrlByNumber(number);
|
|
|
+ Map<String, Object> dataInfo = new HashMap<>();
|
|
|
+
|
|
|
+ ArchiveFormulaConfig multiLineconfig = null;
|
|
|
+
|
|
|
+
|
|
|
+ for (ArchiveFormulaConfig config : formulaConfigs) {
|
|
|
+ String coords = config.getCoords();
|
|
|
+ String formula = config.getFormula();
|
|
|
+
|
|
|
+ if(variables.containsKey("ArchiveFile") && variables.get("ArchiveFile") instanceof List
|
|
|
+ && formula.indexOf("ArchiveFile") >= 0){
|
|
|
+
|
|
|
+ multiLineconfig = config;
|
|
|
+ //handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ handleNonArchiveFile(config, coords, formula, variables, file_path, excelUrl, dataInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //一起处理
|
|
|
+ if (multiLineconfig != null) {
|
|
|
+ String coords = multiLineconfig.getCoords();
|
|
|
+ String formula = multiLineconfig.getFormula();
|
|
|
+ handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ try {
|
|
|
+ String url = getBussPdfInfo(null, dataInfo, excelUrl, file_path);
|
|
|
+ urls.add(url);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleArchiveFile(String coords, String formula,
|
|
|
+ Map<String,Object> variables,String file_path,
|
|
|
+ String excelUrl, Map<String, Object> dataInfo,List<String> urls){
|
|
|
+ String[] coordArr = coords.split("~");
|
|
|
+ if (coordArr.length == 2) {
|
|
|
+ DataVO dataVO1 = FormulaUtil.convertCellToIndex(coordArr[0]);
|
|
|
+ DataVO dataVO2 = FormulaUtil.convertCellToIndex(coordArr[1]);
|
|
|
+ Integer pageSize = dataVO2.getY() - dataVO1.getY() + 1;
|
|
|
+
|
|
|
+ List<Map<String,Object>> archiveFiles = (List<Map<String,Object>>)variables.get("ArchiveFile");
|
|
|
+
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
+ if(archiveFiles != null && archiveFiles.size() > 0){
|
|
|
+ int pageIndex = 0; // 当前页数
|
|
|
+ while (true) {
|
|
|
+ List<Map<String,Object>> subList = archiveFiles.subList(pageIndex * pageSize,
|
|
|
+ Math.min((pageIndex + 1) * pageSize, archiveFiles.size()));
|
|
|
+
|
|
|
+ pageMap.clear();
|
|
|
+ pageMap.putAll(dataInfo);
|
|
|
+
|
|
|
+ int subIndex = 0;
|
|
|
+ for (Map<String,Object> archiveMap : subList) {
|
|
|
+ // 处理archiveFile逻辑
|
|
|
+ int y = dataVO1.getY() + subIndex;
|
|
|
+ List<Object> objects = FormulaUtil.expressionParseList(formula, archiveMap);
|
|
|
+ int xIndex = 0;
|
|
|
+ for (Object o: objects) {
|
|
|
+ if (o == null) {
|
|
|
+ xIndex++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int x = dataVO1.getX() + xIndex;
|
|
|
+ String key = subIndex + "__" + y + "_" + x;
|
|
|
+ pageMap.put(key, o);
|
|
|
+ xIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ subIndex++;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String url = getBussPdfInfo(null, pageMap, excelUrl, file_path);
|
|
|
+ urls.add(url);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (subList.size() < pageSize) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pageIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleNonArchiveFile(ArchiveFormulaConfig config, String coords, String formula,
|
|
|
+ Map<String,Object> variables,String file_path,
|
|
|
+ String excelUrl, Map<String, Object> dataInfo) {
|
|
|
+ DataVO dataVO = FormulaUtil.convertCellToIndex(coords);
|
|
|
+ Object object = null;
|
|
|
+ if (formula.indexOf("~") > 0) {
|
|
|
+ String[] formulaArr = formula.split("~");
|
|
|
+ if (formulaArr.length == 2) {
|
|
|
+ Object object1 = FormulaUtil.expressionParse(formulaArr[0],variables);
|
|
|
+ Object object2 = FormulaUtil.expressionParse(formulaArr[1],variables);
|
|
|
+ object = object1 + "~" + object2;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ object = FormulaUtil.expressionParse(formula,variables);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String key = config.getId() + "__" + dataVO.getY() + "_" + dataVO.getX();
|
|
|
+ dataInfo.put(key, object);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static boolean isOssFilePath(String filePath) {
|
|
|
+ return filePath.contains("https") || filePath.contains("aliyun");
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBussPdfInfo(Long pkeyId,Map<String, Object> DataInfo,String excelUrl,String filePath) throws Exception{
|
|
|
+
|
|
|
+ if (pkeyId == null) {
|
|
|
+ pkeyId = SnowFlakeUtil.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ String pdfPath = filePath + "/pdf//" + pkeyId + ".pdf";
|
|
|
+ String excelPath = filePath + "/pdf//" + pkeyId + ".xlsx";
|
|
|
+ File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
+ if (tabPdf.exists()) {
|
|
|
+ tabPdf.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取excel流 和 html流
|
|
|
+ InputStream exceInp = null;
|
|
|
+ if ( isOssFilePath(excelUrl)){
|
|
|
+ exceInp = CommonUtil.getOSSInputStream(excelUrl);
|
|
|
+ }else {
|
|
|
+ exceInp = new FileInputStream(new File(excelUrl));
|
|
|
+ }
|
|
|
+
|
|
|
+ org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(exceInp);
|
|
|
+
|
|
|
+ //获取工作表
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setHorizontallyCenter(true);
|
|
|
+ sheet.setVerticallyCenter(true);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
|
+ for (String val : DataInfo.keySet()) {
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
+ String[] DataVal = val.split("__");
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
+
|
|
|
+ int x1 = 0;
|
|
|
+ int y1 = 0;
|
|
|
+ int x2 = 0;
|
|
|
+ int y2 = 0;
|
|
|
+
|
|
|
+ if (xy.length == 2 ) {
|
|
|
+ x1 = Integer.parseInt(xy[1]);
|
|
|
+ y1 = Integer.parseInt(xy[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (xy.length == 4 ) {
|
|
|
+ x2 = Integer.parseInt(xy[3]);
|
|
|
+ y2 = Integer.parseInt(xy[2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ String myData = DataInfo.get(val) + "";
|
|
|
+
|
|
|
+ //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
|
+ if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
+
|
|
|
+ InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
|
+ byte[] bytes = IOUtils.toByteArray(imageIn);
|
|
|
+ // 这里根据实际需求选择图片类型
|
|
|
+ int pictureIdx = workbook.addPicture(bytes, 6);
|
|
|
+
|
|
|
+ CreationHelper helper = workbook.getCreationHelper();
|
|
|
+ ClientAnchor anchor = helper.createClientAnchor();
|
|
|
+ anchor.setCol1(x1); // param1是列号
|
|
|
+ anchor.setCol2(x2);
|
|
|
+ anchor.setRow1(y1); // param2是行号
|
|
|
+ anchor.setRow2(y2); // param2是行号
|
|
|
+ //
|
|
|
+ Drawing drawing = sheet.createDrawingPatriarch();
|
|
|
+ anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
|
|
+ // 插入图片
|
|
|
+ Picture pict = drawing.createPicture(anchor, pictureIdx); // 调整图片占单元格百分比的大小,1.0就是100%
|
|
|
+ pict.resize(1, 1);
|
|
|
+ FileUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Row row = sheet.getRow(y1 );
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 );
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ cell.setCellValue(myData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
+ workbook.write(outputStream);
|
|
|
+ FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
+
|
|
|
+ String pdfLink = "";
|
|
|
+ if (bladeFile!= null ){
|
|
|
+ pdfLink = bladeFile.getLink();
|
|
|
+ }
|
|
|
+ return pdfLink;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String,Object> dataSourceBuilder(ArchivesAuto archive, List<ArchiveFile> datas){
|
|
|
+
|
|
|
+ //预处理
|
|
|
+ archive.setSecretLevel(FormulaUtil.securityLevelMap.get(archive.getSecretLevel()));
|
|
|
+ archive.setStorageTime(FormulaUtil.storageTimeMap.get(archive.getStorageTime()));
|
|
|
+ archive.setFileN(datas.size());
|
|
|
+
|
|
|
+ Integer idx = 0;
|
|
|
+ Integer iStartPage = 1;
|
|
|
+ List<Map<String, Object>> fileMapList = new ArrayList<>();
|
|
|
+ for (ArchiveFile file: datas) {
|
|
|
+ idx++;
|
|
|
+ file.setId(idx.longValue());
|
|
|
+ if (StringUtil.isEmpty(file.getFileNumber())) {
|
|
|
+ file.setFileNumber("\\");
|
|
|
+ }
|
|
|
+ file.setPageNum(iStartPage.toString());
|
|
|
+
|
|
|
+ iStartPage += file.getFilePage();
|
|
|
+ if (idx >= datas.size() ) {
|
|
|
+ String lastPageNum = file.getPageNum() + "~" + iStartPage;
|
|
|
+ file.setPageNum(lastPageNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> fileMap = new ObjectMapper().convertValue(file, Map.class);
|
|
|
+ fileMapList.add(fileMap);
|
|
|
+ }
|
|
|
+ archive.setPageN(iStartPage - 1);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> archivesAutoMap = new ObjectMapper().convertValue(archive, Map.class);
|
|
|
+ if (archive.getRollDate()!= null) {
|
|
|
+ archivesAutoMap.put("rollDate",FormulaUtil.formatLocalDateTime(archive.getRollDate(),"yyyy年MM月dd日"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (archive.getReviewDate()!= null) {
|
|
|
+ archivesAutoMap.put("reviewDate",FormulaUtil.formatLocalDateTime(archive.getReviewDate(),"yyyy年MM月dd日"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (archive.getStartDate()!= null) {
|
|
|
+ archivesAutoMap.put("startDate",FormulaUtil.formatLocalDateTime(archive.getStartDate(),"yyyyMMdd"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (archive.getEndDate()!= null) {
|
|
|
+ archivesAutoMap.put("endDate",FormulaUtil.formatLocalDateTime(archive.getEndDate(),"yyyyMMdd"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Map<String,Object> variables = new HashMap<>();
|
|
|
+ variables.put("Archive",archivesAutoMap);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ variables.put("ArchiveFile",fileMapList);
|
|
|
+ return variables;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public String getUrlByNumber(String number) {
|
|
|
+ // Get the URL from the static map using the number as key
|
|
|
+ String url = URL_MAP.get(number);
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|