From 72288c08a4793b78e7c28be598a4270a38ca1b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E6=96=87=E8=B4=A2?= Date: Tue, 20 May 2025 16:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/ReceiptPrintRequest.java | 4 +- .../service/impl/TemplateService.java | 32 ++++++----- src/main/resources/templates/department.html | 42 +++++---------- .../resources/templates/hospitalPayment.html | 38 ++++++------- .../templates/outpatientPayment.html | 38 ++++++------- src/main/resources/templates/register.html | 54 ++++++++----------- 6 files changed, 93 insertions(+), 115 deletions(-) diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/request/ReceiptPrintRequest.java b/src/main/java/com/dpkj/modules/autoReplyPrint/request/ReceiptPrintRequest.java index abc4d5a..3c85e74 100644 --- a/src/main/java/com/dpkj/modules/autoReplyPrint/request/ReceiptPrintRequest.java +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/request/ReceiptPrintRequest.java @@ -50,9 +50,9 @@ public class ReceiptPrintRequest implements Serializable { private Integer width = 690; /** - * 生成的模板的高度,默认为:1000 + * 生成的模板的高度,默认为:1050 */ - private Integer height = 1000; + private Integer height = 1050; } diff --git a/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/TemplateService.java b/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/TemplateService.java index 21d123f..2f746d8 100644 --- a/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/TemplateService.java +++ b/src/main/java/com/dpkj/modules/autoReplyPrint/service/impl/TemplateService.java @@ -14,6 +14,7 @@ import org.jsoup.Jsoup; import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext; import org.springframework.stereotype.Service; import org.thymeleaf.TemplateEngine; +import org.thymeleaf.context.Context; import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver; import org.thymeleaf.templatemode.TemplateMode; import org.thymeleaf.templateresolver.StringTemplateResolver; @@ -42,8 +43,6 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import org.thymeleaf.context.Context; - /** * 模板服务类 * @@ -77,7 +76,7 @@ public class TemplateService { resolver.setTemplateMode("HTML"); // 设置模板引擎使用这个自定义的模板解析器 templateEngine.setTemplateResolver(resolver); - }else { + } else { SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver(); resolver.setPrefix("classpath:/templates/"); resolver.setSuffix(".html"); @@ -111,9 +110,10 @@ public class TemplateService { /** * 生成图片 + * * @param html html内容 */ - private BufferedImage generate(String html, int width, int height){ + private BufferedImage generate(String html, int width, int height) { try { // 转换为xhtml String xhtml = this.htmlToXhtml(html); @@ -132,13 +132,14 @@ public class TemplateService { /** * 通过JsonObject进行context内容填充 + * * @param data jsonObject * @return context */ private Context getContext(JSONObject data) { // 创建Thymeleaf上下文 Context context = new Context(); - if ( data != null) { + if (data != null) { Set keys = data.keySet(); for (String key : keys) { // 判单是否有图片生成,统一后面采用的是_2base64Type @@ -163,6 +164,7 @@ public class TemplateService { /** * 根据内容生成二维码 + * * @param content 转换内容 */ private String generateQRCode(int type, String content, int width, int height) { @@ -173,15 +175,16 @@ public class TemplateService { Map hints = new HashMap<>(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); // 设置字符编码为 UTF-8 hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); // 设置纠错级别 - + hints.put(EncodeHintType.MARGIN, 1); // // 添加边距控制,设置边距为1 QRCodeWriter qrCodeWriter = new QRCodeWriter(); bitMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, width, height, hints); qrImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - }else if (type == 2) { + } else if (type == 2) { Map hints = new HashMap<>(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); + hints.put(EncodeHintType.MARGIN, 1); // // 添加边距控制,设置边距为1 Code128Writer barcodeWriter = new Code128Writer(); bitMatrix = barcodeWriter.encode(content, BarcodeFormat.CODE_128, width, height, hints); @@ -206,7 +209,7 @@ public class TemplateService { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(qrImage, "png", baos); return Base64.getEncoder().encodeToString(baos.toByteArray()); - }catch (Exception e){ + } catch (Exception e) { log.error("二维码/条形码生成失败", e); throw new RRException("二维码/条形码生成失败"); } @@ -215,6 +218,7 @@ public class TemplateService { /** * xhtml 转换为 Document + * * @param xhtml xhtml * @return document * @throws Exception e @@ -235,6 +239,7 @@ public class TemplateService { /** * 转换,将html转换为xhtml + * * @param html html内容 * @return xhtml */ @@ -262,9 +267,10 @@ public class TemplateService { /** * 通过document转换为图片 + * * @param document doc - * @param width 图片的宽度 - * @param height 图片的高度 + * @param width 图片的宽度 + * @param height 图片的高度 * @return bufferedImage */ private BufferedImage createImageToDocument(Document document, int width, int height) { @@ -312,15 +318,16 @@ public class TemplateService { /** * 校验这个模板内容是不是html字符串,而非模板名称 + * * @param template template * @return 是否是html字符串 */ - private boolean checkIsHtml(String template){ + private boolean checkIsHtml(String template) { try { String pattern = "<(\"[^\"]*\"|'[^']*'|[^'\">])*>"; Pattern r = Pattern.compile(pattern); return r.matcher(template).find(); - }catch (Exception e) { + } catch (Exception e) { return false; } } @@ -328,6 +335,7 @@ public class TemplateService { /** * 将document对象转换为字符串 + * * @param doc document * @return document转换为的字符串 */ diff --git a/src/main/resources/templates/department.html b/src/main/resources/templates/department.html index 11b5cf6..cb2fcfd 100644 --- a/src/main/resources/templates/department.html +++ b/src/main/resources/templates/department.html @@ -2,7 +2,7 @@ - 门诊缴费凭证 + 门诊缴费凭证T2
@@ -12,16 +12,12 @@
********
-
- ----------------------------------------------------------------------------- -
+
-
- ----------------------------------------------------------------------------- -
+
-
+
姓名: 性别: @@ -37,10 +33,8 @@
就诊科室:
-
- ----------------------------------------------------------------------------- -
-
+
+
费用总额: 个人支付: @@ -49,18 +43,16 @@ th:text="${actualReceiptAmount}">
实收金额:
-
- ----------------------------------------------------------------------------- -
+
- + - + @@ -68,17 +60,11 @@
项目名称 数量 单价 小计
-
- ----------------------------------------------------------------------------- -
-
-
终端编号:
-
打印时间:
-
-
- 温馨提示
- 1.请取走全部凭条、并妥善保管
- 2.如果对缴费结算存在疑问,请到人工窗口咨询 +
+
终端编号:
+
打印时间:
+
+ 温馨提示:请取走缴费凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!
diff --git a/src/main/resources/templates/hospitalPayment.html b/src/main/resources/templates/hospitalPayment.html index edc02af..15ae90b 100644 --- a/src/main/resources/templates/hospitalPayment.html +++ b/src/main/resources/templates/hospitalPayment.html @@ -1,7 +1,7 @@ - 挂号单 + 住院押金预缴
@@ -11,32 +11,28 @@
********
-
- ----------------------------------------------------------------------------- -
+
-
- ----------------------------------------------------------------------------- -
+
-
姓  名:
-
性  别:
-
年  龄:
-
出生日期:
-
门 诊 号:
-
入院科室:
-
总 费 用: 元
-
支付方式:
-
交易流水: +
姓  名:
+
性  别:
+
年  龄:
+
出生日期:
+
门 诊 号:
+
入院科室:
+
总 费 用: 元
+
支付方式:
+
交易流水:
-
-
备注:缴费凭证,请妥善保管!
-
终 端 号: -
-
打印时间:
+
+
终端编号:
+
打印时间:
+
+ 温馨提示:请取走缴费凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!
diff --git a/src/main/resources/templates/outpatientPayment.html b/src/main/resources/templates/outpatientPayment.html index 52af7b1..5a63cdd 100644 --- a/src/main/resources/templates/outpatientPayment.html +++ b/src/main/resources/templates/outpatientPayment.html @@ -1,7 +1,7 @@ - 门诊缴费 + 门诊缴费凭证T1
@@ -11,30 +11,26 @@
********
-
- ----------------------------------------------------------------------------- -
+
-
- ----------------------------------------------------------------------------- +
+
+
+
姓  名:
+
性  别:
+
年  龄:
+
出生日期:
+
总 费 用: 元
+
支付方式:
+
交易流水:
-
-
姓  名:
-
性  别:
-
年  龄:
-
出生日期:
-
总 费 用: 元
-
支付方式:
-
交易流水: -
-
-
-
备注:缴费凭证,请妥善保管!
-
终 端 号: -
-
打印时间:
+
+
终端编号:
+
打印时间:
+
+ 温馨提示:请取走缴费凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!
diff --git a/src/main/resources/templates/register.html b/src/main/resources/templates/register.html index 20358c4..a56024c 100644 --- a/src/main/resources/templates/register.html +++ b/src/main/resources/templates/register.html @@ -11,44 +11,36 @@
********
-
- ----------------------------------------------------------------------------- -
+
-
- ----------------------------------------------------------------------------- -
+
-
姓  名:
-
性  别:
-
年  龄:
-
出生日期:
-
门 诊 号:
-
就诊科室:
-
出诊级别:
-
就诊医生:
-
号  序:
-
挂号日期:
-
总 费 用: 元
-
支付方式:
-
交易流水:姓  名:
+
性  别:
+
年  龄:
+
出生日期:
+
门 诊 号:
+
就诊科室:
+
出诊级别:
+
就诊医生:
+
号  序:
+
挂号日期:
+
总 费 用: 元
+
支付方式:
+
交易流水:
-
- QR Code +
+ #
-
-
- ----------------------------------------------------------------------------- -
-
备注:凭此条退费,请妥善保管!
-
终 端 号: -
-
打印时间:
+
+
终端编号:
+
打印时间:
+
+ 温馨提示:请取走挂号凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!