From f82511343cf2c8ecf3981954e7eb92172d72a905 Mon Sep 17 00:00:00 2001 From: Huangxiaoqiang-03 <1247017146@qq.com> Date: 星期二, 05 十一月 2024 17:26:08 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 123 +++++++++++++++++++++++++++------------- 1 files changed, 83 insertions(+), 40 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 c711405..e9b04ca 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" @@ -17,6 +17,7 @@ using AutoMapper; using MailKit.Search; +using Newtonsoft.Json; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using SqlSugar; using System; @@ -25,6 +26,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Linq.Expressions; +using System.Net.Http.Headers; using System.Reflection; using System.Reflection.Metadata; using System.Text; @@ -34,6 +36,7 @@ using WIDESEA_Core.BaseServices; using WIDESEA_Core.Enums; using WIDESEA_Core.Helper; +using WIDESEA_Core.Log; using WIDESEA_DTO.Inbound; using WIDESEA_DTO.Stock; using WIDESEA_IBasicRepository; @@ -86,6 +89,7 @@ /// <returns>杩斿洖澶勭悊缁撴灉</returns> public WebResponseContent TaskCompleted(int taskNum) { + WebResponseContent content = new WebResponseContent(); try { Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); @@ -93,45 +97,85 @@ { return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); } + _unitOfWorkManage.BeginTran(); MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); if (methodInfo != null) { WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); if (responseContent != null) { - return responseContent; + 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; } } - return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); } catch (Exception ex) { - return WebResponseContent.Instance.Error(ex.Message); + _unitOfWorkManage.RollbackTran(); + return content=WebResponseContent.Instance.Error(ex.Message); + } + finally + { + WriteLog.GetLog("浠诲姟瀹屾垚").Write(JsonConvert.SerializeObject(content), "浠诲姟瀹屾垚"); } } public WebResponseContent TaskCancel(int taskNum) { + WebResponseContent content = new WebResponseContent(); try { Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); if (task == null) { - return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); + return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); } + _unitOfWorkManage.BeginTran(); MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCancel"); if (methodInfo != null) { WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); if (responseContent != null) { - return responseContent; + if (responseContent != null) + { + if (App.User.UserId > 0) + { + var response = HttpHelper.Post<WebResponseContent>(url + "TaskCancel?taskNum=" + task.TaskNum, "", "浠诲姟鍙栨秷"); + if (!response.Status) + { + _unitOfWorkManage.RollbackTran(); + return content=WebResponseContent.Instance.Error(response.Message); + } + _unitOfWorkManage.CommitTran(); + return content=responseContent; + } + _unitOfWorkManage.CommitTran(); + return content=responseContent; + } } } - return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); } catch (Exception ex) { - return WebResponseContent.Instance.Error(ex.Message); + _unitOfWorkManage.RollbackTran(); + return content=WebResponseContent.Instance.Error(ex.Message); + } + finally + { + WriteLog.GetLog("浠诲姟鍙栨秷").Write(JsonConvert.SerializeObject(content), "浠诲姟鍙栨秷"); } } @@ -196,7 +240,7 @@ 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); + _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound,task.TaskNum); _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); } @@ -224,8 +268,8 @@ PalletCode = task.PalletCode, LocationCode = task.TargetAddress, StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(), - Creater = App.User.UserId == 0 ? "" : "WCS", - CreateDate = App.User.UserId == 0 ? DateTime.Now : DateTime.Now, + Creater = App.User.UserId > 0 ? "" : "System", + CreateDate = App.User.UserId > 0 ? DateTime.Now : DateTime.Now, }; Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); @@ -296,11 +340,10 @@ stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); _stockService.StockInfoService.Repository.UpdateData(stockInfo); int beforeStatus = locationInfo.LocationStatus; - if (task.Depth == 1) + if (task.Depth != 1) { - if (DepthTask(task)) { } - else - { + if (!DepthTask(task)) + { locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); _basicService.LocationInfoService.Repository.UpdateData(locationInfo); @@ -309,7 +352,7 @@ else { locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + //_basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); _basicService.LocationInfoService.Repository.UpdateData(locationInfo); } @@ -321,7 +364,7 @@ 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); + _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(); @@ -410,7 +453,6 @@ CheckCompleted(stockInfo, locationInfo); - stockInfo.LocationCode = locationInfo.LocationCode; stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(); _stockService.StockInfoService.Repository.UpdateData(stockInfo); @@ -474,6 +516,7 @@ _unitOfWorkManage.BeginTran(); decimal beforeQuantity = 0; Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id); Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); @@ -481,23 +524,15 @@ stockInfo.LocationCode = locationInfo.LocationCode; stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + stockInfoDetail.OutboundQuantity = beforeQuantity; + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); int beforeStatus = locationInfo.LocationStatus; - if (task.Depth == 1) - { - if (!DepthTask(task)) - { - locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); - _basicService.LocationInfoService.Repository.UpdateData(locationInfo); - } - } - else - { - locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); - _basicService.LocationInfoService.Repository.UpdateData(locationInfo); - } + + locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + task.TaskStatus = OutTaskStatusEnum.OutCancel.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); @@ -505,10 +540,10 @@ 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); + _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(); + return WebResponseContent.Instance.OK(); } catch (Exception ex) { @@ -531,14 +566,15 @@ int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + //_basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), true); _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); task.TaskStatus = OutTaskStatusEnum.OutCancel.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); - _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); - + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); _unitOfWorkManage.CommitTran(); @@ -560,6 +596,9 @@ Dt_LocationInfo locationEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); Dt_LocationInfo locationStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); locationEnd.LocationStatus= LocationStatusEnum.Free.ObjToInt(); _basicService.LocationInfoService.RelocationFree(locationStart, task.TaskNum); @@ -584,18 +623,22 @@ { if(location.Row%2==0) { - 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_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_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; } } - return false; + else + { + return false; + } + } public WebResponseContent GetTaskInfo() -- Gitblit v1.9.3