| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipFile; |
| | |
| | | @RestController |
| | | @RequestMapping("/system/archiveAllExport") |
| | | public class archiveAllExportController { |
| | | // 存储当天导出序号的Map,键为日期(yyyyMMdd),值为当前序号 |
| | | private static Map<String, Integer> dailySequenceMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Autowired |
| | | private pdfGenerateService pdfGenerateService; |
| | |
| | | |
| | | @Autowired |
| | | private IArchiveRecordsService iArchiveRecordsService; |
| | | |
| | | // 用于生成当天导出序号的方法 |
| | | private String generateDailySequence(String date) { |
| | | // 使用synchronized确保线程安全 |
| | | synchronized (dailySequenceMap) { |
| | | // 获取当前日期的序号,如果不存在则初始化为0 |
| | | int sequence = dailySequenceMap.getOrDefault(date, 0); |
| | | // 序号递增 |
| | | sequence++; |
| | | // 更新Map中的序号 |
| | | dailySequenceMap.put(date, sequence); |
| | | // 格式化为三位字符串,不足三位补前导零 |
| | | return String.format("%03d", sequence); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | System.out.println(siz/1000); |
| | | //判断是否大于4G,是的话,直接抛出异常 |
| | | long maxSize = 4L * 1024 * 1024 * 1024; // 4GB in bytes |
| | | if (siz > maxSize) { |
| | | throw new RuntimeException("文件总大小超过4GB,无法导出"); |
| | | } |
| | | System.out.println("092939932"); |
| | | String zipFileName ="test" +".zip"; |
| | | //生成压缩包存储地址(最后会删掉) |
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | String formattedDate = date.format(formatter); |
| | | System.out.println(formattedDate); |
| | | String fna = "GH"+20250908+"/"; |
| | | |
| | | // 生成当天导出序号 |
| | | String sequence = generateDailySequence(formattedDate); |
| | | String fna = "GH" + formattedDate + sequence + "/"; |
| | | zos.putNextEntry(new ZipEntry(fna)); |
| | | |
| | | |
| | |
| | | archiveRecords.setIds(ids); |
| | | List<ArchiveRecords> lis = iArchiveRecordsService.selectArchiveRecordsList(archiveRecords); |
| | | //案卷目录导出 |
| | | ZipEntry entry = new ZipEntry("案卷目录" + ".xls"); |
| | | ZipEntry entry = new ZipEntry(fna + "案卷目录" + ".xls"); |
| | | ExcelUtil<ArchiveRecords> util = new ExcelUtil<ArchiveRecords>(ArchiveRecords.class); |
| | | |
| | | zos.putNextEntry(entry); |
| | |
| | | List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords); |
| | | System.out.println(lrs); |
| | | System.out.println("99999999990000"); |
| | | ZipEntry entry1 = new ZipEntry("移交清单" + ".xls"); |
| | | ZipEntry entry1 = new ZipEntry(fna + "移交清单" + ".xls"); |
| | | ExcelUtil<ArchiveRecordSmall> util1 = new ExcelUtil<ArchiveRecordSmall>(ArchiveRecordSmall.class); |
| | | |
| | | |
| | |
| | | |
| | | //.selectDocumentMaterialsList(documentMaterials); |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString()); |
| | | if(dsvs==null||dsvs.isEmpty()) |
| | | { |
| | | throw new RuntimeException("电子文件信息没有上传,请补充!"); |
| | | } |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id); |
| | | |
| | | System.out.println(dsvs.size()); |
| | | List<String> paths = new ArrayList<>(); |
| | | // System.out.println(docs); |
| | | if (docs.size() == 1) { // 直接下载 |
| | |
| | | System.out.println(filePath+"0009999999999"); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | // response.addHeader("Content-Disposition", "attachment;filename=fileName" + ".xls"); |
| | | |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | |
| | | } |
| | |
| | | |
| | | //pdf目录封面 |
| | | String pdfPathF = "07-案卷封面.pdf"; |
| | | pdfGenerateService.generatePdf(pdfPathF, 55L); |
| | | pdfGenerateService.generatePdf(pdfPathF, id); |
| | | // 2. 压缩PDF到ZIP文件 |
| | | // 添加PDF文件到ZIP |
| | | ZipEntry zipEntry = new ZipEntry(pdfPathF); |