From 87b988afc48221b4a23db5535a424de79e3d6d9f Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期六, 11 一月 2025 21:51:50 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs | 92 +++++++++++++++++++++++++++++++-------------- 1 files changed, 63 insertions(+), 29 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs" index f44093e..8aa4a5d 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderDetailService.cs" @@ -47,7 +47,21 @@ _basicService = basicService; _recordService = recordService; } - + public WebResponseContent GetOutboundOrderDetails(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + string orderNo = saveModel.MainData["orderNo"].ToString(); + Dt_OutboundOrder inboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == orderNo).Includes(x => x.Details).First(); + content.OK(data: inboundOrder.Details); + } + catch (Exception ex) + { + content.Error(ex.Message); + } + return content; + } /// <summary> /// 閿佸畾搴撳瓨锛岀敱绯荤粺鍒嗛厤(浠呴�昏緫杩愮畻锛屼笉鐢熸垚浠诲姟锛屼笉淇敼鏁版嵁搴撴暟鎹�) /// </summary> @@ -234,42 +248,54 @@ float needQuantity = originalNeedQuantity; List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, outboundOrder.WarehouseId); + if (!stockInfos.Any()) + { + throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨"); + } List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity); item.LockQuantity += needQuantity - residueQuantity; outStocks.AddRange(autoAssignStocks); float assignQuantity = needQuantity - residueQuantity; - //for (int i = 0; i < outboundOrderDetails.Count; i++) - //{ - // for (int j = 0; j < outStocks.Count; j++) - // { - // if(assignQuantity > 0) - // { - // if (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity >= outStocks[j].) - // { - // } - // } - // } + List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList(); - // if (assignQuantity > 0 && outboundOrderDetails[i].LockQuantity < outboundOrderDetails[i].OrderQuantity) - // { - // outStockLockInfos.AddRange(_outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetails[i], outStocks)); - // if (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity >= assignQuantity) - // { - // outboundOrderDetails[i].LockQuantity += assignQuantity; - // break; - // } - // else - // { - // assignQuantity -= (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity); - // outboundOrderDetails[i].LockQuantity = outboundOrderDetails[i].OrderQuantity; - // } - // } - //} + for (int i = 0; i < details.Count; i++) + { + float orderQuantity = details[i].OrderQuantity; + for (int j = 0; j < autoAssignStocks.Count; j++) + { + float detailAssignQuantity = outStockLockInfos.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);//鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲� + + float palletAssignQuantity = outStockLockInfos.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲� + if (string.IsNullOrEmpty(item.BatchNo)) + { + palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲� + } + float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); + if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭� + { + float orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity; + if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) + { + details[i].LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; + Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); + outStockLockInfos.Add(outStockLockInfo); + } + else + { + Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], details[i].OrderQuantity - details[i].LockQuantity); + outStockLockInfos.Add(outStockLockInfo); + details[i].LockQuantity = details[i].OrderQuantity; + break; + } + + } + } + } + + locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); } - - return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos); } @@ -385,6 +411,14 @@ List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList(); if (addOutStockLockInfos != null && addOutStockLockInfos.Any()) { + if (tasks != null) + { + addOutStockLockInfos.ForEach(x => + { + x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum; + }); + } + _outStockLockInfoService.Repository.AddData(addOutStockLockInfos); } List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList(); -- Gitblit v1.9.3