Explorar o código

扩展结构json返回

devin.zhu@doverfs.com hai 9 meses
pai
achega
10c7db9ad7

+ 2 - 1
Ai.AgentServer/Controllers/FccController.cs

@@ -47,8 +47,9 @@ namespace Ai.AgentServer.Controllers
             var reponse=await _server.SendCommon(body);
 
             //¸ñÁéµ÷ÓÃ
-            await _mqttServer.PublicMessage(body.AIId,body.Type, body.BuildDto());
+            reponse.MQTT_Public=await _mqttServer.PublicMessage(body.AIId,body.Type, body.BuildDto());
 
+            reponse.DataJson = body.BuildDto();
             return reponse;
         }
 

+ 2 - 0
Ai.AgentServer/Server/FuelDto/FuelReponse.cs

@@ -23,6 +23,8 @@
 
         public bool MQTT_Public { get; set; }
 
+        public object DataJson { get; set; }
+
         /// <summary>
         /// 给响应结构赋值应用id 和 命令类型
         /// </summary>

+ 1 - 1
Ai.AgentServer/Server/FuelDto/HttpThirdRequest.cs

@@ -6,7 +6,7 @@
     /// </summary>
     public class HttpThirdRequest
     {
-        public string callId { get; set; } = new Guid().ToString();
+        public string callId { get; set; } =  Guid.NewGuid().ToString();
         public int inType { get; set; } = 2;
         public Textinput textInput { get; set; }
         public string useType { get; set; } = "virtual";

+ 1 - 1
Ai.AgentServer/Server/HttpServer.cs

@@ -24,7 +24,7 @@ namespace Ai.AgentServer.Server
             var client = _httpClientFactory.CreateClient("FuelClient");
             //配置文件读取
             client.BaseAddress =new Uri("http://211.91.71.15:8899");
-            var requesStr = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
+            var requesStr = new StringContent(JsonConvert.SerializeObject(request.BuildDto()), Encoding.UTF8, "application/json");
             try
             {
                 var response = await client.PostAsync("/app-control-center/app/manualDrive", requesStr);

+ 6 - 5
Ai.AgentServer/Server/MqttServer.cs

@@ -17,12 +17,12 @@ namespace Ai.AgentServer.Server
         }
 
 
-        public Task<bool> PublicMessage(string topic,string type, HttpThirdRequest request)
+        public async Task<bool> PublicMessage(string topic,string type, HttpThirdRequest request)
         {
             //暂时指传递交易上传的类型数据  && type!= "refuel_out_process"
             if (string.IsNullOrEmpty(type)) {
                 Console.WriteLine($"type{type}命令不能为空 {DateTime.Now}");
-                return Task.FromResult(false);
+                return false;
             }
 
             var requestDto= new MqttRequestDto();
@@ -45,14 +45,15 @@ namespace Ai.AgentServer.Server
             try
             {
                 requestDto.Data = request;
-                MqttClientService._mqttClient.PublishStringAsync($"/ToServer/{topic}", JsonConvert.SerializeObject(requestDto));
+                var result=await MqttClientService._mqttClient.PublishStringAsync($"/ToServer/{topic}", JsonConvert.SerializeObject(requestDto));
+                return result.IsSuccess;
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
-                return Task.FromResult(false);
+                return false;
             }
-            return Task.FromResult(true);
+     
         }
     }
 }

+ 1 - 0
Ai.AgentServer/appsettings.json

@@ -8,6 +8,7 @@
   "AllowedHosts": "*",
   "XunFei": "",
   "GeLin": "",
+  "Sysurl": "系统内部地址",
   "MqttSettings": {
     "Name": "Mqtt",
     "Host": "192.168.0.166",