【优化】物料码管理的打印和打印预览根据中码和小码采用对应的打印模版
This commit is contained in:
parent
f76e078237
commit
79bad56f77
|
|
@ -54,7 +54,6 @@ import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装箱管理
|
* 装箱管理
|
||||||
*
|
|
||||||
* @author: nflg
|
* @author: nflg
|
||||||
* @date: 2022/3/17
|
* @date: 2022/3/17
|
||||||
* @description:
|
* @description:
|
||||||
|
|
@ -86,7 +85,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取包装箱和箱内物料信息
|
* 获取包装箱和箱内物料信息
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -126,7 +124,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包装箱编码获取包装箱和箱内物料信息
|
* 包装箱编码获取包装箱和箱内物料信息
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -161,7 +158,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 箱码Validation
|
* 箱码Validation
|
||||||
*
|
|
||||||
* @param qrCodeMaster
|
* @param qrCodeMaster
|
||||||
* @param smallQrCodeMasters
|
* @param smallQrCodeMasters
|
||||||
*/
|
*/
|
||||||
|
|
@ -209,7 +205,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装箱绑码
|
* 装箱绑码
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -265,7 +260,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拆箱删除
|
* 拆箱删除
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -294,7 +288,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 换箱
|
* 换箱
|
||||||
* 针对库存地点内的物料箱合并,修改物料的箱属性和库存
|
* 针对库存地点内的物料箱合并,修改物料的箱属性和库存
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -402,7 +395,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料出入库统一扫码接口
|
* 物料出入库统一扫码接口
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
* @author
|
* @author
|
||||||
|
|
@ -437,7 +429,6 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 换箱扫码接口
|
* 换箱扫码接口
|
||||||
*
|
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
* @author
|
* @author
|
||||||
|
|
@ -469,11 +460,12 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出标签图片为ZIP
|
* 导出标签图片为ZIP
|
||||||
*
|
|
||||||
* @param datas 二维码列表
|
* @param datas 二维码列表
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "exportToZip", produces = "application/zip")
|
@PostMapping(value = "exportToZip", produces = "application/zip")
|
||||||
public ResponseEntity<byte[]> exportToZip(@Valid @RequestBody @NotEmpty List<QrCodeItemVO> datas) throws Exception {
|
public ResponseEntity<byte[]> exportToZip(@Valid @RequestBody @NotEmpty List<QrCodeItemVO> datas) throws Exception {
|
||||||
|
VUtil.trueThrowBusinessError(datas.stream().map(QrCodeItemVO::getPackagingType).collect(Collectors.toSet()).size() > 1)
|
||||||
|
.throwMessage("只能选择一种包装类型");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
|
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
|
||||||
for (QrCodeItemVO it : datas) {
|
for (QrCodeItemVO it : datas) {
|
||||||
|
|
@ -482,7 +474,8 @@ public class QrCodeMasterController extends BaseController {
|
||||||
dto.setQrCode(QRCodeUtil.generateQRCodeBase64(generateQRContent(dto), 100, 100));
|
dto.setQrCode(QRCodeUtil.generateQRCodeBase64(generateQRContent(dto), 100, 100));
|
||||||
Map<String, Object> variables = new HashMap<>();
|
Map<String, Object> variables = new HashMap<>();
|
||||||
variables.put("list", List.of(dto));
|
variables.put("list", List.of(dto));
|
||||||
String html = ThymeleafUtil.generator("/template/qrcode/", "dp-1-label", ".html", variables);
|
String html = ThymeleafUtil.generator("/template/qrcode/"
|
||||||
|
, datas.get(0).getPackagingType() == 0 ? "dp-1-label" : "medium-box-label", ".html", variables);
|
||||||
ZipEntry entry = new ZipEntry(it.getBarcodeCode() + ".png");
|
ZipEntry entry = new ZipEntry(it.getBarcodeCode() + ".png");
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
byte[] imageBytes = HtmlToImageUtil.convertToPng(html, 600);
|
byte[] imageBytes = HtmlToImageUtil.convertToPng(html, 600);
|
||||||
|
|
@ -499,11 +492,12 @@ public class QrCodeMasterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出标签图片为PDF
|
* 导出标签图片为PDF
|
||||||
*
|
|
||||||
* @param datas 二维码列表
|
* @param datas 二维码列表
|
||||||
*/
|
*/
|
||||||
@PostMapping("exportToPdf")
|
@PostMapping("exportToPdf")
|
||||||
public void exportToPdf(HttpServletResponse response, @RequestBody @NotEmpty List<QrCodeItemVO> datas) throws Exception {
|
public void exportToPdf(HttpServletResponse response, @RequestBody @NotEmpty List<QrCodeItemVO> datas) throws Exception {
|
||||||
|
VUtil.trueThrowBusinessError(datas.stream().map(QrCodeItemVO::getPackagingType).collect(Collectors.toSet()).size() > 1)
|
||||||
|
.throwMessage("只能选择一种包装类型");
|
||||||
Map<String, Object> variables = new HashMap<>();
|
Map<String, Object> variables = new HashMap<>();
|
||||||
variables.put("list", datas.stream().map(data ->
|
variables.put("list", datas.stream().map(data ->
|
||||||
{
|
{
|
||||||
|
|
@ -512,7 +506,8 @@ public class QrCodeMasterController extends BaseController {
|
||||||
dto.setQrCode(QRCodeUtil.generateQRCodeBase64(generateQRContent(dto), 100, 100));
|
dto.setQrCode(QRCodeUtil.generateQRCodeBase64(generateQRContent(dto), 100, 100));
|
||||||
return dto;
|
return dto;
|
||||||
}).toList());
|
}).toList());
|
||||||
String html = ThymeleafUtil.generator("/template/qrcode/", "dp-1", ".html", variables);
|
String html = ThymeleafUtil.generator("/template/qrcode/"
|
||||||
|
, datas.get(0).getPackagingType() == 0 ? "dp-1" : "medium-box", ".html", variables);
|
||||||
URL baseUrl = new ClassPathResource("template/qrcode/").getURL();
|
URL baseUrl = new ClassPathResource("template/qrcode/").getURL();
|
||||||
PdfGeneratorUtil.generatePdf("箱码标签图片", html, baseUrl.toString(), response);
|
PdfGeneratorUtil.generatePdf("箱码标签图片", html, baseUrl.toString(), response);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue