身份证读取、社保卡读取优化
This commit is contained in:
parent
0e9a6b6cf0
commit
24820af27a
|
@ -10,6 +10,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CardReaderServiceImpl implements CardReaderService {
|
public class CardReaderServiceImpl implements CardReaderService {
|
||||||
|
@ -18,154 +21,156 @@ public class CardReaderServiceImpl implements CardReaderService {
|
||||||
@Value("${IDCardReader.waitingTime}")
|
@Value("${IDCardReader.waitingTime}")
|
||||||
private Long waitingTime;
|
private Long waitingTime;
|
||||||
private final Object cardReaderLock = new Object();
|
private final Object cardReaderLock = new Object();
|
||||||
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result IDCardReader() {
|
public Result IDCardReader() {
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
Long handle = null;
|
Long handle = null;
|
||||||
UserInfoVO userInfo = null;
|
UserInfoVO userInfo = null;
|
||||||
try {
|
try {
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][26]: 开始连接指定设备与电脑端口,即打开端口");
|
log.info("[CardReaderServiceImpl][IDCardReader][33]: 开始连接指定设备与电脑端口,即打开端口");
|
||||||
// 连接指定设备与电脑端口,即打开端口
|
// 连接指定设备与电脑端口,即打开端口
|
||||||
handle = cardReaderSdk.ICC_Reader_Open("USB1");
|
handle = cardReaderSdk.ICC_Reader_Open("USB1");
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][29]: 连接指定设备与电脑端口,即打开端口,返回句柄: {}", handle);
|
log.info("[CardReaderServiceImpl][IDCardReader][36]: 连接指定设备与电脑端口,即打开端口,返回句柄: {}", handle);
|
||||||
|
if (handle == null) {
|
||||||
|
log.error("[CardReaderServiceImpl][IDCardReader][38]: 打开端口失败");
|
||||||
|
return Result.error("打开端口失败,请检查设备连接");
|
||||||
|
}
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][32]: 开始循环读取 ID 卡信息,开始时间: {}", startTime);
|
log.info("[CardReaderServiceImpl][IDCardReader][42]: 开始循环读取 ID 卡信息,开始时间: {}", startTime);
|
||||||
|
|
||||||
|
byte[] bytes = new byte[1024];
|
||||||
|
log.info("[CardReaderServiceImpl][IDCardReader][45]: 尝试读取 ID 卡");
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
int idCard = cardReaderSdk.PICC_Reader_ReadIDCard(handle, bytes);
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][36]: 尝试读取 ID 卡");
|
log.info("[CardReaderServiceImpl][IDCardReader][48]: PICC_Reader_ReadIDCard读取 ID 卡,返回值: {}", idCard);
|
||||||
Long idCard = cardReaderSdk.PICC_Reader_ReadIDCard(handle);
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][38]: 读取 ID 卡,返回值: {}", idCard);
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][39]: 尝试创建 UserInfoVO 对象");
|
|
||||||
userInfo = new UserInfoVO(cardReaderSdk);
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][53]: 创建 UserInfoVO 对象成功,姓名: {}", userInfo.getName());
|
|
||||||
if (!"".equals(userInfo.getName()) && userInfo.getName() != null) {
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][55]: 成功读取到用户姓名,退出循环");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 处理创建 UserInfoVO 时可能出现的异常
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][60]: 创建 UserInfoVO 对象时发生异常", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][64]: 已过去时间: {} 毫秒", elapsedTime);
|
|
||||||
if (elapsedTime >= waitingTime) {
|
if (elapsedTime >= waitingTime) {
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][66]: 读取 ID 卡信息超时,等待了 {} 秒。", waitingTime);
|
log.info("[CardReaderServiceImpl][IDCardReader][52]: 读取 ID 卡信息超时,等待了 {} 秒。", waitingTime);
|
||||||
return Result.error("读取 ID 卡信息超时,请重试。");
|
return Result.error("读取 ID 卡信息超时,请重试。", -18);
|
||||||
}
|
}
|
||||||
|
if (idCard == 0) {
|
||||||
try {
|
try {
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][70]: 线程休眠 100 毫秒,避免 CPU 空转");
|
userInfo = new UserInfoVO(cardReaderSdk);
|
||||||
// 短暂休眠,避免 CPU 空转
|
if (userInfo.getName() != null && !userInfo.getName().isEmpty()) {
|
||||||
Thread.sleep(100);
|
log.info("[CardReaderServiceImpl][IDCardReader][59]: 成功读取到用户信息,返回结果");
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][74]: 线程休眠被中断,重新设置中断状态");
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][78]: 成功读取到用户信息,返回结果");
|
|
||||||
return Result.ok(userInfo);
|
return Result.ok(userInfo);
|
||||||
|
} else {
|
||||||
|
log.info("[CardReaderServiceImpl][IDCardReader][62]: 读取到的用户信息异常,请尝试重新读取");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("[CardReaderServiceImpl][IDCardReader][65]: 创建 UserInfoVO 对象时发生异常", e);
|
||||||
|
return Result.error("创建用户信息对象时发生异常,请重试。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (handle != null) {
|
if (handle != null) {
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][82]: 开始关闭端口,句柄: {}", handle);
|
log.info("[CardReaderServiceImpl][IDCardReader][72]: 开始关闭端口,句柄: {}", handle);
|
||||||
// 不管什么情况最终都要关闭端口
|
// 不管什么情况最终都要关闭端口
|
||||||
cardReaderSdk.ICC_Reader_Close(handle);
|
cardReaderSdk.ICC_Reader_Close(handle);
|
||||||
log.info("[CardReaderServiceImpl][IDCardReader][85]: 端口关闭成功");
|
log.info("[CardReaderServiceImpl][IDCardReader][75]: 端口关闭成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result SocialSecurityCardReader() {
|
public Result SocialSecurityCardReader() {
|
||||||
|
lock.lock();
|
||||||
|
try{
|
||||||
Long handle = null;
|
Long handle = null;
|
||||||
try {
|
try {
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][70]: 开始连接指定设备与电脑端口,即打开端口");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][89]: 开始连接指定设备与电脑端口,即打开端口");
|
||||||
handle = cardReaderSdk.ICC_Reader_Open("USB1");
|
handle = cardReaderSdk.ICC_Reader_Open("USB1");
|
||||||
if (handle != null) {
|
if (handle == null) {
|
||||||
log.error("[CardReaderServiceImpl][SocialSecurityCardReader][70]: 打开端口失败");
|
log.error("[CardReaderServiceImpl][SocialSecurityCardReader][92]: 打开端口失败");
|
||||||
return Result.error("打开端口失败,请检查设备连接");
|
return Result.error("打开端口失败,请检查设备连接");
|
||||||
}
|
}
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][70]: 连接指定设备与电脑端口,即打开端口,返回句柄: {}", handle);
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][95]: 连接指定设备与电脑端口,即打开端口,返回句柄: {}", handle);
|
||||||
|
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始循环读取社保卡信息,开始时间: {}", startTime);
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][99]: 开始循环读取社保卡信息,开始时间: {}", startTime);
|
||||||
|
|
||||||
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][101]: 获取设备卡读取设备状态");
|
||||||
while (true) {
|
while (true) {
|
||||||
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
|
if (elapsedTime >= waitingTime) {
|
||||||
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][105]: 读取社保卡信息超时,等待了 {} 毫秒。", waitingTime);
|
||||||
|
return Result.error("读取社保卡信息超时,请重试。", -18);
|
||||||
|
}
|
||||||
|
int l = cardReaderSdk.ICC_Reader_GetStatus(handle, 0x01);
|
||||||
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][109]: 获取社保卡读取设备状态:结果{}", l);
|
||||||
|
if (l == 0) {
|
||||||
byte[] data = new byte[4096];
|
byte[] data = new byte[4096];
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 尝试读取社保卡基本信息");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][112]: 尝试读取社保卡基本信息");
|
||||||
Long i = cardReaderSdk.iReadCardBas(3, data);
|
int i = cardReaderSdk.iReadCardBas(3, data);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 读取社保卡基本信息,返回值: {}", i);
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][114]: 读取社保卡基本信息,返回值: {}", i);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
java.lang.String bas = new java.lang.String(data, "GBK");
|
java.lang.String bas = new java.lang.String(data, "GBK");
|
||||||
java.lang.String[] split = bas.split("\\|");
|
java.lang.String[] split = bas.split("\\|");
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 读基本信息,结果: {}", bas);
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][118]: 读基本信息,结果: {}", bas);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始分割基本信息");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][119]: 开始创建 SocialSecurityCardInfoVO 对象");
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 基本信息分割完成,分割后的数组长度: {}", split.length);
|
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始创建 SocialSecurityCardInfoVO 对象");
|
|
||||||
SocialSecurityCardInfoVO socialSecurityCardInfoVO = new SocialSecurityCardInfoVO();
|
SocialSecurityCardInfoVO socialSecurityCardInfoVO = new SocialSecurityCardInfoVO();
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始截取区号代码");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][121]: 开始截取区号代码");
|
||||||
// 区号代码截取
|
// 区号代码截取
|
||||||
socialSecurityCardInfoVO.setAreaCode(split[0].substring(split[0].length() - 6));
|
socialSecurityCardInfoVO.setAreaCode(split[0].substring(split[0].length() - 6));
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 区号代码截取完成,结果: {}", socialSecurityCardInfoVO.getAreaCode());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][124]: 区号代码截取完成,结果: {}", socialSecurityCardInfoVO.getAreaCode());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置社保卡号");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][125]: 开始设置社保卡号");
|
||||||
socialSecurityCardInfoVO.setSocialSecurityNo(split[1]);
|
socialSecurityCardInfoVO.setSocialSecurityNo(split[1]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 社保卡号设置完成,结果: {}", socialSecurityCardInfoVO.getSocialSecurityNo());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][127]: 社保卡号设置完成,结果: {}", socialSecurityCardInfoVO.getSocialSecurityNo());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置卡号");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置卡号");
|
||||||
socialSecurityCardInfoVO.setCardNumber(split[2]);
|
socialSecurityCardInfoVO.setCardNumber(split[2]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 卡号设置完成,结果: {}", socialSecurityCardInfoVO.getCardNumber());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][130]: 卡号设置完成,结果: {}", socialSecurityCardInfoVO.getCardNumber());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置识别码");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][131]: 开始设置识别码");
|
||||||
socialSecurityCardInfoVO.setIdentificationCode(split[3]);
|
socialSecurityCardInfoVO.setIdentificationCode(split[3]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 识别码设置完成,结果: {}", socialSecurityCardInfoVO.getIdentificationCode());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][133]: 识别码设置完成,结果: {}", socialSecurityCardInfoVO.getIdentificationCode());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置姓名");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][134]: 开始设置姓名");
|
||||||
socialSecurityCardInfoVO.setName(split[4]);
|
socialSecurityCardInfoVO.setName(split[4]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 姓名设置完成,结果: {}", socialSecurityCardInfoVO.getName());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][136]: 姓名设置完成,结果: {}", socialSecurityCardInfoVO.getName());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置卡重置信息");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][137]: 开始设置卡重置信息");
|
||||||
socialSecurityCardInfoVO.setCardResetInformation(split[5]);
|
socialSecurityCardInfoVO.setCardResetInformation(split[5]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 卡重置信息设置完成,结果: {}", socialSecurityCardInfoVO.getCardResetInformation());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][139]: 卡重置信息设置完成,结果: {}", socialSecurityCardInfoVO.getCardResetInformation());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置规格版本");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][140]: 开始设置规格版本");
|
||||||
socialSecurityCardInfoVO.setSpecificationVersion(split[6]);
|
socialSecurityCardInfoVO.setSpecificationVersion(split[6]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 规格版本设置完成,结果: {}", socialSecurityCardInfoVO.getSpecificationVersion());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][142]: 规格版本设置完成,结果: {}", socialSecurityCardInfoVO.getSpecificationVersion());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置发卡日期");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][143]: 开始设置发卡日期");
|
||||||
socialSecurityCardInfoVO.setIssuanceDate(split[7]);
|
socialSecurityCardInfoVO.setIssuanceDate(split[7]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 发卡日期设置完成,结果: {}", socialSecurityCardInfoVO.getIssuanceDate());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][145]: 发卡日期设置完成,结果: {}", socialSecurityCardInfoVO.getIssuanceDate());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置过期日期");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][146]: 开始设置过期日期");
|
||||||
socialSecurityCardInfoVO.setExpireDate(split[8]);
|
socialSecurityCardInfoVO.setExpireDate(split[8]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 过期日期设置完成,结果: {}", socialSecurityCardInfoVO.getExpireDate());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][148]: 过期日期设置完成,结果: {}", socialSecurityCardInfoVO.getExpireDate());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置终端号");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][149]: 开始设置终端号");
|
||||||
socialSecurityCardInfoVO.setTerminalNumber(split[9]);
|
socialSecurityCardInfoVO.setTerminalNumber(split[9]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 终端号设置完成,结果: {}", socialSecurityCardInfoVO.getTerminalNumber());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][151]: 终端号设置完成,结果: {}", socialSecurityCardInfoVO.getTerminalNumber());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始设置终端设备号");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][152]: 开始设置终端设备号");
|
||||||
socialSecurityCardInfoVO.setTerminalDeviceNumber(split[10]);
|
socialSecurityCardInfoVO.setTerminalDeviceNumber(split[10]);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 终端设备号设置完成,结果: {}", socialSecurityCardInfoVO.getTerminalDeviceNumber());
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][154]: 终端设备号设置完成,结果: {}", socialSecurityCardInfoVO.getTerminalDeviceNumber());
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 成功读取社保卡信息,返回结果");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][155]: 成功读取社保卡信息,返回结果");
|
||||||
return Result.ok(socialSecurityCardInfoVO);
|
return Result.ok(socialSecurityCardInfoVO);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
return Result.error("社保卡读取失败!");
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 已过去时间: {} 毫秒", elapsedTime);
|
|
||||||
if (elapsedTime >= waitingTime) {
|
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 读取社保卡信息超时,等待了 {} 毫秒。", waitingTime);
|
|
||||||
return Result.error("读取社保卡信息超时,请重试。");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 线程休眠 100 毫秒,避免 CPU 空转");
|
|
||||||
// 短暂休眠,避免 CPU 空转
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 线程休眠被中断,重新设置中断状态");
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: Error occurred during card reader operation: ", e);
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
if (handle != null) {
|
if (handle != null) {
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 开始关闭端口,句柄: {}", handle);
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][166]: 开始关闭端口,句柄: {}", handle);
|
||||||
// 关闭端口
|
// 关闭端口
|
||||||
cardReaderSdk.ICC_Reader_Close(handle);
|
cardReaderSdk.ICC_Reader_Close(handle);
|
||||||
log.info("[CardReaderServiceImpl][SocialSecurityCardReader]: 端口关闭成功");
|
log.info("[CardReaderServiceImpl][SocialSecurityCardReader][169]: 端口关闭成功");
|
||||||
}
|
}
|
||||||
return Result.error("操作失败:" + e.getMessage());
|
}
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.dpkj.modules.cardReader.utils;
|
package com.dpkj.modules.cardReader.utils;
|
||||||
|
|
||||||
import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint;
|
|
||||||
import com.sun.jna.Library;
|
import com.sun.jna.Library;
|
||||||
import com.sun.jna.Native;
|
import com.sun.jna.Native;
|
||||||
import com.sun.jna.Platform;
|
|
||||||
|
|
||||||
public interface CardReaderSdk extends Library {
|
public interface CardReaderSdk extends Library {
|
||||||
CardReaderSdk INSTANCE = (CardReaderSdk) Native.loadLibrary(GetLibraryPath_Helper.GetLibraryPath(), CardReaderSdk.class);
|
CardReaderSdk INSTANCE = (CardReaderSdk) Native.loadLibrary(GetLibraryPath_Helper.GetLibraryPath(), CardReaderSdk.class);
|
||||||
|
@ -137,7 +135,7 @@ public interface CardReaderSdk extends Library {
|
||||||
* 0x3x:非接CPU卡
|
* 0x3x:非接CPU卡
|
||||||
* @return = 0 表示卡座有卡,其他见状态码
|
* @return = 0 表示卡座有卡,其他见状态码
|
||||||
*/
|
*/
|
||||||
Long ICC_Reader_GetStatus(Long ReaderHandle, String ICCSlotNo);
|
int ICC_Reader_GetStatus(Long ReaderHandle, int ICCSlotNo);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,8 +273,8 @@ public interface CardReaderSdk extends Library {
|
||||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||||
* @return 返回错误信息 = 0 表示成功,非0失败
|
* @return 返回错误信息 = 0 表示成功,非0失败
|
||||||
*/
|
*/
|
||||||
Long PICC_Reader_ReadIDCard(Long ReaderHandle);
|
// Long PICC_Reader_ReadIDCard(Long ReaderHandle);
|
||||||
// int PICC_Reader_ReadIDCard(Long ReaderHandle, byte[] response);
|
int PICC_Reader_ReadIDCard(Long ReaderHandle, byte[] response);
|
||||||
|
|
||||||
/** 以下函数须在 “PICC_Reader_ReadIDCard” 函数执行成功之后调用,否则获取不到有效信息 */
|
/** 以下函数须在 “PICC_Reader_ReadIDCard” 函数执行成功之后调用,否则获取不到有效信息 */
|
||||||
/**
|
/**
|
||||||
|
@ -287,99 +285,99 @@ public interface CardReaderSdk extends Library {
|
||||||
* 2:港澳台居民居住证
|
* 2:港澳台居民居住证
|
||||||
* 4:新外国人永久居留证
|
* 4:新外国人永久居留证
|
||||||
*/
|
*/
|
||||||
Integer GetCardType();
|
int GetCardType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 姓名(类型为 1 时表示:外国人中文姓名)
|
* 姓名(类型为 1 时表示:外国人中文姓名)
|
||||||
*/
|
*/
|
||||||
Integer GetName(byte[] outParam);
|
int GetName(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 性别
|
* 性别
|
||||||
*/
|
*/
|
||||||
Integer GetSex(byte[] outParam);
|
int GetSex(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 民族
|
* 民族
|
||||||
*/
|
*/
|
||||||
Integer GetNation(byte[] outParam);
|
int GetNation(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出生日期
|
* 出生日期
|
||||||
*/
|
*/
|
||||||
Integer GetBirth(byte[] outParam);
|
int GetBirth(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 住址
|
* 住址
|
||||||
*/
|
*/
|
||||||
Integer GetAddress(byte[] outParam);
|
int GetAddress(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公民身份证号码(类型为 1时表示:外国人居留证号码)
|
* 公民身份证号码(类型为 1时表示:外国人居留证号码)
|
||||||
*/
|
*/
|
||||||
Integer GetCertNo(byte[] outParam);
|
int GetCertNo(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签发机关
|
* 签发机关
|
||||||
*/
|
*/
|
||||||
Integer GetDepartemt(byte[] outParam);
|
int GetDepartemt(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有效起始日期
|
* 有效起始日期
|
||||||
*/
|
*/
|
||||||
Integer GetEffectDate(byte[] outParam);
|
int GetEffectDate(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有效截止日期
|
* 有效截止日期
|
||||||
*/
|
*/
|
||||||
Integer GetExpireDate(byte[] outParam);
|
int GetExpireDate(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bmp 格式照片数据
|
* bmp 格式照片数据
|
||||||
*/
|
*/
|
||||||
Integer GetBmpFileData(byte[] outParam);
|
int GetBmpFileData(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成照片
|
* 生成照片
|
||||||
* TODO 入参参考文中3.4.1
|
* TODO 入参参考文中3.4.1
|
||||||
*/
|
*/
|
||||||
Integer GetBmpFile(byte[] outParam);
|
int GetBmpFile(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否含存在指纹信息:存在时返回 512 或者 1024
|
* 是否含存在指纹信息:存在时返回 512 或者 1024
|
||||||
* 不存在时返回 0
|
* 不存在时返回 0
|
||||||
*/
|
*/
|
||||||
Integer IsFingerExist();
|
int IsFingerExist();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指纹数据:成功时返回获取到的字节长度
|
* 获取指纹数据:成功时返回获取到的字节长度
|
||||||
*/
|
*/
|
||||||
Integer GetFingerprint(byte[] outParam);
|
int GetFingerprint(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 外国人英文姓名
|
* 外国人英文姓名
|
||||||
*/
|
*/
|
||||||
Integer GetEnName(byte[] outParam);
|
int GetEnName(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 外国人国籍代码,符合GB/T2659-2000规定
|
* 外国人国籍代码,符合GB/T2659-2000规定
|
||||||
*/
|
*/
|
||||||
Integer GetNationalityCode(byte[] outParam);
|
int GetNationalityCode(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 港澳台通行证号码
|
* 港澳台通行证号码
|
||||||
*/
|
*/
|
||||||
Integer GetTXZHM(byte[] outParam);
|
int GetTXZHM(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 港澳台通行证签发次数
|
* 港澳台通行证签发次数
|
||||||
*/
|
*/
|
||||||
Integer GetTXZQFCS(byte[] outParam);
|
int GetTXZQFCS(byte[] outParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 外国人换证次数
|
* 外国人换证次数
|
||||||
*/
|
*/
|
||||||
Integer GetHZCS(byte[] outParam);
|
int GetHZCS(byte[] outParam);
|
||||||
|
|
||||||
/** ------------ 社保卡 ---------*/
|
/** ------------ 社保卡 ---------*/
|
||||||
/**
|
/**
|
||||||
|
@ -392,7 +390,7 @@ public interface CardReaderSdk extends Library {
|
||||||
* 4-自动寻卡,非接触式操作卡优先
|
* 4-自动寻卡,非接触式操作卡优先
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Long iReadCardBas(int iType, byte[] data);
|
int iReadCardBas(int iType, byte[] data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于加密机的读基本信息(步骤一)
|
* 基于加密机的读基本信息(步骤一)
|
||||||
|
@ -424,44 +422,8 @@ public interface CardReaderSdk extends Library {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String GetLibraryPath() {
|
private static String GetLibraryPath() {
|
||||||
// if (Platform.isWindows()) {
|
|
||||||
// return Platform.is64Bit() ? "/win32-x86-64/QXSSSE32_x64.dll" : "/win32-x86-64/QXSSSE32_x64.dll";
|
|
||||||
// } else if (Platform.isLinux()) {
|
|
||||||
// return Platform.is64Bit() ? "/win32-x86-64/QXSSSE32_x64.so" : "/win32-x86-64/QXSSSE32_x64.so";
|
|
||||||
// } else {
|
|
||||||
// return Platform.isMac() ? "/win32-x86-64/QXSSSE32_x64.so" : "/win32-x86-64/QXSSSE32_x64.so";
|
|
||||||
// }
|
|
||||||
return "/win32-x86-64/SSSE32.dll";
|
return "/win32-x86-64/SSSE32.dll";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//社保卡
|
|
||||||
public int PICC_Reader_SSCardInfo1(Long ReaderHandle,
|
|
||||||
byte[] SBKH,
|
|
||||||
byte[] SHBZHM,
|
|
||||||
byte[] XM,
|
|
||||||
byte[] XB,
|
|
||||||
byte[] CSRQ
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
//身份证
|
|
||||||
public int PICC_Reader_ReadIDInfo(Long ReaderHandle,
|
|
||||||
String filepath,
|
|
||||||
byte[] pName,
|
|
||||||
byte[] pSex,
|
|
||||||
byte[] pNation,
|
|
||||||
byte[] pBirth,
|
|
||||||
byte[] pAddress,
|
|
||||||
byte[] pCertNo,
|
|
||||||
byte[] pDepartment ,
|
|
||||||
byte[] pEffectData,
|
|
||||||
byte[] pExpire,
|
|
||||||
byte[] pErrMsg);
|
|
||||||
|
|
||||||
public int ICC_SelscetScan(Long ReaderHandle, byte[] pCodeInfo , int [] lent);
|
|
||||||
|
|
||||||
|
|
||||||
public int iGetDevUID(byte[] pOutInfo);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue