|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public partial class TaskService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public WebResponseContent TaskCompleted(int taskNum) | 
|---|
|  |  |  | public async Task<WebResponseContent> TaskCompleted(int taskNum) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = Repository.QueryFirst(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | Dt_Task task = await Repository.QueryFirstAsync(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | if (task == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯"); | 
|---|
|  |  |  | return await Task.FromResult(WebResponseContent.Instance.Error($"æªæ¾å°ä»»å¡ä¿¡æ¯")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return InboundTaskCompleted(taskNum); | 
|---|
|  |  |  | return await Task.FromResult(InboundTaskCompleted(taskNum)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return OutboundTaskCompleted(taskNum); | 
|---|
|  |  |  | return await Task.FromResult(OutboundTaskCompleted(taskNum)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return RelocationTaskCompleted(task); | 
|---|
|  |  |  | return await Task.FromResult(RelocationTaskCompleted(task)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç±»åä»»å¡,ä»»å¡ç±»å:{task.TaskType}"); | 
|---|
|  |  |  | return await Task.FromResult(WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç±»åä»»å¡,ä»»å¡ç±»å:{task.TaskType}")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /// ä»»å¡ä¿¡æ¯æ¨éè³WCS | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = "") | 
|---|
|  |  |  | public WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = "", string agvtaskNum = "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | taskDTOs.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.AGVArea = agvDescription; | 
|---|
|  |  |  | x.AGVTaskNum = agvtaskNum; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string url = AppSettings.Get("WCS"); | 
|---|
|  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// åè°wcsæå¨å®æä»»å¡ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="taskNum"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent FeedBackWCSTaskCompleted(int taskNum) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_ApiInfo? url = _apiInfoRepository.QueryData(x => x.ApiCode == APIEnum.FeedBackWCSTaskCompleted.ToString()).First(); | 
|---|
|  |  |  | string? apiAddress = url.ApiAddress; | 
|---|
|  |  |  | if (string.IsNullOrEmpty(apiAddress)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"{taskNum},æªæ¾å°WCSä»»å¡å®ææ¥å£,è¯·æ£æ¥æ¥å£é
ç½®"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string responseStr = HttpHelper.Get(apiAddress + "?taskNum=" + taskNum); | 
|---|
|  |  |  | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(responseStr) ?? WebResponseContent.Instance.Error("æªæ¾å°ä»»å¡å®æè¿åå¼"); | 
|---|
|  |  |  | return content; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|