60 lines
1.5 KiB
Java
60 lines
1.5 KiB
Java
|
package com.dpkj.modules.chs.dll;
|
|||
|
|
|||
|
import com.sun.jna.Library;
|
|||
|
import com.sun.jna.Native;
|
|||
|
import com.sun.jna.Pointer;
|
|||
|
import lombok.extern.slf4j.Slf4j;
|
|||
|
|
|||
|
/**
|
|||
|
* @Auther: 萧道子
|
|||
|
* @Date: 2025/3/22 17:48
|
|||
|
* @Description:
|
|||
|
*/
|
|||
|
@Slf4j
|
|||
|
public class AlipayDll {
|
|||
|
|
|||
|
/**
|
|||
|
* 获取 AlipayDll 实例,同时注册 AlipayDll 控件。
|
|||
|
*
|
|||
|
* @return AlipayDll 实例
|
|||
|
* @throws DllRegistrationException 如果注册控件失败,抛出此异常
|
|||
|
*/
|
|||
|
public static Dll instance() throws DllRegistrationException {
|
|||
|
try {
|
|||
|
return Native.load("AlipayChs", Dll.class);
|
|||
|
} catch (UnsatisfiedLinkError e) {
|
|||
|
log.info("[AlipayDll][getPrintSDK][医保动态库] SDK注册失败:{}", e.getMessage());
|
|||
|
throw new DllRegistrationException("Failed to load AlipayDll 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 {
|
|||
|
|
|||
|
/**
|
|||
|
* 设置打印端口和波特率。
|
|||
|
*
|
|||
|
* @return 返回操作结果代码
|
|||
|
*/
|
|||
|
String NationEcTrans(String strUrl, String InData, Pointer OutData);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|