From 50393719d85fc30438456b0d0f065573a404fba5 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期五, 01 五月 2026 17:26:31 +0800
Subject: [PATCH] 增加一个单条上报的模式

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/CloudWmsNotifySchedule.java |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/CloudWmsNotifySchedule.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/CloudWmsNotifySchedule.java
index c98199f..875b320 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/CloudWmsNotifySchedule.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/CloudWmsNotifySchedule.java
@@ -7,6 +7,7 @@
 import com.vincent.rsf.server.api.controller.erp.params.InOutResultReportParam;
 import com.vincent.rsf.server.api.controller.erp.params.InventoryAdjustReportParam;
 import com.vincent.rsf.server.api.service.CloudWmsReportService;
+import com.vincent.rsf.server.manager.constant.CloudWmsInoutReportMode;
 import com.vincent.rsf.server.manager.entity.CloudWmsNotifyLog;
 import com.vincent.rsf.server.manager.service.CloudWmsNotifyLogService;
 import com.vincent.rsf.server.system.constant.GlobalConfigCode;
@@ -77,6 +78,21 @@
         return s != null && s != 0;
     }
 
+    /** CLOUD_WMS_INOUT_REPORT_MODE锛岀己鐪� immediate */
+    private String resolveInOutReportMode() {
+        try {
+            Config cfg = configService.getCachedOrLoad(GlobalConfigCode.CLOUD_WMS_INOUT_REPORT_MODE);
+            if (cfg != null && cfg.getVal() != null) {
+                String v = cfg.getVal().trim();
+                if (!v.isEmpty()) {
+                    return v.toLowerCase();
+                }
+            }
+        } catch (Exception ignored) {
+        }
+        return CloudWmsInoutReportMode.IMMEDIATE;
+    }
+
     /** 鍚屽崟澶氭潯鍚堝苟涓婃姤 */
     private void dispatchPending(List<CloudWmsNotifyLog> pending) {
         int rowsReported = 0;
@@ -85,6 +101,11 @@
         log.debug("浜戜粨涓婃姤娲惧彂锛氳鍙栦笂鎶ョ被鍨嬮厤缃�");
         String rtInOut = cloudWmsNotifyLogService.getReportTypeInOutResult();
         log.debug("浜戜粨涓婃姤娲惧彂锛氫笂鎶ョ被鍨�={}锛岃閰嶇疆鑰楁椂 {} ms", rtInOut, System.currentTimeMillis() - tCfg);
+        String inoutMode = resolveInOutReportMode();
+        boolean singleRowOnly = CloudWmsInoutReportMode.SINGLE.equals(inoutMode);
+        if (singleRowOnly) {
+            log.debug("浜戜粨涓婃姤娲惧彂锛氬叆鍑哄簱妯″紡 single锛屼笉鍚堝苟鍚屽崟澶氭潯");
+        }
         LinkedHashMap<String, List<CloudWmsNotifyLog>> inOutGroups = new LinkedHashMap<>();
         int n = pending.size();
         for (int i = 0; i < n; i++) {
@@ -99,7 +120,9 @@
             if (key == null) {
                 continue;
             }
-            inOutGroups.computeIfAbsent(key, k -> new ArrayList<>()).add(row);
+            if (!singleRowOnly) {
+                inOutGroups.computeIfAbsent(key, k -> new ArrayList<>()).add(row);
+            }
         }
         log.debug("浜戜粨涓婃姤娲惧彂锛氬叆鍑哄簱鍙垎缁勯敭 {} 涓�", inOutGroups.size());
         Set<Long> done = new HashSet<>();
@@ -135,6 +158,19 @@
                 }
                 continue;
             }
+            if (singleRowOnly) {
+                if (isSendingBusy(row)) {
+                    continue;
+                }
+                log.debug("浜戜粨涓婃姤娲惧彂锛歴ingle 妯″紡鍗曟潯 id={}", rid);
+                if (safeProcessOne(row)) {
+                    rowsReported++;
+                    if (rid != null) {
+                        done.add(rid);
+                    }
+                }
+                continue;
+            }
             List<CloudWmsNotifyLog> g = inOutGroups.get(key);
             List<CloudWmsNotifyLog> work = new ArrayList<>();
             if (g != null) {

--
Gitblit v1.9.1