feat(normal-order): 添加箱码标签图片导出PDF功能

This commit is contained in:
曹鹏飞 2026-03-17 10:51:07 +08:00
parent 2e4119cb4f
commit f1eb8682fe
1 changed files with 30 additions and 0 deletions

View File

@ -478,4 +478,34 @@ public class NormalOrderController extends BaseController {
headers.setContentLength(zipBytes.length);
return new ResponseEntity<>(zipBytes, headers, HttpStatus.OK);
}
/**
* 导出箱码标签图片为PDF
* @param materials 物料列表
*/
@PostMapping("exportBoxPdf")
public void exportBoxPdf(HttpServletResponse response, @RequestBody @NotEmpty List<MaterialMinQO> materials) throws Exception {
List<WmsQrCodeMaster> qrCodeMasters = materials.stream()
.map(it -> new WmsQrCodeMaster()
.setBarcodeCode(KeyUtil.next())
.setProcessStage(BarCodeProcessStage.Unpackaged.getState())
.setBarcodeType(BarCodeType.Purchase.getState())
.setMaterialCode(it.getMaterialNo())
.setMaterialDescription(it.getMaterialDes())
.setPackagingType((short) 1)
.setCreateUserId(UserUtil.getUserId())
.setUnit("")
.setQuantity(BigDecimal.valueOf(1.0))
.setSupplierCode(it.getSupplierCode())
.setSupplierId(it.getSupplierId())
.setCreateUserName(UserUtil.getUserName())
.setCreateTime(LocalDateTime.now()))
.toList();
qrCodeMasterService.saveBatch(qrCodeMasters);
Map<String, Object> variables = new HashMap<>();
variables.put("list", convertToPrintDTO(qrCodeMasters));
String html = ThymeleafUtil.generator("/template/qrcode/", "dp-2", ".html", variables);
URL baseUrl = new ClassPathResource("template/qrcode/").getURL();
PdfGeneratorUtil.generatePdf("箱码标签图片", html, baseUrl.toString(), response);
}
}