From 300ca9810420efbf8468c9d6f47bd364c9c72d5f Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期一, 12 一月 2026 11:09:20 +0800
Subject: [PATCH] 盘点更改

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs |    8 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundController.cs        |   11 
 项目代码/WIDESEA_WMSClient/src/extension/inbound/takeStockOrder.js                                   |   32 
 项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/DirectOutbound.vue                          |    1 
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/TakeStockSelect.vue                          |  253 +---
 项目代码/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js                                   |    1 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/CalcOut/PickingOutboundRequestDTO.cs                  |    2 
 项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue                             |   63 
 项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue                          |  151 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs                          |  124 ++
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/OrderStockTake.vue                           |  339 +----
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IInboundService/ITakeStockOrderService.cs                 |    4 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs                          |   33 
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue                      |    1 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs                      |    4 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs                        |  875 +++++++-------
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/StockTakeGroupPallet.vue                     | 1124 +++++++++++++++++++
 项目代码/WIDESEA_WMSClient/config/buttons.js                                                         |   22 
 项目代码/WIDESEA_WMSClient/src/extension/inbound/takeStockOrderDetail.js                             |  136 --
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundService.cs                        |    6 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/TakeStockOrderService.cs                   |  292 ++--
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/TakeStockOrderController.cs |   13 
 22 files changed, 2,195 insertions(+), 1,300 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js"
index cd0b5f0..64174fb 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/config/buttons.js"
@@ -284,7 +284,7 @@
     onClick: function () {
     }
 },{
-    name: "鍗� 鎹� 鐩� 鐐� 鎿� 浣�",
+    name: "鍗� 鎹� 鐩� 浜� 鎿� 浣�",
     icon: '',
     class: '',
     value: 'OrderStockTake',
@@ -315,7 +315,7 @@
     type: 'warning',
     onClick: function () {
     }
-},,{
+},{
     name: "鍏抽棴鍗曟嵁",
     icon: '',
     class: '',
@@ -323,7 +323,23 @@
     type: 'warning',
     onClick: function () {
     }
-},
+},{
+    name: "鐩樹簭鏉傚彂鎿嶄綔",
+    icon: '',
+    class: '',
+    value: 'OutOrderStockTake',
+    type: 'warning',
+    onClick: function () {
+    }
+},{
+    name: "鐩樹簭缁勭洏鎿嶄綔",
+    icon: '',
+    class: '',
+    value: 'StockTakeGroupPallet',
+    type: 'warning',
+    onClick: function () {
+    }
+}
 ]
 
 export default buttons
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/OrderStockTake.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/OrderStockTake.vue"
index 92a0bb3..fcb06f4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/OrderStockTake.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/OrderStockTake.vue"
@@ -15,7 +15,7 @@
           </el-tag>
         </div>
 
-        <!-- 鏍稿績杈撳叆琛ㄥ崟 -->
+        <!-- 鏍稿績杈撳叆琛ㄥ崟锛氱Щ闄ゆ墍鏈夋牎楠岃鍒� -->
         <el-form
           :model="formData"
           ref="formRef"
@@ -23,20 +23,8 @@
           class="stock-take-form"
           @submit.prevent
         >
-          <!-- 鏂欑鍙疯緭鍏ユ -->
-          <el-form-item
-            label="鏂欑鍙凤細"
-            name="boxNo"
-            :rules="[
-              {
-                required: true,
-                message: '璇锋壂鎻忔垨杈撳叆鏂欑鍙�',
-                trigger: 'blur',
-              },
-              { validator: validateBoxNo, trigger: 'blur' },
-            ]"
-            class="form-item"
-          >
+          <!-- 鏂欑鍙疯緭鍏ユ锛氱Щ闄ゆ牎楠岃鍒� -->
+          <el-form-item label="鏂欑鍙凤細" name="boxNo" class="form-item">
             <el-input
               ref="boxNoInputRef"
               v-model="formData.boxNo"
@@ -54,30 +42,19 @@
                   type="primary"
                   size="small"
                   @click="handleBoxNoScan"
-                  :disabled="!formData.boxNo.trim() || loading"
+                  :disabled="loading"
                   class="input-btn"
                 ></el-button>
               </template>
             </el-input>
           </el-form-item>
 
-          <!-- 鏂板锛氱珯鍙伴�夋嫨涓嬫媺妗� -->
-          <el-form-item
-            label="鍥炲簱绔欏彴锛�"
-            name="station"
-            :rules="[
-              {
-                required: true,
-                message: '璇烽�夋嫨鍥炲簱绔欏彴',
-                trigger: 'blur',
-              },
-            ]"
-            class="form-item"
-          >
+          <!-- 绔欏彴閫夋嫨涓嬫媺妗嗭細绉婚櫎鏍¢獙瑙勫垯 -->
+          <el-form-item label="鍥炲簱绔欏彴锛�" name="station" class="form-item">
             <el-select
               v-model="selectedStation"
               placeholder="璇烽�夋嫨鍥炲簱绔欏彴"
-              :disabled="!formData.boxNo.trim() || loading"
+              :disabled="loading"
               class="custom-input"
               :class="{ 'has-value': selectedStation }"
             >
@@ -90,23 +67,15 @@
             </el-select>
           </el-form-item>
 
-          <!-- 鏉$爜杈撳叆妗� -->
-          <el-form-item
-            label="鐩樼偣鏉$爜锛�"
-            name="barcode"
-            :rules="[
-              { required: true, message: '璇锋壂鎻忔垨杈撳叆鏉$爜', trigger: 'blur' },
-              { validator: validateBarcode, trigger: 'blur' },
-            ]"
-            class="form-item"
-          >
+          <!-- 鏉$爜杈撳叆妗嗭細绉婚櫎鏍¢獙瑙勫垯 -->
+          <el-form-item label="鐩樼偣鏉$爜锛�" name="barcode" class="form-item">
             <el-input
               ref="barcodeInputRef"
               v-model="formData.barcode"
               placeholder="璇蜂娇鐢ㄦ壂鐮佹灙鎵弿鏉$爜锛屾垨鎵嬪姩杈撳叆"
               clearable
               @keydown.enter="debouncedHandleBarcodeScan"
-              :disabled="!formData.boxNo.trim() || loading"
+              :disabled="loading"
               class="custom-input"
               :class="{ 'has-value': formData.barcode.trim() }"
             >
@@ -116,11 +85,7 @@
                   type="primary"
                   size="small"
                   @click="handleBarcodeScan"
-                  :disabled="
-                    !formData.boxNo.trim() ||
-                    !formData.barcode.trim() ||
-                    loading
-                  "
+                  :disabled="loading"
                   class="input-btn"
                 ></el-button>
               </template>
@@ -128,11 +93,7 @@
           </el-form-item>
 
           <!-- 搴撳瓨鏁伴噺妗嗭紙鍙锛� -->
-          <el-form-item
-            label="搴撳瓨鏁伴噺锛�"
-            name="stockQuantity"
-            class="form-item"
-          >
+          <el-form-item label="搴撳瓨鏁伴噺锛�" name="stockQuantity" class="form-item">
             <el-input
               v-model="formData.stockQuantity"
               placeholder="鎵弿鏉$爜鍚庤嚜鍔ㄥ~鍏�"
@@ -142,41 +103,25 @@
             ></el-input>
           </el-form-item>
 
-          <!-- 瀹為檯鐩樼偣鏁伴噺 -->
-          <el-form-item
-            label="瀹為檯鐩樼偣鏁伴噺锛�"
-            name="actualQuantity"
-            :rules="[
-              {
-                required: true,
-                message: '璇疯緭鍏ュ疄闄呯洏鐐规暟閲�',
-                trigger: 'blur',
-              },
-              { type: 'number', message: '璇疯緭鍏ユ湁鏁堢殑鏁板瓧', trigger: 'blur' },
-              { validator: validateActualQuantity, trigger: 'blur' },
-            ]"
-            class="form-item"
-          >
+          <!-- 瀹為檯鐩樼偣鏁伴噺锛氬彧璇伙紝榛樿0 -->
+          <el-form-item label="瀹為檯鐩樼偣鏁伴噺锛�" name="actualQuantity" class="form-item">
             <el-input
-              v-model.number="formData.actualQuantity"
-              placeholder="璇疯緭鍏ュ疄闄呯洏鐐规暟閲�"
-              type="number"
-              clearable
-              @keydown.enter="handleStockTakeComplete"
-              :disabled="!formData.stockQuantity || loading"
-              class="custom-input"
+              v-model="formData.actualQuantity"
+              placeholder="榛樿鍊间负0"
+              readonly
+              class="custom-input custom-readonly-input"
               :class="{ 'has-value': formData.actualQuantity !== '' }"
             ></el-input>
           </el-form-item>
         </el-form>
 
-        <!-- 鎿嶄綔鎸夐挳鍖哄煙 -->
+        <!-- 鎿嶄綔鎸夐挳鍖哄煙锛氱畝鍖栫鐢ㄩ�昏緫 -->
         <div class="action-buttons">
           <el-button
             type="info"
             size="small"
             @click="handleBoxReturn"
-            :disabled="!formData.boxNo.trim() || !selectedStation || loading"
+            :disabled="loading"
             class="return-btn"
           >
             <Return /> 鏂欑鍥炲簱
@@ -185,7 +130,7 @@
             type="primary"
             size="small"
             @click="handleStockTakeComplete"
-            :disabled="isFormCompleteDisabled"
+            :disabled="loading"
             class="complete-btn"
           >
             <Check /> 鐩樼偣瀹屾垚
@@ -211,7 +156,6 @@
 
 import VolBox from "@/components/basic/VolBox.vue";
 import http from "@/api/http";
-// 鏂板锛氬紩鍏ョ珯鍙扮鐞嗗伐鍏凤紙鍜岀ず渚嬩唬鐮佷繚鎸佷竴鑷达級
 import { stationManager, STATION_STORAGE_KEY } from "@/../src/uitils/stationManager";
 
 // 鍝嶅簲寮忓彉閲� - 鍗曟嵁鍙�
@@ -225,18 +169,18 @@
 const formData = reactive({
   boxNo: "", // 鏂欑鍙�
   barcode: "", // 鐩樼偣鏉$爜
-  stockQuantity: "", // 搴撳瓨鏁伴噺锛堝彧璇伙級
-  actualQuantity: "", // 瀹為檯鐩樼偣鏁伴噺
+  stockQuantity: "", // 搴撳瓨鏁伴噺
+  actualQuantity: 0, // 瀹為檯鐩樼偣鏁伴噺榛樿0
 });
 const loading = ref(false);
 const formRef = ref(null);
 
-// 鏂板锛氱珯鍙扮浉鍏冲搷搴斿紡鏁版嵁锛堜豢鐓хず渚嬩唬鐮侊級
+// 绔欏彴鐩稿叧鍝嶅簲寮忔暟鎹�
 const stations = ref([
   { label: "绔欏彴2", value: "2-1" },
   { label: "绔欏彴3", value: "3-1" },
 ]);
-const selectedStation = ref(stationManager.getStation() || ""); // 榛樿閫変腑缂撳瓨鐨勭珯鍙�
+const selectedStation = ref(stationManager.getStation() || "");
 
 // 妯℃澘寮曠敤
 const boxNoInputRef = ref(null);
@@ -247,39 +191,24 @@
   return window.innerWidth < 768;
 });
 
-// 璁$畻灞炴�э細鐩樼偣瀹屾垚鎸夐挳鏄惁绂佺敤
-const isFormCompleteDisabled = computed(() => {
-  return (
-    loading.value ||
-    !formData.boxNo.trim() ||
-    !formData.barcode.trim() ||
-    !formData.stockQuantity ||
-    formData.actualQuantity === "" ||
-    formData.actualQuantity === null ||
-    formData.actualQuantity === undefined ||
-    Number(formData.actualQuantity) < 0 // 灏忎簬0鏃剁鐢紝0鏄厑璁哥殑
-  );
-});
-
 // 缁勪欢鎸傝浇鏃惰仛鐒﹀埌鏂欑鍙疯緭鍏ユ
 onMounted(() => {
   nextTick(() => {
     boxNoInputRef.value?.focus();
   });
-  // 鐩戝惉绐楀彛澶у皬鍙樺寲
   window.addEventListener("resize", () => {});
 });
 
-// 鐩戝惉鏂欑鍙峰彉鍖栵紝娓呯┖鍚庣画鐩稿叧瀛楁
+// 鐩戝惉鏂欑鍙峰彉鍖栵紝娓呯┖鍚庣画鐩稿叧瀛楁锛堜粎淇濈暀鍩虹娓呯┖閫昏緫锛�
 watch(
   () => formData.boxNo,
   (newVal) => {
     if (!newVal.trim()) {
       formData.barcode = "";
       formData.stockQuantity = "";
-      formData.actualQuantity = "";
-      // 鏂板锛氭枡绠卞彿娓呯┖鏃讹紝閲嶇疆绔欏彴閫夋嫨
+      formData.actualQuantity = 0;
       selectedStation.value = stationManager.getStation() || "";
+      orderNo.value = "";
     }
   },
   { immediate: true }
@@ -296,17 +225,16 @@
   };
 };
 
-// 鎵撳紑寮圭獥骞舵帴鏀跺崟鎹彿
-const open = (receiptNo) => {
+// 鎵撳紑寮圭獥
+const open = () => {
   showStockTakeBox.value = true;
-  orderNo.value = receiptNo;
   // 閲嶇疆琛ㄥ崟
   formData.boxNo = "";
   formData.barcode = "";
   formData.stockQuantity = "";
-  formData.actualQuantity = "";
-  // 鏂板锛氭墦寮�寮圭獥鏃堕噸缃珯鍙伴�夋嫨锛堥粯璁ゅ彇缂撳瓨鐨勭珯鍙帮級
+  formData.actualQuantity = 0;
   selectedStation.value = stationManager.getStation() || "";
+  orderNo.value = "";
   nextTick(() => {
     boxNoInputRef.value?.focus();
   });
@@ -321,43 +249,6 @@
   orderNo.value = "";
 };
 
-// 鏂欑鍙烽獙璇侊紙浼樺寲锛氭湁鍊兼椂浠呴獙璇侀暱搴︼紝鏃犲�兼椂瑙﹀彂蹇呭~锛�
-const validateBoxNo = (rule, value, callback) => {
-  // 鏈夊�兼椂楠岃瘉闀垮害
-  if (value && value.trim().length < 3) {
-    callback(new Error("鏂欑鍙烽暱搴︿笉鑳藉皯浜�3浣�"));
-  } 
-  // 鏃犲�兼椂鐢眗equired瑙勫垯澶勭悊锛岃繖閲屼笉閲嶅鎻愮ず
-  else {
-    callback();
-  }
-};
-
-// 鏉$爜楠岃瘉锛堜紭鍖栵細鏈夊�兼椂浠呴獙璇侀暱搴︼級
-const validateBarcode = (rule, value, callback) => {
-  if (value && value.trim().length < 6) {
-    callback(new Error("鏉$爜闀垮害涓嶈兘灏戜簬6浣�"));
-  } else {
-    callback();
-  }
-};
-
-// 瀹為檯鐩樼偣鏁伴噺楠岃瘉锛氬厑璁�0锛屼絾涓嶅厑璁稿皬浜�0
-const validateActualQuantity = (rule, value, callback) => {
-  // 绌哄�肩敱required瑙勫垯澶勭悊锛岃繖閲屽彧楠岃瘉鏁板�煎悎娉曟��
-  if (value === null || value === undefined || value === "") {
-    callback(); // 绌哄�间笉鍦ㄨ繖閲屾彁绀猴紝浜ょ粰required瑙勫垯
-  } 
-  // 楠岃瘉鏁板�兼槸鍚﹀皬浜�0
-  else if (value < 0) {
-    callback(new Error("瀹為檯鐩樼偣鏁伴噺涓嶈兘灏忎簬0"));
-  } 
-  // 楠岃瘉閫氳繃锛堝厑璁�0锛�
-  else {
-    callback();
-  }
-};
-
 // 鏂欑鍙峰け鐒﹀鐞�
 const handleBoxNoBlur = () => {
   if (formData.boxNo.trim() && boxNoInputRef.value?.input) {
@@ -365,39 +256,29 @@
   }
 };
 
-// 鏂欑鍙锋壂鎻忛獙璇侊紙鍚庣鎺ュ彛锛�
-const validateBoxNoApi = async (boxNo) => {
+// 鏂欑鍙锋壂鎻忓鐞嗭細绉婚櫎鍓嶇鏍¢獙锛岀洿鎺ヨ皟鐢ㄦ帴鍙�
+const handleBoxNoScan = async () => {
+  const boxNo = formData.boxNo.trim();
+  if (!boxNo) {
+    ElMessage.warning("璇疯緭鍏ユ枡绠卞彿");
+    return;
+  }
+
   try {
+    loading.value = true;
+    // 鐩存帴璋冪敤鎺ュ彛锛屼笉鍋氬墠绔牎楠�
     const res = await http.post(
-      `/api/TakeStockOrder/ValidateBoxNo?orderNo=${encodeURIComponent(
-        orderNo.value
-      )}&boxNo=${encodeURIComponent(boxNo)}`,
+      `/api/TakeStockOrder/ValidateBoxNo?orderNo=${encodeURIComponent(orderNo.value)}&boxNo=${encodeURIComponent(boxNo)}`,
       "楠岃瘉鏂欑鍙蜂腑..."
     );
 
     if (!res.status) {
       throw new Error(res.message || "鏂欑鍙烽獙璇佸け璐�");
     }
-    return res.data;
-  } catch (error) {
-    throw error;
-  }
-};
-
-// 鏂欑鍙锋壂鎻忓鐞�
-const handleBoxNoScan = async () => {
-  if (!formRef.value) return;
-  // 鎵嬪姩瑙﹀彂楠岃瘉锛堜粎楠岃瘉褰撳墠瀛楁锛�
-  const valid = await formRef.value.validateField("boxNo");
-  if (valid !== true) return;
-
-  const boxNo = formData.boxNo.trim();
-  if (!boxNo) return;
-
-  try {
-    loading.value = true;
-    await validateBoxNoApi(boxNo);
-    ElMessage.success(`鏂欑鍙� ${boxNo} 楠岃瘉閫氳繃`);
+    if (res.data?.takeStockOrder) {
+      orderNo.value = res.data.takeStockOrder;
+    }
+    ElMessage.success(`鏂欑鍙� ${boxNo} 楠岃瘉閫氳繃锛屽崟鎹彿锛�${orderNo.value}`);
     nextTick(() => {
       barcodeInputRef.value?.focus();
     });
@@ -413,13 +294,20 @@
   }
 };
 
-// 鏉$爜鎵弿楠岃瘉锛堝悗绔帴鍙o級
-const validateBarcodeApi = async (boxNo, barcode) => {
+// 鏉$爜鎵弿澶勭悊锛氱Щ闄ゅ墠绔牎楠岋紝鐩存帴璋冪敤鎺ュ彛
+const handleBarcodeScan = async () => {
+  const boxNo = formData.boxNo.trim();
+  const barcode = formData.barcode.trim();
+  if (!boxNo || !barcode) {
+    ElMessage.warning("璇疯緭鍏ユ枡绠卞彿鍜屾潯鐮�");
+    return;
+  }
+
   try {
+    loading.value = true;
+    // 鐩存帴璋冪敤鎺ュ彛锛屼笉鍋氬墠绔牎楠�
     const res = await http.post(
-      `/api/TakeStockOrder/ValidateBarcode?boxNo=${encodeURIComponent(
-        boxNo
-      )}&barcode=${encodeURIComponent(barcode)}`,
+      `/api/TakeStockOrder/ValidateBarcode?boxNo=${encodeURIComponent(boxNo)}&barcode=${encodeURIComponent(barcode)}`,
       "楠岃瘉鏉$爜涓�..."
     );
 
@@ -427,41 +315,13 @@
       throw new Error(res.message || "鏉$爜楠岃瘉澶辫触");
     }
 
-    if (
-      res.data?.stockQuantity === undefined ||
-      res.data?.stockQuantity === null
-    ) {
-      throw new Error("鏈煡璇㈠埌璇ユ潯鐮佺殑搴撳瓨鏁伴噺");
+    if (res.data?.stockQuantity !== undefined && res.data?.stockQuantity !== null) {
+      formData.stockQuantity = res.data.stockQuantity;
     }
-
-    return res.data;
-  } catch (error) {
-    throw error;
-  }
-};
-
-// 鏉$爜鎵弿澶勭悊
-const handleBarcodeScan = async () => {
-  if (!formRef.value) return;
-  const valid = await formRef.value.validateField("barcode");
-  if (valid !== true) return;
-
-  const boxNo = formData.boxNo.trim();
-  const barcode = formData.barcode.trim();
-  if (!boxNo || !barcode) return;
-
-  try {
-    loading.value = true;
-    const result = await validateBarcodeApi(boxNo, barcode);
-    formData.stockQuantity = result.stockQuantity;
-    ElMessage.success(
-      `鏉$爜 ${barcode} 楠岃瘉閫氳繃锛屽簱瀛樻暟閲忥細${result.stockQuantity}`
-    );
+    ElMessage.success(`鏉$爜 ${barcode} 楠岃瘉閫氳繃锛屽簱瀛樻暟閲忥細${formData.stockQuantity}`);
     nextTick(() => {
-      const actualQuantityInput = document.querySelector(
-        ".form-item:last-child .el-input__inner"
-      );
-      actualQuantityInput?.focus();
+      const actualQuantityInput = document.querySelector(".form-item:last-child .el-input__inner");
+      actualQuantityInput?.blur();
     });
   } catch (error) {
     ElMessage.error(error.message);
@@ -475,32 +335,33 @@
   }
 };
 
-// 鐩樼偣瀹屾垚鎻愪氦
+// 鐩樼偣瀹屾垚鎻愪氦锛氬畬鍏ㄧЩ闄ゅ墠绔牎楠岋紝鐩存帴浼犲�肩粰鍚庣
 const handleStockTakeComplete = async () => {
-  if (!formRef.value) return;
-  // 鍏ㄨ〃鍗曢獙璇�
-  const valid = await formRef.value.validate();
-  if (!valid) return;
-
-  // 棰濆妫�鏌ュ疄闄呯洏鐐规暟閲忔槸鍚﹀皬浜�0
-  if (formData.actualQuantity < 0) {
-    ElMessage.error("瀹為檯鐩樼偣鏁伴噺涓嶈兘灏忎簬0");
+  // 浠呭仛鏈�鍩虹鐨勭┖鎻愮ず锛堝彲閫夛紝涔熷彲浠ュ幓鎺夛級
+  if (!formData.boxNo.trim()) {
+    ElMessage.warning("璇疯緭鍏ユ枡绠卞彿");
+    return;
+  }
+  if (!formData.barcode.trim()) {
+    ElMessage.warning("璇疯緭鍏ユ潯鐮�");
     return;
   }
 
+  // 鐩存帴鑾峰彇鎵�鏈夊�硷紝涓嶅仛浠讳綍鏍¢獙
   const { boxNo, barcode, actualQuantity, stockQuantity } = formData;
   const receiptNo = orderNo.value;
 
   try {
     loading.value = true;
 
+    // 鐩存帴浼犲�肩粰鍚庣锛屼笉鍋氫换浣曞墠绔牎楠�
     const res = await http.post(
       "/api/TakeStockOrder/CompleteStockTake",
       {
         orderNo: receiptNo,
         boxNo,
         barcode,
-        actualQuantity,
+        actualQuantity, // 鍥哄畾浼�0
         stockQuantity,
       },
       {
@@ -512,7 +373,7 @@
       ElMessage.success("鐩樼偣瀹屾垚锛屾彁浜ゆ垚鍔燂紒");
       formData.barcode = "";
       formData.stockQuantity = "";
-      formData.actualQuantity = "";
+      formData.actualQuantity = 0;
       nextTick(() => {
         barcodeInputRef.value?.focus();
       });
@@ -527,16 +388,11 @@
   }
 };
 
-// 鏂欑鍥炲簱鍔熻兘锛堟牳蹇冧慨鏀癸細澧炲姞绔欏彴楠岃瘉 + 浼犲叆sourceAddress鍙傛暟锛�
+// 鏂欑鍥炲簱鍔熻兘锛氱畝鍖栨牎楠岋紝鐩存帴浼犲��
 const handleBoxReturn = async () => {
   const boxNo = formData.boxNo.trim();
-  // 鏂板锛氶獙璇佺珯鍙版槸鍚﹂�夋嫨
   if (!boxNo) {
-    ElMessage.warning("璇峰厛杈撳叆鎴栨壂鎻忔枡绠卞彿");
-    return;
-  }
-  if (!selectedStation.value) {
-    ElMessage.warning("璇烽�夋嫨鍥炲簱绔欏彴");
+    ElMessage.warning("璇疯緭鍏ユ枡绠卞彿");
     return;
   }
 
@@ -552,11 +408,9 @@
 
     loading.value = true;
 
-    // 鏂板锛氭嫾鎺ourceAddress鍙傛暟锛堢珯鍙版暟鎹級鍒版帴鍙h姹備腑
+    // 鐩存帴浼犲�肩粰鍚庣锛屼笉鍋氫弗鏍兼牎楠�
     const res = await http.post(
-      `/api/TakeStockOrder/ReturnBox?boxNo=${encodeURIComponent(boxNo)}&orderNo=${encodeURIComponent(
-        orderNo.value
-      )}&sourceAddress=${encodeURIComponent(selectedStation.value)}`, // 鏂板sourceAddress鍙傛暟
+      `/api/TakeStockOrder/ReturnBox?boxNo=${encodeURIComponent(boxNo)}&orderNo=${encodeURIComponent(orderNo.value)}&sourceAddress=${encodeURIComponent(selectedStation.value)}`,
       "鏂欑鍥炲簱涓�..."
     );
 
@@ -565,8 +419,9 @@
       formData.boxNo = "";
       formData.barcode = "";
       formData.stockQuantity = "";
-      formData.actualQuantity = "";
-      selectedStation.value = stationManager.getStation() || ""; // 閲嶇疆绔欏彴閫夋嫨
+      formData.actualQuantity = 0;
+      selectedStation.value = stationManager.getStation() || "";
+      orderNo.value = "";
       nextTick(() => {
         boxNoInputRef.value?.focus();
       });
@@ -603,7 +458,7 @@
 </script>
 
 <style scoped>
-/* 涓诲鍣ㄦ牱寮� - 浼樺寲闂磋窛鍜屽搷搴斿紡 */
+/* 鏍峰紡瀹屽叏淇濈暀锛屾棤淇敼 */
 .stock-take-container {
   width: 100%;
   display: flex;
@@ -612,7 +467,6 @@
   padding: 8px 0;
 }
 
-/* 鍗曟嵁淇℃伅鏍峰紡 - 浼樺寲瑙嗚灞傜骇 */
 .receipt-info {
   margin-bottom: 4px;
 }
@@ -633,7 +487,6 @@
   margin-left: 6px;
 }
 
-/* 琛ㄥ崟鏍峰紡 - 浼樺寲闃村奖鍜屽唴杈硅窛 */
 .stock-take-form {
   width: 100%;
   background-color: #ffffff;
@@ -647,17 +500,15 @@
   margin-bottom: 16px;
 }
 
-/* 杈撳叆妗嗘牳蹇冩牱寮� - 浼樺寲鐘舵�佹樉绀� */
 .custom-input {
   width: 100%;
   position: relative;
 }
 
-/* 鏈夊�兼椂闅愯棌鍗犱綅绗� + 浼樺寲杈规 */
 .custom-input.has-value :deep(.el-input__inner),
 .custom-input.has-value :deep(.el-select__wrapper) {
-  --el-input-placeholder-color: transparent; /* 闅愯棌鍗犱綅绗� */
-  border-color: #8cc5ff; /* 娴呰摑杈规锛屽尯鍒嗘棤鍊肩姸鎬� */
+  --el-input-placeholder-color: transparent;
+  border-color: #8cc5ff;
   background-color: #ffffff;
 }
 
@@ -673,7 +524,6 @@
   padding: 0 12px;
 }
 
-/* 鑱氱劍鏍峰紡浼樺寲 */
 .custom-input :deep(.el-input__inner:focus),
 .custom-input :deep(.el-select__wrapper:focus) {
   border-color: #409eff;
@@ -682,7 +532,6 @@
   outline: none;
 }
 
-/* 娓呴櫎鎸夐挳鏍峰紡浼樺寲 */
 .custom-input :deep(.el-input__clear) {
   color: #91c9f7;
   width: 18px;
@@ -693,7 +542,6 @@
   color: #409eff;
 }
 
-/* 鍙杈撳叆妗嗘牱寮� - 澧炲己鍖哄垎搴� */
 .custom-readonly-input :deep(.el-input__inner) {
   background-color: #f0f8fb;
   color: #1989fa;
@@ -703,7 +551,6 @@
   padding-right: 12px;
 }
 
-/* 杈撳叆妗嗘寜閽牱寮� - 浼樺寲灏哄鍜宧over鏁堟灉 */
 .input-btn {
   border-radius: 0 8px 8px 0 !important;
   height: 42px;
@@ -720,28 +567,23 @@
   transform: translateY(-1px);
 }
 
-/* 琛ㄥ崟楠岃瘉閿欒鏍峰紡 - 鍏抽敭锛氭湁鍊兼椂涓嶆樉绀洪敊璇竟妗� */
 .form-item :deep(.el-form-item__error) {
   font-size: 12px;
   color: #f56c6c;
   margin-top: 4px;
-  /* 浠呭湪杈撳叆妗嗕负绌轰笖楠岃瘉澶辫触鏃舵樉绀� */
   display: none;
 }
 
-/* 鍙湁杈撳叆妗嗕负绌� + 楠岃瘉澶辫触鏃舵樉绀洪敊璇彁绀� */
 .form-item:deep(.el-form-item--error) .custom-input:not(.has-value) + .el-form-item__error {
   display: block;
 }
 
-/* 鏈夊�兼椂鍗充娇楠岃瘉澶辫触锛屼篃涓嶆樉绀洪敊璇竟妗� */
 .custom-input.has-value :deep(.el-input__inner.el-input__inner--error),
 .custom-input.has-value :deep(.el-select__wrapper.el-select__wrapper--error) {
   border-color: #8cc5ff;
   box-shadow: none;
 }
 
-/* 鎿嶄綔鎸夐挳鍖哄煙 - 浼樺寲闂磋窛鍜屽搷搴斿紡 */
 .action-buttons {
   display: flex;
   justify-content: flex-end;
@@ -750,7 +592,6 @@
   flex-wrap: wrap;
 }
 
-/* 鍥炲簱鎸夐挳鏍峰紡 - 浼樺寲浜や簰 */
 .return-btn {
   border-radius: 8px;
   padding: 9px 20px;
@@ -779,7 +620,6 @@
   box-shadow: none;
 }
 
-/* 鐩樼偣瀹屾垚鎸夐挳鏍峰紡 - 浼樺寲浜や簰 */
 .complete-btn {
   border-radius: 8px;
   padding: 9px 20px;
@@ -806,7 +646,6 @@
   box-shadow: none;
 }
 
-/* 鍙栨秷鎸夐挳鏍峰紡 - 浼樺寲鐐瑰嚮鍖哄煙 */
 .cancel-btn {
   color: #666666;
   font-size: 14px;
@@ -821,7 +660,6 @@
   background-color: #f0f8fb !important;
 }
 
-/* 寮圭獥鏁翠綋鏍峰紡 - 浼樺寲鍦嗚鍜岄槾褰� */
 .custom-vol-box {
   border-radius: 16px !important;
   overflow: hidden;
@@ -844,7 +682,6 @@
   padding: 16px 24px;
 }
 
-/* 鍝嶅簲寮忛�傞厤 - 灏忓睆骞曚紭鍖� */
 @media (max-width: 768px) {
   .stock-take-form {
     padding: 16px;
@@ -869,14 +706,12 @@
 </style>
 
 <style>
-/* 鍏ㄥ眬琛ュ厖鏍峰紡 - 缁熶竴涓婚 */
 .el-tag--primary {
   --el-tag-bg-color: #e8f4f8;
   --el-tag-border-color: #409eff;
   --el-tag-text-color: #1989fa;
 }
 
-/* 鍗犱綅绗︽牱寮� - 缁熶竴棰滆壊 */
 .el-input__inner::-webkit-input-placeholder,
 .el-select__placeholder {
   color: #b3d8ff;
@@ -901,7 +736,6 @@
   font-size: 13px;
 }
 
-/* 淇℃伅鎸夐挳鍏ㄥ眬鏍峰紡 */
 .el-button--info {
   --el-button-bg-color: #e8f4f8;
   --el-button-border-color: #409eff;
@@ -911,7 +745,6 @@
   --el-button-hover-text-color: #1989fa;
 }
 
-/* 纭寮圭獥鏍峰紡浼樺寲 */
 .el-message-box {
   border-radius: 12px !important;
   box-shadow: 0 4px 20px rgba(64, 158, 255, 0.15);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/StockTakeGroupPallet.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/StockTakeGroupPallet.vue"
new file mode 100644
index 0000000..20885b9
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/StockTakeGroupPallet.vue"
@@ -0,0 +1,1124 @@
+<template>
+  <vol-box v-model="show" :title="'缁勭洏鎿嶄綔 - 鍗曟嵁鍙凤細' + orderNo" :height="1000" :width="1100" :padding="20" :modal="true">
+    <div class="barcode-scanner-container">
+
+      <!-- 浠撳簱閫夋嫨 - 绱у噾甯冨眬 -->
+      <div class="location-section compact">
+        <el-form :model="form" :rules="rules" ref="locationForm" class="compact-form">
+          <el-form-item label="鍏ュ簱浠撳簱" prop="warehouseType" class="location-select compact-item">
+            <el-select v-model="form.warehouseType" placeholder="璇烽�夋嫨浠撳簱" clearable filterable
+              @change="handleWarehouseChange" style="width: 100%" :loading="warehouseLoading" size="medium">
+              <el-option v-for="item in warehouseTypes" :key="item.warehouseType" :label="item.warehouseTypeDesc"
+                :value="item.warehouseType" />
+            </el-select>
+          </el-form-item>
+        </el-form>
+      </div>
+
+      <!-- 浠撳簱鍖哄煙閫夋嫨 - 绱у噾甯冨眬 -->
+      <div class="location-section compact">
+        <el-form :model="form" :rules="rules" ref="locationForm" class="compact-form">
+          <el-form-item label="浠撳簱鍖哄煙" prop="locationType" class="location-select compact-item">
+            <el-select v-model="form.locationType" placeholder="璇峰厛閫夋嫨浠撳簱" clearable filterable
+              @change="handleLocationChange" style="width: 100%" :loading="locationLoading" size="medium">
+              <el-option v-for="item in locationTypes" :key="item.locationType" :label="item.locationTypeDesc"
+                :value="item.locationType" />
+            </el-select>
+          </el-form-item>
+        </el-form>
+      </div>
+
+      <!-- 鎵樼洏淇℃伅鏄剧ず - 绱у噾甯冨眬 -->
+      <div class="tray-info compact" v-if="trayBarcode">
+        <i class="el-icon-s-management"></i> 褰撳墠鏂欑: {{ trayBarcode }}
+        <span class="location-info" v-if="form.warehouseType">
+          | 浠撳簱: {{ currentWarehouseName }}
+        </span>
+        <span class="location-info" v-if="form.locationType">
+          | 浠撳簱鍖哄煙: {{ currentLocationDesc }}
+        </span>
+      </div>
+
+      <!-- 鎵爜鍖哄煙 - 绱у噾甯冨眬 -->
+      <div class="input-section compact">
+        <el-card shadow="hover" class="compact-card">
+          <div slot="header" class="compact-header">
+            <span><i class="el-icon-scanner"></i> 鎵爜鍖哄煙</span>
+            <span class="scan-status">
+              <span class="scan-indicator"></span>
+              {{ form.locationType && form.warehouseType ? '鎵爜灏辩华' : '璇峰厛閫夋嫨浠撳簱鍜屼粨搴撳尯鍩�' }}
+            </span>
+          </div>
+
+          <!-- 鎵樼洏鏉$爜杈撳叆 -->
+          <div class="input-wrapper custom-input-group compact-input">
+            <div class="input-label">鎵樼洏鏉$爜</div>
+            <el-input ref="trayInput" v-model="trayBarcode" placeholder="璇锋壂鎻忔垨杈撳叆鏂欑鐮佸悗鎸夊洖杞﹂敭" clearable
+              :disabled="!form.locationType || !form.warehouseType" @keyup.enter.native="handleTraySubmit"
+              @clear="handleTrayClear" @input="handleTrayInput" class="custom-input" size="medium">
+              <template slot="append">
+                <el-button @click="handleTraySubmit" type="primary" icon="el-icon-position"
+                  :disabled="!form.locationType || !trayBarcode || !form.warehouseType" size="medium">
+                  纭
+                </el-button>
+              </template>
+            </el-input>
+          </div>
+
+          <!-- 鐗╂枡鏉$爜杈撳叆 -->
+          <div class="input-wrapper custom-input-group compact-input">
+            <div class="input-label">鐗╂枡鏉$爜</div>
+            <el-input ref="barcodeInput" v-model="barcode" placeholder="璇锋壂鎻忔垨杈撳叆鐗╂枡鏉$爜鍚庢寜鍥炶溅閿�" clearable
+              :disabled="!form.locationType || !trayBarcode || !form.warehouseType"
+              @keyup.enter.native="handleBarcodeSubmit" @clear="handleClear" @input="handleBarcodeInput"
+              class="custom-input" size="medium">
+              <template slot="append">
+                <el-button :loading="loading" @click="handleBarcodeSubmit" type="primary" icon="el-icon-search"
+                  :disabled="!form.locationType || !trayBarcode || !barcode || !from.warehouseType" size="medium">
+                  {{ loading ? '鏌ヨ涓�...' : '鏌ヨ' }}
+                </el-button>
+              </template>
+            </el-input>
+          </div>
+
+          <div class="input-tips compact-tips">
+            <p>鎻愮ず锛氳鍏堥�夋嫨浠撳簱 鈫� 閫夋嫨浠撳簱鍖哄煙 鈫� 杈撳叆鏂欑鐮� 鈫� 杈撳叆鐗╂枡鏉$爜</p>
+            <p v-if="!form.warehouseType" class="warning-text">鈿狅笍 璇峰厛閫夋嫨浠撳簱</p>
+            <p v-if="!form.locationType && !form.warehouseType" class="warning-text">鈿狅笍 璇峰厛閫夋嫨浠撳簱鍖哄煙</p>
+            <p v-if="form.warehouseType && form.locationType && !trayBarcode" class="warning-text">鈿狅笍 璇峰厛杈撳叆鏂欑鐮�</p>
+          </div>
+
+        </el-card>
+      </div>
+
+      <!-- 鍔犺浇鐘舵�� -->
+      <div v-if="loading" class="loading compact">
+        <el-progress :percentage="100" status="success" :show-text="false" />
+        <p>姝e湪鏌ヨ鐗╂枡淇℃伅...</p>
+      </div>
+
+      <!-- 閿欒鎻愮ず -->
+      <div v-if="error" class="error-message compact">
+        <el-alert :title="error" type="error" show-icon closable @close="error = ''" />
+      </div>
+
+      <!-- 鏈粍鐩樺垪琛� -->
+      <div class="unpallet-section compact">
+        <el-card shadow="hover" class="compact-card unpallet-card">
+          <div slot="header" class="compact-header">
+            <span><i class="el-icon-tickets"></i> 鏈粍鐩樻潯鐮�</span>
+            <span class="list-actions">
+              <el-tag type="primary" size="small">鏈粍鐩� {{ totalStockCount }}</el-tag>
+            </span>
+          </div>
+
+
+          <div class="table-container">
+            <el-table :data="unpalletMaterials" stripe style="width: 100%" height="100%" size="small"
+              v-loading="unpalletBarcodesLoading">
+              <el-table-column type="index" label="搴忓彿" width="60" align="center"></el-table-column>
+              <el-table-column prop="barcode" label="鏉$爜" min-width="140" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="materielCode" label="鐗╂枡缂栫爜" min-width="150" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="batchNo" label="鎵规" min-width="150" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="orderQuantity" label="鏁伴噺" min-width="130" align="right"></el-table-column>
+              <el-table-column prop="unit" label="鍗曚綅" width="80" align="center"></el-table-column>
+              <el-table-column prop="supplyCode" label="渚涘簲鍟�" min-width="130" show-overflow-tooltip></el-table-column>
+            </el-table>
+          </div>
+        </el-card>
+
+      </div>
+
+      <!-- 鐗╂枡鍒楄〃 - 鍥哄畾楂樺害甯︽粴鍔ㄦ潯 -->
+      <div class="material-list compact">
+        <el-card shadow="hover" class="compact-card">
+          <div slot="header" class="compact-header">
+            <span><i class="el-icon-tickets"></i> 缁勭洏鏁版嵁</span>
+            <span class="list-actions">
+              <el-tag type="primary" size="small">鍏� {{ materials.length }} 鏉�</el-tag>
+              <el-tag type="primary" size="small">鏈叆搴撴暟閲� {{ totalStockSum }}{{ uniqueUnit }}</el-tag>
+              <el-tag v-if="trayBarcode" type="success" size="small">鎵樼洏: {{ trayBarcode }}</el-tag>
+              <el-tag v-if="form.warehouseType" type="info" size="small">浠撳簱: {{ currentWarehouseName }}</el-tag>
+              <el-tag v-if="form.locationType" type="info" size="small">鍖哄煙: {{ currentLocationDesc }}</el-tag>
+            </span>
+          </div>
+
+          <div v-if="materials.length === 0" class="empty-state compact">
+            <i class="el-icon-document"></i>
+            <p v-if="!form.warehouseType">璇峰厛閫夋嫨浠撳簱</p>
+            <p v-if="!form.locationType">璇峰厛閫夋嫨浠撳簱鍖哄煙</p>
+            <p v-else-if="!trayBarcode">璇峰厛杈撳叆鏂欑鏉$爜</p>
+            <p v-else>鏆傛棤鐗╂枡鏁版嵁锛岃鎵弿鎴栬緭鍏ョ墿鏂欐潯鐮�</p>
+          </div>
+
+          <div class="table-container" v-else>
+            <el-table :data="materials" stripe style="width: 100%" height="100%" size="small">
+              <el-table-column type="index" label="搴忓彿" width="60" align="center"></el-table-column>
+              <el-table-column prop="barcode" label="鏉$爜" min-width="140" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="materielCode" label="鐗╂枡缂栫爜" min-width="150" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="batchNo" label="鎵规" min-width="150" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="stockQuantity" label="鏁伴噺" min-width="130" align="right"></el-table-column>
+              <el-table-column prop="unit" label="鍗曚綅" width="80" align="center"></el-table-column>
+              <el-table-column prop="supplyCode" label="渚涘簲鍟�" min-width="130" show-overflow-tooltip></el-table-column>
+              <el-table-column prop="warehouseType" label="浠撳簱" min-width="120" show-overflow-tooltip></el-table-column>
+            </el-table>
+          </div>
+        </el-card>
+      </div>
+    </div>
+    <template #footer>
+      <el-button type="danger" size="small" @click="handleDialogClose()">鍏抽棴</el-button>
+    </template>
+  </vol-box>
+</template>
+<script>
+import http from '@/api/http.js';
+import VolBox from '@/components/basic/VolBox.vue';
+
+export default {
+  components: { VolBox },
+  data() {
+    return {
+      show: false,
+      orderNo: "",
+      palletVisible: this.visible,
+      trayBarcodeReg: /^[A-Z]\d{9}$/,
+      trayBarcode: '',
+      barcode: '',
+      materials: [],
+      loading: false,
+      error: '',
+      debugMode: false,
+      currentFocus: 'warehouse',
+
+      unpalletBarcodes: [],
+      unpalletBarcodesLoading: false,
+      unpalletMaterials: [], // 鏈粍鐩樿缁嗘暟鎹垪琛�
+
+      // 鎵爜鏋浉鍏冲彉閲�
+      scanCode: '',
+      lastKeyTime: null,
+      isManualInput: false,
+      isScanning: false,
+      scanTimer: null,
+      manualInputTimer: null,
+      scanTarget: 'tray', // 褰撳墠鎵爜鐩爣: tray 鎴� material
+
+      // 搴撳瓨缁熻鐩稿叧鍙橀噺
+      totalStockSum: 0,
+      totalStockCount: 0,
+      uniqueUnit: '',
+      sumLoading: false,
+      sumError: '',
+      // 浠撳簱鐩稿叧鍙橀噺
+      warehouseTypes: [],
+      warehouseLoading: false,
+      // 浠撳簱鍖哄煙鐩稿叧鍙橀噺
+      locationTypes: [],
+      locationLoading: false,
+      form: {
+        warehouseType: null,
+        locationType: null
+      },
+      rules: {
+        locationType: [
+          {
+            validator: this.validateLocationType,
+            trigger: 'change'
+          }
+        ],
+        trayBarcode: [
+          {
+            pattern: this.trayBarcodeReg,
+            message: '鎵樼洏鍙锋牸寮忛敊璇紙闇�涓�1涓ぇ鍐欏瓧姣�+9涓暟瀛楋紝濡侫000008024锛�',
+            trigger: 'blur'
+          }
+        ],
+        warehouseType: [
+          {
+            message: '璇烽�夋嫨浠撳簱',
+            trigger: 'change'
+          }
+        ]
+      }
+    }
+  },
+
+  computed: {
+    // 褰撳墠閫夋嫨鐨勪粨搴撳悕绉�
+    currentWarehouseName() {
+      const warehouse = this.warehouseTypes.find(item => item.warehouseType === this.form.warehouseType);
+      return warehouse ? warehouse.warehouseTypeDesc : '';
+    },
+    // 褰撳墠閫夋嫨鐨勪粨搴撳尯鍩熸弿杩�
+    currentLocationDesc() {
+      const location = this.locationTypes.find(item => item.locationType === this.form.locationType)
+      return location ? location.locationTypeDesc : ''
+    }
+  },
+  watch: {
+    visible(newVal, oldVal) {
+      this.palletVisible = newVal;
+
+      // 褰撲粠 false 鍙樹负 true 鏃讹紝琛ㄧず寮规鎵撳紑
+      if (newVal === true && oldVal === false) {
+        console.log('寮规鎵撳紑锛岄噸缃暟鎹�');
+        this.resetData();
+        this.$nextTick(() => {
+          setTimeout(() => {
+            this.fetchUnpalletMaterialDetails();
+          }, 300);
+        });
+      }
+
+      // 褰撲粠 true 鍙樹负 false 鏃讹紝琛ㄧず寮规鍏抽棴
+      if (newVal === false && oldVal === true) {
+        console.log('寮规鍏抽棴锛岄噸缃暟鎹�');
+        this.resetData();
+      }
+    },
+    palletVisible(newVal) {
+      this.$emit('update:visible', newVal);
+    },
+    docNo(newVal) {
+      if (newVal) {
+        this.palletForm = { palletCode: '', barcode: '' };
+        this.backData = [];
+        this.$refs.palletForm?.reset();
+        this.fetchUnpalletMaterialDetails();
+      }
+    }
+  },
+  mounted() {
+    document.addEventListener('keypress', this.handleKeyPress);
+  },
+  beforeDestroy() {
+    document.removeEventListener('keypress', this.handleKeyPress);
+    this.clearAllTimers();
+  },
+  methods: {
+    open() {
+      this.show = true;
+      this.orderNo = "";
+      this.resetData();
+      this.initLocationTypes();
+      this.initwarehouseTypes();
+      this.fetchUnpalletMaterialDetails();
+    },
+    validateLocationType(rule, value, callback) {
+      if (!this.form.warehouseType) {
+        callback(new Error('璇峰厛閫夋嫨浠撳簱'));
+      } else if (value === null || value === undefined || value === '') {
+        callback(new Error('璇烽�夋嫨浠撳簱鍖哄煙'));
+      } else {
+        callback();
+      }
+    },
+
+    // 鏍规嵁鏉$爜鍒楄〃鑾峰彇璇︾粏鏁版嵁
+    async fetchUnpalletMaterialDetails() {
+      try {
+        const response = await http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.orderNo, {});
+        if (response.status && Array.isArray(response.data)) {
+          this.unpalletMaterials = response.data;
+          this.unpalletBarcodes = response.data.map(item => item.barcode || '');
+          this.totalStockCount = response.data.length;
+        } else {
+          this.unpalletMaterials = [];
+        }
+      } catch (err) {
+        this.unpalletMaterials = this.unpalletBarcodes.map(barcode => ({
+          barcode: barcode,
+          materielCode: '-',
+          batchNo: '-',
+          stockQuantity: '-',
+          unit: '-',
+          supplyCode: '-',
+          warehouseType: '-'
+        }));
+      }
+    },
+    async initLocationTypes() {
+      try {
+        const { data } = await this.http.post("api/LocationInfo/GetLocationTypes")
+        this.locationTypes = data
+      } catch (e) {
+        this.$message.error('鑾峰彇鍖哄煙绫诲瀷澶辫触')
+      }
+    },
+    async initwarehouseTypes() {
+      try {
+        const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes")
+        this.warehouseTypes = data
+      } catch (e) {
+        this.$message.error('鑾峰彇鍖哄煙绫诲瀷澶辫触')
+      }
+    },
+
+    async fetchStockStatistics(orderNo) {
+      // 鍗曟嵁鍙蜂负绌烘椂涓嶆煡璇�
+      if (!orderNo) {
+        this.sumError = '鍗曟嵁鍙蜂负绌猴紝鏃犳硶缁熻';
+        return;
+      }
+
+      this.sumLoading = true;
+      this.sumError = '';
+      try {
+        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + orderNo, {});
+        if (response.data) {
+          this.totalStockSum = response.data.stockSumQuantity || 0;
+          this.totalStockCount = response.data.stockCount || 0;
+          this.uniqueUnit = response.data.uniqueUnit || '';
+        }
+      } catch (err) {
+        this.sumError = '缁熻鍔犺浇澶辫触';
+        this.totalStockSum = 0;
+        this.totalStockCount = 0;
+      } finally {
+        this.sumLoading = false;
+      }
+    },
+
+    async validateForm() {
+      return new Promise((resolve) => {
+        if (!this.$refs.locationForm) {
+          this.error = '琛ㄥ崟鏈垵濮嬪寲';
+          this.$message.warning('璇峰厛閫夋嫨浠撳簱鍖哄煙');
+          resolve(false);
+          return;
+        }
+
+        this.$refs.locationForm.validate((valid) => {
+          if (valid) {
+            this.error = '';
+            resolve(true);
+          } else {
+            if (!this.from.warehouseType) {
+              this.error = '璇峰厛閫夋嫨浠撳簱';
+            }
+            else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') {
+              this.error = '璇峰厛閫夋嫨浠撳簱鍖哄煙';
+            } else {
+              this.error = '璇锋鏌ヨ〃鍗曞~鍐欐槸鍚︽纭�';
+            }
+            resolve(false);
+          }
+        });
+      });
+    },
+    // 鑱氱劍鍒版墭鐩樿緭鍏ユ
+    focusTrayInput() {
+      if (this.$refs.trayInput && this.$refs.trayInput.$el) {
+        const inputEl = this.$refs.trayInput.$el.querySelector('input');
+        if (inputEl) {
+          inputEl.focus();
+          this.currentFocus = 'tray';
+          this.scanTarget = 'tray';
+          inputEl.select();
+        }
+      }
+    },
+
+    // 鑱氱劍鍒扮墿鏂欒緭鍏ユ
+    focusBarcodeInput() {
+      if (this.$refs.barcodeInput && this.$refs.barcodeInput.$el) {
+        const inputEl = this.$refs.barcodeInput.$el.querySelector('input');
+        if (inputEl) {
+          inputEl.focus();
+          this.currentFocus = 'material';
+          this.scanTarget = 'material';
+          inputEl.select();
+        }
+      }
+    },
+    // 閲嶇疆鎵�鏈夋暟鎹�
+    resetData() {
+      this.trayBarcode = '';
+      this.barcode = '';
+      this.materials = [];
+      this.unpalletBarcodes = [];
+      this.unpalletMaterials = [];
+      this.loading = false;
+      this.error = '';
+      this.scanCode = '';
+      this.lastKeyTime = null;
+      this.isManualInput = false;
+      this.isScanning = false;
+      this.currentFocus = 'warehouse';
+      this.scanTarget = 'tray';
+      this.clearAllTimers();
+      this.totalStockSum = 0;
+      this.totalStockCount = 0;
+      this.sumLoading = false;
+      this.sumError = '';
+      this.form = {
+        warehouseType: null,
+        locationType: null
+      }
+      this.warehouseTypes = [];
+      this.locationTypes = [];
+      // 娓呴櫎琛ㄥ崟楠岃瘉鐘舵��
+      this.$nextTick(() => {
+        if (this.$refs.locationForm) {
+          this.$refs.locationForm.clearValidate();
+        }
+      });
+    },
+
+    // 娓呴櫎鎵�鏈夎鏃跺櫒
+    clearAllTimers() {
+      if (this.manualInputTimer) {
+        clearTimeout(this.manualInputTimer);
+        this.manualInputTimer = null;
+      }
+      if (this.scanTimer) {
+        clearTimeout(this.scanTimer);
+        this.scanTimer = null;
+      }
+    },
+    handleDialogClose() {
+      this.show = false;
+      this.resetData();
+    },
+
+    // 纭鎸夐挳
+    async handleConfirm() {
+      if (!await this.validateForm()) return;
+
+      if (this.materials.length === 0) {
+        this.$message.warning('璇疯嚦灏戞坊鍔犱竴涓墿鏂�');
+        return;
+      }
+
+      if (!this.trayBarcode) {
+        this.$message.warning('璇疯緭鍏ユ墭鐩樻潯鐮�');
+        return;
+      }
+
+      const result = {
+        warehouseType: this.form.warehouseType,
+        warehouseName: this.currentWarehouseName,
+        locationType: this.form.locationType,
+        locationDesc: this.currentLocationDesc,
+        trayBarcode: this.trayBarcode,
+        materials: this.materials,
+        docNo: this.docNo
+      };
+
+      // 瑙﹀彂鐖剁粍浠剁殑 back-success 浜嬩欢
+      this.$emit('back-success', result);
+      this.palletVisible = false;
+    },
+    // 澶勭悊鎵樼洏杈撳叆
+    handleTrayInput() {
+      // 鏍囪涓烘墜鍔ㄨ緭鍏ユā寮�
+      this.isManualInput = true;
+      this.isScanning = false;
+
+      // 娓呴櫎涔嬪墠鐨勮鏃跺櫒
+      if (this.manualInputTimer) {
+        clearTimeout(this.manualInputTimer);
+      }
+
+      // 璁剧疆璁℃椂鍣紝濡傛灉涓�娈垫椂闂村唴娌℃湁杈撳叆锛屽垯閲嶇疆涓烘壂鐮佹ā寮�
+      this.manualInputTimer = setTimeout(() => {
+        this.isManualInput = false;
+      }, 1000);
+    },
+
+    // 澶勭悊鐗╂枡杈撳叆
+    handleBarcodeInput() {
+      // 鏍囪涓烘墜鍔ㄨ緭鍏ユā寮�
+      this.isManualInput = true;
+      this.isScanning = false;
+
+      // 娓呴櫎涔嬪墠鐨勮鏃跺櫒
+      if (this.manualInputTimer) {
+        clearTimeout(this.manualInputTimer);
+      }
+
+      // 璁剧疆璁℃椂鍣紝濡傛灉涓�娈垫椂闂村唴娌℃湁杈撳叆锛屽垯閲嶇疆涓烘壂鐮佹ā寮�
+      this.manualInputTimer = setTimeout(() => {
+        this.isManualInput = false;
+      }, 1000);
+    },
+
+    // 澶勭悊鎵樼洏鏉$爜鎻愪氦
+    async handleTraySubmit() {
+      // 鍏堢洿鎺ユ鏌ocationType锛岄伩鍏嶈〃鍗曢獙璇佺殑寮傛闂
+      if (!this.form.warehouseType) {
+        this.error = '璇峰厛閫夋嫨浠撳簱';
+        return;
+      }
+      if (!this.form.locationType) {
+        this.error = '璇峰厛閫夋嫨浠撳簱鍖哄煙';
+        //this.$message.warning('璇峰厛閫夋嫨浠撳簱鍖哄煙');
+        return;
+      }
+
+      // 鐒跺悗鍐嶈繘琛屽畬鏁寸殑琛ㄥ崟楠岃瘉
+      if (!await this.validateForm()) return;
+
+      const currentTrayBarcode = this.trayBarcode.trim();
+
+      if (!currentTrayBarcode) {
+        this.error = '璇疯緭鍏ユ垨鎵弿鎵樼洏鏉$爜';
+        return;
+      }
+
+      this.error = '';
+
+      if (!this.trayBarcodeReg.test(currentTrayBarcode)) {
+        // ElMessage.warning({
+        //   message: '鎵樼洏鍙锋牸寮忛敊璇�',
+        //   type: 'warning',
+        //   duration: 3000
+        // })
+        this.$message("鎵樼洏鍙锋牸寮忛敊璇�");
+        this.focusTrayInput();
+        return;
+      }
+
+      // 璁剧疆鎵樼洏鏉$爜鍚庯紝鑷姩鑱氱劍鍒扮墿鏂欒緭鍏ユ
+      this.focusBarcodeInput();
+
+      // this.$message({
+      //   message: `鎵樼洏鏉$爜宸茶缃�: ${currentTrayBarcode}`,
+      //   type: 'success',
+      //   duration: 2000
+      // });
+      this.$message.success(`鎵樼洏鏉$爜宸茶缃�: ${currentTrayBarcode}`);
+    },
+
+    // 娓呴櫎鎵樼洏
+    clearTray() {
+      this.trayBarcode = '';
+      this.materials = [];
+      this.focusTrayInput();
+      this.$message({
+        message: '鎵樼洏鏉$爜宸叉竻闄�',
+        type: 'info',
+        duration: 2000
+      });
+    },
+
+    // 娓呯┖鎵樼洏杈撳叆
+    handleTrayClear() {
+      this.error = '';
+    },
+
+    // 娓呯┖杈撳叆
+    handleClear() {
+      this.error = '';
+      this.scanCode = '';
+      this.isManualInput = false;
+      this.isScanning = false;
+    },
+
+
+    // 澶勭悊鐗╂枡鏉$爜鎻愪氦
+    async handleBarcodeSubmit() {
+      if (!await this.validateForm()) return;
+      const currentBarcode = this.barcode.trim();
+
+      if (!this.trayBarcode) {
+        this.error = '璇峰厛杈撳叆鎵樼洏鏉$爜';
+        this.focusTrayInput();
+        return;
+      }
+
+      if (!currentBarcode) {
+        this.error = '璇疯緭鍏ユ垨鎵弿鐗╂枡鏉$爜';
+        return;
+      }
+
+      this.focusBarcodeInput();
+      this.error = '';
+      this.loading = true;
+
+      try {
+        // 璋冪敤API鏌ヨ鐗╂枡淇℃伅
+        const materialData = await this.fetchMaterialData(currentBarcode);
+        if (!materialData || materialData.length === 0) {
+          return;
+        }
+
+        this.materials = [];
+        materialData.forEach(item => {
+          this.materials.push({
+            ...item,
+            trayCode: this.trayBarcode,
+            locationType: this.form.locationType,
+            locationDesc: this.currentLocationDesc,
+            scanTime: this.formatTime(new Date())
+          });
+        });
+        this.orderNo = materialData[0].orderNo;
+        await this.fetchStockStatistics(materialData[0].orderNo);
+        await this.fetchUnpalletMaterialDetails();
+        // 娓呯┖鐗╂枡杈撳叆妗嗗苟淇濇寔鑱氱劍
+        this.barcode = '';
+        this.scanCode = ''; // 娓呯┖鎵爜缂撳瓨
+        this.isScanning = false;
+
+        setTimeout(() => {
+          this.focusBarcodeInput();
+        }, 100);
+      } catch (err) {
+        this.error = err.message || '鏌ヨ鏉$爜淇℃伅澶辫触锛岃閲嶈瘯';
+        this.focusBarcodeInput();
+        setTimeout(() => {
+          // 閫変腑杈撳叆妗嗗唴鐨勯敊璇唴瀹癸紙纭繚focus瀹屾垚鍚庢墽琛岋級
+          const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input');
+          if (inputEl) inputEl.select();
+        }, 100);
+      } finally {
+        this.loading = false;
+      }
+    },
+
+    // API璇锋眰 - 鏇挎崲涓哄疄闄呯殑API璋冪敤
+    async fetchMaterialData(barcode) {
+      try {
+        const response = await http.post('/api/Inbound/StockTakeGroupPallet',
+          {
+            palletCode: this.trayBarcode,
+            barcode: barcode,
+            locationTypeDesc: this.currentLocationDesc,
+            locationType: this.form.locationType, // 娣诲姞浠撳簱鍖哄煙淇℃伅
+            warehouseType: this.form.warehouseType
+          }
+        );
+        let materialData;
+
+        if (typeof response.data === 'string') {
+
+          try {
+            materialData = JSON.parse(response.data);
+          } catch (e) {
+
+          }
+        } else {
+          materialData = response.data;
+        }
+        if (!response.status) {
+          this.error = response.message || '鏌ヨ鏉$爜淇℃伅澶辫触锛岃閲嶈瘯';
+        }
+
+        return materialData;
+
+      } catch (error) {
+        console.error('API璋冪敤澶辫触:', error);
+      }
+    },
+
+    // 澶勭悊鎵爜鏋緭鍏�
+    handleKeyPress(event) {
+      // 濡傛灉鏄墜鍔ㄨ緭鍏ユā寮忥紝涓嶅鐞嗘壂鐮佹灙閫昏緫
+      if (this.isManualInput) {
+        return;
+      }
+
+      const key = event.key;
+      const currentTime = new Date().getTime();
+
+      // 蹇界暐鐩存帴鎸変笅鐨勫洖杞﹂敭锛堢敱handleBarcodeSubmit澶勭悊锛�
+      if (key === 'Enter') {
+        if (this.scanCode.length > 0) {
+          // 闃绘榛樿鍥炶溅琛屼负锛岄伩鍏嶈〃鍗曟彁浜�
+          event.preventDefault();
+
+          // 鎵爜瀹屾垚锛岃嚜鍔ㄨЕ鍙戞煡璇�
+          this.isScanning = false;
+
+          // 鏍规嵁褰撳墠鎵爜鐩爣璁剧疆鐩稿簲鐨勮緭鍏ユ鍊�
+          if (this.scanTarget === 'tray') {
+            this.trayBarcode = this.scanCode;
+            this.handleTraySubmit();
+          } else if (this.scanTarget === 'material') {
+            this.barcode = this.scanCode;
+            this.handleBarcodeSubmit();
+          }
+        }
+        this.scanCode = '';
+        this.lastKeyTime = null;
+        return;
+      }
+
+      // 鏋勫缓鎵爜鍐呭锛堝揩閫熻繛缁緭鍏ヨ涓烘壂鐮侊級
+      if (this.lastKeyTime && currentTime - this.lastKeyTime < 50) {
+        this.scanCode += key;
+        this.isScanning = true;
+      } else {
+        this.scanCode = key;
+        this.isScanning = true;
+      }
+
+      // 璁剧疆璁℃椂鍣紝濡傛灉涓�娈垫椂闂村唴娌℃湁杈撳叆锛屽垯閲嶇疆鎵弿鐘舵��
+      if (this.scanTimer) {
+        clearTimeout(this.scanTimer);
+      }
+      this.scanTimer = setTimeout(() => {
+        this.isScanning = false;
+      }, 100);
+
+      this.lastKeyTime = currentTime;
+    },
+
+    // 鏍煎紡鍖栨椂闂�
+    formatTime(date) {
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0');
+      const day = String(date.getDate()).padStart(2, '0');
+      const hours = String(date.getHours()).padStart(2, '0');
+      const minutes = String(date.getMinutes()).padStart(2, '0');
+      const seconds = String(date.getSeconds()).padStart(2, '0');
+
+      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+    }
+  }
+}
+</script>
+
+<style scoped>
+.barcode-scanner-container {
+  max-width: 1200px;
+  margin: 0 auto;
+  padding: 10px;
+  display: flex;
+  flex-direction: column;
+  height: 100%;
+  gap: 8px;
+}
+
+/* 绱у噾甯冨眬鏍峰紡 */
+.compact {
+  margin-bottom: 0;
+}
+
+.compact-form {
+  margin-bottom: 0;
+}
+
+.compact-item {
+  margin-bottom: 0;
+}
+
+.compact-card {
+  margin-bottom: 0;
+}
+
+.compact-card>>>.el-card__body {
+  padding: 12px;
+}
+
+.compact-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 0 !important;
+}
+
+.compact-header>>>.el-card__header {
+  padding: 8px 12px;
+}
+
+.compact-input {
+  margin: 8px 0;
+}
+
+.compact-tips {
+  margin-top: 8px;
+  font-size: 11px;
+}
+
+/* 浠撳簱鍖哄煙閫夋嫨 - 绱у噾 */
+.location-section.compact {
+  margin-bottom: 8px;
+}
+
+.location-section.compact>>>.el-form-item {
+  margin-bottom: 0;
+}
+
+/* 鎵樼洏淇℃伅 - 绱у噾 */
+.tray-info.compact {
+  padding: 6px 10px;
+  margin-bottom: 8px;
+  font-size: 13px;
+}
+
+/* 鎵爜鍖哄煙 - 绱у噾 */
+.input-section.compact {
+  margin-bottom: 8px;
+  flex-shrink: 0;
+}
+
+/* 鐗╂枡鍒楄〃 - 鍥哄畾楂樺害甯︽粴鍔� */
+.material-list.compact {
+  flex: 1;
+  min-height: 0;
+  /* 閲嶈锛氬厑璁竑lex瀛愰」鏀剁缉 */
+  display: flex;
+  flex-direction: column;
+}
+
+.material-list.compact>>>.el-card {
+  display: flex;
+  flex-direction: column;
+  height: 100%;
+}
+
+.material-list.compact>>>.el-card__body {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  padding: 0;
+  min-height: 0;
+}
+
+.table-container {
+  flex: 1;
+  min-height: 0;
+  overflow: hidden;
+}
+
+.material-list.compact>>>.el-table {
+  flex: 1;
+}
+
+.material-list.compact>>>.el-table__body-wrapper {
+  overflow-y: auto;
+}
+
+/* 绱у噾鐨勭┖鐘舵�� */
+.empty-state.compact {
+  padding: 20px 0;
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+}
+
+.empty-state.compact i {
+  font-size: 36px;
+  margin-bottom: 8px;
+}
+
+.empty-state.compact p {
+  font-size: 13px;
+}
+
+/* 鍏朵粬鍘熸湁鏍峰紡璋冩暣 */
+.page-title {
+  text-align: center;
+  margin-bottom: 15px;
+}
+
+.scan-status {
+  font-size: 12px;
+  color: #67C23A;
+}
+
+.scan-indicator {
+  display: inline-block;
+  width: 8px;
+  height: 8px;
+  border-radius: 50%;
+  background-color: #67C23A;
+  margin-right: 5px;
+  animation: pulse 1.5s infinite;
+}
+
+@keyframes pulse {
+  0% {
+    opacity: 1;
+  }
+
+  50% {
+    opacity: 0.4;
+  }
+
+  100% {
+    opacity: 1;
+  }
+}
+
+.input-wrapper {
+  position: relative;
+}
+
+.input-tips {
+  margin-top: 6px;
+  color: #909399;
+}
+
+.warning-text {
+  color: #E6A23C;
+  font-weight: bold;
+}
+
+.loading.compact {
+  text-align: center;
+  margin: 10px 0;
+  padding: 5px;
+}
+
+.loading.compact p {
+  margin-top: 5px;
+  color: #409EFF;
+  font-size: 12px;
+}
+
+.error-message.compact {
+  margin: 5px 0;
+}
+
+.error-message.compact>>>.el-alert {
+  padding: 6px 12px;
+}
+
+.list-actions {
+  display: flex;
+  align-items: center;
+  gap: 4px;
+}
+
+.list-actions>>>.el-tag {
+  height: 24px;
+  line-height: 22px;
+  padding: 0 6px;
+}
+
+.clear-all-btn {
+  margin-left: 8px;
+}
+
+.material-code {
+  font-family: 'Courier New', monospace;
+  font-weight: bold;
+  color: #409EFF;
+}
+
+.location-info {
+  color: #606266;
+  font-weight: normal;
+}
+
+.debug-info {
+  background: #f5f7fa;
+  padding: 8px;
+  border-radius: 4px;
+  margin-top: 8px;
+  font-size: 11px;
+  color: #909399;
+}
+
+.small-button {
+  padding: 6px 8px;
+  font-size: 11px;
+}
+
+/* 杈撳叆妗嗙粍鏍峰紡璋冩暣 */
+.custom-input-group {
+  display: flex;
+  align-items: center;
+  width: 100%;
+  margin: 8px 0;
+  border: 1px solid #DCDFE6;
+  border-radius: 4px;
+  overflow: hidden;
+  background: #fff;
+}
+
+.input-label {
+  padding: 0 12px;
+  background: #F5F7FA;
+  border-right: 1px solid #DCDFE6;
+  color: #606266;
+  font-size: 13px;
+  white-space: nowrap;
+  height: 36px;
+  line-height: 36px;
+  flex-shrink: 0;
+  min-width: 70px;
+  text-align: center;
+}
+
+.input-container {
+  display: flex;
+  flex: 1;
+  align-items: center;
+}
+
+.custom-input {
+  flex: 1;
+}
+
+.custom-input>>>.el-input__inner {
+  border: none;
+  border-radius: 0;
+  height: 36px;
+  line-height: 36px;
+  font-size: 13px;
+}
+
+/* 鍝嶅簲寮忚皟鏁� */
+@media (max-width: 768px) {
+  .barcode-scanner-container {
+    padding: 5px;
+  }
+
+  .custom-input-group {
+    flex-direction: column;
+    border: none;
+  }
+
+  .input-label {
+    width: 100%;
+    border-right: none;
+    border-bottom: 1px solid #DCDFE6;
+    margin-bottom: 5px;
+  }
+
+  .input-container {
+    width: 100%;
+    border: 1px solid #DCDFE6;
+    border-radius: 4px;
+  }
+
+  .unpallet-section.compact {
+    margin-bottom: 8px;
+    flex-shrink: 0;
+  }
+
+  .unpallet-card {
+    flex-shrink: 0;
+  }
+
+  .unpallet-barcode-list {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 6px;
+    padding: 8px 0;
+    max-height: 180px;
+    overflow-y: auto;
+  }
+
+  .unpallet-barcode-list>>>.el-tag {
+    cursor: pointer;
+    max-width: calc(33.333% - 4px);
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+
+  @media (max-width: 768px) {
+    .unpallet-barcode-list>>>.el-tag {
+      max-width: calc(50% - 4px);
+    }
+  }
+}
+</style>
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/TakeStockSelect.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/TakeStockSelect.vue"
index f80b6ae..bc75900 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/TakeStockSelect.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/TakeStockSelect.vue"
@@ -1,81 +1,30 @@
 <template>
   <el-dialog
     v-model="dialogVisible"
-    title="鏉傛敹鏉傚彂骞宠处"
-    width="1000px"
+    title="鏉傚彂骞宠处"
+    width="600px"
     :close-on-click-modal="false"
     :destroy-on-close="true"
     @closed="handleDialogClosed"
   >
     <div class="reconciliation-container">
-      <!-- 鍗曟嵁鍩烘湰淇℃伅 -->
-      <div class="order-info">
-        <div class="info-row">
-          <span class="label">鍗曟嵁ID锛�</span>
-          <span class="value">{{ currentRow.id || "-" }}</span>
-        </div>
-        <div class="info-row" v-if="selectedItem">
-          <span class="label">宸查�夎鍗曪細</span>
-          <span class="value selected-order">{{ selectedItem.id }}</span>
-        </div>
+      <!-- 绉婚櫎鍗曟嵁ID灞曠ず锛屼粎淇濈暀鏉$爜杈撳叆妗� -->
+      <!-- 鏉$爜杈撳叆妗� -->
+      <div class="barcode-input-container">
+        <el-input
+          v-model="barcode"
+          placeholder="璇疯緭鍏�/鎵弿鏉$爜鍚庡钩璐�"
+          clearable
+          @keyup.enter="handleEnterConfirm"
+          class="barcode-input"
+          :disabled="loading"
+        />
       </div>
 
-      <!-- 鏁版嵁鍒楄〃灞曠ず -->
-      <el-scrollbar height="400px" class="custom-scrollbar">
-        <transition-group name="data-item-transition">
-          <div
-            class="data-item"
-            v-for="(item, index) in displayData"
-            :key="`${item.orderId}-${index}`"
-          >
-            <div class="radio-container">
-              <el-radio
-                v-model="selectedItem"
-                :label="item"
-                :value="item"
-                @change="handleRadioChange(item)"
-              ></el-radio>
-            </div>
-            <div class="data-detail">
-              <div class="detail-row">
-                <span class="label">璁㈠崟ID锛�</span>
-                <span class="value">{{ item.id || "-" }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">鐗╂枡缂栫爜锛�</span>
-                <span class="value">{{ item.materielCode || "-" }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">鐗╂枡鍚嶇О锛�</span>
-                <span class="value">{{ item.materielName || "-" }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">鎵规鍙凤細</span>
-                <span class="value">{{ item.batchNo || "-" }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">璁㈠崟鏁伴噺锛�</span>
-                <span class="value">{{ item.orderQuantity || 0 }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">鍗曚綅锛�</span>
-                <span class="value">{{ item.unit || "-" }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">渚涘簲鍟嗙紪鐮侊細</span>
-                <span class="value">{{ item.supplyCode || "-" }}</span>
-              </div>
-              <div class="detail-row">
-                <span class="label">浠撳簱缂栫爜锛�</span>
-                <span class="value">{{ item.warehouseCode || "-" }}</span>
-              </div>
-            </div>
-          </div>
-        </transition-group>
-        <div class="empty-tip" v-if="displayData.length === 0">
-          <span>鏆傛棤鐩稿叧鏁版嵁</span>
-        </div>
-      </el-scrollbar>
+      <!-- 绌烘彁绀猴紙浠呮潯鐮佷负绌烘椂鏄剧ず锛� -->
+      <div class="empty-tip" v-if="!barcode && !loading">
+        <span>璇疯緭鍏ユ潯鐮佸悗杩涜骞宠处鎿嶄綔</span>
+      </div>
     </div>
 
     <template #footer>
@@ -83,7 +32,7 @@
       <el-button
         type="primary"
         @click="handleConfirm"
-        :disabled="!selectedItem"
+        :disabled="!barcode || loading"
         :loading="loading"
       >
         {{ loading ? "骞宠处涓�..." : "纭骞宠处" }}
@@ -91,7 +40,7 @@
     </template>
   </el-dialog>
   
-  <!-- 鎵撳嵃缁勪欢锛堝繀椤诲湪妯℃澘涓0鏄庯紝鎵嶈兘閫氳繃ref鑾峰彇锛� -->
+  <!-- 鎵撳嵃缁勪欢锛堜繚鐣欏師鏈夐�昏緫锛� -->
   <printView ref="printViewRef" @parentcall="parentcall"></printView>
 </template>
 
@@ -103,52 +52,50 @@
 
 // 寮圭獥鏄剧ず鐘舵��
 const dialogVisible = ref(false);
-// 褰撳墠閫変腑鐨勮鏁版嵁
-const currentRow = ref({});
-// 瑕佸睍绀虹殑鏁版嵁鍒楄〃
-const displayData = ref([]);
-// 閫変腑鐨勬暟鎹」
-const selectedItem = ref(null);
+// 鏉$爜杈撳叆妗嗗��
+const barcode = ref("");
 // 鍔犺浇鐘舵��
 const loading = ref(false);
-// 澹版槑鎵撳嵃缁勪欢鐨剅ef寮曠敤锛堝叧閿細鏇夸唬this.$refs.printView锛�
+// 鎵撳嵃缁勪欢ref寮曠敤
 const printViewRef = ref(null);
 
-// 鎵撳紑寮圭獥鏂规硶锛堜緵鐖剁粍浠惰皟鐢級
-const open = (row, data) => {
-  currentRow.value = row;
-  displayData.value = data;
-  selectedItem.value = null; // 閲嶇疆閫夋嫨
+// 鎵撳紑寮圭獥鏂规硶锛堟棤鍙傛暟锛屼緵鐖剁粍浠剁洿鎺ヨ皟鐢級
+const open = () => {
+  barcode.value = ""; // 姣忔鎵撳紑寮圭獥閲嶇疆鏉$爜
   dialogVisible.value = true;
-};
-
-// 澶勭悊鍗曢�夋寜閽彉鍖�
-const handleRadioChange = (item) => {
-  selectedItem.value = item;
 };
 
 // 寮圭獥鍏抽棴鏃剁殑澶勭悊
 const handleDialogClosed = () => {
-  selectedItem.value = null;
+  barcode.value = "";
   loading.value = false;
 };
 
-// 鐖剁粍浠惰皟鐢ㄧ殑鍥炶皟锛堝鏋減rintView闇�瑕侊級
+// 鐖剁粍浠惰皟鐢ㄧ殑鍥炶皟锛堜繚鐣欏師鏈夐�昏緫锛�
 const parentcall = (params) => {
   console.log("printView鍥炶皟鍙傛暟锛�", params);
 };
 
-// 纭骞宠处鎿嶄綔
+// 鍥炶溅瑙﹀彂骞宠处锛堟壂鐮佹灙鑷姩鍥炶溅鏃惰皟鐢級
+const handleEnterConfirm = async () => {
+  if (!barcode.value) {
+    ElMessage.warning("璇疯緭鍏ユ潯鐮佸悗鍐嶆搷浣�");
+    return;
+  }
+  await handleConfirm();
+};
+
+// 纭骞宠处鎿嶄綔锛堟牳蹇冮�昏緫锛�
 const handleConfirm = async () => {
-  if (!selectedItem.value) {
-    ElMessage.warning("璇烽�夋嫨涓�鏉℃暟鎹繘琛屽钩璐﹀鐞�");
+  if (!barcode.value) {
+    ElMessage.warning("璇疯緭鍏ユ潯鐮佽繘琛屽钩璐﹀鐞�");
     return;
   }
 
   try {
     // 纭鎻愮ず
     await ElMessageBox.confirm(
-      `纭畾瑕佸璁㈠崟 ${selectedItem.value.id} 杩涜骞宠处澶勭悊鍚楋紵`,
+      `纭畾瑕佸鏉$爜 ${barcode.value} 杩涜骞宠处澶勭悊鍚楋紵`,
       "骞宠处纭",
       {
         confirmButtonText: "纭畾",
@@ -159,10 +106,9 @@
 
     loading.value = true;
 
-    // 璋冪敤骞宠处鎺ュ彛
+    // 璋冪敤骞宠处鎺ュ彛锛堜粎浼犻�抌arcode鍙傛暟锛�
     const params = {
-      id: currentRow.value.id, // 琛孖D
-      orderId: selectedItem.value.id, // 閫夋嫨鐨勫崟鎹畂rderId
+      barcode: barcode.value,
     };
 
     const response = await axios.get(
@@ -172,21 +118,20 @@
       }
     );
 
-    console.log("鎺ュ彛瀹屾暣杩斿洖鍊硷細", response); // 璋冭瘯鐢細鎵撳嵃瀹屾暣杩斿洖
-    
-    // 绗竴姝ワ細鏍¢獙鏈�澶栧眰鐘舵��
+    console.log("鎺ュ彛瀹屾暣杩斿洖鍊硷細", response); // 璋冭瘯鐢�
+
+    // 鏍¢獙鎺ュ彛杩斿洖鐘舵��
     if (response.data?.status) {
       ElMessage.success("骞宠处鎿嶄綔鎴愬姛");
       
-      // 绗簩姝ワ細瑙f瀽姝g‘鐨剆cannedDetail灞傜骇锛堜笁灞俤ata锛�
-      const thirdLayerData = response.data.data?.data; // 鍏抽敭淇锛氬彇绗笁灞俤ata
+      // 瑙f瀽杩斿洖鏁版嵁锛堜繚鐣欏師鏈夋墦鍗伴�昏緫锛�
+      const thirdLayerData = response.data.data?.data;
       const scannedDetail = thirdLayerData?.scannedDetail;
       
-      console.log("瑙f瀽鍚庣殑scannedDetail锛�", scannedDetail); // 璋冭瘯鐢細鎵撳嵃鐩爣鏁版嵁
+      console.log("瑙f瀽鍚庣殑scannedDetail锛�", scannedDetail);
       
-      // 绗笁姝ワ細鍒ゆ柇鎵撳嵃鏉′欢
+      // 鍒ゆ柇鎵撳嵃鏉′欢骞惰Е鍙戞墦鍗�
       if (scannedDetail?.isUnpacked && scannedDetail?.materialCodes?.length > 0) {
-        // 纭繚鎵撳嵃缁勪欢瀹炰緥瀛樺湪
         if (printViewRef.value) {
           console.log("瑙﹀彂鎵撳嵃鏂规硶锛屽弬鏁帮細", scannedDetail.materialCodes);
           printViewRef.value.open(scannedDetail.materialCodes);
@@ -197,21 +142,20 @@
         ElMessage.info("鏃犻渶鎵撳嵃锛氭湭婊¤冻鎷嗗寘鏉′欢鎴栨棤鐗╂枡缂栫爜鏁版嵁");
       }
       
-      dialogVisible.value = false;
+      dialogVisible.value = false; // 骞宠处鎴愬姛鍚庡叧闂脊绐�
     } else {
       ElMessage.error(response.data?.message || "骞宠处鎿嶄綔澶辫触");
     }
   } catch (error) {
-    // 瀹屽杽閿欒澶勭悊锛氬尯鍒嗙敤鎴峰彇娑堝拰鐪熷疄閿欒
+    // 鍖哄垎鐢ㄦ埛鍙栨秷鍜岀湡瀹為敊璇�
     if (error === "cancel" || error === "close") {
       ElMessage.info("宸插彇娑堝钩璐︽搷浣�");
       return;
     }
-    // 鎵撳嵃閿欒鏃ュ織锛屾柟渚挎帓鏌�
     console.error("骞宠处鎺ュ彛璋冪敤澶辫触锛�", error);
     ElMessage.error(`骞宠处鎿嶄綔澶辫触锛�${error.message || "缃戠粶寮傚父"}`);
   } finally {
-    loading.value = false;
+    loading.value = false; // 鏃犺鎴愬姛澶辫触锛岀粨鏉熷姞杞界姸鎬�
   }
 };
 
@@ -222,103 +166,24 @@
 </script>
 
 <style scoped>
-/* 鏍峰紡閮ㄥ垎涓嶅彉锛岀渷鐣ラ噸澶嶄唬鐮� */
 .reconciliation-container {
   padding: 10px 0;
 }
 
-.order-info {
-  margin-bottom: 20px;
-  padding: 10px;
-  background: #f5f7fa;
-  border-radius: 4px;
-  display: flex;
-  flex-wrap: wrap;
-  gap: 20px;
+/* 鏉$爜杈撳叆妗嗘牱寮� */
+.barcode-input-container {
+  margin: 20px 0;
 }
 
-.info-row {
-  display: flex;
-  align-items: center;
-}
-
-.label {
-  font-weight: 600;
-  color: #606266;
-  margin-right: 5px;
-  min-width: 80px;
-  text-align: right;
-}
-
-.value {
-  color: #303133;
-}
-
-.selected-order {
-  color: #409eff;
-  font-weight: 600;
-}
-
-.custom-scrollbar {
-  border: 1px solid #e4e7ed;
-  border-radius: 4px;
-}
-
-.data-item {
-  display: flex;
-  align-items: flex-start;
-  padding: 15px;
-  margin: 10px;
-  background: #fff;
-  border: 1px solid #e4e7ed;
-  border-radius: 4px;
-  transition: all 0.3s;
-}
-
-.data-item:hover {
-  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
-}
-
-.data-item.selected {
-  border-color: #409eff;
-  background-color: #f0f7ff;
-}
-
-.radio-container {
-  margin-right: 12px;
-  margin-top: 4px;
-}
-
-.data-detail {
-  display: grid;
-  grid-template-columns: repeat(2, 1fr);
-  gap: 10px;
-  flex: 1;
-}
-
-.detail-row {
-  display: flex;
-  align-items: center;
+.barcode-input {
+  width: 100%;
+  font-size: 16px;
+  height: 48px;
 }
 
 .empty-tip {
   text-align: center;
   padding: 50px 0;
   color: #909399;
-}
-
-.data-item-transition-enter-from,
-.data-item-transition-leave-to {
-  opacity: 0;
-  transform: translateY(10px);
-}
-
-.data-item-transition-enter-active,
-.data-item-transition-leave-active {
-  transition: all 0.3s ease;
-}
-
-:deep(.el-radio__label) {
-  display: none;
 }
 </style>
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue"
index e170fa5..2c19905 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue"
@@ -612,6 +612,7 @@
                         outboundQuantity: formData.outboundDecimal,
                         operator: "",
                         orderNo: this.row.orderNo,
+                        stockDetailIds:[]
                       };
 
                       this.http
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrder.js"
index cae7d0a..3f11655 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrder.js"
@@ -1,12 +1,14 @@
 // 鑷畾涔夋墿灞曚笟鍔′唬鐮�
 import gridBody from "./extend/OrderStockTake.vue";
+import gridHeader from "./extend/TakeStockSelect.vue";
+import gridFooter from "./extend/StockTakeGroupPallet.vue";
 
 let extension = {
   components: {
     // 鏌ヨ鐣岄潰鎵╁睍缁勪欢锛氬皢鑷畾涔夊脊绐楁敞鍐屼负 gridBody 缁勪欢
-    gridHeader: '',
+    gridHeader: gridHeader,
     gridBody: gridBody, // 瀵瑰簲浣犵殑鐩樼偣寮圭獥缁勪欢
-    gridFooter: '',
+    gridFooter: gridFooter,
     // 鏂板缓/缂栬緫寮瑰嚭妗嗘墿灞曠粍浠讹紙姝ゅ涓嶇敤锛岀暀绌猴級
     modelHeader: '',
     modelBody: '',
@@ -16,21 +18,27 @@
   buttons: { view: [], box: [], detail: [] }, // 鎵╁睍鎸夐挳锛堝闇�棰濆娣诲姞鍙湪姝ら厤缃級
   methods: {
     onInit() {
-      // 鎵惧埌 value 涓� "OrderStockTake" 鐨勬寜閽紙闇�鍦ㄦ鏋朵腑鎻愬墠閰嶇疆璇ユ寜閽級
       let OrderStockTakeBtn = this.buttons.find(x => x.value === 'OrderStockTake');
       if (OrderStockTakeBtn) {
         // 閲嶅啓鎸夐挳鐐瑰嚮浜嬩欢
         OrderStockTakeBtn.onClick = function () {
-          // 1. 鑾峰彇琛ㄦ牸閫変腑琛屾暟鎹�
-          let rows = this.$refs.table.getSelected();
-          if (rows.length === 0) return this.$error("璇烽�夋嫨涓�鏉$洏鐐瑰崟鎹暟鎹紒");
-          if (rows.length > 1) return this.$error("鍙兘閫夋嫨涓�鏉$洏鐐瑰崟鎹暟鎹紒");
-          
-          const selectedReceiptNo = rows[0].orderNo;
-          if (!selectedReceiptNo) return this.$error("閫変腑鐨勫崟鎹己灏戞湁鏁堢殑鍗曟嵁鍙凤紒");
+          this.$refs.gridBody.open();
+        };
+      }
+      let OutOrderStockTakeBtn = this.buttons.find(x => x.value === 'OutOrderStockTake');
+      if (OutOrderStockTakeBtn) {
+        // 閲嶅啓鎸夐挳鐐瑰嚮浜嬩欢
+        OutOrderStockTakeBtn.onClick = function () {
 
-          // 3. 璋冪敤鑷畾涔夊脊绐楃殑 open 鏂规硶锛屽苟浼犻�掑崟鎹彿锛堟牳蹇冿細缁欏脊绐椾紶鍙傦級
-          this.$refs.gridBody.open(selectedReceiptNo);
+          this.$refs.gridHeader.open();
+        };
+      }
+      let StockTakeGroupPalletBtn = this.buttons.find(x => x.value === 'StockTakeGroupPallet');
+      if (StockTakeGroupPalletBtn) {
+        // 閲嶅啓鎸夐挳鐐瑰嚮浜嬩欢
+        StockTakeGroupPalletBtn.onClick = function () {
+
+          this.$refs.gridFooter.open();
         };
       }
 
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrderDetail.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrderDetail.js"
index fb2ce17..ab7f6a7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrderDetail.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/takeStockOrderDetail.js"
@@ -18,19 +18,6 @@
   buttons: { view: [], box: [], detail: [] }, // 鎵╁睍鎸夐挳
   methods: {
     onInit() {
-      // 鍘熸湁鐩樼偣鎸夐挳閫昏緫淇濈暀
-      let OrderStockTakeBtn = this.buttons.find(x => x.value === 'OrderStockTake');
-      if (OrderStockTakeBtn) {
-        OrderStockTakeBtn.onClick = function () {
-          let rows = this.$refs.table.getSelected();
-          if (rows.length === 0) return this.$error("璇烽�夋嫨涓�鏉$洏鐐瑰崟鎹暟鎹紒");
-          if (rows.length > 1) return this.$error("鍙兘閫夋嫨涓�鏉$洏鐐瑰崟鎹暟鎹紒");
-          
-          const selectedReceiptNo = rows[0].orderNo;
-          if (!selectedReceiptNo) return this.$error("閫変腑鐨勫崟鎹己灏戞湁鏁堢殑鍗曟嵁鍙凤紒");
-          this.$refs.gridBody.open(selectedReceiptNo);
-        };
-      }
 
       // 鐩戝惉鍘熸湁寮圭獥浜嬩欢锛堜繚鐣欙級
       this.$nextTick(() => {
@@ -48,128 +35,9 @@
       });
 
       // ========== 鏂板鎿嶄綔鍒楋細浜哄伐骞宠处 + 鏉傛敹鏉傚彂骞宠处 ==========
-      this.columns.push({
-        field: 'operation',
-        title: '鎿嶄綔',
-        width: 200,
-        fixed: 'right',
-        align: 'center',
-        formatter: (row) => {
-          return `
-            <span style="cursor: pointer;color: #2d8cf0;margin-right: 10px;" class="manual-reconciliation">
-              <i class="el-icon-check"></i>浜哄伐骞宠处
-            </span>
-            <span style="cursor: pointer;color: #1989fa;" class="misc-reconciliation">
-              <i class="el-icon-edit"></i>鏉傛敹鏉傚彂骞宠处
-            </span>
-          `;
-        },
-        click: (row, column, event) => {
-          const target = event.target;
-          // 鍖哄垎鐐瑰嚮鐨勬槸浜哄伐骞宠处杩樻槸鏉傛敹鏉傚彂骞宠处
-          if (target.closest('.manual-reconciliation')) {
-            this.handleManualReconciliation(row); // 浜哄伐骞宠处閫昏緫
-          } else if (target.closest('.misc-reconciliation')) {
-            this.handleMiscReconciliation(row); // 鏉傛敹鏉傚彂骞宠处閫昏緫
-          }
-        }
-      });
+      
     },
-
-    // ========== 浜哄伐骞宠处鏍稿績閫昏緫 ==========
-    handleManualReconciliation(row) {
-      // 寮瑰嚭纭妗�
-      ElMessageBox.confirm(
-        '纭瑕佹墽琛屼汉宸ュ钩璐︽搷浣滃悧锛�',
-        '鎿嶄綔纭',
-        {
-          confirmButtonText: '纭',
-          cancelButtonText: '鍙栨秷',
-          type: 'warning'
-        }
-      ).then(async () => {
-        // 娣诲姞閬僵灞傞槻姝㈤噸澶嶇偣鍑�
-        const loading = ElLoading.service({
-          lock: true,
-          text: '澶勭悊涓紝璇风◢鍊�...',
-          background: 'rgba(0, 0, 0, 0.7)'
-        });
-
-        try {
-          // 璋冪敤浜哄伐骞宠处鎺ュ彛
-          const response = await this.http.get(`/api/TakeStockOrder/ManualReconciliation?id=${row.id}`);
-          if (response.status) {
-            ElMessage.success('浜哄伐骞宠处鎿嶄綔鎴愬姛锛�');
-            this.$refs.table.reload(); // 鍒锋柊琛ㄦ牸
-          } else {
-            ElMessage.error(`鎿嶄綔澶辫触锛�${response.message || '鏈煡閿欒'}`);
-          }
-        } catch (error) {
-        } finally {
-          // 鍏抽棴閬僵灞�
-          loading.close();
-        }
-      }).catch(() => {
-        ElMessage.info('宸插彇娑堜汉宸ュ钩璐︽搷浣�');
-      });
-    },
-
-    // ========== 鏉傛敹鏉傚彂骞宠处鏍稿績閫昏緫锛堜慨鏀瑰悗锛� ==========
-    handleMiscReconciliation(row) {
-      // 閫変腑褰撳墠琛�
-      const table = this.$refs.table.$refs.table;
-      if (table) {
-        table.clearSelection();
-        table.toggleRowSelection(row, true);
-      }
-
-      // 璋冪敤鎺ュ彛鑾峰彇鏉傛敹鏉傚彂骞宠处鏁版嵁
-      const fetchMiscData = async () => {
-        const loading = ElLoading.service({
-          lock: true,
-          text: '鍔犺浇鏁版嵁涓�...',
-          background: 'rgba(0, 0, 0, 0.7)'
-        });
-
-        try {
-          // 璋冪敤鎺ュ彛锛屼紶閫抮ow涓殑remark鍜宨d鍙傛暟
-          const response = await this.http.get(`/api/TakeStockOrder/SelectOrder?remark=${row.remark || ''}&id=${row.id}`);
-          loading.close();
-          
-          if (response.status) {
-            if (!Array.isArray(response.data) || response.data.length === 0) {
-              ElMessage.warning("鏈煡璇㈠埌鐩稿叧鏁版嵁");
-              // 鎵撳紑绌烘暟鎹殑寮圭獥
-              this.$refs.gridHeader.open(row, []);
-              return;
-            }
-
-            // 鎻愬彇闇�瑕佸睍绀虹殑瀛楁
-            const displayData = response.data.map(item => ({
-              id: item.id || '',
-              materielCode: item.materielCode || '',
-              materielName: item.materielName || '',
-              batchNo: item.batchNo || '',
-              orderQuantity: item.orderQuantity || 0,
-              unit: item.unit || '',
-              supplyCode: item.supplyCode || '',
-              warehouseCode: item.warehouseCode || ''
-            }));
-
-            // 鎵撳紑寮圭獥骞朵紶閫掑鐞嗗悗鐨勬暟鎹�
-            this.$refs.gridHeader.open(row, displayData);
-          } else {
-            ElMessage.error(`鏌ヨ澶辫触锛�${response.message || '鏈煡閿欒'}`);
-          }
-        } catch (error) {
-          loading.close();
-          ElMessage.error(`缃戠粶寮傚父锛�${error.message || '鎺ュ彛璋冪敤澶辫触'}`);
-        }
-      };
-
-      // 鎵ц鏁版嵁鏌ヨ骞舵墦寮�寮圭獥
-      fetchMiscData();
-    },
+    
 
     onInited() {
       // 妗嗘灦鍒濆鍖栧畬鎴愬悗鎵ц
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/DirectOutbound.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/DirectOutbound.vue"
index 5c8ddc4..d19763c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/DirectOutbound.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/DirectOutbound.vue"
@@ -69,6 +69,7 @@
                     outboundQuantity: this.keys.length > 1 ? 1 : this.outboundQuantity,
                     operator: "",
                     orderNo: this.orderNo,
+                    stockDetailIds:[]
                 };
                 console.log(requestParams);
                 this.http.post("api/Outbound/ProcessPickingOutbound", requestParams, '鏁版嵁澶勭悊涓�...')
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue"
index 55145a5..f2e53d8 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue"
@@ -3,7 +3,7 @@
     <vol-box
       v-model="showDetialBox"
       :lazy="true"
-      width="60%"
+      width="80%"
       :padding="15"
       title="鎸囧畾搴撳瓨"
     >
@@ -11,6 +11,8 @@
         <el-alert :closable="false" style="width: 100%">
           <el-row>
             <el-col :span="16">
+              <span class="less-style">鍗曟嵁缂栧彿锛歿{ mainOrderNo }}</span>
+              <el-divider direction="vertical"></el-divider>
               <span class="less-style">鐗╂枡鍚嶇О锛� {{ row.materielName }} </span>
               <el-divider direction="vertical"></el-divider>
               <span class="less-style">鐗╂枡缂栧彿锛� {{ row.materielCode }} </span>
@@ -92,12 +94,10 @@
         </el-table>
       </div>
       <template #footer>
-       <!--  <el-button type="primary" size="small" @click="outbound"
+       <el-button type="primary" size="small" @click="outbound"
           >鐩存帴鍑哄簱</el-button
         >
-        <el-button type="primary" size="small" @click="lockStock"
-          >閿佸畾搴撳瓨</el-button
-        > -->
+
         <el-button type="danger" size="small" @click="showDetialBox = false"
           >鍏抽棴</el-button
         >
@@ -114,6 +114,7 @@
     return {
       row: null,
       kcname: "",
+      mainOrderNo: '',
       pkcx: false,
       showDetialBox: false,
       tableData: [],
@@ -137,6 +138,12 @@
           width: 150,
         },
         {
+          prop: "barcode",
+          title: "鏉$爜",
+          type: "string",
+          width: 150,
+        },
+        {
           prop: "locationCode",
           title: "璐т綅缂栧彿",
           type: "string",
@@ -147,6 +154,25 @@
           title: "鍙敤鏁伴噺",
           type: "string",
         },
+        {
+          prop: "supplyCode",
+          title: "渚涘簲鍟�",
+          type: "string",
+        },
+        {
+          prop: "batchNo",
+          title: "鎵规鍙�",
+          type: "string",
+        },
+        {
+          prop: "stockId",
+          title: "搴撳瓨涓婚敭",
+          type: "string",
+        },{
+          prop: "orderDetailId",
+          title: "鍗曟嵁鏄庣粏涓婚敭",
+          type: "string",
+        },
       ],
       selection: [],
       selectionSum: 0,
@@ -155,13 +181,14 @@
     };
   },
   methods: {
-    open(row) {
-      console.log(row);
-      this.row = row;
-      this.showDetialBox = true;
+    open(row, orderNo) {
+    this.row = row;
+    this.mainOrderNo = orderNo; // 瀛樺偍涓诲崟鎹紪鍙�
+    this.showDetialBox = true;
       this.originalQuantity = this.row.lockQuantity;
       this.selectionSum = this.row.lockQuantity;
       this.getData();
+
       if (this.selectionSum == this.row.orderQuantity) {
         this.selectionClass = "equle-style";
       } else if (this.selectionSum < this.row.orderQuantity) {
@@ -220,23 +247,7 @@
           this.tableData = x;
         });
     },
-    revokeAssign() {
-      console.log(this.row);
-      this.http
-        .post(
-          "api/OutboundOrderDetail/RevokeLockOutboundStock?id=" + this.row.id,
-          null,
-          "鏁版嵁澶勭悊涓�"
-        )
-        .then((x) => {
-          if (!x.status) return this.$message.error(x.message);
-          this.$message.success("鎿嶄綔鎴愬姛");
-          this.showDetialBox = false;
-          this.$emit("parentCall", ($vue) => {
-            $vue.getData();
-          });
-        });
-    },
+  
     handleSelectionChange(val) {
       this.selection = val;
       this.selectionSum =
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue"
index 7d27ed6..7687237 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/outOrderDetail.vue"
@@ -1,6 +1,12 @@
 <template>
   <div>
-    <vol-box v-model="showDetialBox" :lazy="true" width="75%" :padding="15" title="鍗曟嵁鏄庣粏淇℃伅">
+    <vol-box
+      v-model="showDetialBox"
+      :lazy="true"
+      width="75%"
+      :padding="15"
+      title="鍗曟嵁鏄庣粏淇℃伅"
+    >
       <div class="box-head">
         <el-alert :closable="false" style="width: 100%">
           <el-row>
@@ -8,33 +14,89 @@
               <span>宸查�変腑 {{ selection.length }} 椤�</span>
             </el-col>
             <el-col :span="8">
-              <el-link type="primary" size="small" v-if="isBatch === 0" style="float: right; height: 20px"
-                @click="handleOpenPicking">鎷i��</el-link>
-              <el-link type="primary" size="small" style="float: right; height: 20px; margin-right: 10px"
-                v-if="isBatch === 1" @click="handleOpenBatchPicking">鍒嗘壒鎷i��</el-link>
-              <el-link type="primary" size="small" v-if="isBatch === 0"
-                style="float: right; height: 20px; margin-right: 10px" @click="outbound">鐩存帴鍑哄簱</el-link>
-              <el-link type="primary" size="small" v-if="isBatch === 1"
-                style="float: right; height: 20px; margin-right: 10px" @click="outboundbatch">鍒嗘壒鍑哄簱</el-link>
-              <el-link type="primary" size="small" style="float: right; height: 20px; margin-right: 10px"
-                @click="getData">鍒锋柊</el-link>
+              <el-link
+                type="primary"
+                size="small"
+                v-if="isBatch === 0"
+                style="float: right; height: 20px"
+                @click="handleOpenPicking"
+                >鎷i��</el-link
+              >
+              <el-link
+                type="primary"
+                size="small"
+                style="float: right; height: 20px; margin-right: 10px"
+                v-if="isBatch === 1"
+                @click="handleOpenBatchPicking"
+                >鍒嗘壒鎷i��</el-link
+              >
+              <el-link
+                type="primary"
+                size="small"
+                v-if="isBatch === 0"
+                style="float: right; height: 20px; margin-right: 10px"
+                @click="outbound"
+                >鐩存帴鍑哄簱</el-link
+              >
+              <el-link
+                type="primary"
+                size="small"
+                v-if="isBatch === 1"
+                style="float: right; height: 20px; margin-right: 10px"
+                @click="outboundbatch"
+                >鍒嗘壒鍑哄簱</el-link
+              >
+              <el-link
+                type="primary"
+                size="small"
+                style="float: right; height: 20px; margin-right: 10px"
+                @click="getData"
+                >鍒锋柊</el-link
+              >
             </el-col>
           </el-row>
         </el-alert>
       </div>
       <div class="box-table" style="margin-top: 1%">
-        <el-table ref="singleTable" :data="tableData" style="width: 100%; height: 100%" highlight-current-row
-          @current-change="handleCurrentChange" height="500px" @row-click="handleRowClick"
-          @selection-change="handleSelectionChange">
+        <el-table
+          ref="singleTable"
+          :data="tableData"
+          style="width: 100%; height: 100%"
+          highlight-current-row
+          @current-change="handleCurrentChange"
+          height="500px"
+          @row-click="handleRowClick"
+          @selection-change="handleSelectionChange"
+        >
           <el-table-column type="selection" width="55"> </el-table-column>
-          <el-table-column label="搴忓彿" type="index" fixed="left" width="55" align="center"></el-table-column>
-          <el-table-column v-for="(item, index) in tableColumns.filter((x) => !x.hidden)" :key="index" :prop="item.prop"
-            :label="item.title" :width="item.width" align="center">
+          <el-table-column
+            label="搴忓彿"
+            type="index"
+            fixed="left"
+            width="55"
+            align="center"
+          ></el-table-column>
+          <el-table-column
+            v-for="(item, index) in tableColumns.filter((x) => !x.hidden)"
+            :key="index"
+            :prop="item.prop"
+            :label="item.title"
+            :width="item.width"
+            align="center"
+          >
             <template #default="scoped">
               <div v-if="item.type == 'icon'">
-                <el-tooltip class="item" effect="dark" :content="item.title" placement="bottom">
-                  <el-link type="primary" :disabled="getButtonEnable(item.prop, scoped.row)"
-                    @click="tableButtonClick(scoped.row, item)">
+                <el-tooltip
+                  class="item"
+                  effect="dark"
+                  :content="item.title"
+                  placement="bottom"
+                >
+                  <el-link
+                    type="primary"
+                    :disabled="getButtonEnable(item.prop, scoped.row)"
+                    @click="tableButtonClick(scoped.row, item)"
+                  >
                     <i :class="item.icon" style="font-size: 22px"></i>
                   </el-link>
                 </el-tooltip>
@@ -53,9 +115,15 @@
       </div>
     </vol-box>
     <stock-select ref="child" @parentCall="parentCall"></stock-select>
-    <selected-stock ref="selectedStock" @parentCall="parentCall"></selected-stock>
+    <selected-stock
+      ref="selectedStock"
+      @parentCall="parentCall"
+    ></selected-stock>
     <NoStockOut ref="NoStockOut" @parentCall="parentCall"></NoStockOut>
-    <DirectOutbound ref="DirectOutbound" @parentCall="parentCall"></DirectOutbound>
+    <DirectOutbound
+      ref="DirectOutbound"
+      @parentCall="parentCall"
+    ></DirectOutbound>
   </div>
 </template>
 
@@ -79,7 +147,14 @@
 } from "element-plus";
 
 export default {
-  components: { VolBox, VolForm, StockSelect, SelectedStock, NoStockOut, DirectOutbound },
+  components: {
+    VolBox,
+    VolForm,
+    StockSelect,
+    SelectedStock,
+    NoStockOut,
+    DirectOutbound,
+  },
   data() {
     return {
       row: null,
@@ -290,14 +365,16 @@
         });
     },
     tableButtonClick(row, column) {
-      if (column.prop == "assignStock") {
-        this.$refs.child.open(row);
-      } else if (column.prop == "NoStockOut") {
-        this.$refs.NoStockOut.open(row);
-      } else {
-        this.$refs.selectedStock.open(row);
-      }
-    },
+  if (column.prop == "assignStock") {
+    this.$refs.child.open(row,this.row.orderNo);
+  } else if (column.prop == "NoStockOut") {
+    this.$refs.NoStockOut.open(row);
+  } else {
+    this.$refs.selectedStock.open(row);
+
+  }
+},
+
     lockstocks() {
       if (this.selection.length === 0) {
         return this.$message.error("璇烽�夋嫨鍗曟嵁鏄庣粏");
@@ -337,7 +414,7 @@
         outboundQuantity: 1,
         operator: "",
         orderNo: this.row.orderNo,
-        isBatch: this.isBatch
+        isBatch: this.isBatch,
       };
       console.log(requestParams);
       this.$refs.DirectOutbound.open(requestParams);
@@ -350,14 +427,14 @@
       const keys = this.selection.map((item) => item.id);
       const requestParams = {
         detailIds: keys,
-        outboundQuantity: this.selection[0].orderQuantity - this.selection[0].lockQuantity,
+        outboundQuantity:
+          this.selection[0].orderQuantity - this.selection[0].lockQuantity,
         operator: "",
         orderNo: this.row.orderNo,
-        isBatch: this.isBatch
+        isBatch: this.isBatch,
       };
       console.log(requestParams);
       this.$refs.DirectOutbound.open(requestParams);
-
     },
     setCurrent(row) {
       this.$refs.singleTable.setCurrentRow(row);
@@ -445,11 +522,11 @@
   background: oldlace;
 }
 
-.box-table .el-table tbody tr:hover>td {
+.box-table .el-table tbody tr:hover > td {
   background-color: #d8e0d4 !important;
 }
 
-.box-table .el-table tbody tr.current-row>td {
+.box-table .el-table tbody tr.current-row > td {
   background-color: #f0f9eb !important;
 }
 
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
index 6fa1f60..638df8b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
@@ -505,6 +505,7 @@
                       outboundQuantity: 1,
                       operator: this.currentOperator || "admin", 
                       orderNo: param,
+                      stockDetailIds:[]
                     };
 
                     try {
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/CalcOut/PickingOutboundRequestDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/CalcOut/PickingOutboundRequestDTO.cs"
index 18058e3..813f09f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/CalcOut/PickingOutboundRequestDTO.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_DTO/CalcOut/PickingOutboundRequestDTO.cs"
@@ -39,5 +39,7 @@
         /// 鍑哄簱鐩爣浣嶇疆
         /// </summary>
         public string OutboundTargetLocation { get; set; }
+
+        public List<int> StockDetailIds { get; set; }
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundService.cs"
index 8adfa6d..3ca1720 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundService.cs"
@@ -29,6 +29,12 @@
         /// <returns></returns>
         Task<WebResponseContent> AllcatedGroupPallet(GroupPalletDto palletDto);
 
+        /// <summary>
+        /// 鐩樼偣缁勭洏
+        /// </summary>
+        /// <param name="palletDto"></param>
+        /// <returns></returns>
+        Task<WebResponseContent> StockTakeGroupPallet(GroupPalletDto palletDto);
 
         /// <summary>
         /// 鍏ュ簱鍒嗘壒鍥炰紶
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/ITakeStockOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/ITakeStockOrderService.cs"
index f29a703..931c3ab 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/ITakeStockOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/ITakeStockOrderService.cs"
@@ -25,7 +25,9 @@
 
         WebResponseContent SelectOrder(string remark, int id);
 
-        WebResponseContent DocumentReconciliation(int orderId, int id);
+        WebResponseContent DocumentReconciliation(string barcode);
+
+        WebResponseContent StockTakeGroupPallet(string barcode, string boxNo);
 
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs"
index b2d5cb5..8a8c3b3 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundService.cs"
@@ -60,6 +60,6 @@
 
         public void PerformFullOutboundOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo,
             decimal actualOutboundQuantity, OutboundCompleteRequestDTO request, decimal beforeQuantity, int taskNum);
-      
-     }
+
+    }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
index 3c2b957..4a3c19c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
@@ -52,7 +52,8 @@
         private readonly HttpClientHelper _httpClientHelper;
         private readonly IRepository<Dt_MesReturnRecord> _mesReturnRecord;
         private readonly ILocationInfoService _locationInfoService;
-        public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord,ILocationInfoService locationInfoService)
+        private readonly IRepository<Dt_TakeStockOrder> _takeStockOrder;
+        public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord,ILocationInfoService locationInfoService,IRepository<Dt_TakeStockOrder> takeStockOrder)
         {
             _unitOfWorkManage = unitOfWorkManage;
             InboundOrderDetailService = inboundOrderDetailService;
@@ -68,6 +69,7 @@
             _httpClientHelper = httpClientHelper;
             _mesReturnRecord = mesReturnRecord;
             _locationInfoService = locationInfoService;
+            _takeStockOrder = takeStockOrder;
         }
 
         public async Task<WebResponseContent> GroupPallet(GroupPalletDto palletDto)
@@ -594,5 +596,125 @@
 
             return httpResponseResult;
         }
+
+        public async Task<WebResponseContent> StockTakeGroupPallet(GroupPalletDto palletDto)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                (bool, string, object?) result2 = ModelValidate.ValidateModelData(palletDto);
+                if (!result2.Item1) return content.Error(result2.Item2);
+
+                // 楠岃瘉浠撳簱缂栧彿鏄惁瀛樺湪
+                var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>()
+                    .Where(x => x.Code == palletDto.WarehouseType)
+                    .Select(x => x.Code)
+                    .First();
+                if (string.IsNullOrEmpty(code))
+                {
+                    return content.Error($"浠撳簱涓病鏈夎{palletDto.WarehouseType}缂栧彿銆�");
+                }
+
+                // 鏌ヨ褰撳墠鎵樼洏鐨勫簱瀛樹俊鎭�
+                Dt_StockInfo? stockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>()
+                    .Includes(x => x.Details)
+                    .Where(x => x.PalletCode == palletDto.PalletCode)
+                    .FirstAsync();
+
+                // 楠岃瘉鎵樼洏鏄惁宸茬敓鎴愪换鍔�
+                if (_taskRepository.QueryFirst(x => x.PalletCode == palletDto.PalletCode) != null)
+                {
+                    return content.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟");
+                }
+
+                // 楠岃瘉鎵樼洏鏄惁宸蹭笂鏋讹紙宸蹭笂鏋朵笉鑳界粍鐩橈級
+                if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != (int)StockStatusEmun.缁勭洏鏆傚瓨)
+                {
+                    return content.Error("宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏");
+                }
+
+                Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+                    .Where(x => x.Barcode == palletDto.Barcode && x.StockId == 0)
+                    .First();
+                if (stockInfoDetail == null)
+                {
+                    return content.Error($"{palletDto.Barcode} 鏉$爜宸插叧鑱斿叾浠栨墭鐩橈紝鏃犳硶缁勭洏");
+                }
+
+                Dt_TakeStockOrder takeStockOrder = _takeStockOrder.Db.Queryable<Dt_TakeStockOrder>()
+                    .Where(x => x.OrderNo == stockInfoDetail.OrderNo)
+                    .First();
+                if (takeStockOrder == null)
+                {
+                    return content.Error($"{palletDto.Barcode} 涓嶅睘浜庣洏鐐瑰崟鎹腑鐨勬潯鐮侊紝涓嶅厑璁哥洏浜忕粍鐩�");
+                }
+                if (stockInfo == null)
+                {
+                    stockInfo = new Dt_StockInfo()
+                    {
+                        PalletType = (int)PalletTypeEnum.None,
+                        LocationType = Convert.ToInt32(palletDto.locationType),
+                        PalletCode = palletDto.PalletCode,
+                        StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+                        Details = new List<Dt_StockInfoDetail>()
+                    };
+                }
+
+                if (stockInfo.Details.Count > 0 && stockInfo.Details.FirstOrDefault()?.WarehouseCode != palletDto.WarehouseType)
+                {
+                    return content.Error($"璇ユ墭鐩樼粍鐩樹粨搴撲负{stockInfo.Details.FirstOrDefault()?.WarehouseCode}涓庡綋鍓嶄粨搴搟palletDto.WarehouseType}涓嶄竴鑷达紝涓嶅厑璁哥粍鐩�");
+                }
+
+                _unitOfWorkManage.BeginTran();
+
+                try
+                {
+                    if (stockInfo.Id == 0)
+                    {
+                        int newStockId = await _stockInfoRepository.Db.Insertable(stockInfo).ExecuteReturnIdentityAsync();
+                        stockInfo.Id = newStockId;
+                    }
+
+                    stockInfoDetail.StockId = stockInfo.Id;
+
+                    await _stockService.StockInfoDetailService.Db.Updateable(stockInfoDetail)
+                        .Where(x => x.Id == stockInfoDetail.Id)
+                        .ExecuteCommandAsync();
+
+                    if (stockInfo.Id != 0 && stockInfo.Details != null && !stockInfo.Details.Contains(stockInfoDetail))
+                    {
+                        stockInfo.Details.Add(stockInfoDetail);
+
+                        await _stockInfoRepository.Db.Updateable(stockInfo)
+                            .IgnoreColumns(x => x.Details)
+                            .ExecuteCommandAsync();
+                    }
+
+                    // 鎻愪氦浜嬪姟
+                    _unitOfWorkManage.CommitTran();
+                }
+                catch (Exception)
+                {
+                    // 浜嬪姟鍥炴粴
+                    _unitOfWorkManage.RollbackTran();
+                    throw; // 鎶涚粰澶栧眰catch澶勭悊鏃ュ織
+                }
+
+                // 鏌ヨ鏈�鏂扮殑搴撳瓨淇℃伅锛堝寘鍚叧鑱旂殑鏄庣粏锛�
+                Dt_StockInfo? NewstockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>()
+                    .Includes(x => x.Details)
+                    .Where(x => x.PalletCode == palletDto.PalletCode)
+                    .FirstAsync();
+
+                return WebResponseContent.Instance.OK(data: NewstockInfo.Details.OrderByDescending(x => x.Id));
+
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                LogFactory.GetLog($"缁勭洏淇℃伅").Info(true, $"銆愬紓甯搞�戯細銆恵ex.Message}銆憑Environment.NewLine}銆恵ex.StackTrace}銆憑Environment.NewLine}{Environment.NewLine}");
+                return content.Error(ex.Message);
+            }
+        }
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/TakeStockOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/TakeStockOrderService.cs"
index b1f62ed..3b0dbe7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/TakeStockOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/TakeStockOrderService.cs"
@@ -80,10 +80,10 @@
                 {
                     return WebResponseContent.Instance.Error("璇ユ墭鐩樺浜庨潪鐩樼偣鐘舵�侊紝璇锋鏌ョ洏鐐逛换鍔�");
                 }
-                Dt_TakeStockOrder takeStockOrder = _takeStockOrder.QueryFirst(x=>x.OrderNo == orderNo);
+                Dt_TakeStockOrder takeStockOrder = _takeStockOrder.QueryFirst(x=>x.AllPalletCode.Contains(boxNo)&& x.TakeStockStatus == TakeStockStatusEnum.鐩樼偣涓�.ObjToInt());
                 if (takeStockOrder == null)
                 {
-                    return WebResponseContent.Instance.Error("鏈壘鍒拌鐩樼偣鍗曟嵁");
+                    return WebResponseContent.Instance.Error("璇ユ墭鐩樻湭鎵惧埌璇ョ洏鐐瑰崟鎹�");
                 }
                 if (takeStockOrder.AllPalletCode.Contains(","))
                 {
@@ -103,8 +103,8 @@
                         return WebResponseContent.Instance.Error($"绠卞彿銆恵boxNo}銆戞湭鍦ㄧ洏鐐瑰崟绠卞彿銆恵takeStockOrder.AllPalletCode}銆戜腑鎵惧埌鍖归厤椤�");
                     }
                 }
-
-                return WebResponseContent.Instance.OK();
+                var resultData = new { takeStockOrder = takeStockOrder.OrderNo };
+                return WebResponseContent.Instance.OK(data:resultData);
             }
             catch(Exception ex)
             {
@@ -148,10 +148,6 @@
         {
             try
             {
-                if(completeStockTakeDTO.actualQuantity == completeStockTakeDTO.stockQuantity)
-                {
-                    return WebResponseContent.Instance.OK("璇ユ潯鐮佷负骞宠处锛屾棤闇�璁板綍宸紓");
-                }
                 Dt_TakeStockOrder takeStockOrder = _takeStockOrder.QueryFirst(x=>x.OrderNo == completeStockTakeDTO.orderNo);
                 if (takeStockOrder == null)
                 {
@@ -167,7 +163,6 @@
                 {
                     return WebResponseContent.Instance.Error("鏉$爜搴撳瓨鏁版嵁鏈壘鍒板尮閰嶆暟鎹�");
                 }
-                List<Dt_AllocateMaterialInfo> allocateMaterialInfos = new List<Dt_AllocateMaterialInfo>();
                 Dt_TakeStockOrderDetail takeStockOrderDetail = new Dt_TakeStockOrderDetail()
                 {
                     TakeStockId = takeStockOrder.Id,
@@ -179,7 +174,7 @@
                     Unit = stockInfoDetail.Unit,
                     SysQty = completeStockTakeDTO.stockQuantity,
                     Qty = completeStockTakeDTO.actualQuantity,
-                    Remark = completeStockTakeDTO.actualQuantity - completeStockTakeDTO.stockQuantity >= 0 ? "鐩樼泩" : "鐩樹簭",
+                    Remark = "鐩樹簭",
                     barcode = completeStockTakeDTO.barcode,
                     WarehouseCode = stockInfoDetail.WarehouseCode ?? "",
                     FactoryArea = stockInfoDetail.FactoryArea,
@@ -188,25 +183,12 @@
                     DifferenceQty = completeStockTakeDTO.actualQuantity - completeStockTakeDTO.stockQuantity
 
                 };
-                foreach (var item in stockInfo.Details)
-                {
-                    Dt_AllocateMaterialInfo allocateMaterialInfo = new Dt_AllocateMaterialInfo()
-                    {
-                        Barcode = item.Barcode,
-                        BatchNo = item.BatchNo,
-                        FactoryArea = item.FactoryArea,
-                        MaterialCode = item.MaterielCode,
-                        MaterialName = item.MaterielName,
-                        OrderId = takeStockOrder.Id,
-                        OrderNo = takeStockOrder.OrderNo,
-                        Quantity = item.StockQuantity,
-                        SupplyCode = item.SupplyCode,
-                        Unit = item.Unit
-                    };
-                }
+                stockInfoDetail.StockId = 0;
+                stockInfoDetail.OrderNo = takeStockOrder.OrderNo;
                 stockInfo.StockStatus = StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt();
                 _unitOfWorkManage.BeginTran();
                 _takeStockOrderDetail.AddData(takeStockOrderDetail);
+                _stockInfoDetailRepository.UpdateData(stockInfoDetail);
                 _stockInfoRepository.UpdateData(stockInfo);
                 _unitOfWorkManage.CommitTran();
                 return WebResponseContent.Instance.OK("鐩樼偣瀹屾垚锛岃鍙栬蛋璇ュ紓甯告枡绠辫繘琛屽钩璐﹀鐞嗭紒");
@@ -236,18 +218,14 @@
                 }
 
                 var task = _taskRepository.QueryFirst(x => x.PalletCode == boxNo);
-                    
-
                 if (task != null)
                 {
-                    return content.Error($"鎵樼洏{boxNo}瀛樺湪浠诲姟鍥炲簱澶辫触!");
+                    return content.Error($"鎵樼洏{boxNo}瀛樺湪浠诲姟锛屽洖搴撳け璐�!");
                 }
                 if(stock.StockStatus != StockStatusEmun.鐩樼偣鍑哄簱瀹屾垚.ObjToInt() && stock.StockStatus != StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt())
                 {
                     return content.Error("璇ユ墭鐩樼姸鎬佷笉瀵�,涓嶅厑璁哥洏鐐瑰叆搴�");
                 }
-                stock.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
-
                 var palletCodes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                 if (!string.IsNullOrEmpty(takeStockOrder.AllPalletCode))
                 {
@@ -256,19 +234,14 @@
                         .Select(p => p.Trim())
                         .ToHashSet(StringComparer.OrdinalIgnoreCase);
                 }
-                Dt_TakeStockOrderDetail isReturn = _takeStockOrderDetail.QueryFirst(x => x.TakePalletCode == boxNo && (x.TakeDetalStatus == TakeStockDetailStatusEnum.鏈繘琛屽钩璐﹀鐞�.ObjToInt() || x.TakeDetalStatus == TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊涓�.ObjToInt()));
-                if(isReturn != null)
-                {
-                    return WebResponseContent.Instance.Error("璇ユ墭鐩樿繕鏈夋潯鐮佸緟骞宠处锛岃鍏堝鐞嗗啀鍥炲簱");
-                }
-                bool hasRelatedTasks = _taskRepository.QueryData(x => palletCodes.Contains(x.PalletCode)).Any();
-                bool hasRelatedDetails = _takeStockOrderDetail.QueryData(x => palletCodes.Contains(x.TakePalletCode)).Any();
+                int overPalletCodeCount = _stockInfoRepository.QueryData(x => palletCodes.Contains(x.PalletCode) && (x.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() || x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() || x.StockStatus == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()|| x.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt())).Count();
+                bool hasRelatedTasks = palletCodes.Count == overPalletCodeCount + 1;
 
-                if (!hasRelatedTasks && !hasRelatedDetails)
+                if (hasRelatedTasks)
                 {
                     takeStockOrder.TakeStockStatus = (int)TakeStockStatusEnum.鐩樼偣瀹屾垚;
                 }
-
+                stock.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
                 // 鍒嗛厤鏂拌揣浣�
                 var newLocation = _locationInfoService.AssignLocation(stock.LocationType);
 
@@ -416,128 +389,123 @@
             }
         }
 
-        public WebResponseContent DocumentReconciliation(int orderId, int id)
+        public WebResponseContent DocumentReconciliation(string barcode)
         {
             WebResponseContent webResponseContent = new WebResponseContent();
             try
             {
-                Dt_TakeStockOrderDetail takeStockOrderDetail = _takeStockOrderDetail.QueryFirst(x => x.Id == id);
-                if(takeStockOrderDetail== null)
+                Dt_TakeStockOrderDetail takeStockOrderDetail = _takeStockOrderDetail.QueryFirst(x => x.barcode == barcode);
+                if (takeStockOrderDetail == null)
                 {
                     return WebResponseContent.Instance.Error("鏈壘鍒拌鐩樼偣宸紓鏁版嵁");
                 }
-                if(takeStockOrderDetail.Remark == "鐩樼泩")
+                //if(takeStockOrderDetail.Remark == "鐩樼泩")
+                //{
+                //    Dt_InboundOrderDetail inboundOrderDetail = _inboundOrderDetailRepository.QueryFirst(x => x.Id == orderId);
+                //    if(inboundOrderDetail == null)
+                //    {
+                //        return WebResponseContent.Instance.Error("鏈壘鍒伴�夋嫨鐨勬潅鏀跺钩璐﹀崟鎹�");
+                //    }
+                //    Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x=>x.Id == inboundOrderDetail.OrderId).Includes(x=>x.Details).First();
+                //    Dt_StockInfo  stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x=>x.PalletCode == takeStockOrderDetail.TakePalletCode && x.StockStatus == StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()).Includes(x=>x.Details).First();
+                //    if(stockInfo== null)
+                //    {
+                //        return WebResponseContent.Instance.Error($"鐩樼偣鎵樼洏{takeStockOrderDetail.TakePalletCode}鐨勫簱瀛樹俊鎭湭鎵惧埌锛屾垨鎵樼洏鐘舵�佷笉姝g‘");
+                //    }
+                //    var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x => x.MaterialCode.Contains(inboundOrderDetail.MaterielCode.Substring(0, 6))).First();
+                //    var newStockDetail = new Dt_StockInfoDetail
+                //    {
+                //        StockId = stockInfo == null ? 0 : stockInfo.Id,
+                //        Barcode = inboundOrderDetail.Barcode,
+                //        MaterielCode = inboundOrderDetail.MaterielCode,
+                //        MaterielName = inboundOrderDetail.MaterielName,
+                //        BatchNo = inboundOrderDetail.BatchNo,
+                //        Unit = inboundOrderDetail.Unit,
+                //        InboundOrderRowNo = inboundOrderDetail.lineNo,
+                //        SupplyCode = inboundOrderDetail.SupplyCode,
+                //        WarehouseCode = inboundOrderDetail.WarehouseCode,
+                //        StockQuantity = inboundOrderDetail.OrderQuantity,
+                //        BarcodeQty = inboundOrderDetail.BarcodeQty,
+                //        BarcodeUnit = inboundOrderDetail.BarcodeUnit,
+                //        FactoryArea = inboundOrder.FactoryArea,
+                //        Status = 0,
+                //        OrderNo = inboundOrder.InboundOrderNo,
+                //        BusinessType = inboundOrder.BusinessType,
+                //        ValidDate = inboundOrder.BusinessType == BusinessTypeEnum.澶栭儴浠撳簱璋冩櫤浠�.ToString() ? inboundOrderDetail.ValidDate : datevaliDate == null ? null : Convert.ToDateTime(DateTime.Now).AddDays(Convert.ToDouble(datevaliDate.ValidityDays)),
+                //    };
+                //    stockInfo.Details.Add(newStockDetail);
+
+                //    inboundOrderDetail.ReceiptQuantity = inboundOrderDetail.OrderQuantity;
+                //    inboundOrderDetail.OverInQuantity = inboundOrderDetail.OrderQuantity;
+                //    inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
+                //    int overCount = 1;
+                //    int moreOverCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
+                //    if (inboundOrder.Details.Count() == overCount + moreOverCount)
+                //    {
+                //        inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+                //    }
+                //    else
+                //    {
+                //        inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                //    }
+                //    takeStockOrderDetail.DifferenceQty -= inboundOrderDetail.OrderQuantity;
+                //    if(takeStockOrderDetail.DifferenceQty > 0)
+                //    {
+                //        takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊涓�.ObjToInt();
+                //    }
+                //    else if (takeStockOrderDetail.DifferenceQty == 0)
+                //    {
+                //        takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊.ObjToInt();
+                //    }
+                //    else
+                //    {
+                //        return WebResponseContent.Instance.Error("璇ユ潅鏀跺崟鎹槑缁嗘潯鐮佹暟閲忓ぇ浜庡緟骞宠处鏁伴噺锛岃鍙﹂�夊叾浠栧崟鎹钩璐�");
+                //    }
+
+                //    _unitOfWorkManage.BeginTran();
+                //    _inboundOrderRepository.UpdateData(inboundOrder);
+                //    _inboundOrderDetailRepository.UpdateData(inboundOrderDetail);
+                //    _takeStockOrderDetail.UpdateData(takeStockOrderDetail);
+                //    BaseDal.Db.Insertable(newStockDetail).ExecuteCommand();
+                //    _unitOfWorkManage.CommitTran();
+                //    List<string> barcodes = new List<string>();
+                //    barcodes.Add(inboundOrderDetail.Barcode);
+                //    _outboundPickingService.NoStockOutBatchInOrderFeedbackToMes(inboundOrder.Id, barcodes);
+
+
+                //}
+                //else
+                //{
+                Dt_OutboundOrderDetail outboundOrderDetail = _outboundOrderDetailRepository.QueryFirst(x => x.Remark == takeStockOrderDetail.TakeStockNo && (x.OrderQuantity-x.LockQuantity-x.MoveQty)>0);
+                if (outboundOrderDetail == null)
                 {
-                    Dt_InboundOrderDetail inboundOrderDetail = _inboundOrderDetailRepository.QueryFirst(x => x.Id == orderId);
-                    if(inboundOrderDetail == null)
-                    {
-                        return WebResponseContent.Instance.Error("鏈壘鍒伴�夋嫨鐨勬潅鏀跺钩璐﹀崟鎹�");
-                    }
-                    Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x=>x.Id == inboundOrderDetail.OrderId).Includes(x=>x.Details).First();
-                    Dt_StockInfo  stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x=>x.PalletCode == takeStockOrderDetail.TakePalletCode && x.StockStatus == StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()).Includes(x=>x.Details).First();
-                    if(stockInfo== null)
-                    {
-                        return WebResponseContent.Instance.Error($"鐩樼偣鎵樼洏{takeStockOrderDetail.TakePalletCode}鐨勫簱瀛樹俊鎭湭鎵惧埌锛屾垨鎵樼洏鐘舵�佷笉姝g‘");
-                    }
-                    var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x => x.MaterialCode.Contains(inboundOrderDetail.MaterielCode.Substring(0, 6))).First();
-                    var newStockDetail = new Dt_StockInfoDetail
-                    {
-                        StockId = stockInfo == null ? 0 : stockInfo.Id,
-                        Barcode = inboundOrderDetail.Barcode,
-                        MaterielCode = inboundOrderDetail.MaterielCode,
-                        MaterielName = inboundOrderDetail.MaterielName,
-                        BatchNo = inboundOrderDetail.BatchNo,
-                        Unit = inboundOrderDetail.Unit,
-                        InboundOrderRowNo = inboundOrderDetail.lineNo,
-                        SupplyCode = inboundOrderDetail.SupplyCode,
-                        WarehouseCode = inboundOrderDetail.WarehouseCode,
-                        StockQuantity = inboundOrderDetail.OrderQuantity,
-                        BarcodeQty = inboundOrderDetail.BarcodeQty,
-                        BarcodeUnit = inboundOrderDetail.BarcodeUnit,
-                        FactoryArea = inboundOrder.FactoryArea,
-                        Status = 0,
-                        OrderNo = inboundOrder.InboundOrderNo,
-                        BusinessType = inboundOrder.BusinessType,
-                        ValidDate = inboundOrder.BusinessType == BusinessTypeEnum.澶栭儴浠撳簱璋冩櫤浠�.ToString() ? inboundOrderDetail.ValidDate : datevaliDate == null ? null : Convert.ToDateTime(DateTime.Now).AddDays(Convert.ToDouble(datevaliDate.ValidityDays)),
-                    };
-                    stockInfo.Details.Add(newStockDetail);
-
-                    inboundOrderDetail.ReceiptQuantity = inboundOrderDetail.OrderQuantity;
-                    inboundOrderDetail.OverInQuantity = inboundOrderDetail.OrderQuantity;
-                    inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
-                    int overCount = 1;
-                    int moreOverCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
-                    if (inboundOrder.Details.Count() == overCount + moreOverCount)
-                    {
-                        inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
-                    }
-                    else
-                    {
-                        inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
-                    }
-                    takeStockOrderDetail.DifferenceQty -= inboundOrderDetail.OrderQuantity;
-                    if(takeStockOrderDetail.DifferenceQty > 0)
-                    {
-                        takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊涓�.ObjToInt();
-                    }
-                    else if (takeStockOrderDetail.DifferenceQty == 0)
-                    {
-                        takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊.ObjToInt();
-                    }
-                    else
-                    {
-                        return WebResponseContent.Instance.Error("璇ユ潅鏀跺崟鎹槑缁嗘潯鐮佹暟閲忓ぇ浜庡緟骞宠处鏁伴噺锛岃鍙﹂�夊叾浠栧崟鎹钩璐�");
-                    }
-                    
-                    _unitOfWorkManage.BeginTran();
-                    _inboundOrderRepository.UpdateData(inboundOrder);
-                    _inboundOrderDetailRepository.UpdateData(inboundOrderDetail);
-                    _takeStockOrderDetail.UpdateData(takeStockOrderDetail);
-                    BaseDal.Db.Insertable(newStockDetail).ExecuteCommand();
-                    _unitOfWorkManage.CommitTran();
-                    List<string> barcodes = new List<string>();
-                    barcodes.Add(inboundOrderDetail.Barcode);
-                    _outboundPickingService.NoStockOutBatchInOrderFeedbackToMes(inboundOrder.Id, barcodes);
-
-
+                    return WebResponseContent.Instance.Error("鏈壘鍒伴�夋嫨鐨勬潅鍙戝钩璐﹀崟鎹�");
                 }
-                else
+                if(outboundOrderDetail.MaterielCode != takeStockOrderDetail.MaterielCode)
                 {
-                    Dt_OutboundOrderDetail outboundOrderDetail = _outboundOrderDetailRepository.QueryFirst(x => x.Id == orderId);
-                    if (outboundOrderDetail == null)
-                    {
-                        return WebResponseContent.Instance.Error("鏈壘鍒伴�夋嫨鐨勬潅鍙戝钩璐﹀崟鎹�");
-                    }
-                    Dt_OutboundOrder outboundOrder = _outboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outboundOrderDetail.OrderId).Includes(x => x.Details).First();
-                    Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == takeStockOrderDetail.TakePalletCode && x.StockStatus == StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
-                    if (stockInfo == null)
-                    {
-                        return WebResponseContent.Instance.Error($"鐩樼偣鎵樼洏{takeStockOrderDetail.TakePalletCode}鐨勫簱瀛樹俊鎭湭鎵惧埌锛屾垨鎵樼洏鐘舵�佷笉姝g‘");
-                    }
-                    if(outboundOrderDetail.OrderQuantity + takeStockOrderDetail.DifferenceQty > 0)
-                    {
-                        return WebResponseContent.Instance.Error("璇ユ潅鍙戝崟鎹槑缁嗗彂鏂欐暟閲忓ぇ浜庡緟骞宠处鏁伴噺锛岃鍙﹂�夊叾浠栧崟鎹钩璐�");
-                    }
-                    else if(outboundOrderDetail.OrderQuantity + takeStockOrderDetail.DifferenceQty < 0)
-                    {
-                        takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊涓�.ObjToInt();
-                    }
-                    else
-                    {
-                        takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊.ObjToInt();
-                    }
-                    OutboundCompleteRequestDTO request = new OutboundCompleteRequestDTO()
-                    {
-                        OrderNo = outboundOrder.OrderNo,
-                        PalletCode = stockInfo.PalletCode,
-                        Barcode = takeStockOrderDetail.barcode,
-                        Operator = App.User.UserName
-                    };
-                    decimal stoQty = takeStockOrderDetail.SysQty;
-                  webResponseContent = CompleteOutboundWithBarcode(request, stoQty, orderId);
-                    takeStockOrderDetail.DifferenceQty = 0;
-                    _takeStockOrderDetail.UpdateData(takeStockOrderDetail);
+                    return WebResponseContent.Instance.Error("涓庢潅鍙戝钩璐﹀崟鎹墿鏂欑紪鐮佷笉鍖归厤");
                 }
+                if (!string.IsNullOrWhiteSpace(outboundOrderDetail.BatchNo)&& outboundOrderDetail.BatchNo != takeStockOrderDetail.BatchNo)
+                {
+                    return WebResponseContent.Instance.Error("涓庢潅鍙戝钩璐﹀崟鎹墿鏂欐壒娆′笉鍖归厤");
+                }
+                if (!string.IsNullOrWhiteSpace(outboundOrderDetail.SupplyCode) && outboundOrderDetail.SupplyCode != takeStockOrderDetail.SupplyCode)
+                {
+                    return WebResponseContent.Instance.Error("涓庢潅鍙戝钩璐﹀崟鎹緵搴斿晢涓嶅尮閰�");
+                }
+                Dt_OutboundOrder outboundOrder = _outboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outboundOrderDetail.OrderId).Includes(x => x.Details).First();
+
+                takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.鏉傛敹鏉傚彂骞宠处澶勭悊.ObjToInt();
+                OutboundCompleteRequestDTO request = new OutboundCompleteRequestDTO()
+                {
+                    OrderNo = outboundOrder.OrderNo,
+                    PalletCode = takeStockOrderDetail.TakePalletCode,
+                    Barcode = takeStockOrderDetail.barcode,
+                    Operator = App.User.UserName
+                };
+                webResponseContent = CompleteOutboundWithBarcode(request,outboundOrderDetail.Id);
+                takeStockOrderDetail.DifferenceQty = 0;
+                _takeStockOrderDetail.UpdateData(takeStockOrderDetail);
                 return WebResponseContent.Instance.OK(data: webResponseContent);
             }
             catch(Exception ex)
@@ -547,7 +515,7 @@
 
             }
         }
-        public WebResponseContent CompleteOutboundWithBarcode(OutboundCompleteRequestDTO request ,decimal stoQty, int orderDetailId)
+        public WebResponseContent CompleteOutboundWithBarcode(OutboundCompleteRequestDTO request ,int orderDetailId)
         {
             WebResponseContent content = WebResponseContent.Instance;
 
@@ -572,13 +540,7 @@
                     return WebResponseContent.Instance.Error($"鏉$爜 {request.Barcode} 瀵瑰簲鐨勫簱瀛樻槑缁嗕笉瀛樺湪");
                 }
 
-                // 3. 楠岃瘉搴撳瓨鏄庣粏涓庢墭鐩樻槸鍚﹀尮閰�
-                if (stockDetail.StockId != stockInfo.Id)
-                {
-                    response.Success = false;
-                    response.Message = $"鏉$爜 {request.Barcode} 涓嶅睘浜庢墭鐩樺彿 {request.PalletCode} 鐨勫簱瀛樻槑缁�";
-                    return WebResponseContent.Instance.Error($"鏉$爜 {request.Barcode} 涓嶅睘浜庢墭鐩樺彿 {request.PalletCode} 鐨勫簱瀛樻槑缁�");
-                }
+
 
                 // 4. 鏌ユ壘鍑哄簱鍗曚俊鎭�
                 Dt_OutboundOrder outboundOrder = _outboundOrderRepository.QueryFirst(o => o.OrderNo == request.OrderNo);
@@ -595,11 +557,11 @@
                     return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟鏄庣粏");
                 }
                 // 瀹為檯鍑哄簱閲�
-                decimal actualOutboundQuantity = outboundOrderDetail.OrderQuantity;
+                decimal actualOutboundQuantity = outboundOrderDetail.OrderQuantity-outboundOrderDetail.LockQuantity-outboundOrderDetail.MoveQty;
 
 
                 // 8. 鍒ゆ柇鏄惁闇�瑕佹媶鍖咃紙褰撳嚭搴撴暟閲忓皬浜庡簱瀛樻暟閲忔椂闇�瑕佹媶鍖咃級
-                bool isUnpacked = outboundOrderDetail.OrderQuantity < stockDetail.StockQuantity;
+                bool isUnpacked = actualOutboundQuantity < stockDetail.StockQuantity;
                 List<MaterialCodeReturnDTO> returnDTOs = new List<MaterialCodeReturnDTO>();
                 string newBarcode = string.Empty;
                 // 9. 寮�鍚簨鍔�
@@ -744,10 +706,10 @@
                     if (!string.IsNullOrEmpty(newBarcode))
                     {
                         // 鐗╂枡鏂版潯鐮佸洖浼�
-                        _feedbackMesService.BarcodeFeedback(newBarcode);
+                        //_feedbackMesService.BarcodeFeedback(newBarcode);
                     }
 
-                    _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+                    //_feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
 
                 }
                 catch (Exception ex)
@@ -767,6 +729,10 @@
             return content;
         }
 
+        public WebResponseContent StockTakeGroupPallet(string barcode, string boxNo)
+        {
+            throw new NotImplementedException();
+        }
     }
     
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index 6adef6d..99bb3e2 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -108,139 +108,120 @@
         public WebResponseContent ProcessPickingOutbound(PickingOutboundRequestDTO request)
         {
             WebResponseContent content = WebResponseContent.Instance;
-
             PickingOutboundResponseDTO response = new PickingOutboundResponseDTO();
+            decimal totalNeedAllocate = 0; // 鎬婚渶姹傚垎閰嶉噺
+            decimal totalActualAllocate = 0; // 瀹為檯鎬诲垎閰嶉噺
+
             try
             {
                 _unitOfWorkManage.BeginTran();
                 // 1. 璁$畻鍑哄簱鏁伴噺閫昏緫
                 OutboundCalculationDTO calculationResult = CalcOutboundQuantity(request);
-
                 if (!calculationResult.CanOutbound)
                 {
                     content = WebResponseContent.Instance.Error("鏃犳硶澶勭悊鎷h揣鍑哄簱锛�" + calculationResult.ErrorMessage);
                     _unitOfWorkManage.RollbackTran();
                     return content;
                 }
+                // 璁板綍鎬婚渶姹傛暟閲�
+                totalNeedAllocate = calculationResult.MaterielCalculations.Sum(x => x.UnallocatedQuantity);
 
-                // 2. 璋冪敤鍑哄簱澶勭悊閫昏緫锛岄攣瀹氬簱瀛橈紝鐢熸垚鍑哄簱璁板綍绛�
+                // 2. 澶勭悊鐗╂枡鍒嗛厤
                 List<PickedStockDetailDTO> pickedDetails = new List<PickedStockDetailDTO>();
-
-                // 鑾峰彇鍑哄簱鍗曚俊鎭�
                 Dt_OutboundOrder outboundOrder = calculationResult.OutboundOrder;
-
-                // 鍑哄簱璇︽儏娣诲姞鎴栦慨鏀归泦鍚�
                 List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
-
-                List<Dt_OutboundOrderDetail> outboundOrderDetails = new();
-
+                List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
                 List<Dt_Task> tasks = new List<Dt_Task>();
+
                 foreach (var materielCalc in calculationResult.MaterielCalculations)
                 {
-                    (List<PickedStockDetailDTO> PickedDetails, List<Dt_Task> Tasks, List<Dt_OutStockLockInfo> OutStockLockInfo) materielPickedDetails = ProcessMaterielTaskGeneration(outboundOrder, materielCalc, request, calculationResult.FactoryArea);
+                    var materielPickedDetails = ProcessMaterielTaskGeneration(outboundOrder, materielCalc, request, calculationResult.FactoryArea);
+                    // 璁$畻褰撳墠鐗╂枡瀹為檯鍒嗛厤閲�
+                    decimal actualAllocatedQuantity = materielPickedDetails.PickedDetails.Sum(x => x.OutboundQuantity);
+                    actualAllocatedQuantity = Math.Min(actualAllocatedQuantity, materielCalc.UnallocatedQuantity);
+                    totalActualAllocate += actualAllocatedQuantity; // 绱姞鑷虫�诲疄闄呭垎閰嶉噺
+                    materielCalc.UnallocatedQuantity = materielCalc.UnallocatedQuantity - actualAllocatedQuantity;
 
+                    // 澶勭悊鍑哄簱閿佸畾璁板綍
                     foreach (var item in materielPickedDetails.OutStockLockInfo)
                     {
-                        Dt_OutStockLockInfo? outStockLockInfo = materielCalc.OutStockLockInfos.FirstOrDefault(x => x.Id == item.Id && x.Id > 0);
-                        if (outStockLockInfo != null)
+                        Dt_OutStockLockInfo? existLockInfo = materielCalc.OutStockLockInfos.FirstOrDefault(x => x.Id == item.Id && x.Id > 0);
+                        if (existLockInfo != null)
                         {
-                            outStockLockInfo = item;
+                            existLockInfo = item;
                             Dt_Task? task = tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
-                            if (task != null)
-                            {
-                                outStockLockInfo.TaskNum = task.TaskNum;
-                            }
+                            if (task != null) existLockInfo.TaskNum = task.TaskNum;
                         }
                         else
                         {
                             Dt_Task? task = tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
-                            if (task != null)
-                            {
-                                item.TaskNum = task.TaskNum;
-                            }
+                            if (task != null) item.TaskNum = task.TaskNum;
                             materielCalc.OutStockLockInfos.Add(item);
                         }
                         outStockLockInfos.Add(item);
                     }
+
+                    // 澶勭悊浠诲姟
                     foreach (var item in materielPickedDetails.Tasks)
                     {
-                        Dt_Task? task = tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
-                        if (task == null)
-                        {
+                        if (tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode) == null)
                             tasks.Add(item);
-                        }
                     }
 
+                    // 姹囨�诲垎鎷f槑缁�
                     pickedDetails.AddRange(materielPickedDetails.PickedDetails);
 
-                    decimal allallocatedQuantity = Math.Min(materielCalc.UnallocatedQuantity, materielPickedDetails.PickedDetails.Sum(x => x.OutboundQuantity));
-                    materielCalc.UnallocatedQuantity = allallocatedQuantity;
-                    // 鏇存柊鍑哄簱鍗曟槑缁嗭紙澧炲姞閿佸畾鏁伴噺锛屼笉澧炲姞宸插嚭鏁伴噺锛�
+                    // 鎸夊疄闄呭垎閰嶉噺鏇存柊鍗曟嵁閿佸畾鏁伴噺
+                    decimal remainingToLock = actualAllocatedQuantity;
                     foreach (var detail in materielCalc.Details)
                     {
-                        if (allallocatedQuantity <= 0) break;
-
-                        decimal lockQuantity = (detail.OrderQuantity - detail.OverOutQuantity);
-                        if (lockQuantity < materielCalc.UnallocatedQuantity)
-                        {
-                            detail.LockQuantity += lockQuantity; // 澧炲姞閿佸畾鏁伴噺 涓嶆洿鏂� OverOutQuantity 鍜� OrderDetailStatus锛屽洜涓鸿繕娌℃湁瀹為檯鍑哄簱
-                            outboundOrderDetails.Add(detail);
-                            materielCalc.UnallocatedQuantity -= lockQuantity;
-                        }
-                        else
-                        {
-                            detail.LockQuantity += materielCalc.UnallocatedQuantity;
-                            outboundOrderDetails.Add(detail);
-                            break;
-                        }
+                        if (remainingToLock <= 0) break;
+                        decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
+                        if (maxLockableQty <= 0) continue;
+                        decimal currentLockQty = Math.Min(remainingToLock, maxLockableQty);
+                        detail.LockQuantity += currentLockQty;
+                        outboundOrderDetails.Add(detail);
+                        remainingToLock -= currentLockQty;
                     }
                 }
 
-                // 3. 鏇存柊鍑哄簱鍗曠姸鎬佷负鍑哄簱涓紙琛ㄧず宸叉湁浠诲姟鍒嗛厤锛�
+                // 3. 鎵归噺鏇存柊鐘舵�侊紙鍘熸湁閫昏緫涓嶅彉锛�
                 UpdateOutboundOrderStatus(request.OrderNo, (int)OutOrderStatusEnum.鍑哄簱涓�);
-
-                // 4. 鏇存柊鍑哄簱鍗曟槑缁嗛攣瀹氭暟閲�
                 _detailRepository.UpdateData(outboundOrderDetails);
-
-                // 5. 鏇存柊搴撳瓨鐘舵��
-                UpdateStockStatus(pickedDetails.Select(x => x.PalletCode).ToList(), StockStatusEmun.鍑哄簱閿佸畾.ObjToInt());
-
-                // 6. 鏇存柊璐т綅鐘舵��
-                UpdateLocationStatus(pickedDetails.Select(x => x.LocationCode).ToList(), LocationStatusEnum.Lock.ObjToInt());
-
-                // 7. 鏇存柊搴撳瓨璇︽儏
+                if (pickedDetails.Any())
+                {
+                    UpdateStockStatus(pickedDetails.Select(x => x.PalletCode).ToList(), StockStatusEmun.鍑哄簱閿佸畾.ObjToInt());
+                    UpdateLocationStatus(pickedDetails.Select(x => x.LocationCode).ToList(), LocationStatusEnum.Lock.ObjToInt());
+                }
                 UpdateOutStockLockInfo(outStockLockInfos);
-
-                // 8. 娣诲姞浠诲姟鏁版嵁
-                _taskRepository.AddData(tasks);
+                if (tasks.Any()) _taskRepository.AddData(tasks);
 
                 _unitOfWorkManage.CommitTran();
 
+                // 4. 鏋勯�犲搷搴旓細鍖哄垎銆屽叏閮ㄥ垎閰嶃�嶅拰銆岄儴鍒嗗垎閰嶃��
+                string responseMsg = totalActualAllocate == totalNeedAllocate
+                    ? "鍒嗘嫞浠诲姟鍒嗛厤鎴愬姛"
+                    : $"鍒嗘嫞浠诲姟鍒嗛厤瀹屾垚锛堝疄闄呭垎閰峽totalActualAllocate}锛岄渶姹倇totalNeedAllocate}锛屽簱瀛樹笉瓒抽儴鍒嗘湭鍒嗛厤锛�";
                 response.Success = true;
-                response.Message = "鍒嗘嫞浠诲姟鍒嗛厤鎴愬姛";
-                response.Tasks = tasks; // 杩斿洖绗竴涓换鍔″彿
-                response.PickedDetails = pickedDetails; // 杩斿洖绗竴涓垎鎷f槑缁�
-                content = WebResponseContent.Instance.OK("鍒嗘嫞浠诲姟鍒嗛厤鎴愬姛", response);
-                return content;
+                response.Message = responseMsg;
+                response.Tasks = tasks;
+                response.PickedDetails = pickedDetails;
+                content = WebResponseContent.Instance.OK(responseMsg, response);
             }
             catch (Exception ex)
             {
                 _unitOfWorkManage.RollbackTran();
-
                 content = WebResponseContent.Instance.Error("澶勭悊鎷h揣鍑哄簱澶辫触锛�" + ex.Message);
             }
             return content;
         }
 
         /// <summary>
-        /// 璁$畻鍑哄簱鏁伴噺閫昏緫
+        /// 璁$畻鍑哄簱鏁伴噺閫昏緫锛堝師鏈夐�昏緫涓嶅彉锛�
         /// </summary>
-        /// <param name="request"></param>
-        /// <returns></returns>
         public OutboundCalculationDTO CalcOutboundQuantity(PickingOutboundRequestDTO request)
         {
-            OutboundCalculationDTO result = new();
-
+            OutboundCalculationDTO result = new OutboundCalculationDTO();
             try
             {
                 Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == request.OrderNo);
@@ -253,23 +234,14 @@
 
                 result.FactoryArea = outboundOrder.FactoryArea;
                 List<Dt_OutboundOrderDetail> selectedDetails = new List<Dt_OutboundOrderDetail>();
-
                 if (request.DetailIds == null || !request.DetailIds.Any())
                 {
                     selectedDetails = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id);
                 }
                 else
                 {
-                    // 鑾峰彇閫夋嫨鐨勫嚭搴撴槑缁�
                     selectedDetails = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && request.DetailIds.Contains(x.Id));
                 }
-
-
-                //if (outboundOrder.IsBatch == 1 && request.DetailIds.Count == 1)
-                //{
-                //    selectedDetails = _detailRepository.QueryData(x => x.OrderId == selectedDetails.First().OrderId && x.WarehouseCode == selectedDetails.First().WarehouseCode && x.MaterielCode == selectedDetails.First().MaterielCode && x.BatchNo == selectedDetails.First().BatchNo && x.SupplyCode == selectedDetails.First().SupplyCode);
-                //}
-
 
                 if (!selectedDetails.Any())
                 {
@@ -280,23 +252,21 @@
                 if (selectedDetails.Any(x => x.LockQuantity > x.OrderQuantity - x.MoveQty || x.OverOutQuantity > x.OrderQuantity - x.MoveQty))
                 {
                     List<int> selectDetailIds = selectedDetails.Where(x => x.LockQuantity > x.OrderQuantity - x.MoveQty || x.OverOutQuantity > x.OrderQuantity - x.MoveQty).Select(x => x.Id).ToList();
-
                     result.CanOutbound = false;
                     result.ErrorMessage = $"鍑哄簱鏄庣粏淇℃伅{string.Join(",", selectDetailIds)}宸插垎閰嶅畬鎴�";
                     return result;
                 }
+
                 outboundOrder.Details = selectedDetails;
                 result.OutboundOrder = outboundOrder;
                 result.SelectedDetails = selectedDetails;
 
                 if (outboundOrder.IsBatch == 0 || request.DetailIds.Count != 1)
                 {
-                    // 澶氭槑缁嗗嚭搴擄細鎸夌墿鏂欏垎缁勫鐞�
                     result.MaterielCalculations = CalcMaterielOutboundQuantities(outboundOrder, selectedDetails.ToList());
                 }
                 else
                 {
-                    // 鍗曟槑缁嗗嚭搴擄細楠岃瘉杈撳叆鐨勫嚭搴撴暟閲�
                     if (!request.OutboundQuantity.HasValue || request.OutboundQuantity.Value <= 0)
                     {
                         result.CanOutbound = false;
@@ -308,10 +278,8 @@
                     decimal orderQuantity = selectedDetails.Sum(x => x.OrderQuantity);
                     decimal moveQuantity = selectedDetails.Sum(x => x.MoveQty);
                     decimal overQuantity = selectedDetails.Sum(x => x.OverOutQuantity);
-
                     Dt_OutboundOrderDetail? singleDetail = selectedDetails.First();
 
-                    //鍒ゆ柇鍙嚭搴撴暟閲�
                     if (orderQuantity - lockQuantity - moveQuantity < request.OutboundQuantity.Value || orderQuantity - overQuantity - moveQuantity < request.OutboundQuantity.Value)
                     {
                         result.CanOutbound = false;
@@ -325,10 +293,7 @@
                     {
                         inputQuantity -= (item.OrderQuantity - item.MoveQty - item.LockQuantity);
                         outboundOrderDetails.Add(item);
-                        if (inputQuantity <= 0)
-                        {
-                            break;
-                        }
+                        if (inputQuantity <= 0) break;
                     }
 
                     result.MaterielCalculations = new List<MaterielOutboundCalculationDTO>()
@@ -348,31 +313,24 @@
                             Details = outboundOrderDetails
                         }
                     };
-
                     outboundOrder.Details = outboundOrderDetails;
                 }
-
                 result.CanOutbound = true;
-                return result;
             }
             catch (Exception ex)
             {
                 result.CanOutbound = false;
                 result.ErrorMessage = ex.Message;
-                return result;
             }
-
+            return result;
         }
 
         /// <summary>
-        /// 澶氬嚭搴撳崟鏄庣粏鏃讹紝鎸夌墿鏂欏垎缁勮绠楀嚭搴撴暟閲�
+        /// 鎸夌墿鏂欏垎缁勮绠楀嚭搴撴暟閲忥紙鍘熸湁閫昏緫涓嶅彉锛�
         /// </summary>
-        /// <param name="selectedDetails"></param>
-        /// <returns></returns>
         private List<MaterielOutboundCalculationDTO> CalcMaterielOutboundQuantities(Dt_OutboundOrder outboundOrder, List<Dt_OutboundOrderDetail> selectedDetails)
         {
-            // 鎸夌墿鏂欏垎缁勶細鐗╂枡缂栧彿銆佹壒娆″彿銆佷緵搴斿晢缂栧彿銆佷粨搴撶紪鍙�
-            List<MaterielOutboundCalculationDTO> materielGroups = selectedDetails
+            return selectedDetails
                 .GroupBy(x => new
                 {
                     x.MaterielCode,
@@ -392,138 +350,397 @@
                     UnallocatedQuantity = g.Sum(x => x.OrderQuantity - x.LockQuantity - x.MoveQty),
                     MovedQuantity = g.Sum(x => x.MoveQty),
                     Details = g.ToList(),
-                    OutStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.MaterielCode == g.Key.MaterielCode && x.BatchNo == g.Key.BatchNo && x.OrderType == (int)outboundOrder.OrderType && x.OrderNo == outboundOrder.OrderNo)
+                    OutStockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+                        x.MaterielCode == g.Key.MaterielCode &&
+                        x.BatchNo == g.Key.BatchNo &&
+                        x.OrderType == (int)outboundOrder.OrderType &&
+                        x.OrderNo == outboundOrder.OrderNo)
                 })
                 .ToList();
-
-            return materielGroups;
         }
 
         /// <summary>
-        /// 澶勭悊鐗╂枡鐨勪换鍔$敓鎴�
+        /// 澶勭悊鐗╂枡浠诲姟鐢熸垚锛堟牳蹇冿細鏈夊灏戝垎澶氬皯+绉婚櫎搴撳瓨涓嶈冻寮傚父锛�
         /// </summary>
-        /// <param name="outboundOrder">鍑哄簱璁㈠崟</param>
-        /// <param name="materielCalc">鎸夌墿鏂欑殑鍑哄簱璁$畻缁撴灉</param>
-        /// <param name="request">鍒嗘嫞鍑哄簱璇锋眰</param>
-        /// <param name="factoryArea"></param>
-        /// <returns></returns>
-        /// <exception cref="Exception"></exception>
-        private (List<PickedStockDetailDTO> PickedDetails, List<Dt_Task> Tasks, List<Dt_OutStockLockInfo> OutStockLockInfo) ProcessMaterielTaskGeneration(Dt_OutboundOrder outboundOrder, MaterielOutboundCalculationDTO materielCalc, PickingOutboundRequestDTO request, string factoryArea)
+        private (List<PickedStockDetailDTO> PickedDetails, List<Dt_Task> Tasks, List<Dt_OutStockLockInfo> OutStockLockInfo) ProcessMaterielTaskGeneration(
+    Dt_OutboundOrder outboundOrder,
+    MaterielOutboundCalculationDTO materielCalc,
+    PickingOutboundRequestDTO request,
+    string factoryArea)
         {
             List<PickedStockDetailDTO> pickedDetails = new List<PickedStockDetailDTO>();
-            List<Dt_Task> generatedTasks = new List<Dt_Task>();
-
-            // 鏋勫缓搴撳瓨鏌ヨ鏉′欢锛堝寘鍚簱瀛樿〃銆佸簱瀛樻槑缁嗭級
-            List<Dt_StockInfo> stockQuery = BuildStockQueryWithInfo(materielCalc, factoryArea);
-
-            if (!stockQuery.Any())
-            {
-                throw new Exception($"鐗╂枡 {materielCalc.MaterielCode} 瀵瑰簲鐨勫簱瀛樹笉瀛樺湪");
-            }
-
-            // 鎵归噺璁$畻鎬诲彲鐢ㄥ簱瀛樻暟閲�
-            (Dictionary<int, decimal> AvailableStockMap, Dictionary<int, List<Dt_OutStockLockInfo>> LockStockMap) data = GetBatchAvailableStockQuantities(materielCalc, stockQuery);
-
-            // 鍙敤搴撳瓨鏁伴噺鏄犲皠
-            Dictionary<int, decimal> availableStockMap = data.AvailableStockMap;
-
-            // 鐗╂枡鎬诲彲鐢ㄥ簱瀛樻暟閲�
-            decimal totalAvailableStock = availableStockMap.Values.Sum();
-
-            // 宸查攣瀹氬簱瀛樻暟閲忔槧灏�
-            Dictionary<int, List<Dt_OutStockLockInfo>> lockStockMap = data.LockStockMap;
-
-            // 楠岃瘉鎬诲彲鐢ㄥ簱瀛樻槸鍚︽弧瓒冲嚭搴撻渶姹�
-            //if (totalAvailableStock < materielCalc.UnallocatedQuantity)
-            //{
-            //    throw new Exception($"鐗╂枡 {materielCalc.MaterielCode} 鍙敤搴撳瓨 {totalAvailableStock} 涓嶈冻鍑哄簱鏁伴噺 {materielCalc.UnallocatedQuantity}");
-            //}
-            // 闇�鍒嗛厤鏁伴噺
-            decimal remainingQuantity = Math.Min(totalAvailableStock, materielCalc.UnallocatedQuantity);
-
-            // 闇�鍒嗛厤鏁伴噺
-            //decimal remainingQuantity = materielCalc.UnallocatedQuantity;
-
-            // 宸插垎閰嶇殑鎵樼洏鍒楄〃
-            List<string> allocatedPallets = new List<string>();
-
-            // 鑾峰彇绗竴涓嚭搴撴槑缁�
-            Dt_OutboundOrderDetail firstDetail = materielCalc.Details.First();
-
-            // 棰勫姞杞藉簱瀛樻槑缁嗗拰閿佸畾璁板綍
-            List<int> stockIds = stockQuery.Select(x => x.Id).ToList();
-            Dictionary<int, List<Dt_StockInfoDetail>> stockDetailMap = stockQuery.ToDictionary(x => x.Id, x => x.Details);
-
-            // 璁板綍姣忎釜鎵樼洏鐨勫疄闄呭垎閰嶉噺
-            Dictionary<string, decimal> palletAllocations = new Dictionary<string, decimal>();
-
+            List<Dt_Task> generatedTasks = new List<Dt_Task>(); // 鍒濆绌轰换鍔″垪琛�
             List<Dt_OutStockLockInfo> lockInfoList = new List<Dt_OutStockLockInfo>();
-            foreach (var stock in stockQuery)
+            decimal remainingQuantity = materielCalc.UnallocatedQuantity;
+
+            // 1. 浼樺厛澶勭悊鎸囧畾搴撳瓨鏄庣粏
+            if (request.StockDetailIds?.Any() == true)
             {
-                if (remainingQuantity <= 0) break;
+                var specifiedResult = AllocateSpecifiedStockDetails(outboundOrder, materielCalc, request, factoryArea, remainingQuantity);
+                pickedDetails.AddRange(specifiedResult.PickedDetails);
+                lockInfoList.AddRange(specifiedResult.LockInfoList);
+                remainingQuantity -= specifiedResult.ActualAllocatedQuantity;
 
-                // 褰撳墠搴撳瓨鍙敤鏁伴噺
-                decimal availableQuantity = availableStockMap.GetValueOrDefault(stock.Id, 0);
-                if (availableQuantity <= 0) continue;
-
-                // 璁$畻璇ユ墭鐩樺彲鍒嗛厤鏁伴噺
-                decimal allocateQuantity = Math.Min(remainingQuantity, availableQuantity);
-                (decimal ActualAllocatedQuantity, List<Dt_OutStockLockInfo> LockInfoList) actualAllocated = AllocateStockQuantity(stock, allocateQuantity, availableQuantity, outboundOrder, firstDetail, request, lockStockMap.GetValueOrDefault(stock.Id, new List<Dt_OutStockLockInfo>()), stockDetailMap);
-
-                // 鏈鍒嗛厤鐨勬暟閲�
-                decimal actualAllocatedQuantity = actualAllocated.ActualAllocatedQuantity;
-
-                if (actualAllocatedQuantity > 0)
+                // ===== 鏍稿績淇锛氭寚瀹氬簱瀛樺垎閰嶅悗锛岀珛鍗崇敓鎴愪换鍔★紙鏃犺鍓╀綑閲忓灏戯級=====
+                if (specifiedResult.PickedDetails.Any()) // 鏈夋寚瀹氬簱瀛樺垎閰嶇粨鏋滃氨鐢熸垚浠诲姟
                 {
-                    allocatedPallets.Add(stock.PalletCode);
-                    palletAllocations[stock.PalletCode] = actualAllocatedQuantity; // 璁板綍瀹為檯鍒嗛厤閲�
-                    remainingQuantity -= actualAllocatedQuantity;
-                    lockInfoList.AddRange(actualAllocated.LockInfoList);
+                    var specifiedTasks = GenerateTasksForSpecifiedStock(specifiedResult.PickedDetails, request.OutboundTargetLocation);
+                    generatedTasks.AddRange(specifiedTasks); // 娣诲姞鎸囧畾搴撳瓨浠诲姟鍒版�讳换鍔″垪琛�
+                }
+
+                // 鍓╀綑閲�<=0鏃讹紝鐩存帴杩斿洖锛堝凡鐢熸垚鎸囧畾搴撳瓨浠诲姟锛�
+                if (remainingQuantity <= 0)
+                {
+                    return (pickedDetails, generatedTasks, lockInfoList);
                 }
             }
 
-            foreach (var palletCode in allocatedPallets)
+            // 2. 澶勭悊鍓╀綑鏁伴噺鐨勮嚜鍔ㄥ垎閰嶏紙鍘熸湁閫昏緫涓嶅彉锛岃嚜鍔ㄥ垎閰嶇殑浠诲姟浼氳拷鍔犲埌generatedTasks锛�
+            List<Dt_StockInfo> stockQuery = BuildStockQueryWithInfo(materielCalc, factoryArea);
+            var allocatedPalletCodes = pickedDetails.Select(x => x.PalletCode).Distinct().ToList();
+            stockQuery = stockQuery.Where(x => !allocatedPalletCodes.Contains(x.PalletCode)).ToList();
+
+            var stockData = GetBatchAvailableStockQuantities(materielCalc, stockQuery);
+            decimal totalAutoAvailable = stockData.AvailableStockMap.Values.Sum();
+            decimal autoAllocateQuantity = Math.Min(remainingQuantity, totalAutoAvailable);
+            remainingQuantity -= autoAllocateQuantity;
+
+            if (autoAllocateQuantity > 0 && stockQuery.Any())
             {
-                Dt_StockInfo stock = stockQuery.First(x => x.PalletCode == palletCode);
+                Dt_OutboundOrderDetail firstDetail = materielCalc.Details.First();
+                Dictionary<int, List<Dt_StockInfoDetail>> stockDetailMap = stockQuery.ToDictionary(x => x.Id, x => x.Details);
+                Dictionary<string, decimal> palletAllocations = new Dictionary<string, decimal>();
 
-                // 鑾峰彇瀹為檯鍒嗛厤鐨勬暟閲�
-                decimal actualAllocatedQuantity = palletAllocations.GetValueOrDefault(palletCode, 0);
-
-                // 璁$畻鍒嗛厤鍚庡墿浣欑殑搴撳瓨鏁伴噺
-                decimal originalAvailableQuantity = availableStockMap.GetValueOrDefault(stock.Id, 0);
-                decimal remainingStockQuantity = Math.Max(0, originalAvailableQuantity - actualAllocatedQuantity);
-
-                pickedDetails.Add(new PickedStockDetailDTO
+                foreach (var stock in stockQuery)
                 {
-                    PalletCode = palletCode,
-                    MaterielCode = materielCalc.MaterielCode,
-                    OutboundQuantity = actualAllocatedQuantity, // 鏈瀹為檯鍒嗛厤鐨勫嚭搴撻噺
-                    RemainingQuantity = remainingStockQuantity, // 鍒嗛厤鍚庡墿浣欑殑鍙敤搴撳瓨
-                    LocationCode = stock.LocationCode,
-                    OutStockLockInfos = lockInfoList
-                });
+                    if (autoAllocateQuantity <= 0) break;
+                    decimal availableQuantity = stockData.AvailableStockMap.GetValueOrDefault(stock.Id, 0);
+                    if (availableQuantity <= 0) continue;
 
-                Dt_OutStockLockInfo? outStockLockInfo = lockInfoList.FirstOrDefault(x => x.PalletCode == palletCode);
-                int taskNum = outStockLockInfo?.TaskNum ?? Db.Ado.GetScalar($"SELECT NEXT VALUE FOR SeqTaskNum").ObjToInt();
+                    // 鑷姩鍒嗛厤鏃舵煡璇㈡墭鐩樻�诲簱瀛橈紙鍘熸湁浼樺寲閫昏緫涓嶅彉锛�
+                    decimal palletMaterielTotalStock = _stockDetailRepository.QueryData(
+                        x => x.StockId == stock.Id && x.MaterielCode == materielCalc.MaterielCode
+                    ).Sum(x => x.StockQuantity);
 
-                Dt_Task task = GenerationOutTask(stock, TaskTypeEnum.Outbound, taskNum, request.OutboundTargetLocation);
-                if (generatedTasks.FirstOrDefault(x => x.PalletCode == stock.PalletCode) == null) generatedTasks.Add(task);
+                    decimal allocateQuantity = Math.Min(autoAllocateQuantity, availableQuantity);
+                    var actualAllocated = AllocateStockQuantity(
+                        stock, allocateQuantity, availableQuantity, outboundOrder, firstDetail,
+                        request, stockData.LockStockMap.GetValueOrDefault(stock.Id, new List<Dt_OutStockLockInfo>()),
+                        stockDetailMap, palletMaterielTotalStock);
+
+                    if (actualAllocated.ActualAllocatedQuantity > 0)
+                    {
+                        palletAllocations[stock.PalletCode] = actualAllocated.ActualAllocatedQuantity;
+                        autoAllocateQuantity -= actualAllocated.ActualAllocatedQuantity;
+                        lockInfoList.AddRange(actualAllocated.LockInfoList);
+                    }
+                }
+
+                // 鐢熸垚鑷姩鍒嗛厤鐨勪换鍔★紙杩藉姞鍒癵eneratedTasks锛屼笉浼氶噸澶嶏級
+                foreach (var palletCode in palletAllocations.Keys)
+                {
+                    Dt_StockInfo stock = stockQuery.First(x => x.PalletCode == palletCode);
+                    decimal actualQty = palletAllocations[palletCode];
+                    decimal originalAvailable = stockData.AvailableStockMap.GetValueOrDefault(stock.Id, 0);
+
+                    pickedDetails.Add(new PickedStockDetailDTO
+                    {
+                        PalletCode = palletCode,
+                        MaterielCode = materielCalc.MaterielCode,
+                        OutboundQuantity = actualQty,
+                        RemainingQuantity = Math.Max(0, originalAvailable - actualQty),
+                        LocationCode = stock.LocationCode,
+                        OutStockLockInfos = lockInfoList.Where(x => x.PalletCode == palletCode).ToList()
+                    });
+
+                    int taskNum = lockInfoList.FirstOrDefault(x => x.PalletCode == palletCode)?.TaskNum ??
+                                  Db.Ado.GetScalar($"SELECT NEXT VALUE FOR SeqTaskNum").ObjToInt();
+                    Dt_Task task = GenerationOutTask(stock, TaskTypeEnum.Outbound, taskNum, request.OutboundTargetLocation);
+                    // 杩囨护閲嶅浠诲姟锛堟寚瀹氬簱瀛樼殑鎵樼洏宸茬敓鎴愶紝涓嶄細閲嶅娣诲姞锛�
+                    if (generatedTasks.FirstOrDefault(x => x.PalletCode == palletCode) == null)
+                        generatedTasks.Add(task);
+                }
             }
 
+            // 杩斿洖銆屾寚瀹氬簱瀛樹换鍔�+鑷姩鍒嗛厤浠诲姟銆嶇殑鍚堝苟鍒楄〃
             return (pickedDetails, generatedTasks, lockInfoList);
         }
 
         /// <summary>
-        /// 鐢熸垚鍑哄簱浠诲姟
+        /// 鍒嗛厤鎸囧畾搴撳瓨鏄庣粏锛堟牳蹇冧紭鍖栵細鏌ヨ鎵樼洏鐗╂枡鎬诲簱瀛樺苟浼犻�掞級
         /// </summary>
-        /// <param name="stockInfo"></param>
-        /// <param name="taskType"></param>
-        /// <param name="outStation"></param>
-        /// <returns></returns>
+        private (decimal ActualAllocatedQuantity, List<PickedStockDetailDTO> PickedDetails, List<Dt_OutStockLockInfo> LockInfoList) AllocateSpecifiedStockDetails(
+            Dt_OutboundOrder outboundOrder,
+            MaterielOutboundCalculationDTO materielCalc,
+            PickingOutboundRequestDTO request,
+            string factoryArea,
+            decimal needAllocateQuantity)
+        {
+            List<PickedStockDetailDTO> pickedDetails = new List<PickedStockDetailDTO>();
+            List<Dt_OutStockLockInfo> lockInfoList = new List<Dt_OutStockLockInfo>();
+            decimal actualAllocated = 0;
+
+            List<Dt_StockInfoDetail> specifiedStockDetails = _stockDetailRepository.QueryData(
+                x => request.StockDetailIds.Contains(x.Id)
+                && x.MaterielCode == materielCalc.MaterielCode
+                && x.StockQuantity > 0
+                && (x.Status == (int)StockStatusEmun.鍏ュ簱瀹屾垚 || x.Status == (int)StockStatusEmun.鎵嬪姩瑙i攣));
+
+            if (!specifiedStockDetails.Any())
+            {
+                throw new Exception($"鎸囧畾搴撳瓨鏄庣粏ID [{string.Join(",", request.StockDetailIds)}] 涓嶅瓨鍦ㄦ垨涓嶅彲鐢�");
+            }
+
+            List<int> stockIds = specifiedStockDetails.Select(x => x.StockId).Distinct().ToList();
+            List<Dt_StockInfo> specifiedStocks = _stockInfoRepository.QueryData(x => stockIds.Contains(x.Id));
+            Dictionary<int, Dt_StockInfo> stockMap = specifiedStocks.ToDictionary(x => x.Id);
+
+            foreach (var stockDetail in specifiedStockDetails)
+            {
+                if (needAllocateQuantity <= 0) break;
+                if (!stockMap.ContainsKey(stockDetail.StockId)) continue;
+
+                Dt_StockInfo stock = stockMap[stockDetail.StockId];
+                decimal availableQty = stockDetail.StockQuantity;
+                decimal allocateQty = Math.Min(needAllocateQuantity, availableQty);
+                if (allocateQty <= 0) continue;
+
+                // ===== 鏍稿績浼樺寲1锛氭煡璇㈣鎵樼洏涓嬪綋鍓嶇墿鏂欑殑鎬诲簱瀛� =====
+                decimal palletMaterielTotalStock = _stockDetailRepository.QueryData(
+                    x => x.StockId == stock.Id && x.MaterielCode == materielCalc.MaterielCode
+                ).Sum(x => x.StockQuantity); // 璇ユ墭鐩樿鐗╂枡鐨勬�诲簱瀛橈紙鑰岄潪鏈鍒嗛厤閲忥級
+
+                var lockInfos = materielCalc.OutStockLockInfos
+                    .Where(x => x.StockId == stock.Id && x.MaterielCode == materielCalc.MaterielCode)
+                    .ToList();
+
+                // ===== 浼犻�掓�诲簱瀛樺埌AllocateStockQuantity =====
+                var allocateResult = AllocateStockQuantity(
+                    stock, allocateQty, availableQty, outboundOrder, materielCalc.Details.First(),
+                    request, lockInfos,
+                    new Dictionary<int, List<Dt_StockInfoDetail>> { { stock.Id, new List<Dt_StockInfoDetail> { stockDetail } } },
+                    palletMaterielTotalStock // 鏂板锛氫紶鍏ユ墭鐩樼墿鏂欐�诲簱瀛�
+                );
+
+                if (allocateResult.ActualAllocatedQuantity > 0)
+                {
+                    pickedDetails.Add(new PickedStockDetailDTO
+                    {
+                        PalletCode = stock.PalletCode,
+                        MaterielCode = materielCalc.MaterielCode,
+                        OutboundQuantity = allocateResult.ActualAllocatedQuantity,
+                        RemainingQuantity = Math.Max(0, availableQty - allocateResult.ActualAllocatedQuantity),
+                        LocationCode = stock.LocationCode,
+                        OutStockLockInfos = allocateResult.LockInfoList
+                    });
+
+                    actualAllocated += allocateResult.ActualAllocatedQuantity;
+                    needAllocateQuantity -= allocateResult.ActualAllocatedQuantity;
+                    lockInfoList.AddRange(allocateResult.LockInfoList);
+                }
+            }
+
+            return (actualAllocated, pickedDetails, lockInfoList);
+        }
+
+        /// <summary>
+        /// 涓烘寚瀹氬簱瀛樼敓鎴愪换鍔★紙鍘熸湁閫昏緫涓嶅彉锛�
+        /// </summary>
+        private List<Dt_Task> GenerateTasksForSpecifiedStock(List<PickedStockDetailDTO> pickedDetails, string outboundTargetLocation)
+        {
+            List<Dt_Task> tasks = new List<Dt_Task>();
+            var palletCodes = pickedDetails.Select(x => x.PalletCode).Distinct().ToList();
+
+            foreach (var palletCode in palletCodes)
+            {
+                Dt_StockInfo stock = _stockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+                if (stock == null) continue;
+
+                int taskNum = pickedDetails.First(x => x.PalletCode == palletCode)
+                    .OutStockLockInfos.FirstOrDefault()?.TaskNum ??
+                    Db.Ado.GetScalar($"SELECT NEXT VALUE FOR SeqTaskNum").ObjToInt();
+
+                Dt_Task task = GenerationOutTask(stock, TaskTypeEnum.Outbound, taskNum, outboundTargetLocation);
+                if (tasks.FirstOrDefault(x => x.PalletCode == palletCode) == null)
+                    tasks.Add(task);
+            }
+
+            return tasks;
+        }
+
+        /// <summary>
+        /// 鏋勫缓搴撳瓨鏌ヨ鏉′欢锛堝師鏈夐�昏緫涓嶅彉锛�
+        /// </summary>
+        private List<Dt_StockInfo> BuildStockQueryWithInfo(MaterielOutboundCalculationDTO materielCalc, string factoryArea)
+        {
+            ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>()
+                .Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0
+                && (x.Status == (int)StockStatusEmun.鍏ュ簱瀹屾垚 || x.Status == (int)StockStatusEmun.鎵嬪姩瑙i攣));
+
+            if (!string.IsNullOrEmpty(materielCalc.SupplyCode))
+                stockDetails = stockDetails.Where(x => x.SupplyCode == materielCalc.SupplyCode);
+            if (!string.IsNullOrEmpty(materielCalc.WarehouseCode))
+                stockDetails = stockDetails.Where(x => x.WarehouseCode == materielCalc.WarehouseCode);
+            if (!string.IsNullOrEmpty(factoryArea))
+                stockDetails = stockDetails.Where(x => x.FactoryArea == factoryArea);
+            if (!string.IsNullOrEmpty(materielCalc.BatchNo))
+                stockDetails = stockDetails.Where(x => x.BatchNo == materielCalc.BatchNo);
+
+            List<Dt_StockInfoDetail> stockDetailList = stockDetails.ToList();
+            List<string> locationCodes = _locationInfoRepository.QueryData(x =>
+                (x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() || x.LocationStatus == LocationStatusEnum.Lock.ObjToInt())
+                && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()).Select(x => x.LocationCode).ToList();
+
+            List<int> stockIds = stockDetailList.GroupBy(x => x.StockId).Select(x => x.Key).ToList();
+            List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x =>
+                stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() || x.StockStatus == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt())
+                && !string.IsNullOrEmpty(x.LocationCode) && locationCodes.Contains(x.LocationCode));
+
+            foreach (var stockInfo in stockInfos)
+            {
+                stockInfo.Details = stockDetailList.Where(x => x.StockId == stockInfo.Id).ToList();
+            }
+
+            return stockInfos;
+        }
+
+        /// <summary>
+        /// 鎵归噺鑾峰彇鎵樼洏鍙敤搴撳瓨淇℃伅锛堝師鏈夐�昏緫涓嶅彉锛�
+        /// </summary>
+        private (Dictionary<int, decimal> AvailableStockMap, Dictionary<int, List<Dt_OutStockLockInfo>> LockStockMap) GetBatchAvailableStockQuantities(
+            MaterielOutboundCalculationDTO materielCalc, List<Dt_StockInfo> stockInfos)
+        {
+            List<int> stockIds = stockInfos.Select(x => x.Id).ToList();
+            Dictionary<int, decimal> availableStockMap = new Dictionary<int, decimal>();
+            Dictionary<int, List<Dt_OutStockLockInfo>> lockStockMap = new Dictionary<int, List<Dt_OutStockLockInfo>>();
+
+            List<Dt_OutStockLockInfo> allocatedData = materielCalc.OutStockLockInfos
+                .Where(x => stockIds.Contains(x.StockId) && x.MaterielCode == materielCalc.MaterielCode).ToList();
+
+            foreach (var stockInfo in stockInfos)
+            {
+                decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
+                List<Dt_OutStockLockInfo> outStockLockInfos = allocatedData
+                    .Where(x => x.StockId == stockInfo.Id && x.MaterielCode == materielCalc.MaterielCode).ToList();
+                decimal allocatedQuantity = outStockLockInfos.Sum(x => x.AllocatedQuantity);
+
+                availableStockMap[stockInfo.Id] = Math.Max(0, totalQuantity - allocatedQuantity);
+                lockStockMap[stockInfo.Id] = outStockLockInfos;
+            }
+
+            return (availableStockMap, lockStockMap);
+        }
+
+        /// <summary>
+        /// 鍒嗛厤搴撳瓨锛堟牳蹇冧紭鍖栵細OriginalQuantity璧嬪�间负鎵樼洏鐗╂枡鎬诲簱瀛橈級
+        /// </summary>
+        private (decimal ActualAllocatedQuantity, List<Dt_OutStockLockInfo> LockInfoList) AllocateStockQuantity(
+            Dt_StockInfo stockInfo, decimal allocateQuantity, decimal availableQuantity,
+            Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail detail,
+            PickingOutboundRequestDTO request, List<Dt_OutStockLockInfo> lockInfos,
+            Dictionary<int, List<Dt_StockInfoDetail>> stockDetailMap = null,
+            decimal palletMaterielTotalStock = 0 // 鏂板锛氭墭鐩樼墿鏂欐�诲簱瀛樺弬鏁�
+        )
+        {
+            decimal actualAllocatedQuantity = Math.Min(allocateQuantity, availableQuantity);
+            List<Dt_OutStockLockInfo> lockInfoList = new List<Dt_OutStockLockInfo>();
+
+            if (actualAllocatedQuantity > 0)
+            {
+                // 妫�鏌ョ洰鏍囦綅缃竴鑷存��
+                if (lockInfos.Any() && !string.IsNullOrEmpty(lockInfos.First().OutboundTargetLocation)
+                    && !string.Equals(lockInfos.First().OutboundTargetLocation, request.OutboundTargetLocation, StringComparison.OrdinalIgnoreCase))
+                {
+                    return (0, lockInfoList);
+                }
+
+                Dt_OutStockLockInfo? lockInfo = lockInfos.FirstOrDefault(x =>
+                    x.StockId == stockInfo.Id && x.Status == OutLockStockStatusEnum.宸插垎閰�.ObjToInt()
+                    && x.PalletCode == stockInfo.PalletCode && x.OrderNo == outboundOrder.OrderNo);
+
+                if (lockInfo != null)
+                {
+                    List<string> currentIds = lockInfo.OrderDetailIds?.Split(',').ToList() ?? new List<string>();
+                    if (!currentIds.Contains(detail.Id.ToString()))
+                    {
+                        currentIds.Add(detail.Id.ToString());
+                        lockInfo.OrderDetailIds = string.Join(",", currentIds);
+                    }
+
+                    decimal totalAllocatedQuantity = CalcTotalAllocatedQuantity(lockInfos, stockInfo.Id, detail.MaterielCode);
+                    lockInfo.AssignQuantity += actualAllocatedQuantity;
+                    lockInfo.AllocatedQuantity = totalAllocatedQuantity;
+                    // 瀛橀噺閿佸畾璁板綍涔熸洿鏂癘riginalQuantity涓烘墭鐩樻�诲簱瀛橈紙鍙�夛紝淇濇寔鏁版嵁涓�鑷达級
+                    if (palletMaterielTotalStock > 0)
+                        lockInfo.OriginalQuantity = palletMaterielTotalStock;
+                    lockInfoList.Add(lockInfo);
+                }
+                else
+                {
+                    // ===== 鏍稿績浼樺寲2锛歄riginalQuantity璧嬪�间负鎵樼洏鐗╂枡鎬诲簱瀛� =====
+                    decimal originalQuantity = palletMaterielTotalStock; // 鏇夸唬鍘熸湁灞�閮ㄦ槑缁嗘暟閲�
+
+                    List<string> allDetailIds = outboundOrder.Details.Where(x =>
+                        x.OrderId == outboundOrder.Id && x.MaterielCode == detail.MaterielCode
+                        && x.BatchNo == detail.BatchNo && x.SupplyCode == detail.SupplyCode
+                        && x.WarehouseCode == detail.WarehouseCode)
+                        .Select(x => x.Id.ToString()).ToList();
+
+                    decimal totalAllocatedQuantity = CalcTotalAllocatedQuantity(lockInfos, stockInfo.Id, detail.MaterielCode);
+
+                    lockInfo = new Dt_OutStockLockInfo
+                    {
+                        OrderNo = request.OrderNo,
+                        OrderDetailIds = string.Join(",", allDetailIds),
+                        OrderType = outboundOrder.OrderType,
+                        BatchNo = detail.BatchNo,
+                        MaterielCode = detail.MaterielCode,
+                        MaterielName = detail.MaterielName,
+                        StockId = stockInfo.Id,
+                        OrderQuantity = allDetailIds.Count > 1
+                            ? outboundOrder.Details.Where(x =>
+                                x.OrderId == outboundOrder.Id && x.MaterielCode == detail.MaterielCode
+                                && x.BatchNo == detail.BatchNo && x.SupplyCode == detail.SupplyCode
+                                && x.WarehouseCode == detail.WarehouseCode).Sum(x => x.OrderQuantity)
+                            : detail.OrderQuantity,
+                        OriginalQuantity = originalQuantity, // 鐜板湪璧嬪�间负鎵樼洏鐗╂枡鎬诲簱瀛�
+                        AssignQuantity = actualAllocatedQuantity,
+                        AllocatedQuantity = totalAllocatedQuantity,
+                        LocationCode = stockInfo.LocationCode,
+                        PalletCode = stockInfo.PalletCode,
+                        Unit = detail.Unit,
+                        OutboundTargetLocation = request.OutboundTargetLocation,
+                        Status = OutLockStockStatusEnum.宸插垎閰�.ObjToInt(),
+                        SupplyCode = detail.SupplyCode,
+                        WarehouseCode = detail.WarehouseCode,
+                        FactoryArea = outboundOrder.FactoryArea,
+                        TaskNum = Db.Ado.GetScalar($"SELECT NEXT VALUE FOR SeqTaskNum").ObjToInt(),
+                        OrderDetailId = 0
+                    };
+                    lockInfoList.Add(lockInfo);
+                }
+            }
+
+            return (actualAllocatedQuantity, lockInfoList);
+        }
+
+        /// <summary>
+        /// 璁$畻璇ユ墭鐩樼疮璁″凡鍒嗛厤鏁伴噺锛堝師鏈夐�昏緫涓嶅彉锛�
+        /// </summary>
+        private decimal CalcTotalAllocatedQuantity(List<Dt_OutStockLockInfo> lockInfos, int stockId, string materielCode)
+        {
+            List<Dt_OutStockLockInfo> lockRecords = _outboundLockInfoRepository.QueryData(x =>
+                x.StockId == stockId && x.MaterielCode == materielCode);
+
+            return lockRecords?.Sum(x => x.AssignQuantity) ?? 0;
+        }
+
+        /// <summary>
+        /// 鐢熸垚鍑哄簱浠诲姟锛堝師鏈夐�昏緫涓嶅彉锛�
+        /// </summary>
         public Dt_Task GenerationOutTask(Dt_StockInfo stockInfo, TaskTypeEnum taskType, int taskNum, string outStation)
         {
-
-            Dt_Task task = new()
+            return new Dt_Task
             {
                 CurrentAddress = stockInfo.LocationCode,
                 Grade = 0,
@@ -538,240 +755,13 @@
                 PalletType = stockInfo.PalletType,
                 WarehouseId = stockInfo.WarehouseId,
             };
-
-            return task;
         }
-
-        /// <summary>
-        /// 鏋勫缓搴撳瓨鏌ヨ鏉′欢锛堝寘鍚簱瀛樹俊鎭拰搴撳瓨鏄庣粏锛�
-        /// </summary>
-        /// <param name="materielCalc"></param>
-        /// <param name="factoryArea"></param>
-        /// <returns></returns>
-        private List<Dt_StockInfo> BuildStockQueryWithInfo(MaterielOutboundCalculationDTO materielCalc, string factoryArea)
-        {
-            // 鍩虹鏌ヨ鏉′欢锛氱墿鏂欑紪鍙枫�佹壒娆″彿锛堝鏋滄彁渚涳級銆佸簱瀛樻暟閲�>0
-            ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0 && (x.Status == (int)StockStatusEmun.鍏ュ簱瀹屾垚 || x.Status == (int)StockStatusEmun.鎵嬪姩瑙i攣));
-
-            // 鏍规嵁鏉′欢娣诲姞渚涘簲鍟嗙紪鍙峰尮閰嶏紙涓嶄负绌烘椂鎵嶉渶瑕佸尮閰嶏級
-            if (!string.IsNullOrEmpty(materielCalc.SupplyCode))
-            {
-                stockDetails = stockDetails.Where(x => x.SupplyCode == materielCalc.SupplyCode);
-            }
-
-            // 鏍规嵁鏉′欢娣诲姞浠撳簱缂栧彿鍖归厤锛堜笉涓虹┖鏃舵墠闇�瑕佸尮閰嶏級
-            if (!string.IsNullOrEmpty(materielCalc.WarehouseCode))
-            {
-                stockDetails = stockDetails.Where(x => x.WarehouseCode == materielCalc.WarehouseCode);
-            }
-
-            // 鏍规嵁鏉′欢娣诲姞鍘傚尯鍖归厤锛堜笉涓虹┖鏃舵墠闇�瑕佸尮閰嶏級
-            if (!string.IsNullOrEmpty(factoryArea))
-            {
-                stockDetails = stockDetails.Where(x => x.FactoryArea == factoryArea);
-            }
-
-            // 鏍规嵁鎵规鍙疯繘琛岃繃婊わ紙濡傛灉鎻愪緵锛�
-            if (!string.IsNullOrEmpty(materielCalc.BatchNo))
-            {
-                stockDetails = stockDetails.Where(x => x.BatchNo == materielCalc.BatchNo);
-            }
-
-            List<Dt_StockInfoDetail> stockDetailList = stockDetails.ToList();
-
-            // 鑾峰彇鍙敤璐т綅缂栧彿
-            List<string> locationCodes = _locationInfoRepository.QueryData(x => (x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() /*|| x.LocationStatus == LocationStatusEnum.Lock.ObjToInt()*/) && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()).Select(x => x.LocationCode).ToList();
-
-            // 鑾峰彇鎵�鏈夌浉鍏崇殑搴撳瓨淇℃伅
-            List<int> stockIds = stockDetailList.GroupBy(x => x.StockId).Select(x => x.Key).ToList();
-            List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() /*|| x.StockStatus == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()*/) && !string.IsNullOrEmpty(x.LocationCode) && locationCodes.Contains(x.LocationCode));
-
-            // 鍦ㄥ唴瀛樹腑鍏宠仈鏁版嵁
-            foreach (var stockInfo in stockInfos)
-            {
-                stockInfo.Details = new List<Dt_StockInfoDetail>();
-                stockInfo.Details = stockDetailList.Where(x => x.StockId == stockInfo.Id).ToList();
-            }
-
-            return stockInfos;
-        }
-
-        /// <summary>
-        /// 鎵归噺鑾峰彇鎵樼洏鍙敤搴撳瓨淇℃伅
-        /// </summary>
-        /// <param name="stockInfos">搴撳瓨淇℃伅鍒楄〃</param>
-        /// <param name="materielCode">鐗╂枡缂栧彿</param>
-        /// <returns>杩斿洖鍊间负(搴撳瓨涓婚敭锛屽彲鐢ㄦ暟閲�)瀛楀吀</returns>
-        private (Dictionary<int, decimal> AvailableStockMap, Dictionary<int, List<Dt_OutStockLockInfo>> LockStockMap) GetBatchAvailableStockQuantities(MaterielOutboundCalculationDTO materielCalc, List<Dt_StockInfo> stockInfos)
-        {
-            List<int> stockIds = stockInfos.Select(x => x.Id).ToList();
-
-            Dictionary<int, decimal> availableStockMap = new Dictionary<int, decimal>(); // 鍙敤搴撳瓨鏁伴噺
-            Dictionary<int, List<Dt_OutStockLockInfo>> lockStockMap = new Dictionary<int, List<Dt_OutStockLockInfo>>(); // 宸查攣瀹氬簱瀛樻暟閲�
-
-            // 鎵归噺鏌ヨ宸插垎閰嶆暟閲�
-            List<Dt_OutStockLockInfo> allocatedData = materielCalc.OutStockLockInfos.Where(x => stockIds.Contains(x.StockId) && x.MaterielCode == materielCalc.MaterielCode).ToList();
-
-            foreach (var stockInfo in stockInfos)
-            {
-                // 璁$畻鎬诲簱瀛樻暟閲�
-                decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
-
-                List<Dt_OutStockLockInfo> outStockLockInfos = allocatedData.Where(x => x.StockId == stockInfo.Id && x.MaterielCode == materielCalc.MaterielCode).ToList();
-
-                // 璁$畻宸插垎閰嶆暟閲�
-                decimal allocatedQuantity = outStockLockInfos.Sum(x => x.AllocatedQuantity);
-                availableStockMap[stockInfo.Id] = Math.Max(0, totalQuantity - allocatedQuantity);
-
-                lockStockMap[stockInfo.Id] = outStockLockInfos;
-            }
-
-            return (availableStockMap, lockStockMap);
-        }
-
-        /// <summary>
-        /// 鍒嗛厤搴撳瓨
-        /// </summary>
-        /// <param name="stockInfo">搴撳瓨淇℃伅</param>
-        /// <param name="allocateQuantity">瑕佸垎閰嶇殑鏁伴噺</param>
-        /// <param name="availableQuantity">鍙垎閰嶇殑鏁伴噺</param>
-        /// <param name="outboundOrder">鍑哄簱鍗�</param>
-        /// <param name="detail">鍑哄簱鍗曟槑缁�</param>
-        /// <param name="request"></param>
-        /// <param name="lockInfos"></param>
-        /// <param name="stockDetailMap"></param>
-        /// <returns></returns>
-        private (decimal ActualAllocatedQuantity, List<Dt_OutStockLockInfo> LockInfoList) AllocateStockQuantity(Dt_StockInfo stockInfo, decimal allocateQuantity, decimal availableQuantity, Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail detail, PickingOutboundRequestDTO request, List<Dt_OutStockLockInfo> lockInfos, Dictionary<int, List<Dt_StockInfoDetail>> stockDetailMap = null)
-        {
-            decimal actualAllocatedQuantity = Math.Min(allocateQuantity, availableQuantity); // 瀹為檯鍒嗛厤鏁伴噺
-            List<Dt_OutStockLockInfo> lockInfoList = new List<Dt_OutStockLockInfo>();
-            if (actualAllocatedQuantity > 0)
-            {
-                //妫�鏌ョ洰鏍囦綅缃竴鑷存�э細濡傛灉鎵樼洏宸叉湁閿佸畾璁板綍涓旂洰鏍囦綅缃笉鍚岋紝鍒欎笉鍏佽鍒嗛厤
-                if (lockInfos.Any() && !string.IsNullOrEmpty(lockInfos.First().OutboundTargetLocation))
-                {
-                    if (!string.Equals(lockInfos.First().OutboundTargetLocation, request.OutboundTargetLocation, StringComparison.OrdinalIgnoreCase))
-                    {
-                        // 鎵樼洏鐨勭洰鏍囦綅缃笌鏂拌姹傜殑鐩爣浣嶇疆涓嶅悓锛屼笉鍏佽浣跨敤璇ユ墭鐩�
-                        return (0, lockInfoList);
-                    }
-                }
-
-                Dt_OutStockLockInfo? lockInfo = lockInfos.FirstOrDefault(x => x.StockId == stockInfo.Id && x.Status == OutLockStockStatusEnum.宸插垎閰�.ObjToInt() && x.PalletCode == stockInfo.PalletCode && x.OrderNo == outboundOrder.OrderNo);
-
-                if (lockInfo != null)
-                {
-                    // 杩藉姞褰撳墠鏄庣粏ID鍒癘rderDetailIds瀛楁锛堥伩鍏嶉噸澶嶏級
-                    List<string> currentIds = lockInfo.OrderDetailIds?.Split(',').ToList() ?? new List<string>();
-                    if (!currentIds.Contains(detail.Id.ToString()))
-                    {
-                        currentIds.Add(detail.Id.ToString());
-                        lockInfo.OrderDetailIds = string.Join(",", currentIds);
-                    }
-
-                    // 璁$畻璇ユ墭鐩樿鐗╂枡鐨勬�荤疮璁″凡鍑哄簱鏁伴噺锛堣法鎵�鏈夊崟鎹級
-                    decimal totalAllocatedQuantity = CalcTotalAllocatedQuantity(lockInfos, stockInfo.Id, detail.MaterielCode);
-
-                    // 鏇存柊鍒嗛厤鍑哄簱閲�
-                    decimal beforeAssignQuantity = totalAllocatedQuantity; // 鏈鍒嗛厤鍓嶇殑鎬荤疮璁¢噺
-                    lockInfo.AssignQuantity += actualAllocatedQuantity; // 鏈鍒嗛厤鏁伴噺
-                    lockInfo.AllocatedQuantity = beforeAssignQuantity; // 璁板綍鏈鍒嗛厤鍓嶇殑鎬荤疮璁¢噺
-
-                    lockInfoList.Add(lockInfo);
-                }
-                else
-                {
-                    // 鍒涘缓鏂扮殑閿佸畾璁板綍锛堜娇鐢ㄩ鍔犺浇鐨勫簱瀛樻槑缁嗭級
-                    decimal originalQuantity = 0;
-                    if (stockDetailMap?.ContainsKey(stockInfo.Id) == true)
-                    {
-                        originalQuantity = stockDetailMap[stockInfo.Id].Sum(x => x.StockQuantity);
-                    }
-
-                    // 鑾峰彇璇ョ墿鏂欏湪璇ヨ鍗曚腑鐨勬墍鏈夋槑缁咺D
-                    List<string> allDetailIds = (outboundOrder.Details.Where(x =>
-                        x.OrderId == outboundOrder.Id &&
-                        x.MaterielCode == detail.MaterielCode &&
-                        x.BatchNo == detail.BatchNo &&
-                        x.SupplyCode == detail.SupplyCode &&
-                        x.WarehouseCode == detail.WarehouseCode))
-                        .Select(x => x.Id.ToString())
-                        .ToList();
-
-                    // 璁$畻璇ユ墭鐩樿鐗╂枡鐨勬�荤疮璁″凡鍑哄簱鏁伴噺锛堣法鎵�鏈夊崟鎹級
-                    decimal totalAllocatedQuantity = CalcTotalAllocatedQuantity(lockInfos, stockInfo.Id, detail.MaterielCode);
-
-                    lockInfo = new Dt_OutStockLockInfo
-                    {
-                        OrderNo = request.OrderNo,
-                        OrderDetailIds = string.Join(",", allDetailIds), // 璁板綍璇ョ墿鏂欑殑鎵�鏈夋槑缁咺D
-                        OrderType = outboundOrder.OrderType,
-                        BatchNo = detail.BatchNo,
-                        MaterielCode = detail.MaterielCode,
-                        MaterielName = detail.MaterielName,
-                        StockId = stockInfo.Id,
-                        OrderQuantity = allDetailIds.SelectMany(id => allDetailIds).Count() > 1
-                            ? (outboundOrder.Details.Where(x =>
-                                x.OrderId == outboundOrder.Id &&
-                                x.MaterielCode == detail.MaterielCode &&
-                                x.BatchNo == detail.BatchNo &&
-                                x.SupplyCode == detail.SupplyCode &&
-                                x.WarehouseCode == detail.WarehouseCode))
-                                .Sum(x => x.OrderQuantity)
-                            : detail.OrderQuantity, // 濡傛灉鍙湁涓�涓槑缁嗭紝浣跨敤鏄庣粏鏁伴噺
-                        OriginalQuantity = originalQuantity,
-                        AssignQuantity = actualAllocatedQuantity, // 鏈鍒嗛厤鏁伴噺
-                        AllocatedQuantity = totalAllocatedQuantity, // 鏈鍒嗛厤鍓嶇殑鎬荤疮璁″凡鍑哄簱鏁伴噺锛堣法鎵�鏈夊崟鎹級
-                        LocationCode = stockInfo.LocationCode,
-                        PalletCode = stockInfo.PalletCode,
-                        Unit = detail.Unit,
-                        OutboundTargetLocation = request.OutboundTargetLocation,
-                        Status = OutLockStockStatusEnum.宸插垎閰�.ObjToInt(),
-                        SupplyCode = detail.SupplyCode,
-                        WarehouseCode = detail.WarehouseCode,
-                        FactoryArea = outboundOrder.FactoryArea,
-                        TaskNum = Db.Ado.GetScalar($"SELECT NEXT VALUE FOR SeqTaskNum").ObjToInt(),
-                        OrderDetailId = 0 // 鏈叧鑱斿叿浣撴槑缁咺D
-                    };
-                    lockInfoList.Add(lockInfo);
-                }
-            }
-            return (actualAllocatedQuantity, lockInfoList);
-        }
-
-        /// <summary>
-        /// 璁$畻璇ユ墭鐩樼疮璁″凡鍒嗛厤鏁伴噺
-        /// </summary>
-        /// <param name="lockInfos"></param>
-        /// <param name="stockId"></param>
-        /// <param name="materielCode"></param>
-        /// <returns></returns>
-        private decimal CalcTotalAllocatedQuantity(List<Dt_OutStockLockInfo> lockInfos, int stockId, string materielCode)
-        {
-            // 鏌ヨ璇ユ墭鐩樿鐗╂枡鍦ㄦ墍鏈夐攣瀹氳褰曚腑鐨勬渶澶у凡鍒嗛厤鏁伴噺
-            List<Dt_OutStockLockInfo> lockRecords = _outboundLockInfoRepository.QueryData(x =>
-                x.StockId == stockId &&
-                x.MaterielCode == materielCode);
-
-            if (lockRecords == null || !lockRecords.Any())
-            {
-                return 0;
-            }
-
-            // 杩斿洖绱宸插垎閰嶆暟閲�
-            return lockRecords.Sum(x => x.AssignQuantity);
-        }
-
-        /// <summary>
-        /// 鏇存柊鍑哄簱鍗曠姸鎬�
-        /// </summary>
         public bool UpdateOutboundOrderStatus(string orderNo, int status)
         {
             try
             {
                 Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo);
                 if (outboundOrder == null) return false;
-
                 outboundOrder.OrderStatus = status;
                 _outboundRepository.UpdateData(outboundOrder);
                 return true;
@@ -782,22 +772,12 @@
             }
         }
 
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="palletCodes"></param>
-        /// <param name="status"></param>
-        /// <returns></returns>
         public bool UpdateStockStatus(List<string> palletCodes, int status)
         {
             try
             {
                 List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => palletCodes.Contains(x.PalletCode));
-                stockInfos.ForEach(stockInfo =>
-                {
-                    stockInfo.StockStatus = status;
-                });
-
+                stockInfos.ForEach(stockInfo => stockInfo.StockStatus = status);
                 _stockInfoRepository.UpdateData(stockInfos);
                 return true;
             }
@@ -807,22 +787,12 @@
             }
         }
 
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="locationCodes"></param>
-        /// <param name="status"></param>
-        /// <returns></returns>
         public bool UpdateLocationStatus(List<string> locationCodes, int status)
         {
             try
             {
                 List<Dt_LocationInfo> locationInfos = _locationInfoRepository.QueryData(x => locationCodes.Contains(x.LocationCode));
-                locationInfos.ForEach(x =>
-                {
-                    x.LocationStatus = status;
-                });
-
+                locationInfos.ForEach(x => x.LocationStatus = status);
                 _locationInfoRepository.UpdateData(locationInfos);
                 return true;
             }
@@ -832,21 +802,14 @@
             }
         }
 
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="outStockLockInfos"></param>
-        /// <returns></returns>
         public bool UpdateOutStockLockInfo(List<Dt_OutStockLockInfo> outStockLockInfos)
         {
             try
             {
                 List<Dt_OutStockLockInfo> updateData = outStockLockInfos.Where(x => x.Id > 0).ToList();
                 _outboundLockInfoRepository.UpdateData(updateData);
-
                 List<Dt_OutStockLockInfo> addData = outStockLockInfos.Where(x => x.Id <= 0).ToList();
                 _outboundLockInfoRepository.AddData(addData);
-
                 return true;
             }
             catch
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs"
index 794e638..452d411 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs"
@@ -523,23 +523,24 @@
 
                     if (relevantDetails.Any())
                     {
-                        var firstDetail = relevantDetails.First();
-                        var useableQuantity = relevantDetails.Sum(d => d.StockQuantity - d.OutboundQuantity);
-
-                        result.Add(new StockSelectViewDTO
+                        foreach (var item in relevantDetails)
                         {
-                            LocationCode = stock.LocationCode,
-                            MaterielCode = firstDetail.MaterielCode,
-                            MaterielName = firstDetail.MaterielName,
-                            BatchNo = orderDetail.BatchNo,
-                            SupplyCode = orderDetail.SupplyCode,
-                            Barcode = firstDetail.Barcode,
-                            PalletCode = stock.PalletCode,
-                            UseableQuantity = useableQuantity,
-                            StockCreateDate = stock.CreateDate,
-                            StockId = stock.Id,
-                            OrderDetailId = orderDetail.Id // 鍏宠仈鍒板叿浣撶殑鍑哄簱鍗曟槑缁�
-                        });
+                            result.Add(new StockSelectViewDTO
+                            {
+                                LocationCode = stock.LocationCode,
+                                MaterielCode = item.MaterielCode,
+                                MaterielName = item.MaterielName,
+                                BatchNo = item.BatchNo,
+                                SupplyCode = item.SupplyCode,
+                                Barcode = item.Barcode,
+                                PalletCode = stock.PalletCode,
+                                UseableQuantity = item.StockQuantity,
+                                StockCreateDate = stock.CreateDate,
+                                StockId = item.Id,
+                                OrderDetailId = orderDetail.Id // 鍏宠仈鍒板叿浣撶殑鍑哄簱鍗曟槑缁�
+                            });
+                        }
+                        
                     }
                 }
             }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs"
index 9f06e30..27c14ed 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs"
@@ -92,6 +92,10 @@
                             ValidDate = barcodeDto.validDate,
                             BoxSN = barcodeDto.BoxSN
                         };
+                        if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴� || businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
+                        {
+                            orderDetail.WarehouseCode = model.fromWarehouse;
+                        }
                         allocateOrder.Details.Add(orderDetail);
                     }
                 }
@@ -108,6 +112,10 @@
                         BarcodeQty=detailDto.Qty,
                         MaterielName = materialName
                     };
+                    if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴� || businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
+                    {
+                        orderDetail.WarehouseCode = model.fromWarehouse;
+                    }
                     allocateOrder.Details.Add(orderDetail);
                 }
                 allocateOrder.Details.AddRange(allocateOrder.Details);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundController.cs"
index e4bb663..3dfcd07 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundController.cs"
@@ -41,6 +41,17 @@
         }
 
         /// <summary>
+        /// 鐩樼偣缁勭洏
+        /// </summary>
+        /// <param name="palletDto"></param>
+        /// <returns></returns>
+        [HttpPost, Route("StockTakeGroupPallet"), AllowAnonymous]
+        public async Task<WebResponseContent> StockTakeGroupPallet([FromBody] GroupPalletDto palletDto)
+        {
+            return await Service.StockTakeGroupPallet(palletDto);
+        }
+
+        /// <summary>
         /// 鍏ュ簱鍒嗘壒鍥炰紶MES
         /// </summary>
         /// <param name="palletDto"></param>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/TakeStockOrderController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/TakeStockOrderController.cs"
index 8bbacca..19033c5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/TakeStockOrderController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/TakeStockOrderController.cs"
@@ -76,9 +76,18 @@
         /// 鏉傚彂鏉傛敹鍗曞鐞�
         /// </summary>
         [HttpPost, HttpGet, Route("DocumentReconciliation"), AllowAnonymous]
-        public WebResponseContent DocumentReconciliation(int orderId,int id)
+        public WebResponseContent DocumentReconciliation(string barcode)
         {
-            return Service.DocumentReconciliation(orderId, id);
+            return Service.DocumentReconciliation(barcode);
+        }
+
+        /// <summary>
+        /// 鐩樼偣缁勭洏
+        /// </summary>
+        [HttpPost, HttpGet, Route("StockTakeGroupPallet"), AllowAnonymous]
+        public WebResponseContent StockTakeGroupPallet(string barcode, string boxNo)
+        {
+            return Service.StockTakeGroupPallet(barcode,boxNo);
         }
     }
 }

--
Gitblit v1.9.3