From c827fe7b0c5b3b444d76ba0d96a2649c764630dd Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期四, 14 十一月 2024 16:36:08 +0800 Subject: [PATCH] 修改WCS、WMS出入库逻辑 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 90 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 71 insertions(+), 19 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index 1c40c2f..682c77f 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -108,7 +108,11 @@ } } - + /// <summary> + /// 鍏ュ簱浠诲姟瀹屾垚 + /// </summary> + /// <param name="task"></param> + /// <returns></returns> public WebResponseContent InboundTaskCompleted(Dt_Task task) { Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -188,7 +192,11 @@ return (true, "鎴愬姛"); } - + /// <summary> + /// 鍑哄簱浠诲姟瀹屾垚 + /// </summary> + /// <param name="task"></param> + /// <returns></returns> public WebResponseContent OutboundTaskCompleted(Dt_Task task) { Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -212,6 +220,11 @@ return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK(); } + /// <summary> + /// 鎵樼洏鍑哄簱浠诲姟瀹屾垚 + /// </summary> + /// <param name="task"></param> + /// <returns></returns> public WebResponseContent PalletOutboundTaskCompleted(Dt_Task task) { Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -247,13 +260,16 @@ if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); if (task.TaskType == (int)TaskTypeEnum.Inbound) { - int nextStatus = task.TaskStatus.GetNextNotCompletedStatus<TaskInStatusEnum>(); - if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskStatus}銆�"); - task.TaskStatus = nextStatus; + int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); + if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�"); + task.TaskState = nextStatus; switch (nextStatus) { case (int)TaskInStatusEnum.SC_InFinish: content = UpdateTaskStatusInFinish(task); + break; + case (int)TaskInStatusEnum.Car_InFinish: + content = InboundTaskCompleted(task); break; default: break; @@ -261,12 +277,12 @@ } else if (task.TaskType == (int)TaskTypeEnum.Outbound) { - int nextStatus = task.TaskStatus.GetNextNotCompletedStatus<TaskOutStatusEnum>(); - if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskStatus}銆�"); - task.TaskStatus = nextStatus; + int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>(); + if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�"); + task.TaskState = nextStatus; switch (nextStatus) { - case (int)TaskOutStatusEnum.SC_OutFinish: + case (int)TaskOutStatusEnum.SC_OutFinish://鏇存柊璐т綅淇℃伅 break; default: break; @@ -279,6 +295,7 @@ } return content; } + /// <summary> /// 鏇存柊浠诲姟鐘舵�佸畬鎴� /// </summary> @@ -289,24 +306,59 @@ WebResponseContent content = new WebResponseContent().OK(); try { - Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); - Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);//缁勭洏搴撳瓨 + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);//璐т綅 var result = CheckCompleted(stockInfo, locationInfo); if (!result.Item1) throw new Exception(result.Item2); + + if (stockInfo.StockStatus != StockStatusEmun.鍏ュ簱涓�.ObjToInt()) throw new Exception($"鎵樼洏[{task.PalletCode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�"); - stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); - locationInfo.CurrentQty++; - locationInfo.LocationStatus = locationInfo.MaxQty - locationInfo.CurrentQty == 0 ? LocationStatusEnum.Fullload.ObjToInt() : LocationStatusEnum.InStock.ObjToInt(); - using (TransactionScope scope = new TransactionScope()) + Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(x => x.StockId == stockInfo.Id); + + #region 鍏ュ簱鍗� + Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo); + if (inboundOrder == null || inboundOrder.Details == null) throw new Exception($"鏈壘鍒版墭鐩榌{task.PalletCode}]鐨勫叆搴撳崟鏄庣粏淇℃伅"); + Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo && x.MaterielCode == stockInfoDetail.MaterielCode); + inboundOrderDetail.OverInQuantity++; + inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); + + if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null) { - BaseDal.UpdateData(task); - _basicService.LocationInfoService.Repository.UpdateData(locationInfo); - _stockService.StockInfoService.Repository.UpdateData(stockInfo); - scope.Complete(); + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(); } + else if (inboundOrder.OrderStatus == InboundStatusEnum.鏈紑濮�.ObjToInt()) + { + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt(); + } + #endregion + + #region 鍒ゆ柇鏄惁涓哄爢鍨涙満鍙栨斁璐т綅 + if(task.IsPickPlace) + { + + } + #endregion + //List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.LocationCodesGetStockInfos(stockInfo.LocationCode).Where(x => x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt()).ToList(); + //stockInfo.SerialNumber = stockInfos.Count + 1; + stockInfo.InDate= DateTime.Now; + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + stockInfoDetail.Status = StockStatusEmun.宸插叆搴�.ObjToInt(); + int beforeStatus = locationInfo.LocationStatus; + locationInfo.LocationStatus = locationInfo.MaxQty - locationInfo.CurrentQty == 0 ? LocationStatusEnum.Fullload.ObjToInt() : LocationStatusEnum.InStock.ObjToInt(); + + Db.Ado.BeginTran(); + BaseDal.UpdateData(task); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); + _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder); + _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + Db.Ado.CommitTran(); } catch (Exception ex) { + Db.Ado.RollbackTran(); content.Error(ex.Message); } return content; -- Gitblit v1.9.3