Compare commits

...

5 Commits

Author SHA1 Message Date
91c7818dee 复制自助机模块的完善 2025-07-02 09:28:50 +08:00
11b684294d 小票模板优化 2025-06-20 14:21:26 +08:00
18f74eb342 小票模板优化 2025-06-20 10:29:36 +08:00
265644b473 Merge remote-tracking branch 'origin/1.0' into 1.0 2025-06-18 18:40:42 +08:00
81f0307bd9 小票模板优化 2025-06-18 18:40:37 +08:00
10 changed files with 135 additions and 66 deletions

View File

@@ -75,7 +75,7 @@ public class ReceiptPrintController {
int dinyHeight = 0;
if (templateName.equals("department")) {
// 由于是使用的门诊小票-T2那么默认的高度为1100强行设置通过动态修改渲染的图片的高度
height = 800;//根据实际情况800较为合适
height = 900;//根据实际情况调整
// 单行最大长度为10
int singleLineMaxLength = 10;

View File

@@ -1,19 +1,13 @@
package com.dpkj.modules.scanface.ali.controller;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.dpkj.common.vo.Result;
import com.dpkj.modules.scanface.ali.config.AliFaceConfig;
import com.dpkj.modules.scanface.ali.constants.AliFaceConstants;
import com.dpkj.modules.scanface.ali.dll.AbcpInvoke;
import com.dpkj.modules.scanface.ali.service.IAliScanFaceService;
import com.dpkj.modules.scanface.ali.vo.AliOrderVo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -22,8 +16,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.File;
import java.util.Map;
/**
* @Auther: 萧道子

View File

@@ -1,6 +1,5 @@
package com.dpkj.modules.scanface.ali.dll;
import com.dpkj.common.vo.Result;
import com.sun.jna.Callback;
import com.sun.jna.Native;
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +32,7 @@ public class AbcpInvoke {
msAbcpNativeDll = (AbcpNativeDll) Native.load(fileDylib, AbcpNativeDll.class);
} catch (Throwable e) {
msAbcpNativeDll = null;
log.error("## 本地库未加载,返回错误 ERROR :{},{} ", fileDylib, e.getMessage());
log.error("## 本地库未加载,返回错误 ERROR : load. ## [%s][%s] %n", fileDylib, e.getMessage());
}
} else {
log.error("## ERROR : dylib NOT exist ## %s %n", fileDylib);

View File

@@ -4,8 +4,8 @@ import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dpkj.common.vo.Result;
import com.dpkj.modules.scanface.ali.config.AliFaceConfig;
import com.dpkj.modules.scanface.ali.constants.AliFaceConstants;
@@ -16,8 +16,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.File;
import java.util.HashMap;
@@ -44,6 +44,20 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
private AliFaceConfig aliFaceConfig;
/**
* 资源初始化
* 把刷脸初始化加到项目启动时先初始化一次,防止首次调用刷脸初始化过慢的问题
*/
@PostConstruct
public void postConstruct() {
log.info("[AliScanFaceServiceImpl][postConstruct][支付宝刷脸DLL] 初始化动态链接库");
try {
this.iniAbcpAbsolute();
} catch (Exception e) {
log.info("[AliScanFaceServiceImpl][postConstruct][56][支付宝刷脸初始化失败:] {}", e.getMessage());
}
}
/**
* @description: * 完整的统一的支付宝刷脸支付
* 1、调用硬件刷脸获取到ftoken
@@ -57,40 +71,52 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
public Result<JSONObject> aliFacePay(AliOrderVo aliOrderVo) {
try {
/**
* 1、获取刷脸"刷脸去初始化服务"的ftoken返回值
* 0、执行ABCP初始化
*/
this.iniAbcpAbsolute();
//参数
JSONObject zolozConfig = new JSONObject().fluentPut("installAngle", 90);
JSONObject params = new JSONObject()
.fluentPut("serviceId", aliFaceConfig.getServiceId())
.fluentPut("zolozConfig", zolozConfig);
String json = params.toJSONString();
String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码:初始化
Result<Object> startServiceIniResult = this.startServiceIni(json, service_code);
if (startServiceIniResult.isSuccess()) {
Map<String, String> res = (Map<String, String>) startServiceIniResult.getResult();
String ftoken = res.get("ftoken");
Result<Object> result = this.iniAbcpAbsolute();
if (result.isSuccess()) {
/**
* 2、调用后端的支付宝统一收单交易支付接口、存入hisPay
* 1、获取刷脸"刷脸去初始化服务"的ftoken返回值
*/
aliOrderVo.setAuthCode(ftoken);//Demo值"fp128d26333fa66e66e7f34c493d30cdh76"
JSONObject serverParams = (JSONObject) JSON.toJSON(aliOrderVo);
//参数
JSONObject zolozConfig = new JSONObject().fluentPut("installAngle", 90);
JSONObject params = new JSONObject()
.fluentPut("serviceId", aliFaceConfig.getServiceId())
.fluentPut("zolozConfig", zolozConfig);
String json = params.toJSONString();
String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码:初始化
Result<Object> startServiceIniResult = this.startServiceIni(json, service_code);
log.info("[AliScanFaceServiceImpl][aliFacePay][72][1、获取刷脸去初始化服务的结果] {}", startServiceIniResult.toString());
if (startServiceIniResult.isSuccess()) {
Map<String, String> res = (Map<String, String>) startServiceIniResult.getResult();
String ftoken = res.get("ftoken");
log.info("[AliScanFaceServiceImpl][aliFacePay][76][[1、获取刷脸去初始化服务的结果-ftoken值] {}", ftoken);
String url = serverUrl + "openapi/aliPayOrderApi/createOrder";
String req = HttpRequest.post(url)
.header(Header.CONTENT_TYPE, ContentType.JSON.toString(CharsetUtil.CHARSET_UTF_8))
.body(serverParams.toJSONString())
.execute()
.body();
JSONObject serverResult = JSONObject.parseObject(req);
/**
* 2、调用后端的支付宝统一收单交易支付接口、存入hisPay
*/
aliOrderVo.setAuthCode(ftoken);//Demo值"fp128d26333fa66e66e7f34c493d30cdh76"
JSONObject serverParams = (JSONObject) JSON.toJSON(aliOrderVo);
log.info("[AliScanFaceServiceImpl][aliFacePay][83][调用后端的支付宝统一收单交易支付接口参数] {}", serverParams.toString());
return Result.ok(serverResult);
} else {
//调用ABCP 刷脸初始化服务失败
log.error("[AliScanFaceServiceImpl][aliFacePay][299]调用ABCP 刷脸初始化服务失败 {}", startServiceIniResult.getMessage());
return Result.error(startServiceIniResult.getMessage());
String url = serverUrl + "openapi/aliPayOrderApi/createOrder";
log.info("[AliScanFaceServiceImpl][aliFacePay][86][调用后端的支付宝统一收单交易支付接口路径] {}", url);
String req = HttpRequest.post(url)
.header(Header.CONTENT_TYPE, ContentType.JSON.toString(CharsetUtil.CHARSET_UTF_8))
.body(serverParams.toJSONString())
.execute()
.body();
JSONObject serverResult = JSONObject.parseObject(req);
log.info("[AliScanFaceServiceImpl][aliFacePay][93][调用后端的支付宝统一收单交易支付接口结果] {}", serverResult.toString());
return Result.ok(serverResult);
} else {
//调用ABCP 刷脸初始化服务失败
log.error("[AliScanFaceServiceImpl][aliFacePay][299]调用ABCP 刷脸初始化服务失败 {}", startServiceIniResult.getMessage());
return Result.error(startServiceIniResult.getMessage());
}
}else {
return Result.error("执行iniAbcpAbsolute初始化失败");
}
} catch (Exception e) {
e.printStackTrace();
@@ -126,23 +152,59 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
//指定支付宝LOT SDK的本地库路径
AbcpInvoke.SetAPIPathFile(aliFaceConfig.getDllPath());
// 使用 CountDownLatch 实现线程同步
CountDownLatch latch = new CountDownLatch(1);
CountDownLatch latchFinish = new CountDownLatch(1);
//获取返回数据
AtomicReference<Integer> processCode = new AtomicReference<>();
AtomicReference<String> processResult = new AtomicReference<>();
AtomicReference<Integer> finishCode = new AtomicReference<>();
AtomicReference<String> finishResult = new AtomicReference<>();
//创建回调实例
AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() {
@Override
public void OnProcess(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][OnProcess][123][ABCP调用iniAbcpAbsolute][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
log.info("[AliScanFaceServiceImpl][OnProcess][155][0、ABCP调用iniAbcpAbsolute-OnProcess][code:{}][subCode:{}][subMsg:{}][result:{}] ", code, subCode, subMsg, result);
try {
processCode.set(code);
processResult.set(result);
} finally {
latch.countDown(); // 确保无论如何都释放锁
}
}
@Override
public void OnFinish(int code, String subCode, String subMsg, String result) {
log.info("[AliScanFaceServiceImpl][OnFinish][128][ABCP调用iniAbcpAbsolute][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
log.info("[AliScanFaceServiceImpl][OnFinish][167][0、ABCP调用iniAbcpAbsolute-OnFinish][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result);
try {
finishCode.set(code);
finishResult.set(result);
} finally {
latchFinish.countDown(); // 确保无论如何都释放锁
}
}
};
//初始化
log.info("[AliScanFaceServiceImpl][iniAbcpAbsolute][175][0、ABCP调用iniAbcpAbsolute初始化参数][appId:{}][appVersion:{}][json:{}] ", aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json);
AbcpInvoke.AbcpInit(aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, callbackRsp);
return Result.ok("支付宝ABCP初始化成功");
// 等待finish回调完成设置超时避免死锁
boolean awaitFinishSuccess = latchFinish.await(120, TimeUnit.SECONDS);
if (!awaitFinishSuccess) {
log.info("[AliScanFaceServiceImpl][iniAbcpAbsolute][181] [0、ABCP调用iniAbcpAbsolute初始化-120秒-等待finish回调超时]");
return Result.error("初始化等待finish回调超时");
} else {
JSONObject jsonObject = JSONObject.parseObject(finishResult.get());
log.info("[AliScanFaceServiceImpl][iniAbcpAbsolute][184][0、ABCP调用iniAbcpAbsolute初始化-finish回调结果-finishCode {}] [返回结果:{}]", finishCode, jsonObject.toString());
if (finishCode.get() == 1000) {
return Result.ok("ABCP调用iniAbcpAbsolute初始化成功");
} else {
return Result.error("ABCP调用刷脸初始化服务finish失败");
}
}
} else {
log.info("[AliScanFaceServiceImpl][iniAbcpAbsolute][55][{} :文件不存在]", aliFaceConfig.getDllPath());
return Result.error("支付宝ABCP初始化失败" + aliFaceConfig.getDllPath() + "不存在");
@@ -217,10 +279,13 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
// 等待process回调完成设置超时避免死锁
boolean awaitSuccess = latch.await(10, TimeUnit.SECONDS);
if (!awaitSuccess) {
log.info("[AliScanFaceServiceImpl][startServiceIni][226][10秒-等待process回调超时]");
return Result.error("等待process回调超时");
} else {
log.info("[AliScanFaceServiceImpl][startServiceIni][229][ABCP调用刷脸初始化服务-process回调结果-processCode] {}", processCode);
if (processCode.get() == 0) {
JSONObject jsonObject = JSONObject.parseObject(processResult.get());
log.info("[AliScanFaceServiceImpl][startServiceIni][232][ABCP调用刷脸初始化服务-process回调结果] {}", jsonObject.toString());
if (jsonObject.containsKey("traceId")) {
res.put("traceId", jsonObject.getString("traceId"));
} else {
@@ -234,10 +299,13 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
// 等待finish回调完成设置超时避免死锁
boolean awaitFinishSuccess = latchFinish.await(120, TimeUnit.SECONDS);
if (!awaitFinishSuccess) {
log.info("[AliScanFaceServiceImpl][startServiceIni][246][120秒-等待finish回调超时]");
return Result.error("等待finish回调超时");
} else {
log.info("[AliScanFaceServiceImpl][startServiceIni][249][ABCP调用刷脸初始化服务-finish回调结果-finishCode] {}", finishCode);
if (finishCode.get() == 1000) {
JSONObject jsonObject = JSONObject.parseObject(finishResult.get());
log.info("[AliScanFaceServiceImpl][startServiceIni][252][ABCP调用刷脸初始化服务-finish回调结果] {}", jsonObject.toString());
if (jsonObject.containsKey("ftoken")) {
res.put("ftoken", jsonObject.getString("ftoken"));//ftoken参数的有效期为2分钟
res.put("barCode", jsonObject.getString("barCode"));
@@ -251,6 +319,7 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
}
//结果返回
log.info("[AliScanFaceServiceImpl][startServiceIni][266][][ABCP调用刷脸初始化服务成功返回结果] {}", finishResultRef.get());
return finishResultRef.get();
} catch (Exception e) {
e.printStackTrace();

View File

@@ -37,7 +37,7 @@ public class AliOrderVo implements Serializable {
private String outTradeNo;
/**
* 用户支付金额
* 用户支付金额 单位元
*/
//@ApiModelProperty(value = "用户支付金额")
private String totalAmount;

View File

@@ -1,6 +1,6 @@
dpkj:
#后端项目访问地址 #https://yinyitong.yzqingyan.cn/ http://172.16.11.13:15946/ ttps://yinyitong.yzqingyan.cn
serverurl: http://localhost:5946/api/
serverurl: http://www.lczyyy.com/api/
# 医保配置
chs:
# 医保机构编码

View File

@@ -18,35 +18,44 @@
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
</div>
<div style="font-size: 29px;word-break: break-all;margin: 10px 20px;">
<div style="display: flex;">
<div style="margin-top: 10px;word-break: break-all;" th:if="${outpatientNumber}">门诊号:<span
th:text="${outpatientNumber}"></span>
</div>
<div style="margin-top: 10px;word-break: break-all;">
<span style="margin-right: 25px;">姓名:<span th:text="${name}"></span></span>
<span style="margin-right: 25px;">性别:<span th:text="${gender}"></span></span>
<span>年龄:<span th:text="${age}"></span></span>
</div>
<div style="word-break: break-all;margin-top: 10px;">
<span style="margin-right: 25px;" th:if="${outpatientNumber}">
门诊号:<span th:text="${outpatientNumber}"></span></span>
<span th:if="${doctor}">
就诊医生:<span th:text="${doctor}"></span>
</span>
<div style="margin-top: 10px;word-break: break-all;" th:if="${doctor}">
就诊医生:<span th:text="${doctor}"></span>
</div>
<div style="margin-top: 10px;" th:if="${department}">就诊科室:<span th:text="${department}"></span>
<div style="margin-top: 10px;word-break: break-all;" th:if="${department}">就诊科室:<span
th:text="${department}"></span>
</div>
</div>
<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>
<div style="text-align: center; font-size: 32px;font-weight: bold;"><span>费用信息</span></div>
<div style="margin-top: 10px;">
<div style="float: left;width: 190px;">金额合计:</div>
<div style="margin-left: 190px;word-break: break-all;">
<span><span th:text="${totalFee}"></span>(小写金额)</span><br/>
<span><span th:text="${actualReceiptAmountChinese}"></span>(大写金额)</span>
</div>
</div>
<div style="margin-top: 10px;word-break: break-all;"><span>实收金额:</span><span
th:text="${actualReceiptAmount}"></span></div>
<div style="margin-top: 10px;"><span>实收金额:</span><span th:text="${actualReceiptAmountChinese}"></span></div>
<div th:if="${chs==1}">
<div style="margin-top: 10px;word-break: break-all;">医保统筹支付:<span th:text="${ybtcjj}"></span></div>
<div style="margin-top: 10px;word-break: break-all;">个人医保支付:<span th:text="${ybgrzh}"></span></div>
<div style="margin-top: 10px;word-break: break-all;">医院账户支付:<span th:text="${yyzh}"></span></div>
<div style="margin-top: 10px;word-break: break-all;">医院优惠金额:<span th:text="${yyyh}"></span></div>
</div>
<div style="margin-top: 10px;word-break: break-all;">个人自费:<span th:text="${personalPayment}"></span></div>
</div>
<div style="border-bottom: 1px dashed #000;margin: 3px 0;"></div>
<div style="margin: 10px 20px">
<div style="text-align: center; font-size: 32px;font-weight: bold;"><span>费用明细</span></div>
<table style="width: 100%; table-layout: fixed; border-collapse: collapse;">
<tr style="font-size: 29px;">
<tr style="font-size: 26px;">
<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>
@@ -63,7 +72,7 @@
<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;">
<div style="margin-left: 20px;font-size: 27px;">
<span>温馨提示:请取走缴费凭证,并妥善保管。<br/>如果对缴费存在疑问,请到人工窗口咨询!</span>
</div>
</div>

View File

@@ -31,7 +31,7 @@
<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;">
<div style="margin-left: 20px;font-size: 27px;">
<span>温馨提示:请取走缴费凭证,并妥善保管。<br/>如果对缴费存在疑问,请到人工窗口咨询!</span>
</div>
</div>

View File

@@ -29,7 +29,7 @@
<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;">
<div style="margin-left: 20px;font-size: 27px;">
<span>温馨提示:请取走缴费凭证,并妥善保管。<br/>如果对缴费存在疑问,请到人工窗口咨询!</span>
</div>
</div>

View File

@@ -39,7 +39,7 @@
<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;">
<div style="margin-left: 20px;font-size: 27px;">
<span>温馨提示:请取走挂号凭证,并妥善保管。<br/>如果对缴费存在疑问,请到人工窗口咨询!</span>
</div>
</div>