From f747c5151051c12a1c44eaf5ef49f0a3805702b0 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期日, 09 十一月 2025 10:22:53 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Inbound/PalletSumQuantityDTO.cs                     |   17 ++++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs                   |   53 ++++++++++++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs |    6 +
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue                                 |   47 +++++++++++
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs                 |    2 
 项目代码/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js                                 |   11 +-
 项目代码/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js                                   |   59 +++++++++++++-
 7 files changed, 179 insertions(+), 16 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue"
index 1f42f05..33c3072 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/Pallet.vue"
@@ -126,6 +126,8 @@
             <span><i class="el-icon-tickets"></i> 缁勭洏鏁版嵁</span>
             <span class="list-actions">
               <el-tag type="primary">鍏� {{ materials.length }} 鏉¤褰�</el-tag>
+              <el-tag type="primary">宸茬粍鐩� {{ totalStockCount }}</el-tag>
+              <el-tag type="primary">搴撳瓨鏁伴噺 {{ totalStockSum }}<span>{{ uniqueUnit }}</span></el-tag>
               <el-tag v-if="trayBarcode" type="success">鎵樼洏: {{ trayBarcode }}</el-tag>
     <!--           <el-button 
                 v-if="materials.length > 0"
@@ -197,6 +199,7 @@
 import VolTable from '@/components/basic/VolTable.vue';
 import { ElLoading, ElMessage,ElMessageBox  } from 'element-plus';
 import { ref, onMounted, onUnmounted } from 'vue'
+import InboundOrder from '../../../views/inbound/inboundOrder.vue';
 
 export default {
   name: 'BarcodeScanner',
@@ -225,6 +228,13 @@
           scanTimer: null,
           manualInputTimer: null,
           scanTarget: 'tray', // 褰撳墠鎵爜鐩爣: tray 鎴� material
+
+          // 搴撳瓨缁熻鐩稿叧鍙橀噺
+          totalStockSum: 0,  
+          totalStockCount: 0,
+          uniqueUnit: '',
+          sumLoading: false,
+          sumError: ''
     }
   },
   computed: {
@@ -245,6 +255,7 @@
       this.$nextTick(() => {
         setTimeout(() => {
           this.focusTrayInput();
+          this.fetchStockStatistics(); // 鍔犺浇缁熻鏁版嵁
         }, 300);
       });
     }
@@ -263,6 +274,7 @@
         this.palletForm = { palletCode: '', barcode: '' };
         this.backData = [];
         this.$refs.palletForm?.reset();
+        this.fetchStockStatistics(); // 鍗曟嵁鍙峰彉浜嗭紝鍒锋柊缁熻
       }
     }
   },
@@ -283,6 +295,37 @@
          this.clearAllTimers();
       },
       methods: {
+        // 鏂板锛氭煡璇㈠悗绔簱瀛樼粺璁℃暟鎹紙璋冪敤涔嬪墠鐨� SumQuantity 鎺ュ彛锛�
+    async fetchStockStatistics() {
+      // 鍗曟嵁鍙蜂负绌烘椂涓嶆煡璇�
+      if (!this.docNo) {
+        this.sumError = '鍗曟嵁鍙蜂负绌猴紝鏃犳硶缁熻';
+        return;
+      }
+
+      this.sumLoading = true;
+      this.sumError = '';
+      try {
+        // 璋冪敤鍚庣缁熻鎺ュ彛锛堟浛鎹负浣犵殑瀹為檯鎺ュ彛璺緞锛�
+        const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo='+this.docNo, {
+          
+        });
+
+        // 缁戝畾鏁版嵁锛堝尮閰� PalletSumQuantityDTO 缁撴瀯锛�
+        if (response.data) {
+          this.totalStockSum = response.data.stockSumQuantity || 0; // 鎬诲簱瀛樻暟閲�
+          this.totalStockCount = response.data.stockCount || 0;     // 鎬诲簱瀛樿褰曟暟
+          this.uniqueUnit = response.data.uniqueUnit || '';               // 璁¢噺鍗曚綅
+        }
+      } catch (err) {
+        this.sumError = '缁熻鍔犺浇澶辫触';
+        this.totalStockSum = 0;
+        this.totalStockCount = 0;
+        console.error('搴撳瓨缁熻鏌ヨ寮傚父锛�', err);
+      } finally {
+        this.sumLoading = false;
+      }
+    },
          // 閲嶇疆鎵�鏈夋暟鎹�
     resetData() {
       console.log('閲嶇疆寮规鏁版嵁');
@@ -298,6 +341,10 @@
       this.currentFocus = 'tray';
       this.scanTarget = 'tray';
       this.clearAllTimers();
+      this.totalStockSum = 0;
+      this.totalStockCount = 0;
+      this.sumLoading = false;
+      this.sumError = '';
     },
     
     // 娓呴櫎鎵�鏈夎鏃跺櫒
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js"
index fb1ded8..e28f59c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js"
@@ -40,12 +40,57 @@
 
           const targetRow = selectedRows[0];
      
-   
-
-      
           this.$emit('openPalletDialog', targetRow.inboundOrderNo);
         }
       },
+      {
+  name: '鍒嗘壒鍏ュ簱',
+  type: 'primary',
+  value: '鍒嗘壒鍏ュ簱',
+  onClick: async function () { 
+    console.log('鍒嗘壒鍏ュ簱鎸夐挳琚偣鍑伙紝寮�濮嬫牎楠�');
+    const selectedRows = this.$refs.table.getSelected();
+
+    // 鏍¢獙1锛氭槸鍚﹂�変腑琛岋紙鑷冲皯閫夋嫨涓�鏉★級
+    if (selectedRows.length === 0) {
+      console.log('鏍¢獙涓嶉�氳繃锛氭湭閫変腑浠讳綍鍗曟嵁');
+      ElMessage.warning('璇烽�夋嫨鑷冲皯涓�鏉″崟鎹�');
+      return;
+    }
+
+    // 鏀堕泦鎵�鏈夐�変腑鍗曟嵁鐨勭紪鍙凤紙杩囨护鏃犲崟鎹彿鐨勫紓甯歌锛�
+    const inboundOrderNos = selectedRows
+      .filter(row => row.inboundOrderNo)
+      .map(row => row.inboundOrderNo);
+
+    // 鏍¢獙2锛氭槸鍚︽湁鏈夋晥鍗曟嵁鍙�
+    if (inboundOrderNos.length === 0) {
+      console.log('鏍¢獙涓嶉�氳繃锛氶�変腑鍗曟嵁鏃犳湁鏁堢紪鍙�');
+      ElMessage.warning('閫変腑鐨勫崟鎹腑鏃犳湁鏁堢紪鍙凤紝璇烽噸鏂伴�夋嫨');
+      return;
+    }
+
+    try {
+      console.log('鍙戣捣鍒嗘壒鍏ュ簱璇锋眰锛屽弬鏁帮細', { inboundOrderNos});
+      const response = await http.post('/api/InboundOrder/BatchInbound', {
+        inboundOrderNos: inboundOrderNos, 
+      });
+
+      const { status, message, data } = response;
+      if (status) {
+        console.log('鍒嗘壒鍏ュ簱鎴愬姛锛屽悗绔繑鍥烇細', data);
+        ElMessage.success(`鍒嗘壒鍏ュ簱鎴愬姛锛佸叡澶勭悊${inboundOrderNos.length}鏉″崟鎹甡);
+        this.refresh(); // 鍏ュ簱鎴愬姛鍚庡埛鏂板垪琛紙澶嶇敤鍘熸湁閫昏緫锛�
+      } else {
+        console.log('鍒嗘壒鍏ュ簱澶辫触锛屽悗绔彁绀猴細', message);
+        ElMessage.error(message || data?.message || '鍒嗘壒鍏ュ簱澶辫触');
+      }
+    } catch (error) {
+      console.error('鍒嗘壒鍏ュ簱璇锋眰寮傚父锛�', error);
+      ElMessage.error('缃戠粶寮傚父鎴栨帴鍙i敊璇紝璇风◢鍚庨噸璇�');
+    }
+  }
+},
      {
   name: '绌烘墭鐩樺叆搴�',
   type: 'primary',
@@ -76,16 +121,16 @@
         rules: {
           // 鏂欑鐮佹牎楠岋細浠呬繚鐣欏瓧绗︿覆绫诲瀷锛岀Щ闄ゅ繀濉姹傦紙绌哄�煎彲閫氳繃锛�
           boxCode: [
+            { required: true, message: '璇疯緭鍏ユ枡绠辩爜', trigger: 'blur' },
             { type: 'string', message: '鏂欑鐮佸繀椤讳负瀛楃涓�', trigger: 'blur' }
           ]
         },
         ref: 'batchInForm'
       }, [
         // 鏂欑鐮佽緭鍏ラ」锛堝彲閫夊~锛�
-        h(ElFormItem, { label: '鏂欑鐮�', prop: 'boxCode' }, [
+        h(ElFormItem, { label: '鏂欑鐮�', prop: 'boxCode',required:true }, [
           h(ElInput, {
             type: 'text',
-            placeholder: '鍙�夎緭鍏ユ枡绠辩爜锛屼笉濉垯榛樿鍏ュ簱', // 鎻愮ず鍙┖瑙勫垯
             modelValue: formData.boxCode,
             'onUpdate:modelValue': (val) => {
               formData.boxCode = val;
@@ -113,8 +158,8 @@
               }
 
               // 鍏ュ簱鎺ュ彛鎻愪氦锛氭枡绠辩爜涓虹┖鏃朵紶閫掔┖瀛楃涓诧紝鍚庣闇�鏀寔璇ュ瓧娈靛彲閫�
-              http.post('/api/wmsTask/BatchInboundTask', {
-                boxCode: formData.boxCode // 鍙┖锛氱敤鎴疯緭鍏ユ垨绌哄瓧绗︿覆
+              http.post('/api/InboundOrder/EmptyMaterielGroup', {
+                palletCode: formData.boxCode // 鍙┖锛氱敤鎴疯緭鍏ユ垨绌哄瓧绗︿覆
               }).then(({ data, status, message }) => {
                 if (status) {
                   ElMessage.success(`鍏ュ簱鎴愬姛${formData.boxCode ? '锛屾枡绠辩爜锛�' + formData.boxCode : ''}`);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
index 664b84e..fb04c10 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js"
@@ -50,9 +50,9 @@
   onClick: function () {
     
     // 2. 鐢熸垚3-12绔欏彴閫夐」锛堥粯璁ょ涓�涓负绔欏彴3锛�
-    const platformOptions = Array.from({ length: 10 }, (_, i) => {
-      const num = i + 3;
-      return { label: `绔欏彴${num}`, value: `PLATFORM${num.toString().padStart(3, '0')}` };
+    const platformOptions = Array.from({ length: 1 }, (_, i) => {
+      const num = 1;
+      return { label: `绔欏彴${num}`, value: `1-2` };
     });
 
     const mountNode = document.createElement('div');
@@ -176,9 +176,8 @@
                 return;
               }
 
-              http.post('/api/wmsTask/BatchOutboundTask', {
-                palletCode: formData.palletCode,
-                platform: formData.selectedPlatform
+              http.post('/api/Task/PalletOutboundTask?palletCode='+formData.palletCode+'&endStation='+formData.selectedPlatform, {
+                
               }).then(({ data, status, message }) => {
                 if (status) {
                   ElMessage.success(`鍑哄簱鎴愬姛锛屽垎閰嶇殑鎵樼洏缂栧彿锛�${data.palletCode || formData.palletCode}`);
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/Inbound/PalletSumQuantityDTO.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/Inbound/PalletSumQuantityDTO.cs"
new file mode 100644
index 0000000..9cd59d3
--- /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_DTO/Inbound/PalletSumQuantityDTO.cs"
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WIDESEA_DTO.Inbound
+{
+    public class PalletSumQuantityDTO
+    {
+        public decimal StockSumQuantity { get; set; }
+
+        public int StockCount { get; set; }
+
+        public string UniqueUnit { get; set; }
+    }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs"
index a05f54c..29f53de 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs"
@@ -22,6 +22,6 @@
         WebResponseContent BarcodeMaterielGroup(BarcodeMaterielGroupDTO materielGroupDTO);
         WebResponseContent EmptyMaterielGroup(EmptyBarcodeMaterielGroupDTO materielGroupDTO);
 
-
+        WebResponseContent UnPalletQuantity(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_InboundService/InboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
index 5ecdbe0..96bb475 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
@@ -33,9 +33,11 @@
         private readonly IMaterialUnitService _materialUnitService;
         private readonly IInboundOrderDetailService _inboundOrderDetailService;
         private readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
+        private readonly IRepository<Dt_StockInfoDetail> _stockDetailRepository;
+        private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
         public IRepository<Dt_InboundOrder> Repository => BaseDal;
 
-        public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService) : base(BaseDal)
+        public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService,IRepository<Dt_StockInfoDetail> stockDetailRepository,IRepository<Dt_InboundOrder> inboundOrderRepository) : base(BaseDal)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -44,6 +46,8 @@
             _stockService = stockService;
             _inboundOrderDetailService = inboundOrderDetailService;
             _materialUnitService = materialUnitService;
+            _stockDetailRepository = stockDetailRepository;
+            _inboundOrderRepository = inboundOrderRepository;
         }
 
         public async Task<WebResponseContent> ReceiveInboundOrder(List<Dt_InboundOrder> models, int operateType)
@@ -548,6 +552,51 @@
         }
 
 
-
+        public WebResponseContent UnPalletQuantity(string orderNo)
+        {
+            // 鍒濆鍖栬繑鍥濪TO锛堥粯璁ゅ�奸兘涓�0锛岄伩鍏峮ull锛�
+            var resultDTO = new PalletSumQuantityDTO
+            {
+                StockSumQuantity = 0,
+                StockCount = 0,
+                UniqueUnit=""
+            };
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                if (string.IsNullOrWhiteSpace(orderNo))
+                {
+                  return content.Error("浼犲叆鐨勮鍗曞彿orderNo涓虹┖鎴栫┖鐧�");
+                }
+                var orderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).Where(s => s.InboundOrderNo == orderNo).First();
+                if (orderDetail == null)
+                {
+                   return content.Error("鏈壘鍒板崟鎹�");
+                }
+               var unitGroups = orderDetail.Details.GroupBy(d => d.Unit).ToList();
+                if (unitGroups.Count == 1)
+                {
+                    resultDTO.UniqueUnit = unitGroups.First().Key;
+                }
+                else
+                {
+                    resultDTO.UniqueUnit = "";
+                }
+                var validDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList();
+                resultDTO.StockSumQuantity = orderDetail.Details.Sum(d => d.OrderQuantity);
+                resultDTO.StockCount = orderDetail.Details.Count;
+                if(validDetails.Any())
+                {
+                     resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity);
+                    // 鏄庣粏璁板綍鏁帮細绗﹀悎鏉′欢鐨勬湁鏁堣褰曟潯鏁�
+                    resultDTO.StockCount -= validDetails.Count;
+                }
+                return content.OK("",resultDTO);
+            }
+            catch (Exception ex)
+            {
+              return content.Error("SumQuantity 缁熻搴撳瓨鏁伴噺澶辫触锛岃鍗曞彿锛歿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_WMSServer/Controllers/Inbound/InboundOrderController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs"
index 6b5cd67..7a055e8 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs"
@@ -194,5 +194,11 @@
 
         }
 
+        [HttpPost, Route("UnPalletQuantity"), AllowAnonymous, MethodParamsValidate]
+        public WebResponseContent UnPalletQuantity(string orderNo)
+        {
+            return Service.UnPalletQuantity(orderNo);
+        }
+
     }
 }

--
Gitblit v1.9.3