diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/visitor/controller/VisCarryStuffController.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/visitor/controller/VisCarryStuffController.java index 98798fc..8077265 100644 --- a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/visitor/controller/VisCarryStuffController.java +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/visitor/controller/VisCarryStuffController.java @@ -567,10 +567,6 @@ public class VisCarryStuffController extends BaseController { }); } - //查询申请二维码 - CheckCodeVo checkCodeVo = visCarryStuffService.selectStuffCheckCode(id); - String code = checkCodeVo.getCode(); - // 创建PDF文档 Document document = new Document(new RectangleReadOnly(842F, 595F)); document.setMargins(60, 60, 72, 72); @@ -623,14 +619,17 @@ public class VisCarryStuffController extends BaseController { rightColumn.setWidthPercentage(100); // 生成二维码图片 - BarcodeQRCode qrCode = new BarcodeQRCode(code, 100, 100, null); - Image qrCodeImage = qrCode.getImage(); - qrCodeImage.scaleAbsolute(100, 100); - qrCodeImage.setAlignment(Element.ALIGN_CENTER); - - // 添加二维码到右边列 - rightColumn.addCell(createCell(qrCodeImage, Element.ALIGN_CENTER)); - rightColumn.addCell(createCell(new Paragraph("出门证二维码", contentFont), Element.ALIGN_CENTER)); + CheckCodeVo checkCodeVo = visCarryStuffService.selectStuffCheckCode(id); + if (ObjectUtil.isNotNull(checkCodeVo) && StrUtil.isNotBlank(checkCodeVo.getCode())) { + BarcodeQRCode qrCode = new BarcodeQRCode(checkCodeVo.getCode(), 100, 100, null); + Image qrCodeImage = qrCode.getImage(); + qrCodeImage.scaleAbsolute(100, 100); + qrCodeImage.setAlignment(Element.ALIGN_CENTER); + + // 添加二维码到右边列 + rightColumn.addCell(createCell(qrCodeImage, Element.ALIGN_CENTER)); + rightColumn.addCell(createCell(new Paragraph("出门证二维码", contentFont), Element.ALIGN_CENTER)); + } // 将左右列添加到主表格 mainTable.addCell(createCell(leftColumn, Element.ALIGN_LEFT));