From f51582d5b4b498f28513f215f91828ef181df4a1 Mon Sep 17 00:00:00 2001 From: Huangxiaoqiang-03 <1247017146@qq.com> Date: 星期三, 06 十一月 2024 17:16:09 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 117 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 74 insertions(+), 43 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 e9b04ca..41f4c02 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" @@ -113,22 +113,22 @@ return 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 { - WriteLog.GetLog("浠诲姟瀹屾垚").Write(JsonConvert.SerializeObject(content), "浠诲姟瀹屾垚"); + WriteLog.GetLog("浠诲姟瀹屾垚").Write($"鎿嶄綔浜猴細{(App.User.UserId>0? App.User.UserName: "System")}{ Environment.NewLine}{ JsonConvert.SerializeObject(content)}", "浠诲姟瀹屾垚"); } } public WebResponseContent TaskCancel(int taskNum) @@ -175,12 +175,13 @@ } finally { - WriteLog.GetLog("浠诲姟鍙栨秷").Write(JsonConvert.SerializeObject(content), "浠诲姟鍙栨秷"); + WriteLog.GetLog("浠诲姟鍙栨秷").Write($"鎿嶄綔浜猴細{(App.User.UserId > 0 ? App.User.UserName : "System")}{Environment.NewLine}{JsonConvert.SerializeObject(content)}", "浠诲姟鍙栨秷"); } } public WebResponseContent UpdateTaskStatus(int taskNum) { + WebResponseContent content = new WebResponseContent(); try { Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); @@ -204,10 +205,17 @@ { throw new Exception($"浠诲姟绫诲瀷閿欒,鏈壘鍒拌浠诲姟绫诲瀷,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟绫诲瀷:銆恵task.TaskType}銆�"); } - return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + _unitOfWorkManage.BeginTran(); + task.Dispatchertime = DateTime.Now; + task.ModifyDate = DateTime.Now; + task.Modifier = "System"; + BaseDal.UpdateData(task); + _unitOfWorkManage.CommitTran(); + return content = WebResponseContent.Instance.OK(); } catch (Exception ex) { + _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } @@ -268,13 +276,12 @@ PalletCode = task.PalletCode, LocationCode = task.TargetAddress, StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(), - Creater = App.User.UserId > 0 ? "" : "System", + Creater = App.User.UserId > 0 ? App.User.UserName : "System", CreateDate = App.User.UserId > 0 ? DateTime.Now : DateTime.Now, }; Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); CheckCompleted(stockInfo, locationInfo); - _stockService.StockInfoService.Repository.AddData(stockInfo); @@ -340,21 +347,16 @@ stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); _stockService.StockInfoService.Repository.UpdateData(stockInfo); int beforeStatus = locationInfo.LocationStatus; - if (task.Depth != 1) + if (locationInfo.Depth == 2) { - if (!DepthTask(task)) - { - locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + if (DepthTask(locationInfo) == false) + { _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); - _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + } } - else - { - locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); - //_basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); - _basicService.LocationInfoService.Repository.UpdateData(locationInfo); - } + locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); task.TaskStatus = OutTaskStatusEnum.OutFinish.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); @@ -364,10 +366,11 @@ beforeQuantity = stockInfo.Details.Where(x => x.Id != 0).Sum(x => x.StockQuantity); _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); + _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) { @@ -389,10 +392,15 @@ int beforeStatus = locationInfo.LocationStatus; + if (locationInfo.Depth == 2) + { + if (DepthTask(locationInfo) == false) + { + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + } + } locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); _basicService.LocationInfoService.Repository.UpdateData(locationInfo); - task.TaskStatus = OutTaskStatusEnum.OutFinish.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); @@ -418,12 +426,28 @@ Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); Dt_LocationInfo locationEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + Dt_LocationInfo locationStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); CheckCompleted(stockInfo, locationEnd); stockInfo.LocationCode = locationEnd.LocationCode; stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); _stockService.StockInfoService.Repository.UpdateData(stockInfo); + + if (locationStart.Depth == 1) + { + if (DepthTask(locationStart) == false) + { + locationStart.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.RelocationFree(locationEnd, task.TaskNum); + _basicService.LocationInfoService.Repository.UpdateData(locationStart); + } + else + { + locationStart.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.Repository.UpdateData(locationStart); + } + } _basicService.LocationInfoService.RelocationFree(locationEnd, task.TaskNum); @@ -460,7 +484,10 @@ int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + if (locationInfo.Depth == 2) + { + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + } _basicService.LocationInfoService.Repository.UpdateData(locationInfo); task.TaskStatus = InTaskStatusEnum.InCancel.ObjToInt(); @@ -490,7 +517,10 @@ int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + if (locationInfo.Depth == 2) + { + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + } _basicService.LocationInfoService.Repository.UpdateData(locationInfo); task.TaskStatus = InTaskStatusEnum.InCancel.ObjToInt(); @@ -530,6 +560,13 @@ _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); int beforeStatus = locationInfo.LocationStatus; + if (locationInfo.Depth == 2) + { + if (DepthTask(locationInfo) == false) + { + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), true); + } + } locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); _basicService.LocationInfoService.Repository.UpdateData(locationInfo); @@ -565,8 +602,14 @@ int beforeStatus = locationInfo.LocationStatus; + if (locationInfo.Depth == 2) + { + if (DepthTask(locationInfo) == false) + { + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), true); + } + } locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); - //_basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), true); _basicService.LocationInfoService.Repository.UpdateData(locationInfo); stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); @@ -616,31 +659,19 @@ return WebResponseContent.Instance.Error(ex.Message); } } - public bool DepthTask(Dt_Task task) + public bool DepthTask(Dt_LocationInfo location) { - Dt_LocationInfo location=_locationInfoService.Repository.QueryFirst(x=>x.LocationCode == task.SourceAddress); - if(location != null) + if (location != null ) { - if(location.Row%2==0) + 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) { - Dt_LocationInfo locations = _locationInfoService.Repository.QueryFirst(x => x.Row == location.Row - 1 && x.Layer == location.Layer && x.Column == location.Column && x.RoadwayNo == location.RoadwayNo); - Dt_Task tasks=BaseDal.QueryFirst(x=>x.SourceAddress == locations.LocationCode); - return tasks != null ? true : false; - } - else - { - Dt_LocationInfo locations = _locationInfoService.Repository.QueryFirst(x => x.Row == location.Row + 1 && x.Layer == location.Layer && x.Column == location.Column && x.RoadwayNo == location.RoadwayNo); Dt_Task tasks = BaseDal.QueryFirst(x => x.SourceAddress == locations.LocationCode); return tasks != null ? true : false; } } - else - { - return false; - } - + return false; } - public WebResponseContent GetTaskInfo() { WebResponseContent content = new WebResponseContent(); -- Gitblit v1.9.3