From b31d961a3f0bcd2e555ea12b76c30c453826deba Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期一, 28 七月 2025 09:42:58 +0800 Subject: [PATCH] 代码提交 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 274 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 205 insertions(+), 69 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..59d937f 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,77 +103,180 @@ // 閬嶅巻浼犲叆鐨刉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_Task taskOut = new Dt_Task() + if (Convert.ToInt32(item.EndPoint) > 1999 && Convert.ToInt32(item.EndPoint) < 3000) { - TaskNum = BaseDal.GetTaskNo().Result, - Creater = "WMS", - WMSTaskNum=item.TaskId, - Grade = 1, - PalletCode = item.TPbarcode, - TaskType = (int)TaskOutboundTypeEnum.Outbound, - TaskState = (int)TaskOutStatusEnum.OutNew, - SourceAddress = item.BeginPoint, - CurrentAddress = item.BeginPoint, - Roadway = GetScCode(Convert.ToInt32(targetCodes[0])), - NextAddress = stationManager.stationChildCode, - TargetAddress = item.EndPoint, - RGVName = "RGV01" - }; - BaseDal.AddData(taskOut); + Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.EndPoint); + if (stationManagerStart == null) + { + return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�"); + } + Dt_Task taskIn = new Dt_Task() + { + TaskNum = BaseDal.GetTaskNo().Result, + Creater = "WMS", + WMSTaskNum = item.TaskId, + Grade = 1, + PalletCode = item.TPbarcode, + TaskType = (int)TaskOutboundTypeEnum.Outbound, + TaskState = (int)TaskOutStatusEnum.OutNew, + SourceAddress = item.BeginPoint, + CurrentAddress = item.BeginPoint, + Roadway = stationManagerStart.Roadway, + NextAddress = item.EndPoint, + TargetAddress = item.EndPoint, + Floor = stationManagerStart.stationFloor, + RGVName = "" + }; + BaseDal.AddData(taskIn); + } + else + { + + string[] targetCodes = item.BeginPoint.Split("-"); + + 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 == "1F").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, + Creater = "WMS", + WMSTaskNum = item.TaskId, + Grade = 1, + PalletCode = item.TPbarcode, + TaskType = (int)TaskOutboundTypeEnum.Outbound, + TaskState = (int)TaskOutStatusEnum.OutNew, + SourceAddress = item.BeginPoint, + CurrentAddress = item.BeginPoint, + Roadway = GetScCode(Convert.ToInt32(targetCodes[0])), + NextAddress = stationManager.stationChildCode, + TargetAddress = item.EndPoint, + RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName, + Floor = stationManager.stationFloor, + }; + BaseDal.AddData(taskOut); + } } // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄叆搴撲换鍔� else if (item.TaskType == "1") { - task.TaskType = (int)TaskInboundTypeEnum.Inbound; + if (Convert.ToInt32(item.BeginPoint) > 1999 && Convert.ToInt32(item.BeginPoint) < 3000) + { + Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.BeginPoint); + if (stationManagerStart == null) + { + return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�"); + } + Dt_Task taskIn = new Dt_Task() + { + TaskNum = BaseDal.GetTaskNo().Result, + Creater = "WMS", + WMSTaskNum = item.TaskId, + Grade = 1, + PalletCode = item.TPbarcode, + TaskType = (int)TaskInboundTypeEnum.Inbound, + TaskState = (int)TaskInStatusEnum.Line_InFinish, + SourceAddress = item.BeginPoint, + CurrentAddress = stationManagerStart.stationChildCode, + Roadway = stationManagerStart.Roadway, + NextAddress = item.EndPoint, + TargetAddress = item.EndPoint, + Floor = stationManagerStart.stationFloor, + RGVName = "" + }; + BaseDal.AddData(taskIn); + } + else + { + var task = BaseDal.QueryFirst(x => x.PalletCode == item.TPbarcode); + if (task != null) + { + task.Creater = "WMS"; + task.Grade = 1; + task.PalletCode = item.TPbarcode; - task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish; + task.TaskType = (int)TaskInboundTypeEnum.Inbound; - task.CurrentAddress = item.BeginPoint; + task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish; - task.WMSTaskNum = item.TaskId; + task.CurrentAddress = item.BeginPoint; - task.TargetAddress = item.EndPoint; + task.WMSTaskNum = item.TaskId; - string[] targetCodes = item.EndPoint.Split("-"); + task.TargetAddress = item.EndPoint; - task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0])); + string[] targetCodes = item.EndPoint.Split("-"); - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3); + task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0])); - task.NextAddress = stationManager.stationChildCode; - BaseDal.UpdateData(task); + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3 && x.stationFloor == task.Floor); + + 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 +425,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 +441,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 +648,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 +665,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 +753,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 +770,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"; @@ -720,23 +829,41 @@ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) { - task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; + if (Convert.ToInt32(task.TargetAddress) > 1999 && Convert.ToInt32(task.TargetAddress) < 3000) + { + task.TaskState = (int)TaskOutStatusEnum.OutFinish; ; + task.ModifyDate = DateTime.Now; + task.Modifier = "System"; - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2); + Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task); + task_Hty.TaskId = 0; - task.CurrentAddress = task.NextAddress; + BaseDal.DeleteData(task); + _taskHtyRepository.AddData(task_Hty); + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�"); + } + else + { + task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish; - task.NextAddress = stationManager.stationNextChildCode; + Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor); - BaseDal.UpdateData(task); + task.CurrentAddress = task.NextAddress; - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�"); + task.NextAddress = stationManager.stationNextChildCode; + + BaseDal.UpdateData(task); + + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�"); + } + } + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) + { + } 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"; @@ -954,5 +1081,14 @@ return WebResponseContent.Instance.Error(ex.Message); } } + public WebResponseContent text(int taskNum) + { + WebResponseContent content = new WebResponseContent(); + var result = _stationManagerRepository.Db.Queryable<Dt_StationManager>() + .Where(t => SqlFunc.Abs(t.LevelPointFist - taskNum) <= 10) + .ToList(); + + return content.OK(data: result); + } } } -- Gitblit v1.9.3