wangxinhui
2025-11-30 f2b85c65234e0dcdd3fcce4dafbe16933b7f1b48
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs
@@ -1,4 +1,6 @@
using Autofac.Core;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -15,19 +17,24 @@
{
    public partial class TaskService
    {
        // åˆ›å»ºä¸€ä¸ªä½¿ç”¨å°é©¼å³°å‘½åæ³•的序列化设置
        JsonSerializerSettings settings = new JsonSerializerSettings
        {
            ContractResolver = new CamelCasePropertyNamesContractResolver()
        };
        public WebResponseContent AgvSendTask(AgvTaskSendDTO taskModel, APIEnum SendTask = APIEnum.AgvSendTask)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == SendTask.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到发送AGV任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, taskModel.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "0")
                string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == SendTask.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"未找到发送AGV任务接口,请检查接口配置");
                string request = JsonConvert.SerializeObject(taskModel, settings);
                string response = HttpHelper.Post(apiAddress, request);
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>() ?? throw new Exception("AGV任务发送未返回结果");
                if (agvContent.Success)
                {
                    content.OK(data: agvContent.Data);
                    content.OK();
                }
                else
                {