From b51a65433d6102f2f8f00226404d9ca3808404af Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期四, 02 一月 2025 22:23:17 +0800 Subject: [PATCH] 打印托盘号 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 102 insertions(+), 9 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" index 42c290b..4bb32e3 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" @@ -21,17 +21,20 @@ /// <param name="palletCode">鎵樼洏鍙�</param> /// <param name="stationCode">绔欏彴鍙�</param> /// <returns></returns> - public WebResponseContent RequestInboundTask(string palletCode, string stationCode) + public WebResponseContent RequestInboundTask(SaveModel saveModel) { try { - Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); + var palletCode = saveModel.MainData["barcode"].ToString(); + var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); + var stationCode = saveModel.MainData["startPoint"].ToString(); + Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId); if (task != null) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟"); } - if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskInStatusEnum.InNew.ObjToInt()) != null) + if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) { return WebResponseContent.Instance.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�"); } @@ -41,13 +44,17 @@ { return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�"); } - if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt()) + if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱"); } if (!string.IsNullOrEmpty(stockInfo.LocationCode)) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅"); + } + if (warehouseId != stockInfo.WarehouseId) + { + return WebResponseContent.Instance.Error($"浠撳簱涓嶆纭�"); } Dt_Task newTask = new Dt_Task() @@ -59,18 +66,99 @@ Roadway = "", SourceAddress = stationCode, TargetAddress = "", - TaskType = TaskInboundTypeEnum.Inbound.ObjToInt(), - TaskStatus = TaskInStatusEnum.InNew.ObjToInt(), + TaskType = TaskTypeEnum.Inbound.ObjToInt(), + TaskStatus = TaskStatusEnum.New.ObjToInt(), + WarehouseId = stockInfo.WarehouseId, + PalletType = stockInfo.PalletType }; - stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); - + if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); + } + else + { + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); + } _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); newTask.TaskId = taskId; _stockRepository.StockInfoRepository.UpdateData(stockInfo); _unitOfWorkManage.CommitTran(); + PushTasksToWCS(new List<Dt_Task> { newTask }); + return WebResponseContent.Instance.OK(data: newTask); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode) + { + try + { + Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); + if (task != null) + { + return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟"); + } + + if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) + { + return WebResponseContent.Instance.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�"); + } + + Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); + if (stockInfo == null) + { + return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�"); + } + if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) + { + return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱"); + } + if (!string.IsNullOrEmpty(stockInfo.LocationCode)) + { + return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅"); + } + + Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, (PalletTypeEnum)stockInfo.PalletType, stockInfo.WarehouseId); + if (locationInfo == null) + { + return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅"); + } + + Dt_Task newTask = new Dt_Task() + { + CurrentAddress = stationCode, + Grade = 0, + NextAddress = locationInfo.LocationCode, + PalletCode = palletCode, + Roadway = roadwayNo, + SourceAddress = stationCode, + TargetAddress = locationInfo.LocationCode, + TaskType = TaskTypeEnum.Inbound.ObjToInt(), + TaskStatus = TaskStatusEnum.New.ObjToInt(), + WarehouseId = stockInfo.WarehouseId, + PalletType = stockInfo.PalletType + }; + + if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); + } + else + { + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); + } + _unitOfWorkManage.BeginTran(); + int taskId = BaseDal.AddData(newTask); + newTask.TaskId = taskId; + _stockRepository.StockInfoRepository.UpdateData(stockInfo); + _unitOfWorkManage.CommitTran(); + PushTasksToWCS(new List<Dt_Task> { newTask }); return WebResponseContent.Instance.OK(data: newTask); } catch (Exception ex) @@ -96,6 +184,11 @@ return WebResponseContent.Instance.Error($"鏈壘鍒拌鍏ュ簱浠诲姟"); } + if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) + { + return WebResponseContent.Instance.OK(data: task.TargetAddress); + } + Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, (PalletTypeEnum)task.PalletType, task.WarehouseId); if (locationInfo == null) { @@ -104,7 +197,7 @@ task.Roadway = roadwayNo; task.TargetAddress = locationInfo.LocationCode; - task.TaskStatus = TaskInStatusEnum.SC_InExecute.ObjToInt(); + task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; -- Gitblit v1.9.3