|
|
@@ -17,6 +17,7 @@ import com.bumptech.glide.Glide; |
|
|
|
import com.google.gson.JsonParseException; |
|
|
|
import com.google.gson.internal.LinkedTreeMap; |
|
|
|
import com.huntersun.vkyes.etcopencard.R; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.bluetooth.BluetoothDialog; |
|
|
|
import com.huntersun.vkyes.etcopencard.databinding.ActivityLogoutEtcStep3Binding; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.MyRetrofit; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.Result; |
|
|
@@ -189,9 +190,9 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
binding.lyBackfeeInfo.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
// 注销原因固定为"其他",只显示输入框内容 |
|
|
|
binding.LLInputReason.setVisibility(View.VISIBLE); |
|
|
|
binding.tvReason.setText("其他"); |
|
|
|
binding.etReason.setText(etReason); |
|
|
|
binding.LLInputReason.setVisibility(View.VISIBLE); |
|
|
|
binding.tvReason.setText("其他"); |
|
|
|
binding.etReason.setText(etReason); |
|
|
|
|
|
|
|
// 隐藏下拉选择部分 |
|
|
|
binding.LLReason.setVisibility(View.GONE); |
|
|
@@ -463,14 +464,15 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
@Override |
|
|
|
public void success() { |
|
|
|
Log.i(this.getClass().getSimpleName(), "蓝牙连接成功,开始执行注销指令"); |
|
|
|
// 蓝牙连接成功,执行注销指令 |
|
|
|
// 普通设备连接成功,执行注销指令 |
|
|
|
executeLogoutCommand(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void success9901(int isPlk) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "9901设备连接成功,开始执行注销指令"); |
|
|
|
Log.i(this.getClass().getSimpleName(), "9901设备连接成功,设备类型: " + isPlk + ",开始执行注销指令"); |
|
|
|
// 9901设备连接成功,执行注销指令 |
|
|
|
// 注意:BluetoothDialog.Builder.transCmd 内部会直接使用 isPlk,无需额外设置 |
|
|
|
executeLogoutCommand(); |
|
|
|
} |
|
|
|
|
|
|
@@ -548,9 +550,9 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
e.printStackTrace(); |
|
|
|
ToastUtils.show("解析指令初始化响应失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError(Response<Result> resp) { |
|
|
|
hideDialog(); |
|
|
|
Log.e(this.getClass().getSimpleName(), "指令初始化失败: " + (resp != null ? resp.message() : "未知错误")); |
|
|
@@ -565,29 +567,15 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
private void executeWriteCard(String command, String cmdType, String transOrderId) { |
|
|
|
showDialog("正在执行注销指令..."); |
|
|
|
|
|
|
|
try { |
|
|
|
Log.i(this.getClass().getSimpleName(), "开始执行写卡操作 - command: " + command + ", transOrderId: " + transOrderId); |
|
|
|
|
|
|
|
// 根据指令类型执行不同的操作 |
|
|
|
String result; |
|
|
|
if ("CARD".equals(cmdType)) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行卡指令"); |
|
|
|
result = writeCard(command); |
|
|
|
} else { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行OBU指令"); |
|
|
|
result = writeObu(command); |
|
|
|
} |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "指令执行完成,结果: " + result); |
|
|
|
|
|
|
|
// 第三步:回传指令结果 |
|
|
|
callbackLogoutCommand(command, transOrderId, result); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
hideDialog(); |
|
|
|
Log.e(this.getClass().getSimpleName(), "写卡操作失败: " + e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
ToastUtils.show("写卡操作失败"); |
|
|
|
Log.i(this.getClass().getSimpleName(), "开始执行写卡操作 - command: " + command + ", transOrderId: " + transOrderId); |
|
|
|
|
|
|
|
// 根据指令类型执行不同的操作 |
|
|
|
if ("CARD".equals(cmdType)) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行卡指令"); |
|
|
|
writeCard(command, transOrderId); |
|
|
|
} else { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行OBU指令"); |
|
|
|
writeObu(command, transOrderId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -608,7 +596,7 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令回传 当前步骤:" + currentStepNo + ", 指令:" + command + ", 指令编号:" + transOrderId + ", 指令结果:" + result); |
|
|
|
|
|
|
|
MyRetrofit.newInstanceGZ(this, IFCode.IFCODE_DEVICE_CANCEL_INST_CALLBACK, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
hideDialog(); |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令回传 响应数据:" + JSONObject.toJSONString(resultBean)); |
|
|
@@ -655,121 +643,81 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
hideDialog(); |
|
|
|
Log.e(this.getClass().getSimpleName(), "指令回传失败: " + (resp != null ? resp.message() : "未知错误")); |
|
|
|
ToastUtils.show("指令回传失败"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 写卡操作(支持多条指令,用逗号分隔) |
|
|
|
* 参考:BluetoothWriteCardWriteTab.writeCard() |
|
|
|
* 使用"普通"方式:BluetoothDialog.Builder.transCmd |
|
|
|
*/ |
|
|
|
private String writeCard(String commands) { |
|
|
|
private void writeCard(String commands, String transOrderId) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "开始写卡操作,指令: " + commands); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 确保MethodManager已初始化 |
|
|
|
if (MethodManager.getCls() == null) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "MethodManager未初始化,开始初始化"); |
|
|
|
MethodManager.initData("com.huntersun.vky.obublelib.box.BoxManagers"); |
|
|
|
if (MethodManager.getCls() == null) { |
|
|
|
Log.e(this.getClass().getSimpleName(), "MethodManager初始化失败"); |
|
|
|
throw new RuntimeException("MethodManager初始化失败"); |
|
|
|
} |
|
|
|
Log.i(this.getClass().getSimpleName(), "MethodManager初始化成功"); |
|
|
|
} |
|
|
|
|
|
|
|
// 分割多条指令 |
|
|
|
String[] commands_arry = commands.split(","); |
|
|
|
String[] results = new String[commands_arry.length]; |
|
|
|
int len = results.length; |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "指令总数: " + len); |
|
|
|
|
|
|
|
// 逐条执行指令,先收集所有结果 |
|
|
|
for (int i = 0; i < len; i++) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行第 " + (i + 1) + " 条指令: " + commands_arry[i]); |
|
|
|
|
|
|
|
// 透传写卡指令 |
|
|
|
ServiceStatus resp_string = MethodManager.sendApduICC(commands_arry[i]); |
|
|
|
results[i] = resp_string.getServiceInfo(); |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "第 " + (i + 1) + " 条指令执行结果: " + results[i] + ", 状态码: " + resp_string.getServiceCode()); |
|
|
|
} |
|
|
|
|
|
|
|
// 拼接结果 |
|
|
|
StringBuilder buffer = new StringBuilder(); |
|
|
|
for (int i = 0; i < len; i++) { |
|
|
|
buffer.append(results[i]); |
|
|
|
if (i != len - 1) { |
|
|
|
buffer.append(","); |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令总数: " + commands_arry.length); |
|
|
|
|
|
|
|
// 使用"普通"方式:BluetoothDialog.Builder.transCmd |
|
|
|
// 这个方法内部会直接使用 isPlk 变量,无需额外设置 |
|
|
|
// 直接传递整个指令数组,不需要 for 循环 |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行指令数组: " + java.util.Arrays.toString(commands_arry)); |
|
|
|
|
|
|
|
// 使用 BluetoothDialog.Builder.transCmd,传递 "10" 表示IC卡操作 |
|
|
|
BluetoothDialog.Builder.transCmd(commands_arry, "10", new BluetoothDialog.PerformCmdCallBack() { |
|
|
|
@Override |
|
|
|
public void performOnSuccess(String[] strings) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令执行成功: " + java.util.Arrays.toString(strings)); |
|
|
|
String result = String.join(",", strings); |
|
|
|
Log.i(this.getClass().getSimpleName(), "写卡操作完成,最终结果: " + result); |
|
|
|
// 第三步:回传指令结果 |
|
|
|
callbackLogoutCommand(commands, transOrderId, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String finalResult = buffer.toString(); |
|
|
|
Log.i(this.getClass().getSimpleName(), "写卡操作完成,最终结果: " + finalResult); |
|
|
|
return finalResult; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
Log.e(this.getClass().getSimpleName(), "写卡操作异常: " + e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
throw new RuntimeException("写卡操作异常: " + e.getMessage()); |
|
|
|
hideDialog(); |
|
|
|
ToastUtils.show("写卡操作失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 写OBU操作(支持多条指令,用逗号分隔) |
|
|
|
* 参考:OrderUtils.writeObu() |
|
|
|
* 使用"普通"方式:BluetoothDialog.Builder.transCmd |
|
|
|
*/ |
|
|
|
private String writeObu(String commands) { |
|
|
|
private void writeObu(String commands, String transOrderId) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "开始写OBU操作,指令: " + commands); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 确保MethodManager已初始化 |
|
|
|
if (MethodManager.getCls() == null) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "MethodManager未初始化,开始初始化"); |
|
|
|
MethodManager.initData("com.huntersun.vky.obublelib.box.BoxManagers"); |
|
|
|
if (MethodManager.getCls() == null) { |
|
|
|
Log.e(this.getClass().getSimpleName(), "MethodManager初始化失败"); |
|
|
|
throw new RuntimeException("MethodManager初始化失败"); |
|
|
|
} |
|
|
|
Log.i(this.getClass().getSimpleName(), "MethodManager初始化成功"); |
|
|
|
} |
|
|
|
|
|
|
|
// 分割多条指令 |
|
|
|
String[] commands_arry = commands.split(","); |
|
|
|
String[] results = new String[commands_arry.length]; |
|
|
|
int len = results.length; |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "指令总数: " + len); |
|
|
|
|
|
|
|
// 逐条执行指令,先收集所有结果 |
|
|
|
for (int i = 0; i < len; i++) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行第 " + (i + 1) + " 条指令: " + commands_arry[i]); |
|
|
|
|
|
|
|
// 透传OBU指令 |
|
|
|
ServiceStatus resp_string = MethodManager.sendApduEsam(commands_arry[i]); |
|
|
|
results[i] = resp_string.getServiceInfo(); |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "第 " + (i + 1) + " 条指令执行结果: " + results[i] + ", 状态码: " + resp_string.getServiceCode()); |
|
|
|
} |
|
|
|
|
|
|
|
// 拼接结果 |
|
|
|
StringBuilder buffer = new StringBuilder(); |
|
|
|
for (int i = 0; i < len; i++) { |
|
|
|
buffer.append(results[i]); |
|
|
|
if (i != len - 1) { |
|
|
|
buffer.append(","); |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令总数: " + commands_arry.length); |
|
|
|
|
|
|
|
// 使用"普通"方式:BluetoothDialog.Builder.transCmd |
|
|
|
// 这个方法内部会直接使用 isPlk 变量,无需额外设置 |
|
|
|
// 直接传递整个指令数组,不需要 for 循环 |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行指令数组: " + java.util.Arrays.toString(commands_arry)); |
|
|
|
|
|
|
|
// 使用 BluetoothDialog.Builder.transCmd,传递 "20" 表示OBU操作 |
|
|
|
BluetoothDialog.Builder.transCmd(commands_arry, "20", new BluetoothDialog.PerformCmdCallBack() { |
|
|
|
@Override |
|
|
|
public void performOnSuccess(String[] strings) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令执行成功: " + java.util.Arrays.toString(strings)); |
|
|
|
String result = String.join(",", strings); |
|
|
|
Log.i(this.getClass().getSimpleName(), "写OBU操作完成,最终结果: " + result); |
|
|
|
// 第三步:回传指令结果 |
|
|
|
callbackLogoutCommand(commands, transOrderId, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String finalResult = buffer.toString(); |
|
|
|
Log.i(this.getClass().getSimpleName(), "写OBU操作完成,最终结果: " + finalResult); |
|
|
|
return finalResult; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
Log.e(this.getClass().getSimpleName(), "写OBU操作异常: " + e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
throw new RuntimeException("写OBU操作异常: " + e.getMessage()); |
|
|
|
hideDialog(); |
|
|
|
ToastUtils.show("写OBU操作失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|