Commit 89112e9a488de8998f6b8f286817904f29b991d6

Authored by yeqianyong
1 parent dd6e0c96

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

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