From 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期六, 19 四月 2025 19:50:43 +0800 Subject: [PATCH] 优化空托出入库逻辑 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs | 79 +++++++++++++++++++++++++++++---------- 1 files changed, 58 insertions(+), 21 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs" index 6f4ef1c..315eff5 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs" @@ -74,8 +74,19 @@ { lock (_CarTaskObject) { + #region 鑾峰彇鏂板缓绉昏溅鍏呯數浠诲姟 + Dt_Task dt_Task = GetTask((int)CarChargingTaskEnum.CarNew, (int)TaskOtherTypeEnum.RelocationCarCharging); + if (dt_Task != null && dt_Task.ShuttleCarCode == shuttleCar.DeviceCode) + { + if (!string.IsNullOrEmpty(dt_Task.SourceAddress) && !string.IsNullOrEmpty(dt_Task.TargetAddress) && !string.IsNullOrEmpty(dt_Task.ShuttleCarCode)) + { + SendTask(dt_Task); + } + } + #endregion + #region 鑾峰彇鏂板缓绉昏溅浠诲姟 - Dt_Task dt_Task = GetTask((int)TaskCarStatusEnum.CarNew, (int)TaskOtherTypeEnum.RelocationCar); + dt_Task = GetTask((int)TaskCarStatusEnum.CarNew, (int)TaskOtherTypeEnum.RelocationCar); if (dt_Task != null) { if (string.IsNullOrEmpty(dt_Task.SourceAddress)) @@ -89,8 +100,9 @@ else if (string.IsNullOrEmpty(dt_Task.TargetAddress)) { #region 鍚慦MS鐢宠 + var ShuttleCar = _shuttleCarService.QueryNoCode(dt_Task.ShuttleCarCode); WebResponseContent content = new WebResponseContent(); - var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.GetPosition + $"?position={dt_Task.SourceAddress}", "", headers: new Dictionary<string, string>()); + var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.GetPosition + $"?position={dt_Task.SourceAddress}&&position1={ShuttleCar.ShuttleCarPosition}", "", headers: new Dictionary<string, string>()); if (ResultData.Result != null) { content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); @@ -105,7 +117,7 @@ #endregion } //绌挎杞︾Щ杞︿换鍔′笅鍙� - if (!string.IsNullOrEmpty(dt_Task.SourceAddress) && !string.IsNullOrEmpty(dt_Task.TargetAddress) && !string.IsNullOrEmpty(dt_Task.ShuttleCarCode)) + if (!string.IsNullOrEmpty(dt_Task.SourceAddress) && !string.IsNullOrEmpty(dt_Task.TargetAddress) && !string.IsNullOrEmpty(dt_Task.ShuttleCarCode) && dt_Task.ShuttleCarCode == shuttleCar.DeviceCode) { SendTask(dt_Task); } @@ -126,11 +138,15 @@ task = _taskService.QueryShuttleCarTask(shuttleCar.DeviceCode); if (task != null) { - if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && !task.SourceIsPickPlace) + if (_taskService.TaskOutboundTypes.Contains(task.TaskType) && !task.SourceIsPickPlace) { var ShuttleCar = _shuttleCarService.QueryShuttleCar(task.SourceAddress);//鍑哄簱浠诲姟鍒ゆ柇璧风偣鏄惁鏈夌┛姊溅 - if (ShuttleCar != null) SendTask(task); - else _taskService.AddRelocationCarTask("", task.SourceAddress); + if (ShuttleCar == null) _taskService.AddRelocationCarTask("", task.SourceAddress); + else + { + task.ShuttleCarCode = ShuttleCar.ShuttleCarCode; + SendTask(task); + } } else SendTask(task); @@ -212,19 +228,25 @@ if (shuttleCar != null) { ShuttleCarTaskCommandR command = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar, shuttleCar.DeviceCode);//璇诲彇绌挎杞︿俊鎭� - if (command != null && command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command.Err_Status == (short)ShuttleCarErr.Normal) + if (command != null && command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && (command.Err_Status == (short)ShuttleCarErr.Normal || command.Err_Status == (short)ShuttleCarErr.LowBattery)) { #region 鍒ゆ柇灏忚溅浣嶇疆鏃燗B闈笉涓嬪彂浠诲姟 - short Position = 0; - if (shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.DirectionA)) Position = 1; - if (shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.DirectionB)) Position = 2; - if (Position != 1 && Position != 2) - { - var Message = $"{shuttleCar.DeviceName}鏃燗B闈�"; - if (task.ExceptionMessage != Message) - _taskService.UpdateData(task); - return; - } + //short Position = 0; + //if (shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.DirectionA)) Position = 1; + //if (shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.DirectionB)) Position = 2; + //if (Position != 1 && Position != 2) + //{ + // var Message = $"{shuttleCar.DeviceName}鏃燗B闈�"; + // if (task.ExceptionMessage != Message) + // { + // task.ExceptionMessage = Message; + // _taskService.UpdateData(task); + // } + // return; + //} + Dt_ShuttleCar _ShuttleCar = QueryCode(task.ShuttleCarCode); + var Row = Convert.ToInt32(_ShuttleCar.ShuttleCarPosition.Split("-")[0]); + short Position = Convert.ToInt16(Row < 3 ? 1 : 2); #endregion //浠诲姟杞崲 shuttleCar.SetValue(ShuttleCarDBName.Direction, Position);//鍐欏叆杞︿綋鏂瑰悜 @@ -246,6 +268,12 @@ // shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction); } } + else if (task.TaskType == (int)TaskOtherTypeEnum.RelocationCarCharging) + { + shuttleCarTaskCommand.TaskType = task.TaskState == CarChargingTaskEnum.CarNew.ObjToInt() ? + (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction) : + (short)GetCarTaskType(ShuttleCarTaskType.Charging.ToString()); + } else shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction); //shuttleCarTaskCommand.TaskType = string.IsNullOrEmpty(task.Remark) ? (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction) : (short)GetCarTaskType(task.Remark); @@ -254,8 +282,9 @@ { if (shuttleCar.SendCommand(shuttleCarTaskCommand, shuttleCar.DeviceCode)) { - if (!string.IsNullOrEmpty(task.Remark)) task.Remark = task.Remark + "宸蹭笅鍙�"; - task.TaskState = GetTaskState(task.TaskType); + if (!string.IsNullOrEmpty(task.Remark) && task.TaskState == CarChargingTaskEnum.CarNew.ObjToInt()) + task.Remark = task.Remark + "宸蹭笅鍙�"; + task.TaskState = GetTaskState(task.TaskType, task.TaskState); _taskService.UpdateData(task); } } @@ -297,9 +326,11 @@ switch (TaskType) { case (int)TaskInboundTypeEnum.Inbound: + case (int)TaskInboundTypeEnum.PalletInbound: taskType = ShuttleCarTaskType.In; break; case (int)TaskOutboundTypeEnum.Outbound: + case (int)TaskOutboundTypeEnum.PalletOutbound: taskType = ShuttleCarTaskType.Out; break; case (int)TaskOtherTypeEnum.RelocationCar: @@ -316,20 +347,26 @@ /// </summary> /// <param name="TaskType"></param> /// <returns></returns> - int GetTaskState(int TaskType) + int GetTaskState(int TaskType, int state) { - int state = 0; switch (TaskType) { case (int)TaskInboundTypeEnum.Inbound: + case (int)TaskInboundTypeEnum.PalletInbound: state = (int)TaskInStatusEnum.Car_InExecuting; break; case (int)TaskOutboundTypeEnum.Outbound: + case (int)TaskOutboundTypeEnum.PalletOutbound: state = (int)TaskOutStatusEnum.Car_OutExecuting; break; case (int)TaskOtherTypeEnum.RelocationCar: state = (int)TaskCarStatusEnum.ShuttleCar_Executing; break; + case (int)TaskOtherTypeEnum.RelocationCarCharging: + state = state < (int)CarChargingTaskEnum.SC_CarFinish ? + (int)CarChargingTaskEnum.ShuttleCar_Executing : + (int)CarChargingTaskEnum.ShuttleCar_Charging; + break; default: break; } -- Gitblit v1.9.3