From cde56aae50adc11ff8db84e424d873843c566bfd Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 24 二月 2025 23:40:41 +0800
Subject: [PATCH] 优化WCS移库逻辑
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 124 +++++++++++++++++++++++++----------------
1 files changed, 75 insertions(+), 49 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 73ce11d..7db3b97 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -81,7 +81,7 @@
if (Enum.Parse<RunStatus>(commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.RunStatus).ToString()) == RunStatus.Standby)
{
var Task = _taskService.GetTaskState(TaskType: (int)TaskOtherTypeEnum.RelocationCar);//鑾峰彇绉昏溅浠诲姟
- var Task1 = _taskService.GetTaskState((int)CarChargingTask.ShuttleCar_Finish, (int)TaskOtherTypeEnum.RelocationCarCharging);//鑾峰彇绉昏溅鍏呯數浠诲姟
+ var Task1 = _taskService.GetTaskState((int)CarChargingTaskEnum.ShuttleCar_Finish, (int)TaskOtherTypeEnum.RelocationCarCharging);//鑾峰彇绉昏溅鍏呯數浠诲姟
if (Task != null)
{
if (Task.TaskState == (int)TaskCarStatusEnum.ShuttleCar_Finish) SendTask(commonStackerCrane, Task);
@@ -92,7 +92,7 @@
}
else
{
- Dt_Task? task = GetTask(commonStackerCrane);//鑾峰彇鍫嗗灈鏈哄嚭鍏ュ簱浠诲姟
+ Dt_Task? task = GetTask(commonStackerCrane);//鑾峰彇鍫嗗灈鏈轰换鍔�
if (task != null)
{
if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation)//绉诲簱浠诲姟鍒ゆ柇缁堢偣鏄惁鏈夌┛姊溅
@@ -161,19 +161,9 @@
{
if (commonStackerCrane.SetValue(StackerCraneDBName.CommandSend, sendFlag))
{
- //if (task.TaskType != (int)TaskOtherTypeEnum.RelocationCar)
commonStackerCrane.LastTaskType = task.TaskType;
_taskService.UpdateTaskStatusToNext(task.TaskNum);
}
- // DeviceProDTO? deviceProDTO = commonStackerCrane.DeviceProDTOs.FirstOrDefault((DeviceProDTO x) => x.DeviceProParamName == StackerCraneDBName.CommandSend.ToString());
- //if (deviceProDTO != null)
- //{
- // if (commonStackerCrane.Communicator.Write<bool>(deviceProDTO.DeviceProAddress, sendFlag))
- // {
- // if (task.TaskType != (int)TaskOtherTypeEnum.RelocationCar) commonStackerCrane.LastTaskType = task.TaskType;
- // _taskService.UpdateTaskStatusToNext(task.TaskNum);
- // }
- //}
}
}
}
@@ -205,12 +195,8 @@
{
if (commonStackerCrane != null)
{
- //if (_taskService.GetTaskInfo(commonStackerCrane.CurrentTaskNum) != null)
- //{
- //Console.Out.WriteLine($"鍫嗗灈鏈轰换鍔″畬鎴愶細[{commonStackerCrane.CurrentTaskNum}]锛泏DateTime.Now}");
_taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum);
commonStackerCrane.SetValue(StackerCraneDBName.ConfirmComplete, true);
- //}
}
}
/// <summary>
@@ -221,52 +207,92 @@
private Dt_Task? GetTask(SpeStackerCrane commonStackerCrane)
{
Dt_Task task = _taskService.QueryStackerCraneRelocationTask(commonStackerCrane.DeviceCode);//鑾峰彇绉诲簱浠诲姟
- if (task != null) return task;
- if (commonStackerCrane.LastTaskType == null)
+ #region 瀛樺湪绉诲簱浠诲姟蹇呴』鍏堟墽琛岀Щ搴撲换鍔�
+ if (task != null)
{
- task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
+ if (task.SourceIsPickPlace && task.TaskState == (int)TaskRelocationStatusEnum.RelocationNew)
+ SendTask(commonStackerCrane, task);//涓嬪彂鍫嗗灈鏈轰换鍔�
+ else if (!task.SourceIsPickPlace && task.TaskState == (int)TaskRelocationStatusEnum.RelocationNew)
+ {
+ var ShuttleCar = GetShuttleCarInfo(task.SourceAddress);//绉诲簱浠诲姟鍒ゆ柇璧风偣鏄惁鏈夌┛姊溅
+ if (ShuttleCar != null)
+ {
+ task.ShuttleCarCode = ShuttleCar.ShuttleCarCode;
+ _taskService.UpdateData(task);
+ }
+ else _taskService.AddRelocationCarTask("", task.SourceAddress);
+ }
+ else if (!task.TargetIsPickPlace && task.TaskState == (int)TaskRelocationStatusEnum.CarSource_Finish)
+ {
+ var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//绉诲簱浠诲姟鍒ゆ柇缁堢偣鏄惁鏈夌┛姊溅
+ if (task.TargetIsPickPlace && ShuttleCar != null)//绉昏蛋
+ {
+ _taskService.AddRelocationCarTask(task.TargetAddress, "", ShuttleCar.ShuttleCarCode);
+ }
+ else if (!task.TargetIsPickPlace && ShuttleCar == null)
+ {
+ _taskService.AddRelocationCarTask("", task.TargetAddress);
+ }
+ else
+ {
+ task.ShuttleCarCode = ShuttleCar?.ShuttleCarCode;
+ _taskService.UpdateData(task);
+ SendTask(commonStackerCrane, task);//涓嬪彂鍫嗗灈鏈轰换鍔�
+ }
+ }
}
+ #endregion
+
+ #region 鍑哄叆搴撲换鍔�
else
{
- if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+ if (commonStackerCrane.LastTaskType == null)
{
- task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode) ?? _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
- if (task == null)
- {
- task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
- }
+ task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
}
else
{
- task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
- if (task == null)
+ if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
+ task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode) ?? _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
+ if (task == null)
+ {
+ task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
+ }
+ }
+ else
+ {
+ task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
+ if (task == null)
+ {
+ task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
+ }
+ }
+ }
+
+ if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+ {
+ if (OutTaskStationIsOccupied(task) != null)
+ {
+ return task;
+ }
+ else
+ {
+ List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).Select(x => x.ChildPosi).ToList();
+ List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes);
+ foreach (var item in tasks)
+ {
+ if (OutTaskStationIsOccupied(item) != null)
+ {
+ return item;
+ }
+ }
task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
}
}
+ if (task != null && !string.IsNullOrEmpty(task.TargetAddress)) return task;//鍏ュ簱浠诲姟鍒ゆ柇鏄惁宸插垎閰嶈揣浣嶏紝WMS鍒ゆ柇璐т綅鐘舵�佹槸鍚﹀厑璁告斁璐�
}
-
- if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
- {
- if (OutTaskStationIsOccupied(task) != null)
- {
- return task;
- }
- else
- {
- List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).Select(x => x.ChildPosi).ToList();
- List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes);
- foreach (var item in tasks)
- {
- if (OutTaskStationIsOccupied(item) != null)
- {
- return item;
- }
- }
- task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
- }
- }
- if (task != null && !string.IsNullOrEmpty(task.TargetAddress)) return task;//鍏ュ簱浠诲姟鍒ゆ柇鏄惁宸插垎閰嶈揣浣嶏紝WMS鍒ゆ柇璐т綅鐘舵�佹槸鍚﹀厑璁告斁璐�
+ #endregion
return task;
}
--
Gitblit v1.9.3