From 5be086f36d5fbcde9aaa6f775961f292aaae6ec1 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期日, 22 十二月 2024 22:53:31 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 156 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 118 insertions(+), 38 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 e26a402..9e6af5c 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" @@ -34,22 +34,25 @@ if (stockInfo != null) { Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); - Dt_Task task = new() + if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode)) { - CurrentAddress = stockInfo.LocationCode, - Grade = 0, - PalletCode = stockInfo.PalletCode, - NextAddress = "", - Roadway = locationInfo.RoadwayNo, - SourceAddress = stockInfo.LocationCode, - TargetAddress = "", - TaskStatus = TaskOutStatusEnum.OutNew.ObjToInt(), - TaskType = TaskOutboundTypeEnum.Outbound.ObjToInt(), - TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), - PalletType = stockInfo.PalletType, - WarehouseId = stockInfo.WarehouseId, - }; - tasks.Add(task); + Dt_Task task = new() + { + CurrentAddress = stockInfo.LocationCode, + Grade = 0, + PalletCode = stockInfo.PalletCode, + NextAddress = "", + Roadway = locationInfo.RoadwayNo, + SourceAddress = stockInfo.LocationCode, + TargetAddress = "", + TaskStatus = TaskOutStatusEnum.OutNew.ObjToInt(), + TaskType = TaskOutboundTypeEnum.Outbound.ObjToInt(), + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + PalletType = stockInfo.PalletType, + WarehouseId = stockInfo.WarehouseId, + }; + tasks.Add(task); + } } } return tasks; @@ -113,6 +116,65 @@ } return (tasks, stockInfos, orderDetail == null ? null : new List<Dt_OutboundOrderDetail> { orderDetail }, outStockLockInfos, locationInfos); + } + + /// <summary> + /// 鍑哄簱浠诲姟鏁版嵁澶勭悊 + /// </summary> + /// <param name="orderDetailId"></param> + /// <param name="stockSelectViews"></param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys) + { + List<Dt_Task> tasks = new List<Dt_Task>(); + List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id)); + + if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) + { + throw new Exception("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅"); + } + + List<Dt_StockInfo>? stockInfos = null; + List<Dt_OutboundOrderDetail>? orderDetails = null; + List<Dt_OutStockLockInfo>? outStockLockInfos = null; + List<Dt_LocationInfo>? locationInfos = null; + //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) + { + (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); + if (result.Item1 != null && result.Item1.Count > 0) + { + tasks = GetTasks(result.Item1); + result.Item2.ForEach(x => + { + x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); + }); + result.Item3.ForEach(x => + { + x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt(); + }); + + stockInfos = result.Item1; + orderDetails = result.Item2; + outStockLockInfos = result.Item3; + locationInfos = result.Item4; + } + else + { + throw new Exception("鏃犲簱瀛�"); + } + } + //else + //{ + // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.宸插垎閰�); + // if (stockLockInfos != null && stockLockInfos.Count > 0) + // { + // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); + // tasks = GetTasks(stocks); + // } + //} + + return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); } /// <summary> @@ -190,7 +252,7 @@ /// <summary> /// 鐢熸垚鍑哄簱浠诲姟 /// </summary> - /// <param name="keys"></param> + /// <param name="keys">鍑哄簱鍗曟槑缁嗕富閿�</param> /// <returns></returns> public WebResponseContent GenerateOutboundTask(int[] keys) { @@ -202,29 +264,27 @@ List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); - foreach (int key in keys) + + (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys); + if (result.Item2 != null && result.Item2.Count > 0) { - (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(key, stockSelectViews); - if (result.Item2 != null && result.Item2.Count > 0) - { - stockInfos.AddRange(result.Item2); - } - if (result.Item3 != null && result.Item3.Count > 0) - { - outboundOrderDetails.AddRange(result.Item3); - } - if (result.Item4 != null && result.Item4.Count > 0) - { - outStockLockInfos.AddRange(result.Item4); - } - if (result.Item5 != null && result.Item5.Count > 0) - { - locationInfos.AddRange(result.Item5); - } - if (result.Item1 != null && result.Item1.Count > 0) - { - tasks.AddRange(result.Item1); - } + stockInfos.AddRange(result.Item2); + } + if (result.Item3 != null && result.Item3.Count > 0) + { + outboundOrderDetails.AddRange(result.Item3); + } + if (result.Item4 != null && result.Item4.Count > 0) + { + outStockLockInfos.AddRange(result.Item4); + } + if (result.Item5 != null && result.Item5.Count > 0) + { + locationInfos.AddRange(result.Item5); + } + if (result.Item1 != null && result.Item1.Count > 0) + { + tasks.AddRange(result.Item1); } WebResponseContent content = GenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); @@ -236,5 +296,25 @@ return WebResponseContent.Instance.Error(ex.Message); } } + + /// <summary> + /// 鐢熸垚鍑哄簱浠诲姟 + /// </summary> + /// <param name="outboundId">鍑哄簱鍗曚富閿�</param> + /// <returns></returns> + public WebResponseContent GenerateOutboundTaskByHeadId(int outboundId) + { + try + { + List<int> keys = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => x.Id, x => x.OrderId == outboundId); + + return GenerateOutboundTask(keys.ToArray()); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } } } \ No newline at end of file -- Gitblit v1.9.3