From 2d9272bdcdbdbca81396a61493e4ef6a822dcf4a Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期四, 24 七月 2025 14:21:33 +0800 Subject: [PATCH] 代码提交 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 124 ++++++++++++++++++++++++++++------------ 1 files changed, 86 insertions(+), 38 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" index fdf9e8d..2fdd7d6 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" @@ -20,6 +20,7 @@ using Newtonsoft.Json; using SqlSugar; using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; using WIDESEA_Comm.Http; using WIDESEA_Common.Log; using WIDESEAWCS_Common; @@ -41,6 +42,7 @@ using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.DeviceBase; using WIDESEAWCS_QuartzJob.Models; +using WIDESEAWCS_QuartzJob.Repository; using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_TaskInfoRepository; @@ -55,6 +57,7 @@ private readonly ITask_HtyRepository _taskHtyRepository; private readonly ISys_ConfigService _sys_ConfigService; private readonly IMapper _mapper; + private readonly IDeviceInfoRepository _deviceInfoRepository; private readonly IDt_StationManagerRepository _stationManagerRepository; @@ -71,7 +74,8 @@ public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList(); public List<int> TaskRelocationboundTypes => typeof(TaskRelocationTypeEnum).GetEnumIndexList(); - public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService taskHtyService, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository taskHtyRepository) : base(BaseDal) + public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService taskHtyService, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository taskHtyRepository, + IDeviceInfoRepository deviceInfoRepository) : base(BaseDal) { _routerService = routerService; _taskExecuteDetailService = taskExecuteDetailService; @@ -82,6 +86,7 @@ _taskHtyRepository = taskHtyRepository; _mapper = mapper; _sys_ConfigService = sys_ConfigService; + _deviceInfoRepository = deviceInfoRepository; } /// <summary> @@ -98,20 +103,48 @@ // 閬嶅巻浼犲叆鐨刉MSTaskDTO鍒楄〃 foreach (var item in taskDTOs) { - - var task = BaseDal.QueryFirst(x => x.WMSTaskNum == item.TaskId || x.PalletCode == item.TPbarcode); - if (task != null) - { - task.Creater = "WMS"; - task.Grade = 1; - task.PalletCode = item.TPbarcode; - } - // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄嚭搴撲换鍔� if (item.TaskType == "2") { string[] targetCodes = item.BeginPoint.Split("-"); - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2); + + Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode==item.EndPoint); + if (stationManagerEnd == null) + { + return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�"); + } + + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2 && x.stationFloor == stationManagerEnd.stationFloor); + + var RGVName = string.Empty; + if (stationManager.stationFloor == "1F") + { + var deviceCode = _deviceInfoRepository.Db.Queryable<Dt_DeviceInfo>().Where(x => x.DeviceStatus == "1" && x.DeviceRemark == "OneFloor").Where(x => x.DeviceCode.Contains("RGV")).ToList().Select(x => x.DeviceCode).ToList(); + if (deviceCode != null && deviceCode.Count() > 0) + { + if (deviceCode.Contains("RGV01")&& deviceCode.Contains("RGV02")) + { + var RGVOne = BaseDal.QueryData(x => x.RGVName == "RGV01").ToList(); + var RGVTwo = BaseDal.QueryData(x => x.RGVName == "RGV02").ToList(); + if (RGVOne.Count > RGVTwo.Count) + { + RGVName = "RGV01"; + } + else + { + RGVName = "RGV02"; + } + } + else + { + RGVName = deviceCode[0]; + } + } + else + { + RGVName = "RGV01"; + } + } Dt_Task taskOut = new Dt_Task() { TaskNum = BaseDal.GetTaskNo().Result, @@ -126,13 +159,21 @@ Roadway = GetScCode(Convert.ToInt32(targetCodes[0])), NextAddress = stationManager.stationChildCode, TargetAddress = item.EndPoint, - RGVName = "RGV01" + RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName, + Floor= stationManager.stationFloor, }; BaseDal.AddData(taskOut); } // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄叆搴撲换鍔� else if (item.TaskType == "1") { + var task = BaseDal.QueryFirst(x => x.PalletCode == item.TPbarcode); + if (task != null) + { + task.Creater = "WMS"; + task.Grade = 1; + task.PalletCode = item.TPbarcode; + task.TaskType = (int)TaskInboundTypeEnum.Inbound; task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish; @@ -151,24 +192,32 @@ task.NextAddress = stationManager.stationChildCode; BaseDal.UpdateData(task); + } + else + { + return content.Error($"鏈壘鍒拌鎵樼洏銆恵item.TPbarcode}銆戜换鍔�"); + } } else if (item.TaskType == "3") { - task.TaskType = (int)TaskRelocationTypeEnum.Relocation; + Dt_Task taskRelocation = new Dt_Task() + { + TaskType = (int)TaskRelocationTypeEnum.Relocation, - task.TaskState = (int)TaskRelocationStatusEnum.RelocationNew; + TaskState = (int)TaskRelocationStatusEnum.RelocationNew, - task.SourceAddress = item.BeginPoint; + SourceAddress = item.BeginPoint, - task.CurrentAddress = item.BeginPoint; + CurrentAddress = item.BeginPoint, - task.NextAddress = item.EndPoint; + NextAddress = item.EndPoint, - task.TargetAddress = item.EndPoint; + TargetAddress = item.EndPoint, - task.Grade = 3; + Grade = 3, - BaseDal.AddData(tasks); + }; + BaseDal.AddData(taskRelocation); } else { @@ -317,7 +366,7 @@ /// <param name="deviceNo">璁惧缂栧彿</param> /// <param name="currentAddress">褰撳墠鍦板潃</param> /// <returns></returns> - public Dt_Task QueryConveyorLineTask(string currentAddress) + public Dt_Task QueryConveyorLineTask(string currentAddress,int taskNum) { Dt_Task task= BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.RGV_InExecutingFinish && x.CurrentAddress == currentAddress, TaskOrderBy); if (task == null) @@ -333,12 +382,12 @@ /// <param name="deviceNo">璁惧缂栧彿</param> /// <param name="currentAddress">褰撳墠鍦板潃</param> /// <returns></returns> - public Dt_Task QueryConveyorLineFinishTask(string currentAddress) + public Dt_Task QueryConveyorLineFinishTask(string currentAddress,int taskNum) { - Dt_Task task = BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.NextAddress == currentAddress, TaskOrderBy); + Dt_Task task = BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.NextAddress == currentAddress && x.TaskNum == taskNum, TaskOrderBy); if (task == null) { - task = BaseDal.QueryFirst(x => TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && x.NextAddress == currentAddress, TaskOrderBy); + task = BaseDal.QueryFirst(x => TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && x.CurrentAddress == currentAddress && x.TaskNum == taskNum, TaskOrderBy); } return task; } @@ -540,6 +589,12 @@ BaseDal.DeleteData(task); _taskHtyRepository.AddData(task_Hty); } + if (task.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting) + { + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode == task.NextAddress); + task.CurrentAddress = task.NextAddress; + task.NextAddress = task.TargetAddress; + } if (task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) { @@ -551,13 +606,8 @@ { int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); task.TaskState = nextStatus; - if (task.TaskState == (int)TaskInStatusEnum.Line_InExecuting) - { - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode== task.NextAddress); - task.CurrentAddress = task.NextAddress; - task.NextAddress = stationManager.stationNextChildCode; - } - else if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) + + if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish) { task.CurrentAddress = task.NextAddress; task.NextAddress = task.TargetAddress; @@ -644,10 +694,10 @@ } else if (task.TaskState == (int)TaskInStatusEnum.RGV_InExecuting) { - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress); + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress && x.stationFloor == task.Floor); task.TaskState = (int)TaskInStatusEnum.RGV_InExecutingFinish; - task.NextAddress = stationManager.stationNextChildCode; task.CurrentAddress = task.NextAddress; + task.NextAddress = stationManager.stationNextChildCode; task.ModifyDate = DateTime.Now; BaseDal.UpdateData(task); _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"RGV鍏ュ簱瀹屾垚"); @@ -661,7 +711,7 @@ } else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting) { - task.TaskState = (int)TaskOutStatusEnum.RGV_OutFinish; + task.TaskState = (int)TaskOutStatusEnum.OutFinish; task.ModifyDate = DateTime.Now; task.Modifier = "System"; @@ -722,7 +772,7 @@ { task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2); + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor); task.CurrentAddress = task.NextAddress; @@ -734,9 +784,7 @@ } else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) { - //todo 鍚屾鍒癢MS - int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); - task.TaskState = nextStatus; + task.TaskState = (int)TaskInStatusEnum.InFinish; ; task.ModifyDate = DateTime.Now; task.Modifier = "System"; -- Gitblit v1.9.3