|
@@ -4,15 +4,15 @@ using System.Text;
|
|
|
|
|
|
namespace Ai.AgentServer.Server
|
|
|
{
|
|
|
- public class HttpServer: IHttpServer
|
|
|
+ public class HttpServer : IHttpServer
|
|
|
{
|
|
|
public IHttpClientFactory _httpClientFactory;
|
|
|
public ILogger _logger { get; set; }
|
|
|
public IConfiguration configuration1 { get; set; }
|
|
|
- public HttpServer(IHttpClientFactory httpClientFactory,ILogger<HttpServer> logger,IConfiguration configuration)
|
|
|
+ public HttpServer(IHttpClientFactory httpClientFactory, ILogger<HttpServer> logger, IConfiguration configuration)
|
|
|
{
|
|
|
- _httpClientFactory=httpClientFactory;
|
|
|
- _logger=logger;
|
|
|
+ _httpClientFactory = httpClientFactory;
|
|
|
+ _logger = logger;
|
|
|
configuration1 = configuration;
|
|
|
}
|
|
|
|
|
@@ -24,7 +24,7 @@ namespace Ai.AgentServer.Server
|
|
|
|
|
|
public async Task<FuelReponse> SendCommon(FuelSendRequest request)
|
|
|
{
|
|
|
- if (request == null||string.IsNullOrWhiteSpace(request.Type)) return new FuelReponse(5001, request);
|
|
|
+ if (request == null || string.IsNullOrWhiteSpace(request.Type)) return new FuelReponse(5001, request);
|
|
|
var client = _httpClientFactory.CreateClient("FuelClient");
|
|
|
var xunfeiUrl = "http://211.91.71.15:8899";
|
|
|
|
|
@@ -32,8 +32,8 @@ namespace Ai.AgentServer.Server
|
|
|
{
|
|
|
xunfeiUrl = configuration1.GetSection("XunFei").Value;
|
|
|
}
|
|
|
-
|
|
|
- client.BaseAddress =new Uri(xunfeiUrl);
|
|
|
+
|
|
|
+ client.BaseAddress = new Uri(xunfeiUrl);
|
|
|
var requestJson = JsonConvert.SerializeObject(request.BuildDto());
|
|
|
_logger.LogInformation($"讯飞request:{DateTime.Now}-{requestJson}");
|
|
|
var requesStr = new StringContent(requestJson, Encoding.UTF8, "application/json");
|
|
@@ -47,7 +47,7 @@ namespace Ai.AgentServer.Server
|
|
|
var fuelreponse = JsonConvert.DeserializeObject<FuelReponse>(await response.Content.ReadAsStringAsync());
|
|
|
return fuelreponse.SetID(request);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -58,5 +58,37 @@ namespace Ai.AgentServer.Server
|
|
|
}
|
|
|
return new FuelReponse(5000, request);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public FuelReponse GetFackData(FuelSendRequest request)
|
|
|
+ {
|
|
|
+ FuelReponse fuelReponse = new FuelReponse(200, request);
|
|
|
+ Data data = new Data();
|
|
|
+ switch (request.Type)
|
|
|
+ {
|
|
|
+ case "refuel_password_current":
|
|
|
+ data.OilLiters = "10.00";
|
|
|
+ data.OilAmount = "0.00";
|
|
|
+ data.LicensePlate = "京A32012";
|
|
|
+ break;
|
|
|
+ case "refuel_no_password_enter":
|
|
|
+ data.OilLiters = "0.00";
|
|
|
+ data.OilAmount = "10.00";
|
|
|
+ data.LicensePlate = "京A32012";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ data.OilAmount = "0.00";
|
|
|
+ data.OilLiters = "0.00";
|
|
|
+ data.LicensePlate = null;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ fuelReponse.Data = data;
|
|
|
+ return fuelReponse;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|