From d46490fc6b8cd181ba0ad0ab75c4744e9785b00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=AA?= <1044122544@qq.com> Date: Tue, 29 Apr 2025 09:56:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E5=88=B7=E8=84=B8?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E3=80=81=E8=B0=83=E7=94=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ali/controller/AliScanFaceController.java | 28 +-- .../modules/scanface/ali/dll/AbcpInvoke.java | 5 +- .../ali/service/IAliScanFaceService.java | 10 +- .../service/impl/AliScanFaceServiceImpl.java | 182 ++++++------------ .../scanface/ali/vo/MyCallbackRsp.java | 1 - .../controller/WxpayFaceTestController.java | 2 - .../scanface/wx/dll/WxpayFaceSDKDll.java | 64 +----- .../scanface/wx/dll/WxpayFaceSDKDll_old.java | 71 ------- src/main/resources/application-dev.yml | 8 +- src/main/resources/application-pro.yml | 4 +- 10 files changed, 91 insertions(+), 284 deletions(-) delete mode 100644 src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll_old.java diff --git a/src/main/java/com/dpkj/modules/scanface/ali/controller/AliScanFaceController.java b/src/main/java/com/dpkj/modules/scanface/ali/controller/AliScanFaceController.java index b64fd6a..9ab79df 100644 --- a/src/main/java/com/dpkj/modules/scanface/ali/controller/AliScanFaceController.java +++ b/src/main/java/com/dpkj/modules/scanface/ali/controller/AliScanFaceController.java @@ -48,7 +48,7 @@ public class AliScanFaceController { } /** - * ABCP服务调用 刷脸去初始化服务 + * ABCP服务调用 刷脸去初始化服务,获取ftoken * 文档地址:https://opendocs.alipay.com/iot/05e9ye * 初始化成功后,商家App 可根据业务需求,调用接口 abcp_start_service 执行 ABCP 所提供的服务。 * 上述服务调用过程可重复多次调用,通过传入不同的 service_code 来调用不同的 ABCP 服务。 @@ -59,30 +59,17 @@ public class AliScanFaceController { Result abcpStartServiceIni() { aliScanFaceService.iniAbcpAbsolute(); - //参数 - JSONObject params = new JSONObject().fluentPut("serviceId", aliFaceConfig.getServiceId()); //服务场景 + 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; //调用的组件编码:初始化 return aliScanFaceService.startServiceIni(json, service_code); } - /** - * ABCP服务调用 刷脸支付服务 - * 文档地址:https://opendocs.alipay.com/iot/05e9ye - * @return - */ - @GetMapping("startServiceFaceSmilePay") - Result startServiceFaceSmilePay() { - //参数 - JSONObject params = new JSONObject(); // - String json = params.toJSONString(); - - String service_code = AliFaceConstants.SMILEPAY; //调用的组件编码:刷脸支付 - return aliScanFaceService.startServiceFaceSmilePay(json, service_code); - } - /** * ABCP服务停用 @@ -91,10 +78,11 @@ public class AliScanFaceController { */ @PostMapping("stopService") Result stopService(@RequestParam String traceId) { + aliScanFaceService.iniAbcpAbsolute(); //参数 JSONObject params = new JSONObject() - .fluentPut("traceId",traceId) - .fluentPut("service_code",AliFaceConstants.SMILEVERIFYNIN_V1); // + .fluentPut("traceId",traceId); + //.fluentPut("service_code",AliFaceConstants.SMILEVERIFYNIN_V1); // String json = params.toJSONString(); String service_code = AliFaceConstants.SMILEVERIFYNIN_V1; //调用的组件编码 diff --git a/src/main/java/com/dpkj/modules/scanface/ali/dll/AbcpInvoke.java b/src/main/java/com/dpkj/modules/scanface/ali/dll/AbcpInvoke.java index 7b997b8..e66ddd3 100644 --- a/src/main/java/com/dpkj/modules/scanface/ali/dll/AbcpInvoke.java +++ b/src/main/java/com/dpkj/modules/scanface/ali/dll/AbcpInvoke.java @@ -107,7 +107,7 @@ public class AbcpInvoke { } try { - log.info("调用 abcp_start_service: seedId={}, appId={}, serviceCode={}, jsonLength={}",seedId, appId, serviceCode, json.length()); + log.info("调用 abcp_start_service: seedId={}, appId={}, serviceCode={}, jsonLength={}", seedId, appId, serviceCode, json.length()); msAbcpNativeDll.abcp_start_service(seedId, appId, serviceCode, json, msABCPProcess, msABCPFinish); } catch (Throwable e) { log.error("##本地方法调用异常 ERROR ## %s %n", e.getMessage()); @@ -129,6 +129,7 @@ public class AbcpInvoke { msLock.unlock(); try { + log.info("[调用abcp_stop_service]:seedId={}, appId={}, serviceCode={}, json={}", seedId, appId, serviceCode, json); msAbcpNativeDll.abcp_stop_service(seedId, appId, serviceCode, json, msABCPProcess, msABCPFinish); } catch (Throwable e) { callback.OnFinish(3, "E69001", e.getMessage(), ""); @@ -251,7 +252,7 @@ public class AbcpInvoke { public static class ABCPFinish implements FuncFinish { public void onFinish(int seed_id, int _code, String subCode, String subMsg, String result) { - log.info("[ABCPFinish][onFinish][261][ABCPFinish数据:][seed_id:{}],[_code:{}],[subMsg:{}],[result:{}]", seed_id, _code, subCode, subMsg, result); + //log.info("[ABCPFinish][onFinish][261][ABCPFinish数据:][seed_id:{}],[_code:{}],[subMsg:{}],[result:{}]", seed_id, _code, subCode, subMsg, result); Integer seedId = Integer.valueOf(seed_id); CallbackRsp callback = null; diff --git a/src/main/java/com/dpkj/modules/scanface/ali/service/IAliScanFaceService.java b/src/main/java/com/dpkj/modules/scanface/ali/service/IAliScanFaceService.java index a2faa22..e68d280 100644 --- a/src/main/java/com/dpkj/modules/scanface/ali/service/IAliScanFaceService.java +++ b/src/main/java/com/dpkj/modules/scanface/ali/service/IAliScanFaceService.java @@ -18,7 +18,7 @@ public interface IAliScanFaceService { /** - * ABCP服务调用 刷脸去初始化服务 + * ABCP服务调用 刷脸去初始化服务,获取ftoken * 接受调用者传入的参数信息,执行指定服务(service_code),然后通过回调返回服务结果。 * https://opendocs.alipay.com/iot/05e9ye#ABCP%E6%9C%8D%E5%8A%A1%E8%B0%83%E7%94%A8 * @param json 组装参数 @@ -27,14 +27,6 @@ public interface IAliScanFaceService { */ Result startServiceIni(String json,String service_code); - /** - * ABCP服务调用 :刷脸支付服务 - * @param json - * @param service_code - * @return - */ - Result startServiceFaceSmilePay(String json,String service_code); - /** * ABCP服务停用 diff --git a/src/main/java/com/dpkj/modules/scanface/ali/service/impl/AliScanFaceServiceImpl.java b/src/main/java/com/dpkj/modules/scanface/ali/service/impl/AliScanFaceServiceImpl.java index 5e3fcba..e002dec 100644 --- a/src/main/java/com/dpkj/modules/scanface/ali/service/impl/AliScanFaceServiceImpl.java +++ b/src/main/java/com/dpkj/modules/scanface/ali/service/impl/AliScanFaceServiceImpl.java @@ -57,10 +57,20 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService { AbcpInvoke.SetAPIPathFile(aliFaceConfig.getDllPath()); //创建回调实例 - MyCallbackRsp callback = new MyCallbackRsp(); + 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); + } + + @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); + } + }; //初始化 - AbcpInvoke.AbcpInit(aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, callback); + AbcpInvoke.AbcpInit(aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, callbackRsp); return Result.ok("支付宝ABCP初始化成功"); } else { @@ -74,42 +84,7 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService { } /** - * 使用相对路径调用ABCP_SDK部署出来的AbcpInvoke类 - * - * @return - * @Override public Result iniAbcp() { - * try { - * log.info("[AliScanFaceServiceImpl][iniAbcpAli][26][ABCP初始化参数][appId:{}],[merchantId:{}],[deviceNum:{}],[partnerId:{}]", - * aliFaceConfig.getAppId(), aliFaceConfig.getMerchantId(), aliFaceConfig.getDeviceNum(), aliFaceConfig.getPartnerId()); - *

- * AliScanFaceDll.Dll dll = AliScanFaceDll.instance(); - * dll.bp_api_set_isv_lan(3);// 0:cpp | 1:cshap | 2:jni | 3:jna - *

- * JSONObject params = new JSONObject() - * .fluentPut("appId", aliFaceConfig.getAppId()) //应用ID - * .fluentPut("merchantId", aliFaceConfig.getMerchantId()) //签约商家的 PID,以 2088 开头 - * .fluentPut("deviceNum", aliFaceConfig.getDeviceNum())//商家机具终端编号,每台设备保持唯一 - * .fluentPut("partnerId", aliFaceConfig.getPartnerId());//服务商的 PID - * String json = params.toJSONString(); - *

- *

- * AbcpInvoke.ABCPProcess msABCPProcess = new AbcpInvoke.ABCPProcess(); - * AbcpInvoke.ABCPFinish msABCPFinish = new AbcpInvoke.ABCPFinish(); - * Integer seedId = AbcpInvoke.getMsSeedId(); - * dll.abcp_init(seedId, aliFaceConfig.getAppId(), aliFaceConfig.getAppVersion(), json, msABCPProcess, msABCPFinish); - *

- * log.info("[AliScanFaceServiceImpl][iniAbcp][49][ABCP初始化process] :{}", msABCPProcess.toString()); - * log.info("[AliScanFaceServiceImpl][iniAbcp][49][ABCP初始化结果] :{}", msABCPFinish.toString()); - * return Result.ok("成功"); - * } catch (Exception e) { - * e.printStackTrace(); - * return Result.error("失败"); - * } - * } - */ - - /** - * ABCP服务调用 刷脸初始化服务 + * ABCP服务调用 刷脸初始化服务,获取ftoken * 接受调用者传入的参数信息,执行指定服务(service_code),然后通过回调返回服务结果。 * https://opendocs.alipay.com/iot/05e9ye#ABCP%E6%9C%8D%E5%8A%A1%E8%B0%83%E7%94%A8 * @param json 组装参数 @@ -123,18 +98,26 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService { // 使用 CountDownLatch 实现线程同步 CountDownLatch latch = new CountDownLatch(1); - AtomicReference> resultRef = new AtomicReference<>(); + CountDownLatch latchFinish = new CountDownLatch(1); + AtomicReference> finishResultRef = new AtomicReference<>(); //获取返回数据 - AtomicReference returnCode = new AtomicReference<>(); - AtomicReference returnResult = new AtomicReference<>(); + AtomicReference processCode = new AtomicReference<>(); + AtomicReference processResult = new AtomicReference<>(); + AtomicReference finishCode = new AtomicReference<>(); + AtomicReference finishResult = new AtomicReference<>(); + + + //接收结果 + Map res = new HashMap<>(); + AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() { @Override public void OnProcess(int code, String subCode, String subMsg, String result) { - log.info("[AliScanFaceServiceImpl][OnProcess][123][ABCP调用刷脸初始化服务][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result); + log.info("[AliScanFaceServiceImpl][OnProcess][123][service_code:{}][code:{}][subCode:{}][subMsg:{}][result:{}]",service_code, code, subCode, subMsg, result); try { - returnCode.set(code); - returnResult.set(result); + processCode.set(code); + processResult.set(result); } finally { latch.countDown(); // 确保无论如何都释放锁 } @@ -142,7 +125,17 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService { @Override public void OnFinish(int code, String subCode, String subMsg, String result) { - log.info("[AliScanFaceServiceImpl][OnFinish][128][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result); + log.info("[AliScanFaceServiceImpl][OnFinish][128][service_code:{}][code:{}][subCode:{}][subMsg:{}][result:{}]",service_code, code, subCode, subMsg, result); + + /**Demo示例记录 + * [service_code:BPaaSSmileVerifyNonInitV1][code:1000][subCode:E00000][subMsg:SUCCESS][result:{"code":1000,"subCode":"OK_SUCCESS","subMessage":"SUCCESS","barCode":"281215320962898068","ftoken":"fp1efd3d4c0230a28f5261efe7c5050eh28","alipayUid":"2088812449506047","accountList":"[\"104***@qq.com\"]","authToken":"44686f7195c77ee2e09c09bcdc657dd5h28i","result":{"accountList":["104***@qq.com"],"alipayUid":"2088812449506047","allowRetry":false,"authToken":"44686f7195c77ee2e09c09bcdc657dd5h28i","barCode":"281215320962898068","certName":"您好,*雪","ftoken":"fp1efd3d4c0230a28f5261efe7c5050eh28","type":"selectUid"},"easterEgg":false,"zolozConfig":{"installAngle":90},"serviceId":"pay","traceId":"2444-44-1745802328","callStartTimeMs":1745802328114,"localTime":"2025-04-28-09-05-41-791"}] + */ + try { + finishCode.set(code); + finishResult.set(result); + } finally { + latchFinish.countDown(); // 确保无论如何都释放锁 + } } }; @@ -150,97 +143,50 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService { log.info("[AliScanFaceServiceImpl][startService][141][ABCP调用刷脸初始化服务-调用AbcpStartService参数][appId:{}][service_code:{}][json:{}] ", appId, service_code, json.toString()); AbcpInvoke.AbcpStartService(appId, service_code, json, callbackRsp); - // 等待回调完成(设置超时避免死锁) + // 等待process回调完成(设置超时避免死锁) boolean awaitSuccess = latch.await(10, TimeUnit.SECONDS); if (!awaitSuccess) { - return Result.error("等待回调超时"); + return Result.error("等待process回调超时"); } else { - if (returnCode.get() == 0) { - Map res = new HashMap<>(); - JSONObject jsonObject = JSONObject.parseObject(returnResult.get()); + if (processCode.get() == 0) { + JSONObject jsonObject = JSONObject.parseObject(processResult.get()); if (jsonObject.containsKey("traceId")) { res.put("traceId", jsonObject.getString("traceId")); - resultRef.set(Result.ok("ABCP调用刷脸初始化服务成功", res)); } else { - return Result.ok("ABCP调用刷脸初始化服务失败,返回结果无traceId"); + return Result.error("ABCP调用刷脸初始化服务process失败,返回结果无traceId"); } } else { - return Result.error("ABCP调用刷脸初始化服务失败"); + return Result.error("ABCP调用刷脸初始化服务process失败"); + } + } + + // 等待finish回调完成(设置超时避免死锁) + boolean awaitFinishSuccess = latchFinish.await(120, TimeUnit.SECONDS); + if (!awaitFinishSuccess) { + return Result.error("等待finish回调超时"); + } else { + if (finishCode.get() == 1000) { + JSONObject jsonObject = JSONObject.parseObject(finishResult.get()); + if (jsonObject.containsKey("ftoken")) { + res.put("ftoken", jsonObject.getString("ftoken")); + res.put("barCode", jsonObject.getString("barCode")); + finishResultRef.set(Result.ok("ABCP调用刷脸初始化finish服务成功", res)); + } else { + return Result.ok("ABCP调用刷脸初始化服务finish失败,返回结果无ftoken"); + } + } else { + return Result.error("ABCP调用刷脸初始化服务finish失败"); } } //结果返回 - return resultRef.get(); + return finishResultRef.get(); } catch (Exception e) { e.printStackTrace(); return Result.error("ABCP调用刷脸初始化服务失败:" + e.getMessage()); } } - /** - * ABCP服务调用 :刷脸支付服务 - * - * @param json - * @param service_code - * @return - */ - public Result startServiceFaceSmilePay(String json, String service_code) { - try { - String appId = aliFaceConfig.getAppId(); - - CountDownLatch latch = new CountDownLatch(1); - AtomicReference> finalResultRef = new AtomicReference<>(); - - AbcpInvoke.CallbackRsp callbackRsp = new AbcpInvoke.CallbackRsp() { - @Override - public void OnProcess(int code, String subCode, String subMsg, String result) { - log.info("[AliScanFaceServiceImpl][startServiceFaceSmilePay][OnProcess][188][ABCP调用刷脸支付服务-OnProcess][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result); - if (code != 0) { - finalResultRef.set(Result.error("流程中断: " + subMsg)); - latch.countDown(); // 失败时立即释放锁 - } - } - - @Override - public void OnFinish(int code, String subCode, String subMsg, String result) { - log.info("[AliScanFaceServiceImpl][startServiceFaceSmilePay][OnFinish][128][ABCP调用刷脸支付服务-OnFinish][code:{}][subCode:{}][subMsg:{}][result:{}]", code, subCode, subMsg, result); - try { - if (code == 0 && StringUtil.isNotBlank(result)) { - JSONObject resultJson = JSONObject.parseObject(result); - if (resultJson.containsKey("ftoken")) { - String ftoken = resultJson.getString("ftoken"); - finalResultRef.set(Result.ok("ABCP刷脸支付服务成功", ftoken)); - } else { - finalResultRef.set(Result.error("ABCP刷脸支付服务结果中ftoken不存在")); - } - } else { - finalResultRef.set(Result.error("ABCP刷脸支付服务失败: " + subMsg)); - } - } catch (Exception e) { - finalResultRef.set(Result.error("ABCP刷脸支付服务结果解析异常: " + e.getMessage())); - } finally { - latch.countDown(); - } - } - }; - - //调用 - log.info("[AliScanFaceServiceImpl][startServiceFaceSmilePay][141][ABCP调用刷脸初始化服务-调用AbcpStartService参数][appId:{}][service_code:{}][json:{}] ", appId, service_code, json.toString()); - AbcpInvoke.AbcpStartService(appId, service_code, json, callbackRsp); - - // 等待回调完成(60秒超时) - boolean awaitSuccess = latch.await(60, TimeUnit.SECONDS); - if (!awaitSuccess) { - return Result.error("等待结果超时"); - } - - return finalResultRef.get(); - - } catch (Exception e) { - e.printStackTrace(); - return Result.error("ABCP调用刷脸支付服务失败:" + e.getMessage()); - } - } /** diff --git a/src/main/java/com/dpkj/modules/scanface/ali/vo/MyCallbackRsp.java b/src/main/java/com/dpkj/modules/scanface/ali/vo/MyCallbackRsp.java index 113059e..8ded108 100644 --- a/src/main/java/com/dpkj/modules/scanface/ali/vo/MyCallbackRsp.java +++ b/src/main/java/com/dpkj/modules/scanface/ali/vo/MyCallbackRsp.java @@ -22,7 +22,6 @@ public class MyCallbackRsp implements AbcpInvoke.CallbackRsp { public void OnFinish(int code, String subCode, String subMsg, String result) { // 处理初始化完成结果 if (code == 0) { - log.info("[MyCallbackRsp][OnFinish][24] :{}", "初始化成功!"); log.info("[MyCallbackRsp][OnFinish][27][返回结果:] :{}", result); } else { log.info("[MyCallbackRsp][OnFinish][29] :初始化失败!错误码: %s, 错误信息: %s%n", subCode, subMsg); diff --git a/src/main/java/com/dpkj/modules/scanface/wx/controller/WxpayFaceTestController.java b/src/main/java/com/dpkj/modules/scanface/wx/controller/WxpayFaceTestController.java index 753acd3..2145d08 100644 --- a/src/main/java/com/dpkj/modules/scanface/wx/controller/WxpayFaceTestController.java +++ b/src/main/java/com/dpkj/modules/scanface/wx/controller/WxpayFaceTestController.java @@ -19,8 +19,6 @@ import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.security.Provider; import java.security.Security; -import java.time.LocalDate; -import java.time.temporal.ChronoUnit; import java.util.Map; import java.util.TreeSet; diff --git a/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll.java b/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll.java index ea10d2f..7860de0 100644 --- a/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll.java +++ b/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll.java @@ -4,12 +4,6 @@ import com.sun.jna.Library; import com.sun.jna.Native; import lombok.extern.slf4j.Slf4j; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; - /** * @description: * @author: Zhangxue @@ -17,57 +11,19 @@ import java.nio.file.StandardCopyOption; */ @Slf4j public class WxpayFaceSDKDll { - private static final String DLL_NAME = "WxpayFaceSDK.dll"; // 确保文件名与实际资源一致 - //win32-x86-64/WxpayFaceSDK.dll - private static final String RESOURCE_PATH = "win32-x86-64/" + DLL_NAME; // 例如: resources/native/WxpayFaceSDK.dll - private static volatile boolean dllLoaded = false; - - static { - loadDllFromResources(); - } - - - private static void loadDllFromResources() { - if (dllLoaded) return; + /** + * 获取 Dll 实例,同时注册 Dll 控件。 + * + * @return WxpayFaceSDKDll 实例 + * @throws WxpayFaceSDKDll.DllRegistrationException 如果注册控件失败,抛出此异常 + */ + public static WxpayFaceSDKDll.Dll instance() throws DllRegistrationException { try { - // 从 resources 中读取 DLL 文件流 - InputStream inputStream = WxpayFaceSDKDll.class.getClassLoader().getResourceAsStream(RESOURCE_PATH); - if (inputStream == null) { - throw new RuntimeException("DLL 未找到: " + RESOURCE_PATH); - } - - // 创建临时目录并提取 DLL - Path tempDir = Files.createTempDirectory("native-libs"); - Path tempDll = tempDir.resolve(DLL_NAME); - Files.copy(inputStream, tempDll, StandardCopyOption.REPLACE_EXISTING); - inputStream.close(); - - // 显式加载 DLL - System.load(tempDll.toAbsolutePath().toString()); - dllLoaded = true; - - // 可选:JVM 退出时清理临时文件 - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - try { - Files.deleteIfExists(tempDll); - Files.deleteIfExists(tempDir); - } catch (Exception e) { - e.printStackTrace(); - } - })); - } catch (Exception e) { - throw new RuntimeException("加载 DLL 失败", e); - } - } - - public static Dll instance() throws DllRegistrationException { - try { - // 加载已提取的 DLL - return Native.load(DLL_NAME, Dll.class); + return Native.load("WxpayFaceSDK", WxpayFaceSDKDll.Dll.class); } catch (UnsatisfiedLinkError e) { - log.error("[WxpayFaceSDK][instance] 加载失败", e); - throw new DllRegistrationException("Failed to load WxpayFaceSDK library: ", e); + log.info("[WxpayFaceSDK][instance][微信扫脸动态库] SDK注册失败:{}", e.getMessage()); + throw new WxpayFaceSDKDll.DllRegistrationException("Failed to load WxpayFaceSDK library: ", e); } } diff --git a/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll_old.java b/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll_old.java deleted file mode 100644 index 86a77f0..0000000 --- a/src/main/java/com/dpkj/modules/scanface/wx/dll/WxpayFaceSDKDll_old.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.dpkj.modules.scanface.wx.dll; - -import com.sun.jna.Library; -import com.sun.jna.Native; -import lombok.extern.slf4j.Slf4j; - -/** - * @description: - * @author: Zhangxue - * @time: 2025/4/17 17:02 - */ -@Slf4j -public class WxpayFaceSDKDll_old { - - /** - * 获取 Dll 实例,同时注册 Dll 控件。 - * - * @return WxpayFaceSDKDll 实例 - * @throws WxpayFaceSDKDll_old.DllRegistrationException 如果注册控件失败,抛出此异常 - */ - public static WxpayFaceSDKDll_old.Dll instance() throws DllRegistrationException { - try { - return Native.load("WxpayFaceSDK", WxpayFaceSDKDll_old.Dll.class); - } catch (UnsatisfiedLinkError e) { - log.info("[WxpayFaceSDK][instance][微信扫脸动态库] SDK注册失败:{}", e.getMessage()); - throw new WxpayFaceSDKDll_old.DllRegistrationException("Failed to load WxpayFaceSDK library: ", e); - } - } - - /** - * 定义自定义异常类,用于表示注册控件时发生的错误 - */ - public static class DllRegistrationException extends Exception { - public DllRegistrationException(String message) { - super(message); - } - - public DllRegistrationException(String message, Throwable cause) { - super(message, cause); - } - } - - /** - * 定义接口映射本地库中的函数。 - */ - public interface Dll extends Library { - /** - * 调用人脸服务 - * 注意:这里的方法签名需要与DLL中的C函数签名一致 - * req和resp都是JSON字符串,需要转换为Pointer类型 - * char * -->String; char ** -->String[] - * int -->int; int* --> IntByReference - * @param reqBuf 请求参数(JSON字符串) - * @param reqSize 请求参数长度 - * @param pRespBuf 用来接收响应结果(JSON字符串)的char**指针 - * @param pRespSize 用来接收响应结果长度的unsigned int*指针 - * @return 如果成功返回0,失败则返回非0 - */ - //int wxpayCallFaceService(String reqBuf, int reqSize, String[] pRespBuf, IntByReference pRespSize); - int wxpayCallFaceService(String reqBuf, int reqSize, long[] pRespBuf, int[] pRespSize); - - - /** - * char ** -->String[] - * 释放人脸服务的响应字符串,调用wxpayCallFaceService成功后务必调用此函数释放内存 - * @param pRespBuf 指向响应结果(JSON字符串)的指针 - */ - void wxpayReleaseResponse(String[] pRespBuf); - } - -} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f459716..01c42a6 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -29,17 +29,15 @@ dpkj: #dll文件路径 dll-path: C:/opt/ant-abcp/bpaas_api.dll #IOT 应用管理-appid - app-id: 2021005138692337 + app-id: 2021005138656502 #IOT应用版本 - app-version: 1.0.0 + app-version: 1.0.0.0 #签约商家的 PID,以 2088 开头,企业主体 merchant-id: 2088641941653700 - #商家机具终端编号,每台设备保持唯一【设备铭牌上的整机编码】 + #商家机具终端编号,每台设备保持唯一 device-num: P060003750 #服务商的 PID partner-id: 2088641941653700 - # 刷脸支付服务-服务编码(serviceCode) - service-code: BPaaSSmileVerifyNonInitV1 # 核心入参 serviceId service-id: pay diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index ff179fe..6c6f999 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -1,5 +1,5 @@ server: - port: 5948 + port: 5946 dpkj: # 医保配置 @@ -31,7 +31,7 @@ dpkj: #IOT 应用管理-appid app-id: 2021005138656502 #IOT应用版本 - app-version: 1.0.0 + app-version: 1.0.0.0 #签约商家的 PID,以 2088 开头,企业主体 merchant-id: 2088641941653700 #商家机具终端编号,每台设备保持唯一