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 |   64 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
index 465fcb5..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)
@@ -219,15 +226,58 @@
                     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>

--
Gitblit v1.9.3