From 225d11e2ddaa55d1d482201cb4d89c9486cdba69 Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期五, 20 六月 2025 12:27:52 +0800 Subject: [PATCH] 更新代码 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 0 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" index 11dc349..87bf3af 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" @@ -20,6 +20,7 @@ using WIDESEA_Core.CodeConfigEnum; using Microsoft.AspNetCore.Mvc; using WIDESEA_DTO.ERP; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; namespace WIDESEA_TaskInfoService { @@ -78,6 +79,102 @@ return content; } /// <summary> + /// 閫夊畾搴撳瓨鐢熸垚鐩樼偣鍗曞嚭搴� + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public WebResponseContent TakeOutbound(List<StockViewDTO> stockViews) + { + WebResponseContent content = new WebResponseContent(); + try + { + if (stockViews.Select(x=>x.WarehouseId).Distinct().Count()>=2) + { + return content.Error($"璇烽�夋嫨鍚屼竴浠撳簱搴撳瓨杩涜鐩樼偣"); + } + List<int> ids = stockViews.Select(x => x.StockId).ToList(); + //鑾峰彇搴撳瓨 + List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList(); + if (stockInfos.Count!= stockViews.Count) + { + StockViewDTO? stockViewDTO = stockViews.FirstOrDefault(x=> !stockInfos.Select(x=>x.PalletCode).ToList().Contains(x.PalletCode)); + return content.Error($"鏈壘鍒皗stockViewDTO?.PalletCode}搴撳瓨"); + } + //鑾峰彇璐т綅 + List<string> locStrs = stockInfos.Select(x => x.LocationCode).ToList(); + List<Dt_LocationInfo> locationInfos =_basicRepository.LocationInfoRepository.QueryData(x=> locStrs.Contains(x.LocationCode)); + if (stockInfos.Count != locationInfos.Count) + { + string? locStr = locStrs.FirstOrDefault(x=> !locationInfos.Select(x => x.LocationCode).ToList().Contains(x)); + return content.Error($"鏈壘鍒皗locStr}璐т綅鏁版嵁"); + } + Dt_TakeStockOrder takeStockOrder = new Dt_TakeStockOrder() + { + WarehouseId = stockInfos.FirstOrDefault().WarehouseId, + TakeStockStatus = TakeStockStatusEnum.鐩樼偣涓�.ObjToInt(), + Details = new List<Dt_TakeStockOrderDetail>() + }; + foreach (var item in stockInfos) + { + if (item.Details.Count<=0) + { + return content.Error($"鏈壘鍒皗item.PalletCode}搴撳瓨鏄庣粏鏁版嵁"); + } + Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x=>x.LocationCode==item.LocationCode); + if (locationInfo != null && (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && item.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()) + { + //鍒涘缓鏄庣粏 + Dt_TakeStockOrderDetail takeStockOrderDetail = new Dt_TakeStockOrderDetail() + { + MaterielCode= item.Details.FirstOrDefault().MaterielCode, + MaterielName=item.Details.FirstOrDefault().MaterielName ?? "鏃犵墿鏂欏悕绉�", + BatchNo=item.Details.FirstOrDefault().BatchNo, + MaterielSpec=item.Details.FirstOrDefault().MaterielSpec ?? "鏃犵墿鏂欒鏍�", + LocationCode=item.LocationCode, + TakePalletCode=item.PalletCode, + TakeDetalStatus=TakeStockDetailStatusEnum.鐩樼偣鍑哄簱涓�.ObjToInt(), + Unit=item.Details.FirstOrDefault().Unit ?? "鏃犲崟浣�", + SysQty=item.Details.Sum(x=>x.StockQuantity), + Qty=0 + }; + takeStockOrder.Details.Add(takeStockOrderDetail); + } + else + { + content.Error($"璐т綅鎴栧簱瀛樼姸鎬佷笉婊¤冻鍑哄簱鏉′欢"); + } + } + List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutInventory); + if (tasks == null || tasks.Count <= 0) + { + return content.Error($"鐢熸垚浠诲姟澶辫触"); + } + stockInfos.ForEach(x => + { + x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt(); + }); + LocationStatusEnum locationStatus = LocationStatusEnum.Lock; + _unitOfWorkManage.BeginTran(); + //鏇存柊搴撳瓨鐘舵�� + _stockRepository.StockInfoRepository.UpdateData(stockInfos); + _inboundRepository.TakeStockOrderRepository.Db.InsertNav(takeStockOrder).Include(x=>x.Details).ExecuteCommand(); + //鏂板缓浠诲姟 + BaseDal.AddData(tasks); + //鍔犲叆璐т綅鍙樺姩璁板綍 + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus, LocationChangeType.OutboundAssignLocation, "", tasks?.Select(x => x.TaskNum).ToList()); + _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus); + _unitOfWorkManage.CommitTran(); + PushTasksToWCS(tasks); + content.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + content.Error(ex.Message); + } + return content; + } + /// <summary> /// 鐢熸垚鎴愬搧鍑哄簱浠诲姟 /// </summary> /// <param name="ProOutNo">鍑哄簱璁㈠崟鍙�</param> -- Gitblit v1.9.3