feat:新增住院缴费、门诊缴费小票模板

This commit is contained in:
石崇礼 2025-03-24 10:27:51 +08:00
parent d931ad2bdf
commit 0b9d16befc
4 changed files with 132 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package com.dpkj.modules.autoReplyPrint.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dpkj.common.exception.RRException; import com.dpkj.common.exception.RRException;
import com.dpkj.common.vo.Result; import com.dpkj.common.vo.Result;
import com.dpkj.modules.autoReplyPrint.enums.ReceiptTemplateEnum;
import com.dpkj.modules.autoReplyPrint.request.ReceiptPrintRequest; import com.dpkj.modules.autoReplyPrint.request.ReceiptPrintRequest;
import com.dpkj.modules.autoReplyPrint.service.ImagePrintService; import com.dpkj.modules.autoReplyPrint.service.ImagePrintService;
import com.dpkj.modules.autoReplyPrint.service.impl.TemplateService; import com.dpkj.modules.autoReplyPrint.service.impl.TemplateService;
@ -38,6 +39,7 @@ public class ReceiptPrintController {
@PostMapping("/print") @PostMapping("/print")
private Result<Void> print(@Validated @RequestBody ReceiptPrintRequest request) throws UnsupportedEncodingException { private Result<Void> print(@Validated @RequestBody ReceiptPrintRequest request) throws UnsupportedEncodingException {
String devName = "VID:0x0FE6,PID:0x811E"; // 采用默认的devName不进行入参传值了 String devName = "VID:0x0FE6,PID:0x811E"; // 采用默认的devName不进行入参传值了
String templateName = ReceiptTemplateEnum.getTemplateName(request.getTemplateName());
// 进行模板填充 // 进行模板填充
// String testData = "{\"hospitalName\":\"澜沧县中医医院\",\"registeTerminalName\":\"中国农业银行自助终端\",\"registeType\":\"自助挂号\",\"name\":\"刘博雅\",\"gender\":\"\",\"age\":28,\"birthDate\":\"1996-06-31\",\"cardNumber\":\"6221**********0731\",\"outpatientNumber\":\"2501150038\",\"department\":\"普外科门诊\",\"visitLevel\":\"普通号\",\"doctor\":\"普通门诊\",\"sequence\":\"1\",\"registerDate\":\"2025-01-15\",\"totalFee\":4.00,\"paymentMethod\":\"微信扫码支付\",\"orderNumber\":\"\",\"transactionNumber\":\"2025011513090412092794szztzzj\",\"qrCodeBase64_2base64Type_1_250_250\":\"maby this is a Base64 code data if has\",\"terminalNumber\":\"12092794\",\"printTime\":\"2025-01-15 13:10:08\"}"; // String testData = "{\"hospitalName\":\"澜沧县中医医院\",\"registeTerminalName\":\"中国农业银行自助终端\",\"registeType\":\"自助挂号\",\"name\":\"刘博雅\",\"gender\":\"\",\"age\":28,\"birthDate\":\"1996-06-31\",\"cardNumber\":\"6221**********0731\",\"outpatientNumber\":\"2501150038\",\"department\":\"普外科门诊\",\"visitLevel\":\"普通号\",\"doctor\":\"普通门诊\",\"sequence\":\"1\",\"registerDate\":\"2025-01-15\",\"totalFee\":4.00,\"paymentMethod\":\"微信扫码支付\",\"orderNumber\":\"\",\"transactionNumber\":\"2025011513090412092794szztzzj\",\"qrCodeBase64_2base64Type_1_250_250\":\"maby this is a Base64 code data if has\",\"terminalNumber\":\"12092794\",\"printTime\":\"2025-01-15 13:10:08\"}";
StringBuilder filePath = new StringBuilder(request.getFileDir()); StringBuilder filePath = new StringBuilder(request.getFileDir());
@ -45,7 +47,7 @@ public class ReceiptPrintController {
if ( !StringUtils.isEmpty(request.getTemplateName()) && !StringUtils.isEmpty(request.getFileDir())){ if ( !StringUtils.isEmpty(request.getTemplateName()) && !StringUtils.isEmpty(request.getFileDir())){
byte[] image = templateService.generateReceiptImage( byte[] image = templateService.generateReceiptImage(
JSONObject.parseObject(URLDecoder.decode(request.getTemplateFillData(), "UTF-8")), JSONObject.parseObject(URLDecoder.decode(request.getTemplateFillData(), "UTF-8")),
request.getTemplateName(), templateName,
request.getWidth(), request.getWidth(),
request.getHeight(), request.getHeight(),
filePath); filePath);

View File

@ -0,0 +1,63 @@
package com.dpkj.modules.autoReplyPrint.enums;
import com.dpkj.common.exception.RRException;
import lombok.Getter;
@Getter
public enum ReceiptTemplateEnum {
/**
* 自足挂号模板
*/
REGISTER("1", "register", "自助挂号的"),
/**
* 住院缴费的模板
*/
HOSPITAL_PAYMENT("2", "hospitalPayment", "住院缴费的小票"),
/**
* 门诊缴费的模板
*/
OUTPATIENT_PAYMENT("3", "outpatientPayment", "门诊缴费的小票"),
;
private final String code;
private final String templateName;
private final String desc;
ReceiptTemplateEnum(String code, String templateName, String desc){
this.code = code;
this.templateName = templateName;
this.desc = desc;
}
/**
* 通过code获取模板名称
* @param code code/也有可能直接是一个名称
* @return 模板的名称
*/
public static String getTemplateName(String code){
if (code == null || "".equals(code)) {
throw new RRException("模板名称不能为空");
}
String name = null;
for (ReceiptTemplateEnum enumEntity : ReceiptTemplateEnum.values()) {
String enumCode = enumEntity.getCode();
if ( enumCode.equals(code)){
name = enumEntity.getTemplateName();
break;
}
}
return name == null ? code : name;
}
}

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>挂号单</title>
</head>
<body>
<div style="font-size: 32px; margin-top: 20px;">
<div style="">
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${hospitalName}"></span></div>
<div style="text-align: center; font-weight: 700; font-size: 28px;">****<span th:text="${registeTerminalName}"></span></span>****</div>
<div style="text-align: center; font-weight: 700; margin-bottom: -10px; margin-top: -10px;">-----------------------------------------------------------------------------</div>
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${registeType}"></span></div>
<div style="text-align: center; font-weight: 700; margin-top: -15px;">-----------------------------------------------------------------------------</div>
</div>
<div style="font-weight: 700; font-size: 37px;">
<div style="margin-left: 35px;">&emsp;&emsp;名:<span th:text="${name}"></span></div>
<div style="margin-left: 35px;">&emsp;&emsp;别:<span th:text="${gender}"></span></div>
<div style="margin-left: 35px;">&emsp;&emsp;龄:<span th:text="${age}"></span></div>
<div style="margin-left: 35px;">出生日期:<span th:text="${birthDate}"></span></div>
<div style="margin-left: 35px;">&ensp;&ensp;号:<span th:text="${outpatientNumber}"></span></div>
<div style="margin-left: 35px;">入院科室:<span th:text="${department}"></span></div>
<div style="margin-left: 35px;">&ensp;&ensp;用:<span th:text="${totalFee}"></span>&thinsp;</div>
<div style="margin-left: 35px;">支付方式:<span th:text="${paymentMethod}"></span></div>
<div style="margin-left: 35px;">交易流水:<span style="font-size: 35px;" th:text="${transactionNumber}"></span></div>
</div>
<div style="font-weight: 700; margin-top: 8px;">
<!-- <div style="margin-top: -40px; text-align: center; ">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</div>-->
<div style="font-size: 36px;margin-left: 35px; ">备注:缴费凭证,请妥善保管!</div>
<div style="font-size: 36px;margin-left: 35px;">&ensp;&ensp;号:<span th:text="${terminalNumber}"></span></div>
<div style="font-size: 36px;margin-left: 35px;">打印时间:<span th:text="${printTime}"></span></div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>门诊缴费</title>
</head>
<body>
<div style="font-size: 32px; margin-top: 20px;">
<div style="">
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${hospitalName}"></span></div>
<div style="text-align: center; font-weight: 700; font-size: 28px;">****<span th:text="${registeTerminalName}"></span></span>****</div>
<div style="text-align: center; font-weight: 700; margin-bottom: -10px; margin-top: -10px;">-----------------------------------------------------------------------------</div>
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${registeType}"></span></div>
<div style="text-align: center; font-weight: 700; margin-top: -15px;">-----------------------------------------------------------------------------</div>
</div>
<div style="font-weight: 700; font-size: 37px;">
<div style="margin-left: 35px;">&emsp;&emsp;名:<span th:text="${name}"></span></div>
<div style="margin-left: 35px;">&emsp;&emsp;别:<span th:text="${gender}"></span></div>
<div style="margin-left: 35px;">&emsp;&emsp;龄:<span th:text="${age}"></span></div>
<div style="margin-left: 35px;">出生日期:<span th:text="${birthDate}"></span></div>
<div style="margin-left: 35px;">&ensp;&ensp;用:<span th:text="${totalFee}"></span>&thinsp;</div>
<div style="margin-left: 35px;">支付方式:<span th:text="${paymentMethod}"></span></div>
<div style="margin-left: 35px;">交易流水:<span style="font-size: 35px;" th:text="${transactionNumber}"></span></div>
</div>
<div style="font-weight: 700; margin-top: 8px;">
<!-- <div style="margin-top: -40px; text-align: center; ">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</div>-->
<div style="font-size: 36px;margin-left: 35px; ">备注:缴费凭证,请妥善保管!</div>
<div style="font-size: 36px;margin-left: 35px;">&ensp;&ensp;号:<span th:text="${terminalNumber}"></span></div>
<div style="font-size: 36px;margin-left: 35px;">打印时间:<span th:text="${printTime}"></span></div>
</div>
</div>
</body>
</html>