From f56441867f2cc77567f97a92348a5d878f0dca05 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 12 三月 2026 18:24:15 +0800
Subject: [PATCH] Add AGENTS instructions and updates
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs | 186 +++++++++++++---------------------------------
1 files changed, 52 insertions(+), 134 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
index 73df26f..6dc2ef3 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/ConveyorLineDispatchHandler.cs
@@ -1,24 +1,24 @@
-#region << 版 本 注 释 >>
+锘�#region << 鐗� 鏈� 娉� 閲� >>
/*----------------------------------------------------------------
- * 命名空间:WIDESEAWCS_Tasks.ConveyorLineJob
- * 创建者:胡童庆
- * 创建时间:2024/8/2 16:13:36
- * 版本:V1.0.0
- * 描述:
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_Tasks.ConveyorLineJob
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛�
*
* ----------------------------------------------------------------
- * 修改人:
- * 修改时间:
- * 版本:V1.0.1
- * 修改说明:
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏1.0.1
+ * 淇敼璇存槑锛�
*
*----------------------------------------------------------------*/
-#endregion << 版 本 注 释 >>
+#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
-using System.Data;
+using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITaskInfoService;
@@ -35,37 +35,36 @@
private readonly IRouterService _routerService;
private readonly IMapper _mapper;
+ private readonly ConveyorLineTaskFilter _taskFilter;
+ private readonly ConveyorLineTargetAddressSelector _targetAddressSelector;
+
public ConveyorLineDispatchHandler(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper)
{
_taskService = taskService;
_taskExecuteDetailService = taskExecuteDetailService;
_routerService = routerService;
_mapper = mapper;
+
+ _taskFilter = new ConveyorLineTaskFilter(taskService);
+ _targetAddressSelector = new ConveyorLineTargetAddressSelector();
}
/// <summary>
- /// 心跳处理
+ /// 蹇冭烦澶勭悊
/// </summary>
- /// <param name="conveyorLine"></param>
- /// <param name="command"></param>
- /// <param name="childDeviceCode"></param>
public void HeartBeat(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- //心跳处理逻辑
conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, 0, childDeviceCode);
}
/// <summary>
- /// 输送线请求入库
+ /// 杈撻�佺嚎璇锋眰鍏ュ簱
/// </summary>
- /// <param name="conveyorLine">输送线实例对象</param>
- /// <param name="command">读取的请求信息</param>
- /// <param name="childDeviceCode">子设备编号</param>
public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)
+ if (_taskFilter.RequestWmsTask(command.Barcode, childDeviceCode))
{
- Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+ Dt_Task? task = _taskFilter.QueryPendingTask(conveyorLine.DeviceCode, childDeviceCode);
if (task != null)
{
ConveyorLineTaskCommandNew taskCommand = _mapper.Map<ConveyorLineTaskCommandNew>(task);
@@ -78,59 +77,34 @@
}
/// <summary>
- /// 输送线请求入库下一地址
+ /// 杈撻�佺嚎璇锋眰鍏ュ簱涓嬩竴鍦板潃
/// </summary>
- /// <param name="conveyorLine">输送线实例对象</param>
- /// <param name="command">读取的请求信息</param>
- /// <param name="childDeviceCode">子设备编号</param>
public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
- if (task != null)
+ Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
+ if (task == null)
{
- const string ConstraintMachineName = "拘束机";
- const string PinMachineName = "插拔钉机";
+ return;
+ }
- var devices = Storage.Devices;
+ _targetAddressSelector.HandleInboundNextAddress(conveyorLine, task.NextAddress, childDeviceCode);
- if (string.Equals(task.NextAddress, ConstraintMachineName, StringComparison.Ordinal))
+ Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
+ if (newTask != null)
+ {
+ if (_taskService.UpdateTaskStatusToNext(newTask).Status && newTask.TaskState == (int)TaskInStatusEnum.Line_InFinish)
{
- ConstraintMachine? constraint = devices.OfType<ConstraintMachine>().FirstOrDefault(d => d.DeviceName == ConstraintMachineName);
- if (constraint == null) return;
-
- ProcessDeviceRequest(conveyorLine, constraint, childDeviceCode,
- () => constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestUpper),
- () => constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.OutputRequestUpper),
- outputReq => constraint.SetValue(ConstraintMachineDBName.ConstraintTrayOutputReadyUpper, outputReq ? 1 : 0));
- }
- else if (string.Equals(task.NextAddress, PinMachineName, StringComparison.Ordinal))
- {
- PinMachine? pinMachine = devices.OfType<PinMachine>().FirstOrDefault(d => d.DeviceName == PinMachineName);
- if (pinMachine == null) return;
-
- ProcessDeviceRequest(conveyorLine, pinMachine, childDeviceCode,
- () => pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestUpper),
- () => pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.OutputRequestUpper),
- outputReq => pinMachine.SetValue(PinMachineDBName.PlugPinTrayOutputReadyUpper, outputReq ? 1 : 0));
- }
-
- Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
- if (newTask != null)
- {
- _taskService.UpdateTaskStatusToNext(task);
+ conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_STB, 1, childDeviceCode);
}
}
}
/// <summary>
- /// 输送线入库完成
+ /// 杈撻�佺嚎鍏ュ簱瀹屾垚
/// </summary>
- /// <param name="conveyorLine">输送线实例对象</param>
- /// <param name="command">读取的请求信息</param>
- /// <param name="childDeviceCode">子设备编号</param>
public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
+ Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
if (task != null)
{
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
@@ -140,80 +114,44 @@
}
/// <summary>
- /// 输送线请求出信息
+ /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
/// </summary>
- /// <param name="conveyorLine">输送线实例对象</param>
- /// <param name="command">读取的请求信息</param>
- /// <param name="childDeviceCode">子设备编号</param>
public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+ Dt_Task? task = _taskFilter.QueryPendingTask(conveyorLine.DeviceCode, childDeviceCode);
if (task != null)
{
- ConveyorLineTaskCommandNew taskCommand = _mapper.Map<ConveyorLineTaskCommandNew>(task);
- taskCommand.WCS_ACK = command.WCS_ACK;
- conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, task.TaskNum, childDeviceCode);
+ conveyorLine.SetValue(ConveyorLineDBNameNew.Barcode, task.PalletCode, childDeviceCode);
+ conveyorLine.SetValue(ConveyorLineDBNameNew.Target, task.TargetAddress, childDeviceCode);
+ conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
_taskService.UpdateTaskStatusToNext(task);
}
}
/// <summary>
- /// 输送线请求出库下一地址
+ /// 杈撻�佺嚎璇锋眰鍑哄簱涓嬩竴鍦板潃
/// </summary>
- /// <param name="conveyorLine">输送线实例对象</param>
- /// <param name="command">读取的请求信息</param>
- /// <param name="childDeviceCode">子设备编号</param>
public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
- if (task != null)
+ Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
+ if (task == null)
{
- const string ConstraintMachineName = "拘束机";
- const string PinMachineName = "插拔钉机";
-
- var devices = Storage.Devices;
-
- if (string.Equals(task.NextAddress, ConstraintMachineName, StringComparison.Ordinal))
- {
- ConstraintMachine? constraint = devices.OfType<ConstraintMachine>().FirstOrDefault(d => d.DeviceName == ConstraintMachineName);
- if (constraint == null)
- {
- // 处理 processing 为空的情况(可根据实际业务需求添加处理逻辑)
- return;
- }
- ProcessDeviceRequest(conveyorLine, constraint, childDeviceCode,
- () => constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.MaterialRequestLower),
- () => constraint.GetValue<ConstraintMachineDBName, bool>(ConstraintMachineDBName.OutputRequestLower),
- outputReq => constraint.SetValue(ConstraintMachineDBName.ConstraintTrayOutputReadyLower, outputReq ? 1 : 0));
- }
- else if (string.Equals(task.NextAddress, PinMachineName, StringComparison.Ordinal))
- {
- PinMachine? pinMachine = devices.OfType<PinMachine>().FirstOrDefault(d => d.DeviceName == PinMachineName);
- if (pinMachine == null)
- {
- // 处理 pinMachine 为空的情况(可根据实际业务需求添加处理逻辑)
- return;
- }
- ProcessDeviceRequest(conveyorLine, pinMachine, childDeviceCode,
- () => pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.MaterialRequestLower),
- () => pinMachine.GetValue<PinMachineDBName, bool>(PinMachineDBName.OutputRequestLower),
- outputReq => pinMachine.SetValue(PinMachineDBName.PlugPinTrayOutputReadyLower, outputReq ? 1 : 0));
- }
-
- Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
+ return;
}
+
+ _targetAddressSelector.HandleOutboundNextAddress(conveyorLine, task.NextAddress, childDeviceCode);
+
+ _ = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
}
/// <summary>
- /// 输送线出库完成
+ /// 杈撻�佺嚎鍑哄簱瀹屾垚
/// </summary>
- /// <param name="conveyorLine">输送线实例对象</param>
- /// <param name="command">读取的请求信息</param>
- /// <param name="childDeviceCode">子设备编号</param>
public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
{
- Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
+ Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
if (task != null)
{
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
@@ -221,25 +159,5 @@
Console.Out.WriteLine(content.Serialize());
}
}
-
- /// <summary>
- /// 通用的设备请求处理方法
- /// </summary>
- private void ProcessDeviceRequest<T>(CommonConveyorLine conveyorLine, T device, string childDeviceCode,
- Func<bool> getMaterialRequest, Func<bool> getOutputRequest, Action<bool> setOutputReady)
- {
- bool materialReq = getMaterialRequest();
- bool outputReq = getOutputRequest();
-
- if (materialReq)
- {
- conveyorLine.SetValue(ConveyorLineDBNameNew.Target, 1, childDeviceCode);
- conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
- }
- else
- {
- setOutputReady(outputReq);
- }
- }
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3