Sfoglia il codice sorgente

更新最后版本

devin.zhu@doverfs.com 9 mesi fa
parent
commit
b291550d6f

+ 12 - 0
Ai.AgentServer/.config/dotnet-tools.json

@@ -0,0 +1,12 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {
+    "dotnet-ef": {
+      "version": "8.0.7",
+      "commands": [
+        "dotnet-ef"
+      ]
+    }
+  }
+}

+ 0 - 12
Ai.AgentServer/Ai.AgentServer.sln

@@ -5,10 +5,6 @@ VisualStudioVersion = 17.8.34601.278
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ai.AgentServer", "Ai.AgentServer.csproj", "{6AEF0967-D649-41FA-BA7A-88FB5539CB45}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleMQTT", "C:\Users\11047158\Downloads\SimpleMQTT-master\SimpleMQTT-master\SimpleMQTT\SimpleMQTT.csproj", "{67B8C5EE-FC91-4683-B474-274B5FCE703F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTClient", "..\MQTTClient\MQTTClient.csproj", "{5F0DCC50-9CD6-45DB-A6C6-E944B0EBED42}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -19,14 +15,6 @@ Global
 		{6AEF0967-D649-41FA-BA7A-88FB5539CB45}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{6AEF0967-D649-41FA-BA7A-88FB5539CB45}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{6AEF0967-D649-41FA-BA7A-88FB5539CB45}.Release|Any CPU.Build.0 = Release|Any CPU
-		{67B8C5EE-FC91-4683-B474-274B5FCE703F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{67B8C5EE-FC91-4683-B474-274B5FCE703F}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{67B8C5EE-FC91-4683-B474-274B5FCE703F}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{67B8C5EE-FC91-4683-B474-274B5FCE703F}.Release|Any CPU.Build.0 = Release|Any CPU
-		{5F0DCC50-9CD6-45DB-A6C6-E944B0EBED42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{5F0DCC50-9CD6-45DB-A6C6-E944B0EBED42}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{5F0DCC50-9CD6-45DB-A6C6-E944B0EBED42}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{5F0DCC50-9CD6-45DB-A6C6-E944B0EBED42}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

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

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

+ 1 - 0
Ai.AgentServer/Controllers/WeatherForecastController.cs

@@ -1,3 +1,4 @@
+using Ai.AgentServer.Server;
 using Microsoft.AspNetCore.Mvc;
 
 namespace Ai.AgentServer.Controllers

+ 0 - 74
Ai.AgentServer/MQTTSetup.cs

@@ -1,74 +0,0 @@
-//using Ai.AgentServer.Server.Mqtt_Ext;
-
-//namespace Ai.AgentServer
-//{
-//    /// <summary>
-//    /// Mqtt客户端扩展类
-//    /// </summary>
-//    public static class MQTTSetup
-//    {
-//        /// <summary>
-//        /// 添加Mqtt客户端服务
-//        /// </summary>
-//        /// <param name="services"></param>
-//        /// <exception cref="ArgumentNullException"></exception>
-//        public static void AddMqttClientManager(this IServiceCollection services)
-//        {
-//            if (services == null) throw new ArgumentNullException(nameof(services));
-//            //services.AddSingleton<IMqttClientManager, MqttClientManager>();
-//        }
-
-//        /// <summary>
-//        /// 添加Mqtt客户端服务
-//        /// </summary>
-//        /// <param name="services"></param>
-//        /// <param name="configuration">IConfiguration</param>
-//        /// <param name="section">配置文件节点</param>
-//        /// <param name="start">立即启动</param>
-//        /// <exception cref="ArgumentNullException"></exception>
-//        public static void AddMqttClientManager(this IServiceCollection services, IConfiguration configuration, string section = "MqttSettings", bool start = true)
-//        {
-//            if (services == null) throw new ArgumentNullException(nameof(services));
-//            MqttClientConfig config = configuration.GetSection(section).Get<MqttClientConfig>();//获取配置配置
-//            if (config != null && !string.IsNullOrEmpty(config.Host))
-//            {
-//                services.AddSingleton<IMqttClientManager, MqttClientManager>(x => new MqttClientManager(config, start));
-//            }
-//            else
-//            {
-//                List<MqttClientConfig> configs = configuration.GetSection(section).Get<List<MqttClientConfig>>();//获取配置配置
-//                if (configs == null) throw new ArgumentException("mqtt配置未找到,请配置mqtt链接信息", nameof(configuration));
-//                services.AddSingleton<IMqttClientManager, MqttClientManager>(x => new MqttClientManager(configs, start));
-//            }
-
-//        }
-
-//        /// <summary>
-//        /// 添加Mqtt客户端服务
-//        /// </summary>
-//        /// <param name="services"></param>
-//        /// <param name="config">mqtt配置</param>
-//        /// <param name="start">立即启动</param>
-//        /// <exception cref="ArgumentNullException"></exception>
-//        public static void AddMqttClientManager(this IServiceCollection services, MqttClientConfig config, bool start = true)
-//        {
-
-//            if (services == null) throw new ArgumentNullException(nameof(services));
-//            services.AddSingleton<IMqttClientManager, MqttClientManager>(x => new MqttClientManager(config, start));
-//        }
-
-//        /// <summary>
-//        /// 添加Mqtt客户端服务
-//        /// </summary>
-//        /// <param name="services"></param>
-//        /// <param name="configs">mqtt配置</param>
-//        /// <param name="start">立即启动</param>
-//        /// <exception cref="ArgumentNullException"></exception>
-//        public static void AddMqttClientManager(this IServiceCollection services, List<MqttClientConfig> configs, bool start = true)
-//        {
-//            if (services == null) throw new ArgumentNullException(nameof(services));
-//            services.AddSingleton<IMqttClientManager, MqttClientManager>(x => new MqttClientManager(configs, start));
-//        }
-
-//    }
-//}

+ 1 - 0
Ai.AgentServer/Server/CommonMessageHandle.cs

@@ -41,6 +41,7 @@ namespace Ai.AgentServer.Server
                         case 10000:
                             LockNozzle(deviceId, messageDto);
                             break;
+
                     }
                 }
             }

+ 4 - 0
Ai.AgentServer/Server/FuelDto/FuelSendRequest.cs

@@ -66,6 +66,8 @@ namespace Ai.AgentServer.Server.Fuel
 
 
 
+
+
         /// <summary>
         /// 转成讯飞的文档实体对象   or 格灵深瞳的实体对象
         /// </summary>
@@ -77,6 +79,7 @@ namespace Ai.AgentServer.Server.Fuel
                 textInput=new  Textinput()
             };
             dto.textInput.type = Type;
+
             switch (Type) {
                 case "refuel_card_refund":
                     dto.textInput.payload = new Refuel_card_refund() { 
@@ -104,6 +107,7 @@ namespace Ai.AgentServer.Server.Fuel
                 default:
                     dto.textInput.payload = new CardPayload(cardType: CardType, oilCode: OilCode, nozzleNo: NozzleNo);
                     break;
+
             }
             return dto;
         }

+ 4 - 0
Ai.AgentServer/Server/FuelDto/HttpThirdRequest.cs

@@ -17,6 +17,8 @@
         public string userId { get; set; }
     }
 
+
+
     public class Textinput
     {
         public Object payload { get; set; }
@@ -105,6 +107,8 @@
         public int LicensePlateMatching { get; set; }
     }
 
+
+
     ///// <summary>
     ///// 一键加油授权
     ///// </summary>

+ 0 - 36
Ai.AgentServer/Server/Mqtt_Ext/IMqttClientManager.cs

@@ -1,36 +0,0 @@
-//using NewLife.MQTT;
-
-//namespace Ai.AgentServer.Server.Mqtt_Ext
-//{
-//    /// <summary>
-//    /// MQTT客户端服务
-//    /// </summary>
-//    public interface IMqttClientManager
-//    {
-//        /// <summary>
-//        /// 添加mqtt客户端
-//        /// </summary>
-//        /// <param name="config">配置信息</param>
-//        void AddClient(MqttClientConfig config);
-
-//        /// <summary>
-//        /// 获取mqtt客户端
-//        /// </summary>
-//        /// <param name="name">客户端名称</param>
-//        /// <returns></returns>
-//        MqttClient GetClient(string name = "Mqtt");
-
-//        /// <summary>
-//        /// 获取所有客户端
-//        /// </summary>
-//        /// <returns></returns>
-//        List<MqttClient> GetClients();
-
-//        /// <summary>
-//        /// 启动Mqtt客户端
-//        /// </summary>
-//        /// <param name="name">客户端名称</param>
-//        /// <returns></returns>
-//        bool StartClient(string name = "Mqtt");
-//    }
-//}

+ 0 - 157
Ai.AgentServer/Server/Mqtt_Ext/MqttClientManager.cs

@@ -1,157 +0,0 @@
-//using NewLife.MQTT;
-//using System.Security.Authentication;
-
-//namespace Ai.AgentServer.Server.Mqtt_Ext
-//{
-//    /// <summary>
-//    /// <inheritdoc cref="IMqttClientManager"/>
-//    /// </summary>
-//    public class MqttClientManager : IMqttClientManager
-//    {
-//        /// <summary>
-//        /// mqtt对象列表
-//        /// </summary>
-//        private List<MqttClient> MqttClients = new List<MqttClient>();
-
-//        public MqttClientManager(IConfiguration configuration)
-//        {
-//            MqttClientConfig config = configuration.GetSection("MqttSettings").Get<MqttClientConfig>();//获取配置配置
-//            if (config != null && !string.IsNullOrEmpty(config.Host))
-//            {
-//                //如果配置不是空则创建连接
-//                AddClient(config);
-//                StartClient(config.Name);
-//            }
-//            else
-//            {
-//                //配置是空,试试是不是多个客户端配置
-//                List<MqttClientConfig> configs = configuration.GetSection("MqttSettings").Get<List<MqttClientConfig>>();//获取配置配置
-//                if (configs != null)
-//                {
-//                    //如果不为空,创建连接
-//                    configs.ForEach(it =>
-//                    {
-//                        AddClient(it);
-//                        StartClient(it.Name);
-//                    });
-//                }
-//                else
-//                {
-//                    throw new ArgumentException("mqtt配置未找到,请配置mqtt链接信息", nameof(config));
-//                }
-//            }
-//        }
-
-//        public MqttClientManager(MqttClientConfig config, bool start = false)
-//        {
-//            //如果配置不是空则创建连接
-//            AddClient(config);
-//            if (start)
-//                StartClient(config.Name);
-//        }
-
-//        public MqttClientManager(List<MqttClientConfig> configs, bool start = false)
-//        {
-//            //如果不为空,创建连接
-//            configs.ForEach(it =>
-//            {
-//                AddClient(it);
-//                if (start)
-//                    StartClient(it.Name);
-//            });
-//        }
-
-
-//        /// <inheritdoc/>
-//        public void AddClient(MqttClientConfig config)
-//        {
-//            if (!string.IsNullOrEmpty(config.Host))
-//            {
-//                if (MqttClients.Any(it => it.Name == config.Name))
-//                    throw new ArgumentException("mqtt配置错误,Name属性唯一", nameof(config));
-//                var client = new MqttClient
-//                {
-//                    Server = $"tcp://{config.Host}:{config.Port}",
-//                    Name = config.Name,
-//                    UserName = config.UserName,
-//                    Password = config.SecretKey,
-//                    ClientId = config.ClientId,
-//                    KeepAlive = config.KeepAlive,
-//                    Reconnect = config.Reconnect,
-//                    CleanSession = config.CleanSession,
-//                    Timeout = config.Timeout,
-//                    SslProtocol = config.UseSSL ? SslProtocols.Tls13 : SslProtocols.None,
-
-//                };
-//                client.Connected += MqttClient_Connected;
-//                client.Disconnected += MqttClient_Disconnected;
-//                MqttClients.Add(client);
-//            }
-//            else
-//            {
-//                throw new ArgumentException("mqtt配置错误,请配置mqtt链接信息", nameof(config));
-//            }
-
-
-//        }
-
-
-//        /// <inheritdoc/>
-//        public bool StartClient(string name = "Mqtt")
-//        {
-//            //获取mqtt连接
-//            var client = MqttClients.Where(it => it.Name == name).FirstOrDefault();
-//            if (client != null)//获取不为空
-//            {
-//                try
-//                {
-//                    client.ConnectAsync().Wait();//连接服务器
-//                }
-//                catch (Exception ex)
-//                {
-//                    throw ex;
-//                }
-
-//                return client.IsConnected;//返回连接状态
-//            }
-//            else { return false; }
-//        }
-
-
-//        /// <inheritdoc/>
-//        public MqttClient GetClient(string name = "Mqtt")
-//        {
-//            var client = MqttClients.Where(it => it.Name == name).FirstOrDefault();
-//            if (client != null) return client;
-//            else return null;
-//        }
-
-//        /// <inheritdoc/>
-//        public List<MqttClient> GetClients()
-//        {
-//            return MqttClients;
-//        }
-
-//        /// <summary>
-//        /// 断开事件
-//        /// </summary>
-//        /// <param name="sender"></param>
-//        /// <param name="e"></param>
-//        private void MqttClient_Disconnected(object sender, EventArgs e)
-//        {
-//            var client = ((MqttClient)sender);
-//            Console.WriteLine($"已断开{client.Name}服务端!:" + DateTime.Now);
-//        }
-
-//        /// <summary>
-//        /// 连接事件
-//        /// </summary>
-//        /// <param name="sender"></param>
-//        /// <param name="e"></param>
-//        private void MqttClient_Connected(object sender, EventArgs e)
-//        {
-//            var client = ((MqttClient)sender);
-//            Console.WriteLine($"已连接{client.Name}的服务端!:" + DateTime.Now);
-//        }
-//    }
-//}

+ 1 - 0
Ai.AgentServer/Server/Mqtt_Ext/MqttClientService.cs

@@ -64,6 +64,7 @@ namespace Ai.AgentServer
         private Task _mqttClient_DisconnectedAsync(MqttClientDisconnectedEventArgs arg)
         {
             Console.WriteLine($"客户端已断开与服务端的连接……");
+
             return Task.CompletedTask;
         }
 

+ 1 - 1
Ai.AgentServer/WeatherForecast.cs → Ai.AgentServer/Server/WeatherForecast.cs

@@ -1,4 +1,4 @@
-namespace Ai.AgentServer
+namespace Ai.AgentServer.Server
 {
     public class WeatherForecast
     {

+ 2 - 0
Ai.AgentServer/appsettings.json

@@ -9,6 +9,8 @@
   "XunFei": "",
   "GeLin": "",
   "Sysurl": "http://192.168.0.53:9001",
+
+
   "MqttSettings": {
     "Name": "Mqtt",
     "Host": "192.168.0.166",