张世豪
23 小时以前 03b0fb0ba2de86bcfff277778826547c0e37a93f
src/chushihua/lunxunzaixian.java
@@ -19,8 +19,8 @@
    private static Thread onlinePollingThread;
    
    // 可配置的轮询参数(不再是final)
    private static int cycleInterval = 60000; // 完整轮询周期间隔:60秒
    private static int slotInterval = 200;    // 卡槽间查询间隔:200毫秒
   private static int cycleInterval = 120000; // 完整轮询周期间隔:60秒
   private static int slotInterval = 200;    // 卡槽间查询间隔:500毫秒
    
    // 卡槽相关常量
    private static final int MIN_SLOT = 1;
@@ -302,7 +302,7 @@
                    } else {
                        consecutiveFailures++;
                        if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {
                            System.err.println("连续失败次数过多,暂停在线轮询");
                     System.err.println("lunxunzaixian连续失败次数过多,暂停在线轮询");
                            pauseOnlinePolling();
                        }
                    }
@@ -365,7 +365,7 @@
            int polledCount = 0;
            int totalCardSlots = cardSlots.size();
            
            // 第二阶段:批量查询有卡卡槽
          // 第二阶段:批量查询有卡卡槽 - 修复:每个卡槽间都有间隔
            for (int i = 0; i < cardSlots.size(); i += BATCH_SIZE) {
                if (!isRunning.get() || Thread.currentThread().isInterrupted() || shouldStop.get()) {
                    break;
@@ -374,14 +374,26 @@
                int end = Math.min(i + BATCH_SIZE, cardSlots.size());
                List<Integer> batch = cardSlots.subList(i, end);
                
                // 批次内查询
                for (int slotNumber : batch) {
              // 批次内查询 - 修复:每个卡槽间添加间隔
              for (int j = 0; j < batch.size(); j++) {
                  int slotNumber = batch.get(j);
                    if (sendQueryToCardSlot(slotNumber)) {
                        polledCount++;
                    }
                  // 重要修复:每个卡槽查询后等待指定间隔(最后一个卡槽除外)
                  if (j < batch.size() - 1) {
                      try {
                          Thread.sleep(slotInterval); // 卡槽间间隔
                      } catch (InterruptedException e) {
                          Thread.currentThread().interrupt();
                          break;
                      }
                  }
                }
                
                // 批次间间隔
              // 批次间间隔(保持原有逻辑)
                if (end < cardSlots.size()) {
                    try {
                        Thread.sleep(slotInterval * BATCH_SIZE);
@@ -393,12 +405,14 @@
            }
            
            if (polledCount > 0 && lunxun.DEBUG_ENABLED) {
                //System.out.println("在线轮询完成,成功查询 " + polledCount + "/" + totalCardSlots + " 个有卡卡槽");
              System.out.println("在线轮询完成,成功查询 " + polledCount + "/" + totalCardSlots + " 个有卡卡槽");
            }
            
            return polledCount > 0;
        }
        
        /**
         * 向指定有卡卡槽发送查询指令
         * @param slotNumber 卡槽编号