From 1dd9f4bf540a74a7de2daeeebf38491f86befa08 Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期三, 27 十一月 2024 09:31:07 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 360 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 250 insertions(+), 110 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" index 30a8f5e..1e2240c 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" @@ -20,6 +20,7 @@ using NetTaste; using Newtonsoft.Json; using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using SqlSugar; using System; @@ -31,9 +32,12 @@ using System.Linq.Expressions; using System.Reflection; using System.Reflection.Metadata; +using System.Security.Policy; using System.Text; using System.Threading.Tasks; using WIDESEA_Comm.Http; +using WIDESEA_Common.Log; +using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_Core.Enums; @@ -42,7 +46,6 @@ using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; -using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Service; @@ -78,12 +81,19 @@ } public string urlWMSTask = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlWMSTask"]; + public string urlTaskCompleted = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlTaskCompleted"]; + public string urlWMSMovelibraryTask = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlWMSMovelibraryTask"]; + public string urlRelocationTaskCompleted = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlRelocationTaskCompleted"]; + public string urlQueryinventory = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlQueryinventory"]; + public string urlEmptyOutbound = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlEmptyOutbound"]; + public string urlRawmaterialout = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlRawmaterialout"]; + public string urlPalletQueryinventory = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlPalletQueryinventory"]; /// <summary> /// 鎺ユ敹WMS浠诲姟淇℃伅 /// </summary> /// <param name="taskDTOs">WMS浠诲姟瀵硅薄闆嗗悎</param> /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent ReceiveWMSTask([NotNull]List<WMSTaskDTO> taskDTOs) + public WebResponseContent ReceiveWMSTask([NotNull]List<Dt_Task> taskDTOs) { WebResponseContent content = new WebResponseContent(); try @@ -96,52 +106,9 @@ continue; } Dt_Task task = _mapper.Map<Dt_Task>(item); - task.Creater = "WMS"; - if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) - { - task.TaskNum = item.TaskNum; - task.TaskType = item.TaskType; - task.TaskState = (int)TaskOutStatusEnum.OutNew; - task.SourceAddress = item.SourceAddress; - task.TargetAddress = item.TargetAddress; - task.PalletCode = item.PalletCode; - task.Roadway = item.RoadWay; - task.CreateDate = DateTime.Now; - task.Grade = 1; - task.CurrentAddress = item.SourceAddress; - task.NextAddress = item.TargetAddress; - task.ModifyDate = DateTime.Now; - } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) - { - task.TaskNum = item.TaskNum; - task.TaskType = item.TaskType; - task.TaskState = (int)TaskInStatusEnum.Line_InFinish; - task.SourceAddress = item.SourceAddress; - task.TargetAddress = item.TargetAddress; - task.PalletCode = item.PalletCode; - task.Roadway = item.RoadWay; - task.CreateDate = DateTime.Now; - task.Grade = 1; - task.CurrentAddress = item.SourceAddress; - task.NextAddress = item.TargetAddress; - task.ModifyDate = DateTime.Now; - }else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) - { - task.TaskNum = item.TaskNum; - task.TaskType = item.TaskType; - task.TaskState = (int)TaskOutStatusEnum.OutNew; - task.SourceAddress = item.SourceAddress; - task.TargetAddress = item.TargetAddress; - task.PalletCode = item.PalletCode; - task.Roadway = item.RoadWay; - task.CreateDate = DateTime.Now; - task.Grade = 1; - task.CurrentAddress = item.SourceAddress; - task.NextAddress = item.TargetAddress; - task.ModifyDate = DateTime.Now; - } - tasks.Add(task); + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02"; + tasks.Add(task); } BaseDal.AddData(tasks); _taskExecuteDetailService.AddTaskExecuteDetail(tasks.Select(x => x.TaskNum).ToList(), "鎺ユ敹WMS浠诲姟"); @@ -151,6 +118,10 @@ { content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}"); } + finally + { + WriteLog.GetLog("鎺ユ敹浠诲姟").Write(JsonConvert.SerializeObject(content), "鎺ユ敹浠诲姟"); + } return content; } @@ -160,39 +131,88 @@ /// <param name="palletCode">鎵樼洏鍙�</param> /// <param name="sourceAddress">璧峰鍦板潃</param> /// <returns></returns> + public class GenerateInv + { + public string SourceAddress { get; set; } + public string PalletCode { get; set; } + } + + public class GenerateInv3 + { + + public string PalletCode { get; set; } + public int outCount { get; set; } + public string TargetAddress { get; set; } + } public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress) { WebResponseContent content = new WebResponseContent(); try { - - /*WMSTaskDTO taskDTO = new WMSTaskDTO() + GenerateInv generate = new GenerateInv() { - TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), - Grade = 1, - PalletCode = palletCode, - SourceAddress = sourceAddress, + SourceAddress=sourceAddress, + PalletCode = palletCode }; - var response = HttpHelper.Post<WebResponseContent>(urlWMSTask, taskDTO, "鐢熸垚浠诲姟");*/ - WMSTaskDTO taskDTO = new WMSTaskDTO() + content = HttpHelper.Post<WebResponseContent>($"{urlWMSTask}", generate); + Dt_Task task = new Dt_Task(); + if (content != null) { - TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), - Grade = 1, - PalletCode = palletCode, - RoadWay = "SC01", - SourceAddress = sourceAddress, - TargetAddress = "SC01", - TaskState = (int)TaskInStatusEnum.InNew, - Id = 0, - TaskType = (int)TaskInboundTypeEnum.Inbound - }; - + if (content.Status) + { + task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString()); + task.TaskState = (int)TaskInStatusEnum.Line_InFinish; + task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02"; + BaseDal.AddData(task); + return content = WebResponseContent.Instance.Error(); + } + } + return content = WebResponseContent.Instance.Error(); } catch (Exception ex) { - content = WebResponseContent.Instance.Error(ex.Message); + return content = WebResponseContent.Instance.Error(ex.Message); } - return content; + } + /// <summary> + /// 杩涜缁勭洏 + /// </summary> + /// <param name="palletCode"></param> + /// <returns></returns> + public WebResponseContent ToPlatform(string palletCode) + { + try + { + WebResponseContent content = new WebResponseContent(); + GenerateInv generate = new GenerateInv() + { + SourceAddress = "", + PalletCode = palletCode + }; + + return content = HttpHelper.Post<WebResponseContent>($"{urlQueryinventory}", generate); + } + catch (Exception ex) + { + + throw; + } + + /*WebResponseContent content = new WebResponseContent(); + GenerateInv generate = new GenerateInv() + { + SourceAddress = "", + PalletCode = palletCode + }; + content = HttpHelper.Post<WebResponseContent>($"{urlQueryinventory}", generate); + if (content != null) + { + if (content.Status) + { + return content; + } + } + return content = WebResponseContent.Instance.Error();*/ } /// <summary> @@ -201,33 +221,129 @@ /// <param name="palletCode">鎵樼洏鍙�</param> /// <param name="sourceAddress">璧峰鍦板潃</param> /// <returns></returns> - public WebResponseContent RequestWMSTask2() + public WebResponseContent RequestWMSTask2(string palletCode,string sourceAddress) { WebResponseContent content = new WebResponseContent(); try { - //娴嬭瘯 - WMSTaskDTO taskDTO2 = new WMSTaskDTO() + GenerateInv generate = new GenerateInv() { - TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), - Grade = 1, - PalletCode = "PalletCode20241030162310", - SourceAddress = "087-056-056", - RoadWay = "SC01", - TargetAddress = "102", - TaskState = (int)TaskRelocationStatusEnum.RelocationNew, - Id = 0, - TaskType = (int)TaskRelocationTypeEnum.Relocation, - - + SourceAddress = sourceAddress, + PalletCode = palletCode }; - content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO2 }); + content = HttpHelper.Post<WebResponseContent>($"{urlEmptyOutbound}", generate); + Dt_Task task = new Dt_Task(); + if (content != null) + { + if (content.Status) + { + task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString()); + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.TaskType = (int)TaskOutboundTypeEnum.Outbound; + task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02"; + BaseDal.AddData(task); + return content = WebResponseContent.Instance.OK(); + } + } + return content = WebResponseContent.Instance.Error(); } catch (Exception ex) { - content = WebResponseContent.Instance.Error(ex.Message); + return content = WebResponseContent.Instance.Error(ex.Message); } - return content; + } + + /// <summary> + /// 鏍规嵁鎵樼洏鍙枫�佽捣濮嬪湴鍧�鍚慦MS璇锋眰浠诲姟 + /// </summary> + /// <param name="palletCode">鎵樼洏鍙�</param> + /// <param name="sourceAddress">璧峰鍦板潃</param> + /// <returns></returns> + public WebResponseContent RequestWMSTask3(string palletCode, int outCount,string Loc) + { + WebResponseContent content = new WebResponseContent(); + try + { + if (outCount==0) + { + outCount = 1; + } + GenerateInv3 generate = new GenerateInv3() + { + PalletCode = palletCode, + outCount = outCount, + TargetAddress= Loc + }; + content = HttpHelper.Post<WebResponseContent>($"{urlRawmaterialout}", generate); + Dt_Task task = new Dt_Task(); + if (content != null) + { + if (content.Status) + { + task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString()); + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.TaskType = (int)TaskOutboundTypeEnum.Outbound; + task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02"; + BaseDal.AddData(task); + return content = WebResponseContent.Instance.OK(); + } + } + return content = WebResponseContent.Instance.Error(); + } + catch (Exception ex) + { + return content = WebResponseContent.Instance.Error(ex.Message); + } + } + + + public WebResponseContent RequestWMSTask4() + { + WebResponseContent content = new WebResponseContent(); + try + { + + return content = HttpHelper.Get<WebResponseContent>($"{urlPalletQueryinventory}"); + } + catch (Exception ex) + { + return content = WebResponseContent.Instance.Error(ex.Message); + } + } + /// <summary> + /// 鏍规嵁娣卞簱浣嶅悜wms鐢宠鍒ゆ柇娴呭簱浣嶆槸鍚︽湁璐э紝鏄惁闇�瑕佽繘琛岀Щ搴撴搷浣� + /// </summary> + /// <param name="palletCode">鎵樼洏鍙�</param> + /// <param name="sourceAddress">璧峰鍦板潃</param> + /// <returns></returns> + public Dt_Task RequestWMSTaskMovelibrary(Dt_Task _Task) + { + WebResponseContent content = new WebResponseContent(); + content = HttpHelper.Get<WebResponseContent>($"{urlWMSMovelibraryTask}?TaskNum={_Task.TaskNum}&SourceAddress={_Task.SourceAddress}"); + Dt_Task task = new Dt_Task(); + if (content != null) + { + if (content.Status) + { + if(content.Data != null) + { + task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString()); + if (task.TaskNum != _Task.TaskNum) + { + + task.TaskState = (int)TaskRelocationTypeEnum.Relocation; + task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02"; + task.TaskNum = task.TaskNum; + task.Grade = 3; + task.TaskType= (int)TaskRelocationTypeEnum.Relocation; + BaseDal.AddData(task); + return task; + } + } + } + } + + return _Task; } /// <summary> @@ -293,6 +409,17 @@ else return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.CurrentAddress == currentAddress && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew), TaskOrderBy); } + public Dt_Task IngStackerCraneTask(string deviceNo) + { + //string deviceNot = deviceNo == "SC01" ? "1" : "2"; + return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskState == (int)TaskInStatusEnum.SC_InExecuting); + } + + public Dt_Task IngStackerCraneTask2(string deviceNo) + { + //string deviceNot = deviceNo == "SC01" ? "1" : "2"; + return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting); + } /// <summary> /// 鏍规嵁璁惧缂栧彿銆佸綋鍓嶅湴鍧�鎸夌収浼樺厛绾т互鍙婂垱寤烘椂闂存帓搴忔煡璇换鍔℃睜鍏ュ簱绫诲瀷鐨勬柊澧炵殑浠诲姟 @@ -331,6 +458,17 @@ public List<Dt_Task> QueryStackerCraneOutTasks(string deviceNo, List<string> outStationCodes) { return BaseDal.QueryData(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew && outStationCodes.Contains(x.CurrentAddress), TaskOrderBy); + } + + /// <summary> + /// 鏍规嵁鍑哄簱璐т綅鏌ヨ鏄惁鏈夊綋鍓嶆祬璐т綅浠诲姟 + /// </summary> + /// <param name="deviceNo">璁惧缂栧彿</param> + /// <param name="currentAddress">褰撳墠鍦板潃</param> + /// <returns>杩斿洖浠诲姟瀹炰綋瀵硅薄闆嗗悎锛屽彲鑳戒负null</returns> + public List<Dt_Task> QueryStationIsOccupiedOutTasks(string deviceNo, string SourceAddress) + { + return BaseDal.QueryData(x => x.Roadway == deviceNo && SourceAddress.Contains(x.SourceAddress), TaskOrderBy); } /// <summary> @@ -413,7 +551,7 @@ try { int oldState = task.TaskState; - if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) { if (task.TaskState >= (int)TaskOutStatusEnum.OutFinish) { @@ -428,7 +566,7 @@ task.Dispatchertime = DateTime.Now; } } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) + else if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) { if (task.TaskState >= (int)TaskInStatusEnum.InFinish) { @@ -441,7 +579,7 @@ { task.Dispatchertime = DateTime.Now; } - if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) + if (task.TaskState == (int)TaskRelocationTypeEnum.Relocation) { Random random = new Random(); task.CurrentAddress = task.NextAddress; @@ -449,7 +587,7 @@ task.TargetAddress = task.NextAddress; } } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) + else if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) { if (task.TaskState <= (int)TaskRelocationStatusEnum.SC_RelocationFinish) { @@ -530,6 +668,12 @@ /// </summary> /// <param name="taskNum">浠诲姟缂栧彿</param> /// <returns>杩斿洖澶勭悊缁撴灉</returns> + public class GenerateInv2 + { + public string PalletCode { get; set; } + public string SourceAddress { get; set; } + public string TargetAddress { get; set; } + } public WebResponseContent StackCraneTaskCompleted(int taskNum) { WebResponseContent content = new WebResponseContent(); @@ -538,11 +682,12 @@ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); if (task == null) return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅,浠诲姟鍙�:銆恵taskNum}銆�"); - if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) + if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) { - List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); - if (!routers.Any()) return WebResponseContent.Instance.Error($"鏈壘鍒拌澶囪矾鐢变俊鎭�"); + /*List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); + if (!routers.Any()) return WebResponseContent.Instance.Error($"鏈壘鍒拌澶囪矾鐢变俊鎭�");*/ + content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}"); task.TaskState = (int)TaskOutStatusEnum.OutFinish; task.ModifyDate = DateTime.Now; BaseDal.DeleteData(task); @@ -552,8 +697,9 @@ //鏆備笉鑰冭檻澶氫釜鍑哄簱鍙� } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) + else if (task.TaskType == (int)TaskInboundTypeEnum.Inbound && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) { + content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}"); //todo //int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); task.TaskState = (int)TaskInStatusEnum.InFinish; @@ -563,28 +709,22 @@ _task_HtyService.AddTaskHty(task); _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍏ュ簱瀹屾垚"); - WMSTaskDTO taskDTO = new WMSTaskDTO() - { - TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), - Grade = 1, - PalletCode = task.PalletCode + "S", - RoadWay = "SC01", - SourceAddress = task.TargetAddress, - TargetAddress = "CLOutAreaA", - TaskState = (int)TaskOutStatusEnum.OutNew, - Id = 0, - TaskType = (int)TaskOutboundTypeEnum.Outbound - }; - - content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) + else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation) { + GenerateInv2 generate = new GenerateInv2() + { + PalletCode = task.PalletCode, + SourceAddress = task.SourceAddress, + TargetAddress = task.TargetAddress + + }; + content = HttpHelper.Post<WebResponseContent>($"{urlRelocationTaskCompleted}", generate); task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; task.ModifyDate = DateTime.Now; BaseDal.DeleteData(task); _task_HtyService.AddTaskHty(task); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍑哄簱瀹屾垚"); + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"绉诲簱瀹屾垚"); } else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup) { -- Gitblit v1.9.3