From 97073e9e6d03114221436ee0aa1e143d6e2c4a09 Mon Sep 17 00:00:00 2001 From: wankeda <Administrator@DESKTOP-HAU3ST3> Date: 星期一, 04 八月 2025 13:07:39 +0800 Subject: [PATCH] 出入库代码逻辑优化 --- WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 435 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 243 insertions(+), 192 deletions(-) diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs index f96becc..3310331 100644 --- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs +++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs @@ -19,6 +19,7 @@ using MailKit.Search; using Microsoft.AspNetCore.SignalR; using Newtonsoft.Json; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Database; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using Org.BouncyCastle.Asn1.Tsp; using SqlSugar; @@ -444,18 +445,18 @@ Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details .FirstOrDefault(x => x.LinId == stockInfo.Details.FirstOrDefault()?.LinId); - if (inboundOrder.OrderType == 0 && inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) - { - //鍏ュ簱鏁伴噺鍥炰紶 - return ProcessNormalInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); - } - else - { - //璋冩嫧鍑哄叆搴撲换鍔℃暟閲忓洖浼� - return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); - } + //if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) + //{ + //鍏ュ簱鏁伴噺鍥炰紶 + return ProcessNormalInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); + //} + //else + //{ + // //璋冩嫧鍑哄叆搴撲换鍔℃暟閲忓洖浼� + // return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); + //} } - + //鍏朵粬鍏ュ簱 private WebResponseContent ProcessNormalInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) { @@ -485,11 +486,15 @@ UpdateInboundOrder(inboundOrder, inboundOrderDetail); // 鍗曟嵁鏁伴噺鍏ㄩ儴涓婃灦瀹屾垚锛屽鐞哤MS鍥炰紶 - //if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) - //{ - // var stockInfoDetail = stockInfo.Details.FirstOrDefault(); - // SendInboundInfoToWMS(task, inboundOrder, stockInfo); - //} + if (inboundOrder.OrderStatus == InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.OrderType == 0) + { + var stockInfoDetail = stockInfo.Details.FirstOrDefault(); + SendInboundInfoToWMS(task, inboundOrder, stockInfo); + } + else if (inboundOrder.OrderStatus == InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.OrderType == 2) + { + SendAllocateInfoToWMS(task, inboundOrder, stockInfo); + } _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); @@ -500,81 +505,51 @@ throw; } } + ////璋冩嫧鍏ュ簱 + //private WebResponseContent ProcessAllocateInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, + // int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) + //{ + // // 鏇存柊鍏ュ簱鍗曟槑缁嗙姸鎬� + // UpdateInboundOrderDetails(stockInfo, inboundOrder, ref inboundOrderDetail); - private WebResponseContent ProcessAllocateInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, - int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) - { - //// 濡傛灉鏄渶鍚庝竴鏉℃槑缁� - //if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) - //{ - // try - // { - // _unitOfWorkManage.BeginTran(); + // // 鏇存柊搴撳瓨鏄庣粏鐘舵�� + // stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()); - // // 澶勭悊璋冩嫧鍏ュ簱鍗� - // ProcessAllocateInboundOrder(inboundOrder, inboundOrderDetail); + // try + // { + // _unitOfWorkManage.BeginTran(); - // // 鑾峰彇鐩稿叧搴撳瓨淇℃伅 - // var relatedStockInfo = _stockService.StockInfoService.Repository - // .QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); + // // 鏇存柊浠诲姟鐘舵�� + // UpdateTaskStatus(task); - // // 鍙戦�佽皟鎷ㄤ俊鎭埌WMS - // SendAllocateInfoToWMS(task, inboundOrder, relatedStockInfo); + // // 鏇存柊璐т綅鐘舵�� + // UpdateLocationStatus(locationInfo, lastStatus); - // _unitOfWorkManage.CommitTran(); - // } - // catch - // { - // _unitOfWorkManage.RollbackTran(); - // throw; - // } - //} + // // 鏇存柊搴撳瓨淇℃伅 + // UpdateStockInfo(stockInfo); - //// 娣诲姞鍘嗗彶璁板綍 - //AddInboundOrderDetailHistory(inboundOrderDetail); + // // 娣诲姞璁板綍 + // AddRecords(task, stockInfo, locationInfo, lastStatus); - //return WebResponseContent.Instance.OK(); - // 鏇存柊鍏ュ簱鍗曟槑缁嗙姸鎬� - UpdateInboundOrderDetails(stockInfo, inboundOrder, ref inboundOrderDetail); + // // 鏇存柊鍏ュ簱鍗� + // UpdateInboundOrder(inboundOrder, inboundOrderDetail); - // 鏇存柊搴撳瓨鏄庣粏鐘舵�� - stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()); + // // 鍗曟嵁鏁伴噺鍏ㄩ儴涓婃灦瀹屾垚锛屽鐞哤MS鍥炰紶 + // if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) + // { + // var stockInfoDetail = stockInfo.Details.FirstOrDefault(); + // SendInboundInfoToWMS(task, inboundOrder, stockInfo); + // } - try - { - _unitOfWorkManage.BeginTran(); - - // 鏇存柊浠诲姟鐘舵�� - UpdateTaskStatus(task); - - // 鏇存柊璐т綅鐘舵�� - UpdateLocationStatus(locationInfo, lastStatus); - - // 鏇存柊搴撳瓨淇℃伅 - UpdateStockInfo(stockInfo); - - // 娣诲姞璁板綍 - AddRecords(task, stockInfo, locationInfo, lastStatus); - - // 鏇存柊鍏ュ簱鍗� - UpdateInboundOrder(inboundOrder, inboundOrderDetail); - - // 鍗曟嵁鏁伴噺鍏ㄩ儴涓婃灦瀹屾垚锛屽鐞哤MS鍥炰紶 - //if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) - //{ - // var stockInfoDetail = stockInfo.Details.FirstOrDefault(); - // SendInboundInfoToWMS(task, inboundOrder, stockInfo); - //} - - _unitOfWorkManage.CommitTran(); - return WebResponseContent.Instance.OK(); - } - catch - { - _unitOfWorkManage.RollbackTran(); - throw; - } - } + // _unitOfWorkManage.CommitTran(); + // return WebResponseContent.Instance.OK(); + // } + // catch + // { + // _unitOfWorkManage.RollbackTran(); + // throw; + // } + //} #region Helper Methods @@ -598,7 +573,12 @@ else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) { inboundOrderDetail.OrderDetailStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt(); + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt(); } + } + if (inboundOrder.Details.Count == overCount) + { + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(); } } @@ -739,40 +719,48 @@ _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); } - private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, List<Dt_StockInfo> stockInfos) + private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfo stockInfos) { - var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfos.FirstOrDefault().Id); + List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == inboundOrder.OrderNo)).ToList(); + //var dt_StockInfo = _stockRepository.StockInfoRepository.QueryData(x => x.Id == stockInfo.Id).ToList(); + //List<Dt_StockInfo> StockInfos = new List<Dt_StockInfo>(); + //foreach (var item in dt_StockInfo) + //{ + // Dt_StockInfo StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == item.Id).Includes(x => x.Details).First(); + // StockInfos.Add(StockInfo); + //} + + if (StockInfos.Count == 0) throw new Exception("鏈壘鍒板簱瀛樹俊鎭�"); var inventoryAllocate = new InventoryAllocate { - ApiType = "AsnController", - Method = "AsrsGroudingAsn", + ApiType = "InventoryAllocateController", + Method = "AsrsFinishedStockCount", Parameters = new List<InventoryAllocate.Allocate> { new InventoryAllocate.Allocate { Value = new List<Allocate.data1> { - new Allocate.data1 + new Allocate.data1 + { + No = inboundOrder.OrderNo, + //InWarehouse = task.Roadway, + TransactionCode = inboundOrder.TransactionCode, + InoutType = inboundOrder.OrderType, + OrderType = inboundOrder.InoutType, + // 閬嶅巻鎵�鏈夊簱瀛樻槑缁嗭紝娣诲姞鍒� DetailList + DetailList = StockInfos.Select(d => new Allocate.data1.Inventory { - No = task.OrderNo, - InWarehouse = task.Roadway, - TransactionCode = inboundOrder.TransactionCode, - InoutType = inboundOrder.OrderType, - OrderType = inboundOrder.InoutType, - DetailList = new List<Allocate.data1.Inventory> - { - new Allocate.data1.Inventory - { - LinId = detail.LinId, - MaterielCode = detail.MaterielCode, - OrderQuantity = detail.StockQuantity, - BatchNo = detail.BatchNo, - FinishQty = detail.StockQuantity, - LocationName = task.TargetAddress - } - } - } + LinId = d.Details.FirstOrDefault()?.LinId?? "", + MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "", + OrderQuantity = d.Details.FirstOrDefault().StockQuantity, + BatchNo = d.BatchNo, + LPN_No = d.PalletCode, + FinishQty = d.Details.FirstOrDefault().StockQuantity, + LocationName = d.LocationCode + }).ToList() + } } } } @@ -849,8 +837,26 @@ out var locationInfo, out var outStockLockInfos); if (!validationResult.Status) return validationResult; + int lastStatus = locationInfo.LocationStatus; + locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + + + + Dt_OutboundOrderDetail outboundOrderDetails = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>() + .Where(x => x.BatchNo == stockInfo.Details.FirstOrDefault().BatchNo) + .First(); + if (outboundOrderDetails == null) return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟淇℃伅"); + + Dt_OutboundOrder inboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() + .Where(x => x.Id == outboundOrderDetails.OrderId) + .Includes(x => x.Details) + .First(); + + if (inboundOrder == null) return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟淇℃伅"); // 2. 澶勭悊鍑哄簱璁㈠崟璇︽儏 - var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); + //var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); + + UpdateOutboundOrderDetails(stockInfo, inboundOrder, ref outboundOrderDetails); // 3. 鎵ц鏍稿績鍑哄簱閫昏緫 return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetails); @@ -889,33 +895,34 @@ return WebResponseContent.Instance.OK(); } - private List<Dt_OutboundOrderDetail> ProcessOutboundOrderDetails(List<Dt_OutStockLockInfo> outStockLockInfos) - { - var outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); + //private List<Dt_OutboundOrderDetail> ProcessOutboundOrderDetails(List<Dt_OutStockLockInfo> outStockLockInfos) + //{ + // var outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); - foreach (var lockInfo in outStockLockInfos) - { - var detail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == lockInfo.BatchNo); - if (detail != null) - { - detail.OverOutQuantity = lockInfo.OriginalQuantity; - if (detail.LockQuantity == detail.OrderQuantity) - { - detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); - } - outboundOrderDetails.Add(detail); - } - } + // foreach (var lockInfo in outStockLockInfos) + // { + // List<Dt_OutboundOrderDetail> detail = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => x.Id == lockInfo.Id); + // if (detail != null) + // { + // detail.OverOutQuantity = lockInfo.OriginalQuantity; + // if (detail.LockQuantity == detail.OrderQuantity) + // { + // detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); + // } + // outboundOrderDetails.Add(detail); + // } + // } - return outboundOrderDetails; - } + // return outboundOrderDetails; + //} private WebResponseContent ExecuteOutboundLogic(Dt_Task task, Dt_StockInfo stockInfo, - Dt_LocationInfo locationInfo, List<Dt_OutboundOrderDetail> outboundOrderDetails) + Dt_LocationInfo locationInfo, Dt_OutboundOrderDetail outboundOrderDetails) { try { _unitOfWorkManage.BeginTran(); + // 鏇存柊鍑哄簱璁㈠崟璇︽儏 _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); @@ -934,22 +941,26 @@ // 鏍规嵁璁㈠崟绫诲瀷澶勭悊涓嶅悓閫昏緫 var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() - .Where(x => x.BatchNo == outboundOrderDetails.FirstOrDefault().BatchNo).First(); + .Where(x => x.BatchNo == outboundOrderDetails.BatchNo).First(); var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() .Where(x => x.Id == outDetail.OrderId).Includes(x => x.Details).First(); - if (outboundOrder.OrderType == 1) // 鏅�氬嚭搴� && outDetail.OrderDetailStatus = OutboundStatusEnum.鍑哄簱瀹屾垚 + + if (outboundOrder.OrderStatus == OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt()) { - ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); + var stockInfoDetail = stockInfo.Details.FirstOrDefault(); + //ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); + SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); } - else if (outboundOrder.OrderType == 240) // 鐩樼偣鍑哄簱 + + if (outboundOrder.OrderType == 240) // 鐩樼偣鍑哄簱 { // 鐩樼偣鍑哄簱鐗规畩澶勭悊閫昏緫 } - else // 璋冩嫧鍑哄簱 - { - ProcessAllocateOutbound(task, stockInfo, outboundOrder, outDetail); - } + //else // 璋冩嫧鍑哄簱 + //{ + // ProcessAllocateOutbound(task, stockInfo, outboundOrder, outDetail); + //} _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); @@ -960,12 +971,45 @@ throw; } } + private void UpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, + ref Dt_OutboundOrderDetail inboundOrderDetail) + { + int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()); + inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfo.Details.FirstOrDefault()?.BatchNo); + + foreach (var item in stockInfo.Details) + { + if (inboundOrderDetail == null) continue; + + inboundOrderDetail.OverOutQuantity += item.OutboundQuantity; + + if (inboundOrderDetail.OverOutQuantity == inboundOrderDetail.OrderQuantity) + { + inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); + overCount++; + } + else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) + { + inboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt(); + inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt(); + } + } + if (inboundOrder.Details.Count == overCount) + { + inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt(); + } + } private void UpdateStockStatus(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) { - stockInfo.LocationCode = locationInfo.LocationCode; + stockInfo.LocationCode = ""; stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); - _stockService.StockInfoService.Repository.UpdateData(stockInfo); + stockInfo.Details.ForEach(x => + { + x.Status = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); + }); + _stockRepository.StockInfoRepository.UpdateData(stockInfo); + _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); } private void UpdateLocationStatus(Dt_LocationInfo locationInfo) @@ -996,32 +1040,40 @@ var stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>() .Where(x => x.StockId == stockInfo.Id).First(); - if (outboundOrder.OrderStatus == OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt()) - { - var history = new Dt_OutboundOrder_Hty - { - OrderStatus = outboundOrder.OrderStatus, - CreateType = outboundOrder.CreateType, - UpperOrderNo = outboundOrder.UpperOrderNo, - OrderNo = outboundOrder.OrderNo, - OutWareHouse = outboundOrder.OutWareHouse, - TransactionCode = outboundOrder.TransactionCode, - InoutType = outboundOrder.InoutType, - OrderType = outboundOrder.OrderType, - Creater = "WMS", - CreateDate = DateTime.Now, - }; - _outboundOrder_HtyService.AddData(history); - _outboundService.OutboundOrderService.DeleteData(outboundOrder); - } + //if (outboundOrder.OrderStatus == OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt()) + //{ + // var history = new Dt_OutboundOrder_Hty + // { + // OrderStatus = outboundOrder.OrderStatus, + // CreateType = outboundOrder.CreateType, + // UpperOrderNo = outboundOrder.UpperOrderNo, + // OrderNo = outboundOrder.OrderNo, + // OutWareHouse = outboundOrder.OutWareHouse, + // TransactionCode = outboundOrder.TransactionCode, + // InoutType = outboundOrder.InoutType, + // OrderType = outboundOrder.OrderType, + // Creater = "WMS", + // CreateDate = DateTime.Now, + // }; + // _outboundOrder_HtyService.AddData(history); + // _outboundService.OutboundOrderService.DeleteData(outboundOrder); + //} - MoveOutboundDetailToHistory(outDetail); + //MoveOutboundDetailToHistory(outDetail); // 鍙戦�佸嚭搴撲俊鎭埌WMS - SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); + if (outboundOrder.OrderStatus == OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && outboundOrder.OrderType == 0) + { + SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); + } + else if (outboundOrder.OrderStatus == OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && outboundOrder.OrderType == 2) + { + SendAllocateOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); + } + // 鍒犻櫎搴撳瓨淇℃伅 - DeleteStockInfo(stockInfo); + //DeleteStockInfo(stockInfo); } private void ProcessAllocateOutbound(Dt_Task task, Dt_StockInfo stockInfo, @@ -1051,7 +1103,7 @@ MoveOutboundDetailToHistory(outDetail); // 鍙戦�佽皟鎷ㄥ嚭搴撲俊鎭埌WMS - SendAllocateOutboundToWMS(task, outboundOrder, outDetail, relatedStockInfos); + // 鍒犻櫎搴撳瓨淇℃伅 DeleteStockInfo(stockInfo); @@ -1080,51 +1132,46 @@ { - List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == outboundOrder.OrderNo)).ToList(); - //var dt_StockInfo = _stockRepository.StockInfoRepository.QueryData(x => x.Id == stockInfo.Id).ToList(); - //List<Dt_StockInfo> StockInfos = new List<Dt_StockInfo>(); - //foreach (var item in dt_StockInfo) - //{ - // Dt_StockInfo StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == item.Id).Includes(x => x.Details).First(); - // StockInfos.Add(StockInfo); - //} + //List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.BatchNo == outDetail.BatchNo)).ToList(); + List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.OrderNo == outboundOrder.OrderNo); - if (StockInfos.Count == 0) throw new Exception("鏈壘鍒板簱瀛樹俊鎭�"); + if (outStockLockInfos.Count == 0) throw new Exception("鏈壘鍒板簱瀛樹俊鎭�"); + + // 鏋勫缓鍥炰紶鏁版嵁锛屽皢鎵�鏈夊尮閰嶇殑搴撳瓨鏄庣粏鍔犲叆 DetailList var passBack = new HouseoutboundPassBack { - ApiType = "ShippingOrderController", - Method = "AsrsOutboundSO", + ApiType = "InventoryAllocateController", + Method = "AsrsFinishedStockCount", Parameters = new List<HouseoutboundPassBack.datas> + { + new HouseoutboundPassBack.datas { - new HouseoutboundPassBack.datas + Value = new List<HouseoutboundPassBack.datas.data1> { - Value = new List<HouseoutboundPassBack.datas.data1> + new HouseoutboundPassBack.datas.data1 { - new HouseoutboundPassBack.datas.data1 - { - No = outboundOrder.OrderNo, - OutWareHouse = task.Roadway, - TransactionCode = outboundOrder.TransactionCode, - InoutType = outboundOrder.OrderType, - OrderType = outboundOrder.InoutType, - DetailList = new List<HouseoutboundPassBack.datas.data1.Inbound> + No = outboundOrder.OrderNo, + OutWareHouse = task.Roadway, + TransactionCode = outboundOrder.TransactionCode, + InoutType = outboundOrder.OrderType, + OrderType = outboundOrder.InoutType, + DetailList = outStockLockInfos.Select(d => new HouseoutboundPassBack.datas.data1.Inbound { - new HouseoutboundPassBack.datas.data1.Inbound - { - LinId = outDetail.LinId, - LPN_No = task.PalletCode, - MaterielCode = stockInfoDetail.MaterielCode, - OrderQuantity = stockInfoDetail.OutboundQuantity, - BatchNo = stockInfoDetail.BatchNo, - FinishQty = stockInfoDetail.OutboundQuantity, - LocationName = task.SourceAddress - } - } - } + LinId = d.LinId?? "", + LPN_No = d.PalletCode, + MaterielCode = d.MaterielCode?? "", + OrderQuantity = d.OrderQuantity, + BatchNo = d.BatchNo, + FinishQty = d.OrderQuantity, + LocationName = d.LocationCode + }) + .ToList() + } } } + } }; var authResult = AuthenticateWithWMS(); @@ -1141,8 +1188,12 @@ } private void SendAllocateOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, - Dt_OutboundOrderDetail outDetail, List<Dt_StockInfo> stockInfos) + Dt_StockInfoDetail stockInfoDetail, Dt_OutboundOrderDetail outDetail) { + List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.OrderNo == outboundOrder.OrderNo); + + + if (outStockLockInfos.Count == 0) throw new Exception("鏈壘鍒板簱瀛樹俊鎭�"); var allocate = new InventoryAllocate { ApiType = "InventoryAllocateController", @@ -1160,7 +1211,7 @@ TransactionCode = outboundOrder.TransactionCode, InoutType = outboundOrder.OrderType, OrderType = outboundOrder.InoutType, - DetailList = stockInfos.Select(item => + DetailList = outStockLockInfos.Select(item => { var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); return new Allocate.data1.Inventory -- Gitblit v1.9.3