模板重构
This commit is contained in:
parent
c937c4823f
commit
72288c08a4
|
@ -50,9 +50,9 @@ public class ReceiptPrintRequest implements Serializable {
|
|||
private Integer width = 690;
|
||||
|
||||
/**
|
||||
* 生成的模板的高度,默认为:1000
|
||||
* 生成的模板的高度,默认为:1050
|
||||
*/
|
||||
private Integer height = 1000;
|
||||
private Integer height = 1050;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 模板服务类
|
||||
*
|
||||
|
@ -111,6 +110,7 @@ public class TemplateService {
|
|||
|
||||
/**
|
||||
* 生成图片
|
||||
*
|
||||
* @param html html内容
|
||||
*/
|
||||
private BufferedImage generate(String html, int width, int height) {
|
||||
|
@ -132,6 +132,7 @@ public class TemplateService {
|
|||
|
||||
/**
|
||||
* 通过JsonObject进行context内容填充
|
||||
*
|
||||
* @param data jsonObject
|
||||
* @return context
|
||||
*/
|
||||
|
@ -163,6 +164,7 @@ public class TemplateService {
|
|||
|
||||
/**
|
||||
* 根据内容生成二维码
|
||||
*
|
||||
* @param content 转换内容
|
||||
*/
|
||||
private String generateQRCode(int type, String content, int width, int height) {
|
||||
|
@ -173,7 +175,7 @@ public class TemplateService {
|
|||
Map<EncodeHintType, Object> 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);
|
||||
|
||||
|
@ -182,6 +184,7 @@ public class TemplateService {
|
|||
Map<EncodeHintType, Object> 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);
|
||||
|
@ -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,6 +267,7 @@ public class TemplateService {
|
|||
|
||||
/**
|
||||
* 通过document转换为图片
|
||||
*
|
||||
* @param document doc
|
||||
* @param width 图片的宽度
|
||||
* @param height 图片的高度
|
||||
|
@ -312,6 +318,7 @@ public class TemplateService {
|
|||
|
||||
/**
|
||||
* 校验这个模板内容是不是html字符串,而非模板名称
|
||||
*
|
||||
* @param template template
|
||||
* @return 是否是html字符串
|
||||
*/
|
||||
|
@ -328,6 +335,7 @@ public class TemplateService {
|
|||
|
||||
/**
|
||||
* 将document对象转换为字符串
|
||||
*
|
||||
* @param doc document
|
||||
* @return document转换为的字符串
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html xmlns:th="http://www.thymeleaf.org" lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>门诊缴费凭证</title>
|
||||
<title>门诊缴费凭证T2</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="font-size: 24px;font-weight: bold;">
|
||||
|
@ -12,16 +12,12 @@
|
|||
<div style="text-align: center; font-size: 20px;">
|
||||
****<span th:text="${registeTerminalName}"></span>****
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-bottom: -10px; margin-top: -10px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="text-align: center; font-size: 32px; "><span th:text="${registeType}"></span>
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-top: -15px;">
|
||||
-----------------------------------------------------------------------------
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size: 27px;word-break: break-all;margin: 10px 20px;">
|
||||
<div style="font-size: 29px;word-break: break-all;margin: 10px 20px;">
|
||||
<div style="display: flex;">
|
||||
<span style="margin-right: 25px;">姓名:<span th:text="${name}"></span></span>
|
||||
<span style="margin-right: 25px;">性别:<span th:text="${gender}"></span></span>
|
||||
|
@ -37,10 +33,8 @@
|
|||
<div style="margin-top: 10px;" th:if="${department}">就诊科室:<span th:text="${department}"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="text-align: center; font-size: 24px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="font-size: 27px; margin: 10px 20px">
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="font-size: 29px; margin: 10px 20px">
|
||||
<div style="word-break: break-all;">
|
||||
<span style="margin-right: 25px;">费用总额:<span th:text="${totalFee}"></span></span>
|
||||
<span>个人支付:<span th:text="${personalPayment}"></span></span>
|
||||
|
@ -49,18 +43,16 @@
|
|||
th:text="${actualReceiptAmount}"></span></div>
|
||||
<div style="margin-top: 10px;"><span>实收金额:</span><span th:text="${actualReceiptAmountChinese}"></span></div>
|
||||
</div>
|
||||
<div style="text-align: center; font-size: 24px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="margin: 10px 20px">
|
||||
<table style="width: 100%; table-layout: fixed; border-collapse: collapse;">
|
||||
<tr style="font-size: 27px;">
|
||||
<tr style="font-size: 29px;">
|
||||
<th style="width: 300px;text-align: left;">项目名称</th>
|
||||
<th style="width: calc(25% - 5px);text-align: center;">数量</th>
|
||||
<th style="width: calc(25% - 5px);text-align: center;">单价</th>
|
||||
<th style="width: calc(25% - 5px);text-align: center;">小计</th>
|
||||
</tr>
|
||||
<tr style="font-size: 22px;word-break: break-all;" th:each="item : ${items}">
|
||||
<tr style="font-size: 24px;word-break: break-all;" th:each="item : ${items}">
|
||||
<td style="text-align: left;width: 300px;" th:text="${item.name}"></td>
|
||||
<td style="text-align: center;" th:text="${item.quantity}"></td>
|
||||
<td style="text-align: center;" th:text="${item.unitPrice}"></td>
|
||||
|
@ -68,17 +60,11 @@
|
|||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div style="text-align: center; font-size: 24px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="margin-left: 20px; font-size: 27px;">
|
||||
<div>终端编号:<span th:text="${terminalNumber}"></span></div>
|
||||
<div>打印时间:<span th:text="${printTime}"></span></div>
|
||||
</div>
|
||||
<div style="margin-left: 20px; font-size: 27px; margin-top: 20px;">
|
||||
<span style="margin-top: 20px;">温馨提示</span><br>
|
||||
<span>1.请取走全部凭条、并妥善保管</span><br>
|
||||
<span>2.如果对缴费结算存在疑问,请到人工窗口咨询</span>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">终端编号:<span th:text="${terminalNumber}"></span></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="margin-left: 20px; margin-top: 10px;font-size: 27px;">
|
||||
<span>温馨提示:请取走缴费凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>挂号单</title>
|
||||
<title>住院押金预缴</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="font-size: 24px;font-weight: bold;">
|
||||
|
@ -11,32 +11,28 @@
|
|||
<div style="text-align: center; font-size: 20px;">
|
||||
****<span th:text="${registeTerminalName}"></span>****
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-bottom: -10px; margin-top: -10px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="text-align: center; font-size: 32px; "><span th:text="${registeType}"></span>
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-top: -15px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
</div>
|
||||
<div style=" font-size: 29px;">
|
||||
<div style="margin-left: 35px;">姓  名:<span th:text="${name}"></span></div>
|
||||
<div style="margin-left: 35px;">性  别:<span th:text="${gender}"></span></div>
|
||||
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
||||
<div style="margin-left: 35px;">出生日期:<span th:text="${birthDate}"></span></div>
|
||||
<div style="margin-left: 35px;">门 诊 号:<span th:text="${outpatientNumber}"></span></div>
|
||||
<div style="margin-left: 35px;">入院科室:<span th:text="${department}"></span></div>
|
||||
<div style="margin-left: 35px;">总 费 用:<span th:text="${totalFee}"></span> 元</div>
|
||||
<div style="margin-left: 35px;">支付方式:<span th:text="${paymentMethod}"></span></div>
|
||||
<div style="margin-left: 35px;">交易流水:<span style="font-size: 27px;" th:text="${transactionNumber}"></span>
|
||||
<div style="margin-left: 20px;">姓  名:<span th:text="${name}"></span></div>
|
||||
<div style="margin-left: 20px;">性  别:<span th:text="${gender}"></span></div>
|
||||
<div style="margin-left: 20px;">年  龄:<span th:text="${age}"></span></div>
|
||||
<div style="margin-left: 20px;">出生日期:<span th:text="${birthDate}"></span></div>
|
||||
<div style="margin-left: 20px;">门 诊 号:<span th:text="${outpatientNumber}"></span></div>
|
||||
<div style="margin-left: 20px;">入院科室:<span th:text="${department}"></span></div>
|
||||
<div style="margin-left: 20px;">总 费 用:<span th:text="${totalFee}"></span> 元</div>
|
||||
<div style="margin-left: 20px;">支付方式:<span th:text="${paymentMethod}"></span></div>
|
||||
<div style="margin-left: 20px;">交易流水:<span style="font-size: 27px;" th:text="${transactionNumber}"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div style=" margin-top: 8px;">
|
||||
<div style="font-size: 28px;margin-left: 35px; ">备注:缴费凭证,请妥善保管!</div>
|
||||
<div style="font-size: 28px;margin-left: 35px;">终 端 号:<span th:text="${terminalNumber}"></span>
|
||||
</div>
|
||||
<div style="font-size: 28px;margin-left: 35px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">终端编号:<span th:text="${terminalNumber}"></span></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="margin-left: 20px; margin-top: 10px;font-size: 27px;">
|
||||
<span>温馨提示:请取走缴费凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>门诊缴费</title>
|
||||
<title>门诊缴费凭证T1</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="font-size: 24px;font-weight: bold;">
|
||||
|
@ -11,30 +11,26 @@
|
|||
<div style="text-align: center; font-size: 20px;">
|
||||
****<span th:text="${registeTerminalName}"></span>****
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-bottom: -10px; margin-top: -10px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="text-align: center; font-size: 32px; "><span th:text="${registeType}"></span>
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-top: -15px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
</div>
|
||||
<div style="font-size: 29px;">
|
||||
<div style="margin-left: 35px;">姓  名:<span th:text="${name}"></span></div>
|
||||
<div style="margin-left: 35px;">性  别:<span th:text="${gender}"></span></div>
|
||||
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
||||
<div style="margin-left: 35px;">出生日期:<span th:text="${birthDate}"></span></div>
|
||||
<div style="margin-left: 35px;">总 费 用:<span th:text="${totalFee}"></span> 元</div>
|
||||
<div style="margin-left: 35px;">支付方式:<span th:text="${paymentMethod}"></span></div>
|
||||
<div style="margin-left: 35px;">交易流水:<span style="font-size: 27px;" th:text="${transactionNumber}"></span>
|
||||
<div style="margin-left: 20px;">姓  名:<span th:text="${name}"></span></div>
|
||||
<div style="margin-left: 20px;">性  别:<span th:text="${gender}"></span></div>
|
||||
<div style="margin-left: 20px;">年  龄:<span th:text="${age}"></span></div>
|
||||
<div style="margin-left: 20px;">出生日期:<span th:text="${birthDate}"></span></div>
|
||||
<div style="margin-left: 20px;">总 费 用:<span th:text="${totalFee}"></span> 元</div>
|
||||
<div style="margin-left: 20px;">支付方式:<span th:text="${paymentMethod}"></span></div>
|
||||
<div style="margin-left: 20px;">交易流水:<span style="font-size: 27px;" th:text="${transactionNumber}"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div style=" margin-top: 8px;">
|
||||
<div style="font-size: 28px;margin-left: 35px; ">备注:缴费凭证,请妥善保管!</div>
|
||||
<div style="font-size: 28px;margin-left: 35px;">终 端 号:<span th:text="${terminalNumber}"></span>
|
||||
</div>
|
||||
<div style="font-size: 28px;margin-left: 35px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">终端编号:<span th:text="${terminalNumber}"></span></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="margin-left: 20px; margin-top: 10px;font-size: 27px;">
|
||||
<span>温馨提示:请取走缴费凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -11,44 +11,36 @@
|
|||
<div style="text-align: center;font-size: 20px;">
|
||||
<span>****<span th:text="${registeTerminalName}"></span>****</span>
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center;margin-bottom: -10px; margin-top: -10px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
<div style="text-align: center; font-size: 32px;"><span th:text="${registeType}"></span>
|
||||
</div>
|
||||
<div style="font-size: 24px;text-align: center; margin-top: -15px;">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
|
||||
</div>
|
||||
<div style="font-size: 29px;">
|
||||
<div style="margin-left: 35px;">姓  名:<span th:text="${name}"></span></div>
|
||||
<div style="margin-left: 35px;">性  别:<span th:text="${gender}"></span></div>
|
||||
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
||||
<div style="margin-left: 35px;">出生日期:<span th:text="${birthDate}"></span></div>
|
||||
<div style="margin-left: 35px;">门 诊 号:<span th:text="${outpatientNumber}"></span></div>
|
||||
<div style="margin-left: 35px;">就诊科室:<span th:text="${department}"></span></div>
|
||||
<div style="margin-left: 35px;">出诊级别:<span th:text="${visitLevel}"></span></div>
|
||||
<div style="margin-left: 35px;">就诊医生:<span th:text="${doctor}"></span></div>
|
||||
<div style="margin-left: 35px;">号  序:<span th:text="${sequence}"></span></div>
|
||||
<div style="margin-left: 35px;">挂号日期:<span th:text="${registerDate}"></span></div>
|
||||
<div style="margin-left: 35px;">总 费 用:<span th:text="${totalFee}"></span> 元</div>
|
||||
<div style="margin-left: 35px;">支付方式:<span th:text="${paymentMethod}"></span></div>
|
||||
<div style="margin-left: 35px;">交易流水:<span style="font-size: 26px;"
|
||||
<div style="margin-left: 20px;">姓  名:<span th:text="${name}"></span></div>
|
||||
<div style="margin-left: 20px;">性  别:<span th:text="${gender}"></span></div>
|
||||
<div style="margin-left: 20px;">年  龄:<span th:text="${age}"></span></div>
|
||||
<div style="margin-left: 20px;">出生日期:<span th:text="${birthDate}"></span></div>
|
||||
<div style="margin-left: 20px;">门 诊 号:<span th:text="${outpatientNumber}"></span></div>
|
||||
<div style="margin-left: 20px;">就诊科室:<span th:text="${department}"></span></div>
|
||||
<div style="margin-left: 20px;">出诊级别:<span th:text="${visitLevel}"></span></div>
|
||||
<div style="margin-left: 20px;">就诊医生:<span th:text="${doctor}"></span></div>
|
||||
<div style="margin-left: 20px;">号  序:<span th:text="${sequence}"></span></div>
|
||||
<div style="margin-left: 20px;">挂号日期:<span th:text="${registerDate}"></span></div>
|
||||
<div style="margin-left: 20px;">总 费 用:<span th:text="${totalFee}"></span> 元</div>
|
||||
<div style="margin-left: 20px;">支付方式:<span th:text="${paymentMethod}"></span></div>
|
||||
<div style="margin-left: 20px;">交易流水:<span style="font-size: 26px;"
|
||||
th:text="${transactionNumber}"></span></div>
|
||||
<div style="width: 100%; text-align: center; margin-bottom: -20px;">
|
||||
<img style="display: inline-block; "
|
||||
th:src="${qrCodeBase64}"
|
||||
alt="QR Code"/>
|
||||
<div style="width:100%;text-align: center;">
|
||||
<img th:src="${qrCodeBase64}"
|
||||
alt="#"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 3px;">
|
||||
<div style="font-size: 24px;margin-top: -40px; text-align: center; ">
|
||||
-----------------------------------------------------------------------------
|
||||
</div>
|
||||
<div style="font-size: 28px;margin-left: 35px; ">备注:凭此条退费,请妥善保管!</div>
|
||||
<div style="font-size: 28px;margin-left: 35px;">终 端 号:<span th:text="${terminalNumber}"></span>
|
||||
</div>
|
||||
<div style="font-size: 28px;margin-left: 35px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="border-bottom: 1px dashed #000;margin-bottom: 3px;"></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">终端编号:<span th:text="${terminalNumber}"></span></div>
|
||||
<div style="margin-left: 20px;font-size: 29px;">打印时间:<span th:text="${printTime}"></span></div>
|
||||
<div style="margin-left: 20px; margin-top: 10px;font-size: 27px;">
|
||||
<span>温馨提示:请取走挂号凭证,并妥善保管,如果对缴费存在疑问,请到人工窗口咨询!</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue