From c3de7bb2097aa347a1f92c2f640d18753aff633a Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期六, 28 二月 2026 13:41:26 +0800
Subject: [PATCH] 添加HTTP客户端助手、枚举、DTO;更新URL
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 432 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 268 insertions(+), 164 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 6ed2eb2..132566c 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -30,6 +30,7 @@
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
private readonly ITaskRepository _taskRepository;
private readonly IRouterService _routerService;
+ private readonly StackerCraneCommandConfig _config;
public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService)
{
@@ -37,46 +38,62 @@
_taskExecuteDetailService = taskExecuteDetailService;
_taskRepository = taskRepository;
_routerService = routerService;
+ _config = LoadConfig();
+ }
+
+ /// <summary>
+ /// 鍔犺浇閰嶇疆锛堜紭鍏堢骇锛氶厤缃枃浠� > 榛樿閰嶇疆锛�
+ /// </summary>
+ private static StackerCraneCommandConfig LoadConfig()
+ {
+ try
+ {
+ string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StackerCraneJob", "stackercrane-command-config.json");
+ if (File.Exists(configPath))
+ {
+ string json = File.ReadAllText(configPath);
+ return System.Text.Json.JsonSerializer.Deserialize<StackerCraneCommandConfig>(json) ?? new StackerCraneCommandConfig();
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"閰嶇疆鍔犺浇澶辫触: {ex.Message}锛屼娇鐢ㄩ粯璁ら厤缃�");
+ }
+ return new StackerCraneCommandConfig();
}
public Task Execute(IJobExecutionContext context)
{
try
{
- List<Dt_Task> tasks = _taskService.Repository.QueryData();
-
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " CommonStackerCraneJob Start");
- bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
- if (flag && value != null && value is CommonStackerCrane commonStackerCrane)
- {
- if (!commonStackerCrane.IsEventSubscribed)
- {
- commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
- }
- if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal)
- {
- commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
- if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
+ bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
+ if (!flag || value is not IStackerCrane commonStackerCrane)
+ {
+ return Task.CompletedTask;
+ }
+
+ if (!commonStackerCrane.IsEventSubscribed)
+ {
+ commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;
+ }
+
+ if (commonStackerCrane.IsCanSendTask(commonStackerCrane.Communicator, commonStackerCrane.DeviceProDTOs, commonStackerCrane.DeviceProtocolDetailDTOs))
+ {
+ commonStackerCrane.CheckStackerCraneTaskCompleted();
+
+ Dt_Task? task = GetTask(commonStackerCrane);
+ if (task != null)
+ {
+ object? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
+ if (stackerCraneTaskCommand != null)
{
- Dt_Task? task = GetTask(commonStackerCrane);
- if (task != null)
+ bool sendFlag = SendStackerCraneCommand(commonStackerCrane, stackerCraneTaskCommand);
+ if (sendFlag)
{
- int num = new Random().Next(1, 100);
- if (num < 30)
- {
- throw new CommunicationException("閿欒娴嬭瘯", CommunicationErrorType.Unknown);
- }
- StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
- if (stackerCraneTaskCommand != null)
- {
- bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
- if (sendFlag)
- {
- commonStackerCrane.LastTaskType = task.TaskType;
- _taskService.UpdateTaskStatusToNext(task.TaskNum);
- }
- }
+ commonStackerCrane.LastTaskType = task.TaskType;
+ _taskService.UpdateTaskStatusToNext(task.TaskNum);
}
}
}
@@ -84,6 +101,7 @@
}
catch (Exception ex)
{
+ Console.WriteLine($"CommonStackerCraneJob Error: {ex.Message}");
}
return Task.CompletedTask;
}
@@ -98,12 +116,12 @@
CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane;
if (commonStackerCrane != null)
{
- if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
- {
+ //if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
+ //{
Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
_taskService.StackCraneTaskCompleted(e.TaskNum);
commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
- }
+ //}
}
}
@@ -112,9 +130,9 @@
/// </summary>
/// <param name="commonStackerCrane">鍫嗗灈鏈哄璞�</param>
/// <returns></returns>
- private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
+ private Dt_Task? GetTask(IStackerCrane commonStackerCrane)
{
- Dt_Task task;
+ Dt_Task? task = null;
if (commonStackerCrane.LastTaskType == null)
{
task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
@@ -124,10 +142,7 @@
if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
- if (task == null)
- {
- task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
- }
+ task ??= _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
}
else
{
@@ -137,162 +152,251 @@
if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
- if (OutTaskStationIsOccupied(task) != null)
- {
+ //if (IsOutTaskStationAvailable(task))
+ //{
return task;
- }
- else
+ //}
+
+ List<string> otherOutStationCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress, task.TaskType)
+ .Select(x => x.ChildPosi).ToList();
+ List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStationCodes);
+ foreach (var alternativeTask in tasks)
{
- 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 (IsOutTaskStationAvailable(alternativeTask))
{
- if (OutTaskStationIsOccupied(task) != null)
- {
- return task;
- }
+ return alternativeTask;
}
- task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
}
+ task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
}
return task;
}
/// <summary>
- /// 鍑哄簱浠诲姟鍒ゆ柇鍑哄簱绔欏彴鏄惁琚崰鐢�
+ /// 鍑哄簱浠诲姟鍒ゆ柇鍑哄簱绔欏彴鏄惁鍙敤
/// </summary>
/// <param name="task">浠诲姟瀹炰綋</param>
- /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns>
- private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task)
+ /// <returns>濡傛灉绔欏彴鍙敤杩斿洖true锛屽惁鍒欒繑鍥瀎alse</returns>
+ private bool IsOutTaskStationAvailable([NotNull] Dt_Task task)
{
-
- Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault();
- if (router != null)
- {
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
- if (device != null)
- {
- CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
- if (conveyorLine.IsOccupied(router.ChildPosi))//鍑哄簱绔欏彴鏈鍗犵敤
- {
- return task;
- }
- }
- else
- {
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵router.ChildPosiDeviceCode}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
- }
- }
- else
+ Dt_Router? router = _routerService.QueryNextRoute(task.Roadway, task.NextAddress, task.TaskType);
+ if (router == null)
{
_taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鏍¢獙绔欏彴");
+ return false;
}
- return null;
+
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
+ if (device == null)
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵router.ChildPosiDeviceCode}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
+ return false;
+ }
+
+ CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+ return conveyorLine.IsOccupied(router.ChildPosi);
}
/// <summary>
/// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
/// </summary>
- /// <param name="task">浠诲姟瀹炰綋</param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public StackerCraneTaskCommand? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
+ public object? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
{
- StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
+ // 鏍规嵁閰嶇疆鍒ゆ柇鍛戒护绫诲瀷
+ string commandType = GetCommandType(task.Roadway);
- stackerCraneTaskCommand.Barcode = task.PalletCode;
- stackerCraneTaskCommand.TaskNum = task.TaskNum;
- stackerCraneTaskCommand.WorkType = 1;
- stackerCraneTaskCommand.TrayType = 0;
- if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
+ // 鍒涘缓骞舵瀯寤哄懡浠�
+ return commandType switch
{
- List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway);
- if (routers.Count > 0)
- {
- stackerCraneTaskCommand.StartRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow);
- stackerCraneTaskCommand.StartColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn);
- stackerCraneTaskCommand.StartLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer);
+ "Formation" => BuildCommand(task, CreateFormationCommand(task)),
+ _ => BuildCommand(task, CreateStandardCommand(task))
+ };
+ }
- string[] targetCodes = task.NextAddress.Split("-");
- if (targetCodes.Length == 3)
- {
- stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
- stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
- stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
- }
- else
- {
- //鏁版嵁閰嶇疆閿欒
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�");
- return null;
- }
- }
- else
+ private static bool SendStackerCraneCommand(IStackerCrane commonStackerCrane, object command)
+ {
+ return command switch
+ {
+ FormationStackerCraneTaskCommand formationCommand => commonStackerCrane.SendCommand(formationCommand),
+ StackerCraneTaskCommand standardCommand => commonStackerCrane.SendCommand(standardCommand),
+ _ => false
+ };
+ }
+
+ /// <summary>
+ /// 鏍规嵁 Roadway 鑾峰彇鍛戒护绫诲瀷
+ /// </summary>
+ private string GetCommandType(string roadway)
+ {
+ foreach (var mapping in _config.RoadwayCommandMapping)
+ {
+ if (roadway.Contains(mapping.Key))
{
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鍙栬揣绔欏彴淇℃伅");
- return null;
+ return mapping.Value;
}
}
- else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
- {
- List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress);
- if (routers.Count > 0)
- {
- stackerCraneTaskCommand.EndRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow);
- stackerCraneTaskCommand.EndColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn);
- stackerCraneTaskCommand.EndLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer);
+ return _config.DefaultCommandType;
+ }
- string[] sourceCodes = task.CurrentAddress.Split("-");
- if (sourceCodes.Length == 3)
- {
- stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
- stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
- stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
- }
- else
- {
- //鏁版嵁閰嶇疆閿欒
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
- return null;
- }
- }
- else
- {
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
- return null;
- }
- }
- else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
+ /// <summary>
+ /// 鍒涘缓鏍囧噯鍫嗗灈鏈哄懡浠�
+ /// </summary>
+ private static StackerCraneTaskCommand CreateStandardCommand(Dt_Task task)
+ {
+ return new StackerCraneTaskCommand
{
- string[] targetCodes = task.NextAddress.Split("-");
- if (targetCodes.Length == 3)
- {
- stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
- stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
- stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
- }
- else
- {
- //鏁版嵁閰嶇疆閿欒
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�");
- return null;
- }
- string[] sourceCodes = task.CurrentAddress.Split("-");
- if (sourceCodes.Length == 3)
- {
- stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
- stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
- stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
- }
- else
- {
- //鏁版嵁閰嶇疆閿欒
- _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
- return null;
- }
+ //Barcode = task.PalletCode,
+ TaskNum = task.TaskNum,
+ WorkType = 1,
+ WorkAction = 1
+ };
+ }
+
+ /// <summary>
+ /// 鍒涘缓鍒嗗鍫嗗灈鏈哄懡浠�
+ /// </summary>
+ private static FormationStackerCraneTaskCommand CreateFormationCommand(Dt_Task task)
+ {
+ return new FormationStackerCraneTaskCommand
+ {
+ Barcode = task.PalletCode,
+ TaskNum = task.TaskNum,
+ WorkType = 1,
+ WorkAction = 1,
+ FireAlarm = 0,
+ HeartBeat = 0,
+ FieldName = string.Empty
+ };
+ }
+
+ /// <summary>
+ /// 閫氱敤鍛戒护鏋勫缓鏂规硶
+ /// </summary>
+ private T? BuildCommand<T>(Dt_Task task, T command) where T : class
+ {
+ TaskTypeGroup taskTypeGroup = task.TaskType.GetTaskTypeGroup();
+
+ return taskTypeGroup switch
+ {
+ TaskTypeGroup.InboundGroup => BuildInboundCommand(task, command),
+ TaskTypeGroup.OutbondGroup => BuildOutboundCommand(task, command),
+ TaskTypeGroup.RelocationGroup => BuildRelocationCommand(task, command),
+ _ => command
+ };
+ }
+
+ /// <summary>
+ /// 閫氱敤鍏ュ簱鍛戒护鏋勫缓
+ /// </summary>
+ private T? BuildInboundCommand<T>(Dt_Task task, T command) where T : class
+ {
+ Dt_Router? router = _routerService.QueryNextRoute(task.CurrentAddress, task.Roadway, task.TaskType);
+ if (router == null)
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.CurrentAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鍙栬揣绔欏彴淇℃伅");
+ return null;
}
- return stackerCraneTaskCommand;
+
+ SetCommandProperty(command, "StartRow", Convert.ToInt16(router.SrmRow));
+ SetCommandProperty(command, "StartColumn", Convert.ToInt16(router.SrmColumn));
+ SetCommandProperty(command, "StartLayer", Convert.ToInt16(router.SrmLayer));
+
+ if (!TryParseAddress(task.NextAddress, out short endRow, out short endColumn, out short endLayer))
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
+ return null;
+ }
+
+ SetCommandProperty(command, "EndRow", endRow);
+ SetCommandProperty(command, "EndColumn", endColumn);
+ SetCommandProperty(command, "EndLayer", endLayer);
+
+ return command;
+ }
+
+ /// <summary>
+ /// 閫氱敤鍑哄簱鍛戒护鏋勫缓
+ /// </summary>
+ private T? BuildOutboundCommand<T>(Dt_Task task, T command) where T : class
+ {
+ Dt_Router? router = _routerService.QueryNextRoute(task.Roadway, task.TargetAddress, task.TaskType);
+ if (router == null)
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.TargetAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅");
+ return null;
+ }
+
+ SetCommandProperty(command, "EndRow", Convert.ToInt16(router.SrmRow));
+ SetCommandProperty(command, "EndColumn", Convert.ToInt16(router.SrmColumn));
+ SetCommandProperty(command, "EndLayer", Convert.ToInt16(router.SrmLayer));
+
+ if (!TryParseAddress(task.CurrentAddress, out short startRow, out short startColumn, out short startLayer))
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
+ return null;
+ }
+
+ SetCommandProperty(command, "StartRow", startRow);
+ SetCommandProperty(command, "StartColumn", startColumn);
+ SetCommandProperty(command, "StartLayer", startLayer);
+
+ return command;
+ }
+
+ /// <summary>
+ /// 閫氱敤绉诲簱鍛戒护鏋勫缓
+ /// </summary>
+ private T? BuildRelocationCommand<T>(Dt_Task task, T command) where T : class
+ {
+ if (!TryParseAddress(task.NextAddress, out short endRow, out short endColumn, out short endLayer))
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�");
+ return null;
+ }
+
+ SetCommandProperty(command, "EndRow", endRow);
+ SetCommandProperty(command, "EndColumn", endColumn);
+ SetCommandProperty(command, "EndLayer", endLayer);
+
+ if (!TryParseAddress(task.CurrentAddress, out short startRow, out short startColumn, out short startLayer))
+ {
+ _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�");
+ return null;
+ }
+
+ SetCommandProperty(command, "StartRow", startRow);
+ SetCommandProperty(command, "StartColumn", startColumn);
+ SetCommandProperty(command, "StartLayer", startLayer);
+
+ return command;
+ }
+
+ /// <summary>
+ /// 浣跨敤鍙嶅皠璁剧疆鍛戒护灞炴��
+ /// </summary>
+ private static void SetCommandProperty<T>(T command, string propertyName, object value) where T : class
+ {
+ var property = typeof(T).GetProperty(propertyName);
+ property?.SetValue(command, value);
+ }
+
+ /// <summary>
+ /// 瑙f瀽鍦板潃瀛楃涓诧紙鏍煎紡锛氳-鍒�-灞傦級
+ /// </summary>
+ private bool TryParseAddress(string address, out short row, out short column, out short layer)
+ {
+ row = column = layer = 0;
+
+ string[] parts = address.Split("-");
+ if (parts.Length != 3)
+ {
+ return false;
+ }
+
+ return short.TryParse(parts[0], out row)
+ && short.TryParse(parts[1], out column)
+ && short.TryParse(parts[2], out layer);
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3