| | |
| | | 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; |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | //把附件和记录一一对应 |
| | | 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()+"", fp); |
| | | // 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 对象 |
| | | 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(), archiveRecords1.getPageCount()); |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]); |
| | | |
| | | System.out.println(aIV.getInquiryNumber()); |
| | | System.out.println(aIV.getRecordId()); |
| | | String adir = aIV.getInquiryNumber() + " " + aIV.getRecordId(); |
| | |
| | | |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = dc.getUrl(); |
| | | String filePath = fileMap.get(dc.getPageNumber().toString()); |
| | | if(filePath==null) |
| | | continue; |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | // filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | System.out.println(filePath); |
| | | 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-办案过程材料")) |
| | |
| | | public void packDownload(HttpServletResponse response, @PathVariable Long id) throws Exception { |
| | | |
| | | |
| | | |
| | | // 获取文件的保存位置,读取数据库, |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | documentMaterials.setRecordId(id); |
| | | // List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id); |
| | | // List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id); |
| | | //根据id拿到pageNumber |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | System.out.println(aIV.getPageCount()+"++++++++++++++++=="); |
| | | 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; |
| | |
| | | System.out.println(dc.getPageNumber()); |
| | | String fip = fileMap.get(dc.getPageNumber().toString()); |
| | | // 创建 File 对象 |
| | | if(fip==null||fip.equals("")) |
| | | { |
| | | throw new RuntimeException("电子文件信息没有上传完整,请补充!"); |
| | | |
| | | |
| | | } |
| | | File file = new File(fip); |
| | | |
| | | // 使用 ImageIO 读取图片 |
| | |
| | | String fname = ""; |
| | | // if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) { |
| | | |
| | | if(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 = "-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "." |
| | | fname = frontCompWithZore(4, dc.getFileNumber().intValue()) +"-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "." |
| | | + filePath.split("\\.")[1]; |
| | | |
| | | System.out.println(fname); |