From 2ae5aa151f7b40a082e34aa7ed22b4b64edd1d3c Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期三, 11 六月 2025 17:13:56 +0800 Subject: [PATCH] 修改堆垛机通讯协议及交互逻辑 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs | 118 +++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 66 insertions(+), 52 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" index d2c5191..dae6e2e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" @@ -8,11 +8,23 @@ using WIDESEA_Core; using WIDESEA_Model.Models; using WIDESEA_Core.Helper; +using Microsoft.Extensions.Logging; +using System.Net.Http.Headers; +using System.Security.Policy; +using Newtonsoft.Json; namespace WIDESEA_TaskInfoService { public partial class TaskService { + /// <summary> + /// WCS IP鍦板潃 + /// </summary> + public string url = AppSettings.Configuration["WCS"]; + /// <summary> + /// AGV IP鍦板潃 + /// </summary> + public string AGVurl = AppSettings.Configuration["AGV"]; /// <summary> /// PDA鐢宠鍏ュ簱--鍫嗗灈鏈虹珛搴撳叆搴� /// </summary> @@ -36,7 +48,7 @@ { return WebResponseContent.Instance.Error("鏈壘鍒拌浠诲姟绫诲瀷涓氬姟"); } - return WebResponseContent.Instance.Error("閿欒"); + return WebResponseContent.Instance.Error($"閿欒"); } /// <summary> @@ -56,7 +68,7 @@ } catch (Exception ex) { - content = WebResponseContent.Instance.Error(ex.Message); + content = WebResponseContent.Instance.Error($"{ex.Message}"); } return content; } @@ -72,14 +84,14 @@ WebResponseContent content = new WebResponseContent(); try { - Dt_StockInfo stockInfo = _stockInfoService.Repository.GetStockInfo(palletCode); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode); (bool, string) result = CheckRequestInbound(stationCode, palletCode, true, stockInfo); if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); content = AssignLocUpdateData(stationCode, TaskTypeEnum.Inbound.ObjToInt(), palletCode, true, stockInfo); } catch (Exception ex) { - content = WebResponseContent.Instance.Error(ex.Message); + content = WebResponseContent.Instance.Error($"{ex.Message}"); } return content; } @@ -99,13 +111,15 @@ WebResponseContent content = new WebResponseContent(); try { - Dt_LocationInfo? locationInfo = _locationInfoService.AssignLocation(stationCode, taskType); + _unitOfWorkManage.BeginTran(); + Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(stationCode, taskType); if (locationInfo != null) { + List<Dt_Task> tasks = new List<Dt_Task>(); Dt_Task task = new() { CurrentAddress = stationCode, - Grade = 0, + Grade = 2, PalletCode = palletCode, NextAddress = locationInfo.LocationCode, Roadway = locationInfo.RoadwayNo, @@ -113,36 +127,65 @@ TargetAddress = locationInfo.LocationCode, TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), TaskType = taskType, + Depth = locationInfo.Depth, }; BaseDal.AddData(task); int beforeStatus = locationInfo.LocationStatus; - locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); if (isUpdateStock) { locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + if (locationInfo.Depth == 2) + { + _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + } + if (stockInfo != null && stockInfo.Details != null && stockInfo.Details.Count > 0) { orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); - _stockInfoService.Repository.UpdateData(stockInfo); + stockInfo.Details.ForEach(x => + { + x.Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(); + }); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details); } else { - return content = WebResponseContent.Instance.Error("鏈壘鍒板簱瀛樹俊鎭�"); + return content.Error("鏈壘鍒板簱瀛樹俊鎭�"); } } - _locationInfoService.Repository.UpdateData(locationInfo); - _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), orderNo, task.TaskNum); + else + { + locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); + if (locationInfo.Depth == 2) + { + _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + } + task.Grade = 1; + } + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); - return content = WebResponseContent.Instance.OK(); + tasks.Add(task); + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), orderNo, task.TaskNum); + + var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", tasks, "鍏ュ簱浠诲姟涓嬪彂"); + if (!response.Status) + { + _unitOfWorkManage.RollbackTran(); + return content.Error($"{response.Message}"); + } + _unitOfWorkManage.CommitTran(); + return content.OK(); } - return content = WebResponseContent.Instance.Error("鏈壘鍒板彲鍒嗛厤璐т綅"); + return content.Error("鏈壘鍒板彲鍒嗛厤璐т綅"); } catch (Exception ex) { - content = WebResponseContent.Instance.Error(ex.Message); + _unitOfWorkManage.RollbackTran(); + content.Error(ex.Message); } return content; } @@ -159,71 +202,42 @@ { if (BaseDal.QueryFirst(x => x.PalletCode == palletCode) != null) { - return (false, "璇ユ墭鐩樺彿宸叉湁浠诲姟"); + return (false, "璇ユ墭鐩樺彿宸叉湁浠诲姟!"); } if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null) { - return (false, "褰撳墠鍏ュ簱绔欏彴宸叉湁涓�鏉℃柊寤轰换鍔�"); + return (false, "褰撳墠鍏ュ簱绔欏彴宸叉湁涓�鏉℃柊寤轰换鍔�!"); } if (isCheckStock) { if (stockInfo == null) { - return (false, "鏈壘鍒扮粍鐩樹俊鎭�"); + return (false, "鏈壘鍒扮粍鐩樹俊鎭�!"); } if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt()) { - return (false, "璇ョ粍鐩樼姸鎬佷笉鍙叆搴�"); + return (false, "璇ョ粍鐩樼姸鎬佷笉鍙叆搴�!"); } if (!string.IsNullOrEmpty(stockInfo.LocationCode)) { - return (false, "璇ユ墭鐩樺凡缁戝畾璐т綅"); + return (false, "璇ユ墭鐩樺凡缁戝畾璐т綅!"); } if (stockInfo.Details == null || stockInfo.Details.Count == 0) { - return (false, "娌℃湁搴撳瓨鏄庣粏淇℃伅"); + return (false, "娌℃湁搴撳瓨鏄庣粏淇℃伅!"); } } else { - if (_stockInfoService.Repository.QueryFirst(x => x.PalletCode == palletCode) != null) + if (_stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == palletCode) != null) { - return (false, "璇ユ墭鐩樺凡瀛樺湪搴撳唴"); + return (false, "璇ユ墭鐩樺凡瀛樺湪搴撳唴!"); } } - return (true, "鎴愬姛"); + return (true, "鎴愬姛!"); } - /// <summary> - /// 绌烘墭鐩樺叆搴撳畬鎴愬鐞� - /// </summary> - /// <param name="task">浠诲姟瀹炰綋瀵硅薄</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent PalletInboundTaskCompleted(Dt_Task task) - { - Dt_StockInfo stockInfo = new Dt_StockInfo() - { - PalletCode = task.PalletCode, - LocationCode = task.TargetAddress, - StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt() - }; - Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); - CheckInboundCompleted(stockInfo, locationInfo); - - _stockInfoService.Repository.AddData(stockInfo); - - int beforeStatus = locationInfo.LocationStatus; - locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); - _locationInfoService.Repository.UpdateData(locationInfo); - - - BaseDal.DeleteData(task); - - _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); - - return WebResponseContent.Instance.OK(); - } } } -- Gitblit v1.9.3