| | |
| | | |
| | | |
| | | |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.Collections; |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.aspose.words.License; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.drew.imaging.ImageMetadataReader; |
| | | import com.drew.metadata.Metadata; |
| | | import com.drew.metadata.exif.ExifIFD0Directory; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelExp; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheet; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; |
| | | import com.ruoyi.domain.ArchiveCategory; |
| | | import com.ruoyi.domain.ArchiveProjectName; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.DocumentMaterials; |
| | | import com.ruoyi.domain.vo.DocumentMaterialFileSmallVo; |
| | | import com.ruoyi.domain.vo.*; |
| | | import com.ruoyi.framework.config.ServerConfig; |
| | | import com.ruoyi.framework.web.domain.server.Sys; |
| | | import com.ruoyi.service.IArchiveProjectNameService; |
| | | import com.ruoyi.service.IArchiveRecordsService; |
| | | import com.ruoyi.service.IDocumentMaterialsService; |
| | | import com.ruoyi.service.impl.BarcodeService; |
| | | import com.ruoyi.service.impl.pdfGenerateService; |
| | | import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; |
| | | import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; |
| | | import org.apache.commons.imaging.ImageInfo; |
| | | import org.apache.commons.imaging.Imaging; |
| | | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
| | | import org.springframework.core.io.support.ResourcePatternResolver; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | public class DocumentMaterialsController extends BaseController |
| | | { |
| | | @Autowired |
| | | private IArchiveProjectNameService iArchiveProjectNameService; |
| | | @Autowired |
| | | private BarcodeService barcodeService; |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | @Autowired |
| | | private pdfGenerateService pdfGenerateService; |
| | | @Autowired |
| | | private IDocumentMaterialsService documentMaterialsService; |
| | | |
| | | @Autowired |
| | | private IArchiveRecordsService iArchiveRecordsService; |
| | | /** |
| | | * 判断PageNumber是否连续 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:materials:list')") |
| | | @GetMapping("/isPageNubLegal/{recordId}") |
| | | public AjaxResult judgePageLegal(@PathVariable("recordId") Integer recordId) |
| | | { |
| | | |
| | | boolean res = documentMaterialsService.isPageNumberIslegal(recordId); |
| | | int cnt = documentMaterialsService.getFileCount(recordId); |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | data.put("res",res); |
| | | data.put("total",cnt); |
| | | return AjaxResult.success(data); |
| | | } |
| | | /** |
| | | * 拿到对应的案卷材料个数 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:materials:list')") |
| | | @GetMapping("/getFileCount/{recordId}") |
| | | public AjaxResult getFileCount(@PathVariable("recordId") Integer recordId) |
| | | { |
| | | |
| | | int cnt = documentMaterialsService.getFileCount(recordId); |
| | | return AjaxResult.success(cnt); |
| | | } |
| | | |
| | | /** |
| | | * 判断卷内目录是否上传了附件 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:materials:list')") |
| | | @GetMapping("/judge/{recordId}") |
| | | public AjaxResult judge(@PathVariable("recordId") Integer recordId) |
| | | { |
| | | |
| | | Boolean cnt = documentMaterialsService.judgeInfo(recordId); |
| | | return AjaxResult.success(cnt); |
| | | } |
| | | |
| | | /** |
| | | * 根据页号添加中间记录的接口 |
| | | * 例如页号1,5,7,则添加页号为2,3,4(信息与1保持一致),6(信息与5保持一致) |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:materials:edit')") |
| | | @GetMapping("/addMiddleRecords/{recordId}/{maxPageNumber}") |
| | | public AjaxResult addMiddleRecords(@PathVariable("recordId") Long recordId,@PathVariable("maxPageNumber") Long maxPageNumber) |
| | | { |
| | | return documentMaterialsService.addMiddleRecordsByPageNumbers(recordId, maxPageNumber); |
| | | } |
| | | /** |
| | | * 查询【文件材料综合信息】列表 |
| | | */ |
| | |
| | | @GetMapping("/list") |
| | | public AjaxResult list(DocumentMaterials documentMaterials) |
| | | { |
| | | |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return documentMaterialsService.selectDataList(documentMaterials, pageNum, pageSize); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:materials:export')") |
| | | @Log(title = "【文件材料综合信息】", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, DocumentMaterials documentMaterials) |
| | | public void export(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids) |
| | | { |
| | | List<DocumentMaterials> list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials); |
| | | List<DocumentMaterials> list; |
| | | System.out.println(ids); |
| | | // 如果提供了ids参数,则根据ids导出指定记录 |
| | | if (ids != null && ids.length > 0) { |
| | | list = documentMaterialsService.selectDocumentMaterialsByIds(ids); |
| | | } else { |
| | | list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials); |
| | | |
| | | } |
| | | ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class); |
| | | util.exportExcel(response, list, "【文件材料综合信息】数据"); |
| | | util.exportExcel(response, list, "电子文件目录"); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:materials:export')") |
| | | @Log(title = "【导出卷内目录】", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportDir") |
| | | public void exportDir(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids) |
| | | { |
| | | List<DocumentMaterials> list; |
| | | System.out.println(ids); |
| | | // 如果提供了ids参数,则根据ids导出指定记录 |
| | | if (ids != null && ids.length > 0) { |
| | | list = documentMaterialsService.selectDocumentMaterialsByIds(ids); |
| | | } else { |
| | | list = documentMaterialsService.selectDocumentMaterialsList(documentMaterials); |
| | | |
| | | } |
| | | // 根据visible字段筛选,只保留visible为1的记录 |
| | | List<DocumentMaterials> filteredList = list.stream() |
| | | .filter(doc -> doc.getVisible() != null && doc.getVisible() == 1 && !Objects.equals(doc.getFileStyle(), "其他材料")) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 使用AtomicLong实现序号的递增 |
| | | AtomicLong nm = new AtomicLong(1L); |
| | | // 将筛选后的DocumentMaterials转换为DocumentMaterialsVo |
| | | List<DocumentMaterialsVoSmall> list1 = filteredList.stream().map(doc -> { |
| | | DocumentMaterialsVoSmall vo = new DocumentMaterialsVoSmall(); |
| | | // 手动映射字段,使用getAndIncrement()方法获取当前值并递增 |
| | | vo.setNum(nm.getAndIncrement()); |
| | | |
| | | vo.setDocumentNumber(doc.getDocumentNumber()); |
| | | vo.setCreator(doc.getCreator()); |
| | | vo.setTitle(doc.getTitle()); |
| | | vo.setDate(doc.getDate()); |
| | | vo.setPageNumber(doc.getPageNumber()); |
| | | vo.setRemarks(doc.getRemarks()); |
| | | // vo.setRecordId(doc.getRecordId() != null ? doc.getRecordId().toString() : null); |
| | | // vo.setPublicity(doc.getPublicity()); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | ExcelUtil<DocumentMaterialsVoSmall> util = new ExcelUtil<DocumentMaterialsVoSmall>(DocumentMaterialsVoSmall.class); |
| | | util.exportExcel(response, list1, "卷内目录"); |
| | | } |
| | | |
| | | // List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); |
| | | |
| | | /** |
| | | * 获取【文件材料综合信息】详细信息 |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody DocumentMaterials documentMaterials) |
| | | { |
| | | documentMaterials.setVisible(1); |
| | | int res = documentMaterialsService.insertDocumentMaterials(documentMaterials); |
| | | System.out.println(res+"][[[[[[[[[[[[[[[[[["); |
| | | return toAjax(res); |
| | |
| | | return "A0"; |
| | | } |
| | | |
| | | @PostMapping("/upload") |
| | | public AjaxResult uploadFile(MultipartFile file, Long recordId) throws Exception |
| | | @PostMapping("/upload/{recordId}") |
| | | public AjaxResult uploadFile(MultipartFile file, @PathVariable Long recordId) throws Exception |
| | | { |
| | | // System.out.println("sdfd9999999999999999999999999999999"); |
| | | try |
| | |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | //分割文件名 |
| | | String [] nams = fname.split("\\."); |
| | | System.out.println(fname); |
| | | Long nam = Long.parseLong(nams[0]); |
| | | //文件名称 |
| | | String pname = nams[1]; |
| | | ajax.put("url", url); |
| | | //拿到图像属性 |
| | | BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", file.getSize()*1.0/1024)); |
| | | System.out.println(wid+":"+hei+":"+sz); |
| | | //拿到图像的dpi信息 |
| | | //根据页号拿到案卷的详细信息 |
| | | System.out.println(recordId); |
| | | System.out.println("0-------------"); |
| | | |
| | | ImageInfo info = Imaging.getImageInfo(file.getBytes()); |
| | | DocumentMaterials doc = documentMaterialsService.selectByPageNumber(nam, Math.toIntExact(recordId)); |
| | | if(doc==null) |
| | | return AjaxResult.error("无对应页号,请检查清楚附件以及对应的输入!"); |
| | | else{ |
| | | if(doc.getSecurityLevel()!=null&&doc.getSecurityLevel().equals("该页另存")) |
| | | { |
| | | |
| | | //替换为了准备好的图像 |
| | | //读取服务器上的图像 |
| | | // new InputStream(); |
| | | String fp = filePath + "\\glc.jpg"; |
| | | Path path = Paths.get(fp); |
| | | File fil = new File(fp); |
| | | //拿到图像属性 |
| | | BufferedImage bufferedImage = ImageIO.read(Files.newInputStream(path)); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", Files.size(path)*1.0/1024)); |
| | | System.out.println("ddsdsdsd"); |
| | | System.out.println(wid+":"+hei+":"+sz); |
| | | |
| | | //拿到图像的dpi信息 |
| | | |
| | | ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path)); |
| | | |
| | | |
| | | int wdpi = info.getPhysicalWidthDpi() ; |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | System.out.println("DPI: " + info.getPhysicalWidthDpi()); |
| | | //计算fileNumber |
| | | Long fileNumber = documentMaterialsService.getFiNum(nam); |
| | | //计算sizeType |
| | | String sizeType = getPageSize(wid*hei); |
| | | //插入数据库对应的url当中 |
| | | documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi, sz, fileName, pname, recordId); |
| | | // System.out.println(url); |
| | | int wdpi = info.getPhysicalWidthDpi() ; |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | System.out.println("DPI: " + info.getPhysicalWidthDpi()); |
| | | //计算fileNumber |
| | | Long fileNumber = documentMaterialsService.getFiNum(nam,recordId); |
| | | //计算sizeType |
| | | String sizeType = getPageSize(wid*hei); |
| | | |
| | | |
| | | Graphics2D g2d = bufferedImage.createGraphics(); // 获取Graphics2D对象用于绘制 |
| | | g2d.setFont(new Font("Arial", Font.BOLD, 80)); // 设置字体样式和大小 |
| | | g2d.setColor(Color.black); // 设置字体颜色为白色,可根据需要调整颜色和字体样式 |
| | | String pageNumber = doc.getPageNumber()+""; // 页码字符串,可以根据需要修改或动态生成 |
| | | int fontHeight = g2d.getFontMetrics().getHeight(); // 获取字体高度,用于定位文本位置 |
| | | int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80; // 计算文本X坐标位置,确保在右下角附近 |
| | | int y = bufferedImage.getHeight() - fontHeight / 2 - 100; // 计算文本Y坐标位置,垂直居中显示文本 |
| | | g2d.drawString(pageNumber, x, y); // 在图片上绘制页码文本 |
| | | |
| | | |
| | | System.out.println(pageNumber+"[[[[[[[[[[[[[[["); |
| | | g2d.dispose(); // 释放Graphics2D资源 |
| | | // File outputFile = new File(filePath+"/output_image.jpg"); // 输出文件路径 |
| | | // ImageIO.write(bufferedImage, "jpg", outputFile); // 保 |
| | | //得到BufferedImage对象 |
| | | MultipartFile multipartFile = null; |
| | | try { |
| | | //创建一个ByteArrayOutputStream |
| | | ByteArrayOutputStream os = new ByteArrayOutputStream(); |
| | | //把BufferedImage写入ByteArrayOutputStream |
| | | ImageIO.write(bufferedImage, "jpg", os); |
| | | //ByteArrayOutputStream转成InputStream |
| | | InputStream input = new ByteArrayInputStream(os.toByteArray()); |
| | | //InputStream转成MultipartFile |
| | | multipartFile = new MockMultipartFile(pageNumber, pageNumber+".jpg", "text/plain", input); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 上传并返回新文件名称 |
| | | String fileName1 = FileUploadUtils.upload(filePath, multipartFile); |
| | | String url1 = serverConfig.getUrl() + fileName; |
| | | |
| | | |
| | | String us = "/profile/upload/0071.jpg"; |
| | | documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi, sz, fileName1, "jpg", recordId); |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | //文件名称 |
| | | String pname = nams[1]; |
| | | ajax.put("url", url); |
| | | //拿到图像属性 |
| | | BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", file.getSize()*1.0/1024)); |
| | | System.out.println(wid+":"+hei+":"+sz); |
| | | //拿到图像的dpi信息 |
| | | |
| | | ImageInfo info = Imaging.getImageInfo(file.getBytes()); |
| | | |
| | | |
| | | int wdpi = info.getPhysicalWidthDpi() ; |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | System.out.println("DPI: " + info.getPhysicalWidthDpi()+nam+"dds"); |
| | | //计算fileNumber |
| | | Long fileNumber = documentMaterialsService.getFiNum(nam, recordId); |
| | | //计算sizeType |
| | | String sizeType = getPageSize(wid*hei); |
| | | //插入数据库对应的url当中 |
| | | documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi, sz, fileName, pname, recordId); |
| | | // |
| | | } |
| | | } |
| | | System.out.println(url); |
| | | // System.out.println(fileName); |
| | | ajax.put("fileName", fileName); |
| | | // System.out.println(FileUtils.getName(fileName)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | System.out.println("88888888882222222222222"); |
| | | System.out.println(e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | |
| | | ExcelUtil<DocumentMaterialFileSmallVo> util = new ExcelUtil<>(DocumentMaterialFileSmallVo.class); |
| | | util.exportExcel(response,list,"档案详细信息导入模板"); |
| | | } |
| | | public boolean getLicense() { |
| | | boolean result = false; |
| | | try { |
| | | InputStream is = null; |
| | | |
| | | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
| | | org.springframework.core.io.Resource[] resources = resolver.getResources("classpath:words.xml"); |
| | | is = resources[0].getInputStream(); |
| | | // ��Ŀ��lincense.xml��·�� |
| | | License aposeLic = new License(); |
| | | aposeLic.setLicense(is); |
| | | result = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | //导出备考表 |
| | | @PostMapping("/exportBack/{id}/{recordId}") |
| | | public void exportBackInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) |
| | | { |
| | | //09-备考表.pdf |
| | | String pdf09Path = "09-备考表.pdf"; |
| | | |
| | | //根据项目名称拿到公司名称和项目负责人 |
| | | |
| | | String compName = "广州盈家档案管理有限公司"; |
| | | String li_person = "仇翀"; |
| | | String sh_person = "曾瑞莹"; |
| | | ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id); |
| | | ArchiveProjectName tmp = new ArchiveProjectName(); |
| | | tmp.setName(archiveRecords.getProjectName()); |
| | | List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp); |
| | | if(!projectName.isEmpty()) |
| | | { |
| | | if(StringUtils.isEmpty(projectName.get(0).getCompanyName())) |
| | | compName = projectName.get(0).getCompanyName(); |
| | | if(StringUtils.isEmpty(projectName.get(0).getCreatePerson())) |
| | | li_person = projectName.get(0).getCreatePerson(); |
| | | } |
| | | // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id); |
| | | //拿到相关数据 |
| | | List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | |
| | | LocalDate currentDate = LocalDate.now(); |
| | | |
| | | |
| | | String cdt = currentDate.getYear()+"年"+currentDate.getMonthValue()+"月"+currentDate.getDayOfMonth()+"日"; |
| | | |
| | | HashMap<String, Object> hs = new HashMap<String, Object>(); |
| | | int allPages = 0; |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | if(!dmfs.isEmpty()) |
| | | { |
| | | for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs) |
| | | { |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("文字材料")) |
| | | texPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("图样材料")) |
| | | patPages = documentMaterialFileStyle.getCnt(); |
| | | if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("照片材料")) |
| | | picPages = documentMaterialFileStyle.getCnt(); |
| | | } |
| | | } |
| | | allPages = texPages + picPages + patPages; |
| | | hs.put("pages", allPages); |
| | | hs.put("patPages", patPages); |
| | | hs.put("picPages", picPages); |
| | | hs.put("texPages", texPages); |
| | | hs.put("volumeNumber", recordId); |
| | | hs.put("company", compName); |
| | | hs.put("time", cdt); |
| | | |
| | | if (!getLicense()) { |
| | | System.out.println("没有相关证书!"); |
| | | } |
| | | |
| | | |
| | | try { |
| | | |
| | | // 获取 Word 模板所在路径 |
| | | // String filepath = "09-备考表.docx"; |
| | | // // 通过 XWPFTemplate 编译文件并渲染数据到模板中 |
| | | // XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs |
| | | // ); |
| | | // 获取 Word 模板所在路径 |
| | | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
| | | org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx"); |
| | | // String filepath = resource.getFile().getAbsolutePath(); |
| | | // // 通过 XWPFTemplate 编译文件并渲染数据到模板中 |
| | | // XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs |
| | | // ); |
| | | |
| | | InputStream inputStream = resource.getInputStream(); |
| | | // 通过 XWPFTemplate 编译文件并渲染数据到模板中 |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream).render(hs |
| | | ); |
| | | |
| | | String renderedDocPath = "rendered_output.docx"; |
| | | File renderedFile = new File(renderedDocPath); |
| | | try { |
| | | // 将完成数据渲染的文档写出 |
| | | template.writeAndClose(new FileOutputStream(renderedFile)); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | com.aspose.words.Document doc = new com.aspose.words.Document("rendered_output.docx"); |
| | | // 创建临时字节输出流 |
| | | ByteArrayOutputStream baobk = new ByteArrayOutputStream(); |
| | | // 将Word文档转换为PDF字节数组 |
| | | doc.save(response.getOutputStream(), com.aspose.words.SaveFormat.PDF);//ȫ��֧��DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF �ת�� |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | //导出卷内目录 |
| | | @PostMapping("/exportJuan/{id}") |
| | | |
| | | public void exportJuanInfo(HttpServletResponse response, @PathVariable Long id) throws IOException { |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); |
| | | |
| | | //拿到卷内目录的excel |
| | | List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(), |
| | | res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList()); |
| | | if(!dsvs.isEmpty()) { |
| | | String recordId = dsvs.get(0).getRecordId(); |
| | | byte[] imgr = barcodeService.generateBarcodeImage(recordId); |
| | | ExcelExp e1 = new ExcelExp("卷内目录数据", dsvs, DocumentMaterialsVo.class); |
| | | ExcelExp e2 = new ExcelExp("卷内数据", list2, recordId, imgr, DocumentMaterialsVoSmall.class); |
| | | List<ExcelExp> mysheet = new ArrayList<ExcelExp>(); |
| | | mysheet.add(e1); |
| | | mysheet.add(e2); |
| | | ExcelUtilManySheet<List<ExcelExp>> util2 = new ExcelUtilManySheet<List<ExcelExp>>(mysheet); |
| | | // ZipEntry entr = new ZipEntry(fna + adir + "/" + "卷内目录" + ".xls"); |
| | | // ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class); |
| | | // System.out.println(dsvs); |
| | | // zos.putNextEntry(entr); |
| | | ByteOutputStream bos8 = new ByteOutputStream(); |
| | | |
| | | util2.exportExcelManySheet(bos8, mysheet); |
| | | |
| | | bos8.writeTo( response.getOutputStream()); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | //导出案卷封面 |
| | | @PostMapping("/exportPageInfo/{id}/{recordId}") |
| | | public void exportPageInfo(HttpServletResponse response, @PathVariable Long id, @PathVariable String recordId) throws IOException { |
| | | |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | |
| | | List<ArchiveInfoVo> arsi = new ArrayList<>(); |
| | | arsi.add(aIV); |
| | | |
| | | String recordId1 = recordId; |
| | | byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1); |
| | | byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 200, 200); |
| | | ExcelExp e3 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class); |
| | | ExcelExp e4 = new ExcelExp("案卷封面", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>(); |
| | | mysheet1.add(e3); |
| | | mysheet1.add(e4); |
| | | ByteOutputStream bos2 = new ByteOutputStream(); |
| | | ExcelUtilManySheetSecond<List<ExcelExp>> util3 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet1); |
| | | |
| | | util3.exportExcelManySheet(bos2, mysheet1); |
| | | |
| | | // System.out.println(bos2); |
| | | bos2.writeTo(response.getOutputStream()); |
| | | |
| | | } |
| | | |
| | | |
| | | } |