From 4f39dcc195f28fa275fc2d065fbf1bf6a46c21b7 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 17 六月 2025 00:41:18 +0800 Subject: [PATCH] 优化出入库逻辑 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 113 ++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 72 insertions(+), 41 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index 95da17c..d584a14 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -98,28 +98,41 @@ return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); } _unitOfWorkManage.BeginTran(); - MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); - if (methodInfo != null) + #region MyRegion + switch ((TaskTypeEnum)task.TaskType) { - WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); - if (responseContent != null) - { - if (App.User.UserId > 0) - { - var response = HttpHelper.Post<WebResponseContent>(url + "StackCraneTaskCompleted?taskNum=" + task.TaskNum, "", "浠诲姟瀹屾垚"); - if (!response.Status) - { - _unitOfWorkManage.RollbackTran(); - return WebResponseContent.Instance.Error(response.Message); - } - _unitOfWorkManage.CommitTran(); - return content = responseContent; - } - _unitOfWorkManage.CommitTran(); - return content = responseContent; - } + case TaskTypeEnum.Inbound: + content = InboundTaskCompleted(task); + break; + case TaskTypeEnum.Outbound: + content = OutboundTaskCompleted(task); + break; + case TaskTypeEnum.PalletInbound: + content = PalletInboundTaskCompleted(task); + break; + case TaskTypeEnum.PalletOutbound: + content = PalletOutboundTaskCompleted(task); + break; + case TaskTypeEnum.Relocation: + content = RelocationTaskCompleted(task); + break; + case TaskTypeEnum.AGVCarry: + + break; + default: + return content = WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); } - return content = WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + if (content.Status) + { + if (App.User.UserId > 0) + { + content = HttpHelper.Post<WebResponseContent>(url + "StackCraneTaskCompleted?taskNum=" + task.TaskNum, "", "浠诲姟瀹屾垚"); + if (!content.Status) throw new Exception(content.Message); + } + _unitOfWorkManage.CommitTran(); + } + return content; + #endregion } catch (Exception ex) { @@ -128,7 +141,7 @@ } finally { - WriteLog.GetLog("浠诲姟瀹屾垚").Write($"鎿嶄綔浜猴細{(App.User.UserId>0? App.User.UserName: "System")}{ Environment.NewLine}浠诲姟鍙凤細{taskNum}{Environment.NewLine}{ JsonConvert.SerializeObject(content)}", "浠诲姟瀹屾垚"); + WriteLog.GetLog("浠诲姟瀹屾垚").Write($"鎿嶄綔浜猴細{(App.User.UserId > 0 ? App.User.UserName : "System")}{Environment.NewLine}浠诲姟鍙凤細{taskNum}{Environment.NewLine}{JsonConvert.SerializeObject(content)}", "浠诲姟瀹屾垚"); } } /// <summary> @@ -144,7 +157,7 @@ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); if (task == null) { - return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); + return content = WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); } _unitOfWorkManage.BeginTran(); MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCancel"); @@ -161,22 +174,22 @@ if (!response.Status) { _unitOfWorkManage.RollbackTran(); - return content=WebResponseContent.Instance.Error(response.Message); + return content = WebResponseContent.Instance.Error(response.Message); } _unitOfWorkManage.CommitTran(); - return content=responseContent; + return content = responseContent; } _unitOfWorkManage.CommitTran(); - return content=responseContent; + return content = responseContent; } } } - return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + return content = WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); - return content=WebResponseContent.Instance.Error(ex.Message); + return content = WebResponseContent.Instance.Error(ex.Message); } finally { @@ -216,7 +229,7 @@ task.Modifier = App.User.UserId > 0 ? App.User.UserName : "System"; BaseDal.UpdateData(task); _unitOfWorkManage.CommitTran(); - return content = WebResponseContent.Instance.OK(); + return content = WebResponseContent.Instance.OK(); } catch (Exception ex) { @@ -228,14 +241,37 @@ { try { - _unitOfWorkManage.BeginTran(); decimal beforeQuantity = 0; Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(); Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); CheckCompleted(stockInfo, locationInfo); + + Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo); + if (inboundOrder != null) + { + Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.Where(x => x.BatchNo == stockInfoDetail.BatchNo).FirstOrDefault(); + if (inboundOrderDetail != null) + { + inboundOrderDetail.OverInQuantity++; + inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); + + if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) + { + if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() && x.BatchNo != inboundOrderDetail.BatchNo) == null) + { + inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(); + _inboundService.InbounOrderService.Repository.DeleteAndMoveIntoHty(inboundOrder, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + _inboundService.InboundOrderDetailService.Repository.DeleteAndMoveIntoHty(inboundOrder.Details, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + } + } + _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); + } + _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder); + } stockInfo.LocationCode = locationInfo.LocationCode; stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); @@ -253,16 +289,14 @@ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); - _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound,task.TaskNum); - _unitOfWorkManage.CommitTran(); + _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound, task.TaskNum); return WebResponseContent.Instance.OK(); } catch (Exception ex) { - _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } - + } /// <summary> @@ -340,7 +374,6 @@ { try { - _unitOfWorkManage.BeginTran(); decimal beforeQuantity = 0; Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); @@ -373,13 +406,11 @@ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) - beforeQuantity, StockChangeType.Outbound, task.TaskNum); - _unitOfWorkManage.CommitTran(); return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK(); } catch (Exception ex) { - _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } @@ -543,7 +574,7 @@ } } - + public WebResponseContent OutboundTaskCancel(Dt_Task task) { try @@ -622,7 +653,7 @@ task.TaskStatus = OutTaskStatusEnum.OutCancel.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); - + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); _unitOfWorkManage.CommitTran(); @@ -648,7 +679,7 @@ stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); _stockService.StockInfoService.Repository.UpdateData(stockInfo); - locationEnd.LocationStatus= LocationStatusEnum.Free.ObjToInt(); + locationEnd.LocationStatus = LocationStatusEnum.Free.ObjToInt(); _basicService.LocationInfoService.RelocationFree(locationStart, task.TaskNum); _basicService.LocationInfoService.Repository.UpdateData(locationEnd); @@ -666,7 +697,7 @@ } public bool DepthTask(Dt_LocationInfo location) { - if (location != null ) + if (location != null) { Dt_LocationInfo locations = _locationInfoService.Repository.QueryFirst(x => x.RoadwayNo == location.RoadwayNo && x.Column == location.Column && x.Layer == location.Layer && x.Depth != location.Depth && x.Row != location.Row && (SqlFunc.Abs(x.Row - location.Row) == 1)); if (locations != null) @@ -687,7 +718,7 @@ { expression = x => x.Creater == App.User.UserName; } - var task = BaseDal.Db.Queryable<Dt_Task>().OrderByDescending(x => x.CreateDate).Take(10).Select(x => new Dt_Task { TaskNum = x.TaskNum, PalletCode=x.PalletCode, TaskType=x.TaskType,SourceAddress=x.SourceAddress,TargetAddress=x.TargetAddress }).ToList(); + var task = BaseDal.Db.Queryable<Dt_Task>().OrderByDescending(x => x.CreateDate).Take(10).Select(x => new Dt_Task { TaskNum = x.TaskNum, PalletCode = x.PalletCode, TaskType = x.TaskType, SourceAddress = x.SourceAddress, TargetAddress = x.TargetAddress }).ToList(); content = WebResponseContent.Instance.OK(data: task); } catch (Exception ex) -- Gitblit v1.9.3