From a6ea79849f0142b5280f0c5d4b15ecc83f0d015a Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期六, 21 十二月 2024 09:52:27 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu
---
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 65 +++++++++++++++++++++++---------
1 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 83311b0..7889386 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -4,6 +4,7 @@
using Newtonsoft.Json;
using Quartz;
using System.Diagnostics.CodeAnalysis;
+using System.Threading.Tasks;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core.Caches;
@@ -171,14 +172,14 @@
else
return;
}
-
+
_taskService.StackCraneTaskCompleted(e.TaskNum);
if (commonStackerCrane.DeviceCode.Contains("CH") && task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
{
task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum);
Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
}
- if(task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TargetAddress == "1359-4")
+ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TargetAddress == "002-021-001")
{
var TASKHTY = task.Adapt<Dt_Task_Hty>();
_taskRepository.DeleteData(task);
@@ -197,15 +198,14 @@
private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
{
Dt_Task task;
- //var taskRun = _taskRepository.QueryFirst(x => x.Roadway == commonStackerCrane.DeviceCode && (x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting));
- //if (taskRun != null) { return null; }
if (commonStackerCrane.LastTaskType == null)
{
task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
}
else
{
- if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+ var lastTaskTypeGroup = commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup();
+ if (lastTaskTypeGroup == TaskTypeGroup.OutbondGroup)
{
task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
if (task == null)
@@ -221,23 +221,18 @@
if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
- if (OutTaskStationIsOccupied(task) != null)
+ // 妫�鏌ュ綋鍓嶅嚭搴撲换鍔$珯鍙版槸鍚﹀厑璁告斁璐�
+ var occupiedStation = OutTaskStationIsOccupied(task);
+ if (occupiedStation == null)
+ {
+ // 濡傛灉褰撳墠鍑哄簱浠诲姟绔欏彴涓嶅厑璁告斁璐э紝鎺掗櫎褰撳墠浠诲姟锛屾煡鎵惧叾浠栧嚭搴撲换鍔�
+ ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵task.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵task.NextAddress}銆戜笉鍏佽鏀捐揣");
+ task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task.TaskId);
+ }
+ else
{
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(task) != null)
- // {
- // return task;
- // }
- // }
- // task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
- //}
}
else if (task == null)
{
@@ -326,6 +321,38 @@
return null;
}
+
+ /// <summary>
+ /// 鏌ユ壘鍏朵粬鍑哄簱浠诲姟鐨勮緟鍔╂柟娉曪紙鎺掗櫎鎸囧畾浠诲姟ID鐨勪换鍔★級
+ /// </summary>
+ /// <param name="deviceCode">璁惧浠g爜</param>
+ /// <param name="excludedTaskId">瑕佹帓闄ょ殑浠诲姟ID</param>
+ /// <returns></returns>
+ private Dt_Task? FindAnotherOutboundTask(string deviceCode, int excludedTaskId)
+ {
+ // 鍏堣幏鍙栨墍鏈夌鍚堟潯浠讹紙鎺掗櫎鎸囧畾浠诲姟ID锛夌殑鍑哄簱浠诲姟鍒楄〃
+ var allOutboundTasks = _taskService.QueryAllOutboundTasks(deviceCode);
+ var availableTasks = allOutboundTasks?.Where(t => excludedTaskId != t.TaskId && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList();
+
+ if (availableTasks == null || availableTasks.Count == 0)
+ {
+ return null;
+ }
+
+ // 閬嶅巻鍙敤浠诲姟鍒楄〃锛屾鏌ヤ换鍔$珯鍙版槸鍚﹀厑璁告斁璐э紝鎵惧埌绗竴涓厑璁告斁璐х殑浠诲姟灏辫繑鍥�
+ foreach (var candidateTask in availableTasks)
+ {
+ var occupiedStation = OutTaskStationIsOccupied(candidateTask);
+ if (occupiedStation != null)
+ {
+ return candidateTask;
+ }
+ ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵occupiedStation.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵occupiedStation.NextAddress}銆戜笉鍏佽鏀捐揣");
+ }
+
+ return null;
+ }
+
/// <summary>
/// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
/// </summary>
--
Gitblit v1.9.3