From 094889f27d4bda5116747a2dcc57724a9d5e90d7 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期二, 09 十二月 2025 13:51:12 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/AllocateStockSelect.vue                      |    4 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs |    4 +
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs        |    4 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs                          |   99 ++++++++++++++++++++++++++++++---
 项目代码/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js                                   |    4 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs                   |   38 +++++++-----
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue                      |    6 +-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs                        |    5 +
 8 files changed, 129 insertions(+), 35 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocateStockSelect.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocateStockSelect.vue"
index 1bf588f..1e1c625 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocateStockSelect.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/AllocateStockSelect.vue"
@@ -209,7 +209,7 @@
         ? "api/Task/GenerateAllocatOutboundTask?orderDetailId="
         : "api/Task/GenerateAllocatOutboundTask?orderDetailId=";
       this.http
-        .post(url + this.row.id, this.selection, "鏁版嵁澶勭悊涓�")
+        .post(url + this.row.id+"&station="+this.outboundForm.selectedPlatform, this.selection, "鏁版嵁澶勭悊涓�")
         .then((x) => {
           if (!x.status) return this.$message.error(x.message);
           this.$message.success("鎿嶄綔鎴愬姛");
@@ -227,7 +227,7 @@
       const url = "api/StockInfo/GetAllocateStockSelect?materielCode=";
       this.http
         .post(
-          url + this.row.materielCode + "&orderId=" + this.row.orderId,
+          url + this.row.materielCode + "&orderId=" + this.row.orderId + "&orderDetailId=" + this.row.id,
           null,
           "鏌ヨ涓�"
         )
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue"
index 67fec1f..0537356 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/allocateOrderDetail.vue"
@@ -287,7 +287,7 @@
       this.getData();
     },
     getData() {
-      var wheres = [{ name: "orderId", value: this.row.id }];
+            var wheres = [{ name: "orderId", value: this.row.id }];
       var param = {
         page: this.paginations.page,
         rows: this.paginations.rows,
@@ -296,7 +296,7 @@
         wheres: JSON.stringify(wheres), // 鏌ヨ鏉′欢锛屾牸寮忎负[{ name: "瀛楁", value: "xx" }]
       };
       this.http
-        .post("api/AllocateOrderDetail/GetPageData", param, "鏌ヨ涓�")
+        .post("api/AllocateOrderDetail/GetDetailPage", param, "鏌ヨ涓�")
         .then((x) => {
           this.tableData = x.rows;
         });
@@ -305,7 +305,7 @@
       if (column.prop == "assignStock") {
         this.$refs.child.open(row);
       } else {
-        //鐐瑰嚮鎵撳紑鍑哄簱璇︽儏
+        //鐐瑰嚮鎵撳紑
         this.$refs.selectedStock.open(row);
       }
     },
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 97ad4e9..65bb4dd 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"
@@ -351,12 +351,12 @@
                 _this.$Message.success('鍒嗘壒鍑哄簱鍥炶皟瀹屾垚');
                 _this.refresh();
               } else {
-                return _this.$Message.error(x.message);
+                return _this.$Message.error( '鍒嗘壒鍑哄簱鍥炶皟澶辫触');
               }
             })
             .catch((error) => {
               // 澧炲姞寮傚父鎹曡幏锛屽鐞嗙綉缁滈敊璇瓑鎯呭喌
-              _this.$Message.error('璇锋眰澶辫触锛�' + (error.message || '鏈煡閿欒'));
+              //_this.$Message.error('璇锋眰澶辫触锛�' + (error.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_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 5a208d0..f01c5ae 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"
@@ -20,8 +20,11 @@
 
         List<StockSelectViewDTO> GetStockSelectViews(int orderId, string materielCode);
 
+        List<StockSelectViewDTO> GetStockSelectViews(int orderId, int orderdetailid, string materielCode);
+
+        List<StockSelectViewDTO> GetAllocateSelectViewDTOs(int orderId, int orderdetailid, string materielCode);
+
         List<StockSelectViewDTO> GetSelectViewDTOs(string orderNo, string materielCode);
 
-        List<StockSelectViewDTO> GetAllocateSelectViewDTOs(int orderId, string materielCode);
     }
 }
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 719bea5..0a00059 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"
@@ -286,21 +286,102 @@
 
         //} 
 
-        public List<StockSelectViewDTO> GetAllocateSelectViewDTOs(int orderId, string materielCode)
+        public List<StockSelectViewDTO> GetAllocateSelectViewDTOs(int orderId, int orderdetailid, string materielCode)
         {
-            var dballocate = _allocateRepository.Db.Queryable<Dt_AllocateOrder>().First(x => x.Id == orderId);
-            if (dballocate == null)
-            {
-                throw new Exception($"鏈壘鍒板崟鎹紪鍙蜂负{dballocate.OrderNo}鐨勫崟淇℃伅");
+            //var dballocate = _allocateRepository.Db.Queryable<Dt_AllocateOrder>().Includes(x=>x.Details).Where(x=>x.Details.Any(o=>o.OrderId==orderId)) .First();
+            //if (dballocate == null)
+            //{
+            //    throw new Exception($"鏈壘鍒板崟鎹紪鍙蜂负{dballocate.OrderNo}鐨勫崟淇℃伅");
 
-            }
+            //}
 
-            var outboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == dballocate.OrderNo).First();
+            var outboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Includes(x=>x.Details) .Where(x => x.Details.Any(o=>o.OrderId==orderId)).First();
             if (outboundOrder == null)
             {
-                throw new Exception($"鏈壘鍒板崟鎹紪鍙蜂负{dballocate.OrderNo}鐨勫嚭搴撳崟淇℃伅");
+                throw new Exception($"鏈壘鍒板崟鎹紪鍙蜂负{outboundOrder.UpperOrderNo}鐨勫嚭搴撳崟淇℃伅");
             }
-            return GetStockSelectViews(outboundOrder.Id, materielCode);
+            return GetStockSelectViews(outboundOrder.Id,orderdetailid, materielCode);
+        }
+
+        public List<StockSelectViewDTO> GetStockSelectViews(int orderId,int orderdetailid, string materielCode)
+        {
+            Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == orderId);
+            if (outboundOrder == null)
+            {
+                throw new Exception($"鏈壘鍒癐D涓簕orderId}鐨勫嚭搴撳崟淇℃伅");
+            }
+
+            // 鑾峰彇鍑哄簱鍗曟槑缁嗭紝鐢ㄤ簬纭畾闇�瑕佺殑鎵规鍜屼緵搴斿晢
+            var orderDetails = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrderDetail>().Where(x =>x.Id==orderdetailid && x.OrderId == orderId && x.MaterielCode == materielCode).ToList();
+
+            if (!orderDetails.Any())
+            {
+                throw new Exception($"鍑哄簱鍗晎orderId}涓湭鎵惧埌鐗╂枡{materielCode}鐨勬槑缁嗕俊鎭�");
+            }
+
+            List<string> locationCodes = _locationInfoService.GetCanOutLocationCodes();
+            var result = new List<StockSelectViewDTO>();
+
+            // 涓烘瘡涓嚭搴撳崟鏄庣粏鏌ヨ瀵瑰簲鐨勫簱瀛�
+            foreach (var orderDetail in orderDetails)
+            {
+                // 鏋勫缓鏌ヨ鏉′欢
+                var stockQuery = Db.Queryable<Dt_StockInfo>()
+                    .Where(x => locationCodes.Contains(x.LocationCode))
+                    .Where(x => x.StockStatus == (int)StockStatusEmun.鍏ュ簱瀹屾垚)
+                    .Includes(x => x.Details);
+
+                // 鎵ц鏌ヨ骞舵寜鍏堣繘鍏堝嚭鎺掑簭
+                var Qstocks = stockQuery.Where(x => x.Details.Any(d => d.MaterielCode == materielCode && d.StockQuantity > d.OutboundQuantity));
+
+                if (!string.IsNullOrEmpty(orderDetail.BatchNo))
+                {
+
+                    Qstocks = stockQuery.Where(x => x.Details.Any(d => d.BatchNo == orderDetail.BatchNo));
+
+                }
+                if (!string.IsNullOrEmpty(orderDetail.SupplyCode))
+                {
+
+                    Qstocks = stockQuery.Where(x => x.Details.Any(d => d.SupplyCode == orderDetail.SupplyCode));
+
+                }
+
+                var stocks = Qstocks.OrderBy(x => x.CreateDate).ToList();
+
+                foreach (var stock in stocks)
+                {
+                    var relevantDetails = stock.Details
+                        .Where(d => d.MaterielCode == materielCode &&
+                                   string.IsNullOrEmpty(orderDetail.BatchNo) ? true : d.BatchNo == orderDetail.BatchNo &&
+                                   string.IsNullOrEmpty(orderDetail.SupplyCode) ? true : d.SupplyCode == orderDetail.SupplyCode &&
+                                   d.StockQuantity > d.OutboundQuantity)
+                        .ToList();
+
+                    if (relevantDetails.Any())
+                    {
+                        var firstDetail = relevantDetails.First();
+                        var useableQuantity = relevantDetails.Sum(d => d.StockQuantity - d.OutboundQuantity);
+
+                        result.Add(new StockSelectViewDTO
+                        {
+                            LocationCode = stock.LocationCode,
+                            MaterielCode = firstDetail.MaterielCode,
+                            MaterielName = firstDetail.MaterielName,
+                            BatchNo = orderDetail.BatchNo,
+                            SupplyCode = orderDetail.SupplyCode,
+                            Barcode = firstDetail.Barcode,
+                            PalletCode = stock.PalletCode,
+                            UseableQuantity = useableQuantity,
+                            StockCreateDate = stock.CreateDate,
+                            StockId = stock.Id,
+                            OrderDetailId = orderDetail.Id // 鍏宠仈鍒板叿浣撶殑鍑哄簱鍗曟槑缁�
+                        });
+                    }
+                }
+            }
+
+            return result;
         }
 
         public List<StockSelectViewDTO> GetSelectViewDTOs(string orderNo, string materielCode)
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 29100af..6457db1 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"
@@ -1,4 +1,5 @@
-锘縰sing Microsoft.Extensions.Logging;
+锘縰sing MailKit.Search;
+using Microsoft.Extensions.Logging;
 using Newtonsoft.Json;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
 using System;
@@ -581,28 +582,33 @@
         {
             try
             {
-                var allocorder = _allocateOrderRepository.Db.Queryable<Dt_AllocateOrder>().Includes(x => x.Details).Where(x => x.Details.Any(o => o.Id == orderDetailId)).First();
-                //var allocorder = _allocateOrderDetailRepository.Db.Queryable<Dt_AllocateOrderDetail>()
-                //               .LeftJoin<Dt_AllocateOrder>((detail, order) => detail.OrderId == order.Id)
-                //               .Where((detail, order) => order.Id == orderDetailId)
-                //               .Select((detail, order) => order)
-                //               .First();
-                if (allocorder == null)
-                {
-                    return WebResponseContent.Instance.Error("鎵句笉鍒板崟鎹�");
-                }
-                var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == allocorder.OrderNo);
+                //var allocorder = _allocateOrderRepository.Db.Queryable<Dt_AllocateOrder>().Includes(x => x.Details).Where(x => x.Details.Any(o => o.Id == orderDetailId)).First();
+                ////var allocorder = _allocateOrderDetailRepository.Db.Queryable<Dt_AllocateOrderDetail>()
+                ////               .LeftJoin<Dt_AllocateOrder>((detail, order) => detail.OrderId == order.Id)
+                ////               .Where((detail, order) => order.Id == orderDetailId)
+                ////               .Select((detail, order) => order)
+                ////               .First();
+                //if (allocorder == null)
+                //{
+                //    return WebResponseContent.Instance.Error("鎵句笉鍒板崟鎹�");
+                //}
+
+                var outboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Includes(x => x.Details).Where(x => x.Details.Any(o => o.Id == orderDetailId)).First();
+ 
                 if (outboundOrder == null)
                 {
                     return WebResponseContent.Instance.Error("鎵句笉鍒板嚭搴撳崟鎹�");
                 }
-
-                var orderdetail = outboundOrder.Details.Where(outItem => allocorder.Details.Any(allocItem => allocItem.MaterielCode == outItem.MaterielCode && allocItem.LineNo == outItem.lineNo
-                 && allocItem.BarcodeQty == outItem.BarcodeQty && allocItem.WarehouseCode == outItem.WarehouseCode && allocItem.BarcodeUnit == outItem.BarcodeUnit)).First();
-                if (orderdetail == null)
+                if (outboundOrder.Details == null || !outboundOrder.Details.Any()) 
                 {
                     return WebResponseContent.Instance.Error("鎵句笉鍒板嚭搴撴槑缁嗗崟鎹�");
                 }
+                //var orderdetail = outboundOrder.Details.Where(outItem => allocorder.Details.Any(allocItem => allocItem.MaterielCode == outItem.MaterielCode && allocItem.LineNo == outItem.lineNo
+                // && allocItem.BarcodeQty == outItem.BarcodeQty && allocItem.WarehouseCode == outItem.WarehouseCode && allocItem.BarcodeUnit == outItem.BarcodeUnit)).First();
+                //if (orderdetail == null)
+                //{
+                //    return WebResponseContent.Instance.Error("鎵句笉鍒板嚭搴撴槑缁嗗崟鎹�");
+                //}
 
                 (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(outboundOrder.Details.First().Id, stockSelectViews, station);
 
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs"
index d328c16..5ac31db 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs"
@@ -57,6 +57,10 @@
             {
                 allocateOrder.OrderType = 115;
             }
+            else if (businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
+            {
+                allocateOrder.OrderType = 117;
+            }
 
             foreach (var detailDto in model.Details)
             {
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.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/Stock/StockInfoController.cs"
index 7759dcc..48e53f0 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/Stock/StockInfoController.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/Stock/StockInfoController.cs"
@@ -57,11 +57,11 @@
         /// <param name="materielCode"></param>
         /// <returns></returns>
         [HttpPost, HttpGet, Route("GetAllocateStockSelect"), AllowAnonymous]
-        public List<StockSelectViewDTO> GetAllocateSelectViewDTOs(int orderId, string materielCode)
+        public List<StockSelectViewDTO> GetAllocateSelectViewDTOs(int orderId,int orderDetailId, string materielCode)
         {
             try
             {
-                return Service.GetAllocateSelectViewDTOs(orderId, materielCode);
+                return Service.GetAllocateSelectViewDTOs(orderId, orderDetailId,materielCode);
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3