From 5ccef03578cac085fecb4afd96e48bdf42df3aef Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期四, 04 十二月 2025 10:23:30 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs |   58 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 15 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs"
index 5bc2bc6..659a98c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/ESSApiService.cs"
@@ -6,6 +6,7 @@
 using System.Linq;
 using System.Text;
 using System.Text.Json;
+using System.Threading;
 using System.Threading.Tasks;
 using WIDESEA_DTO.Basic;
 using WIDESEA_IBasicService;
@@ -25,12 +26,29 @@
         /// <summary>
         /// 瀹瑰櫒娴佸姩閫氱煡
         /// </summary>
-        public async Task MoveContainerAsync(MoveContainerRequest request)
+        public async Task<bool> MoveContainerAsync(MoveContainerRequest request)
         {
-            var url = "conveyor/moveContainer";
-
-            var result = await PostAsync<MoveContainerRequest, ApiResponse<string>>(url, request);
-
+            try
+            {
+                var url = "conveyor/moveContainer";
+                _logger.LogInformation("ESSApiService MoveContainerAsync Request:  " + JsonConvert.SerializeObject(request));
+                var result = await PostAsync<MoveContainerRequest, ApiResponse<string>>(url, request);
+                if (result != null && result.Code == 0)
+                {
+                    //{"code":0,"msg":"success","data":{"107":"TASK_ALREADY_EXIST"}}
+                    if (result.Data.Contains("TASK_ALREADY_EXIST"))
+                    {
+                        return false;
+                    }
+                    return true;
+                }
+                return false;
+            }
+            catch (Exception ex)
+            {
+                _logger.LogInformation("ESSApiService 瀹瑰櫒娴佸姩澶辫触:  " + ex.Message);
+                return false;
+            }
         }
 
         /// <summary>
@@ -40,21 +58,30 @@
         /// <returns></returns>
         public async Task<bool> CreateTaskAsync(TaskModel request)
         {
-            _logger.LogInformation("鍒涘缓浠诲姟Request:  " +  JsonConvert.SerializeObject(request));
-            var url = "task/create";
-
-            var result = await PostAsync<TaskModel, ApiResponse<TasksData>>(url, request);
-            if (result != null && result.Code == 0)
+            try
             {
-                return true;
-            }
-            return false;
-        }
+                _logger.LogInformation("ESSApiService 鍒涘缓浠诲姟Request:  " + JsonConvert.SerializeObject(request));
+                var url = "task/create";
 
+                var result = await PostAsync<TaskModel, ApiResponse<TasksData>>(url, request);
+                if (result != null && result.Code == 0)
+                {
+                    return true;
+                }
+                return false;
+            }
+            catch (Exception ex)
+            {
+                _logger.LogInformation("ESSApiService 鍒涘缓浠诲姟澶辫触:  " + ex.Message);
+                return false;
+            }
+        }
+ 
 
 
         private async Task<TResponse> PostAsync<TRequest, TResponse>(string url, TRequest request)
         {
+
             string json = JsonConvert.SerializeObject(request, new JsonSerializerSettings
             {
                 ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
@@ -67,13 +94,14 @@
 
             using var response = await _client.PostAsync(url, content);
             string body = await response.Content.ReadAsStringAsync();
-            _logger.LogInformation($"ESSAPI post :  {_client.BaseAddress}  {url}   {body}" );
+            _logger.LogInformation($"ESSAPI post :  {_client.BaseAddress}  {url}   {body}");
             if (!response.IsSuccessStatusCode)
             {
                 throw new HttpRequestException(body);
             }
 
             return JsonConvert.DeserializeObject<TResponse>(body);
+
         }
     }
 }

--
Gitblit v1.9.3