1
647556386
2025-04-17 a95a257a702360e7632b5daeb5b554163382720c
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.APIEnum;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OtherEnum;
@@ -29,14 +30,17 @@
                }
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                {
                    FeedBackWCSTaskCompleted(taskNum);
                    return InboundTaskCompleted(taskNum);
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    FeedBackWCSTaskCompleted(taskNum);
                    return OutboundTaskCompleted(taskNum);
                }
                else if (task.TaskType.GetTaskTypeGroup() != TaskTypeGroup.RelocationGroup)
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
                {
                    FeedBackWCSTaskCompleted(taskNum);
                    return RelocationTaskCompleted(task);
                }
                else
@@ -69,7 +73,13 @@
                {
                    x.AGVArea = agvDescription;
                });
                string response = HttpHelper.Post("http://127.0.0.1:9281/api/Task/ReceiveTask", taskDTOs.Serialize());
                string url = AppSettings.Get("WCS");
                if (string.IsNullOrEmpty(url))
                {
                    throw new Exception($"未找到WCSAApi地址,请检查配置文件");
                }
                string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize());
                return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误");
            }
@@ -79,9 +89,50 @@
            }
        }
        //public WebResponseContent UpdateTaskInfo(WCSTaskDTO taskDTO)
        //{
        /// <summary>
        /// ä¿®æ”¹ä»»åŠ¡çŠ¶æ€
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public WebResponseContent UpdateTaskInfo(WCSTaskDTO task)
        {
            try
            {
                Dt_Task wmsTask = BaseDal.QueryFirst(x=>x.TaskNum == task.TaskNum);
                if (wmsTask != null)
                {
                    wmsTask.TaskStatus = task.TaskState;
                    wmsTask.CurrentAddress = task.CurrentAddress;
                    wmsTask.NextAddress = task.NextAddress;
                    wmsTask.Dispatchertime = task.Dispatchertime;
                    BaseDal.UpdateData(wmsTask);
                }
                return WebResponseContent.Instance.OK();
            }
            catch(Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public WebResponseContent FeedBackWCSTaskCompleted(int taskNum)
        {
            try
            {
                Dt_ApiInfo? url = _apiInfoRepository.QueryData(x => x.ApiCode == APIEnum.FeedBackWCSTaskCompleted.ToString()).First();
                string? apiAddrss = url.ApiAddress;
                if (string.IsNullOrEmpty(apiAddrss))
                {
                    return WebResponseContent.Instance.Error($"{taskNum},未找到WCS任务完成接口,请检查接口配置");
                }
                string responseStr = HttpHelper.Get(apiAddrss + "?taskNum=" + taskNum);
                WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(responseStr) ?? WebResponseContent.Instance.Error("未找到任务完成返回值");
                return content;
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        //}
        }
    }
}