| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheet; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.DocumentMaterials; |
| | | import com.ruoyi.domain.vo.ArchiveInfoVo; |
| | | import com.ruoyi.domain.vo.DocumentMaterialsVo; |
| | | import com.ruoyi.domain.vo.DocumentMaterialsVoLarge; |
| | | import com.ruoyi.domain.vo.DocumentMaterialsVoSmall; |
| | | import com.ruoyi.domain.vo.*; |
| | | import com.ruoyi.framework.web.domain.server.Sys; |
| | | import com.ruoyi.service.IArchiveRecordsService; |
| | | import com.ruoyi.service.IDocumentMaterialsService; |
| | |
| | | import org.apache.poi.xssf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | 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 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.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | |
| | | |
| | | @PostMapping("/exportChooseArchive/{ids}") |
| | | public void exportChooseArchive(HttpServletResponse response, @PathVariable Long[] ids)throws Exception |
| | | { |
| | | System.out.println("092939932"); |
| | | String zipFileName ="test" +".zip"; |
| | | //生成压缩包存储地址(最后会删掉) |
| | | String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName; |
| | | OutputStream os=null; |
| | | ZipOutputStream zos = null ; |
| | | System.out.println("==============_______________"); |
| | | System.out.println(ids.length); |
| | | File file = new File(fileZip); |
| | | try { |
| | | if (!file.getParentFile().exists()) { |
| | | file.getParentFile().mkdirs(); |
| | | } |
| | | os = new FileOutputStream(file); |
| | | //压缩文件 |
| | | zos = new ZipOutputStream(os); |
| | | //拿到当前的时间 |
| | | LocalDate date = LocalDate.now(); |
| | | System.out.println("当前日期: " + date); |
| | | |
| | | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | String formattedDate = date.format(formatter); |
| | | System.out.println(formattedDate); |
| | | String fna = "GH"+20250908+"/"; |
| | | zos.putNextEntry(new ZipEntry(fna)); |
| | | |
| | | |
| | | //添加ids的全部数据到excel |
| | | ArchiveRecords archiveRecords = new ArchiveRecords(); |
| | | archiveRecords.setIds(ids); |
| | | List<ArchiveRecords> lis = iArchiveRecordsService.selectArchiveRecordsList(archiveRecords); |
| | | //案卷目录导出 |
| | | ZipEntry entry = new ZipEntry("案卷目录" + ".xls"); |
| | | ExcelUtil<ArchiveRecords> util = new ExcelUtil<ArchiveRecords>(ArchiveRecords.class); |
| | | |
| | | zos.putNextEntry(entry); |
| | | ByteOutputStream bos = new ByteOutputStream(); |
| | | util.byteOutputStreamExcel(bos, lis,"案卷目录", ""); |
| | | bos.writeTo(zos); |
| | | |
| | | //移交清单 |
| | | List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords); |
| | | System.out.println(lrs); |
| | | ZipEntry entry1 = new ZipEntry("移交清单" + ".xls"); |
| | | ExcelUtil<ArchiveRecordSmall> util1 = new ExcelUtil<ArchiveRecordSmall>(ArchiveRecordSmall.class); |
| | | |
| | | zos.putNextEntry(entry1); |
| | | ByteOutputStream bos1 = new ByteOutputStream(); |
| | | util1.byteOutputStreamExcel(bos1, lrs,"移交清单", ""); |
| | | bos1.writeTo(zos); |
| | | for(int i = 0; i < ids.length; i++) { |
| | | |
| | | // 获取文件的保存位置,读取数据库, |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | documentMaterials.setRecordId(ids[i]); |
| | | List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]); |
| | | System.out.println(docs.size()+"----009"); |
| | | |
| | | |
| | | //.selectDocumentMaterialsList(documentMaterials); |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString()); |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]); |
| | | |
| | | String adir = aIV.getInquiryNumber() + " " + aIV.getRecordId(); |
| | | System.out.println(fna+adir); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/")); |
| | | |
| | | //在里面添加文件 |
| | | boolean res = true; |
| | | if(res) { |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/01-申请材料/")); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/02-办案过程材料/")); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/03-结论性文件/")); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/04-其他材料/")); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/05-档案变更材料/")); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/06-业务数据/")); |
| | | res = false; |
| | | } |
| | | //添加07 的pdf |
| | | //pdf目录封面 |
| | | String pdfPathF = "07-卷面封面.pdf"; |
| | | pdfGenerateService.generatePdf(pdfPathF, ids[i]); |
| | | // 2. 压缩PDF到ZIP文件 |
| | | // 添加PDF文件到ZIP |
| | | ZipEntry zipEntry2 = new ZipEntry(fna + adir +"/"+pdfPathF); |
| | | zos.putNextEntry(zipEntry2); |
| | | |
| | | // 读取PDF文件内容并写入ZIP |
| | | try (FileInputStream fis = new FileInputStream(pdfPathF)) { |
| | | byte[] buffer = new byte[1024]; |
| | | int len; |
| | | while ((len = fis.read(buffer)) > 0) { |
| | | zos.write(buffer, 0, len); |
| | | } |
| | | } |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = dc.getUrl(); |
| | | if(filePath==null) |
| | | continue; |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | System.out.println(filePath); |
| | | File tempFile = new File(filePath); |
| | | |
| | | //在压缩包中添加文件夹 |
| | | |
| | | //得到文件名frontCompWithZore(4, dc.get)+ |
| | | String fname = frontCompWithZore(4, dc.getFileNumber().intValue())+"-"+dc.getTitle()+"-"+frontCompWithZore(4,dc.getPageNumber().intValue())+"." |
| | | +dc.getUrl().split("\\.")[1]; |
| | | if(dc.getStage().equals("01-申请材料")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/01-申请材料/"+fname)); |
| | | else if(dc.getStage().equals("02-办案过程材料")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/02-办案过程材料/"+fname)); |
| | | else if(dc.getStage().equals("03-结论性文件")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/03-结论性文件/"+fname)); |
| | | else if(dc.getStage().equals("04-其他材料")) { |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/04-其他材料/" + fname)); |
| | | } |
| | | else if(dc.getStage().equals("05-档案变更材料")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/05-档案变更材料/"+fname)); |
| | | else if(dc.getStage().equals("06-业务数据")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/06-业务数据/"+fname)); |
| | | else |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/"+fname)); |
| | | |
| | | |
| | | |
| | | int len; |
| | | FileInputStream in = new FileInputStream(tempFile); |
| | | while ((len = in.read(buf)) != -1){ |
| | | zos.write(buf, 0, len); |
| | | } |
| | | // zos.putNextEntry(new ZipEntry("04-其他材料")); |
| | | zos.closeEntry(); |
| | | in.close(); |
| | | } |
| | | } |
| | | System.out.println(file.getName()); |
| | | writeFileToRes(response, file.getName(), file); |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | }finally { |
| | | //关闭流 |
| | | if(zos != null){ |
| | | try { |
| | | zos.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | //关闭流 |
| | | if(os!= null){ |
| | | try { |
| | | os.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * @param response |
| | | * @param |
| | | */ |
| | | @PostMapping("/export") |
| | | @PostMapping("/export/{id}") |
| | | |
| | | public void packDownload(HttpServletResponse response, Long id) throws Exception { |
| | | public void packDownload(HttpServletResponse response, @PathVariable Long id) throws Exception { |
| | | // 获取文件的保存位置,读取数据库, |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | documentMaterials.setRecordId(id); |
| | |
| | | System.out.println(file.getName()); |
| | | |
| | | String fileName =aIV.getRecordId()+".zip"; |
| | | |
| | | //输出文件流 |
| | | writeFileToRes(response, file.getName(), file); |
| | | //删除压缩包 |
| | |
| | | |
| | | //pdf目录封面 |
| | | String pdfPathF = "07-卷面封面.pdf"; |
| | | pdfGenerateService.generatePdf(pdfPathF); |
| | | pdfGenerateService.generatePdf(pdfPathF, 55L); |
| | | // 2. 压缩PDF到ZIP文件 |
| | | // 添加PDF文件到ZIP |
| | | ZipEntry zipEntry = new ZipEntry(pdfPathF); |
| | |
| | | byte[] buf = new byte[1024]; |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | String filePath = dc.getUrl(); |
| | | if(filePath==null) |
| | | continue; |
| | | filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/"); |
| | | |
| | | System.out.println(filePath); |