|  |  |  | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public partial class TaskService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //public WebResponseContent TaskCompleted(int taskNum) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    try | 
|---|
|  |  |  | //    { | 
|---|
|  |  |  | //        Dt_Task task = Repository.QueryFirst(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | //        if (task == null) | 
|---|
|  |  |  | //        { | 
|---|
|  |  |  | //            return WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if(task.TaskType.get) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | //    catch (Exception ex) | 
|---|
|  |  |  | //    { | 
|---|
|  |  |  | //        return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | public WebResponseContent TaskCompleted(int taskNum) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = Repository.QueryFirst(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | if (task == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return InboundTaskCompleted(taskNum); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return OutboundTaskCompleted(taskNum); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (task.TaskType.GetTaskTypeGroup() != TaskTypeGroup.RelocationGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return RelocationTaskCompleted(task); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç±»åä»»å¡,ä»»å¡ç±»å:{task.TaskType}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»»å¡ä¿¡æ¯æ¨éè³WCS | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | if (task == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"é误,æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { _mapper.Map<WMSTaskDTO>(task) }; | 
|---|
|  |  |  | taskDTOs.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.AGVArea = agvDescription; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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("è¿åé误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|