1463 WMS系统钢构包采购业务功能优化
This commit is contained in:
parent
03cda3e193
commit
2d44bae3f7
|
|
@ -559,7 +559,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|||
.setNo(trayVO.getPackageNo())
|
||||
.setExternalOrderNo(trayVO.getExternalOrderNo())
|
||||
.setRowNo(trayVO.getRowNo())
|
||||
.setTrayNo(trayVO.getTrayNo())
|
||||
.setSupplierName(trayVO.getSupplierName())
|
||||
.setModelNos(trayVO.getModelNo())
|
||||
.setVersion(trayVO.getPackageVersion())
|
||||
|
|
@ -589,7 +588,7 @@ public class StructuralPackageOrderController extends BaseController {
|
|||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
PdfGeneratorUtil.generatePdf(vo.getExternalOrderNo() + "-" + vo.getWorkbenchCode() + "老鼠图", html, outputStream);
|
||||
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
return ApiResult.success(fileUploadService.upload("tmp/sp/" + RandomUtil.randomString(10) + "/" + vo.getTrayNo() + "老鼠图.pdf", inputStream, MediaType.APPLICATION_PDF_VALUE));
|
||||
return ApiResult.success(fileUploadService.upload("tmp/sp/" + RandomUtil.randomString(10) + "/" + "老鼠图.pdf", inputStream, MediaType.APPLICATION_PDF_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -724,19 +723,40 @@ public class StructuralPackageOrderController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 导出托盘标签图片
|
||||
* 导出托盘标签图片(多个托盘合并为一张长图)
|
||||
*
|
||||
* @param id 托盘id
|
||||
* @param id 订单id
|
||||
*/
|
||||
@GetMapping(value = "exportTrayImage", produces = MediaType.IMAGE_PNG_VALUE)
|
||||
public ResponseEntity<byte[]> exportTrayImage(@Valid @RequestParam @NotNull Long id) throws Exception {
|
||||
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(id);
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(trayVO)).throwMessage("数据不存在");
|
||||
trayVO.setQrCode(QRCodeUtil.generateQRCodeBase64(trayVO.getTrayNo(), 200, 200));
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
variables.put("info", trayVO);
|
||||
String html = ThymeleafUtil.generator("/template/qrcode/", "tray-label", ".html", variables);
|
||||
byte[] imageBytes = HtmlToImageUtil.convertToPng(html, 600);
|
||||
// 根据订单ID获取所有托盘
|
||||
List<WmsStructuralPackageOrderTray> trays = structuralPackageOrderTrayService.getList(id);
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(trays)).throwMessage("数据不存在");
|
||||
|
||||
// 为每个托盘生成HTML内容,并拼接成一个完整的HTML
|
||||
StringBuilder mergedHtml = new StringBuilder();
|
||||
mergedHtml.append("<!DOCTYPE html><html><head><meta charset='UTF-8'/></head><body style='margin:0;padding:0;'>");
|
||||
|
||||
for (WmsStructuralPackageOrderTray tray : trays) {
|
||||
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(tray.getId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(trayVO)).throwMessage("数据不存在");
|
||||
trayVO.setQrCode(QRCodeUtil.generateQRCodeBase64(trayVO.getTrayNo(), 200, 200));
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
variables.put("info", trayVO);
|
||||
String html = ThymeleafUtil.generator("/template/qrcode/", "tray-label", ".html", variables);
|
||||
// 提取body内容并追加
|
||||
int bodyStart = html.indexOf("<body");
|
||||
int bodyEndStart = html.indexOf(">", bodyStart) + 1;
|
||||
int bodyEnd = html.lastIndexOf("</body>");
|
||||
if (bodyStart != -1 && bodyEnd != -1) {
|
||||
mergedHtml.append(html.substring(bodyEndStart, bodyEnd));
|
||||
}
|
||||
}
|
||||
|
||||
mergedHtml.append("</body></html>");
|
||||
|
||||
// 将合并后的HTML转换为图片
|
||||
byte[] imageBytes = HtmlToImageUtil.convertToPng(mergedHtml.toString(), 600);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.IMAGE_PNG);
|
||||
headers.setContentLength(imageBytes.length);
|
||||
|
|
@ -777,14 +797,26 @@ public class StructuralPackageOrderController extends BaseController {
|
|||
/**
|
||||
* 导出齐套标签图片
|
||||
*
|
||||
* @param id 托盘id
|
||||
* @param id 订单id
|
||||
*/
|
||||
@GetMapping(value = "exportQiTaoImage", produces = MediaType.IMAGE_PNG_VALUE)
|
||||
public ResponseEntity<byte[]> exportQiTaoImage(@Valid @RequestParam @NotNull Long id) throws Exception {
|
||||
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(id);
|
||||
// 根据订单ID获取所有托盘
|
||||
List<WmsStructuralPackageOrderTray> trays = structuralPackageOrderTrayService.getList(id);
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(trays)).throwMessage("数据不存在");
|
||||
|
||||
// 获取订单信息用于生成二维码
|
||||
WmsStructuralPackageOrder order = structuralPackageOrderService.getById(id);
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
|
||||
|
||||
List<WmsQrCodeMaster> codes = qrCodeMasterService.getByExtendId(id);
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(codes)).throwMessage("未找到二维码信息");
|
||||
|
||||
// 注意:齐套标签内容基于订单信息(外部订单号、行号、包号),同一订单下所有托盘的标签内容相同
|
||||
// 因此只需取第一个托盘生成一个标签即可
|
||||
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(trays.get(0).getId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(trayVO)).throwMessage("数据不存在");
|
||||
String temp = trayVO.getExternalOrderNo() + "$" + trayVO.getRowNo() + "$" + trayVO.getPackageNo();
|
||||
List<WmsQrCodeMaster> codes = qrCodeMasterService.getByExtendId(trayVO.getOrderId());
|
||||
trayVO.setQrCode(QRCodeUtil.generateQRCodeBase64(codes.get(0).getBarcodeCode() + "$" + temp, 100, 100));
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
variables.put("info", trayVO);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@
|
|||
<tr>
|
||||
<td>订单号:<span th:text="${info.externalOrderNo}">12255665451615</span></td>
|
||||
<td>行号:<span th:text="${info.rowNo}">1111</span></td>
|
||||
<td>托盘号:<span th:text="${info.trayNo}">1111</span></td>
|
||||
<!-- 托盘号已移除,保留空单元格 -->
|
||||
<td></td>
|
||||
<td colspan="2">供应商:<span th:text="${info.supplierName}">1111</span></td>
|
||||
<td rowspan="3" class="cell-img" style="width: 130px;">
|
||||
<img alt="" style="width: 100px;" th:src="${info.qrCode}" src="../img/logo1.png"/>
|
||||
|
|
@ -149,4 +150,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue