| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.aspose.cells.PdfCompliance; |
| | | import com.aspose.words.License; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.itextpdf.text.*; |
| | | import com.itextpdf.text.Image; |
| | | import com.itextpdf.text.pdf.PdfPCell; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.poi.*; |
| | | import com.ruoyi.domain.ArchiveProjectName; |
| | |
| | | import com.ruoyi.service.impl.BarcodeService; |
| | | import com.ruoyi.service.impl.pdfGenerateService; |
| | | import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; |
| | | import org.apache.commons.imaging.ImageInfo; |
| | | import org.apache.commons.imaging.Imaging; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
| | | import org.springframework.core.io.support.ResourcePatternResolver; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.*; |
| | | import java.awt.Font; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | |
| | | |
| | | for(int i = 0; i < ids.length; i++) { |
| | | System.out.println(ids[i]); |
| | | |
| | | ArchiveRecords archiveRecords1 = iArchiveRecordsService.selectArchiveRecordsById(ids[i]); |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]); |
| | | // 获取文件的保存位置,读取数据库, |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | documentMaterials.setRecordId(ids[i]); |
| | | List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]); |
| | | System.out.println(docs.size()+"----7777"); |
| | | |
| | | //生成新的记录,不保存再数据库 |
| | | List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(ids[i], archiveRecords1.getPageCount()); |
| | | //把DocumentMaterils转到docs |
| | | List<DocumentMaterialsVoLarge> docs = new ArrayList<>(); |
| | | int nstar = 1; |
| | | |
| | | //统计3中材料的个数 |
| | | int texPages = 0; |
| | | int picPages = 0; |
| | | int patPages = 0; |
| | | for (DocumentMaterials mater : docAllInfo) { |
| | | // physcialService.mySave(physcial); |
| | | DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge(); |
| | | BeanUtils.copyProperties(mater, docum); |
| | | docum.setRecordId(archiveRecords1.getRecordId()); |
| | | docum.setNum(nstar++); |
| | | docs.add(docum); |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("文字材料")) |
| | | texPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("图样材料")) |
| | | patPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("照片材料")) |
| | | picPages++; |
| | | } |
| | | |
| | | |
| | | |
| | | //把附件和记录一一对应 |
| | | String fileSysPath = RuoYiConfig.getUploadPath(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | String path = fileSysPath + File.separator + ids[i]; |
| | | File desc = new File(fileSysPath + File.separator + ids[i]); |
| | | System.out.println("44444444444444456666666666666666"); |
| | | if (!desc.exists()) |
| | | { |
| | | throw new RuntimeException("电子文件信息没有上传,请补充!"); |
| | | } |
| | | |
| | | |
| | | Map<String, String> fileMap = new HashMap<>(); |
| | | try (Stream<Path> paths = Files.walk(Paths.get(path))) { |
| | | fileMap = paths |
| | | .filter(Files::isRegularFile) |
| | | .collect(Collectors.toMap( |
| | | // Key: 文件名前缀(不带扩展名) |
| | | Path -> { |
| | | String fileNam = Path.getFileName().toString(); |
| | | int dotIndex = fileNam.lastIndexOf('.'); |
| | | return dotIndex > 0 ? fileNam.substring(0, dotIndex) : fileNam; |
| | | }, |
| | | // Value: 文件全路径 |
| | | Path::toString, |
| | | // 处理重复键的情况(如果有相同前缀的文件) |
| | | (existing, replacement) -> existing |
| | | )); |
| | | |
| | | } |
| | | |
| | | |
| | | //重新封装一下docs,和附件绑定再一起 |
| | | |
| | | for (int k = 0; k < docs.size(); k++) { |
| | | DocumentMaterialsVoLarge dc = docs.get(k); |
| | | if (dc.getSecurityLevel() != null && (dc.getSecurityLevel().equals("该页另存") || |
| | | dc.getSecurityLevel().equals("秘密") || dc.getSecurityLevel().equals("内部用途") || |
| | | dc.getSecurityLevel().equals("内部用图"))) { |
| | | // 替换为了准备好的图像 |
| | | String fp = fileSysPath + "\\glc.jpg"; |
| | | Path path1 = Paths.get(fp); |
| | | // 拿到图像属性 |
| | | BufferedImage bufferedImage = ImageIO.read(Files.newInputStream(path1)); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", Files.size(path1) * 1.0 / 1024)); |
| | | |
| | | // 拿到图像的dpi信息 |
| | | ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path1)); |
| | | int wdpi = info.getPhysicalWidthDpi(); |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | |
| | | // 计算fileNumber |
| | | // Long fileNumber = documentMaterialsService.getFiNum(nam, recordId); |
| | | // 计算sizeType |
| | | String sizeType = getPageSize(wid * hei); |
| | | |
| | | Graphics2D g2d = bufferedImage.createGraphics(); |
| | | g2d.setFont(new java.awt.Font("宋体", Font.BOLD, 80)); // 设置字体样式和大小 |
| | | g2d.setColor(Color.black); |
| | | String pageNumber = dc.getPageNumber() + ""; |
| | | int fontHeight = g2d.getFontMetrics().getHeight(); |
| | | int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80; |
| | | int y = bufferedImage.getHeight() - fontHeight / 2 - 100; |
| | | g2d.drawString(pageNumber, x, y); |
| | | g2d.dispose(); |
| | | |
| | | // 将BufferedImage转换为MultipartFile |
| | | MultipartFile multipartFile = null; |
| | | ByteArrayOutputStream ost = new ByteArrayOutputStream(); |
| | | ImageIO.write(bufferedImage, "jpg", ost); |
| | | InputStream input = new ByteArrayInputStream(ost.toByteArray()); |
| | | multipartFile = new MockMultipartFile(pageNumber, pageNumber + ".jpg", "text/plain", input); |
| | | |
| | | // 上传并返回新文件名称 |
| | | String fileName1 = FileUploadUtils.upload(fileSysPath, multipartFile); |
| | | // filePath = fileName1; |
| | | dc.setWidth((long) wid); |
| | | dc.setHeight((long) hei); |
| | | dc.setFileSize(sz); |
| | | dc.setFormat(".jpg"); |
| | | dc.setHorizontalResolution((long) wdpi); |
| | | dc.setVerticalResolution((long) hdpi); |
| | | dc.setSizeType(sizeType); |
| | | fileMap.put(dc.getPageNumber()+"", fileName1); |
| | | // dc.set |
| | | // 更新数据库 |
| | | // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId); |
| | | |
| | | // urls.add(serverConfig.getUrl() + fileName1); |
| | | // fileNames.add(fileName1); |
| | | // newFileNames.add(FileUtils.getName(fileName1)); |
| | | // originalFilenames.add(pageNumber + ".jpg"); |
| | | } |
| | | else { |
| | | //文件名称 |
| | | // String pname = nams[1]; |
| | | // ajax.put("url", url); |
| | | //拿到图像属性 |
| | | System.out.println(dc.getPageNumber()); |
| | | String fip = fileMap.get(dc.getPageNumber().toString()); |
| | | // 创建 File 对象 |
| | | if (fip == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | fip = fileMap.get(paddedKey); |
| | | } |
| | | File fils = new File(fip); |
| | | |
| | | // 使用 ImageIO 读取图片 |
| | | BufferedImage image = ImageIO.read(fils); |
| | | BufferedImage bufferedImage = ImageIO.read(fils); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", fils.length()*1.0/1024)); |
| | | System.out.println(wid+":"+hei+":"+sz); |
| | | //拿到图像的dpi信息 |
| | | byte[] bytesArray = new byte[(int) fils.length()]; |
| | | |
| | | FileInputStream fis = new FileInputStream(fils); |
| | | fis.read(bytesArray); //read file into bytes[] |
| | | |
| | | ImageInfo info = Imaging.getImageInfo(bytesArray); |
| | | |
| | | |
| | | int wdpi = info.getPhysicalWidthDpi() ; |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | // System.out.println("DPI: " + info.getPhysicalWidthDpi()+nam+"dds"); |
| | | |
| | | fis.close(); |
| | | //计算fileNumber |
| | | // Long fileNumber = documentMaterialsService.getFiNum(dc.getPageNumber(), id); |
| | | //计算sizeType |
| | | String sizeType = getPageSize(wid*hei); |
| | | |
| | | dc.setWidth((long) wid); |
| | | dc.setHeight((long) hei); |
| | | dc.setFileSize(sz); |
| | | dc.setFormat(".jpg"); |
| | | dc.setHorizontalResolution((long) wdpi); |
| | | dc.setVerticalResolution((long) hdpi); |
| | | dc.setSizeType(sizeType); |
| | | } |
| | | } |
| | | |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString(), archiveRecords1.getPageCount()); |
| | | |
| | | // List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]); |
| | | // System.out.println(docs.size()+"----7777"); |
| | | |
| | | |
| | | //.selectDocumentMaterialsList(documentMaterials); |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString()); |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]); |
| | | |
| | | System.out.println(aIV.getInquiryNumber()); |
| | | System.out.println(aIV.getRecordId()); |
| | | String adir = aIV.getInquiryNumber() + " " + aIV.getRecordId(); |
| | |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | // 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(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | String compName = "广州盈家档案管理有限公司"; |
| | | String li_person = "仇翀"; |
| | | String sh_person = "曾瑞莹"; |
| | | ArchiveRecords archiveRecords1 = iArchiveRecordsService.selectArchiveRecordsById(ids[i]); |
| | | |
| | | if(!StringUtils.isEmpty(archiveRecords1.getLiPerson())) |
| | | li_person = archiveRecords1.getLiPerson(); |
| | | ArchiveProjectName tmp = new ArchiveProjectName(); |
| | |
| | | // 创建PDF保存选项 |
| | | com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions(); |
| | | pdfSaveOptions.setCompliance(com.aspose.cells.PdfCompliance.PDF_A_1_B); |
| | | // 确保字体嵌入到PDF中 |
| | | |
| | | |
| | | // 创建临时字节输出流 |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | |
| | |
| | | |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = dc.getUrl(); |
| | | if(filePath==null) |
| | | continue; |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | String filePath = fileMap.get(dc.getPageNumber().toString()); |
| | | |
| | | // filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | System.out.println(filePath); |
| | | if (filePath == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | filePath = fileMap.get(paddedKey); |
| | | } |
| | | if(filePath==null) |
| | | continue; |
| | | |
| | | if(filePath.contains("profile")) |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | File tempFile = new File(filePath); |
| | | |
| | | //在压缩包中添加文件夹 |
| | |
| | | String fname = ""; |
| | | if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) { |
| | | fname = frontCompWithZore(4, dc.getFileNumber().intValue()) + "-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "." |
| | | + dc.getUrl().split("\\.")[1]; |
| | | + filePath.split("\\.")[1]; |
| | | if (dc.getStage().equals("01-申请材料")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/01-申请材料/" + fname)); |
| | | else if (dc.getStage().equals("02-办案过程材料")) |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 打包下载 |
| | | * @param response |
| | |
| | | @PostMapping("/export/{id}") |
| | | |
| | | public void packDownload(HttpServletResponse response, @PathVariable Long id) throws Exception { |
| | | |
| | | |
| | | // 获取文件的保存位置,读取数据库, |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | documentMaterials.setRecordId(id); |
| | | List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id); |
| | | System.out.println(docs.size()+"----009"); |
| | | // List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id); |
| | | //根据id拿到pageNumber |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | System.out.println(aIV.getPageCount() + "++++++++++++++++=="); |
| | | //生成新的记录,不保存再数据库 |
| | | List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(id, aIV.getPageCount()); |
| | | if (docAllInfo==null||docAllInfo.isEmpty()) |
| | | { |
| | | throw new RuntimeException("请补充完整信息,然后导出ISO包!"); |
| | | } |
| | | //把DocumentMaterils转到docs |
| | | List<DocumentMaterialsVoLarge> docs = new ArrayList<>(); |
| | | int nstar = 1; |
| | | int texPages = 0; |
| | | int patPages = 0; |
| | | int picPages = 0; |
| | | for (DocumentMaterials mater : docAllInfo) { |
| | | // physcialService.mySave(physcial); |
| | | DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge(); |
| | | BeanUtils.copyProperties(mater, docum); |
| | | docum.setRecordId(aIV.getRecordId()); |
| | | docum.setNum(nstar++); |
| | | docs.add(docum); |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("文字材料")) |
| | | texPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("图样材料")) |
| | | patPages++; |
| | | if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("照片材料")) |
| | | picPages++; |
| | | } |
| | | System.out.println(docs.size()+"----009"); |
| | | |
| | | |
| | | //.selectDocumentMaterialsList(documentMaterials); |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); |
| | | if(dsvs==null||dsvs.isEmpty()) |
| | | |
| | | //把附件和记录一一对应 |
| | | String fileSysPath = RuoYiConfig.getUploadPath(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | String path = fileSysPath + File.separator + id; |
| | | File desc = new File(fileSysPath + File.separator + id); |
| | | System.out.println("44444444444444456666666666666666"); |
| | | if (!desc.exists()) |
| | | { |
| | | throw new RuntimeException("电子文件信息没有上传,请补充!"); |
| | | } |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | |
| | | |
| | | Map<String, String> fileMap = new HashMap<>(); |
| | | try (Stream<Path> paths = Files.walk(Paths.get(path))) { |
| | | fileMap = paths |
| | | .filter(Files::isRegularFile) |
| | | .collect(Collectors.toMap( |
| | | // Key: 文件名前缀(不带扩展名) |
| | | Path -> { |
| | | String fileNam = Path.getFileName().toString(); |
| | | int dotIndex = fileNam.lastIndexOf('.'); |
| | | return dotIndex > 0 ? fileNam.substring(0, dotIndex) : fileNam; |
| | | }, |
| | | // Value: 文件全路径 |
| | | Path::toString, |
| | | // 处理重复键的情况(如果有相同前缀的文件) |
| | | (existing, replacement) -> existing |
| | | )); |
| | | |
| | | } |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString(), aIV.getPageCount()); |
| | | |
| | | //重新封装一下docs,和附件绑定再一起 |
| | | |
| | | for (int i = 0; i < docs.size(); i++) { |
| | | DocumentMaterialsVoLarge dc = docs.get(i); |
| | | if (dc.getSecurityLevel() != null && (dc.getSecurityLevel().equals("该页另存") || |
| | | dc.getSecurityLevel().equals("秘密") || dc.getSecurityLevel().equals("内部用途") || |
| | | dc.getSecurityLevel().equals("内部用图"))) { |
| | | // 替换为了准备好的图像 |
| | | String fp = fileSysPath + "\\glc.jpg"; |
| | | Path path1 = Paths.get(fp); |
| | | // 拿到图像属性 |
| | | BufferedImage bufferedImage = ImageIO.read(Files.newInputStream(path1)); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", Files.size(path1) * 1.0 / 1024)); |
| | | |
| | | // 拿到图像的dpi信息 |
| | | ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path1)); |
| | | int wdpi = info.getPhysicalWidthDpi(); |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | |
| | | // 计算fileNumber |
| | | // Long fileNumber = documentMaterialsService.getFiNum(nam, recordId); |
| | | // 计算sizeType |
| | | String sizeType = getPageSize(wid * hei); |
| | | |
| | | Graphics2D g2d = bufferedImage.createGraphics(); |
| | | g2d.setFont(new java.awt.Font("宋体", Font.BOLD, 80)); // 设置字体样式和大小 |
| | | g2d.setColor(Color.black); |
| | | String pageNumber = dc.getPageNumber() + ""; |
| | | int fontHeight = g2d.getFontMetrics().getHeight(); |
| | | int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80; |
| | | int y = bufferedImage.getHeight() - fontHeight / 2 - 100; |
| | | g2d.drawString(pageNumber, x, y); |
| | | g2d.dispose(); |
| | | |
| | | // 将BufferedImage转换为MultipartFile |
| | | MultipartFile multipartFile = null; |
| | | ByteArrayOutputStream ost = new ByteArrayOutputStream(); |
| | | ImageIO.write(bufferedImage, "jpg", ost); |
| | | InputStream input = new ByteArrayInputStream(ost.toByteArray()); |
| | | multipartFile = new MockMultipartFile(pageNumber, pageNumber + ".jpg", "text/plain", input); |
| | | |
| | | // 上传并返回新文件名称 |
| | | String fileName1 = FileUploadUtils.upload(fileSysPath, multipartFile); |
| | | // filePath = fileName1; |
| | | dc.setWidth((long) wid); |
| | | dc.setHeight((long) hei); |
| | | dc.setFileSize(sz); |
| | | dc.setFormat(".jpg"); |
| | | dc.setHorizontalResolution((long) wdpi); |
| | | dc.setVerticalResolution((long) hdpi); |
| | | dc.setSizeType(sizeType); |
| | | System.out.println(fileName1); |
| | | System.out.println("gggggggggggggggg999999999999"); |
| | | fileMap.put(dc.getPageNumber()+"", fileName1); |
| | | // dc.set |
| | | // 更新数据库 |
| | | // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId); |
| | | |
| | | // urls.add(serverConfig.getUrl() + fileName1); |
| | | // fileNames.add(fileName1); |
| | | // newFileNames.add(FileUtils.getName(fileName1)); |
| | | // originalFilenames.add(pageNumber + ".jpg"); |
| | | } |
| | | else { |
| | | //文件名称 |
| | | // String pname = nams[1]; |
| | | // ajax.put("url", url); |
| | | //拿到图像属性 |
| | | System.out.println(dc.getPageNumber()); |
| | | String fip = fileMap.get(dc.getPageNumber().toString()); |
| | | // 如果直接匹配失败,尝试补零匹配 |
| | | if (fip == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | fip = fileMap.get(paddedKey); |
| | | } |
| | | // 创建 File 对象 |
| | | if(fip==null||fip.equals("")) |
| | | { |
| | | throw new RuntimeException("电子文件信息没有上传完整,请补充!"); |
| | | |
| | | |
| | | } |
| | | |
| | | File file = new File(fip); |
| | | |
| | | // 使用 ImageIO 读取图片 |
| | | BufferedImage image = ImageIO.read(file); |
| | | BufferedImage bufferedImage = ImageIO.read(file); |
| | | int wid = bufferedImage.getWidth(); |
| | | int hei = bufferedImage.getHeight(); |
| | | double sz = Double.parseDouble(String.format("%.2f", file.length()*1.0/1024)); |
| | | System.out.println(wid+":"+hei+":"+sz); |
| | | //拿到图像的dpi信息 |
| | | byte[] bytesArray = new byte[(int) file.length()]; |
| | | |
| | | FileInputStream fis = new FileInputStream(file); |
| | | fis.read(bytesArray); //read file into bytes[] |
| | | |
| | | ImageInfo info = Imaging.getImageInfo(bytesArray); |
| | | |
| | | |
| | | int wdpi = info.getPhysicalWidthDpi() ; |
| | | int hdpi = info.getPhysicalHeightDpi(); |
| | | // System.out.println("DPI: " + info.getPhysicalWidthDpi()+nam+"dds"); |
| | | |
| | | fis.close(); |
| | | //计算fileNumber |
| | | // Long fileNumber = documentMaterialsService.getFiNum(dc.getPageNumber(), id); |
| | | //计算sizeType |
| | | String sizeType = getPageSize(wid*hei); |
| | | |
| | | dc.setWidth((long) wid); |
| | | dc.setHeight((long) hei); |
| | | dc.setFileSize(sz); |
| | | dc.setFormat(".jpg"); |
| | | dc.setHorizontalResolution((long) wdpi); |
| | | dc.setVerticalResolution((long) hdpi); |
| | | dc.setSizeType(sizeType); |
| | | } |
| | | } |
| | | System.out.println(dsvs.size()); |
| | | List<String> paths = new ArrayList<>(); |
| | | // System.out.println(docs); |
| | |
| | | String datumName = "user"; |
| | | //压缩文件 |
| | | List<String> filePathList = paths; |
| | | File file = compressedFileToZip(docs, dsvs, aIV, id); |
| | | //把docmentMaterial转为 |
| | | File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap, texPages, patPages, picPages); |
| | | System.out.println(file.getName()); |
| | | |
| | | String fileName =aIV.getRecordId()+".zip"; |
| | |
| | | |
| | | |
| | | // 压缩文件 |
| | | private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id) throws Exception { |
| | | private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id, Map<String, String> fileMap, |
| | | int texPages, |
| | | int patPages, |
| | | int picPages) throws Exception { |
| | | //压缩包具体名称(拼接时间戳防止重名) |
| | | String datumName = ""; |
| | | String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip"; |
| | |
| | | String pdf09Path = "09-备考表.pdf"; |
| | | // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id); |
| | | //拿到相关数据 |
| | | List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | // List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id)); |
| | | |
| | | LocalDate currentDate = LocalDate.now(); |
| | | |
| | |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | // int texPages = 0; |
| | | // int picPages = 0; |
| | | // int patPages = 0; |
| | | // if(!docs.isEmpty()) |
| | | // { |
| | | // for(DocumentMaterialsVoLarge documentMaterialFileStyle:docs) |
| | | // { |
| | | // if(documentMaterialFileStyle!=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(); |
| | | // } |
| | | // } |
| | | |
| | | String compName = "广州盈家档案管理有限公司"; |
| | | String li_person = "仇翀"; |
| | |
| | | |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = dc.getUrl(); |
| | | String filePath = fileMap.get(dc.getPageNumber().toString()); |
| | | |
| | | |
| | | // else { |
| | | // // 文件名称 |
| | | // String pname = nams[1]; |
| | | // |
| | | // // 拿到图像属性 |
| | | // 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)); |
| | | // |
| | | // // 拿到图像的dpi信息 |
| | | // ImageInfo info = Imaging.getImageInfo(file.getBytes()); |
| | | // int wdpi = info.getPhysicalWidthDpi(); |
| | | // int hdpi = info.getPhysicalHeightDpi(); |
| | | // // 计算fileNumber |
| | | // Long fileNumber = documentMaterialsService.getFiNum(nam, recordId); |
| | | // // 计算sizeType |
| | | // String sizeType = getPageSize(wid * hei); |
| | | // |
| | | // // 更新数据库 |
| | | // // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName, pname, recordId); |
| | | //// |
| | | //// urls.add(url); |
| | | //// fileNames.add(fileName); |
| | | //// newFileNames.add(FileUtils.getName(fileName)); |
| | | //// originalFilenames.add(fname); |
| | | // } |
| | | // |
| | | |
| | | |
| | | if (filePath == null) { |
| | | // 补零到4位(根据你的需求调整位数) |
| | | String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue()); |
| | | filePath = fileMap.get(paddedKey); |
| | | System.out.println(paddedKey); |
| | | |
| | | } |
| | | System.out.println(filePath); |
| | | |
| | | if(filePath==null) |
| | | continue; |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | System.out.println(filePath); |
| | | if(filePath.contains("profile")) |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | File tempFile = new File(filePath); |
| | | |
| | | System.out.println(filePath); |
| | | System.out.println(tempFile.length()); |
| | | //在压缩包中添加文件夹 |
| | | if(res) { |
| | | zos.putNextEntry(new ZipEntry("01-申请材料/")); |
| | |
| | | } |
| | | //得到文件名frontCompWithZore(4, dc.get)+ |
| | | String fname = ""; |
| | | if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) { |
| | | fname = frontCompWithZore(4, dc.getFileNumber().intValue()) + "-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "." |
| | | + dc.getUrl().split("\\.")[1]; |
| | | // if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) { |
| | | |
| | | if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) { |
| | | // fname = frontCompWithZore(4, dc.getFileNumber().intValue()) + "-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "." |
| | | // + filePath.split("\\.")[1]; |
| | | fname = frontCompWithZore(4, dc.getFileNumber().intValue()) +"-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "." |
| | | + filePath.split("\\.")[1]; |
| | | |
| | | System.out.println(fname); |
| | | if (dc.getStage().equals("01-申请材料")) |
| | | zos.putNextEntry(new ZipEntry("01-申请材料/" + fname)); |
| | | else if (dc.getStage().equals("02-办案过程材料")) |
| | |
| | | } |
| | | return file; |
| | | } |
| | | |
| | | public String getPageSize(double du) |
| | | { |
| | | if(du <= 8699840 * 1.5) |
| | | return "A4"; |
| | | else if(du <= 17403188 * 1.5) |
| | | return "A3"; |
| | | else if(du <= 34811347 * 1.5) |
| | | return "A2"; |
| | | else if(du <= 69622674 * 1.5) |
| | | return "A1"; |
| | | else |
| | | return "A0"; |
| | | } |
| | | } |
| | | |
| | | |