|
|
@ -201,9 +201,6 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
// AB门禁不可用弹窗 |
|
|
|
private GateUnavailableDialog gateUnavailableDialog; |
|
|
|
private GateABController gateABController; |
|
|
|
|
|
|
|
// MQTT管理器 |
|
|
|
private com.ouxuan.oxface.device.MqttManager mqttManager; |
|
|
|
private ABGateManager abGateManager; |
|
|
|
private boolean isGateCheckEnabled = false; // AB门检测是否开启 |
|
|
|
|
|
|
@ -238,9 +235,6 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
|
|
|
|
// 初始化AB门禁管理和不可用弹窗 |
|
|
|
initGateUnavailableDialog(); |
|
|
|
|
|
|
|
// 初始化MQTT管理器 |
|
|
|
initMqttManager(); |
|
|
|
|
|
|
|
// 初始化人脸检测状态 |
|
|
|
lastFaceDetectedTime = System.currentTimeMillis(); |
|
|
@ -360,7 +354,9 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
// 设置结果状态 |
|
|
|
if (isSuccess) { |
|
|
|
intent.putExtra("status", "离场成功"); |
|
|
|
intent.putExtra("message", errorMessage != null ? errorMessage : "离场成功"); |
|
|
|
// 使用接口返回的完整消息而不是默认的"离场成功" |
|
|
|
String fullMessage = errorMessage != null ? errorMessage : "离场成功"; |
|
|
|
intent.putExtra("message", fullMessage); |
|
|
|
} else { |
|
|
|
intent.putExtra("status", "离场失败"); |
|
|
|
intent.putExtra("message", errorMessage != null ? errorMessage : "离场失败"); |
|
|
@ -425,8 +421,8 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
public void onVerificationSuccess(com.ouxuan.oxface.network.api.PadApiService.CheckOrderResult data, int verificationType) { |
|
|
|
// 订单核销成功后开启B门 |
|
|
|
if (gateABController != null) { |
|
|
|
LogManager.logInfo(TAG, "订单验证成功,准备执行核销操作"); |
|
|
|
// gateABController.handleFaceRecognitionSuccess(true); // 参数保留兼容性,实际都开B门 |
|
|
|
LogManager.logInfo(TAG, "订单核销成功,开启B门"); |
|
|
|
gateABController.handleFaceRecognitionSuccess(true); // 参数保留兼容性,实际都开B门 |
|
|
|
} |
|
|
|
|
|
|
|
// 然后处理原有的页面跳转逻辑 |
|
|
@ -878,110 +874,6 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 初始化MQTT管理器 |
|
|
|
*/ |
|
|
|
private void initMqttManager() { |
|
|
|
try { |
|
|
|
LogManager.logInfo(TAG, "开始初始化MQTT管理器"); |
|
|
|
|
|
|
|
// 获取MQTT管理器实例 |
|
|
|
mqttManager = com.ouxuan.oxface.device.MqttManager.getInstance(); |
|
|
|
|
|
|
|
// 设置连接状态监听器 |
|
|
|
mqttManager.setConnectionStatusListener(new com.ouxuan.oxface.device.MqttManager.ConnectionStatusListener() { |
|
|
|
@Override |
|
|
|
public void onConnected() { |
|
|
|
LogManager.logInfo(TAG, "MQTT连接成功"); |
|
|
|
showToast("MQTT连接成功"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onConnectionFailed(String reason) { |
|
|
|
LogManager.logError(TAG, "MQTT连接失败: " + reason); |
|
|
|
showToast("MQTT连接失败"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onConnectionLost(String reason) { |
|
|
|
LogManager.logWarning(TAG, "MQTT连接丢失: " + reason); |
|
|
|
showToast("MQTT连接丢失,正在重连..."); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onReconnecting(int attempt) { |
|
|
|
LogManager.logInfo(TAG, "MQTT正在进行第" + attempt + "次重连"); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 设置消息接收监听器 |
|
|
|
mqttManager.setMessageReceivedListener(new com.ouxuan.oxface.device.MqttManager.MessageReceivedListener() { |
|
|
|
@Override |
|
|
|
public void onGateCommandReceived(String gateCommand) { |
|
|
|
LogManager.logInfo(TAG, "MQTT接收到门闸控制命令: " + gateCommand); |
|
|
|
showToast("执行MQTT门闸开门操作"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onRebootCommandReceived() { |
|
|
|
LogManager.logInfo(TAG, "MQTT接收到设备重启命令"); |
|
|
|
showToast("接收到重启命令"); |
|
|
|
|
|
|
|
// 可以在这里实现实际的重启逻辑 |
|
|
|
// performDeviceReboot(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLogLevelQueryReceived() { |
|
|
|
LogManager.logInfo(TAG, "MQTT接收到日志级别查询命令"); |
|
|
|
|
|
|
|
// 可以在这里实现设备信息上报逻辑 |
|
|
|
uploadDeviceInfo(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onOtherMessageReceived(String topic, String message) { |
|
|
|
LogManager.logInfo(TAG, "MQTT接收到其他消息 - 主题: " + topic + ", 内容: " + message); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 初始化MQTT管理器 |
|
|
|
mqttManager.initialize(this); |
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "MQTT管理器初始化完成"); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
LogManager.logError(TAG, "MQTT管理器初始化失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 上报设备信息(MQTT日志级别查询命令响应) |
|
|
|
*/ |
|
|
|
private void uploadDeviceInfo() { |
|
|
|
try { |
|
|
|
// 构建设备信息 |
|
|
|
StringBuilder deviceInfo = new StringBuilder(); |
|
|
|
deviceInfo.append("{"); |
|
|
|
deviceInfo.append("\"deviceId\":\"").append(com.ouxuan.oxface.device.DeviceUtils.getAndroidID(this)).append("\","); |
|
|
|
deviceInfo.append("\"deviceModel\":\"").append(com.ouxuan.oxface.device.DeviceUtils.getDeviceModel()).append("\","); |
|
|
|
deviceInfo.append("\"deviceBrand\":\"").append(com.ouxuan.oxface.device.DeviceUtils.getDeviceBrand()).append("\","); |
|
|
|
deviceInfo.append("\"androidVersion\":\"").append(com.ouxuan.oxface.device.DeviceUtils.getAndroidVersion()).append("\","); |
|
|
|
deviceInfo.append("\"timestamp\":").append(System.currentTimeMillis()); |
|
|
|
deviceInfo.append("}"); |
|
|
|
|
|
|
|
// 发送设备信息 |
|
|
|
String dataTopic = "WZX68L5I75/" + com.ouxuan.oxface.device.DeviceUtils.getFormattedDeviceId(this) + "/data"; |
|
|
|
if (mqttManager != null) { |
|
|
|
mqttManager.publishMessage(dataTopic, deviceInfo.toString()); |
|
|
|
LogManager.logInfo(TAG, "设备信息上报完成: " + deviceInfo.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
LogManager.logError(TAG, "设备信息上报失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 显示新的门禁不可用弹窗 |
|
|
|
* @param reason 不可用原因 |
|
|
|
*/ |
|
|
@ -1584,13 +1476,6 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
LogManager.logInfo(TAG, "摄像头控制广播接收器已注销"); |
|
|
|
} |
|
|
|
|
|
|
|
// 释放MQTT管理器资源 |
|
|
|
if (mqttManager != null) { |
|
|
|
mqttManager.release(); |
|
|
|
mqttManager = null; |
|
|
|
LogManager.logInfo(TAG, "MQTT管理器资源已释放"); |
|
|
|
} |
|
|
|
|
|
|
|
// 释放解锁密码弹窗资源 |
|
|
|
if (unlockPasswordDialog != null) { |
|
|
|
unlockPasswordDialog.release(); |
|
|
@ -1846,7 +1731,7 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi |
|
|
|
LogManager.logInfo(TAG, "准备调用ABPeopleCheck方法"); |
|
|
|
boolean peopleCheckPassed = abGateManager.ABPeopleCheck(); |
|
|
|
LogManager.logInfo(TAG, "ABPeopleCheck方法返回结果: " + peopleCheckPassed); |
|
|
|
peopleCheckPassed = true; //TODO 测试不进行人脸检验 |
|
|
|
|
|
|
|
if (!peopleCheckPassed) { |
|
|
|
LogManager.logWarning(TAG, "人数检测未通过,准备显示弹窗"); |
|
|
|
// 人数检测未通过,显示弹窗 |
|
|
|