From d5c610cbf2451bbf9a103c295ae51e541ad98951 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 18 二月 2025 17:16:26 +0800
Subject: [PATCH] 1
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 143 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 124 insertions(+), 19 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 6738196..6977697 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"
@@ -1,51 +1,122 @@
锘縰sing Microsoft.AspNetCore.Components.Routing;
+using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using System.Net.Http.Json;
+using System.Net.NetworkInformation;
+using System.Reflection;
+using System.Reflection.Metadata;
+using System.Reflection.PortableExecutable;
using System.Text;
+using System.Text.Json.Nodes;
using System.Threading.Tasks;
using WIDESEAWCS_Common.StackerCraneEnum;
-using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_IShuttleCar;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
+using WIDESEAWCS_TaskInfoService;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.StackerCraneJob;
namespace WIDESEAWCS_Tasks
{
[DisallowConcurrentExecution]
- public class CommonStackerCraneJob : IJob
+ public partial class CommonStackerCraneJob : JobBase, IJob
{
private readonly ITaskService _taskService;
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
private readonly ITaskRepository _taskRepository;
private readonly IRouterService _routerService;
+ private readonly IShuttleCarService _shuttleCarService;
- public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService)
+ public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IShuttleCarService shuttleCarService)
{
_taskService = taskService;
_taskExecuteDetailService = taskExecuteDetailService;
_taskRepository = taskRepository;
_routerService = routerService;
+ _shuttleCarService = shuttleCarService;
}
public Task Execute(IJobExecutionContext context)
{
try
{
- SpeStackerCrane commonStackerCrane1 = (SpeStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
- if (commonStackerCrane1.GetStackerCraneStatus<StackerCraneAutoStatus>() == StackerCraneAutoStatus.Automatic && commonStackerCrane1.GetStackerCraneStatus<Onlinestate>() == Onlinestate.online)
+ SpeStackerCrane commonStackerCrane = (SpeStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
+ if (commonStackerCrane != null)
{
+ #region 淇″彿浜や簰澶勭悊
+ //Heartbeat(commonStackerCrane);
+ ShuttleCarSignal(commonStackerCrane);
+ #endregion
+ #region 浠诲姟閫昏緫澶勭悊
+ if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.Onlinestate) == (short)Onlinestate.online
+ && commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WriteStatus) == (short)WriteStatus.Permit)
+ {
+ #region 浠诲姟瀹屾垚
+ DeviceProtocolDetailDTO? deviceProtocolDetail = commonStackerCrane.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CompleteStatus).ToString() && x.DeviceProParamName == nameof(StackerCraneTaskCommandR.CompleteStatus));
+ if (deviceProtocolDetail != null)
+ {
+ MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType);
+ if (method != null) method.Invoke(this, new object[] { commonStackerCrane });
+ }
+ #endregion
+
+ #region 鏌ヨ浠诲姟,閫昏緫澶勭悊
+ if (Enum.Parse<RunStatus>(commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.RunStatus).ToString()) == RunStatus.Standby)
+ {
+ var Task = _taskService.GetTaskState(TaskType: (int)TaskOtherTypeEnum.RelocationCar);//鑾峰彇绉昏溅浠诲姟
+ if (Task != null)
+ {
+ if (Task.TaskState == (int)TaskCarStatusEnum.ShuttleCar_Finish) SendTask(commonStackerCrane, Task);
+ }
+ else
+ {
+ Dt_Task? task = GetTask(commonStackerCrane);//鑾峰彇鍫嗗灈鏈哄嚭鍏ュ簱浠诲姟
+ if (task != null)
+ {
+ if (task.TaskType == (int)TaskInboundTypeEnum.Inbound)
+ {
+ var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//鍏ュ簱浠诲姟鍒ゆ柇鏄惁瀛樺湪绌挎杞�
+ if (task.IsPickPlace && ShuttleCar != null)//绉昏蛋
+ {
+ _taskService.AddRelocationCarTask(task.TargetAddress, "", ShuttleCar.ShuttleCarCode);
+ }
+ else if (!task.IsPickPlace && ShuttleCar == null)
+ {
+ _taskService.AddRelocationCarTask("", task.TargetAddress);
+ }
+ else
+ {
+ task.ShuttleCarCode = ShuttleCar?.ShuttleCarCode;
+ _taskService.UpdateData(task);
+ SendTask(commonStackerCrane, task);//涓嬪彂鍫嗗灈鏈轰换鍔�
+ }
+ }
+ else
+ SendTask(commonStackerCrane, task);//涓嬪彂鍫嗗灈鏈轰换鍔�
+ }
+ }
+
+ }
+ #endregion
+ }
+ #endregion
}
-
}
catch (Exception ex)
{
@@ -53,6 +124,26 @@
}
return Task.CompletedTask;
}
+ #region 浠诲姟涓嬪彂缁欏爢鍨涙満
+ private void SendTask(SpeStackerCrane commonStackerCrane, Dt_Task task)
+ {
+
+ StackerCraneTaskCommandW? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
+ if (stackerCraneTaskCommand != null)
+ {
+ bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
+ bool worktype = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, task.TaskType == (int)TaskOtherTypeEnum.RelocationCar ? (short)WorkType.Car : (short)WorkType.Cargo);
+ if (sendFlag && worktype)
+ {
+ if (commonStackerCrane.SetValue(StackerCraneDBName.CommandSend, sendFlag))
+ {
+ if (task.TaskType != (int)TaskOtherTypeEnum.RelocationCar) commonStackerCrane.LastTaskType = task.TaskType;
+ _taskService.UpdateTaskStatusToNext(task.TaskNum);
+ }
+ }
+ }
+ }
+ #endregion
/// <summary>
/// 浠诲姟瀹屾垚浜嬩欢璁㈤槄鐨勬柟娉�
@@ -62,8 +153,6 @@
private void CommonStackerCrane_StackerCraneTaskCompletedEventHandler(object? sender, WIDESEAWCS_QuartzJob.StackerCrane.StackerCraneTaskCompletedEventArgs e)
{
CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane;
- SpeStackerCrane? commonStackerCrane1 = sender as SpeStackerCrane;
- commonStackerCrane1.GetStackerCraneStatus<StackerCraneDBName>();
if (commonStackerCrane != null)
{
if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
@@ -74,13 +163,28 @@
}
}
}
-
+ /// <summary>
+ /// 浠诲姟姝e父瀹屾垚
+ /// </summary>
+ /// <param name="commonStackerCrane"></param>
+ public void NormalCompleted(SpeStackerCrane commonStackerCrane)
+ {
+ if (commonStackerCrane != null)
+ {
+ //if (_taskService.GetTaskInfo(commonStackerCrane.CurrentTaskNum) != null)
+ //{
+ Console.Out.WriteLine($"鍫嗗灈鏈轰换鍔″畬鎴愶細[{commonStackerCrane.CurrentTaskNum}]锛泏DateTime.Now}");
+ var Status = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum).Status;
+ commonStackerCrane.SetValue(StackerCraneDBName.ConfirmComplete, Status);
+ //}
+ }
+ }
/// <summary>
/// 鑾峰彇浠诲姟
/// </summary>
/// <param name="commonStackerCrane">鍫嗗灈鏈哄璞�</param>
/// <returns></returns>
- private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
+ private Dt_Task? GetTask(SpeStackerCrane commonStackerCrane)
{
Dt_Task task;
if (commonStackerCrane.LastTaskType == null)
@@ -100,6 +204,10 @@
else
{
task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
+ if (task == null)
+ {
+ task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
+ }
}
}
@@ -115,15 +223,15 @@
List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes);
foreach (var item in tasks)
{
- if (OutTaskStationIsOccupied(task) != null)
+ if (OutTaskStationIsOccupied(item) != null)
{
- return task;
+ return item;
}
}
task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
}
}
-
+ if (task != null && !string.IsNullOrEmpty(task.TargetAddress)) return task;//鍏ュ簱浠诲姟鍒ゆ柇鏄惁宸插垎閰嶈揣浣嶏紝WMS鍒ゆ柇璐т綅鐘舵�佹槸鍚﹀厑璁告斁璐�
return task;
}
@@ -164,14 +272,11 @@
/// <param name="task">浠诲姟瀹炰綋</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
- public StackerCraneTaskCommand? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
+ public StackerCraneTaskCommandW? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
{
- StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
+ StackerCraneTaskCommandW stackerCraneTaskCommand = new StackerCraneTaskCommandW();
- stackerCraneTaskCommand.Barcode = task.PalletCode;
stackerCraneTaskCommand.TaskNum = task.TaskNum;
- stackerCraneTaskCommand.WorkType = 1;
- stackerCraneTaskCommand.TrayType = 0;
if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
{
List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway);
@@ -230,7 +335,7 @@
return null;
}
}
- else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
+ else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup || task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)
{
string[] targetCodes = task.NextAddress.Split("-");
if (targetCodes.Length == 3)
--
Gitblit v1.9.3