From 377eec9d813a9ba73ed1630ee7b1940f3ccce0ad Mon Sep 17 00:00:00 2001 From: wwb <782276617@qq.com> Date: Fri, 10 Jul 2026 16:02:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeliveryOrderServiceImpl.java | 55 ++++++++------ .../saleorder/SaleOrderServiceImpl.java | 76 ++++++++++++------- 2 files changed, 78 insertions(+), 53 deletions(-) diff --git a/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/deliveryorder/DeliveryOrderServiceImpl.java b/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/deliveryorder/DeliveryOrderServiceImpl.java index 559ac12..026b98e 100644 --- a/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/deliveryorder/DeliveryOrderServiceImpl.java +++ b/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/deliveryorder/DeliveryOrderServiceImpl.java @@ -22,6 +22,7 @@ import cn.hangtag.module.oms.service.customer.CustomerService; import cn.hangtag.module.oms.service.productinfo.ProductInfoService; import cn.hangtag.module.system.dal.dataobject.user.AdminUserDO; import cn.hangtag.module.system.service.user.AdminUserService; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; @@ -211,34 +212,38 @@ public class DeliveryOrderServiceImpl implements DeliveryOrderService { List deliveryOrders = deliveryOrderMapper.selectList(DeliveryOrderDO::getId, ids); for (DeliveryOrderDO deliveryOrder : deliveryOrders) { List entrys = getDeliveryOrderEntryListByParentId(deliveryOrder.getId()); - String htmlContent = generateHtmlContent(deliveryOrder, entrys); + List> split = ListUtil.split(entrys, 6); + int i = 1; + for (List entrys2 : split) { + String htmlContent = generateHtmlContent(deliveryOrder, entrys2); + //docker生成路径 + String pathUrl = System.getProperty("user.dir") + "/pdffile"; + String fileName = StrUtil.format(pathUrl + "/DeliveryOrder_{}", deliveryOrder.getBillno() + "_" + i); + //主宿机生成路径 + String fileName2 = StrUtil.format(pdfPath + "/DeliveryOrder_{}", deliveryOrder.getBillno() + "_" + i); - //docker生成路径 - String pathUrl = System.getProperty("user.dir") + "/pdffile"; - String fileName = StrUtil.format(pathUrl + "/DeliveryOrder_{}", deliveryOrder.getBillno()); - //主宿机生成路径 - String fileName2 = StrUtil.format(pdfPath + "/DeliveryOrder_{}", deliveryOrder.getBillno()); + String templatePath = fileName + ".html"; + String pdfPath = fileName + ".pdf"; + String templatePath2 = fileName2 + ".html"; + String pdfPath2 = fileName2 + ".pdf"; + FileUtil.writeString(htmlContent, templatePath, "UTF-8"); - String templatePath = fileName + ".html"; - String pdfPath = fileName + ".pdf"; - String templatePath2 = fileName2 + ".html"; - String pdfPath2 = fileName2 + ".pdf"; - FileUtil.writeString(htmlContent, templatePath, "UTF-8"); - - log.info("已生成HTML文件:" + templatePath); - //请求wkapp - JSONObject params = new JSONObject(); - params.put("input_html_path", "file://" + templatePath2); - params.put("output_pdf_path", pdfPath2); - log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf"); - String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params, 5 * 60 * 1000); - log.info("请求wkapp接口返回结果:" + result); - //WKHtmlToPdfUtil.convert(templatePath, pdfPath); - File file = FileUtil.file(pdfPath); - files.add(file); - delFiles.add(pdfPath); - delFiles.add(templatePath); + log.info("已生成HTML文件:" + templatePath); + //请求wkapp + JSONObject params = new JSONObject(); + params.put("input_html_path", "file://" + templatePath2); + params.put("output_pdf_path", pdfPath2); + log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf"); + String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params, 5 * 60 * 1000); + log.info("请求wkapp接口返回结果:" + result); + //WKHtmlToPdfUtil.convert(templatePath, pdfPath); + File file = FileUtil.file(pdfPath); + files.add(file); + delFiles.add(pdfPath); + delFiles.add(templatePath); + i++; + } } String pathUrl = System.getProperty("user.dir") + "/pdffile"; String zipFileName = StrUtil.format(pathUrl + "/DeliveryOrder_{}", new Date().getTime()); diff --git a/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/saleorder/SaleOrderServiceImpl.java b/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/saleorder/SaleOrderServiceImpl.java index f27def6..24ab1a6 100644 --- a/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/saleorder/SaleOrderServiceImpl.java +++ b/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/saleorder/SaleOrderServiceImpl.java @@ -476,29 +476,50 @@ public class SaleOrderServiceImpl implements SaleOrderService { //saleOrder.setSaleContractCode(saleContractVO.getBillno()); saleOrderMapper.updateById(saleOrder); - String htmlContent = generateHtmlContent(saleContractId); + List delFiles = new ArrayList<>(); + List files = new ArrayList<>(); + + SaleContractDO saleContract = saleContractService.getSaleContract(saleContractId); + List saleContractEntrys = saleContractService.getSaleContractEntryListByParentId(saleContractId); + List> split = ListUtil.split(saleContractEntrys, 6); + int i = 1; + for (List saleContractEntryDOS : split) { + String htmlContent = generateHtmlContent(saleContract, saleContractEntryDOS); + + //docker生成路径 + String pathUrl = System.getProperty("user.dir") + "/pdffile"; + String fileName = StrUtil.format(pathUrl + "/SaleContract_{}0", saleOrder.getBillno()+"_"+i); + //主宿机生成路径 + String fileName2 = StrUtil.format(pdfPath + "/SaleContract_{}0", saleOrder.getBillno()+"_"+i); + + String templatePath = fileName + ".html"; + String pdfPath = fileName + ".pdf"; + String templatePath2 = fileName2 + ".html"; + String pdfPath2 = fileName2 + ".pdf"; + + FileUtil.writeString(htmlContent, templatePath, "UTF-8"); + + log.info("已生成HTML文件:" + templatePath); + //请求wkapp + JSONObject params2 = new JSONObject(); + params2.put("input_html_path", "file://" + templatePath2); + params2.put("output_pdf_path", pdfPath2); + log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf"); + String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params2, 5 * 60 * 1000); + log.info("请求wkapp接口返回结果:" + result); + File file = FileUtil.file(pdfPath); + files.add(file); + delFiles.add(pdfPath); + delFiles.add(templatePath); + i++; + } - //docker生成路径 String pathUrl = System.getProperty("user.dir") + "/pdffile"; - String fileName = StrUtil.format(pathUrl + "/SaleContract_{}", saleOrder.getBillno()); - //主宿机生成路径 - String fileName2 = StrUtil.format(pdfPath + "/SaleContract_{}", saleOrder.getBillno()); + String zipFileName = StrUtil.format(pathUrl + "/SaleContract_{}0", new Date().getTime()); - String templatePath = fileName + ".html"; - String pdfPath = fileName + ".pdf"; - String templatePath2 = fileName2 + ".html"; - String pdfPath2 = fileName2 + ".pdf"; - - FileUtil.writeString(htmlContent, templatePath, "UTF-8"); - - log.info("已生成HTML文件:" + templatePath); - //请求wkapp - JSONObject params2 = new JSONObject(); - params2.put("input_html_path", "file://" + templatePath2); - params2.put("output_pdf_path", pdfPath2); - log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf"); - String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params2, 5 * 60 * 1000); - log.info("请求wkapp接口返回结果:" + result); + // 压缩到的位置 + File zipFile = new File(zipFileName + ".zip"); + ZipUtil.zip(zipFile, false, files.toArray(new File[files.size()])); //发送消息 @@ -524,9 +545,15 @@ public class SaleOrderServiceImpl implements SaleOrderService { message.setMail(email); message.setTitle("OMS订单系统"); message.setContent("您好,订单:" + saleOrder.getBillno() + ",已审核通过!"); - mailSendService.doSendMail(message, new File(pdfPath)); + mailSendService.doSendMail(message, zipFile); } } + + // 导出完删除 + delFiles.add(zipFileName); + for (String delFile : delFiles) { + FileUtil.del(delFile); + } } } break; @@ -631,13 +658,6 @@ public class SaleOrderServiceImpl implements SaleOrderService { } } - private String generateHtmlContent(Long saleContractId) { - SaleContractDO saleContract = saleContractService.getSaleContract(saleContractId); - List saleContractEntrys = saleContractService.getSaleContractEntryListByParentId(saleContractId); - Context context = generateHtmlContents(saleContract, saleContractEntrys); - return templateEngine.process("pdf_template", context); - } - private String generateHtmlContent(SaleContractDO saleContract, List saleContractEntrys) { Context context = generateHtmlContents(saleContract, saleContractEntrys); return templateEngine.process("pdf_template", context);