fix:优化界面
This commit is contained in:
parent
4fbc844ddd
commit
9e13e1eaf0
|
@ -2,7 +2,6 @@ package com.dpkj.common.config;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,4 +28,15 @@ public class PrinterConfig {
|
||||||
* 波特率 串口连接下使用
|
* 波特率 串口连接下使用
|
||||||
*/
|
*/
|
||||||
private Integer baudRate;
|
private Integer baudRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端号
|
||||||
|
*/
|
||||||
|
private String terminalNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间格式
|
||||||
|
*/
|
||||||
|
private String timeType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.dpkj.modules.autoReplyPrint.controller;
|
package com.dpkj.modules.autoReplyPrint.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dpkj.common.config.PrinterConfig;
|
||||||
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.enums.ReceiptTemplateEnum;
|
||||||
|
@ -15,6 +17,8 @@ import org.thymeleaf.util.StringUtils;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@ -30,6 +34,12 @@ import javax.annotation.Resource;
|
||||||
@RequestMapping("/receipt")
|
@RequestMapping("/receipt")
|
||||||
public class ReceiptPrintController {
|
public class ReceiptPrintController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrinterConfig printerConfig;
|
||||||
|
|
||||||
|
private static final int MAX_HEIGHT = 1000;
|
||||||
|
private static final int FIXED_WIDTH = 730;
|
||||||
|
|
||||||
@Resource(name = "USBImagePrint")
|
@Resource(name = "USBImagePrint")
|
||||||
private ImagePrintService usbImagePrintService;
|
private ImagePrintService usbImagePrintService;
|
||||||
|
|
||||||
|
@ -40,16 +50,72 @@ public class ReceiptPrintController {
|
||||||
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 templateName = ReceiptTemplateEnum.getTemplateName(request.getTemplateName());
|
||||||
|
|
||||||
|
// 宽度固定
|
||||||
|
request.setWidth(request.getWidth() > 610 ? 600 : request.getWidth());
|
||||||
|
|
||||||
|
JSONObject data = JSONObject.parseObject(URLDecoder.decode(request.getTemplateFillData(), "UTF-8"));
|
||||||
|
|
||||||
|
// 强行设置终端号
|
||||||
|
data.put("terminalNumber", printerConfig.getTerminalNumber());
|
||||||
|
|
||||||
|
// 强行设置终端号和打印时间
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat(printerConfig.getTimeType());
|
||||||
|
String formattedDate = sdf.format( new Date());
|
||||||
|
data.put("printTime", formattedDate);
|
||||||
|
|
||||||
|
Integer height = request.getHeight();
|
||||||
|
|
||||||
|
int dinyHeight = 0;
|
||||||
|
if (templateName.equals("department")) {
|
||||||
|
// 由于是使用的门诊小票-T2,那么默认的高度为1000,强行设置,通过动态修改渲染的图片的高度
|
||||||
|
height = 1100;
|
||||||
|
|
||||||
|
// 单行最大长度为10
|
||||||
|
int singleLineMaxLength = 10;
|
||||||
|
// 这里的长度取自于department.html模板中的项目单个tr高度,并且略高于该高度
|
||||||
|
int singleLineHeight = 30;
|
||||||
|
// 动态计算长度
|
||||||
|
JSONArray items = data.getJSONArray("items");
|
||||||
|
for (Object item : items) {
|
||||||
|
JSONObject itemEntity = (JSONObject) item;
|
||||||
|
String projectName = String.valueOf(itemEntity.get("name"));
|
||||||
|
int length = projectName.length();
|
||||||
|
int count = (int)Math.ceil((double) length / singleLineMaxLength);
|
||||||
|
dinyHeight += count * singleLineHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算是否有门诊号
|
||||||
|
String outpatientNumber = data.getString("outpatientNumber");
|
||||||
|
if ( !StringUtils.isEmpty(outpatientNumber)){
|
||||||
|
dinyHeight += 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算是否有就诊医生
|
||||||
|
String doctor = data.getString("doctor");
|
||||||
|
if ( !StringUtils.isEmpty(doctor)){
|
||||||
|
dinyHeight += 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算是否有就诊科室
|
||||||
|
String department = data.getString("department");
|
||||||
|
if ( !StringUtils.isEmpty(department)){
|
||||||
|
dinyHeight += 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
height += dinyHeight;
|
||||||
|
|
||||||
// 进行模板填充
|
// 进行模板填充
|
||||||
// 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());
|
||||||
// 校验是否选中了模板,如果没选中模板的话则不需要另外生成了
|
// 校验是否选中了模板,如果没选中模板的话则不需要另外生成了
|
||||||
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")),
|
data,
|
||||||
templateName,
|
templateName,
|
||||||
request.getWidth(),
|
request.getWidth(),
|
||||||
request.getHeight(),
|
height,
|
||||||
filePath);
|
filePath);
|
||||||
}else {
|
}else {
|
||||||
throw new RRException("模板渲染错误");
|
throw new RRException("模板渲染错误");
|
||||||
|
|
|
@ -6,6 +6,10 @@ dpkj:
|
||||||
printer:
|
printer:
|
||||||
# 打印机连接方式 USB: usb连接 | BTMS:串口连接
|
# 打印机连接方式 USB: usb连接 | BTMS:串口连接
|
||||||
connection-type: USB
|
connection-type: USB
|
||||||
|
# 终端号设置
|
||||||
|
terminal-Number: PORT-000000001
|
||||||
|
# 打印时间格式化
|
||||||
|
time-Type: yyyy-MM-dd HH:mm:ss
|
||||||
# 打印端口 串口连接下使用
|
# 打印端口 串口连接下使用
|
||||||
port-name:
|
port-name:
|
||||||
# 波特率 串口连接下使用
|
# 波特率 串口连接下使用
|
||||||
|
|
|
@ -6,11 +6,16 @@ dpkj:
|
||||||
printer:
|
printer:
|
||||||
# 打印机连接方式 USB: usb连接 | BTMS:串口连接
|
# 打印机连接方式 USB: usb连接 | BTMS:串口连接
|
||||||
connection-type: USB
|
connection-type: USB
|
||||||
|
# 终端号设置
|
||||||
|
terminal-Number: PORT-000000001
|
||||||
|
# 打印时间格式化
|
||||||
|
time-Type: yyyy-MM-dd HH:mm:ss
|
||||||
# 打印端口 串口连接下使用
|
# 打印端口 串口连接下使用
|
||||||
port-name:
|
port-name:
|
||||||
# 波特率 串口连接下使用
|
# 波特率 串口连接下使用
|
||||||
baud-rate:
|
baud-rate:
|
||||||
|
|
||||||
|
|
||||||
# 身份证读取等待时间
|
# 身份证读取等待时间
|
||||||
IDCardReader:
|
IDCardReader:
|
||||||
waitingTime: 30000
|
waitingTime: 30000
|
||||||
|
|
|
@ -7,50 +7,50 @@
|
||||||
<body>
|
<body>
|
||||||
<div style="font-weight: 700;">
|
<div style="font-weight: 700;">
|
||||||
<div style="text-align: center;margin-top: 40px;">
|
<div style="text-align: center;margin-top: 40px;">
|
||||||
<div><span style="font-size: 28px;">******<span th:text="${hospitalName}"></span>******</span></div>
|
<div><span style="font-size: 28px;">******<span th:text="${registeTerminalName}"></span>******</span></div>
|
||||||
<div style="font-size: 38px; margin-top: 20px;"><span th:text="${registeTerminalName}"></span></div>
|
<div style="font-size: 32px; margin-top: 20px;"><span th:text="${hospitalName}"></span></div>
|
||||||
<div style="font-size: 38px; margin-top: 10px;"><span th:text="${registeType}"></span></div>
|
<div style="font-size: 32px; margin-top: 10px;"><span th:text="${registeType}"></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center; font-weight: 700; font-size: 32px;">-----------------------------------------------------------------------------</div>
|
<div style="text-align: center; font-weight: 700; font-size: 32px;">-----------------------------------------------------------------------------</div>
|
||||||
<div style="margin-left: 20px; font-size: 35px; margin-bottom: 10px; display: flex">
|
<div style="margin-left: 20px; font-size: 28px; margin-bottom: 10px; display: flex">
|
||||||
<div style="flex: 1; margin-top: 10px; ">
|
<div style="flex: 1; margin-top: 10px; ">
|
||||||
姓名:<span style="margin-right: 40px;" th:text="${name}"></span>
|
姓名:<span style="margin-right: 25px;" th:text="${name}"></span><br>
|
||||||
性别:<span style="margin-right: 40px;" th:text="${gender}"></span>
|
性别:<span style="margin-right: 25px;" th:text="${gender}"></span>
|
||||||
年龄:<span style="margin-right: 40px;" th:text="${age}"></span>
|
年龄:<span style="margin-right: 25px;" th:text="${age}"></span>
|
||||||
</div>
|
</div>
|
||||||
<div th:if="${outpatientNumber}" style="flex: 1; margin-top: 10px; margin-right: 15px;">门诊号:<span th:text="${outpatientNumber}"></span></div>
|
<div th:if="${outpatientNumber}" style="flex: 1; margin-top: 10px; margin-right: 15px;">门诊号:<span th:text="${outpatientNumber}"></span></div>
|
||||||
<div th:if="${doctor}" style="flex: 1; margin-top: 10px; margin-right: 15px;">就诊医生:<span th:text="${doctor}"></span></div>
|
<div th:if="${doctor}" style="flex: 1; margin-top: 10px; margin-right: 15px;">就诊医生:<span th:text="${doctor}"></span></div>
|
||||||
<div th:if="${department}" style="flex: 1; margin-top: 10px;">就诊科室:<span th:text="${department}"></span></div>
|
<div th:if="${department}" style="flex: 1; margin-top: 10px;">就诊科室:<span th:text="${department}"></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center; font-weight: 700; font-size: 32px;">-----------------------------------------------------------------------------</div>
|
<div style="text-align: center; font-weight: 700; font-size: 28px;">-----------------------------------------------------------------------------</div>
|
||||||
<div style="margin-left: 20px; font-size: 35px; margin-bottom: 20px; ">
|
<div style="margin-left: 20px; font-size: 28px; margin-bottom: 20px; ">
|
||||||
<div style="margin-top: 20px; ">费用总额:<span style="margin-right: 30px;" th:text="${totalFee}"></span> 个人支付:<span th:text="${personalPayment}"></span></div>
|
<div style="margin-top: 20px; ">费用总额:<span style="margin-right: 30px;" th:text="${totalFee}"></span> 个人支付:<span th:text="${personalPayment}"></span></div>
|
||||||
<div style="margin-top: 10px;">实收金额:<span style="font-weight: 700;" th:text="${actualReceiptAmount}"></span></div>
|
<div style="margin-top: 10px;">实收金额:<span style="font-weight: 700;" th:text="${actualReceiptAmount}"></span></div>
|
||||||
<div style="margin-top: 10px;">实收金额:<span style="font-weight: 700;" th:text="${actualReceiptAmountChinese}"></span></div>
|
<div style="margin-top: 10px;">实收金额:<span style="font-weight: 700;" th:text="${actualReceiptAmountChinese}"></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center; font-weight: 700; font-size: 32px;">-----------------------------------------------------------------------------</div>
|
<div style="text-align: center; font-weight: 700; font-size: 24px;">-----------------------------------------------------------------------------</div>
|
||||||
<div style="margin-left: 20px; margin-top: 10px; ">
|
<div style="margin-left: 20px; margin-top: 10px; ">
|
||||||
<table border="0" style="font-size: 30px;">
|
<table border="0" >
|
||||||
<tr style="font-size: 34px; ">
|
<tr style="font-size: 28px; ">
|
||||||
<th >项目名称</th>
|
<th >项目名称</th>
|
||||||
<th >数量</th>
|
<th >数量</th>
|
||||||
<th >单价</th>
|
<th >单价</th>
|
||||||
<th >小计</th>
|
<th >小计</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:each="item : ${items}" style="height: 50px;">
|
<tr th:each="item : ${items}" style="height: 50px;">
|
||||||
<td style=" width: 310px; word-break: break-all;" th:text="${item.name}"></td>
|
<td style=" width: 310px; word-break: break-all; margin-right: 10px;" th:text="${item.name}"></td>
|
||||||
<td th:text="${item.quantity}"></td>
|
<td style="margin-left: 5px;" th:text="${item.quantity}"></td>
|
||||||
<td th:text="${item.unitPrice}"></td>
|
<td th:text="${item.unitPrice}"></td>
|
||||||
<td th:text="${item.subtotal}"></td>
|
<td th:text="${item.subtotal}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center; font-weight: 700; font-size: 32px;">-----------------------------------------------------------------------------</div>
|
<div style="text-align: center; font-weight: 700; font-size: 32px;">-----------------------------------------------------------------------------</div>
|
||||||
<div style="margin-left: 20px; font-weight: 700; font-size: 35px;">
|
<div style="margin-left: 20px; font-weight: 700; font-size: 32px;">
|
||||||
<div>终端编号:<span th:text="${terminalNumber}"></span></div>
|
<div>终端编号:<span th:text="${terminalNumber}"></span></div>
|
||||||
<div>打印时间:<span th:text="${printTime}"></span></div>
|
<div>打印时间:<span th:text="${printTime}"></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-left: 20px; font-size: 35px; font-weight: 700; margin-top: 20px;">
|
<div style="margin-left: 20px; font-size: 32px; font-weight: 700; margin-top: 20px;">
|
||||||
<span style="margin-top: 20px;">温馨提示</span><br>
|
<span style="margin-top: 20px;">温馨提示</span><br>
|
||||||
<span>1.请取走全部凭条、并妥善保管</span><br>
|
<span>1.请取走全部凭条、并妥善保管</span><br>
|
||||||
<span>2.如果对缴费结算存在疑问,请到人工窗口咨询</span>
|
<span>2.如果对缴费结算存在疑问,请到人工窗口咨询</span>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${registeType}"></span></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 style="text-align: center; font-weight: 700; margin-top: -15px;">-----------------------------------------------------------------------------</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-weight: 700; font-size: 37px;">
|
<div style="font-weight: 700; font-size: 32px;">
|
||||||
<div style="margin-left: 35px;">姓  名:<span th:text="${name}"></span></div>
|
<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="${gender}"></span></div>
|
||||||
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${registeType}"></span></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 style="text-align: center; font-weight: 700; margin-top: -15px;">-----------------------------------------------------------------------------</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-weight: 700; font-size: 37px;">
|
<div style="font-weight: 700; font-size: 32px;">
|
||||||
<div style="margin-left: 35px;">姓  名:<span th:text="${name}"></span></div>
|
<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="${gender}"></span></div>
|
||||||
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<div style="text-align: center; font-size: 40px; font-weight: 700;"><span th:text="${registeType}"></span></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 style="text-align: center; font-weight: 700; margin-top: -15px;">-----------------------------------------------------------------------------</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-weight: 700; font-size: 37px;">
|
<div style="font-weight: 700; font-size: 32px;">
|
||||||
<div style="margin-left: 35px;">姓  名:<span th:text="${name}"></span></div>
|
<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="${gender}"></span></div>
|
||||||
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
<div style="margin-left: 35px;">年  龄:<span th:text="${age}"></span></div>
|
||||||
|
|
Loading…
Reference in New Issue