From f692f869d5fe2e2aee9d3487dbba83e1821b7f6c Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期四, 04 十二月 2025 18:02:19 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/InterfaceLog.cs                              |   65 +++
 项目代码/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue                                         |  626 ++++++++++++++++--------------
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs                          |   18 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm      |    0 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm |    0 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs                                   |  448 ++++++++++++----------
 6 files changed, 647 insertions(+), 510 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue"
index b73d987..1b7dafd 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/BatchPickingConfirm.vue"
@@ -92,7 +92,7 @@
     </div>
 
     <!-- 鎷嗗寘寮圭獥 -->
-    <div v-if="showCustomSplitDialog" class="custom-dialog-overlay">
+    <div v-if="showCustomSplitDialog" class="custom-dialog-overlay" style="z-index: 2000;">
       <div class="custom-dialog-wrapper">
         <div class="custom-dialog">
           <div class="custom-dialog-header">
@@ -154,7 +154,7 @@
     </div>
 
     <!-- 鎾ら攢鎷嗗寘寮圭獥 -->
-    <div v-if="showRevertSplitDialog" class="custom-dialog-overlay">
+    <div v-if="showRevertSplitDialog" class="custom-dialog-overlay"  style="z-index: 2001;">
       <div class="custom-dialog-wrapper">
         <div class="custom-dialog">
           <div class="custom-dialog-header">
@@ -214,7 +214,7 @@
     </div>
 
     <!-- 鎷嗗寘閾句俊鎭脊绐� -->
-<div v-if="showSplitChainDialog" class="custom-dialog-overlay">
+<div v-if="showSplitChainDialog" class="custom-dialog-overlay"  style="z-index: 2002;">
   <div class="custom-dialog-wrapper">
     <div class="custom-dialog" style="width: 750px;">
       <div class="custom-dialog-header">
@@ -338,7 +338,7 @@
 </div>
 
     <!-- 鎵归噺鍥炲簱寮圭獥 -->
-    <div v-if="showBatchReturnDialog" class="custom-dialog-overlay">
+    <div v-if="showBatchReturnDialog" class="custom-dialog-overlay"  style="z-index: 2003;">
       <div class="custom-dialog-wrapper">
         <div class="custom-dialog">
           <div class="custom-dialog-header">
@@ -370,7 +370,7 @@
     </div>
 
     <!-- 鍙栬蛋绌虹寮圭獥 -->
-    <div v-if="showEmptyPalletDialog" class="custom-dialog-overlay">
+    <div v-if="showEmptyPalletDialog" class="custom-dialog-overlay"  style="z-index: 2004;">
       <div class="custom-dialog-wrapper">
         <div class="custom-dialog">
           <div class="custom-dialog-header">
@@ -405,11 +405,12 @@
   </div>
 </template>
 
+ 
+ 
 <script>
 import http from '@/api/http.js'
-import { ref, defineComponent } from "vue";
+import { defineComponent } from "vue";
 import { ElMessage } from 'element-plus' 
-import { useRoute } from 'vue-router'
 import printView from "@/extension/outbound/extend/printView.vue"
 
 export default defineComponent({
@@ -417,6 +418,7 @@
   components: {printView},
   data() {
     return {
+      // 淇濇寔鎵�鏈夊師濮嬫暟鎹粨鏋勪笉鍙�...
       scanData: {
         orderNo: '',
         palletCode: '',
@@ -432,21 +434,24 @@
       },
       palletStatus: '鏈煡',
       
-      // 寮圭獥鐘舵��
+      // 寮圭獥鐘舵�� - 鍏抽敭淇锛氬彧鍏佽涓�涓脊绐楁墦寮�
+      activeDialog: null, // 'split', 'revert', 'batchReturn', 'emptyPallet', 'splitChain'
       showCustomSplitDialog: false,
       showRevertSplitDialog: false,
       showBatchReturnDialog: false,
       showEmptyPalletDialog: false,
-      showSplitChainDialog: false, // 鏂板锛氭媶鍖呴摼淇℃伅寮圭獥
+      showSplitChainDialog: false,
       
+        // 娣诲姞闃查噸澶嶇偣鍑绘爣蹇�
+      isOpeningDialog: false,
       // 鍔犺浇鐘舵��
       splitLoading: false,
       revertSplitLoading: false,
       batchReturnLoading: false,
       emptypalletOutLoading: false,
-      splitChainLoading: false, // 鏂板锛氭媶鍖呴摼鍔犺浇鐘舵��
+      splitChainLoading: false,
       
-      // 琛ㄥ崟鏁版嵁
+      // 琛ㄥ崟鏁版嵁...
       splitForm: {
         orderNo: '',
         palletCode: '',
@@ -472,14 +477,13 @@
         palletCode: ''
       },
       
-      // 鏂板锛氭媶鍖呴摼鐩稿叧鏁版嵁
       splitChainInfo: {
         originalBarcode: '',
         totalSplitTimes: 0,
         splitChain: []
       },
       
-      // 楠岃瘉瑙勫垯
+      // 楠岃瘉瑙勫垯...
       splitFormRules: {
         originalBarcode: [
           { required: true, message: '璇疯緭鍏ュ師鏉$爜', trigger: 'blur' }
@@ -505,8 +509,17 @@
       isProcessing: false
     }
   },
+  watch: {
+    // 鍏抽敭淇锛氱‘淇濆悓涓�鏃堕棿鍙湁涓�涓脊绐楁墦寮�
+    activeDialog(newVal, oldVal) {
+      this.showCustomSplitDialog = newVal === 'split'
+      this.showRevertSplitDialog = newVal === 'revert'
+      this.showBatchReturnDialog = newVal === 'batchReturn'
+      this.showEmptyPalletDialog = newVal === 'emptyPallet'
+      this.showSplitChainDialog = newVal === 'splitChain'
+    }
+  },
   computed: {
-    // 鏄惁鍙互鍙栨秷鏁翠釜鎷嗗寘閾�
     canCancelWholeChain() {
       return this.splitChainInfo.splitChain && 
              this.splitChainInfo.splitChain.some(item => !item.isReverted);
@@ -519,9 +532,13 @@
       this.batchReturnForm.orderNo = this.$route.query.orderNo;
       this.emptypalletOutForm.orderNo = this.$route.query.orderNo;
     }
-    this.$nextTick(() => {
-      this.$refs.palletInput.focus();
+    // 浣跨敤 requestAnimationFrame 纭繚椤甸潰瀹屽叏鍔犺浇
+    requestAnimationFrame(() => {
+      if (this.$refs.palletInput) {
+        this.$refs.palletInput.focus();
+      }
     });
+ 
   },
   methods: {
     goBack(){
@@ -568,16 +585,77 @@
       }
     },
 
-    // 鎷嗗寘鐩稿叧鏂规硶
-    openSplitDialog() {
+   openSplitDialog() {
+      console.log('寮�濮嬫墦寮�鎷嗗寘寮圭獥');
+      
+      if (this.isOpeningDialog) {
+        console.log('姝e湪鎵撳紑寮圭獥锛岃烦杩�');
+        return;
+      }
+      
       if (!this.scanData.palletCode) {
         this.$message.warning('璇峰厛鎵弿鎵樼洏鐮�');
         return;
       }
-      this.showCustomSplitDialog = true;
-      this.resetSplitForm();
-      this.splitForm.orderNo = this.scanData.orderNo;
-      this.splitForm.palletCode = this.scanData.palletCode;
+      
+      this.isOpeningDialog = true;
+      
+      try {
+        // 鏂规硶1: 浣跨敤 setTimeout 纭繚寮傛鎵ц
+        setTimeout(() => {
+          console.log('鎵ц寮圭獥鎵撳紑閫昏緫');
+          
+          // 鍏堝叧闂墍鏈夊脊绐�
+          this.closeAllDialogsImmediately();
+          
+          // 浣跨敤 requestAnimationFrame 纭繚鍦ㄤ笅涓�甯ф墦寮�
+          requestAnimationFrame(() => {
+            console.log('璁剧疆寮圭獥鐘舵�佷负 true');
+            
+            // 閲嶇疆琛ㄥ崟
+            this.resetSplitForm();
+            this.splitForm.orderNo = this.scanData.orderNo;
+            this.splitForm.palletCode = this.scanData.palletCode;
+            
+            // 鍏抽敭锛氱洿鎺ヨ缃脊绐楃姸鎬�
+            this.showCustomSplitDialog = true;
+            
+            console.log('寮圭獥鐘舵�佸凡璁剧疆锛岀瓑寰匘OM鏇存柊');
+            
+            // 浣跨敤 nextTick 纭繚DOM鏇存柊瀹屾垚
+            this.$nextTick(() => {
+              console.log('DOM鏇存柊瀹屾垚锛屽脊绐楀簲璇ユ樉绀轰簡');
+              this.isOpeningDialog = false;
+              
+              // 灏濊瘯鑱氱劍鍒拌緭鍏ユ
+              setTimeout(() => {
+                const input = this.$refs.splitFormRef?.$el?.querySelector('input');
+                if (input) {
+                  input.focus();
+                  console.log('杈撳叆妗嗗凡鑱氱劍');
+                }
+              }, 100);
+            });
+          });
+        }, 0);
+        
+      } catch (error) {
+        console.error('鎵撳紑鎷嗗寘寮圭獥鍑洪敊:', error);
+        this.isOpeningDialog = false;
+      }
+    },
+      closeAllDialogsImmediately() {
+      console.log('绔嬪嵆鍏抽棴鎵�鏈夊脊绐�');
+      
+      // 鐩存帴璁剧疆涓� false锛屼笉绛夊緟浠讳綍寮傛鎿嶄綔
+      this.showCustomSplitDialog = false;
+      this.showRevertSplitDialog = false;
+      this.showBatchReturnDialog = false;
+      this.showEmptyPalletDialog = false;
+      this.showSplitChainDialog = false;
+      
+      // 寮哄埗DOM鏇存柊
+      this.$forceUpdate();
     },
 
     async onSplitBarcodeScan() {
@@ -620,7 +698,7 @@
               });
               if (res.status) {
                 this.$message.success('鎷嗗寘鎴愬姛');
-                this.showCustomSplitDialog = false;
+                this.closeAllDialogs();
                 await this.loadPalletData();
               } else {
                 this.$message.error(res.message || '鎷嗗寘澶辫触');
@@ -634,28 +712,24 @@
         });
       }
     },
-// 鍦ㄦ媶鍖呭脊绐椾腑鏌ョ湅鎷嗗寘閾�
-async viewSplitChainFromSplit(barcode) {
-  if (!barcode) {
-    this.$message.warning('璇峰厛杈撳叆鏉$爜');
-    return;
-  }
-  
-  // 鍏堝叧闂媶鍖呭脊绐�
-  this.closeCustomSplitDialog();
-  
-  await this.$nextTick();
-  
-  // 鐒跺悗鎵撳紑鎷嗗寘閾句俊鎭脊绐�
-  await this.viewSplitChain(barcode);
-},
+
+    async viewSplitChainFromSplit(barcode) {
+      if (!barcode) {
+        this.$message.warning('璇峰厛杈撳叆鏉$爜');
+        return;
+      }
+      
+      this.closeAllDialogs();
+      
+      setTimeout(() => {
+        this.viewSplitChain(barcode);
+      }, 50);
+    },
+
     // 鎾ら攢鎷嗗寘
     async onRevertSplitBarcodeScan() {
       if (!this.revertSplitForm.newBarcode) return;
       this.revertSplitForm.newBarcode = this.revertSplitForm.newBarcode.replace(/\n/g, '').trim();
-      
-      // 鏂板锛氭壂鎻忓悗鑷姩鏄剧ず鎷嗗寘閾句俊鎭�
-      await this.viewSplitChain(this.revertSplitForm.newBarcode);
     },
 
     async handleRevertSplit() {
@@ -671,7 +745,7 @@
               });
               if (res.status) {
                 this.$message.success('鎾ら攢鎷嗗寘鎴愬姛');
-                this.showRevertSplitDialog = false;
+                this.closeAllDialogs();
                 await this.loadPalletData();
               } else {
                 this.$message.error(res.message || '鎾ら攢鎷嗗寘澶辫触');
@@ -685,216 +759,140 @@
         });
       }
     },
-// 鏌ユ壘瀹屾暣鎷嗗寘閾撅紙浠庢牴鏉$爜寮�濮嬶級
-async findRootChain(currentBarcode) {
-  this.splitChainLoading = true;
-  try {
-    const res = await http.post('/api/OutboundBatchPicking/find-root-split-chain', {
-      orderNo: this.scanData.orderNo,
-      barcode: currentBarcode
-    });
-    
-    if (res.status) {
-      this.splitChainInfo = res.data;
-      this.$message.success('宸插姞杞藉畬鏁存媶鍖呴摼');
-    } else {
-      this.$message.error(res.message || '鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
-    }
-  } catch (error) {
-    this.$message.error('鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
-  } finally {
-    this.splitChainLoading = false;
-  }
-},
-    // 鎷嗗寘閾剧浉鍏虫柟娉�
-   // 鏌ョ湅鎷嗗寘閾句俊鎭�
-async viewSplitChain(barcode) {
-  if (!barcode) {
-    this.$message.warning('璇峰厛杈撳叆鏉$爜');
-    return;
-  }
-  
-  this.splitChainLoading = true;
-  try {
-    const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
-      orderNo: this.scanData.orderNo,
-      barcode: barcode
-    });
-    
-    if (res.status) {
-      this.splitChainInfo = res.data;
-      
-      // 鏄剧ず鎻愮ず淇℃伅锛屽憡璇夌敤鎴疯繖鏄粈涔堢被鍨嬬殑鎷嗗寘閾�
-      let chainType = "褰撳墠鏉$爜鐨勬媶鍖呴摼";
-      if (this.splitChainInfo.chainType === 'root') {
-        chainType = "瀹屾暣鎷嗗寘閾撅紙浠庡師濮嬫潯鐮佸紑濮嬶級";
-      } else if (this.splitChainInfo.chainType === 'branch') {
-        chainType = "鍒嗘敮鎷嗗寘閾�";
+
+    async findRootChain(currentBarcode) {
+      this.splitChainLoading = true;
+      try {
+        const res = await http.post('/api/OutboundBatchPicking/find-root-split-chain', {
+          orderNo: this.scanData.orderNo,
+          barcode: currentBarcode
+        });
+        
+        if (res.status) {
+          this.splitChainInfo = res.data;
+          this.$message.success('宸插姞杞藉畬鏁存媶鍖呴摼');
+        } else {
+          this.$message.error(res.message || '鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
+        }
+      } catch (error) {
+        this.$message.error('鏌ユ壘瀹屾暣鎷嗗寘閾惧け璐�');
+      } finally {
+        this.splitChainLoading = false;
+      }
+    },
+
+    // 鏌ョ湅鎷嗗寘閾句俊鎭�
+    async viewSplitChain(barcode) {
+      if (!barcode) {
+        this.$message.warning('璇峰厛杈撳叆鏉$爜');
+        return;
       }
       
-      this.$message.info(`宸插姞杞�${chainType}锛屽叡${this.splitChainInfo.totalSplitTimes}娆℃媶鍖卄);
-      this.showSplitChainDialog = true;
-    } else {
-      this.$message.error(res.message || '鑾峰彇鎷嗗寘閾句俊鎭け璐�');
-    }
-  } catch (error) {
-    this.$message.error('鑾峰彇鎷嗗寘閾句俊鎭け璐�');
-  } finally {
-    this.splitChainLoading = false;
-  }
-},
+      this.splitChainLoading = true;
+      try {
+        const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
+          orderNo: this.scanData.orderNo,
+          barcode: barcode
+        });
+        
+        if (res.status) {
+          this.splitChainInfo = res.data;
+          this.activeDialog = 'splitChain';
+        } else {
+          this.$message.error(res.message || '鑾峰彇鎷嗗寘閾句俊鎭け璐�');
+        }
+      } catch (error) {
+        this.$message.error('鑾峰彇鎷嗗寘閾句俊鎭け璐�');
+      } finally {
+        this.splitChainLoading = false;
+      }
+    },
 
     // 鍏抽棴鎷嗗寘閾句俊鎭脊绐�
-    closeSplitChainDialog() {
+     closeSplitChainDialog() {
       this.showSplitChainDialog = false;
-      
     },
-    // 鍦ㄦ挙閿�鎷嗗寘寮圭獥涓煡鐪嬫媶鍖呴摼
-async viewSplitChainFromRevert(barcode) {
-  if (!barcode) {
-    this.$message.warning('璇峰厛杈撳叆鏉$爜');
-    return;
-  }
-  
-  // 鍏堝叧闂挙閿�鎷嗗寘寮圭獥
-  this.closeRevertSplitDialog();
-  
-  await this.$nextTick();
-  
-  // 鐒跺悗鎵撳紑鎷嗗寘閾句俊鎭脊绐�
-  await this.viewSplitChain(barcode);
-},
-// 蹇�熼噸鏂版墦寮�鎷嗗寘閾惧脊绐�
-async quickReopenSplitChainDialog(barcode) {
-  if (!barcode) return;
-  
-  this.showSplitChainDialog = true;
-  this.splitChainLoading = true;
-  
-  try {
-    const res = await http.post('/api/OutboundBatchPicking/split-package-chain-info', {
-      orderNo: this.scanData.orderNo,
-      barcode: barcode
-    });
-    
-    if (res.status) {
-      this.splitChainInfo = res.data;
-    }
-  } catch (error) {
-    console.error('閲嶆柊鍔犺浇鎷嗗寘閾句俊鎭け璐�:', error);
-  } finally {
-    this.splitChainLoading = false;
-  }
-},
-    // 鍙栨秷鍗曚釜鎷嗗寘璁板綍
-async cancelSingleSplit(newBarcode) {
-  // 鍏堣褰曞綋鍓嶄俊鎭紝鐒跺悗鍏抽棴寮圭獥
-  const originalBarcode = this.splitChainInfo.originalBarcode;
-  this.closeSplitChainDialog();
-  
-  await this.$nextTick();
-  
-  try {
-    await this.$confirm(
-      `纭畾瑕佸彇娑堟潯鐮� ${newBarcode} 鐨勬媶鍖呮搷浣滃悧锛焋, 
-      '鍙栨秷鍗曚釜鎷嗗寘', 
-      {
-        confirmButtonText: '纭畾鍙栨秷',
-        cancelButtonText: '鍐嶆兂鎯�',
-        type: 'warning'
-      }
-    );
-    
-    this.revertSplitLoading = true;
-    
-    const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
-      orderNo: this.scanData.orderNo,
-      palletCode: this.scanData.palletCode,
-      newBarcode: newBarcode
-    });
-    
-    if (res.status) {
-      this.$message.success('鍙栨秷鎷嗗寘鎴愬姛');
-      await this.loadPalletData();
-      // 閲嶆柊鎵撳紑寮圭獥鏄剧ず鏇存柊鍚庣殑鐘舵��
-      await this.viewSplitChain(originalBarcode);
-    } else {
-      this.$message.error(res.message || '鍙栨秷鎷嗗寘澶辫触');
-      await this.viewSplitChain(originalBarcode);
-    }
-  } catch (error) {
-    if (error === 'cancel') {
-      // 鐢ㄦ埛鍙栨秷鍚庨噸鏂版墦寮�寮圭獥
-      await this.viewSplitChain(originalBarcode);
-    } else {
-      this.$message.error('鍙栨秷鎷嗗寘澶辫触');
-      await this.viewSplitChain(originalBarcode);
-    }
-  } finally {
-    this.revertSplitLoading = false;
-  }
-},
 
-// 鍙栨秷鏁翠釜鎷嗗寘閾�  
-async cancelWholeSplitChain() {
-  // 鍏堣褰曞綋鍓嶆媶鍖呴摼淇℃伅锛岀劧鍚庡叧闂脊绐�
-  const originalBarcode = this.splitChainInfo.originalBarcode;
-  this.closeSplitChainDialog();
-  
-  // 缁欎竴鐐规椂闂磋寮圭獥瀹屽叏鍏抽棴
-  await this.$nextTick();
-  
-  try {
-    // 鐜板湪鏄剧ず纭瀵硅瘽妗嗭紝纭繚瀹冨湪鏈�鍓嶉潰
-    await this.$confirm(
-      `纭畾瑕佸彇娑堟暣涓媶鍖呴摼鍚楋紵\n杩欏皢鍙栨秷浠庢潯鐮� ${originalBarcode} 寮�濮嬬殑鎵�鏈夋媶鍖呮搷浣溿�俙, 
-      '鍙栨秷鎷嗗寘閾剧‘璁�', 
-      {
-        confirmButtonText: '纭畾鍙栨秷',
-        cancelButtonText: '鍐嶆兂鎯�',
-        type: 'warning',
-        center: true,
-        closeOnClickModal: false
+    // 鍙栨秷鍗曚釜鎷嗗寘璁板綍
+    async cancelSingleSplit(newBarcode) {
+      const originalBarcode = this.splitChainInfo.originalBarcode;
+      
+      try {
+        await this.$confirm(
+          `纭畾瑕佸彇娑堟潯鐮� ${newBarcode} 鐨勬媶鍖呮搷浣滃悧锛焋, 
+          '鍙栨秷鍗曚釜鎷嗗寘', 
+          {
+            confirmButtonText: '纭畾鍙栨秷',
+            cancelButtonText: '鍐嶆兂鎯�',
+            type: 'warning'
+          }
+        );
+        
+        this.revertSplitLoading = true;
+        
+        const res = await http.post('/api/OutboundBatchPicking/cancel-split', {
+          orderNo: this.scanData.orderNo,
+          palletCode: this.scanData.palletCode,
+          newBarcode: newBarcode
+        });
+        
+        if (res.status) {
+          this.$message.success('鍙栨秷鎷嗗寘鎴愬姛');
+          await this.loadPalletData();
+          this.closeAllDialogs();
+          setTimeout(() => {
+            this.viewSplitChain(originalBarcode);
+          }, 50);
+        } else {
+          this.$message.error(res.message || '鍙栨秷鎷嗗寘澶辫触');
+        }
+      } catch (error) {
+        if (error !== 'cancel') {
+          this.$message.error('鍙栨秷鎷嗗寘澶辫触');
+        }
+      } finally {
+        this.revertSplitLoading = false;
       }
-    );
-    
-    // 鐢ㄦ埛纭鍚庢墽琛屽彇娑堟搷浣�
-    this.revertSplitLoading = true;
-    
-    const res = await http.post('/api/OutboundBatchPicking/cancel-split-chain', {
-      orderNo: this.scanData.orderNo,
-      palletCode: this.scanData.palletCode,
-      startBarcode: originalBarcode
-    });
-    
-    console.log('鍙栨秷鎷嗗寘閾惧搷搴�:', res);
-    
-    if (res.status) {
-      this.$message.success('鍙栨秷鎷嗗寘閾炬垚鍔�');
-      await this.loadPalletData();
-      // 鍙�夛細閲嶆柊鎵撳紑鎷嗗寘閾句俊鎭脊绐楁樉绀烘洿鏂板悗鐨勭姸鎬�
-      // await this.viewSplitChain(originalBarcode);
-    } else {
-      this.$message.error(res.message || '鍙栨秷鎷嗗寘閾惧け璐�');
-      // 澶辫触鍚庨噸鏂版墦寮�寮圭獥
-      await this.viewSplitChain(originalBarcode);
-    }
-  } catch (error) {
-    // 鐢ㄦ埛鍙栨秷鎿嶄綔
-    if (error === 'cancel') {
-      console.log('鐢ㄦ埛鍙栨秷浜嗘媶鍖呴摼鎿嶄綔');
-      // 鐢ㄦ埛鍙栨秷鍚庨噸鏂版墦寮�寮圭獥
-      await this.viewSplitChain(originalBarcode);
-    } else {
-      console.error('鍙栨秷鎷嗗寘閾鹃敊璇�:', error);
-      this.$message.error('鍙栨秷鎷嗗寘閾惧け璐�: ' + error.message);
-      // 鍑洪敊鍚庨噸鏂版墦寮�寮圭獥
-      await this.viewSplitChain(originalBarcode);
-    }
-  } finally {
-    this.revertSplitLoading = false;
-  }
-},
+    },
+
+    // 鍙栨秷鏁翠釜鎷嗗寘閾�  
+    async cancelWholeSplitChain() {
+      try {
+        await this.$confirm(
+          `纭畾瑕佸彇娑堟暣涓媶鍖呴摼鍚楋紵\n杩欏皢鍙栨秷浠庢潯鐮� ${this.splitChainInfo.originalBarcode} 寮�濮嬬殑鎵�鏈夋媶鍖呮搷浣溿�俙, 
+          '鍙栨秷鎷嗗寘閾剧‘璁�', 
+          {
+            confirmButtonText: '纭畾鍙栨秷',
+            cancelButtonText: '鍐嶆兂鎯�',
+            type: 'warning',
+            center: true,
+            closeOnClickModal: false
+          }
+        );
+        
+        this.revertSplitLoading = true;
+        
+        const res = await http.post('/api/OutboundBatchPicking/cancel-split-chain', {
+          orderNo: this.scanData.orderNo,
+          palletCode: this.scanData.palletCode,
+          startBarcode: this.splitChainInfo.originalBarcode
+        });
+        
+        if (res.status) {
+          this.$message.success('鍙栨秷鎷嗗寘閾炬垚鍔�');
+          this.closeAllDialogs();
+          await this.loadPalletData();
+        } else {
+          this.$message.error(res.message || '鍙栨秷鎷嗗寘閾惧け璐�');
+        }
+      } catch (error) {
+        if (error !== 'cancel') {
+          this.$message.error('鍙栨秷鎷嗗寘閾惧け璐�: ' + error.message);
+        }
+      } finally {
+        this.revertSplitLoading = false;
+      }
+    },
 
     // 妫�鏌ユ潯鐮佹槸鍚﹀凡琚垎鎷�
     hasPicked(barcode) {
@@ -908,17 +906,43 @@
       return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`;
     },
 
+    // 鍏抽敭淇锛氭柊澧炲叧闂墍鏈夊脊绐楃殑鏂规硶
+    closeAllDialogs() {
+      this.activeDialog = null;
+      // 纭繚鎵�鏈夊脊绐楃姸鎬侀兘琚噸缃�
+      this.showCustomSplitDialog = false;
+      this.showRevertSplitDialog = false;
+      this.showBatchReturnDialog = false;
+      this.showEmptyPalletDialog = false;
+      this.showSplitChainDialog = false;
+    },
+
     // 鍥炲簱鐩稿叧鏂规硶
     openBatchReturnDialog() {
       if (!this.scanData.palletCode) {
         this.$message.warning('璇峰厛鎵弿鎵樼洏鐮�');
         return;
       }
-      this.showBatchReturnDialog = true;
-      this.batchReturnForm.orderNo = this.scanData.orderNo;
-      this.batchReturnForm.palletCode = this.scanData.palletCode;
-      this.batchReturnForm.unpickedCount = this.summary.unpickedCount;
-      this.batchReturnForm.unpickedQuantity = this.summary.unpickedQuantity;
+      
+      if (this.isOpeningDialog) return;
+      
+      this.isOpeningDialog = true;
+      
+      setTimeout(() => {
+        this.closeAllDialogsImmediately();
+        
+        requestAnimationFrame(() => {
+          this.showBatchReturnDialog = true;
+          this.batchReturnForm.orderNo = this.scanData.orderNo;
+          this.batchReturnForm.palletCode = this.scanData.palletCode;
+          this.batchReturnForm.unpickedCount = this.summary.unpickedCount;
+          this.batchReturnForm.unpickedQuantity = this.summary.unpickedQuantity;
+          
+          this.$nextTick(() => {
+            this.isOpeningDialog = false;
+          });
+        });
+      }, 0);
     },
 
     async handleBatchReturnConfirm() {
@@ -930,7 +954,7 @@
         });
         if (res.status) {
           this.$message.success('鍥炲簱鎴愬姛');
-          this.showBatchReturnDialog = false;
+          this.closeAllDialogs();
           await this.loadPalletData();
         } else {
           this.$message.error(res.message || '鍥炲簱澶辫触');
@@ -943,10 +967,24 @@
     },
 
     // 鍙栫┖绠辨柟娉�
-    handleEmptyPallet() {
-      this.showEmptyPalletDialog = true;
-      this.emptypalletOutForm.orderNo = this.scanData.orderNo;
-      this.emptypalletOutForm.palletCode = '';
+handleEmptyPallet() {
+      if (this.isOpeningDialog) return;
+      
+      this.isOpeningDialog = true;
+      
+      setTimeout(() => {
+        this.closeAllDialogsImmediately();
+        
+        requestAnimationFrame(() => {
+          this.showEmptyPalletDialog = true;
+          this.emptypalletOutForm.orderNo = this.scanData.orderNo;
+          this.emptypalletOutForm.palletCode = '';
+          
+          this.$nextTick(() => {
+            this.isOpeningDialog = false;
+          });
+        });
+      }, 0);
     },
 
     async handleEmptyPalletConfirm() {
@@ -958,7 +996,7 @@
         });
         if (res.status) {
           this.$message.success('鍙栬蛋绌虹鎴愬姛');
-          this.showEmptyPalletDialog = false;
+          this.closeAllDialogs();
           await this.loadPalletData();
         } else {
           this.$message.error(res.message || '鍙栬蛋绌虹澶辫触');
@@ -974,9 +1012,13 @@
     async loadPalletData() {
       if (!this.scanData.orderNo || !this.scanData.palletCode) return;
       
-      await this.loadUnpickedList();
-      await this.loadPickedList();
-      await this.loadPalletStatus();
+      try {
+        await this.loadUnpickedList();
+        await this.loadPickedList();
+        await this.loadPalletStatus();
+      } catch (error) {
+        console.error('鍔犺浇鎵樼洏鏁版嵁澶辫触:', error);
+      }
     },
 
     async loadUnpickedList() {
@@ -986,7 +1028,6 @@
           palletCode: this.scanData.palletCode
         });
         if (res.status) {
-          //this.unpickedList = res.data || [];
           this.unpickedList = (res.data || []).filter(item => item.canPick === true);
           this.summary.unpickedCount = this.unpickedList.length;
           this.summary.unpickedQuantity = this.unpickedList.reduce((sum, item) => sum + (item.remainQuantity || 0), 0);
@@ -1003,16 +1044,10 @@
           palletCode: this.scanData.palletCode
         });
         if (res.status) {
-          this.pickedList = res.data || [];
-          
-          this.pickedList = res.data.map(item => {
-  // 鏂瑰紡1锛氫繚鐣欏師barcode瀛楁锛屾柊澧瀋urrentBarcode
-  return {
-    ...item,
-    currentBarcode: item.barcode
-  };
-});
-
+          this.pickedList = res.data.map(item => ({
+            ...item,
+            currentBarcode: item.barcode
+          }));
           this.summary.pickedCount = this.pickedList.length;
         }
       } catch (error) {
@@ -1116,17 +1151,31 @@
       this.resetSplitForm();
     },
 
-    openRevertSplitDialog() {
-      this.showRevertSplitDialog = true;
-      this.revertSplitForm.newBarcode = '';
+openRevertSplitDialog() {
+      if (this.isOpeningDialog) return;
+      
+      this.isOpeningDialog = true;
+      
+      setTimeout(() => {
+        this.closeAllDialogsImmediately();
+        
+        requestAnimationFrame(() => {
+          this.showRevertSplitDialog = true;
+          this.revertSplitForm.newBarcode = '';
+          
+          this.$nextTick(() => {
+            this.isOpeningDialog = false;
+          });
+        });
+      }, 0);
     },
 
-    closeRevertSplitDialog() {
+  closeRevertSplitDialog() {
       this.showRevertSplitDialog = false;
       this.revertSplitForm.newBarcode = '';
     },
 
-    closeBatchReturnDialog() {
+ closeBatchReturnDialog() {
       this.showBatchReturnDialog = false;
     },
 
@@ -1135,7 +1184,7 @@
       this.emptypalletOutForm.palletCode = this.emptypalletOutForm.palletCode.replace(/\n/g, '').trim();
     },
 
-    closeEmptyPalletDialog() {
+     closeEmptyPalletDialog() {
       this.showEmptyPalletDialog = false;
       this.emptypalletOutForm.palletCode = '';
     },
@@ -1182,19 +1231,7 @@
   color: #909399;
 }
 
-/* 鑷畾涔夊脊绐楁牱寮� */
-:deep(.el-message-box) {
-  z-index: 10010 !important;
-}
-
-:deep(.el-overlay) {
-  z-index: 10009 !important;
-}
-
-:deep(.el-message) {
-  z-index: 10011 !important;
-}
-
+/* 鑷畾涔夊脊绐楁牱寮� - 鍏抽敭淇 */
 .custom-dialog-overlay {
   position: fixed;
   top: 0;
@@ -1205,12 +1242,12 @@
   display: flex;
   align-items: center;
   justify-content: center;
-  z-index: 2000; /* 淇濇寔涓�涓悎鐞嗙殑 z-index */
+  z-index: 9999; /* 鎻愰珮z-index纭繚鍦ㄦ渶涓婂眰 */
 }
 
 .custom-dialog-wrapper {
   position: relative;
-  z-index: 2001;
+  z-index: 10000;
 }
 
 .custom-dialog {
@@ -1276,14 +1313,7 @@
     flex-direction: column;
     align-items: stretch;
   }
-  /* 纭繚纭瀵硅瘽妗嗗湪鏈�鍓嶉潰 */
-.el-message-box__wrapper {
-  z-index: 10001 !important;
-}
-
-.el-message {
-  z-index: 10002 !important;
-}
+  
   .scanner-form .el-input {
     width: 100%;
   }
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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm" "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
index afba870..97ece0b 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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
+++ "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
Binary files differ
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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm" "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
index a06ba36..81243ca 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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
+++ "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
Binary files differ
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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
index 15db4f7..7d8276f 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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
@@ -430,218 +430,46 @@
                     return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖浼犵殑鍒嗘嫞璁板綍");
 
 
-                var documentNo = UniqueValueGenerator.Generate();
-
-
-                var feedModel = new FeedbackOutboundRequestModel
+                var groups = pickingRecords.GroupBy(x => x.FeedBackMesDocumentNo).ToList();
+                foreach (var group in groups)
                 {
-                    reqCode = Guid.NewGuid().ToString(),
-                    reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                    business_type = outboundOrder.BusinessType,
-                    factoryArea = outboundOrder.FactoryArea,
-                    operationType = 1,
-                    Operator = outboundOrder.Operator != "" ? outboundOrder.Operator : App.User.UserName,
-                    orderNo = outboundOrder.UpperOrderNo,
-                    documentsNO = documentNo,
-                    status = outboundOrder.OrderStatus,
-                    details = new List<FeedbackOutboundDetailsModel>()
-                };
-                var detailIds = new List<int>();
-                // 濉厖鏄庣粏鍜屾潯鐮佷俊鎭�
-                foreach (var detail in orderDetails)
-                {
-                    // 鏌ヨ璇ユ槑缁嗗搴旂殑閿佸畾鏉$爜璁板綍
-                    var detailPicks = pickingRecords.Where(x => x.OrderNo == orderNo
-                                   && detail.Id == x.OrderDetailId).ToList();
-                    if (!detailPicks.Any())
+                    
+                    List<Dt_PickingRecord> records = group.ToList(); // 璇ュ垎缁勪笅鐨勬墍鏈夎褰�
+                    if (string.IsNullOrEmpty(group.Key))
                     {
-                        continue;
-                    }
-                    var detailModel = new FeedbackOutboundDetailsModel
-                    {
-                        materialCode = detail.MaterielCode,
-                        lineNo = detail.lineNo,
-                        warehouseCode = detail.WarehouseCode,
-                        qty = detail.BarcodeQty,
-                        currentDeliveryQty = 0,
-                        unit = detail.BarcodeUnit,
-                        barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
-                    };
-
-                    // 濉厖鏉$爜淇℃伅锛堝惈鍗曚綅杞崲锛�
-                    foreach (var item in detailPicks)
-                    {
-                        if (item.PickQuantity <= 0)
+                        var emptydocumentNo = UniqueValueGenerator.Generate();
+                        records.ForEach(x => { x.FeedBackMesDocumentNo = emptydocumentNo; });
+                        var result=   await _pickingRecoreRepository.Db.Insertable(records).ExecuteCommandAsync();
+                        if (result > 0)
                         {
-                            continue;
-                        }
-                        var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
-                        {
-                            barcode = item.Barcode,
-                            supplyCode = item.SupplyCode,
-                            batchNo = item.BatchNo,
-                            unit = item.BarcodeUnit,
-                            qty = item.PickQuantity
-                        };
-
-                        // 鍗曚綅涓嶄竴鑷存椂杞崲
-                        if (detail.BarcodeUnit != detail.Unit)
-                        {
-                            var convertResult = await _materialUnitService.ConvertAsync(
-                                item.MaterielCode, item.PickQuantity, detail.Unit, detail.BarcodeUnit);
-                            barModel.unit = convertResult.Unit;
-                            barModel.qty = convertResult.Quantity;
-                        }
-                        else
-                        {
-                            barModel.qty = item.PickQuantity;
-                        }
-                        detailModel.currentDeliveryQty += barModel.qty;
-                        detailModel.barcodes.Add(barModel);
-                    }
-                    detailIds.Add(detail.Id);
-                    feedModel.details.Add(detailModel);
-                }
-
-                feedModel.details = feedModel.details.GroupBy(item => new { item.materialCode, item.lineNo, item.warehouseCode, item.unit, item.qty }).Select(group => new FeedbackOutboundDetailsModel
-                {
-                    materialCode = group.Key.materialCode,
-                    lineNo = group.Key.lineNo,
-                    warehouseCode = group.Key.warehouseCode,
-                    qty = group.Key.qty,
-                    currentDeliveryQty = group.Sum(x => x.currentDeliveryQty),
-                    unit = group.Key.unit,
-                    barcodes = group.SelectMany(x => x.barcodes.GroupBy(o => new { o.barcode, o.supplyCode, o.batchNo, o.unit }).Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
-                    {
-                        barcode = row.Key.barcode,
-                        supplyCode = row.Key.supplyCode,
-                        batchNo = row.Key.batchNo,
-                        unit = row.Key.unit,
-                        qty = row.Sum(y => y.qty)
-                    })).ToList()
-                }).ToList();
-
-                var allCompleted = true;
-
-                // 绛涢�夊緟鍥炰紶鐨勬槑缁嗭紙ReturnToMESStatus=0锛�
-                var pendingDetails = orderDetails.Where(x => x.ReturnToMESStatus == 0).ToList();
-                foreach (var detail in pendingDetails)
-                {
-                    if (detail.OverOutQuantity < detail.NeedOutQuantity)
-                    {
-                        allCompleted = false;
-                    }
-                }
-
-                // 瀛樺湪鍥炰紶澶辫触鐨勬槑缁嗭紙ReturnToMESStatus=2锛夛紝鏍囪鏈畬鎴�
-                if (orderDetails.Any(x => x.ReturnToMESStatus == 2))
-                {
-                    allCompleted = false;
-                }
-
-                //  鏇存柊璁㈠崟鐘舵��
-                int newStatus = allCompleted ? (int)OutOrderStatusEnum.鍑哄簱瀹屾垚 : (int)OutOrderStatusEnum.鍑哄簱涓�;
-                if (outboundOrder.OrderStatus != newStatus)
-                {
-
-                    int updateCount = await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                        .SetColumns(x => x.OrderStatus == newStatus)
-                        .Where(x => x.OrderNo == orderNo)
-                        .ExecuteCommandAsync();
-
-                    if (updateCount <= 0)
-                    {
-                        _logger.LogWarning($"鏇存柊鍑哄簱鍗曠姸鎬佸け璐� - OrderNo: {orderNo}, 鐩爣鐘舵��: {newStatus}");
-
-                    }
-                }
-
-
-                // 璋冪敤MES鍥炰紶鎺ュ彛
-                var mesResult = await FeedbackOutbound(feedModel);
-                if (mesResult == null || mesResult.code != 200)
-                {
-
-                    // 鏇存柊鏄庣粏涓哄洖浼犲け璐ワ紙ReturnToMESStatus=2锛�
-                    await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                        .SetColumns(it => new Dt_OutboundOrderDetail
-                        {
-                            ReturnToMESStatus = 2,
-                            documentsNO = documentNo,
-                        })
-                        .Where(x => detailIds.Contains(x.Id))
-                        .ExecuteCommandAsync();
-
-                    return WebResponseContent.Instance.Error($"鍥炰紶MES澶辫触");
-                }
-                foreach (var record in pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList())
-                {
-                    record.ReturnToMESStatus = 1;
-                }
-                var updates = pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList();
-                updates.ForEach(x =>
-                {
-                    x.ReturnToMESStatus = 1;
-                });
-                await _pickingRecoreRepository.Db.Updateable(updates).ExecuteCommandAsync();
-                if (allCompleted)
-                {
-                    //MES鍥炰紶鎴愬姛锛氭洿鏂版槑缁嗕负鍥炰紶鎴愬姛鐘舵��
-                    await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                        .SetColumns(it => new Dt_OutboundOrderDetail
-                        {
-                            ReturnToMESStatus = 1,
-                            documentsNO = documentNo,
-                        })
-                        .Where(x => detailIds.Contains(x.Id))
-                        .ExecuteCommandAsync();
-                }
-                // 鏍¢獙鏄惁鎵�鏈夋槑缁嗛兘瀹屾垚锛屾洿鏂拌鍗曟渶缁堢姸鎬�
-                if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
-                {
-                    await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                        .SetColumns(x => new Dt_OutboundOrder
-                        {
-                            ReturnToMESStatus = 1,
-                            OrderStatus = newStatus
-                        })
-                        .Where(x => x.OrderNo == orderNo)
-                        .ExecuteCommandAsync();
-                }
-                else
-                {
-                    // 浜屾鏍¢獙鏄惁鎵�鏈夋湭鍥炰紶鏄庣粏閮藉凡瀹屾垚
-                    var dbOrderDetails = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
-                        .LeftJoin<Dt_OutboundOrder>((o, item) => o.OrderId == item.Id)
-                        .Where((o, item) => item.OrderNo == orderNo && item.ReturnToMESStatus != 1)
-                        .Select((o, item) => o)
-                        .ToListAsync();
-
-                    var secAllCompleted = true;
-                    foreach (var detail in dbOrderDetails.Where(x => x.ReturnToMESStatus == 0).ToList())
-                    {
-                        if (detail.OverOutQuantity < detail.NeedOutQuantity)
-                        {
-                            secAllCompleted = false;
-                            break;
-                        }
-                    }
-
-                    if (secAllCompleted)
-                    {
-                        await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                            .SetColumns(it => new Dt_OutboundOrder
+                            (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, emptydocumentNo);
+                            if (!_flowControl)
                             {
-                                ReturnToMESStatus = 1,
-                                OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt(),
-                            })
-                            .Where(x => x.OrderNo == orderNo)
-                            .ExecuteCommandAsync();
+                                return _value;
+                            }
+                        }
+                    }
+                    else
+                    {
+                        (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, group.Key);
+                        if (!_flowControl)
+                        {
+                            return _value;
+                        }
                     }
                 }
+
+
+                //var documentNo = UniqueValueGenerator.Generate();
+
+                //(bool flowControl, WebResponseContent value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, documentNo);
+                //if (!flowControl)
+                //{
+                //    return value;
+                //}
 
                 // 鍥炰紶鎴愬姛鐨勬渶缁堣繑鍥�
-                response = WebResponseContent.Instance.OK($"鍥炰紶MES鎴愬姛锛屽崟鎹彿锛歿documentNo}");
+                response = WebResponseContent.Instance.OK($"鍥炰紶MES鎴愬姛锛屽崟鎹彿锛歿orderNo}");
             }
             catch (Exception ex)
             {
@@ -656,6 +484,218 @@
             return response;
         }
 
+        private async Task<(bool flowControl, WebResponseContent value)> FeedBackBatchToMes(Dt_OutboundOrder outboundOrder, string orderNo, List<Dt_OutboundOrderDetail> orderDetails, List<Dt_PickingRecord> pickingRecords, string documentNo)
+        {
+            var feedModel = new FeedbackOutboundRequestModel
+            {
+                reqCode = Guid.NewGuid().ToString(),
+                reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                business_type = outboundOrder.BusinessType,
+                factoryArea = outboundOrder.FactoryArea,
+                operationType = 1,
+                Operator = outboundOrder.Operator != "" ? outboundOrder.Operator : App.User.UserName,
+                orderNo = outboundOrder.UpperOrderNo,
+                documentsNO = documentNo,
+                status = outboundOrder.OrderStatus,
+                details = new List<FeedbackOutboundDetailsModel>()
+            };
+            var detailIds = new List<int>();
+            // 濉厖鏄庣粏鍜屾潯鐮佷俊鎭�
+            foreach (var detail in orderDetails)
+            {
+                // 鏌ヨ璇ユ槑缁嗗搴旂殑閿佸畾鏉$爜璁板綍
+                var detailPicks = pickingRecords.Where(x => x.OrderNo == orderNo
+                               && detail.Id == x.OrderDetailId).ToList();
+                if (!detailPicks.Any())
+                {
+                    continue;
+                }
+                var detailModel = new FeedbackOutboundDetailsModel
+                {
+                    materialCode = detail.MaterielCode,
+                    lineNo = detail.lineNo,
+                    warehouseCode = detail.WarehouseCode,
+                    qty = detail.BarcodeQty,
+                    currentDeliveryQty = 0,
+                    unit = detail.BarcodeUnit,
+                    barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
+                };
+
+                // 濉厖鏉$爜淇℃伅锛堝惈鍗曚綅杞崲锛�
+                foreach (var item in detailPicks)
+                {
+                    if (item.PickQuantity <= 0)
+                    {
+                        continue;
+                    }
+                    var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
+                    {
+                        barcode = item.Barcode,
+                        supplyCode = item.SupplyCode,
+                        batchNo = item.BatchNo,
+                        unit = item.BarcodeUnit,
+                        qty = item.PickQuantity
+                    };
+
+                    // 鍗曚綅涓嶄竴鑷存椂杞崲
+                    if (detail.BarcodeUnit != detail.Unit)
+                    {
+                        var convertResult = await _materialUnitService.ConvertAsync(
+                            item.MaterielCode, item.PickQuantity, detail.Unit, detail.BarcodeUnit);
+                        barModel.unit = convertResult.Unit;
+                        barModel.qty = convertResult.Quantity;
+                    }
+                    else
+                    {
+                        barModel.qty = item.PickQuantity;
+                    }
+                    detailModel.currentDeliveryQty += barModel.qty;
+                    detailModel.barcodes.Add(barModel);
+                }
+                detailIds.Add(detail.Id);
+                feedModel.details.Add(detailModel);
+            }
+
+            feedModel.details = feedModel.details.GroupBy(item => new { item.materialCode, item.lineNo, item.warehouseCode, item.unit, item.qty }).Select(group => new FeedbackOutboundDetailsModel
+            {
+                materialCode = group.Key.materialCode,
+                lineNo = group.Key.lineNo,
+                warehouseCode = group.Key.warehouseCode,
+                qty = group.Key.qty,
+                currentDeliveryQty = group.Sum(x => x.currentDeliveryQty),
+                unit = group.Key.unit,
+                barcodes = group.SelectMany(x => x.barcodes.GroupBy(o => new { o.barcode, o.supplyCode, o.batchNo, o.unit }).Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
+                {
+                    barcode = row.Key.barcode,
+                    supplyCode = row.Key.supplyCode,
+                    batchNo = row.Key.batchNo,
+                    unit = row.Key.unit,
+                    qty = row.Sum(y => y.qty)
+                })).ToList()
+            }).ToList();
+
+            var allCompleted = true;
+
+            // 绛涢�夊緟鍥炰紶鐨勬槑缁嗭紙ReturnToMESStatus=0锛�
+            var pendingDetails = orderDetails.Where(x => x.ReturnToMESStatus == 0).ToList();
+            foreach (var detail in pendingDetails)
+            {
+                if (detail.OverOutQuantity < detail.NeedOutQuantity)
+                {
+                    allCompleted = false;
+                }
+            }
+
+            // 瀛樺湪鍥炰紶澶辫触鐨勬槑缁嗭紙ReturnToMESStatus=2锛夛紝鏍囪鏈畬鎴�
+            if (orderDetails.Any(x => x.ReturnToMESStatus == 2))
+            {
+                allCompleted = false;
+            }
+
+            //  鏇存柊璁㈠崟鐘舵��
+            int newStatus = allCompleted ? (int)OutOrderStatusEnum.鍑哄簱瀹屾垚 : (int)OutOrderStatusEnum.鍑哄簱涓�;
+            if (outboundOrder.OrderStatus != newStatus)
+            {
+
+                int updateCount = await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                    .SetColumns(x => x.OrderStatus == newStatus)
+                    .Where(x => x.OrderNo == orderNo)
+                    .ExecuteCommandAsync();
+
+                if (updateCount <= 0)
+                {
+                    _logger.LogWarning($"鏇存柊鍑哄簱鍗曠姸鎬佸け璐� - OrderNo: {orderNo}, 鐩爣鐘舵��: {newStatus}");
+
+                }
+            }
+
+
+            // 璋冪敤MES鍥炰紶鎺ュ彛
+            var mesResult = await FeedbackOutbound(feedModel);
+            if (mesResult == null || mesResult.code != 200)
+            {
+
+                // 鏇存柊鏄庣粏涓哄洖浼犲け璐ワ紙ReturnToMESStatus=2锛�
+                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                    .SetColumns(it => new Dt_OutboundOrderDetail
+                    {
+                        ReturnToMESStatus = 2,
+                        documentsNO = documentNo,
+                    })
+                    .Where(x => detailIds.Contains(x.Id))
+                    .ExecuteCommandAsync();
+
+                return (flowControl: false, value: WebResponseContent.Instance.Error($"鍥炰紶MES澶辫触"));
+            }
+            foreach (var record in pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList())
+            {
+                record.ReturnToMESStatus = 1;
+            }
+            var updates = pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList();
+            updates.ForEach(x =>
+            {
+                x.ReturnToMESStatus = 1;
+            });
+            await _pickingRecoreRepository.Db.Updateable(updates).ExecuteCommandAsync();
+            if (allCompleted)
+            {
+                //MES鍥炰紶鎴愬姛锛氭洿鏂版槑缁嗕负鍥炰紶鎴愬姛鐘舵��
+                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                    .SetColumns(it => new Dt_OutboundOrderDetail
+                    {
+                        ReturnToMESStatus = 1,
+                        documentsNO = documentNo,
+                    })
+                    .Where(x => detailIds.Contains(x.Id))
+                    .ExecuteCommandAsync();
+            }
+            // 鏍¢獙鏄惁鎵�鏈夋槑缁嗛兘瀹屾垚锛屾洿鏂拌鍗曟渶缁堢姸鎬�
+            if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
+            {
+                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                    .SetColumns(x => new Dt_OutboundOrder
+                    {
+                        ReturnToMESStatus = 1,
+                        OrderStatus = newStatus
+                    })
+                    .Where(x => x.OrderNo == orderNo)
+                    .ExecuteCommandAsync();
+            }
+            else
+            {
+                // 浜屾鏍¢獙鏄惁鎵�鏈夋湭鍥炰紶鏄庣粏閮藉凡瀹屾垚
+                var dbOrderDetails = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+                    .LeftJoin<Dt_OutboundOrder>((o, item) => o.OrderId == item.Id)
+                    .Where((o, item) => item.OrderNo == orderNo && item.ReturnToMESStatus != 1)
+                    .Select((o, item) => o)
+                    .ToListAsync();
+
+                var secAllCompleted = true;
+                foreach (var detail in dbOrderDetails.Where(x => x.ReturnToMESStatus == 0).ToList())
+                {
+                    if (detail.OverOutQuantity < detail.NeedOutQuantity)
+                    {
+                        secAllCompleted = false;
+                        break;
+                    }
+                }
+
+                if (secAllCompleted)
+                {
+                    await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                        .SetColumns(it => new Dt_OutboundOrder
+                        {
+                            ReturnToMESStatus = 1,
+                            OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt(),
+                        })
+                        .Where(x => x.OrderNo == orderNo)
+                        .ExecuteCommandAsync();
+                }
+            }
+
+            return (flowControl: true, value: null);
+        }
+
         private async Task<WebResponseContent> HandleOutboundOrderToMESCompletion(Dt_OutboundOrder outboundOrder, string orderNo)
         {
             // 鍓嶇疆鍙傛暟鏍¢獙锛氱┖鍊肩洿鎺ヨ繑鍥為敊璇�
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_Model/Models/Outbound/Dt_PickingRecord.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_Model/Models/Outbound/Dt_PickingRecord.cs"
index d642e34..02f07e6 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_Model/Models/Outbound/Dt_PickingRecord.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_Model/Models/Outbound/Dt_PickingRecord.cs"
@@ -8,11 +8,11 @@
 
 namespace WIDESEA_Model.Models
 {
-    
+
     /// <summary>
     /// 鎷i�夎褰曡〃
     /// </summary>
- 
+
     [SugarTable(nameof(Dt_PickingRecord), "鎷i�夎褰曡〃")]
 
     public class Dt_PickingRecord : BaseEntity
@@ -20,7 +20,7 @@
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         public int Id { get; set; }
 
-        public int TaskNo { get; set; } 
+        public int TaskNo { get; set; }
         public string OrderNo { get; set; }
         public int OrderDetailId { get; set; }
 
@@ -93,6 +93,8 @@
         public decimal BarcodeMoveQty { get; set; }
 
         public int ReturnToMESStatus { get; set; }
+
+        public string FeedBackMesDocumentNo { get; set; }
     }
 
 
@@ -114,7 +116,7 @@
         /// 鍥炲簱鏁伴噺
         /// </summary>
         public decimal ReturnQty { get; set; }
-    
+
         public DateTime ReturnTime { get; set; }
         /// <summary>
         /// 0-寰呭洖搴� 1-宸插洖搴�
@@ -126,7 +128,7 @@
     /// 鎷嗗寘璁板綍琛�
     /// </summary>
     [SugarTable("Dt_SplitPackageRecord")]
-    public class Dt_SplitPackageRecord: BaseEntity
+    public class Dt_SplitPackageRecord : BaseEntity
     {
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         public int Id { get; set; }
@@ -140,8 +142,8 @@
         public int OutStockLockInfoId { get; set; } // 鍏宠仈鐨勫嚭搴撻攣瀹氫俊鎭�
         public string OriginalBarcode { get; set; } // 鍘熸潯鐮�
         public string NewBarcode { get; set; } // 鏂版潯鐮�
- 
-        public string FactoryArea { get; set; } 
+
+        public string FactoryArea { get; set; }
         /// <summary>
         /// 鎷嗗垎鏁伴噺锛堟柊鏉$爜鏁伴噺锛�
         /// </summary>
@@ -162,7 +164,7 @@
         [SugarColumn(IsNullable = true)]
         public decimal? OriginalStockQuantity { get; set; }
 
-       public decimal StockBeforeSplit { get; set; }
+        public decimal StockBeforeSplit { get; set; }
         public decimal AssignBeforeSplit { 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_Model/Models/Outbound/InterfaceLog.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_Model/Models/Outbound/InterfaceLog.cs"
new file mode 100644
index 0000000..015828a
--- /dev/null
+++ "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_Model/Models/Outbound/InterfaceLog.cs"
@@ -0,0 +1,65 @@
+锘縰sing Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.DB.Models;
+
+namespace WIDESEA_Model.Models.Outbound
+{
+
+    /// <summary>
+    /// 鎺ュ彛鏃ュ織璁板綍琛�
+    /// </summary>
+    [SugarTable("Dt_InterfaceLog")]
+    public class Dt_InterfaceLog : BaseEntity
+    {
+        /// <summary>
+        /// 涓婚敭ID锛堣嚜澧烇級
+        /// </summary>
+        [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
+        public long Id { get; set; }
+
+        /// <summary>
+        /// 璁㈠崟鍙�
+        /// </summary>
+        [SugarColumn(ColumnName = "OrderNo", Length = 100, IsNullable = false)]
+        [Required(ErrorMessage = "璁㈠崟鍙蜂笉鑳戒负绌�")]
+        public string OrderNo { get; set; }
+
+        /// <summary>
+        /// 鏂囨。鍙�
+        /// </summary>
+        [SugarColumn(ColumnName = "DocumentNo", Length = 100, IsNullable = true)]
+        public string? DocumentNo { get; set; }
+
+        /// <summary>
+        /// 璁㈠崟绫诲瀷
+        /// </summary>
+        [SugarColumn(ColumnName = "OrderType", Length = 50, IsNullable = true)]
+        [Required(ErrorMessage = "璁㈠崟绫诲瀷涓嶈兘涓虹┖")]
+        public string OrderType { get; set; }
+
+        /// <summary>
+        /// JSON鍐呭
+        /// </summary>
+        [SugarColumn(ColumnName = "Content", IsNullable = true, ColumnDataType = "nvarchar(max)")]
+        [Required(ErrorMessage = "鍐呭涓嶈兘涓虹┖")]
+        public string Content { get; set; }
+
+ 
+
+        public int ReturnToMESStatus { get; set; }
+        /// <summary>
+        /// 杞垹闄ゆ爣蹇�
+        /// </summary>
+        [SugarColumn(ColumnName = "IsDeleted", IsNullable = false)]
+        public bool IsDeleted { get; set; } = false;
+
+        
+    }
+
+}

--
Gitblit v1.9.3