From 29f01b0f46e056212c83513ca59be8c3b70d6b41 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期五, 21 十一月 2025 08:07:26 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs       |   32 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/MaterielToMesService.cs             |   53 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs          |  199 ++++++++
 项目代码/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue                            |   13 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs        |  117 +++-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Outbound/OutboundOrderGetDTO.cs              |   38 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs               |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs |   12 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs    |   72 +++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs           |  203 +-------
 项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/printView.vue                      |  588 +++++++++++++++++++++++++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs                 |    6 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutStockLockInfoService.cs     |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IBasicService/IMaterielToMesService.cs           |    3 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundOrderDetailService.cs  |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs                 |    5 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielToMes.cs           |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs                 |    3 
 18 files changed, 1,118 insertions(+), 234 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/printView.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/printView.vue"
new file mode 100644
index 0000000..055e360
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/printView.vue"
@@ -0,0 +1,588 @@
+<template>
+  <div>
+    <vol-box v-model="showDetialBox" :lazy="true" width="500px" :padding="15" title="">
+      <!-- 鎵撳嵃涓撶敤瀹瑰櫒 -->
+      <div id="printContainer" style="position: absolute; left: -9999px;">
+        <div class="print-page" v-for="(item, index) in printData" :key="index">
+          <div class="material-card">
+            <!-- <div class="header">鍗撳姏鑳界墿鏂欐爣璇嗗崱(灏忓寘)</div> -->
+            <div class="dual-column preview-card-header-qrcode">
+              <div class="preview-card-header">鐗╂枡鍗� {{ idx + 1 }}</div>
+              <VueQrcode :value="generateQr(item)" :size="20" id="qrcode" />
+            </div>
+            <div class="content">
+              <!-- 浜岀淮鐮佹斁鍦ㄥ彸涓婅 -->
+              <!-- <div class="qr-section"> -->
+              <!-- <VueQrcode :value="generateQr(item)" id="qrcode" /> -->
+              <!-- </div> -->
+              <div class="row dual-column">
+                <div class="column">
+                  <span class="label">鏂欏彿</span>
+                  <span class="value code-value">{{ item.materialCode }}</span>
+                </div>
+                <div class="column">
+                  <span class="label">渚涘簲鍟嗙紪鐮�</span>
+                  <span class="value">{{ item.supplierCode }}</span>
+                </div>
+              </div>
+
+              <div class="row dual-column">
+                <div class="column">
+                  <span class="label">鍝佸悕</span>
+                  <span class="value">{{ item.materialName }}</span>
+                </div>
+                <div class="column">
+                  <span class="label">閲囪喘鍗曞彿</span>
+                  <span class="value">{{ item.purchaseOrderNo }}</span>
+                </div>
+              </div>
+
+              <div class="row dual-column">
+                <div class="column">
+                  <span class="label">瑙勬牸</span>
+                  <span class="value full-width">{{ item.specification }}</span>
+                </div>
+                <div class="column">
+                  <span class="label">鏁伴噺/鎬绘暟</span>
+                  <span class="value">{{ item.quantityTotal }}</span>
+                </div>
+              </div>
+
+              <div class="row dual-column">
+                <div class="column">
+                  <span class="label">鎵瑰彿</span>
+                  <span class="value">{{ item.batchNumber }}</span>
+                </div>
+                <div class="column">
+                  <span class="label">鎵规</span>
+                  <span class="value">{{ item.batch }}</span>
+                </div>
+              </div>
+
+              <div class="row dual-column">
+                <div class="column">
+                  <span class="label">鍘傚尯</span>
+                  <span class="value">{{ item.factory }}</span>
+                </div>
+                <div class="column">
+                  <span class="label">鏃ユ湡</span>
+                  <span class="value">{{ item.date }}</span>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- 棰勮鍖哄煙 -->
+      <div id="previewContent" class="preview-container">
+        <div class="preview-header">鍗撳姏鑳界墿鏂欐爣璇嗗崱(灏忓寘) - 棰勮 (鍏眥{ printData.length }}涓�)</div>
+        <div class="preview-scroll">
+          <div v-for="(item, idx) in printData" :key="idx" class="preview-card">
+            <div class="dual-column preview-card-header-qrcode">
+              <div class="preview-card-header">鐗╂枡鍗� {{ idx + 1 }}</div>
+              <VueQrcode :value="generateQr(item)" :size="20" id="qrcode" />
+            </div>
+            <div class="preview-wrapper">
+              <div class="content-preview">
+                <div class="row-preview dual-column">
+                  <div class="column-preview">
+                    <span class="label-preview">鏂欏彿</span>
+                    <span class="value-preview code-value">{{ item.materialCode }}</span>
+                  </div>
+                  <div class="column-preview">
+                    <span class="label-preview">渚涘簲鍟嗙紪鐮�</span>
+                    <span class="value-preview">{{ item.supplierCode }}</span>
+                  </div>
+                </div>
+
+                <div class="row-preview dual-column">
+                  <div class="column-preview">
+                    <span class="label-preview">鍝佸悕</span>
+                    <span class="value-preview">{{ item.materialName }}</span>
+                  </div>
+                  <div class="column-preview">
+                    <span class="label-preview">閲囪喘鍗曞彿</span>
+                    <span class="value-preview">{{ item.purchaseOrderNo }}</span>
+                  </div>
+                </div>
+
+                <div class="row-preview dual-column">
+                  <div class="column-preview">
+                    <span class="label-preview">瑙勬牸</span>
+                    <span class="value-preview full-width">{{ item.specification }}</span>
+                  </div>
+                  <div class="column-preview">
+                    <span class="label-preview">鏁伴噺/鎬绘暟</span>
+                    <span class="value-preview">{{ item.quantityTotal }}</span>
+                  </div>
+                </div>
+
+                <div class="row-preview dual-column">
+                  <div class="column-preview">
+                    <span class="label-preview">鎵瑰彿</span>
+                    <span class="value-preview">{{ item.batchNumber }}</span>
+                  </div>
+                  <div class="column-preview">
+                    <span class="label-preview">鎵规</span>
+                    <span class="value-preview">{{ item.batch }}</span>
+                  </div>
+                </div>
+
+                <div class="row-preview dual-column">
+                  <div class="column-preview">
+                    <span class="label-preview">鍘傚尯</span>
+                    <span class="value-preview">{{ item.factory }}</span>
+                  </div>
+                  <div class="column-preview">
+                    <span class="label-preview">鏃ユ湡</span>
+                    <span class="value-preview">{{ item.date }}</span>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <template #footer>
+        <div class="footer-actions">
+          <span class="print-count">鍏� {{ printData.length }} 涓墿鏂欏崱寰呮墦鍗�</span>
+          <div>
+            <el-button type="primary" size="small" @click="print">鎵撳嵃鍏ㄩ儴</el-button>
+            <el-button type="danger" size="small" @click="showDetialBox = false">鍏抽棴</el-button>
+          </div>
+        </div>
+      </template>
+    </vol-box>
+  </div>
+</template>
+
+<script>
+import VolBox from "@/components/basic/VolBox.vue";
+import VueQrcode from "vue-qrcode";
+
+export default {
+  components: { VolBox, VueQrcode },
+  data() {
+    return {
+      showDetialBox: false,
+      printData: [], // 瀛樺偍鎵撳嵃鏁版嵁闆嗗悎
+    };
+  },
+  methods: {
+    generateQr(item) {
+      return `${item.materialCode}_${item.supplierCode}_${item.purchaseOrderNo}_${item.materialName}_${item.batch}_${item.batchNumber}_${item.factory}_${item.date}`;
+    },
+
+    open(rows) {
+      this.showDetialBox = true;
+      this.printData = Array.isArray(rows) ? rows : [rows];
+      console.log('鎵撳嵃鏁版嵁:', this.printData);
+    },
+
+    async print() {
+      if (this.printData.length === 0) {
+        this.$message.warning('娌℃湁鍙墦鍗扮殑鏁版嵁');
+        return;
+      }
+
+      this.$nextTick(() => {
+        try {
+          const printContent = document.getElementById("printContainer").innerHTML;
+          const printWindow = window.open("", "_blank", "width=800,height=600,scrollbars=yes");
+
+          if (!printWindow) {
+            this.$message.error('鏃犳硶鎵撳紑鎵撳嵃绐楀彛锛岃妫�鏌ユ祻瑙堝櫒寮圭獥璁剧疆');
+            return;
+          }
+
+          printWindow.document.write(`
+            <!DOCTYPE html>
+            <html>
+            <head>
+              <meta charset="UTF-8">
+              <title>鐗╂枡鏍囪瘑鍗℃墦鍗� - 鍏�${this.printData.length}涓�</title>
+              <style>
+                /* 閲嶇疆鎵�鏈夋牱寮� */
+                * {
+                  margin: 0;
+                  padding: 0;
+                  box-sizing: border-box;
+                }
+                
+                body {
+                  font-family: SimSun, "瀹嬩綋", sans-serif;
+                  -webkit-print-color-adjust: exact !important;
+                  print-color-adjust: exact !important;
+                  color-adjust: exact !important;
+                }
+                #qrcode {
+                  width: 60px;
+                  height: 60px;
+                  display: block;
+                  margin: 0, 15px
+                }
+                @media print {
+                  @page {
+                    size: 80mm 60mm;
+                    margin: 0;
+                    padding: 0;
+                  }
+                  
+                  body {
+                    margin: 0 !important;
+                    padding: 0 !important;
+                    width: 80mm !important;
+                    background: white !important;
+                  }
+                  
+                  .print-page {
+                    width: 80mm !important;
+                    height: 60mm !important;
+                    page-break-after: always !important;
+                    break-after: page !important;
+                    margin: 0 !important;
+                    padding: 2mm !important;
+                    display: block !important;
+                  }
+                  
+                  .print-page:last-child {
+                    page-break-after: auto !important;
+                  }
+                  
+                  .material-card {
+                    width: 80mm !important;
+                    height: 56mm !important;
+                    border: 0.3mm solid #000 !important;
+                    padding: 1mm !important;
+                    box-sizing: border-box !important;
+                    position: relative !important;
+                    background: white !important;
+                  }
+                  
+                  .header {
+                    font-size: 3.5mm !important;
+                    font-weight: bold !important;
+                    text-align: center !important;
+                    margin-bottom: 1mm !important;
+                    padding-bottom: 0.5mm !important;
+                    border-bottom: 0.2mm solid #000 !important;
+                  }
+                  
+                  .content {
+                    height: calc(100% - 6mm) !important;
+                    position: relative !important;
+                  }
+                  
+                  .row {
+                    display: flex !important;
+                    margin-bottom: 0.8mm !important;
+                    min-height: 6mm !important;
+                  }
+                  
+                  .dual-column {
+                    display: flex !important;
+                    justify-content: space-between !important;
+                  }
+                  
+                  .column {
+                    flex: 1 !important;
+                    display: flex !important;
+                    align-items: center !important;
+                  }
+                  
+                  .column:first-child {
+                    margin-right: 2mm !important;
+                  }
+                  
+                  .label {
+                    font-weight: bold !important;
+                    flex: 0 0 15mm !important;
+                    white-space: nowrap !important;
+                    font-size: 2.2mm !important;
+                  }
+                  
+                  .value {
+                    flex: 1 !important;
+                    overflow: hidden !important;
+                    text-overflow: ellipsis !important;
+                    white-space: nowrap !important;
+                    border-bottom: 0.1mm dashed #666 !important;
+                    padding-bottom: 0.2mm !important;
+                    min-height: 2.5mm !important;
+                    font-size: 2.2mm !important;
+                  }
+                  
+                  .code-value {
+                    font-weight: bold !important;
+                  }
+                  
+                  .full-width {
+                    white-space: normal !important;
+                    word-break: break-all !important;
+                    line-height: 1.2 !important;
+                  }
+                  
+                  /* 浜岀淮鐮佹牱寮� */
+                  .qr-section {                 
+                    width: 10mm !important;
+                    height: 12mm !important;
+                    font-siz:10px;
+                  }
+                  
+                  .qr-section canvas {
+                    width: 10mm !important;
+                    height: 10mm !important;
+                    max-width: 100% !important;
+                    max-height: 100% !important;
+                  }
+                }
+                
+                /* 灞忓箷棰勮鏍峰紡 */
+                @media screen {
+                  body {
+                    background: #f5f5f5;
+                    padding: 10px;
+                    display: flex;
+                    flex-direction: column;
+                    align-items: center;
+                  }
+                  
+                  .print-page {
+                    width: 80mm;
+                    height: 60mm;
+                    margin: 10px 0;
+                    padding: 2mm;
+                    background: white;
+                    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
+                    border: 1px dashed #ccc;
+                  }
+                  
+                  .material-card {
+                    width: 80mm;
+                    height: 60mm;
+                    border: 0.3mm solid #000;
+                    padding: 1.5mm;
+                    background: white;
+                    position: relative;
+                  }
+                  
+                  .qr-section {
+                    position: absolute;
+                    top: 4mm;
+                    right: 2mm;
+                    width: 12mm;
+                    height: 12mm;
+                    border: 0.2mm solid #ccc;
+                    padding: 0.5mm;
+                    background: white;
+                    display: flex;
+                    align-items: center;
+                    justify-content: center;
+                  }
+                  
+                  .qr-section canvas {
+                    width: 10mm !important;
+                    height: 10mm !important;
+                  }
+                }
+              </style>
+            </head>
+            <body>
+              ${printContent}
+              <script>
+                window.onload = function() {
+                  console.log('鎵撳嵃椤甸潰鍔犺浇瀹屾垚锛屽叡${this.printData.length}涓墿鏂欏崱');
+                  // 绛夊緟浜岀淮鐮佹覆鏌撳畬鎴�
+                  setTimeout(() => {
+                    // 寮哄埗璁剧疆浜岀淮鐮乧anvas灏哄
+                    const canvases = document.querySelectorAll('canvas');
+                    canvases.forEach(canvas => {
+                      canvas.style.width = '10mm !important';
+                      canvas.style.height = '10mm !important';
+                    });
+                    window.print();
+                  }, 800);
+                };
+                
+                window.onafterprint = function() {
+                  setTimeout(() => {
+                    window.close();
+                  }, 500);
+                };
+              <\/script>
+            </body>
+            </html>
+          `);
+
+          printWindow.document.close();
+
+        } catch (error) {
+          console.error('鎵撳嵃閿欒:', error);
+          this.$message.error('鎵撳嵃澶辫触: ' + error.message);
+        }
+      });
+    }
+  }
+};
+</script>
+
+<style scoped>
+#qrcode {
+  width: 60px;
+  height: 60px;
+  display: block;
+  margin: 0, 15px
+}
+
+.preview-container {
+  max-height: 500px;
+  overflow: hidden;
+  display: flex;
+  flex-direction: column;
+}
+
+.preview-header {
+  text-align: center;
+  font-size: 16px;
+  font-weight: bold;
+  margin-bottom: 10px;
+  padding: 8px;
+  background: #f0f0f0;
+  border-radius: 4px;
+}
+
+.preview-scroll {
+  max-height: 400px;
+  overflow-y: auto;
+  padding: 10px;
+  border: 1px solid #e0e0e0;
+  border-radius: 4px;
+  background: #f9f9f9;
+}
+
+.preview-card {
+  width: 320px;
+  height: 240px;
+  margin: 0 auto 15px auto;
+  padding: 8px;
+  border: 1px solid #ccc;
+  font-family: SimSun;
+  box-sizing: border-box;
+  border: 2px solid #000;
+  background: white;
+  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
+  position: relative;
+}
+
+.preview-card:last-child {
+  margin-bottom: 0;
+}
+
+.preview-card-header {
+  text-align: center;
+  font-size: 14px;
+  /* font-weight: bold;
+  margin-bottom: 8px;
+  padding-bottom: 4px;
+  border-bottom: 1px solid #000;
+  background: #f5f5f5;
+  padding: 4px; */
+  height: 60px;
+  width: 60px;
+}
+
+.preview-wrapper {
+  position: relative;
+  height: calc(100% - 40px);
+}
+
+.content-preview {
+  width: 100%;
+  height: 100%;
+}
+
+.row-preview {
+  /* margin-bottom: px; */
+  min-height: 32px;
+}
+
+.dual-column {
+  display: flex;
+  justify-content: space-between;
+}
+
+.column-preview {
+  flex: 1;
+  display: flex;
+  align-items: center;
+}
+
+.column-preview:first-child {
+  margin-right: 10px;
+}
+
+.label-preview {
+  font-weight: bold;
+  flex: 0 0 60px;
+  white-space: nowrap;
+  font-size: 12px;
+}
+
+.value-preview {
+  flex: 1;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 12px;
+  border-bottom: 1px dashed #666;
+  padding-bottom: 2px;
+}
+
+.code-value {
+  font-weight: bold;
+}
+
+.full-width {
+  display: block;
+  margin-top: 2px;
+  white-space: normal;
+  word-break: break-all;
+  line-height: 1.2;
+  font-size: 12px;
+}
+
+/* 棰勮鍖哄煙浜岀淮鐮佹牱寮� */
+.qr-section-preview {
+  position: absolute;
+  top: 10px;
+  right: 10px;
+  width: 150px;
+  height: 175px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: 1px solid #ddd;
+  background: white;
+  padding: 2px;
+}
+
+.qr-section-preview canvas {
+  width: 56px !important;
+  height: 56px !important;
+}
+
+.footer-actions {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  width: 100%;
+}
+
+.print-count {
+  font-size: 14px;
+  color: #409EFF;
+  font-weight: bold;
+}
+</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/views/outbound/PickingConfirm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
index 6170a18..494fd05 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/outbound/PickingConfirm.vue"
@@ -291,6 +291,7 @@
       </div>
     </div>
   </div>
+  <print-view ref="childs" @parentcall="parentcall"></print-view>
 </template>
 
 <script>
@@ -298,12 +299,11 @@
 import { ref, defineComponent } from "vue";
 import { ElMessage } from 'element-plus' 
 import { useRoute } from 'vue-router'
+import printView from "@/extension/outbound/extend/printView.vue"
 
 export default defineComponent({
   name: 'PickingConfirm',
-  components: {
-  
-  },
+  components: {printView},
   props: {
     orderNo: {
       type: String,
@@ -844,7 +844,12 @@
           this.$message.success('鎷i�夌‘璁ゆ垚鍔�');
           this.scanData.barcode = ''; // 娓呯┖鐗╂枡鏉$爜
           this.loadData();
-          
+          console.log(res.data.splitResults)
+          if(res.data && res.data.splitResults.length>0){
+            // 璋冪敤瀛愮粍浠舵墦鍗版柟娉�
+            this.$refs.childs.open(res.data.splitResults);
+            //this.$refs.childs.printSplitLabel(res.data.splitResults);
+          }
           // 鎴愬姛鍚庣户缁仛鐒﹀埌鐗╂枡鏉$爜杈撳叆妗嗭紝鍑嗗涓嬩竴涓壂鐮�
           this.$nextTick(() => {
             this.$refs.barcodeInput.focus();
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 328c761..87d60cc 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"
@@ -116,10 +116,11 @@
 
             var content = new StringContent(json, Encoding.UTF8, "application/json");
 
-            _logger.LogInformation("InvokeMESService  FeedbackInbound :  " + json);
+            _logger.LogInformation("InvokeMESService  NewMaterielToMes :  " + json);
 
             using var response = await client.PostAsync("AldBarcodeInformation/BarcodeInformation", content);
             var responseText = await response.Content.ReadAsStringAsync();
+            _logger.LogInformation("InvokeMESService  NewMaterielToMes  body:  " + responseText);
             if (!response.IsSuccessStatusCode)
             {
                 throw new HttpRequestException(responseText);
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/MaterielToMesService.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/MaterielToMesService.cs"
index 9aa41ab..ea0a8d1 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/MaterielToMesService.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/MaterielToMesService.cs"
@@ -1,4 +1,6 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Dm.filter;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 using System;
 using System.Collections.Generic;
@@ -9,6 +11,7 @@
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Basic;
 using WIDESEA_DTO.Outbound;
 using WIDESEA_IBasicService;
 using WIDESEA_Model.Models;
@@ -19,10 +22,11 @@
     internal class MaterielToMesService : ServiceBase<Dt_MaterielToMes, IRepository<Dt_MaterielToMes>>, IMaterielToMesService
     {
         private readonly IInvokeMESService _invokeMESService;
-
-        public MaterielToMesService(IRepository<Dt_MaterielToMes> BaseDal, IInvokeMESService invokeMESService) : base(BaseDal)
+        private readonly ILogger<MaterielToMesService> _logger;
+        public MaterielToMesService(IRepository<Dt_MaterielToMes> BaseDal, IInvokeMESService invokeMESService, ILogger<MaterielToMesService> logger) : base(BaseDal)
         {
             _invokeMESService = invokeMESService;
+            _logger = logger;
         }
         // 鍒涘缓涓�涓娇鐢ㄥ皬椹煎嘲鍛藉悕娉曠殑搴忓垪鍖栬缃�
         JsonSerializerSettings settings = new JsonSerializerSettings
@@ -31,29 +35,50 @@
         };
         public IRepository<Dt_MaterielToMes> Repository => BaseDal;
 
-        public override WebResponseContent AddData(Dt_MaterielToMes saveModel)
+        public async Task<WebResponseContent> AddMaterielToMes(Dt_MaterielToMes saveModel,int operationtype)
         {
-
-            WebResponseContent content = base.AddData(saveModel);
-            if (content.Status)
+            try
             {
- 
+                base.AddData(saveModel);
 
-                string request = JsonConvert.SerializeObject(saveModel, settings);
-             
+                MaterielToMesDTO dto = new MaterielToMesDTO
+                {
+                    batchNo = saveModel.BatchNo,
+                    factoryArea = saveModel.factoryArea,
+                    materialCode = saveModel.MaterielCode,
+                    newmaterialCode = saveModel.NewMaterialBarCode,
+                    oldmaterialCode = saveModel.OldMaterialBarCode,
+                    operationType = 1,
+                    qty = saveModel.Qty,
+                    supplyCode = saveModel.supplyCode,
+                    unit = saveModel.Unit,
+                    warehouseCode = saveModel.warehouseCode,
+                    reqCode = Guid.NewGuid().ToString(),
+                    reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                };
+
+                var result = await _invokeMESService.NewMaterielToMes(dto);
+
+                if (result != null && result.code == 200)
+                {
+                    await Db.Updateable<Dt_MaterielToMes>()
+                      .SetColumns(it => it.ReturnToMESStatus ==1)
+                      .Where(it => it.Id == saveModel.Id)
+                      .ExecuteCommandAsync();
+                }
 
                 return WebResponseContent.Instance.OK();
             }
-            else
+            catch (Exception ex)
             {
-                return content;
+                _logger.LogError("MaterielToMesService  add Dt_MaterielToMes:  " + ex.Message);
+                return WebResponseContent.Instance.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_DTO/Outbound/OutboundOrderGetDTO.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/Outbound/OutboundOrderGetDTO.cs"
index b39c856..8381ea6 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/Outbound/OutboundOrderGetDTO.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/Outbound/OutboundOrderGetDTO.cs"
@@ -52,7 +52,7 @@
     public class SummaryPickingDto
     {
 
-       public string PalletCode { get; set; }
+        public string PalletCode { get; set; }
         public string MaterielCode { get; set; }
         public int UnpickedCount { get; set; }
         public decimal UnpickedQuantity { get; set; }
@@ -180,7 +180,7 @@
         public string OrderNo { get; set; } = string.Empty; // 鍑哄簱鍗曞彿
     }
 
- 
+
 
     public class PickingConfirmReq
     {
@@ -189,7 +189,7 @@
         public string MaterielBarcode { get; set; } = string.Empty; // 鐗╂枡鏉$爜
     }
 
- 
+
 
     public class SplitPackageReq
     {
@@ -198,7 +198,7 @@
         public decimal SplitQty { get; set; } // 鏂版潯鐮佸垎閰嶆暟閲�
     }
 
- 
+
 
     public class StockReturnReq
     {
@@ -206,14 +206,14 @@
         public string TaskNum { get; set; } = string.Empty; // 浠诲姟鍙凤紙鍙�夛級
     }
 
- 
+
 
     public class OutStockLockDetailReq
     {
         public long OutStockLockId { get; set; } // 鍑哄簱璇︽儏ID
     }
 
- 
+
 
     public class MaterielBarcodeValidateResp
     {
@@ -222,7 +222,7 @@
         public decimal PackageQty { get; set; } // 鏁村寘鏁伴噺锛堝垎閰嶆暟閲忥級
         public string Message { get; set; } = string.Empty;
     }
- 
+
 
     public class OutStockLockDetailResp
     {
@@ -230,7 +230,7 @@
         public decimal AssignQuantity { get; set; }
     }
 
- 
+
 
     public class OutStockLockListResp
     {
@@ -244,7 +244,7 @@
         public bool IsSplitted { get; set; }
     }
 
- 
+
 
     public class PickedRecordListResp
     {
@@ -278,9 +278,21 @@
     // 鎷嗗寘缁撴灉绫�
     public class SplitResult
     {
-        public string OriginalBarcode { get; set; }
-        public string NewBarcode { get; set; }
-        public decimal SplitQuantity { get; set; }
-        public decimal RemainQuantity { get; set; }
+        public string materialCode { get; set; }
+        public string supplierCode { get; set; }
+
+        public string quantityTotal { get; set; }
+
+        public string batchNumber { get; set; }
+
+        public string  batch { get; set; }
+        public string factory { get; set; }
+
+        public string date { get; set; }
+
+       // public string OriginalBarcode { get; set; }
+       // public string NewBarcode { get; set; }
+        //public decimal SplitQuantity { get; set; }
+        //public decimal RemainQuantity { 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_IBasicService/IMaterielToMesService.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_IBasicService/IMaterielToMesService.cs"
index d5aff9e..bc1e9f4 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_IBasicService/IMaterielToMesService.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_IBasicService/IMaterielToMesService.cs"
@@ -3,6 +3,7 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Model.Models;
@@ -13,5 +14,7 @@
     public interface IMaterielToMesService : IService<Dt_MaterielToMes>
     {
         IRepository<Dt_MaterielToMes> Repository { get; }
+
+        Task<WebResponseContent> AddMaterielToMes(Dt_MaterielToMes saveModel, int operationtype);
     }
 }
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/IOutStockLockInfoService.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/IOutStockLockInfoService.cs"
index 2aa1ffd..a97e67f 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/IOutStockLockInfoService.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/IOutStockLockInfoService.cs"
@@ -27,6 +27,8 @@
 
         Task<LockInfoDetailDto> GetLockInfoDetail(int lockInfoId);
         Dt_OutStockLockInfo GetOutStockLockInfo(Dt_OutboundOrder outboundOrder,Dt_OutboundOrderDetail outboundOrderDetail,Dt_StockInfo outStock, decimal assignQuantity, string barcode = null);
+
+        List<Dt_OutStockLockInfo> GetOutStockLockInfos(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, List<Dt_StockInfo> outStocks, int? taskNum = null);
         Task<List<Dt_OutStockLockInfo>> GetPalletLockInfos(string palletCode);
         Task<WebResponseContent> UpdateLockInfoBarcode(int lockInfoId, string newBarcode);
     }
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/IOutboundOrderDetailService.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/IOutboundOrderDetailService.cs"
index 6ff92b0..3525497 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/IOutboundOrderDetailService.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/IOutboundOrderDetailService.cs"
@@ -21,7 +21,7 @@
         public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails);
 
         WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null);
-
+        (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews);
         //List<Dt_OutboundOrderDetail> GetOutboundStockDataById(int 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_IStockService/IStockInfoService.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_IStockService/IStockInfoService.cs"
index 0af78c6..34899a9 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_IStockService/IStockInfoService.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_IStockService/IStockInfoService.cs"
@@ -9,7 +9,7 @@
     {
         IRepository<Dt_StockInfo> Repository { get; }
         Dt_StockInfo? GetStockByPalletCode(string palletCode);
-
+        List<Dt_StockInfo> GetStockInfosByPalletCodes(List<string> palletCodes);
         List<Dt_StockInfo> GetStockInfos(string materielCode, string lotNo, string supplyCode, List<string> locationCodes);
 
         List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo,string supplyCode);
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_ITaskInfoService/ITaskService.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_ITaskInfoService/ITaskService.cs"
index 1d84bf7..43c9e48 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_ITaskInfoService/ITaskService.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_ITaskInfoService/ITaskService.cs"
@@ -45,6 +45,9 @@
         Task<WebResponseContent> TaskCompleted(string taskNum);
 
         Task<WebResponseContent> GenerateOutboundTasksAsync(int[] keys, string outStation);
- 
+
+        WebResponseContent GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews);
+
+
     }
 }
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/Basic/Dt_MaterielToMes.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/Basic/Dt_MaterielToMes.cs"
index 1bc54da..3ea82c3 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/Basic/Dt_MaterielToMes.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/Basic/Dt_MaterielToMes.cs"
@@ -87,7 +87,7 @@
         public string MaterielCode { get; set; } = null!;
 
          
-
+        public int ReturnToMESStatus { 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_OutboundService/OutStockLockInfoService.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/OutStockLockInfoService.cs"
index 0e84c80..b259d4d 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/OutStockLockInfoService.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/OutStockLockInfoService.cs"
@@ -111,6 +111,38 @@
                 IsSplitted = 0
             };
         }
+
+
+        public List<Dt_OutStockLockInfo> GetOutStockLockInfos(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, List<Dt_StockInfo> outStocks, int? taskNum = null)
+        {
+            List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
+
+            foreach (var item in outStocks)
+            {
+                Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo()
+                {
+                    PalletCode = item.PalletCode,
+                    AssignQuantity = item.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).Sum(x => x.OutboundQuantity),
+                    MaterielCode = outboundOrderDetail.MaterielCode,
+                    BatchNo = outboundOrderDetail.BatchNo,
+                    LocationCode = item.LocationCode,
+                    MaterielName = outboundOrderDetail.MaterielName,
+                    OrderDetailId = outboundOrderDetail.Id,
+                    OrderNo = outboundOrder.OrderNo,
+                    OrderType = outboundOrder.OrderType,
+                    OriginalQuantity = item.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).Sum(x => x.StockQuantity),
+                    Status = taskNum == null ? OutLockStockStatusEnum.宸插垎閰�.ObjToInt() : OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt(),
+                    StockId = item.Id,
+                    TaskNum = taskNum,
+                  
+
+                };
+                outStockLockInfos.Add(outStockLockInfo);
+            }
+
+            return outStockLockInfos;
+        }
+
         /// <summary>
         /// 鏍规嵁璁㈠崟鏄庣粏ID鑾峰彇鍑哄簱閿佸畾淇℃伅
         /// </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_OutboundService/OutboundOrderDetailService.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/OutboundOrderDetailService.cs"
index 3fa61d7..954e8fc 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/OutboundOrderDetailService.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/OutboundOrderDetailService.cs"
@@ -1,6 +1,7 @@
 锘縰sing Microsoft.Extensions.Logging;
 using SqlSugar;
 using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.OrderEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
@@ -22,6 +23,7 @@
 
    
         private readonly IStockService _stockService;
+     
         private readonly IOutStockLockInfoService _outStockLockInfoService;
         private readonly ILocationInfoService _locationInfoService;
         private readonly IBasicService _basicService;
@@ -40,6 +42,7 @@
             _locationStatusChangeRecordService = locationStatusChangeRecordService;
             _outboundOrderService = outboundOrderService;
             _logger = logger;
+
         }
 
 
@@ -153,7 +156,7 @@
                     if (remainingAllocate <= 0) break;
 
                     // 璁$畻杩欎釜鏄庣粏杩橀渶瑕佸垎閰嶇殑鏁伴噺
-                    var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
+                    var detailNeed = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity-detail.MoveQty;
                     if (detailNeed <= 0) continue;
 
                     // 鍒嗛厤鏁伴噺
@@ -289,5 +292,72 @@
             return new PageGridData<Dt_OutboundOrderDetail> ();
         }
 
+
+        public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
+        {
+            (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews);
+            if (!checkResult.Item1) throw new Exception(checkResult.Item2);
+
+            Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
+            var originalNeedQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity;
+
+            var needQuantity = originalNeedQuantity;
+
+            List<Dt_StockInfo> outStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList());
+            var assignQuantity =0m;
+            outStocks.ForEach(x =>
+            {
+                x.Details.ForEach(v =>
+                {
+                    assignQuantity += v.StockQuantity - v.OutboundQuantity;
+                });
+            });
+
+            outboundOrderDetail.LockQuantity += assignQuantity;
+            outStocks.ForEach(x =>
+            {
+                x.Details.ForEach(v =>
+                {
+                    v.OutboundQuantity = v.StockQuantity;
+                });
+            });
+            needQuantity -= assignQuantity;
+            if (outboundOrderDetail.OrderQuantity > outboundOrderDetail.LockQuantity)
+            {
+                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo,"");
+                stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList();
+                var (autoAssignStocks, stockAllocations)   = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity);
+                outboundOrderDetail.LockQuantity += needQuantity - residueQuantity;
+                outStocks.AddRange(autoAssignStocks);
+                outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
+                if (residueQuantity > 0)
+                {
+                    outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.AssignOverPartial.ObjToInt();
+                }
+            }
+
+            List<Dt_OutStockLockInfo> outStockLockInfos = _outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetail, outStocks);
+
+            List<Dt_LocationInfo> locationInfos = _locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList());
+
+            return (outStocks, outboundOrderDetail, outStockLockInfos, locationInfos);
+        }
+        private (bool, string) CheckSelectStockDeital(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
+        {
+            if (outboundOrderDetail == null)
+            {
+                return (false, "鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+            }
+            if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt() && outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt())
+            {
+                return (false, "璇ユ槑缁嗕笉鍙搷浣�");
+            }
+            if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity)
+            {
+                return (false, "閫夋嫨鏁伴噺瓒呭嚭鍗曟嵁鏁伴噺");
+            }
+            return (true, "鎴愬姛");
+        }
+
     }
 }
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/OutboundPickingService.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/OutboundPickingService.cs"
index 6d672b9..3c03457 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/OutboundPickingService.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/OutboundPickingService.cs"
@@ -1,6 +1,7 @@
 锘縰sing Dm.filter;
 using MailKit.Search;
 using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Logging;
 using SqlSugar;
 using System;
@@ -230,8 +231,16 @@
                                }).ToList();
                             feedmodel.details = groupedData;
 
-                            _invokeMESService.FeedbackOutbound(feedmodel);
+                            var result = await _invokeMESService.FeedbackOutbound(feedmodel);
+                            if (result != null && result.code == 200)
+                            {
+                                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>().SetColumns(x => x.ReturnToMESStatus == 1) // 宸插畬鎴�
+                                            .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
+                                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>() .SetColumns(x => x.ReturnToMESStatus == 1) // 宸插畬鎴�
+                                              .Where(x => x.OrderNo == orderNo) .ExecuteCommandAsync();
+                            }
                         }
+
                     }
                 }
                 catch (Exception ex)
@@ -244,6 +253,32 @@
 
         public async Task<WebResponseContent> ConfirmPicking(string orderNo, string palletCode, string barcode)
         {
+            #region "娴嬭瘯鎵撳嵃"
+            // var splitResults=new List<SplitResult>();
+            //  splitResults.Add(new SplitResult
+            //{
+            //    materialCode = "AAAAbbb",
+            //    supplierCode = "CVBG",
+            //    quantityTotal = "1234",
+            //    batchNumber = "WMLOT25111900032",
+            //    batch = "A234re",
+            //    factory = "01",
+            //    date = DateTime.Now.ToString("yyyy-MM-dd"),
+            //});
+
+            //splitResults.Add(new SplitResult
+            //{
+            //    materialCode = "CCDF",
+            //    supplierCode = "QWCVBG",
+            //    quantityTotal = "1234",
+            //    batchNumber = "WMLOT25111900032",
+            //    batch = "A234re",
+            //    factory = "01",
+            //    date = DateTime.Now.ToString("yyyy-MM-dd"),
+            //});
+
+            // return WebResponseContent.Instance.OK("鎷i�夌‘璁ゆ垚鍔燂紝宸茶嚜鍔ㄦ媶鍖�", new { SplitResults = splitResults });
+            #endregion
             try
             {
                 _unitOfWorkManage.BeginTran();
@@ -287,6 +322,9 @@
                 decimal stockQuantity = stockDetail.StockQuantity;
 
                 List<SplitResult> splitResults = new List<SplitResult>();
+                Dt_OutStockLockInfo finalLockInfo = lockInfo;
+                var finalBarcode = barcode;
+                var finalStockId = stockDetail.Id;
 
                 if (actualQty < stockQuantity)
                 {
@@ -328,7 +366,9 @@
                         IsSplitted = 1,
                         ParentLockId = lockInfo.Id
                     };
-                    await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
+                    // 鎻掑叆鏂伴攣瀹氫俊鎭苟鑾峰彇ID
+                    var newLockId = await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteReturnIdentityAsync();
+                    newLockInfo.Id = newLockId; // 纭繚ID琚纭缃�
 
                     // 璁板綍鎷嗗寘鍘嗗彶锛堢敤浜庤拷韪級
                     var splitHistory = new Dt_SplitPackageRecord
@@ -353,21 +393,37 @@
 
                     // 鏇存柊鍘熼攣瀹氫俊鎭负鍓╀綑搴撳瓨鏁伴噺
                     lockInfo.AssignQuantity = remainingStockQty;
-                    lockInfo.PickedQty = 0;  
-                                       
+                    lockInfo.PickedQty = 0;
+
                     await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
 
                     splitResults.Add(new SplitResult
                     {
-                        OriginalBarcode = barcode,
-                        NewBarcode = newBarcode,
-                        SplitQuantity = actualQty,
-                        RemainQuantity = remainingStockQty
-                    });
+                        materialCode = lockInfo.MaterielCode,
+                        supplierCode = lockInfo.SupplyCode,
+                        quantityTotal = actualQty.ToString("F2"),
+                        batchNumber = newBarcode,
+                        batch = lockInfo.BatchNo,
+                        factory = lockInfo.FactoryArea,
+                        date = DateTime.Now.ToString("yyyy-MM-dd"),
 
+                    });
+                    splitResults.Add(new SplitResult
+                    {
+                        materialCode = lockInfo.MaterielCode,
+                        supplierCode = lockInfo.SupplyCode,
+                        quantityTotal = remainingStockQty.ToString("F2"),
+                        batchNumber = barcode,
+                        batch = lockInfo.BatchNo,
+                        factory = lockInfo.FactoryArea,
+                        date = DateTime.Now.ToString("yyyy-MM-dd"),
+                    });
                     // 鏇存柊鎷i�夎褰曚腑鐨勬潯鐮佷负鏂版潯鐮�
                     barcode = newBarcode;
                     lockInfo = newLockInfo;
+                    finalLockInfo = newLockInfo;
+                    finalBarcode = newBarcode;
+                    finalStockId = stockDetail.Id; // 浣跨敤鍘熷簱瀛業D
                 }
                 else if (actualQty == stockQuantity)
                 {
@@ -379,6 +435,9 @@
                     lockInfo.PickedQty += actualQty;
                     lockInfo.Status = (int)OutLockStockStatusEnum.鎷i�夊畬鎴�;
                     await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
+                    finalLockInfo = lockInfo;
+                    finalBarcode = barcode;
+                    finalStockId = stockDetail.Id;
                 }
                 else
                 {
@@ -399,18 +458,21 @@
                     await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
 
                     var _relatedSplitRecords = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
-        .Where(it => it.OriginalBarcode == barcode || it.NewBarcode == barcode)
-        .Where(it => !it.IsReverted)
-        .ToListAsync();
+                                                .Where(it => it.OriginalBarcode == barcode || it.NewBarcode == barcode)
+                                                .Where(it => !it.IsReverted)
+                                                .ToListAsync();
 
                     foreach (var record in _relatedSplitRecords)
                     {
                         record.Status = (int)SplitPackageStatusEnum.宸叉嫞閫�;
                         await _splitPackageService.Db.Updateable(record).ExecuteCommandAsync();
                     }
+                    finalLockInfo = lockInfo;
+                    finalBarcode = barcode;
+                    finalStockId = stockDetail.Id;
                 }
 
-   
+
 
                 await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                     .SetColumns(it => it.PickedQty == it.PickedQty + actualQty)
@@ -421,23 +483,26 @@
 
                 // 鏌ヨ浠诲姟琛� 
                 var task = _taskRepository.QueryData(x => x.OrderNo == orderNo && x.PalletCode == palletCode).FirstOrDefault();
-
+                if (finalLockInfo.Id <= 0)
+                {
+                    throw new Exception($"閿佸畾淇℃伅ID鏃犳晥: {finalLockInfo.Id}锛屾棤娉曡褰曟嫞閫夊巻鍙�");
+                }
                 // 璁板綍鎷i�夊巻鍙�
                 var pickingHistory = new Dt_PickingRecord
                 {
-                    FactoryArea = lockInfo.FactoryArea,
+                    FactoryArea = finalLockInfo.FactoryArea,
                     TaskNo = task?.TaskNum ?? 0,
                     LocationCode = task?.SourceAddress ?? "",
-                    StockId = stockDetail.Id,
+                    StockId = finalStockId,
                     OrderNo = orderNo,
-                    OrderDetailId = lockInfo.OrderDetailId,
+                    OrderDetailId = finalLockInfo.OrderDetailId,
                     PalletCode = palletCode,
-                    Barcode = barcode,
-                    MaterielCode = lockInfo.MaterielCode,
+                    Barcode = finalBarcode,
+                    MaterielCode = finalLockInfo.MaterielCode,
                     PickQuantity = actualQty,
                     PickTime = DateTime.Now,
                     Operator = App.User.UserName,
-                    OutStockLockId = lockInfo.Id
+                    OutStockLockId = finalLockInfo.Id
                 };
                 await Db.Insertable(pickingHistory).ExecuteCommandAsync();
 
@@ -449,7 +514,7 @@
                     return WebResponseContent.Instance.OK("鎷i�夌‘璁ゆ垚鍔燂紝宸茶嚜鍔ㄦ媶鍖�", new { SplitResults = splitResults });
                 }
 
-                return WebResponseContent.Instance.OK("鎷i�夌‘璁ゆ垚鍔�");
+                return WebResponseContent.Instance.OK("鎷i�夌‘璁ゆ垚鍔�", new { SplitResults = splitResults });
 
             }
             catch (Exception ex)
@@ -458,7 +523,7 @@
                 return WebResponseContent.Instance.Error($"鎷i�夌‘璁ゅけ璐ワ細{ex.Message}");
             }
         }
-        
+
         /// <summary>
         /// 鍥炲簱鎿嶄綔  
         /// </summary>
@@ -566,7 +631,7 @@
                             .Where(it => lockIds.Contains(it.Id))
                             .ExecuteCommandAsync();
 
-           
+
 
                         // 澶勭悊搴撳瓨璁板綍
                         foreach (var lockInfo in palletLocks)
@@ -664,9 +729,9 @@
                         CreateReturnTask(tasks, task, palletCode, newLocation);
                     }
 
-                 
+
                 }
-            
+
                 var allSplitRecords = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
                     .Where(it => it.OrderNo == orderNo && it.PalletCode == palletCode && !it.IsReverted)
                     .ToListAsync();
@@ -1082,7 +1147,7 @@
         private async Task RecordCancelHistory(string orderNo, string palletCode, string barcode,
             decimal cancelQty, int pickingRecordId, string materielCode, string reason)
         {
-           
+
             //var cancelHistory = new Dt_PickingCancelRecord
             //{
             //    OrderNo = 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_OutboundService/SplitPackageService.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/SplitPackageService.cs"
index 34b8f2b..62ef0f2 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/SplitPackageService.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/SplitPackageService.cs"
@@ -17,6 +17,7 @@
 using WIDESEA_IOutboundService;
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Basic;
 
 namespace WIDESEA_OutboundService
 {
@@ -30,9 +31,9 @@
         private readonly IOutStockLockInfoService _outStockLockInfoService;
         private readonly IDailySequenceService _dailySequenceService;
         private readonly IInvokeMESService _invokeMESService;
-
+        private readonly IMaterielToMesService _materielToMesService;
         private readonly ILogger<SplitPackageService> _logger;
-        public SplitPackageService(IRepository<Dt_SplitPackageRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, IDailySequenceService dailySequenceService, IInvokeMESService invokeMESService, ILogger<SplitPackageService> logger) : base(BaseDal)
+        public SplitPackageService(IRepository<Dt_SplitPackageRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, IDailySequenceService dailySequenceService, IInvokeMESService invokeMESService, ILogger<SplitPackageService> logger, IMaterielToMesService materielToMesService) : base(BaseDal)
         {
             _unitOfWorkManage = unitOfWorkManage;
             _stockInfoService = stockInfoService;
@@ -41,172 +42,8 @@
             _dailySequenceService = dailySequenceService;
             _invokeMESService = invokeMESService;
             _logger = logger;
+            _materielToMesService = materielToMesService;
         }
-
-        /// <summary>
-        /// 鎷嗗寘鎷嗙鎿嶄綔
-        /// </summary>
-        //public async Task<WebResponseContent> SplitPackage(SplitPackageDto request)
-        //{
-        //    try
-        //    {
-        //        _unitOfWorkManage.BeginTran();
-
-        //        // 1. 楠岃瘉鍑哄簱閿佸畾淇℃伅
-        //        var lockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
-        //                  .Where(x => x.OrderNo == request.OrderNo &&
-        //                   x.PalletCode == request.PalletCode &&
-        //                   x.CurrentBarcode == request.OriginalBarcode &&
-        //                   x.Status == 1)
-        //            .FirstAsync();
-
-        //        if (lockInfo == null)
-        //            return WebResponseContent.Instance.Error("鏈壘鍒版湁鏁堢殑鍑哄簱閿佸畾淇℃伅");
-
-        //        // 2. 妫�鏌ュ墿浣欓攣瀹氭暟閲�
-        //        decimal remainingLockQuantity = lockInfo.OriginalQuantity - lockInfo.PickedQty;
-        //        if (request.SplitQuantity > remainingLockQuantity)
-        //            return WebResponseContent.Instance.Error($"鎷嗗寘鏁伴噺涓嶈兘澶т簬鍓╀綑閿佸畾鏁伴噺锛屽墿浣欙細{remainingLockQuantity}");
-
-        //        var baseStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
-        //       .Where(x => x.Barcode == request.OriginalBarcode && x.StockId == lockInfo.StockId)
-        //       .FirstAsync();
-        //        if (baseStockDetail == null)
-        //            throw new Exception($"鏈壘鍒版潯鐮亄request.OriginalBarcode}瀵瑰簲鐨勫簱瀛樿褰�");
-
-
-        //        // 4. 璁$畻鎷嗗垎鍚庣殑鏁伴噺
-        //        decimal remainingQty = baseStockDetail.StockQuantity - request.SplitQuantity;
-
-        //        // 鏇存柊鍩虹鏉$爜鐨勫簱瀛樻暟閲忎负鍓╀綑鏁伴噺
-        //        baseStockDetail.StockQuantity = remainingQty;
-        //        baseStockDetail.OutboundQuantity = remainingQty;
-        //        await _stockInfoDetailService.Db.Updateable(baseStockDetail).ExecuteCommandAsync();
-
-
-        //        var seq = await _dailySequenceService.GetNextSequenceAsync();
-        //        // 3. 鐢熸垚鏂版潯鐮�
-        //        string newBarcode = "WSLOT" + DateTime.Now.ToString("yyyyMMdd") + seq.ToString()?.PadLeft(5, '0');
-
-
-        //        // 涓烘媶鍖呬骇鐢熺殑鏂版潯鐮佸垱寤哄簱瀛樿褰�
-        //        var newStockDetail = new Dt_StockInfoDetail
-        //        {
-        //            SupplyCode = baseStockDetail.SupplyCode,
-        //            WarehouseCode = baseStockDetail.WarehouseCode,
-        //            BarcodeQty = baseStockDetail.BarcodeQty,
-        //            BarcodeUnit = baseStockDetail.BarcodeUnit,
-        //            BusinessType = baseStockDetail.BusinessType,
-        //            Unit = baseStockDetail.Unit,
-        //            StockId = lockInfo.StockId,
-        //            MaterielCode = baseStockDetail.MaterielCode,
-        //            OrderNo = baseStockDetail.OrderNo,
-        //            BatchNo = baseStockDetail.BatchNo,
-        //            StockQuantity = request.SplitQuantity, // 鏂版潯鐮佽幏寰楁媶鍒嗘暟閲�
-        //            OutboundQuantity = request.SplitQuantity,
-        //            Barcode = newBarcode,
-        //            InboundOrderRowNo = baseStockDetail.InboundOrderRowNo,
-
-        //        };
-        //        await _outStockLockInfoService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
-
-        //        // 4. 鍒涘缓鏂扮殑鍑哄簱閿佸畾淇℃伅锛堟柊鏉$爜锛�
-        //        var newLockInfo = new Dt_OutStockLockInfo
-        //        {
-
-        //            OrderNo = lockInfo.OrderNo,
-        //            OrderDetailId = lockInfo.OrderDetailId,
-        //            BatchNo = lockInfo.BatchNo,
-        //            MaterielCode = lockInfo.MaterielCode,
-        //            MaterielName = lockInfo.MaterielName,
-        //            StockId = lockInfo.StockId,
-        //            OrderQuantity = request.SplitQuantity,
-        //            OriginalQuantity = request.SplitQuantity,
-        //            AssignQuantity = request.SplitQuantity, // 鏂版潯鐮佸垎閰嶆暟閲�
-        //            PickedQty = 0, // 鏂版潯鐮佹湭鎷i��
-        //            LocationCode = lockInfo.LocationCode,
-        //            PalletCode = lockInfo.PalletCode,
-        //            TaskNum = lockInfo.TaskNum,
-        //            Status = (int)OutLockStockStatusEnum.鍑哄簱涓�,
-        //            Unit = lockInfo.Unit,
-        //            SupplyCode = lockInfo.SupplyCode,
-        //            OrderType = lockInfo.OrderType,
-        //            CurrentBarcode = newBarcode, // 鏂版潯鐮�
-        //            OriginalLockQuantity = request.SplitQuantity,
-        //            IsSplitted = 1,
-        //            ParentLockId = lockInfo.Id // 璁板綍鐖剁骇閿佸畾ID
-        //        };
-        //        await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
-
-        //        lockInfo.AssignQuantity = remainingQty;
-        //        lockInfo.IsSplitted = 1; // 鏍囪涓哄凡鎷嗗寘
-        //        await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
-
-        //        var previousSplitRecord = await Db.Queryable<Dt_SplitPackageRecord>()
-        //      .Where(x => x.OriginalBarcode == request.OriginalBarcode && !x.IsReverted)
-        //      .OrderByDescending(x => x.SplitTime)
-        //      .FirstAsync();
-
-        //        // 6. 璁板綍鎷嗗寘鍘嗗彶锛堢敤浜庤拷韪級
-        //        var splitHistory = new Dt_SplitPackageRecord
-        //        {
-        //            FactoryArea = lockInfo.FactoryArea,
-        //            TaskNum = lockInfo.TaskNum,
-        //            OutStockLockInfoId = lockInfo.Id,
-        //            StockId = baseStockDetail.StockId,
-        //            Operator = App.User.UserName,
-        //            IsReverted = false,
-        //            OriginalBarcode = request.OriginalBarcode,
-        //            NewBarcode = newBarcode,
-        //            SplitQty = request.SplitQuantity,
-        //            RemainQuantity = remainingQty, // 璁板綍鎷嗗垎鍚庣殑鍓╀綑鏁伴噺
-        //            MaterielCode = lockInfo.MaterielCode,
-        //            SplitTime = DateTime.Now,
-        //            OrderNo = request.OrderNo,
-        //            PalletCode = request.PalletCode,
-        //            Status = (int)SplitPackageStatusEnum.宸叉媶鍖�,
-        //            PreviousSplitRecordId = previousSplitRecord?.Id??0 // 璁板綍鍓嶄竴娆℃媶鍖匢D锛屽缓绔嬫媶鍖呴摼
-        //        };
-        //        await Db.Insertable(splitHistory).ExecuteCommandAsync();
-
-        //        _unitOfWorkManage.CommitTran();
-
-        //        try
-        //        {
-        //            MaterielToMesDTO dto = new MaterielToMesDTO
-        //            {
-        //                batchNo = baseStockDetail.BatchNo,
-        //                factoryArea = baseStockDetail.FactoryArea,
-        //                materialCode = baseStockDetail.MaterielCode,
-        //                newmaterialCode = newBarcode,
-        //                oldmaterialCode = request.OriginalBarcode,
-        //                operationType = 1,
-        //                qty = remainingQty,
-        //                supplyCode = baseStockDetail.SupplyCode,
-        //                unit = baseStockDetail.BarcodeUnit,
-        //                warehouseCode = baseStockDetail.WarehouseCode,
-        //                reqCode = Guid.NewGuid().ToString(),
-        //                reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
-        //            };
-        //            _invokeMESService.NewMaterielToMes(dto);
-        //        }
-        //        catch(Exception ex)
-        //        {
-        //            _logger.LogError("SplitPackage 鍥炰紶MES:  " + ex.Message);
-        //        }
-        //        return WebResponseContent.Instance.OK("鎷嗗寘鎴愬姛", new
-        //        {
-        //            NewBarcode = newBarcode,
-        //            NewLockInfoId = newLockInfo.Id
-        //        });
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        _unitOfWorkManage.RollbackTran();
-        //        return WebResponseContent.Instance.Error($"鎷嗗寘澶辫触: {ex.Message}");
-        //    }
-        //}
-        // 鑾峰彇鏉$爜鐨勬媶鍖呭巻鍙查摼
 
         public async Task<WebResponseContent> SplitPackage(SplitPackageDto request)
         {
@@ -331,6 +168,30 @@
 
                 _unitOfWorkManage.CommitTran();
 
+                try
+                {
+                   
+                    var dt_MaterielToMes = new Dt_MaterielToMes
+                    {
+                        OldMaterialBarCode = request.OriginalBarcode,
+                        NewMaterialBarCode = newBarcode,
+                        Unit = baseStockDetail.BarcodeUnit,
+                        factoryArea = baseStockDetail.FactoryArea,
+                        Qty = remainingQty,
+                        supplyCode = baseStockDetail.SupplyCode,
+                        warehouseCode = baseStockDetail.WarehouseCode,
+                        BatchNo = baseStockDetail.BatchNo,
+                        MaterielCode = baseStockDetail.MaterielCode,
+
+                    };
+                    _materielToMesService.AddData(dt_MaterielToMes);    
+              
+                }
+                catch (Exception ex)
+                {
+                    _logger.LogError("SplitPackage 鍥炰紶MES:  " + ex.Message);
+                }
+
                 return WebResponseContent.Instance.OK("鎷嗗寘鎴愬姛", new SplitPackageChainDto
                 {
                     NewBarcode = newBarcode,
@@ -418,7 +279,7 @@
                 {
                     record.IsReverted = true;
                     record.RevertTime = DateTime.Now;
-         
+
                     record.Status = (int)SplitPackageStatusEnum.宸叉挙閿�;
                 }
                 await Db.Updateable(splitRecords).ExecuteCommandAsync();
@@ -526,14 +387,14 @@
         // 鑾峰彇鍙挙閿�鐨勬媶鍖呰褰曞垪琛�
         public Dt_SplitPackageRecord GetRevertableSplitRecords(string originalBarcode)
         {
-            var revertableRecords =   Db.Queryable<Dt_SplitPackageRecord>()
+            var revertableRecords = Db.Queryable<Dt_SplitPackageRecord>()
                     .Where(x => x.OriginalBarcode == originalBarcode && !x.IsReverted)
                     .OrderBy(x => x.SplitTime)
                    .First();
 
-            return   revertableRecords ;
+            return revertableRecords;
         }
- 
+
         // 鑾峰彇鎷嗗寘淇℃伅
         public async Task<WebResponseContent> GetSplitPackageInfo(string orderNo, string palletCode, string barcode)
         {
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 f5ce2dd..5ff38f2 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"
@@ -225,6 +225,12 @@
             return Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() && SqlFunc.Subqueryable<Dt_LocationInfo>().Where(v => v.LocationCode == x.LocationCode && v.LocationType == locationType && v.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (v.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || EnableStatusEnum.Normal.ObjToInt() == v.EnableStatus)).Any()).OrderBy(x => x.ModifyDate).First();
         }
 
+        public List<Dt_StockInfo> GetStockInfosByPalletCodes(List<string> palletCodes)
+        {
+            return Db.Queryable<Dt_StockInfo>().Where(x => palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).ToList();
+        }
+
+ 
         /// <summary>
         /// 
         /// </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_TaskInfoService/TaskService_Outbound.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_TaskInfoService/TaskService_Outbound.cs"
index 58c97a7..1e7699c 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_TaskInfoService/TaskService_Outbound.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_TaskInfoService/TaskService_Outbound.cs"
@@ -335,6 +335,51 @@
             return tasks;
         }
 
+        public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType)
+        {
+            List<Dt_Task> tasks = new List<Dt_Task>();
+            List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.QueryData(x => stockInfos.Select(x => x.LocationCode).Contains(x.LocationCode));
+            for (int i = 0; i < stockInfos.Count; i++)
+            {
+                Dt_StockInfo stockInfo = stockInfos[i];
+
+                if (stockInfo != null)
+                {
+                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode);
+                    if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode))
+                    {
+                        Dt_Task task = new()
+                        {
+                            CurrentAddress = stockInfo.LocationCode,
+                            Grade = 0,
+                            PalletCode = stockInfo.PalletCode,
+                            NextAddress = "",
+                            Roadway = locationInfo.RoadwayNo,
+                            SourceAddress = stockInfo.LocationCode,
+                            TargetAddress = "",
+                            TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                            TaskType = taskType.ObjToInt(),
+                            //TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                            PalletType = stockInfo.PalletType,
+                            WarehouseId = stockInfo.WarehouseId,
+
+                        };
+                        //if (taskType != TaskTypeEnum.OutEmpty)
+                        //{
+                        //    task.MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                        //    task.Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                        //    task.BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
+                        //}
+                        //if (stockInfo.StockLength > 0)
+                        //{
+                        //    task.TaskLength = stockInfo.StockLength;
+                        //}
+                        tasks.Add(task);
+                    }
+                }
+            }
+            return tasks;
+        }
 
         /// <summary>
         /// 鐢熸垚鍑哄簱浠诲姟
@@ -385,5 +430,159 @@
         }
 
 
+        /// <summary>
+        /// 鐢熸垚鍑哄簱浠诲姟
+        /// </summary>
+        /// <param name="orderDetailId"></param>
+        /// <param name="stockSelectViews"></param>
+        /// <returns></returns>
+        public WebResponseContent GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews)
+        {
+            try
+            {
+                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(orderDetailId, stockSelectViews);
+
+                WebResponseContent content = GenerateOutboundTaskDataUpdate(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5);
+
+                return content;
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 鍑哄簱浠诲姟鏁版嵁澶勭悊
+        /// </summary>
+        /// <param name="orderDetailId"></param>
+        /// <param name="stockSelectViews"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int orderDetailId, List<StockSelectViewDTO> stockSelectViews)
+        {
+            List<Dt_Task> tasks = new List<Dt_Task>();
+            Dt_OutboundOrderDetail outboundOrderDetail = _outboundOrderDetailService.Repository.QueryFirst(x => x.Id == orderDetailId);
+
+            if (outboundOrderDetail == null)
+            {
+                throw new Exception("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+            }
+
+            if (stockSelectViews.Sum(x => x.UseableQuantity) > outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity)
+            {
+                throw new Exception("閫夋嫨鏁伴噺瓒呭嚭鍗曟嵁鏁伴噺");
+            }
+            List<Dt_StockInfo>? stockInfos = null;
+            Dt_OutboundOrderDetail? orderDetail = null;
+            List<Dt_OutStockLockInfo>? outStockLockInfos = null;
+            List<Dt_LocationInfo>? locationInfos = null;
+            if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+            {
+                (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(outboundOrderDetail, stockSelectViews);
+                if (result.Item1 != null && result.Item1.Count > 0)
+                {
+                    Dt_OutboundOrder outboundOrder = _outboundOrderService .Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
+                    TaskTypeEnum typeEnum = outboundOrder.OrderType switch
+                    {
+                        (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound,
+                        (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate,
+                        (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality,
+                        _ => new TaskTypeEnum()
+                    };
+                    tasks = GetTasks(result.Item1, typeEnum);
+                    result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                    result.Item3.ForEach(x =>
+                    {
+                        x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
+                    });
+
+                    stockInfos = result.Item1;
+                    orderDetail = result.Item2;
+                    outStockLockInfos = result.Item3;
+                    locationInfos = result.Item4;
+                }
+                else
+                {
+                    throw new Exception("鏃犲簱瀛�");
+                }
+            }
+            else
+            {
+                List<Dt_OutStockLockInfo> stockLockInfos = _outStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.宸插垎閰�);
+                if (stockLockInfos != null && stockLockInfos.Count > 0)
+                {
+                    List<Dt_StockInfo> stocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList());
+                    tasks = GetTasks(stocks, TaskTypeEnum.Outbound);
+                }
+            }
+
+            return (tasks, stockInfos, orderDetail == null ? null : new List<Dt_OutboundOrderDetail> { orderDetail }, outStockLockInfos, locationInfos);
+        }
+
+        /// <summary>
+        /// 鐢熸垚鍑哄簱浠诲姟鍚庢暟鎹洿鏂板埌鏁版嵁搴�
+        /// </summary>
+        /// <param name="tasks"></param>
+        /// <param name="stockInfos"></param>
+        /// <param name="outboundOrderDetails"></param>
+        /// <param name="outStockLockInfos"></param>
+        /// <param name="locationInfos"></param>
+        /// <returns></returns>
+        public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null)
+        {
+            try
+            {
+                _unitOfWorkManage.BeginTran();
+
+                BaseDal.AddData(tasks);
+                if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
+                {
+                    stockInfos.ForEach(x =>
+                    {
+                        x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+                    });
+                    outboundOrderDetails.ForEach(x =>
+                    {
+                        x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                    });
+                    Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+                    if (outboundOrder.OrderStatus != OutOrderStatusEnum.鍑哄簱涓�.ObjToInt())
+                    {
+                        _outboundOrderService.Repository.UpdateData(outboundOrder);
+                    }
+                    WebResponseContent content = _outboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks);
+
+                    if (!content.Status)
+                    {
+                        _unitOfWorkManage.RollbackTran();
+                        return content;
+                    }
+                }
+                else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0)
+                {
+                    outboundOrderDetails.ForEach(x =>
+                    {
+                        x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+                    });
+                    Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+                    if (outboundOrder.OrderStatus != OutOrderStatusEnum.鍑哄簱涓�.ObjToInt())
+                    {
+                        _outboundOrderService.Repository.UpdateData(outboundOrder);
+                    }
+                    _outboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
+                }
+                _unitOfWorkManage.CommitTran();
+                //PushTasksToWCS(tasks);
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                return WebResponseContent.Instance.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_WMSServer/Controllers/TaskInfo/TaskController.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/TaskInfo/TaskController.cs"
index 4612fbc..adfa518 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/TaskInfo/TaskController.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/TaskInfo/TaskController.cs"
@@ -47,5 +47,17 @@
             return await Service.GenerateOutboundTasksAsync(data.taskIds,data.outboundPlatform);
         }
 
+        /// <summary>
+        /// 鐢熸垚鍑哄簱浠诲姟
+        /// </summary>
+        /// <param name="orderDetailId"></param>
+        /// <param name="stockSelectViews"></param>
+        /// <returns></returns>
+        [HttpPost, HttpGet, Route("GenerateOutboundTask"), AllowAnonymous]
+        public WebResponseContent GenerateOutboundTask(int orderDetailId, [FromBody] List<StockSelectViewDTO> stockSelectViews)
+        {
+            return Service.GenerateOutboundTask(orderDetailId, stockSelectViews);
+        }
+
     }
 }

--
Gitblit v1.9.3