From b6c983ac19c0c80744795e122575f4b9ac145414 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 19 四月 2026 18:53:40 +0800
Subject: [PATCH] feat: 更新机器人任务处理逻辑和接口配置
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs | 70 ++++++++++++++++++++++++++++++-----
1 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
index 00291e7..494541e 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
@@ -28,6 +28,7 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.Utilities;
using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
@@ -82,14 +83,15 @@
RobotSourceAddressLineCode = stockDTO.SourceLineNo,
RobotTargetAddressLineCode = stockDTO.TargetLineNo,
RobotRoadway = stockDTO.Roadway,
- RobotSourceAddress = stockDTO.SourceLineNo,
- RobotTargetAddress = stockDTO.TargetLineNo,
+ RobotSourceAddress = taskDTO.SourceAddress,
+ RobotTargetAddress = taskDTO.TargetAddress,
RobotSourceAddressPalletCode = stockDTO.SourcePalletNo,
RobotTargetAddressPalletCode = stockDTO.TargetPalletNo,
RobotTaskType = taskDTO.TaskType,
- RobotTaskState = taskDTO.TaskState,
+ RobotTaskState = taskDTO.TaskStatus,
RobotGrade = taskDTO.Grade,
- Creater = "WMS"
+ Creater = "WMS",
+ RobotTaskTotalNum = taskDTO.TaskQuantity,
};
BaseDal.AddData(task);
@@ -108,6 +110,11 @@
public Dt_RobotTask? QueryRobotCraneTask(string deviceCode)
{
return BaseDal.QueryFirst(x => x.RobotRoadway == deviceCode && x.RobotTaskState != (int)TaskRobotStatusEnum.RobotExecuting, TaskOrderBy);
+ }
+
+ public Dt_RobotTask? QueryRobotCraneExecutingTask(string deviceCode)
+ {
+ return BaseDal.QueryFirst(x => x.RobotRoadway == deviceCode && x.RobotTaskState == (int)TaskRobotStatusEnum.RobotExecuting, TaskOrderBy);
}
public async Task<bool> UpdateRobotTaskAsync(Dt_RobotTask robotTask)
@@ -174,7 +181,7 @@
/// 灏嗛厤缃换鍔$被鍨嬭浆鎹负鎺ュ彛閰嶇疆閿��
/// 鏀寔鍊硷細Split/Group/Change锛堝ぇ灏忓啓涓嶆晱鎰燂級
/// </summary>
- private string MapRobotTaskTypeToConfigKey(string? taskType)
+ public string MapRobotTaskTypeToConfigKey(string? taskType)
{
string type = (taskType ?? string.Empty).Trim().ToLowerInvariant();
return type switch
@@ -188,7 +195,7 @@
/// <summary>
/// 鏍规嵁鎺ュ彛绫诲瀷鏋勫缓鏈烘鎵嬩换鍔″叆鍙傘��
/// </summary>
- private StockDTO BuildRobotTaskStock(Dt_Task task, string configKey)
+ public StockDTO BuildRobotTaskStock(Dt_Task task, string configKey)
{
string targetAddress = task.TargetAddress ?? string.Empty;
string roadway = ResolveRobotRuleValue(targetAddress, "AddressRoadwayMap", task.Roadway);
@@ -219,19 +226,62 @@
CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineDBNameNew.Barcode) && x.DeviceChildCode == sourceLineNo);
- ConveyorLineTaskCommandNew command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandNew>(sourceLineNo); // 娴嬭瘯鐢�
- //var barcode = conveyorLine.GetValue<ConveyorLineDBNameNew, string>(ConveyorLineDBNameNew.Barcode, sourceLineNo);
- stock.SourcePalletNo = string.IsNullOrEmpty(command.Barcode.Replace("\0", "").ToString()) ? string.Empty : command.Barcode.Replace("\0", "").ToString();
+ //ConveyorLineTaskCommandNew command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandNew>(sourceLineNo); // 娴嬭瘯鐢�
+ var barcode = conveyorLine.GetValue<ConveyorLineDBNameNew, string>(ConveyorLineDBNameNew.Barcode, sourceLineNo);
+ stock.SourcePalletNo = string.IsNullOrEmpty(barcode) ? string.Empty : barcode;
}
}
return stock;
}
+ public override WebResponseContent AddData(SaveModel saveModel)
+ {
+ try
+ {
+ if (saveModel == null || saveModel.MainData == null || saveModel.MainData.Count == 0)
+ {
+ return WebResponseContent.Instance.Error("浼犲弬閿欒,鍙傛暟涓嶈兘涓虹┖");
+ }
+
+ string validResult = typeof(Dt_RobotTask).ValidateDicInEntity(saveModel.MainData, true, TProperties);
+ if (!string.IsNullOrEmpty(validResult))
+ {
+ return WebResponseContent.Instance.Error(validResult);
+ }
+
+ object? taskNumObj = saveModel.MainData[nameof(Dt_RobotTask.RobotTaskNum)];
+ if (taskNumObj != null)
+ {
+ int taskNum = Convert.ToInt32(taskNumObj);
+ if (BaseDal.QueryFirst(x => x.RobotTaskNum == taskNum) != null)
+ {
+ return WebResponseContent.Instance.Error($"浠诲姟缂栧彿 {taskNum} 宸插瓨鍦�");
+ }
+ }
+
+ Dt_RobotTask entity = saveModel.MainData.DicToModel<Dt_RobotTask>();
+ entity.Creater = "鎵嬪姩鍒涘缓";
+ entity.CreateDate = DateTime.Now;
+
+ if (saveModel.DetailData == null || saveModel.DetailData.Count == 0)
+ {
+ BaseDal.AddData(entity);
+ return WebResponseContent.Instance.OK("鏂板鎴愬姛", entity);
+ }
+
+ return base.AddData(saveModel);
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鏂板澶辫触,閿欒淇℃伅:{ex.Message}");
+ }
+ }
+
/// <summary>
/// 鏍规嵁鐩爣鍦板潃鎸夈�岀簿纭� > 鍥為��鍊笺�嶈В鏋愯鍒欏�笺��
/// </summary>
- private string ResolveRobotRuleValue(string? targetAddress, string addressSectionName, string? fallback)
+ public string ResolveRobotRuleValue(string? targetAddress, string addressSectionName, string? fallback)
{
string address = (targetAddress ?? string.Empty).Trim();
string defaultValue = fallback ?? string.Empty;
--
Gitblit v1.9.3