From a1808ba0ff1ccc2efacb69c1033054dbaab8687f Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期四, 10 七月 2025 17:57:16 +0800 Subject: [PATCH] 2025-07-10 --- ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java | 401 ++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 268 insertions(+), 133 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java index 4338132..5bc1fde 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisPDFUtil.java @@ -1003,6 +1003,37 @@ List<TjOrderDetail> orderDetails = tjOrderDetailMapper.getzongjianyishengchakanyichangxiangmu4(tjOrder.getTjNumber()); // List<Map<String, Object>> jiancha = new ArrayList<>(); + Font zongJianFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); + Font zongJianTitleFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); + zongJianTitleFont.setStyle(Font.BOLD); + PdfPCell cell; + + + String zjjyandqmgzIstop = sysConfigService.selectConfigByKey("pdf_zjjyandqmgz_istop"); + boolean zjjyandqmgzIstopFlag = false; + if (StrUtil.isNotBlank(zjjyandqmgzIstop) && zjjyandqmgzIstop.equalsIgnoreCase("y")){ + zjjyandqmgzIstopFlag = true; + paragraph = PdfUtils.setParagraph(defaultTitleFont, "鎬绘鍖荤敓寤鸿锛�"); + document2.add(paragraph); + if (tjOrder.getCheckAdvice() == null) { + paragraph = PdfUtils.setParagraph(defaultFont, "鏃�"); + document2.add(paragraph); + } else { + Paragraph paragraphs = new Paragraph(tjOrder.getCheckAdvice(), defaultFont); + //璁剧疆鏂囧瓧灞呬腑 + paragraphs.setAlignment(Element.ALIGN_LEFT); + //琛岄棿璺� +// paragraphs.setLeading(5f); + //璁剧疆娈佃惤涓婄┖鐧� + paragraphs.setSpacingBefore(10f); + //璁剧疆娈佃惤涓嬬┖鐧� + paragraphs.setSpacingAfter(10f); +// paragraph = PdfUtils.setParagraph(defaultFont, tjOrder.getCheckAdvice()); + document2.add(paragraphs); + } + makeZjjyAndQmgzTab(tjOrder, zongJianYiShiQianMing, zongJianFont, zongJianTitleFont, value, document2, defaultFont); + } + int xmXh = 1; @@ -1135,10 +1166,15 @@ List<Map<String, Object>> collect1 = maps.stream().distinct().collect(Collectors.toList()); for (Map<String, Object> objectMap : collect1) { String content = str + objectMap.get("bt").toString() + objectMap.get("nr").toString(); - if (StrUtil.isBlank(content)) content = " "; - paragraph = new Paragraph(content, defaultFont); - paragraph.setAlignment(Element.ALIGN_LEFT); - document2.add(paragraph); +// if (StrUtil.isBlank(content)) content = " "; +// paragraph = new Paragraph(content, defaultFont); +// paragraph.setAlignment(Element.ALIGN_LEFT); +// document2.add(paragraph); + if (StrUtil.isNotBlank(content) && StrUtil.isNotBlank(content.trim())){ + paragraph = new Paragraph(content, defaultFont); + paragraph.setAlignment(Element.ALIGN_LEFT); + document2.add(paragraph); + } } index++; paragraph = PdfUtils.setParagraph(defaultFont, ""); @@ -1157,24 +1193,27 @@ paragraph = PdfUtils.setParagraph(defaultFont, ""); document2.add(paragraph); } - paragraph = PdfUtils.setParagraph(defaultTitleFont, "鎬绘鍖荤敓寤鸿锛�"); - document2.add(paragraph); - if (tjOrder.getCheckAdvice() == null) { - paragraph = PdfUtils.setParagraph(defaultFont, "鏃�"); + if (!zjjyandqmgzIstopFlag){ + paragraph = PdfUtils.setParagraph(defaultTitleFont, "鎬绘鍖荤敓寤鸿锛�"); document2.add(paragraph); - } else { - Paragraph paragraphs = new Paragraph(tjOrder.getCheckAdvice(), defaultFont); - //璁剧疆鏂囧瓧灞呬腑 - paragraphs.setAlignment(Element.ALIGN_LEFT); - //琛岄棿璺� + if (tjOrder.getCheckAdvice() == null) { + paragraph = PdfUtils.setParagraph(defaultFont, "鏃�"); + document2.add(paragraph); + } else { + Paragraph paragraphs = new Paragraph(tjOrder.getCheckAdvice(), defaultFont); + //璁剧疆鏂囧瓧灞呬腑 + paragraphs.setAlignment(Element.ALIGN_LEFT); + //琛岄棿璺� // paragraphs.setLeading(5f); - //璁剧疆娈佃惤涓婄┖鐧� - paragraphs.setSpacingBefore(10f); - //璁剧疆娈佃惤涓嬬┖鐧� - paragraphs.setSpacingAfter(10f); + //璁剧疆娈佃惤涓婄┖鐧� + paragraphs.setSpacingBefore(10f); + //璁剧疆娈佃惤涓嬬┖鐧� + paragraphs.setSpacingAfter(10f); // paragraph = PdfUtils.setParagraph(defaultFont, tjOrder.getCheckAdvice()); - document2.add(paragraphs); + document2.add(paragraphs); + } } + Paragraph paragraphNone = new Paragraph("", defaultFont); @@ -1193,124 +1232,16 @@ document2.add(paragraphNone); - PdfPTable tableQz = new PdfPTable(new float[]{100f, 100f, 50f}); - tableQz.setTotalWidth(PageSize.A4.getWidth() - 100); - tableQz.setLockedWidth(true); - tableQz.setHorizontalAlignment(Element.ALIGN_LEFT); - tableQz.getDefaultCell().setBorder(0); - tableQz.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); - Font zongJianFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); - Font zongJianTitleFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); - zongJianTitleFont.setStyle(Font.BOLD); - - for (int i = 0; i < 3; i++) { - PdfPCell cell = new PdfPCell(); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - cell.setPhrase(new Phrase("", defaultFont)); - cell.setBorder(Rectangle.NO_BORDER); - tableQz.addCell(cell); + if (!zjjyandqmgzIstopFlag){ + makeZjjyAndQmgzTab(tjOrder, zongJianYiShiQianMing, zongJianFont, zongJianTitleFont, value, document2, defaultFont); } - - - PdfPCell cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - cell.setPhrase(new Phrase("", defaultFont)); - cell.setRowspan(3); - tableQz.addCell(cell); - - cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - cell.setPaddingTop(10); - cell.setPaddingBottom(10); - cell.setPaddingRight(4); - cell.setPhrase(new Phrase("浣撴鍗曚綅鐩栫珷:", zongJianTitleFont)); - - tableQz.addCell(cell); - - File file = new File(value + File.separator + "yinzhang.png"); - cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - cell.setPaddingTop(10); - cell.setPaddingBottom(10); - cell.setPaddingRight(4); - if (!file.exists()) { - cell.setPhrase(new Phrase("", zongJianFont)); - }else { - FileInputStream fileInputStream = new FileInputStream(file); - byte[] fileBytes = new byte[(int) file.length()]; - fileInputStream.read(fileBytes); - fileInputStream.close(); - Image image = Image.getInstance(Base64.getDecoder().decode(Base64.getEncoder().encodeToString(fileBytes))); - image.scaleToFit(90, 90); - cell.addElement(image); - } - tableQz.addCell(cell); - - cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - cell.setPaddingTop(10); - cell.setPaddingBottom(10); - cell.setPaddingRight(4); - cell.setPhrase(new Phrase("鎬绘鍖诲笀:", zongJianTitleFont)); - tableQz.addCell(cell); - - - cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setPaddingTop(10); - cell.setPaddingBottom(10); - cell.setPaddingRight(4); - String zongjianysname = sysConfigService.selectConfigByKey("pdf_report_zongjianysname"); - if (zongJianYiShiQianMing == null && StrUtil.isNotBlank(zongjianysname) && !zongjianysname.equals("鏃�")) { - cell.setPhrase(new Phrase(zongjianysname, zongJianFont)); - tableQz.addCell(cell); - } else if (zongJianYiShiQianMing == null && zongjianysname.equals("鏃�")) { - String nickName = SecurityUtils.getLoginUser().getUser().getNickName(); - cell.setPhrase(new Phrase(nickName, zongJianFont)); - tableQz.addCell(cell); - } else { - byte[] bytes = Base64.getDecoder().decode(zongJianYiShiQianMing.getTemplate()); - Image image = Image.getInstance(bytes); - image.scaleToFit(100, 100); - cell.addElement(image); - tableQz.addCell(cell); - } - - cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_RIGHT); - cell.setPaddingTop(10); - cell.setPaddingBottom(10); - cell.setPaddingRight(4); - cell.setPhrase(new Phrase("鎬绘鏃ユ湡:", zongJianTitleFont)); - tableQz.addCell(cell); - - cell = new PdfPCell(); - cell.setBorder(Rectangle.NO_BORDER); - cell.setVerticalAlignment(Element.ALIGN_MIDDLE); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setPaddingTop(10); - cell.setPaddingBottom(10); - cell.setPaddingRight(4); - cell.setPhrase(new Phrase(new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCheckTime()), zongJianFont)); - tableQz.addCell(cell); - - document2.add(tableQz); - document2.close(); + + + zongJianFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); + zongJianTitleFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE); + zongJianTitleFont.setStyle(Font.BOLD); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); @@ -1511,6 +1442,210 @@ } } + private void makeZjjyAndQmgzTab(TjOrder tjOrder, TjReportTemplate zongJianYiShiQianMing, Font zongJianFont, Font zongJianTitleFont, String value, Document document2, Font defaultFont) throws IOException, DocumentException { + PdfPCell cell; + String pdfQzgzpailie = sysConfigService.selectConfigByKey("pdf_qzgzpailie"); + if (StrUtil.isNotBlank(pdfQzgzpailie) && pdfQzgzpailie.equalsIgnoreCase("h")){ + zongJianFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE - 2); + zongJianTitleFont = PdfUtils.setFont(DEFAULT_ZONGJIAN_FONT_SIZE - 2); + zongJianTitleFont.setStyle(Font.BOLD); + PdfPTable tableQz = new PdfPTable(new float[]{90f, 90f, 60f, 60f, 60f, 60f}); + tableQz.setTotalWidth(PageSize.A4.getWidth() - 100); + tableQz.setLockedWidth(true); + tableQz.setHorizontalAlignment(Element.ALIGN_LEFT); + tableQz.getDefaultCell().setBorder(1); + tableQz.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); + + cell = new PdfPCell(new Phrase("浣撴鍗曚綅鐩栫珷:", zongJianTitleFont)); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPadding(10); + tableQz.addCell(cell); + + File file = new File(value + File.separator + "yinzhang.png"); + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setPadding(10); + if (!file.exists()) { + cell.setPhrase(new Phrase("", zongJianFont)); + } else { + FileInputStream fileInputStream = new FileInputStream(file); + byte[] fileBytes = new byte[(int) file.length()]; + fileInputStream.read(fileBytes); + fileInputStream.close(); + Image image = Image.getInstance(Base64.getDecoder().decode(Base64.getEncoder().encodeToString(fileBytes))); + image.scaleToFit(60, 60); + cell.addElement(image); + } + tableQz.addCell(cell); + + cell = new PdfPCell(new Phrase("鎬绘鍖诲笀:", zongJianTitleFont)); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPadding(10); + tableQz.addCell(cell); + + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setPadding(10); + + String zongjianysname = sysConfigService.selectConfigByKey("pdf_report_zongjianysname"); + if (zongJianYiShiQianMing == null && StrUtil.isNotBlank(zongjianysname) && !zongjianysname.equals("鏃�")) { + cell.setPhrase(new Phrase(zongjianysname, zongJianFont)); + } else if (zongJianYiShiQianMing == null && zongjianysname.equals("鏃�")) { + String nickName = SecurityUtils.getLoginUser().getUser().getNickName(); + cell.setPhrase(new Phrase(nickName, zongJianFont)); + } else { + byte[] bytes = Base64.getDecoder().decode(zongJianYiShiQianMing.getTemplate()); + Image image = Image.getInstance(bytes); + image.scaleToFit(60, 60); +// cell.addElement(image); + +// cell.setPaddingTop(5); +// cell.setPaddingBottom(15); + String pdfSfsgqz = sysConfigService.selectConfigByKey("pdf_sfsgqz"); + if (StrUtil.isNotBlank(pdfSfsgqz) && pdfSfsgqz.equalsIgnoreCase("Y")) { + cell.setVerticalAlignment(Element.ALIGN_TOP); + } + cell.setImage(image); + } + tableQz.addCell(cell); + + cell = new PdfPCell(new Phrase("鎬绘鏃ユ湡:", zongJianTitleFont)); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPadding(10); + tableQz.addCell(cell); + + cell = new PdfPCell(new Phrase(new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCheckTime()), zongJianFont)); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setPadding(10); + tableQz.addCell(cell); + document2.add(tableQz); + } else { + PdfPTable tableQz = new PdfPTable(new float[]{90f, 90f, 70f}); + tableQz.setTotalWidth(PageSize.A4.getWidth() - 100); + tableQz.setLockedWidth(true); + tableQz.setHorizontalAlignment(Element.ALIGN_LEFT); +// tableQz.getDefaultCell().setBorder(1); + tableQz.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); + + for (int i = 0; i < 3; i++) { + cell = new PdfPCell(); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPhrase(new Phrase("", defaultFont)); + cell.setBorder(Rectangle.NO_BORDER); + tableQz.addCell(cell); + } + + + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPhrase(new Phrase("", defaultFont)); + cell.setRowspan(3); + tableQz.addCell(cell); + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPaddingTop(10); + cell.setPaddingBottom(10); +// cell.setPaddingRight(50); + cell.setPhrase(new Phrase("浣撴鍗曚綅鐩栫珷:", zongJianTitleFont)); + + tableQz.addCell(cell); + + File file = new File(value + File.separator + "yinzhang.png"); + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); + cell.setPaddingTop(10); + cell.setPaddingBottom(10); +// cell.setPaddingRight(50); + if (!file.exists()) { + cell.setPhrase(new Phrase("", zongJianFont)); + }else { + FileInputStream fileInputStream = new FileInputStream(file); + byte[] fileBytes = new byte[(int) file.length()]; + fileInputStream.read(fileBytes); + fileInputStream.close(); + Image image = Image.getInstance(Base64.getDecoder().decode(Base64.getEncoder().encodeToString(fileBytes))); + image.scaleToFit(90, 90); + cell.addElement(image); + } + tableQz.addCell(cell); + + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPaddingTop(10); + cell.setPaddingBottom(10); +// cell.setPaddingRight(50); + cell.setPhrase(new Phrase("鎬绘鍖诲笀:", zongJianTitleFont)); + tableQz.addCell(cell); + + + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); + cell.setPaddingTop(10); + cell.setPaddingBottom(10); +// cell.setPaddingRight(50); + String zongjianysname = sysConfigService.selectConfigByKey("pdf_report_zongjianysname"); + if (zongJianYiShiQianMing == null && StrUtil.isNotBlank(zongjianysname) && !zongjianysname.equals("鏃�")) { + cell.setPhrase(new Phrase(zongjianysname, zongJianFont)); + tableQz.addCell(cell); + } else if (zongJianYiShiQianMing == null && zongjianysname.equals("鏃�")) { + String nickName = SecurityUtils.getLoginUser().getUser().getNickName(); + cell.setPhrase(new Phrase(nickName, zongJianFont)); + tableQz.addCell(cell); + } else { + byte[] bytes = Base64.getDecoder().decode(zongJianYiShiQianMing.getTemplate()); + Image image = Image.getInstance(bytes); + image.scaleToFit(100, 100); + cell.addElement(image); + tableQz.addCell(cell); + } + + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_RIGHT); + cell.setPaddingTop(10); + cell.setPaddingBottom(10); +// cell.setPaddingRight(50); + cell.setPhrase(new Phrase("鎬绘鏃ユ湡:", zongJianTitleFont)); + tableQz.addCell(cell); + + cell = new PdfPCell(); + cell.setBorder(Rectangle.NO_BORDER); + cell.setVerticalAlignment(Element.ALIGN_MIDDLE); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); + cell.setPaddingTop(10); + cell.setPaddingBottom(10); +// cell.setPaddingRight(50); + cell.setPhrase(new Phrase(new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCheckTime()), zongJianFont)); + tableQz.addCell(cell); + + document2.add(tableQz); + } + } + /** * 鐢熸垚妫�鏌ヨ〃鏍� * -- Gitblit v1.8.0