From c643d266320f0f3936948a6ce4d4428f6c12f50c Mon Sep 17 00:00:00 2001 From: funny <834502597@qq.com> Date: Tue, 14 Apr 2026 16:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E4=BF=AE=E6=94=B9=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MaterialCodeController.java | 124 ++++++------------ .../controller/PackagingCodeController.java | 11 +- .../template/label/material-pdf.html | 112 ++++++++-------- .../template/label/packaging-pdf.html | 70 ++++++---- 4 files changed, 144 insertions(+), 173 deletions(-) diff --git a/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/MaterialCodeController.java b/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/MaterialCodeController.java index deefd3ca..1b27d02e 100644 --- a/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/MaterialCodeController.java +++ b/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/MaterialCodeController.java @@ -831,38 +831,36 @@ public class MaterialCodeController extends BaseController { */ @PostMapping("exportToPdf") public void exportToPdf(HttpServletResponse response, @RequestBody @NotEmpty List ids) throws Exception { - // 根据物料主数据ID查询物料编号 - List materials = materialService.listByIds(ids); - VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(materials)).throwMessage("物料数据不存在"); + // 根据清单ID查询二维码数据 + List datas = materialCodeItemQrService.getListVOByCodeIds(ids); + VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(datas)).throwMessage("物料数据不存在"); - Set materialNos = materials.stream() - .map(WmsShipmentMaterial::getNo) - .collect(Collectors.toSet()); + // 取第一条数据 + ShipmentMaterialCodeQRVO data = datas.get(0); // 根据物料编号查询物料图片 - Map images = materials.stream() + Map images = materialService.lambdaQuery() + .select(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage) + .in(WmsShipmentMaterial::getNo, datas.stream().map(ShipmentMaterialCodeQRVO::getMaterialNo).collect(Collectors.toSet())) + .list() + .stream() .collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)); - // 根据物料编号查询清单明细二维码数据 - List datas = materialCodeItemQrService.getListVOByMaterialNos(materialNos); - VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(datas)).throwMessage("没有需要导出的数据"); - // 构建打印数据 Map variables = new HashMap<>(); - variables.put("list", datas.stream() - .map(data -> new MaterialCodePrintDTO() - .setNo(data.getNo()) - .setQrCode(QRCodeUtil.generateQRCodeBase64(data.getNo(), 200, 200)) - .setMaterialNo(data.getMaterialNo()) - .setMaterialDescribe(data.getMaterialDescribe()) - .setNum(data.getNum()) - .setNumText(data.getNumText()) - .setUnit(data.getUnit()) - .setDeviceNo(data.getDeviceNo()) - .setCustomerName(data.getCustomerName()) - .setLst(images.get(data.getMaterialNo())) - ).toList() - ); + + Map info = new HashMap<>(); + info.put("no", data.getNo()); + info.put("materialNo", data.getMaterialNo()); + info.put("numText", data.getNumText()); + info.put("customerName", data.getCustomerName()); + + Map ext = new HashMap<>(); + ext.put("qrCode", QRCodeUtil.generateQRCodeBase64(data.getNo(), 200, 200)); + ext.put("lst", images.get(data.getMaterialNo())); + + variables.put("info", info); + variables.put("ext", ext); String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables); URL baseUrl = new ClassPathResource("template/label/").getURL(); @@ -878,79 +876,35 @@ public class MaterialCodeController extends BaseController { @PostMapping("exportItemToPdf") public void exportItemToPdf(HttpServletResponse response, @RequestBody @NotEmpty List ids) throws Exception { // 根据明细ID查询数据 - List datas = materialCodeItemService.getListByItemIds(ids); + List datas = materialCodeItemQrService.getListVOByItemIds(ids); VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(datas)).throwMessage("没有需要导出的数据"); - // 获取物料图片 + // 取第一条数据 + ShipmentMaterialCodeQRVO data = datas.get(0); + + // 根据物料编号查询物料图片 Map images = materialService.lambdaQuery() .select(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage) - .in(WmsShipmentMaterial::getNo, datas.stream().map(MaterialItemPrintVO::getMaterialNo).collect(Collectors.toSet())) + .in(WmsShipmentMaterial::getNo, datas.stream().map(ShipmentMaterialCodeQRVO::getMaterialNo).collect(Collectors.toSet())) .list() .stream() .collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)); // 构建打印数据 Map variables = new HashMap<>(); - variables.put("list", datas.stream() - .map(data -> new MaterialCodePrintDTO() - .setNo(data.getMaterialNo() + "-" + data.getId()) - .setQrCode(QRCodeUtil.generateQRCodeBase64(data.getMaterialNo() + "-" + data.getId(), 200, 200)) - .setMaterialNo(data.getMaterialNo()) - .setMaterialDescribe(data.getMaterialDescribe()) - .setNum(data.getNum()) - .setNumText(data.getNumText()) - .setUnit(data.getUnit()) - .setDeviceNo(data.getDeviceNo()) - .setCustomerName(data.getCustomerName()) - .setLst(images.get(data.getMaterialNo())) - ).toList() - ); - String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables); - URL baseUrl = new ClassPathResource("template/label/").getURL(); - PdfGeneratorUtil.generatePdf("物料明细标签", html, baseUrl.toString(), response); - } - - /** - * 根据物料主数据ID导出物料明细PDF(打印预览) - * - * @param response HTTP响应 - * @param ids 物料主数据id列表(wms_shipment_material.id) - */ - @PostMapping("exportMaterialItemToPdf") - public void exportMaterialItemToPdf(HttpServletResponse response, @RequestBody @NotEmpty List ids) throws Exception { - // 根据物料主数据ID查询物料编号 - List materials = materialService.listByIds(ids); - VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(materials)).throwMessage("物料数据不存在"); + Map info = new HashMap<>(); + info.put("no", data.getNo()); + info.put("materialNo", data.getMaterialNo()); + info.put("numText", data.getNumText()); + info.put("customerName", data.getCustomerName()); - Set materialNos = materials.stream() - .map(WmsShipmentMaterial::getNo) - .collect(Collectors.toSet()); + Map ext = new HashMap<>(); + ext.put("qrCode", QRCodeUtil.generateQRCodeBase64(data.getNo(), 200, 200)); + ext.put("lst", images.get(data.getMaterialNo())); - // 根据物料编号查询物料图片 - Map images = materials.stream() - .collect(Collectors.toMap(WmsShipmentMaterial::getNo, WmsShipmentMaterial::getImage)); - - // 根据物料编号查询明细数据 - List datas = materialCodeItemService.getListByMaterialNos(materialNos); - VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(datas)).throwMessage("没有需要导出的数据"); - - // 构建打印数据 - Map variables = new HashMap<>(); - variables.put("list", datas.stream() - .map(data -> new MaterialCodePrintDTO() - .setNo(data.getMaterialNo() + "-" + data.getId()) - .setQrCode(QRCodeUtil.generateQRCodeBase64(data.getMaterialNo() + "-" + data.getId(), 200, 200)) - .setMaterialNo(data.getMaterialNo()) - .setMaterialDescribe(data.getMaterialDescribe()) - .setNum(data.getNum()) - .setNumText(data.getNumText()) - .setUnit(data.getUnit()) - .setDeviceNo(data.getDeviceNo()) - .setCustomerName(data.getCustomerName()) - .setLst(images.get(data.getMaterialNo())) - ).toList() - ); + variables.put("info", info); + variables.put("ext", ext); String html = ThymeleafUtil.generator("/template/label/", "material-pdf", ".html", variables); URL baseUrl = new ClassPathResource("template/label/").getURL(); diff --git a/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/PackagingCodeController.java b/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/PackagingCodeController.java index a7c1c572..3b367d6b 100644 --- a/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/PackagingCodeController.java +++ b/nflg-wms-shipment/src/main/java/com/nflg/wms/shipment/controller/PackagingCodeController.java @@ -421,15 +421,14 @@ public class PackagingCodeController extends BaseController { Map variables = new HashMap<>(); variables.put("list", list.stream() .map(data -> { - String typeName = types.stream() - .filter(type -> type.getId().equals(data.getType())) - .map(DictionaryItem::getName) - .findFirst() - .orElse(""); ShipmentPackagingCodeVO vo = new ShipmentPackagingCodeVO(); vo.setNo(data.getNo()); vo.setName(data.getName()); - vo.setTypeName(typeName); + vo.setTypeName(types.stream() + .filter(type -> type.getId().equals(data.getType())) + .map(DictionaryItem::getName) + .findFirst() + .orElse("")); vo.setQrCode(QRCodeUtil.generateQRCodeBase64(data.getNo(), 100, 100)); return vo; }).toList() diff --git a/nflg-wms-shipment/src/main/resources/template/label/material-pdf.html b/nflg-wms-shipment/src/main/resources/template/label/material-pdf.html index 4f85a029..813de42f 100644 --- a/nflg-wms-shipment/src/main/resources/template/label/material-pdf.html +++ b/nflg-wms-shipment/src/main/resources/template/label/material-pdf.html @@ -2,26 +2,23 @@ - 物料码标签 + 包装码 -
- - - - - - - - - - - - - - - - - -
- -
0PC7B724KV6FM
-
- 机台编号 - - 26LBZ4000L001 - - 客户名称 - - 北京市京联鑫路用材料有限公司 -
- 物料编码 - - 3100006701 - - 数量 - - 10 -
- -
-
+ + + + + + + + + + + + + + + + + +
+ +
0PC7B724KV6FM
+
+ 机台编号 + + 26LBZ4000L001 + + 客户名称 + + 北京市京联鑫路用材料有限公司 +
+ 物料编码 + + 3100006701 + + 数量 + + 10 +
+ +
- + \ No newline at end of file diff --git a/nflg-wms-shipment/src/main/resources/template/label/packaging-pdf.html b/nflg-wms-shipment/src/main/resources/template/label/packaging-pdf.html index 434ca57f..2b9df155 100644 --- a/nflg-wms-shipment/src/main/resources/template/label/packaging-pdf.html +++ b/nflg-wms-shipment/src/main/resources/template/label/packaging-pdf.html @@ -2,37 +2,57 @@ - 包装码标签 + 包装码标签-A4打印版 -
- - - - - -
- -
NFLG-QZ-002
-
-
包装名称: NFLG-QZ-002 测试包装名称
-
包装类型: 托盘
-
+ +
+
+ + + + + +
+ +
NFLG-QZ-002
+
+
包装名称: NFLG-QZ-002 测试包装名称
+
包装类型: 托盘
+
+
+ - + \ No newline at end of file