Commit 89112e9a488de8998f6b8f286817904f29b991d6

Authored by yeqianyong
1 parent dd6e0c96

楚江erp:订货单批量导出bug修复-文件名重复处理

@@ -524,8 +524,8 @@ public class PurchaseOrderInfoController extends DefaultBaseController { @@ -524,8 +524,8 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
524 } 524 }
525 525
526 @ApiOperation("订货单批量打印") 526 @ApiOperation("订货单批量打印")
527 - @GetMapping("/batchPrintPurchaseOrder")  
528 - public InvokeResult<Void> batchPrintPurchaseOrder( QueryPurchaseOrderInfoVo vo) { 527 + @PostMapping("/batchPrintPurchaseOrder")
  528 + public InvokeResult<Void> batchPrintPurchaseOrder(@RequestBody QueryPurchaseOrderInfoVo vo) {
529 vo.setExportType(ExportType.ORDER_EXPORT_ZIP.getCode()); 529 vo.setExportType(ExportType.ORDER_EXPORT_ZIP.getCode());
530 ExportTaskUtil.exportTask("订货单信息", OrderInfoExportTaskWorker.class, vo); 530 ExportTaskUtil.exportTask("订货单信息", OrderInfoExportTaskWorker.class, vo);
531 return InvokeResultBuilder.success(); 531 return InvokeResultBuilder.success();
@@ -177,6 +177,8 @@ public class BusinessDataExportHandler implements ExportHandler { @@ -177,6 +177,8 @@ public class BusinessDataExportHandler implements ExportHandler {
177 if ("PRODUCTION_PROCESS".equals(queryVo.getTemplateType())) { 177 if ("PRODUCTION_PROCESS".equals(queryVo.getTemplateType())) {
178 templateResource = new ClassPathResource("templates/purchaseOrderTemplateForProduction.xlsx"); 178 templateResource = new ClassPathResource("templates/purchaseOrderTemplateForProduction.xlsx");
179 } 179 }
  180 + // 时间格式
  181 + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
180 try (FileOutputStream fosZip = new FileOutputStream(file); 182 try (FileOutputStream fosZip = new FileOutputStream(file);
181 ZipOutputStream zos = new ZipOutputStream(fosZip)) { 183 ZipOutputStream zos = new ZipOutputStream(fosZip)) {
182 for (PurchaseOrderInfo orderInfo : orderInfoList) { 184 for (PurchaseOrderInfo orderInfo : orderInfoList) {
@@ -265,6 +267,8 @@ public class BusinessDataExportHandler implements ExportHandler { @@ -265,6 +267,8 @@ public class BusinessDataExportHandler implements ExportHandler {
265 dataMap.put("priceListNo", orderInfo.getPriceListNo()); 267 dataMap.put("priceListNo", orderInfo.getPriceListNo());
266 dataMap.put("productionProcess", orderInfo.getProductionProcess()); 268 dataMap.put("productionProcess", orderInfo.getProductionProcess());
267 ExcelUtil.processTemplate(workbook, dataMap); 269 ExcelUtil.processTemplate(workbook, dataMap);
  270 +
  271 + String createTime = orderInfo.getCreateTime().format(dateTimeFormatter);
268 if ("PDF".equals(queryVo.getExportFileType())) { 272 if ("PDF".equals(queryVo.getExportFileType())) {
269 // 输出PDF 273 // 输出PDF
270 File tempExcel = File.createTempFile("purchase_order_" + orderInfo.getOrderNo(), ".xlsx"); 274 File tempExcel = File.createTempFile("purchase_order_" + orderInfo.getOrderNo(), ".xlsx");
@@ -273,7 +277,7 @@ public class BusinessDataExportHandler implements ExportHandler { @@ -273,7 +277,7 @@ public class BusinessDataExportHandler implements ExportHandler {
273 } 277 }
274 File pdfFile = ExcelUtil.convertExcelToPdf(tempExcel, "/usr/bin/libreoffice --headless --convert-to pdf --outdir %s %s"); 278 File pdfFile = ExcelUtil.convertExcelToPdf(tempExcel, "/usr/bin/libreoffice --headless --convert-to pdf --outdir %s %s");
275 try (InputStream pdfIn = new FileInputStream(pdfFile)) { 279 try (InputStream pdfIn = new FileInputStream(pdfFile)) {
276 - ZipEntry entry = new ZipEntry(orderInfo.getOrderNo() + "-订货单打印.pdf"); 280 + ZipEntry entry = new ZipEntry(orderInfo.getOrderNo() + "-订货单打印-" + createTime + ".pdf");
277 zos.putNextEntry(entry); 281 zos.putNextEntry(entry);
278 byte[] buffer = new byte[8192]; 282 byte[] buffer = new byte[8192];
279 int len; 283 int len;
@@ -292,7 +296,7 @@ public class BusinessDataExportHandler implements ExportHandler { @@ -292,7 +296,7 @@ public class BusinessDataExportHandler implements ExportHandler {
292 } else { 296 } else {
293 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 297 ByteArrayOutputStream baos = new ByteArrayOutputStream();
294 workbook.write(baos); 298 workbook.write(baos);
295 - ZipEntry entry = new ZipEntry(orderInfo.getOrderNo() + "-订货单打印.xlsx"); 299 + ZipEntry entry = new ZipEntry(orderInfo.getOrderNo() + "-订货单打印-" + createTime + ".xlsx");
296 zos.putNextEntry(entry); 300 zos.putNextEntry(entry);
297 zos.write(baos.toByteArray()); 301 zos.write(baos.toByteArray());
298 zos.closeEntry(); 302 zos.closeEntry();