密码键盘调用操作日志记录格式调整
This commit is contained in:
parent
f088a42aff
commit
5c34a03e7f
|
@ -47,9 +47,9 @@ public class KeypadServiceImpl implements KeypadService {
|
||||||
status.setActionName(MiddlewareFunctionsConst.GET_STATUS_SYNC);
|
status.setActionName(MiddlewareFunctionsConst.GET_STATUS_SYNC);
|
||||||
JSONObject statusParam = new JSONObject();
|
JSONObject statusParam = new JSONObject();
|
||||||
statusParam.put("timeout", 0);
|
statusParam.put("timeout", 0);
|
||||||
log.info("获取设备状态,参数: {}", status);
|
log.info("[KeypadServiceImpl][inputData][50]: 获取设备状态,参数: {}", status);
|
||||||
IDCardReadResultVO statusResult = thirdServiceUtil.callDevice(status, IDCardReadResultVO.class);
|
IDCardReadResultVO statusResult = thirdServiceUtil.callDevice(status, IDCardReadResultVO.class);
|
||||||
log.info("获取设备状态结果: {}", statusResult);
|
log.info("[KeypadServiceImpl][inputData][52]: 获取设备状态结果: {}", statusResult);
|
||||||
if (statusResult.getResult() == 0) {
|
if (statusResult.getResult() == 0) {
|
||||||
// 连接状态,初始化
|
// 连接状态,初始化
|
||||||
LexMarkDTO reset = new LexMarkDTO();
|
LexMarkDTO reset = new LexMarkDTO();
|
||||||
|
@ -58,29 +58,30 @@ public class KeypadServiceImpl implements KeypadService {
|
||||||
reset.setActionName(MiddlewareFunctionsConst.RESET);
|
reset.setActionName(MiddlewareFunctionsConst.RESET);
|
||||||
JSONObject resetParam = new JSONObject();
|
JSONObject resetParam = new JSONObject();
|
||||||
resetParam.put("ResetAction", 1);
|
resetParam.put("ResetAction", 1);
|
||||||
log.info("调用复位(初始化)方法,参数: {}", reset);
|
log.info("[KeypadServiceImpl][inputData][61]: 调用复位(初始化)方法,参数: {}", reset);
|
||||||
IDCardReadResultVO resetResult = thirdServiceUtil.callDevice(reset, IDCardReadResultVO.class);
|
IDCardReadResultVO resetResult = thirdServiceUtil.callDevice(reset, IDCardReadResultVO.class);
|
||||||
log.info("设备复位(初始化)结果: {}", resetResult);
|
log.info("[KeypadServiceImpl][inputData][63]: 设备复位(初始化)结果: {}", resetResult);
|
||||||
if (resetResult.getResult() == 0) {
|
if (resetResult.getResult() == 0) {
|
||||||
// 复位成功
|
// 复位成功
|
||||||
result = connectAndInputData(result);
|
result = connectAndInputData(result);
|
||||||
} else {
|
} else {
|
||||||
result = Result.error("密码键盘(初始化)异常,详情:" + ErrorCodeConstants.COMMON_ERROR_CODE.get(resetResult.getResult()));
|
result = Result.error(ErrorCodeConstants.COMMON_ERROR_CODE.get(resetResult.getResult()));
|
||||||
log.info("密码键盘(初始化)异常,详情:{}", ErrorCodeConstants.COMMON_ERROR_CODE.get(resetResult.getResult()));
|
log.info("[KeypadServiceImpl][inputData][69]: 密码键盘(初始化)异常,详情:{}",
|
||||||
|
ErrorCodeConstants.COMMON_ERROR_CODE.get(resetResult.getResult()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 设备未连接,无需复位(初始化)
|
// 设备未连接,无需复位(初始化)
|
||||||
result = connectAndInputData(result);
|
result = connectAndInputData(result);
|
||||||
}
|
}
|
||||||
log.info("密码输入流程结束,最终返回结果: {}", result);
|
log.info("[KeypadServiceImpl][inputData][76]: 密码输入流程结束,最终返回结果: {}", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result connectAndInputData(Result result){
|
public Result connectAndInputData(Result result){
|
||||||
log.info("开始执行密码输入流程");
|
log.info("[KeypadServiceImpl][connectAndInputData][81]: {}", "开始执行密码输入流程");
|
||||||
|
|
||||||
// 连接数字键盘
|
// 连接数字键盘
|
||||||
log.info("准备连接数字键盘设备");
|
log.info("[KeypadServiceImpl][connectAndInputData][84]: {}", "准备连接数字键盘设备");
|
||||||
LexMarkDTO connect = new LexMarkDTO();
|
LexMarkDTO connect = new LexMarkDTO();
|
||||||
connect.setDevName(LexMarkConst.ENCRYPTOR);
|
connect.setDevName(LexMarkConst.ENCRYPTOR);
|
||||||
connect.setActionName(MiddlewareFunctionsConst.OPEN_CONNECTION);
|
connect.setActionName(MiddlewareFunctionsConst.OPEN_CONNECTION);
|
||||||
|
@ -89,14 +90,14 @@ public class KeypadServiceImpl implements KeypadService {
|
||||||
connectParam.put("TimeOut", 30000);
|
connectParam.put("TimeOut", 30000);
|
||||||
connectParam.put("ServiceName", LexMarkConst.ENCRYPTOR);
|
connectParam.put("ServiceName", LexMarkConst.ENCRYPTOR);
|
||||||
connect.setParam(connectParam.toJSONString());
|
connect.setParam(connectParam.toJSONString());
|
||||||
log.info("调用设备连接方法,参数: {}", connect);
|
log.info("[KeypadServiceImpl][connectAndInputData][93]: {}", "调用设备连接方法,参数: {}", connect);
|
||||||
IDCardReadResultVO connectResult = thirdServiceUtil.callDevice(connect, IDCardReadResultVO.class);
|
IDCardReadResultVO connectResult = thirdServiceUtil.callDevice(connect, IDCardReadResultVO.class);
|
||||||
log.info("设备连接结果: {}", connectResult);
|
log.info("[KeypadServiceImpl][connectAndInputData][95]: 设备连接结果: {}", connectResult);
|
||||||
|
|
||||||
WebSocketClient webSocketClient = null;
|
WebSocketClient webSocketClient = null;
|
||||||
try {
|
try {
|
||||||
if (connectResult.getResult() == 0) {
|
if (connectResult.getResult() == 0) {
|
||||||
log.info("数字键盘设备连接成功,准备进行明文输入");
|
log.info("[KeypadServiceImpl][connectAndInputData][100]: {}", "数字键盘设备连接成功,准备进行明文输入");
|
||||||
|
|
||||||
// 明文输入
|
// 明文输入
|
||||||
LexMarkDTO plaintext = new LexMarkDTO();
|
LexMarkDTO plaintext = new LexMarkDTO();
|
||||||
|
@ -116,58 +117,61 @@ public class KeypadServiceImpl implements KeypadService {
|
||||||
plaintextParam.put("ActiveKeys", 81919);
|
plaintextParam.put("ActiveKeys", 81919);
|
||||||
plaintextParam.put("TerminateKeys", 1024);
|
plaintextParam.put("TerminateKeys", 1024);
|
||||||
plaintext.setParam(plaintextParam.toJSONString());
|
plaintext.setParam(plaintextParam.toJSONString());
|
||||||
log.info("调用明文输入方法,参数: {}", plaintext);
|
log.info("[KeypadServiceImpl][connectAndInputData][120]: 调用明文输入方法,参数: {}", plaintext);
|
||||||
|
|
||||||
// 创建 WebSocket 客户端
|
// 创建 WebSocket 客户端
|
||||||
log.info("创建 WebSocket 客户端,连接地址: ws://127.0.0.1:12347");
|
log.info("[KeypadServiceImpl][connectAndInputData][123]: {}", "创建 WebSocket 客户端,连接地址: ws://127.0.0.1:12347");
|
||||||
webSocketClient = new WebSocketClient("ws://127.0.0.1:12347");
|
webSocketClient = new WebSocketClient("ws://127.0.0.1:12347");
|
||||||
|
|
||||||
IDCardReadResultVO plaintextResult = thirdServiceUtil.callDevice(plaintext, IDCardReadResultVO.class);
|
IDCardReadResultVO plaintextResult = thirdServiceUtil.callDevice(plaintext, IDCardReadResultVO.class);
|
||||||
log.info("明文输入操作结果: {}", plaintextResult);
|
log.info("[KeypadServiceImpl][connectAndInputData][127]: 明文输入操作结果: {}", plaintextResult);
|
||||||
|
|
||||||
if (plaintextResult.getResult() == 0) {
|
if (plaintextResult.getResult() == 0) {
|
||||||
log.info("明文输入成功,开始等待确认");
|
log.info("[KeypadServiceImpl][connectAndInputData][130]: {}", "明文输入成功,开始等待确认");
|
||||||
try {
|
try {
|
||||||
// 适当延长等待时间
|
// 适当延长等待时间
|
||||||
while (true) {
|
while (true) {
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
Boolean confirm = webSocketClient.getConfirm();
|
Boolean confirm = webSocketClient.getConfirm();
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
log.info("收到确认信息,结束等待");
|
log.info("[KeypadServiceImpl][connectAndInputData][137]: {}", "收到确认信息,结束等待");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
log.error("等待确认信息时被中断", e);
|
log.info("[KeypadServiceImpl][connectAndInputData][142]: 等待确认信息时被中断{}", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String password = webSocketClient.getPassword();
|
String password = webSocketClient.getPassword();
|
||||||
log.info("密码输入完成,密码为: {}", password);
|
log.info("[KeypadServiceImpl][connectAndInputData][146]: 密码输入完成,密码为: {}", password);
|
||||||
result = Result.ok("密码输入完成!", password);
|
result = Result.ok("密码输入完成!", password);
|
||||||
} else {
|
} else {
|
||||||
log.error("密码输入异常!详情:{}", ErrorCodeConstants.COMMON_ERROR_CODE.get(plaintextResult.getResult()));
|
log.info("[KeypadServiceImpl][connectAndInputData][149]: 密码输入异常!详情:{}",
|
||||||
result = Result.error("密码输入异常!详情:" + ErrorCodeConstants.COMMON_ERROR_CODE.get(plaintextResult.getResult()));
|
ErrorCodeConstants.COMMON_ERROR_CODE.get(plaintextResult.getResult()));
|
||||||
|
result = Result.error(ErrorCodeConstants.COMMON_ERROR_CODE.get(plaintextResult.getResult()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("数字键盘设备连接失败!详情:{}", ErrorCodeConstants.COMMON_ERROR_CODE.get(connectResult.getResult()));
|
log.info("[KeypadServiceImpl][connectAndInputData][154]: 数字键盘设备连接失败!详情:{}",
|
||||||
result = Result.error("数字键盘设备连接失败!详情:" + ErrorCodeConstants.COMMON_ERROR_CODE.get(connectResult.getResult()));
|
ErrorCodeConstants.COMMON_ERROR_CODE.get(connectResult.getResult()));
|
||||||
|
result = Result.error(ErrorCodeConstants.COMMON_ERROR_CODE.get(connectResult.getResult()));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (webSocketClient != null) {
|
if (webSocketClient != null) {
|
||||||
log.info("关闭 WebSocket 客户端");
|
log.info("[KeypadServiceImpl][connectAndInputData][160]: {}", "关闭 WebSocket 客户端");
|
||||||
webSocketClient.close();
|
webSocketClient.close();
|
||||||
}
|
}
|
||||||
// 关闭身份证读卡设备
|
// 关闭身份证读卡设备
|
||||||
log.info("准备关闭数字键盘设备");
|
log.info("[KeypadServiceImpl][connectAndInputData][164]: {}", "准备关闭数字键盘设备");
|
||||||
LexMarkDTO close = new LexMarkDTO();
|
LexMarkDTO close = new LexMarkDTO();
|
||||||
close.setDevName(LexMarkConst.ENCRYPTOR);
|
close.setDevName(LexMarkConst.ENCRYPTOR);
|
||||||
close.setCallID(0);
|
close.setCallID(0);
|
||||||
close.setActionName(MiddlewareFunctionsConst.CLOSE_CONNECTION);
|
close.setActionName(MiddlewareFunctionsConst.CLOSE_CONNECTION);
|
||||||
log.info("调用设备关闭方法,参数: {}", close);
|
log.info("[KeypadServiceImpl][connectAndInputData][169]: 调用设备关闭方法,参数: {}", close);
|
||||||
IDCardReadResultVO closeResult = thirdServiceUtil.callDevice(close, IDCardReadResultVO.class);
|
IDCardReadResultVO closeResult = thirdServiceUtil.callDevice(close, IDCardReadResultVO.class);
|
||||||
log.info("设备关闭结果: {}", closeResult);
|
log.info("[KeypadServiceImpl][connectAndInputData][171]: 设备关闭结果: {}", closeResult);
|
||||||
if (closeResult.getResult() != 0) {
|
if (closeResult.getResult() != 0) {
|
||||||
log.error("数字键盘设备关闭异常!详情:{}", ErrorCodeConstants.COMMON_ERROR_CODE.get(closeResult.getResult()));
|
log.info("[KeypadServiceImpl][connectAndInputData][173]: 数字键盘设备关闭异常!详情:{}",
|
||||||
|
ErrorCodeConstants.COMMON_ERROR_CODE.get(closeResult.getResult()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -188,7 +192,7 @@ public class KeypadServiceImpl implements KeypadService {
|
||||||
if (connectResult.getResult() == 0) {
|
if (connectResult.getResult() == 0) {
|
||||||
return Result.ok("取消输入 (明文或者密文)完成!");
|
return Result.ok("取消输入 (明文或者密文)完成!");
|
||||||
} else {
|
} else {
|
||||||
return Result.error("取消输入 (明文或者密文)异常!详情:" + connectResult.getDesc());
|
return Result.error(connectResult.getDesc());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue