This commit is contained in:
parent
eb983fef76
commit
651b92e296
|
@ -67,7 +67,7 @@ public class ReceiptPrintController {
|
||||||
|
|
||||||
// 强行设置打印时间
|
// 强行设置打印时间
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(printerConfig.getTimeType());
|
SimpleDateFormat sdf = new SimpleDateFormat(printerConfig.getTimeType());
|
||||||
String formattedDate = sdf.format( new Date());
|
String formattedDate = sdf.format(new Date());
|
||||||
data.put("printTime", formattedDate);
|
data.put("printTime", formattedDate);
|
||||||
|
|
||||||
Integer height = request.getHeight();
|
Integer height = request.getHeight();
|
||||||
|
@ -87,25 +87,25 @@ public class ReceiptPrintController {
|
||||||
JSONObject itemEntity = (JSONObject) item;
|
JSONObject itemEntity = (JSONObject) item;
|
||||||
String projectName = String.valueOf(itemEntity.get("name"));
|
String projectName = String.valueOf(itemEntity.get("name"));
|
||||||
int length = projectName.length();
|
int length = projectName.length();
|
||||||
int count = (int)Math.ceil((double) length / singleLineMaxLength);
|
int count = (int) Math.ceil((double) length / singleLineMaxLength);
|
||||||
dinyHeight += count * singleLineHeight;
|
dinyHeight += count * singleLineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算是否有门诊号
|
// 计算是否有门诊号
|
||||||
String outpatientNumber = data.getString("outpatientNumber");
|
String outpatientNumber = data.getString("outpatientNumber");
|
||||||
if ( !StringUtils.isEmpty(outpatientNumber)){
|
if (!StringUtils.isEmpty(outpatientNumber)) {
|
||||||
dinyHeight += 28;
|
dinyHeight += 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算是否有就诊医生
|
// 计算是否有就诊医生
|
||||||
String doctor = data.getString("doctor");
|
String doctor = data.getString("doctor");
|
||||||
if ( !StringUtils.isEmpty(doctor)){
|
if (!StringUtils.isEmpty(doctor)) {
|
||||||
dinyHeight += 28;
|
dinyHeight += 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算是否有就诊科室
|
// 计算是否有就诊科室
|
||||||
String department = data.getString("department");
|
String department = data.getString("department");
|
||||||
if ( !StringUtils.isEmpty(department)){
|
if (!StringUtils.isEmpty(department)) {
|
||||||
dinyHeight += 28;
|
dinyHeight += 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ public class ReceiptPrintController {
|
||||||
// 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(
|
||||||
data,
|
data,
|
||||||
templateName,
|
templateName,
|
||||||
request.getWidth(),
|
request.getWidth(),
|
||||||
height,
|
height,
|
||||||
filePath);
|
filePath);
|
||||||
}else {
|
} else {
|
||||||
throw new RRException("模板渲染错误");
|
throw new RRException("模板渲染错误");
|
||||||
}
|
}
|
||||||
usbImagePrintService.imagePrintFromPath(devName,
|
usbImagePrintService.imagePrintFromPath(devName,
|
||||||
|
@ -136,7 +136,7 @@ public class ReceiptPrintController {
|
||||||
// 删除图片
|
// 删除图片
|
||||||
File file = new File(filePath.toString());
|
File file = new File(filePath.toString());
|
||||||
// 检查文件是否存在
|
// 检查文件是否存在
|
||||||
if (file.exists() ) {
|
if (file.exists()) {
|
||||||
// 尝试删除文件
|
// 尝试删除文件
|
||||||
if (file.delete()) {
|
if (file.delete()) {
|
||||||
log.info("文件删除成功: " + filePath);
|
log.info("文件删除成功: " + filePath);
|
||||||
|
@ -151,7 +151,7 @@ public class ReceiptPrintController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getStatus")
|
@PostMapping("/getStatus")
|
||||||
public Result<PrinterStatus> print(){
|
public Result<PrinterStatus> print() {
|
||||||
String devName = "VID:0x0FE6,PID:0x811E"; // 采用默认的devName,不进行入参传值了
|
String devName = "VID:0x0FE6,PID:0x811E"; // 采用默认的devName,不进行入参传值了
|
||||||
return Result.ok(this.usbImagePrintService.getStatus(devName));
|
return Result.ok(this.usbImagePrintService.getStatus(devName));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue