身份证读取、社保卡读取
This commit is contained in:
parent
ed61a25ac4
commit
5a84be620d
5
pom.xml
5
pom.xml
|
@ -114,6 +114,11 @@
|
||||||
<version>3.1.28</version> <!-- 可以根据实际情况调整版本 -->
|
<version>3.1.28</version> <!-- 可以根据实际情况调整版本 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.15</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.dpkj.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 利盟台式机 设备调用逻辑名
|
||||||
|
*/
|
||||||
|
public interface LexMarkConst {
|
||||||
|
/**
|
||||||
|
* 身份证读取
|
||||||
|
*/
|
||||||
|
String ID_CARD_READ = "RFIDCardReader";
|
||||||
|
/**
|
||||||
|
* 社保卡读取
|
||||||
|
*/
|
||||||
|
String CARD_READER = "CardReader";
|
||||||
|
/**
|
||||||
|
* 打印机
|
||||||
|
*/
|
||||||
|
String RECEIPT_PRINTER = "ReceiptPrinter";
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.dpkj.common.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 利盟接口返回值DTO
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-02-08 11:03:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class LexMarkResultVO<T> implements Serializable {
|
||||||
|
/**
|
||||||
|
* 对应发送请求中的devName
|
||||||
|
*/
|
||||||
|
private String devName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件名,由发送请求中的actionName+Over组成。
|
||||||
|
*/
|
||||||
|
private String msgName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应发送请求的callID。
|
||||||
|
*/
|
||||||
|
private int callID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误码:0表示成功;其他表示失败,比如-4表示取消,-48表示超时,-14表示硬件故障
|
||||||
|
*/
|
||||||
|
private int result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送请求中的actionName
|
||||||
|
*/
|
||||||
|
private String cmdName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回参数
|
||||||
|
*/
|
||||||
|
private T param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.dpkj.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.dpkj.common.dto.LexMarkDTO;
|
||||||
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
|
import com.dpkj.common.dto.LexMarkResultVO;
|
||||||
|
import com.dpkj.common.exception.RRException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方服务,主要是调用打印机等
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-02-08 10:45:01
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ThirdServiceUtil {
|
||||||
|
|
||||||
|
@Value("${app.custom.lexMarkServiceIp}")
|
||||||
|
private String lexMarkServiceIp;
|
||||||
|
@Value("${app.custom.lexMarkServicePort}")
|
||||||
|
private String lexMarkServicePort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 利盟台式机-立体机 接口请求
|
||||||
|
* @param lexMarkDTO 请求DTO
|
||||||
|
* @return result
|
||||||
|
*/
|
||||||
|
public <T> T callDevice(LexMarkDTO lexMarkDTO, Class<T> responseType) {
|
||||||
|
try {
|
||||||
|
URL url = new URL(lexMarkServiceIp + ":" + lexMarkServicePort + "/CallDevice");
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
// 将 LexMarkDTO 对象转换为 JSON 字符串
|
||||||
|
String jsonInputString = JSON.toJSONString(lexMarkDTO);
|
||||||
|
try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
|
||||||
|
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||||
|
wr.write(input, 0, input.length);
|
||||||
|
}
|
||||||
|
int responseCode = connection.getResponseCode();
|
||||||
|
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||||
|
throw new RRException("利盟服务请求失败,响应码:" + responseCode);
|
||||||
|
}
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String inputLine;
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
response.append(inputLine);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
// 将响应 JSON 字符串转换为泛型对象
|
||||||
|
T result = JSON.parseObject(response.toString(), responseType);
|
||||||
|
if (result instanceof LexMarkResultVO && ((LexMarkResultVO) result).getResult() != 0) {
|
||||||
|
throw new RRException(result.toString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e instanceof RRException) {
|
||||||
|
throw new RRException(((RRException) e).getCode(), e.getMessage());
|
||||||
|
}
|
||||||
|
throw new RRException("利盟服务请求失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.dpkj.modules.readcard.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读卡模块 方法名
|
||||||
|
*/
|
||||||
|
public interface ReadCardConst {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开设备(异步)/ (同步)
|
||||||
|
*/
|
||||||
|
String OPEN_CONNECTION = "OpenConnection";
|
||||||
|
String OPEN_CONNECTION_SYNC = "OpenConnectionSync";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭设备(异步)/ (同步)
|
||||||
|
*/
|
||||||
|
String CLOSE_CONNECTION = "CloseConnection";
|
||||||
|
String CLOSE_CONNECTION_SYNC = "CloseConnectionSync";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进卡读卡(异步)/ (同步)
|
||||||
|
*/
|
||||||
|
String ACCEPT_AND_READ_TRACKS = "AcceptAndReadTracks";
|
||||||
|
String ACCEPT_AND_READ_TRACKS_SYNC = "AcceptAndReadTracksSync";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步取消进卡
|
||||||
|
*/
|
||||||
|
String CANCEL_ACCEPT = "CancelAccept";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步Chip(IC卡片)数据交互 / 同步Chip(IC卡片)数据交互
|
||||||
|
*/
|
||||||
|
String CHIP_IO = "ChipIo";
|
||||||
|
String CHIP_IO_SYNC = "ChipIoSync";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IC卡上电
|
||||||
|
*/
|
||||||
|
String CHIPPOWER = "ChipPower";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退卡
|
||||||
|
*/
|
||||||
|
String EJECT = "Eject";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取属性
|
||||||
|
*/
|
||||||
|
String GET_CAPABILITIES = "GetCapabilities";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态 同步/异步
|
||||||
|
*/
|
||||||
|
String GET_STATUS = "GetStatus";
|
||||||
|
String GET_STATUS_SYNC = "GetStatusSync";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取 读基本信息
|
||||||
|
*/
|
||||||
|
String I_READ_CARD_BAS = "iReadCardBas";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取 基于加密机的读基本信息
|
||||||
|
*/
|
||||||
|
String I_READ_CARD_BAS_HSM_STEP1 = "iReadCardBas_HSM_Step1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取 基于加密机的读基本信息
|
||||||
|
*/
|
||||||
|
String I_READ_CARD_BAS_HSM_STEP2 = "iReadCardBas_HSM_Step2";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.dpkj.modules.readcard.controller;
|
||||||
|
|
||||||
|
import com.dpkj.common.vo.Result;
|
||||||
|
import com.dpkj.modules.readcard.service.ReadCardService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("readCard")
|
||||||
|
public class ReadCardController {
|
||||||
|
@Autowired
|
||||||
|
private ReadCardService readCardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证读取
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("IDCardReader")
|
||||||
|
public Result IDCardReader() {
|
||||||
|
return readCardService.IDCardReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("SocialSecurityCardReader")
|
||||||
|
public Result SocialSecurityCardReader() {
|
||||||
|
return readCardService.SocialSecurityCardReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡退卡
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("cardRefund")
|
||||||
|
public Result cardRefund() {
|
||||||
|
return readCardService.cardRefund();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.dpkj.modules.readcard.service;
|
||||||
|
|
||||||
|
import com.dpkj.common.vo.Result;
|
||||||
|
|
||||||
|
public interface ReadCardService {
|
||||||
|
|
||||||
|
Result IDCardReader();
|
||||||
|
|
||||||
|
Result SocialSecurityCardReader();
|
||||||
|
|
||||||
|
Result cardRefund();
|
||||||
|
}
|
|
@ -0,0 +1,239 @@
|
||||||
|
package com.dpkj.modules.readcard.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dpkj.common.constant.LexMarkConst;
|
||||||
|
import com.dpkj.common.dto.LexMarkDTO;
|
||||||
|
import com.dpkj.common.utils.ThirdService;
|
||||||
|
import com.dpkj.common.utils.ThirdServiceUtil;
|
||||||
|
import com.dpkj.common.vo.Result;
|
||||||
|
import com.dpkj.modules.readcard.constant.ReadCardConst;
|
||||||
|
import com.dpkj.modules.readcard.service.ReadCardService;
|
||||||
|
import com.dpkj.modules.readcard.vo.IDCardReadResultVO;
|
||||||
|
import com.dpkj.modules.readcard.vo.SocialSecurityCardInfoVO;
|
||||||
|
import com.dpkj.modules.readcard.vo.UserInfoVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: 银医通-澜沧中医院-DLL-台式机
|
||||||
|
* @BelongsPackage: com.dpkj.modules.readcard.service.impl
|
||||||
|
* @Author: wzc
|
||||||
|
* @Description:
|
||||||
|
* @CreateTime: 2025-02-07 10:21
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class ReadCardServiceImpl implements ReadCardService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdService thirdService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThirdServiceUtil thirdServiceUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证读取
|
||||||
|
* 1. 连接身份证读取设备
|
||||||
|
* 2. 非接触身份证读取
|
||||||
|
* 3. 关闭设备
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result IDCardReader() {
|
||||||
|
Result result = null;
|
||||||
|
try {
|
||||||
|
// 连接非接身份证读卡模块
|
||||||
|
LexMarkDTO connect = new LexMarkDTO();
|
||||||
|
connect.setActionName(ReadCardConst.OPEN_CONNECTION);
|
||||||
|
connect.setCallID(19256);
|
||||||
|
connect.setDevName(LexMarkConst.ID_CARD_READ);
|
||||||
|
JSONObject connectParam = new JSONObject();
|
||||||
|
connectParam.put("TimeOut", 30000);
|
||||||
|
connectParam.put("ServiceName", LexMarkConst.ID_CARD_READ);
|
||||||
|
connect.setParam(connectParam.toJSONString());
|
||||||
|
IDCardReadResultVO connectResult = thirdServiceUtil.callDevice(connect, IDCardReadResultVO.class);
|
||||||
|
if (connectResult.getResult() == 0) {
|
||||||
|
// 身份证读取
|
||||||
|
LexMarkDTO read = new LexMarkDTO();
|
||||||
|
read.setActionName(ReadCardConst.ACCEPT_AND_READ_TRACKS);
|
||||||
|
read.setCallID(19256);
|
||||||
|
read.setDevName(LexMarkConst.ID_CARD_READ);
|
||||||
|
JSONObject readParam = new JSONObject();
|
||||||
|
readParam.put("TimeOut", 0);
|
||||||
|
readParam.put("TrackMap", 776);
|
||||||
|
read.setParam(readParam.toJSONString());
|
||||||
|
IDCardReadResultVO readResult = thirdServiceUtil.callDevice(read, IDCardReadResultVO.class);
|
||||||
|
if (readResult.getResult() == 0) {
|
||||||
|
IDCardReadResultVO.Param resultParam = JSON.parseObject(readResult.getParam().toString(), IDCardReadResultVO.Param.class);
|
||||||
|
if (resultParam.getResult() == 0) {
|
||||||
|
UserInfoVO userInfoVO = new UserInfoVO();
|
||||||
|
// 身份证基本信息 解析
|
||||||
|
String[] array = Stream.of(resultParam.getChipdata().getDatas().split("\\|"))
|
||||||
|
.filter(pair -> pair.contains("="))
|
||||||
|
.map(pair -> pair.split("=")[1])
|
||||||
|
.toArray(String[]::new);
|
||||||
|
userInfoVO.setName(array[0]);
|
||||||
|
userInfoVO.setSex(array[1]);
|
||||||
|
userInfoVO.setNation(array[2]);
|
||||||
|
userInfoVO.setBorn(array[3]);
|
||||||
|
userInfoVO.setAddress(array[4]);
|
||||||
|
userInfoVO.setIDCardNo(array[5]);
|
||||||
|
userInfoVO.setGrantDept(array[6]);
|
||||||
|
userInfoVO.setUserLifeBegin(array[7]);
|
||||||
|
userInfoVO.setUserLifeEnd(array[8]);
|
||||||
|
userInfoVO.setIDhead(array[9]);
|
||||||
|
// 正面
|
||||||
|
userInfoVO.setFrontimage(resultParam.getFrontimage().getDatas());
|
||||||
|
// 反面
|
||||||
|
userInfoVO.setBackimage(resultParam.getBackimage().getDatas());
|
||||||
|
result = Result.ok(userInfoVO);
|
||||||
|
} else {
|
||||||
|
result = Result.error("身份证读取失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = Result.error(readResult.getDesc());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = Result.error(connectResult.getDesc());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 关闭身份证读卡设备
|
||||||
|
LexMarkDTO close = new LexMarkDTO();
|
||||||
|
close.setDevName(LexMarkConst.ID_CARD_READ);
|
||||||
|
close.setCallID(0);
|
||||||
|
close.setActionName(ReadCardConst.CLOSE_CONNECTION);
|
||||||
|
IDCardReadResultVO closeResult = thirdServiceUtil.callDevice(close, IDCardReadResultVO.class);
|
||||||
|
if (closeResult.getResult() != 0) {
|
||||||
|
log.info("身份证读卡设备关闭异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取
|
||||||
|
* 1. 连接社保卡读取设备
|
||||||
|
* 2. 进卡读卡
|
||||||
|
* 3. 读卡器上电
|
||||||
|
* 4. 社保卡信息读取
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result SocialSecurityCardReader() {
|
||||||
|
// 社保卡读卡设备连接
|
||||||
|
LexMarkDTO connect = new LexMarkDTO();
|
||||||
|
connect.setActionName(ReadCardConst.OPEN_CONNECTION);
|
||||||
|
connect.setCallID(19256);
|
||||||
|
connect.setDevName(LexMarkConst.CARD_READER);
|
||||||
|
JSONObject connectParam = new JSONObject();
|
||||||
|
connectParam.put("TimeOut", 30000);
|
||||||
|
connectParam.put("ServiceName", LexMarkConst.CARD_READER);
|
||||||
|
connect.setParam(connectParam.toJSONString());
|
||||||
|
IDCardReadResultVO connectResult = thirdServiceUtil.callDevice(connect, IDCardReadResultVO.class);
|
||||||
|
if (connectResult.getResult() == 0) {
|
||||||
|
// 进卡
|
||||||
|
LexMarkDTO enterTheCard = new LexMarkDTO();
|
||||||
|
enterTheCard.setActionName(ReadCardConst.ACCEPT_AND_READ_TRACKS);
|
||||||
|
enterTheCard.setCallID(19256);
|
||||||
|
enterTheCard.setDevName(LexMarkConst.CARD_READER);
|
||||||
|
JSONObject enterTheCardParam = new JSONObject();
|
||||||
|
enterTheCardParam.put("DevType", 5);
|
||||||
|
enterTheCardParam.put("TrackMap", 11);
|
||||||
|
enterTheCardParam.put("TimeOut", 0);
|
||||||
|
enterTheCard.setParam(enterTheCardParam.toJSONString());
|
||||||
|
IDCardReadResultVO enterTheCardResult = thirdServiceUtil.callDevice(enterTheCard, IDCardReadResultVO.class);
|
||||||
|
if (enterTheCardResult.getResult() == 0) {
|
||||||
|
// 上电
|
||||||
|
LexMarkDTO powerOn = new LexMarkDTO();
|
||||||
|
powerOn.setActionName(ReadCardConst.CHIPPOWER);
|
||||||
|
powerOn.setCallID(19256);
|
||||||
|
powerOn.setDevName(LexMarkConst.CARD_READER);
|
||||||
|
JSONObject powerOnParam = new JSONObject();
|
||||||
|
powerOnParam.put("PsamNo", 1);
|
||||||
|
powerOnParam.put("ChipAction", 2);
|
||||||
|
powerOn.setParam(powerOnParam.toJSONString());
|
||||||
|
IDCardReadResultVO powerOnResult = thirdServiceUtil.callDevice(powerOn, IDCardReadResultVO.class);
|
||||||
|
if (powerOnResult.getResult() == 0) {
|
||||||
|
// 社保卡信息读取
|
||||||
|
LexMarkDTO socialSecurityCardReader = new LexMarkDTO();
|
||||||
|
socialSecurityCardReader.setActionName(ReadCardConst.I_READ_CARD_BAS);
|
||||||
|
socialSecurityCardReader.setCallID(19256);
|
||||||
|
socialSecurityCardReader.setDevName(LexMarkConst.CARD_READER);
|
||||||
|
JSONObject socialSecurityCardReaderParam = new JSONObject();
|
||||||
|
socialSecurityCardReaderParam.put("iType", 3);
|
||||||
|
socialSecurityCardReader.setParam(socialSecurityCardReaderParam.toJSONString());
|
||||||
|
IDCardReadResultVO socialSecurityCardReaderResult = thirdServiceUtil.callDevice(socialSecurityCardReader, IDCardReadResultVO.class);
|
||||||
|
if (socialSecurityCardReaderResult.getResult() == 0) {
|
||||||
|
// 社保信息
|
||||||
|
IDCardReadResultVO.SocialSecurityCard resultParam = JSON.parseObject(socialSecurityCardReaderResult.getParam().toString(), IDCardReadResultVO.SocialSecurityCard.class);
|
||||||
|
String[] split = resultParam.getRerurnData().split("\\|");
|
||||||
|
SocialSecurityCardInfoVO socialSecurityCardInfoVO = new SocialSecurityCardInfoVO();
|
||||||
|
// 区号代码截取
|
||||||
|
socialSecurityCardInfoVO.setAreaCode(split[0].substring(split[0].length() - 6));
|
||||||
|
socialSecurityCardInfoVO.setSocialSecurityNo(split[1]);
|
||||||
|
socialSecurityCardInfoVO.setCardNumber(split[2]);
|
||||||
|
socialSecurityCardInfoVO.setIdentificationCode(split[3]);
|
||||||
|
socialSecurityCardInfoVO.setName(split[4]);
|
||||||
|
socialSecurityCardInfoVO.setCardResetInformation(split[5]);
|
||||||
|
socialSecurityCardInfoVO.setSpecificationVersion(split[6]);
|
||||||
|
socialSecurityCardInfoVO.setIssuanceDate(split[7]);
|
||||||
|
socialSecurityCardInfoVO.setExpireDate(split[8]);
|
||||||
|
socialSecurityCardInfoVO.setTerminalNumber(split[9]);
|
||||||
|
socialSecurityCardInfoVO.setTerminalDeviceNumber(split[10]);
|
||||||
|
return Result.ok(socialSecurityCardInfoVO);
|
||||||
|
} else {
|
||||||
|
return Result.error("社保卡信息读取失败!详情:" + socialSecurityCardReaderResult.getDesc());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Result.error("社保卡读取设备上电失败!详情:" + powerOnResult.getDesc());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Result.error("社保卡读取设备进卡失败!详情:" + enterTheCardResult.getDesc());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Result.error("社保卡读取设备连接失败!详情:" + connectResult.getDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退卡并关闭设备
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result cardRefund() {
|
||||||
|
// 社保卡退卡
|
||||||
|
LexMarkDTO cardRefund = new LexMarkDTO();
|
||||||
|
cardRefund.setDevName(LexMarkConst.CARD_READER);
|
||||||
|
cardRefund.setCallID(19256);
|
||||||
|
cardRefund.setActionName(ReadCardConst.EJECT);
|
||||||
|
JSONObject cardRefundParam = new JSONObject();
|
||||||
|
cardRefundParam.put("position", 1);
|
||||||
|
cardRefundParam.put("ejectpos", 1);
|
||||||
|
cardRefund.setParam(cardRefundParam.toJSONString());
|
||||||
|
IDCardReadResultVO cardRefundResult = thirdServiceUtil.callDevice(cardRefund, IDCardReadResultVO.class);
|
||||||
|
if (cardRefundResult.getResult() == 0) {
|
||||||
|
// 退卡成功再关闭社保卡读卡设备
|
||||||
|
LexMarkDTO close = new LexMarkDTO();
|
||||||
|
close.setDevName(LexMarkConst.CARD_READER);
|
||||||
|
close.setCallID(0);
|
||||||
|
close.setActionName(ReadCardConst.CLOSE_CONNECTION);
|
||||||
|
IDCardReadResultVO closeResult = thirdServiceUtil.callDevice(close, IDCardReadResultVO.class);
|
||||||
|
if (closeResult.getResult() != 0) {
|
||||||
|
log.info("社保卡读卡设备关闭异常!");
|
||||||
|
}
|
||||||
|
return Result.ok("退卡成功!");
|
||||||
|
} else {
|
||||||
|
return Result.error("退卡失败!请联系工作人员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
package com.dpkj.modules.readcard.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证读取模块返回值
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class IDCardReadResultVO<T> implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应发送请求中的devName
|
||||||
|
*/
|
||||||
|
private String devName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件名,由发送请求中的actionName+Over组成。
|
||||||
|
*/
|
||||||
|
private String msgName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应发送请求的callID。
|
||||||
|
*/
|
||||||
|
private int callID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误码:0表示成功;其他表示失败,比如-4表示取消,-48表示超时,-14表示硬件故障
|
||||||
|
*/
|
||||||
|
private int result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送请求中的actionName
|
||||||
|
*/
|
||||||
|
private String cmdName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回参数
|
||||||
|
*/
|
||||||
|
private T param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class Param {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求ID
|
||||||
|
*/
|
||||||
|
private int RequestID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证反面图像数据
|
||||||
|
*/
|
||||||
|
private Backimage backimage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证基础信息
|
||||||
|
*/
|
||||||
|
private Chipdata chipdata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指令ID
|
||||||
|
*/
|
||||||
|
private int dwCommandCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束事件名称
|
||||||
|
*/
|
||||||
|
private String AcceptAndReadTracksOver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件ID
|
||||||
|
*/
|
||||||
|
private int eventType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证正面图像数据
|
||||||
|
*/
|
||||||
|
private Frontimage frontimage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务ID
|
||||||
|
*/
|
||||||
|
private int hService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取结果 0成功 <0失败
|
||||||
|
*/
|
||||||
|
private int result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用的方法名称(操作函数)
|
||||||
|
*/
|
||||||
|
private String cmdName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class Backimage {
|
||||||
|
/**
|
||||||
|
* 身份证反面图像存储路径
|
||||||
|
*/
|
||||||
|
private String datas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据长度
|
||||||
|
*/
|
||||||
|
private int len;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回的数据状态
|
||||||
|
* DATAOK 读取正常
|
||||||
|
* BLANK 空
|
||||||
|
* INVALID 无效
|
||||||
|
* NOTREAD 未读取
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class Frontimage {
|
||||||
|
/**
|
||||||
|
* 身份证正面图像存储路径
|
||||||
|
*/
|
||||||
|
private String datas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据长度
|
||||||
|
*/
|
||||||
|
private int len;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回的数据状态
|
||||||
|
* DATAOK 读取正常
|
||||||
|
* BLANK 空
|
||||||
|
* INVALID 无效
|
||||||
|
* NOTREAD 未读取
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class Chipdata {
|
||||||
|
/**
|
||||||
|
* 身份证基本信息
|
||||||
|
*/
|
||||||
|
private String datas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据长度
|
||||||
|
*/
|
||||||
|
private int len;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回的数据状态
|
||||||
|
* DATAOK 读取正常
|
||||||
|
* BLANK 空
|
||||||
|
* INVALID 无效
|
||||||
|
* NOTREAD 未读取
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class SocialSecurityCard {
|
||||||
|
/**
|
||||||
|
* 社保卡基本信息
|
||||||
|
*/
|
||||||
|
private String RerurnData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取响应信息
|
||||||
|
*/
|
||||||
|
private String msgerror;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡读取响应结果 0成功 <0失败
|
||||||
|
*/
|
||||||
|
private int result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用的方法
|
||||||
|
*/
|
||||||
|
private String cmdName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.dpkj.modules.readcard.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社保卡信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SocialSecurityCardInfoVO {
|
||||||
|
// 发卡地区行政区划代码
|
||||||
|
private String areaCode;
|
||||||
|
// 社会保障号码
|
||||||
|
private String socialSecurityNo;
|
||||||
|
// 卡号
|
||||||
|
private String cardNumber;
|
||||||
|
// 卡识别码
|
||||||
|
private String identificationCode;
|
||||||
|
// 姓名
|
||||||
|
private String name;
|
||||||
|
// 卡复位信息
|
||||||
|
private String cardResetInformation;
|
||||||
|
// 规范版本
|
||||||
|
private String specificationVersion;
|
||||||
|
// 发卡日期
|
||||||
|
private String issuanceDate;
|
||||||
|
// 卡有效期
|
||||||
|
private String expireDate;
|
||||||
|
// 终端机编号
|
||||||
|
private String terminalNumber;
|
||||||
|
// 终端设备号
|
||||||
|
private String terminalDeviceNumber;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.dpkj.modules.readcard.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证读取信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserInfoVO {
|
||||||
|
// 姓名
|
||||||
|
private String name;
|
||||||
|
// 性别
|
||||||
|
private String sex;
|
||||||
|
// 名族
|
||||||
|
private String nation;
|
||||||
|
// 出生年月
|
||||||
|
private String born;
|
||||||
|
// 地址
|
||||||
|
private String address;
|
||||||
|
// 身份证号
|
||||||
|
private String IDCardNo;
|
||||||
|
// 签发机关
|
||||||
|
private String grantDept;
|
||||||
|
// 有效期起始日期
|
||||||
|
private String userLifeBegin;
|
||||||
|
// 有效期截止日期
|
||||||
|
private String userLifeEnd;
|
||||||
|
// 头像照片存储位置
|
||||||
|
private String IDhead;
|
||||||
|
// 证件正面照存储位置
|
||||||
|
private String frontimage;
|
||||||
|
// 证件反面面照存储位置
|
||||||
|
private String backimage;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue