From f36e6703a3b4c198309154faa39c2eaa8402ff3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BF=97=E6=88=90?= <15187855430@163.com> Date: Mon, 17 Feb 2025 17:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E8=AF=81=E5=AE=9E=E4=BD=93=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=8E=E5=8F=B0=E5=BC=8F=E6=9C=BA=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/cardReader/utils/IdCardInfo.java | 181 ------------------ .../modules/cardReader/utils/UserInfo.java | 147 -------------- 2 files changed, 328 deletions(-) delete mode 100644 src/main/java/com/dpkj/modules/cardReader/utils/IdCardInfo.java delete mode 100644 src/main/java/com/dpkj/modules/cardReader/utils/UserInfo.java diff --git a/src/main/java/com/dpkj/modules/cardReader/utils/IdCardInfo.java b/src/main/java/com/dpkj/modules/cardReader/utils/IdCardInfo.java deleted file mode 100644 index 3973482..0000000 --- a/src/main/java/com/dpkj/modules/cardReader/utils/IdCardInfo.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.dpkj.modules.cardReader.utils; - -import com.dpkj.common.exception.RRException; -import lombok.Data; - -import java.io.UnsupportedEncodingException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.function.Consumer; - -/** - * 有关身份证的基本信息 - */ -@Data -public class IdCardInfo { - - /** - * 名字 - */ - private String name; - - /** - * 性别 - */ - private String sex; - - /** - * 民族 - */ - private String nation; - - /** - * 出生日期 - */ - private LocalDateTime brith; - - /** - * 住址 - */ - private String address; - - /** - * 身份证号码 - */ - private String certNo; - - /** - * 签发机关 - */ - private String department; - - /** - * 有效日期 - */ - private LocalDateTime effectDate; - - /** - * 截至日期 - */ - private LocalDateTime expireDate; - - /** - * 外国人姓名 - */ - private String enName; - - /** - * 外国人国籍 - */ - private String nationalityCode; - - /** - * 注册过的sdk实例 - */ - private CardReaderSdk cardReaderSdk; - - /** - * 是否有指纹 - */ - private Boolean fingerExist; - - /** - * 指纹数据 - */ - private byte[] fingerData; - - /** - * 港澳台通行证号码 - */ - private String TXZHM; - - /** - * 港澳台通行证签发次数 - */ - private Integer TXZQFCS; - - /** - * 外国人换证次数 - */ - private Integer HZCS; - - - public IdCardInfo(CardReaderSdk cardReaderSdk, Long handle){ - if ( cardReaderSdk == null ){ - throw new RRException("sdk初始化失败"); - } - this.cardReaderSdk = cardReaderSdk; - - byte[] errMsg = new byte[999]; - cardReaderSdk.PICC_Reader_ReadIDCard(handle, errMsg); - try { - String gbk = new String(errMsg, "GBK").trim(); - if (!gbk.equals("")) { - throw new RRException(); - } - } catch (Exception e) { - throw new RRException("身份证信息读取失败"); - } - - this.name = this.convert2Str(this.cardReaderSdk::GetName, "姓名转换失败"); - this.sex = this.convert2Str(this.cardReaderSdk::GetSex, "性别转换失败"); - this.nation = this.convert2Str(this.cardReaderSdk::GetNation, "民族转换失败"); - String br = this.convert2Str(this.cardReaderSdk::GetBirth, "出生日期转换失败"); - if ( br != null && br != "" ){ - this.brith = this.str2LocalDateTime(br); - } - this.address = this.convert2Str(this.cardReaderSdk::GetAddress, "住址转换失败"); - this.certNo = this.convert2Str(this.cardReaderSdk::GetCertNo, "身份证转换失败"); - this.department = this.convert2Str(this.cardReaderSdk::GetDepartemt, "签发机关转换失败"); - String eff = this.convert2Str(this.cardReaderSdk::GetEffectDate, "过期时间转换失败"); - if ( eff != null && eff != "" ){ - this.effectDate = this.str2LocalDateTime(eff); - } - String exp = this.convert2Str(this.cardReaderSdk::GetExpireDate, "截至日期转换失败"); - if ( exp != null && exp != "" ){ - this.expireDate = this.str2LocalDateTime(exp); - } - this.enName = this.convert2Str(this.cardReaderSdk::GetEnName, "外国人姓名转换失败"); - this.nationalityCode = this.convert2Str(this.cardReaderSdk::GetNationalityCode, "外国人国籍转换失败"); -// this.fingerExist = this.cardReaderSdk.IsFingerExist() != 0; -// if ( this.fingerExist ) { -// this.fingerData = this.convert2Str(this.cardReaderSdk::GetFingerprint, "指纹数据转换失败").getBytes(StandardCharsets.UTF_8); -// } - - } - - - private String convert2Str(Consumer function, String tip) { - byte[] param = new byte[256]; - function.accept(param); - try { - // 检查字节数组是否为空或者只包含值为 0 的字节 - boolean isAllZero = true; - for (byte b : param) { - if (b != 0) { - isAllZero = false; - break; - } - } - - if (isAllZero) { - return null; - } - - return new String(param, "GBK").trim(); - }catch (Exception e){ - throw new RRException(tip == null ? "参数转换失败" : tip); - } - } - - private LocalDateTime str2LocalDateTime(String str){ - // 定义日期格式化器 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - // 将字符串解析为 LocalDate - LocalDate localDate = LocalDate.parse(str, formatter); - // 将 LocalDate 转换为 LocalDateTime,设置时间为 00:00:00 - return localDate.atStartOfDay(); - } - -} diff --git a/src/main/java/com/dpkj/modules/cardReader/utils/UserInfo.java b/src/main/java/com/dpkj/modules/cardReader/utils/UserInfo.java deleted file mode 100644 index 4ecf72b..0000000 --- a/src/main/java/com/dpkj/modules/cardReader/utils/UserInfo.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.dpkj.modules.cardReader.utils; - -import com.dpkj.common.exception.RRException; -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.Data; - -import java.nio.charset.StandardCharsets; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.function.Consumer; - -/** - * 用户基本信息 - */ -@Data -public class UserInfo { - - /** - * 名字 - */ - private String name; - - /** - * 性别 - */ - private String sex; - - /** - * 民族 - */ - private String nation; - - /** - * 出生日期 - */ - private String brith; - - /** - * 住址 - */ - private String address; - - /** - * 身份证号码 - */ - private String certNo; - - /** - * 签发机关 - */ - private String department; - - /** - * 有效日期 - */ - private String effectDate; - - /** - * 截至日期 - */ - private String expireDate; - - /** - * 外国人姓名 - */ - private String enName; - - /** - * 外国人国籍 - */ - private String nationalityCode; - - /** - * 注册过的sdk实例 - */ - @JsonIgnore - private CardReaderSdk cardReaderSdk; - - /** - * 是否有指纹 - */ - private Boolean fingerExist; - - /** - * 指纹数据 - */ - private byte[] fingerData; - - /** - * 港澳台通行证号码 - */ - private String TXZHM; - - /** - * 港澳台通行证签发次数 - */ - private Integer TXZQFCS; - - /** - * 外国人换证次数 - */ - private Integer HZCS; - - - public UserInfo(CardReaderSdk cardReaderSdk){ - if ( cardReaderSdk == null ){ - throw new RRException("sdk初始化失败"); - } - this.cardReaderSdk = cardReaderSdk; - this.name = this.convert2Str(this.cardReaderSdk::GetName, "姓名转换失败"); - this.sex = this.convert2Str(this.cardReaderSdk::GetSex, "性别转换失败"); - this.nation = this.convert2Str(this.cardReaderSdk::GetNation, "民族转换失败"); - this.brith = this.convert2Str(this.cardReaderSdk::GetBirth, "出生日期转换失败"); - - this.address = this.convert2Str(this.cardReaderSdk::GetAddress, "住址转换失败"); - this.certNo = this.convert2Str(this.cardReaderSdk::GetCertNo, "身份证转换失败"); - this.department = this.convert2Str(this.cardReaderSdk::GetDepartemt, "签发机关转换失败"); - this.effectDate = this.convert2Str(this.cardReaderSdk::GetEffectDate, "过期时间转换失败"); - this.expireDate = this.convert2Str(this.cardReaderSdk::GetExpireDate, "截至日期转换失败"); - - this.enName = this.convert2Str(this.cardReaderSdk::GetEnName, "外国人姓名转换失败"); - this.nationalityCode = this.convert2Str(this.cardReaderSdk::GetNationalityCode, "外国人国籍转换失败"); - } - - - private String convert2Str(Consumer function, String tip) { - byte[] param = new byte[256]; - function.accept(param); - try { - - return new String(param, "GBK").trim(); - }catch (Exception e){ - throw new RRException(tip == null ? "参数转换失败" : tip); - } - } - - private LocalDateTime str2LocalDateTime(String str){ - // 定义日期格式化器 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - // 将字符串解析为 LocalDate - LocalDate localDate = LocalDate.parse(str, formatter); - // 将 LocalDate 转换为 LocalDateTime,设置时间为 00:00:00 - return localDate.atStartOfDay(); - } - -}