Browse Source

fix test 10

devab
MTing 4 weeks ago
parent
commit
6f8b4b4190
  1. 8
      app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java
  2. 35
      app/src/main/java/com/ouxuan/oxface/device/GateABController.java

8
app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java

@ -418,13 +418,7 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
@Override @Override
public void onVerificationSuccess(com.ouxuan.oxface.network.api.PadApiService.CheckOrderResult data, int verificationType) { public void onVerificationSuccess(com.ouxuan.oxface.network.api.PadApiService.CheckOrderResult data, int verificationType) {
// 订单核销成功后开启B门
if (gateABController != null) {
LogManager.logInfo(TAG, "订单核销成功,开启B门");
gateABController.handleFaceRecognitionSuccess(true); // 参数保留兼容性实际都开B门
}
// 然后处理原有的页面跳转逻辑
// 直接处理页面跳转逻辑不在这里开门
orderVerificationResultHandler.handleVerificationSuccess(data, verificationType); orderVerificationResultHandler.handleVerificationSuccess(data, verificationType);
} }

35
app/src/main/java/com/ouxuan/oxface/device/GateABController.java

@ -279,8 +279,9 @@ public class GateABController {
// } // }
// 实时查询1次AB门状态, 防止AB门用户作弊 // 实时查询1次AB门状态, 防止AB门用户作弊
// 在开门场景中使用缓存状态以避免UDP查询延迟
if (getGateAbEnable()) { if (getGateAbEnable()) {
String gateStatus = getGateABState(); // 获取AB门状态
String gateStatus = getGateABState(true); // 获取AB门状态使用缓存以避免延迟
LogManager.logInfo(TAG, "开门-门状态查询:" + gateStatus + " gpio:" + getGateAbGpio()); LogManager.logInfo(TAG, "开门-门状态查询:" + gateStatus + " gpio:" + getGateAbGpio());
if (!"close".equals(gateStatus)) { if (!"close".equals(gateStatus)) {
@ -384,13 +385,22 @@ public class GateABController {
* @return "open"表示开启状态"close"表示关闭状态 . 当a门 b门中有任一个开启状态则返回"open", 两个门都关闭时返回"close" * @return "open"表示开启状态"close"表示关闭状态 . 当a门 b门中有任一个开启状态则返回"open", 两个门都关闭时返回"close"
*/ */
private String getGateABState() { private String getGateABState() {
LogManager.logInfo(TAG, "查询AB门状态");
return getGateABState(false);
}
/**
* 获取AB门状态
* @param useCacheOnly 是否仅使用缓存状态用于开门场景避免延迟
* @return "open"表示开启状态"close"表示关闭状态
*/
private String getGateABState(boolean useCacheOnly) {
LogManager.logInfo(TAG, "查询AB门状态, useCacheOnly: " + useCacheOnly);
try { try {
// 检查是否启用UDP门禁控制 // 检查是否启用UDP门禁控制
if (getGateAbUdp() && udpController != null && udpController.isInitialized()) { if (getGateAbUdp() && udpController != null && udpController.isInitialized()) {
LogManager.logInfo(TAG, "使用UDP查询AB门状态"); LogManager.logInfo(TAG, "使用UDP查询AB门状态");
return getGateStateFromUDP();
return getGateStateFromUDP(useCacheOnly);
} }
// 检查是否启用GPIO门禁控制 // 检查是否启用GPIO门禁控制
@ -792,6 +802,25 @@ public class GateABController {
* @return "open" "close" * @return "open" "close"
*/ */
private String getGateStateFromUDP() { private String getGateStateFromUDP() {
return getGateStateFromUDP(false);
}
/**
* UDP 获取门状态
* @param useCacheOnly 是否仅使用缓存状态用于开门场景避免延迟
* @return "open" "close"
*/
private String getGateStateFromUDP(boolean useCacheOnly) {
// 对于开门操作我们使用缓存状态以避免UDP查询延迟
if (useCacheOnly && currentGateState != null) {
// 按照业务逻辑当A门或B门中有任一个开启时返回"open"
// 两个门都关闭时返回"close"
String result = (currentGateState.gateAOpen || currentGateState.gateBOpen) ? "open" : "close";
LogManager.logInfo(TAG, "使用缓存门状态(开门场景优化): " + result + " (A门: " + currentGateState.gateAOpen +
", B门: " + currentGateState.gateBOpen + ")");
return result;
}
try { try {
LogManager.logInfo(TAG, "使用UDP查询门状态"); LogManager.logInfo(TAG, "使用UDP查询门状态");

Loading…
Cancel
Save