| | |
| | | import com.itextpdf.text.pdf.PdfWriter; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelExp; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheet; |
| | | import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond; |
| | | import com.ruoyi.common.utils.poi.*; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.DocumentMaterials; |
| | | import com.ruoyi.domain.vo.*; |
| | |
| | | @PostMapping("/exportChooseArchive/{ids}") |
| | | public void exportChooseArchive(HttpServletResponse response, @PathVariable Long[] ids)throws Exception |
| | | { |
| | | //计算文件的大小 |
| | | Double siz = 0.0; |
| | | 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"); |
| | | for (DocumentMaterialsVoLarge dc : docs) { |
| | | if(dc!=null) |
| | | siz += dc.getFileSize()!=null?dc.getFileSize():0; |
| | | } |
| | | } |
| | | System.out.println(siz/1000); |
| | | //判断是否大于4G,是的话,直接抛出异常 |
| | | System.out.println("092939932"); |
| | | String zipFileName ="test" +".zip"; |
| | | //生成压缩包存储地址(最后会删掉) |
| | |
| | | //移交清单 |
| | | List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords); |
| | | System.out.println(lrs); |
| | | System.out.println("99999999990000"); |
| | | ZipEntry entry1 = new ZipEntry("移交清单" + ".xls"); |
| | | ExcelUtil<ArchiveRecordSmall> util1 = new ExcelUtil<ArchiveRecordSmall>(ArchiveRecordSmall.class); |
| | | |
| | | |
| | | |
| | | ExcelExp e6 = new ExcelExp("移交清单",lrs, ArchiveRecordSmall.class); |
| | | // ExcelExp e4 = new ExcelExp("案卷封面", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet6 = new ArrayList<ExcelExp>(); |
| | | mysheet6.add(e6); |
| | | // mysheet1.add(e4); |
| | | ByteOutputStream bos6 = new ByteOutputStream(); |
| | | ExcelUtilManySheetThird<List<ExcelExp>> util6 = new ExcelUtilManySheetThird<List<ExcelExp>>(mysheet6); |
| | | |
| | | util6.exportExcelManySheet(bos6, mysheet6); |
| | | |
| | | // System.out.println(bos2); |
| | | zos.putNextEntry(entry1); |
| | | ByteOutputStream bos1 = new ByteOutputStream(); |
| | | util1.byteOutputStreamExcel(bos1, lrs,"移交清单", ""); |
| | | bos1.writeTo(zos); |
| | | // ByteOutputStream bos1 = new ByteOutputStream(); |
| | | // util6.byteOutputStreamExcel(bos1, lrs,"移交清单", ""); |
| | | bos6.writeTo(zos); |
| | | |
| | | |
| | | |
| | | |
| | | for(int i = 0; i < ids.length; i++) { |
| | | |
| | | // 获取文件的保存位置,读取数据库, |
| | |
| | | zos.putNextEntry(entry5); |
| | | ByteOutputStream bos5 = new ByteOutputStream(); |
| | | util5.byteOutputStreamExcel(bos5, docs,"电子文件目录", ""); |
| | | bos.writeTo(zos); |
| | | bos5.writeTo(zos); |
| | | |
| | | //拿到卷内目录的excel |
| | | List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(), |
| | |
| | | // ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class); |
| | | System.out.println(dsvs); |
| | | zos.putNextEntry(entr); |
| | | ByteOutputStream bos6 = new ByteOutputStream(); |
| | | ByteOutputStream bos8 = new ByteOutputStream(); |
| | | |
| | | util2.exportExcelManySheet(bos6, mysheet); |
| | | |
| | | // util1.byteOutputStreamExcel(bos1, dsvs,"Date List", ""); |
| | | bos6.writeTo(zos); |
| | | bos8.writeTo(zos); |
| | | } |
| | | //把excel转为pdf |
| | | |
| | |
| | | in.close(); |
| | | } |
| | | } |
| | | System.out.println(file.getName()); |
| | | writeFileToRes(response, file.getName(), file); |
| | | |
| | | //删除压缩包 |
| | | // if(file.exists()){ |
| | | // file.delete(); |
| | | // } |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | System.out.println(file.getName()); |
| | | System.out.println(file.getTotalSpace()); |
| | | // file. |
| | | writeFileToRes(response, file.getName(), file); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| | | String filePath = RuoYiConfig.getDownloadPath() + fileName; |
| | | |
| | | |
| | | if(file.exists()) |
| | | System.out.println("322329323232323"); |
| | | System.out.println(filePath+"0009999999999"); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |