diff --git a/Entity/Api/Req/TestReq.cs b/Entity/Api/Req/TestReq.cs new file mode 100644 index 0000000..34685a6 --- /dev/null +++ b/Entity/Api/Req/TestReq.cs @@ -0,0 +1,10 @@ +namespace Entity.Api.Req; + +public class TestReq +{ + + /// + /// 序号 + /// + public int Id { get; set; } +} \ No newline at end of file diff --git a/Entity/Api/Resp/PlcSwapModelResp.cs b/Entity/Api/Resp/PlcSwapModelResp.cs new file mode 100644 index 0000000..1aeeb88 --- /dev/null +++ b/Entity/Api/Resp/PlcSwapModelResp.cs @@ -0,0 +1,27 @@ +namespace Entity.Api.Resp; +/// +/// +/// 换电plc模式 +/// +public class PlcSwapModelResp +{ + /// + /// 模式状态[40318]-10001:手动模式;10002:自动模式;10003:维修模式; + /// + public int ModelState { get; set; } + + /// + /// 遥本控状态[40319]-0:无效值;10000:本地控制;10001:远程控制 + /// + public int ControlModel { get; set; } + + /// + /// 站外灯状态值【40506】1000:绿灯;0:黄灯;1001:红灯。 + /// + public int StationInLampSts { get; set; } + + /// + /// 站内灯状态值【40507】0:无颜色;1000:绿灯;1001:红灯;1002:黄灯;1003:黄灯闪烁。 + /// + public int StationOutLampSts { get; set; } +} \ No newline at end of file diff --git a/Entity/Api/Resp/SwapMonitorScreenResp.cs b/Entity/Api/Resp/SwapMonitorScreenResp.cs new file mode 100644 index 0000000..0b0d91c --- /dev/null +++ b/Entity/Api/Resp/SwapMonitorScreenResp.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Entity.Api.Resp; +/// +/// 首页大屏 +/// + + +public class SwapMonitorScreenResp +{ + + /// + /// plc模式 + /// + public PlcSwapModelResp? PlcSwapModel { get; set; } + /// + /// 换电状态 + /// + public SwappingStateInfoResp? StateInfo{ get; set; } + /// + /// 换电车辆 + /// + public SwapVehicleResp? VehicleInfo{ get; set; } + /// + /// 蓝牙 + /// + public TboxResp? TboxInfo{ get; set; } + /// + /// 是否自动 + /// + public bool IsAuto{ get; set; } + /// + /// 云平台是否连接 + /// + public bool CloudIsConnected{ get; set; } +} \ No newline at end of file diff --git a/Entity/Api/Resp/SwapVehicleResp.cs b/Entity/Api/Resp/SwapVehicleResp.cs new file mode 100644 index 0000000..1311b00 --- /dev/null +++ b/Entity/Api/Resp/SwapVehicleResp.cs @@ -0,0 +1,32 @@ +namespace Entity.Api.Resp; + +/// +/// 换电车辆信息 +/// +public class SwapVehicleResp +{ + /// + /// 换电订单号 + /// + public string? OrderNo{ get; set; } + + /// + /// 车辆VIN码 + /// + public string? VelVin{ get; set; } + + /// + /// 车型 + /// + public string? VelType{ get; set; } + + /// + /// 车辆MAC地址 + /// + public string? VelMac{ get; set; } + + /// + /// 车牌号 + /// + public string? VelNo{ get; set; } +} \ No newline at end of file diff --git a/Entity/Api/Resp/SwappingStateInfoResp.cs b/Entity/Api/Resp/SwappingStateInfoResp.cs new file mode 100644 index 0000000..38f9c49 --- /dev/null +++ b/Entity/Api/Resp/SwappingStateInfoResp.cs @@ -0,0 +1,21 @@ +namespace Entity.Api.Resp; + +/// +/// 实时换电状态 +/// +public class SwappingStateInfoResp +{ + /// + /// 换电步序号 + /// + public int StepNo{ get; set; } + /// + /// 换电步序名称 + /// + public string? StepName{ get; set; } + /// + /// 换电步序时刻 + /// + public DateTime StartTime{ get; set; } + +} \ No newline at end of file diff --git a/Entity/Api/Resp/TboxResp.cs b/Entity/Api/Resp/TboxResp.cs new file mode 100644 index 0000000..d93e913 --- /dev/null +++ b/Entity/Api/Resp/TboxResp.cs @@ -0,0 +1,51 @@ +namespace Entity.Api.Resp; +/// +/// TBOX +/// +public class TboxResp +{ + /// + /// 车载电池SN码 + /// + public string? BatteryNo { get; set; } + /// + /// 车载电池SOC + /// + public float BatterySoc { get; set; } + /// + /// 蓝牙连接状态.0:未连接;1:连接 + /// + public int? M2tConnectSts { get; set; } + /// + /// 上高压状态.1:上高压;0:下高压 + /// + public int MainEegCnctrSts { get; set; } + /// + /// BMS换电状态.0:空闲;1:换电准备;2、换电中;3、换电完成;5、原包安装完成 + /// + public int BmsSwapSts { get; set; } + /// + /// 车辆状态.0:熄火;1:准备; + /// + public int VehPowerMode { get; set; } + /// + /// 锁总体状态.0:无效,1:上锁,2:解锁,3:异常 + /// + public int PackLockSts { get; set; } + /// + /// 锁1状态.0:无效,1:上锁,2:解锁,3:异常 + /// + public int PackDetailLock1Sts { get; set; } + /// + /// 锁2状态.0:无效,1:上锁,2:解锁,3:异常 + /// + public int PackDetailLock2Sts { get; set; } + /// + /// 锁3状态.0:无效,1:上锁,2:解锁,3:异常 + /// + public int PackDetailLock3Sts { get; set; } + /// + /// 锁4状态.0:无效,1:上锁,2:解锁,3:异常 + /// + public int PackDetailLock4Sts { get; set; } +} \ No newline at end of file diff --git a/Entity/Entity.csproj b/Entity/Entity.csproj index eaed5f7..1b6bf15 100644 --- a/Entity/Entity.csproj +++ b/Entity/Entity.csproj @@ -6,6 +6,14 @@ enable + + bin\Debug\Entity.xml + + + + bin\Release\Entity.xml + + @@ -14,4 +22,8 @@ + + + + diff --git a/HybirdFrameworkCore/Entity/DatetimeJsonConverter.cs b/HybirdFrameworkCore/Entity/DatetimeJsonConverter.cs new file mode 100644 index 0000000..4e0facd --- /dev/null +++ b/HybirdFrameworkCore/Entity/DatetimeJsonConverter.cs @@ -0,0 +1,27 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace HybirdFrameworkCore.Entity; + + +/// +/// 序列化 +/// +public class DatetimeJsonConverter : JsonConverter +{ + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.String) + { + if (DateTime.TryParse(reader.GetString(), out DateTime date)) + return date; + } + + return reader.GetDateTime(); + } + + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss")); + } +} \ No newline at end of file diff --git a/HybirdFrameworkCore/Entity/QueryPageModel.cs b/HybirdFrameworkCore/Entity/QueryPageModel.cs new file mode 100644 index 0000000..b8bfd4a --- /dev/null +++ b/HybirdFrameworkCore/Entity/QueryPageModel.cs @@ -0,0 +1,13 @@ +namespace HybirdFrameworkCore.Entity; + +public class QueryPageModel +{ + /// + ///页码 + /// + public int Page { get; set; } = 1; + /// + /// 页数 + /// + public int PageSize { get; set; } = 10; +} \ No newline at end of file diff --git a/HybirdFrameworkCore/Entity/Result.cs b/HybirdFrameworkCore/Entity/Result.cs new file mode 100644 index 0000000..3bc3134 --- /dev/null +++ b/HybirdFrameworkCore/Entity/Result.cs @@ -0,0 +1,104 @@ +namespace HybirdFrameworkCore.Entity +{ + /// + /// 通用返回信息类 + /// + public class Result + { + /// + /// 状态码 + /// + + public int Status { get; set; } = 200; + /// + /// 操作是否成功 + /// + public bool IsSuccess { get; set; } = false; + /// + /// 返回信息 + /// + public string? Msg { get; set; } + + /// + /// 返回数据集合 + /// + public T? Data { get; set; } + + /// + /// 返回成功 + /// + /// 消息 + /// + public static Result Success(string msg = "成功") + { + return Message(true, msg, default); + } + + + + /// + /// 返回成功 + /// + /// 数据 + /// 消息 + /// + public static Result Success(T data, string msg = "成功") + { + return Message(true, msg, data); + } + + + + /// + /// 返回失败 + /// + /// 消息 + /// + public static Result Fail(string msg = "失败") + { + return Message(false, msg, default); + } + + + /// + /// 返回失败 + /// + /// 消息 + /// 数据 + /// + public static Result Fail(T data, string msg = "失败") + { + return Message(false, msg, data); + } + + /// + /// 返回消息 + /// + /// 失败/成功 + /// 消息 + /// 数据 + /// + public static Result Message(bool success, string msg, T data) + { + return new Result() { Msg = msg, Data = data, IsSuccess = success }; + } + + /// + /// 返回消息 + /// + /// 失败/成功 + /// 消息 + /// 数据 + /// + public static Result Message(bool success, T data) + { + return new Result() { Msg="查询成功", Data = data, IsSuccess = success }; + } + + + + } + + + +} diff --git a/HybirdFrameworkCore/HybirdFrameworkCore.csproj b/HybirdFrameworkCore/HybirdFrameworkCore.csproj index ae3db33..cefc47f 100644 --- a/HybirdFrameworkCore/HybirdFrameworkCore.csproj +++ b/HybirdFrameworkCore/HybirdFrameworkCore.csproj @@ -6,6 +6,14 @@ enable + + bin\Debug\HybirdFrameworkCore.xml + + + + bin\Release\HybirdFrameworkCore.xml + + @@ -13,6 +21,10 @@ + + + + diff --git a/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json b/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json index 0965e5d..dcd2bd2 100644 --- a/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json +++ b/HybirdFrameworkCore/bin/Debug/net6.0/HybirdFrameworkCore.deps.json @@ -13,6 +13,10 @@ "Microsoft.Extensions.Configuration.Json": "7.0.0", "Newtonsoft.Json": "13.0.3", "StackExchange.Redis": "2.7.33", + "Swashbuckle.AspNetCore": "6.5.0", + "Swashbuckle.AspNetCore.Swagger": "6.5.0", + "Swashbuckle.AspNetCore.SwaggerGen": "6.5.0", + "Swashbuckle.AspNetCore.SwaggerUI": "6.5.0", "log4net": "2.0.15" }, "runtime": { @@ -41,6 +45,7 @@ } } }, + "Microsoft.Extensions.ApiDescription.Server/6.0.5": {}, "Microsoft.Extensions.Configuration/7.0.0": { "dependencies": { "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", @@ -126,14 +131,7 @@ } } }, - "Microsoft.Extensions.Logging.Abstractions/6.0.0": { - "runtime": { - "lib/net6.0/Microsoft.Extensions.Logging.Abstractions.dll": { - "assemblyVersion": "6.0.0.0", - "fileVersion": "6.0.21.52210" - } - } - }, + "Microsoft.Extensions.Logging.Abstractions/6.0.0": {}, "Microsoft.Extensions.Primitives/7.0.0": { "dependencies": { "System.Runtime.CompilerServices.Unsafe": "6.0.0" @@ -146,6 +144,14 @@ } }, "Microsoft.NETCore.Platforms/2.0.0": {}, + "Microsoft.OpenApi/1.2.3": { + "runtime": { + "lib/netstandard2.0/Microsoft.OpenApi.dll": { + "assemblyVersion": "1.2.3.0", + "fileVersion": "1.2.3.0" + } + } + }, "Newtonsoft.Json/13.0.3": { "runtime": { "lib/net6.0/Newtonsoft.Json.dll": { @@ -177,6 +183,44 @@ } } }, + "Swashbuckle.AspNetCore/6.5.0": { + "dependencies": { + "Microsoft.Extensions.ApiDescription.Server": "6.0.5", + "Swashbuckle.AspNetCore.Swagger": "6.5.0", + "Swashbuckle.AspNetCore.SwaggerGen": "6.5.0", + "Swashbuckle.AspNetCore.SwaggerUI": "6.5.0" + } + }, + "Swashbuckle.AspNetCore.Swagger/6.5.0": { + "dependencies": { + "Microsoft.OpenApi": "1.2.3" + }, + "runtime": { + "lib/net6.0/Swashbuckle.AspNetCore.Swagger.dll": { + "assemblyVersion": "6.5.0.0", + "fileVersion": "6.5.0.0" + } + } + }, + "Swashbuckle.AspNetCore.SwaggerGen/6.5.0": { + "dependencies": { + "Swashbuckle.AspNetCore.Swagger": "6.5.0" + }, + "runtime": { + "lib/net6.0/Swashbuckle.AspNetCore.SwaggerGen.dll": { + "assemblyVersion": "6.5.0.0", + "fileVersion": "6.5.0.0" + } + } + }, + "Swashbuckle.AspNetCore.SwaggerUI/6.5.0": { + "runtime": { + "lib/net6.0/Swashbuckle.AspNetCore.SwaggerUI.dll": { + "assemblyVersion": "6.5.0.0", + "fileVersion": "6.5.0.0" + } + } + }, "System.Configuration.ConfigurationManager/4.5.0": { "dependencies": { "System.Security.Cryptography.ProtectedData": "4.5.0", @@ -190,14 +234,7 @@ } }, "System.Diagnostics.DiagnosticSource/4.7.1": {}, - "System.IO.Pipelines/5.0.1": { - "runtime": { - "lib/netcoreapp3.0/System.IO.Pipelines.dll": { - "assemblyVersion": "5.0.0.1", - "fileVersion": "5.0.120.57516" - } - } - }, + "System.IO.Pipelines/5.0.1": {}, "System.Runtime.CompilerServices.Unsafe/6.0.0": {}, "System.Security.AccessControl/4.5.0": { "dependencies": { @@ -290,6 +327,13 @@ "path": "log4net/2.0.15", "hashPath": "log4net.2.0.15.nupkg.sha512" }, + "Microsoft.Extensions.ApiDescription.Server/6.0.5": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw==", + "path": "microsoft.extensions.apidescription.server/6.0.5", + "hashPath": "microsoft.extensions.apidescription.server.6.0.5.nupkg.sha512" + }, "Microsoft.Extensions.Configuration/7.0.0": { "type": "package", "serviceable": true, @@ -360,6 +404,13 @@ "path": "microsoft.netcore.platforms/2.0.0", "hashPath": "microsoft.netcore.platforms.2.0.0.nupkg.sha512" }, + "Microsoft.OpenApi/1.2.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Nug3rO+7Kl5/SBAadzSMAVgqDlfGjJZ0GenQrLywJ84XGKO0uRqkunz5Wyl0SDwcR71bAATXvSdbdzPrYRYKGw==", + "path": "microsoft.openapi/1.2.3", + "hashPath": "microsoft.openapi.1.2.3.nupkg.sha512" + }, "Newtonsoft.Json/13.0.3": { "type": "package", "serviceable": true, @@ -381,6 +432,34 @@ "path": "stackexchange.redis/2.7.33", "hashPath": "stackexchange.redis.2.7.33.nupkg.sha512" }, + "Swashbuckle.AspNetCore/6.5.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-FK05XokgjgwlCI6wCT+D4/abtQkL1X1/B9Oas6uIwHFmYrIO9WUD5aLC9IzMs9GnHfUXOtXZ2S43gN1mhs5+aA==", + "path": "swashbuckle.aspnetcore/6.5.0", + "hashPath": "swashbuckle.aspnetcore.6.5.0.nupkg.sha512" + }, + "Swashbuckle.AspNetCore.Swagger/6.5.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-XWmCmqyFmoItXKFsQSwQbEAsjDKcxlNf1l+/Ki42hcb6LjKL8m5Db69OTvz5vLonMSRntYO1XLqz0OP+n3vKnA==", + "path": "swashbuckle.aspnetcore.swagger/6.5.0", + "hashPath": "swashbuckle.aspnetcore.swagger.6.5.0.nupkg.sha512" + }, + "Swashbuckle.AspNetCore.SwaggerGen/6.5.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Y/qW8Qdg9OEs7V013tt+94OdPxbRdbhcEbw4NiwGvf4YBcfhL/y7qp/Mjv/cENsQ2L3NqJ2AOu94weBy/h4KvA==", + "path": "swashbuckle.aspnetcore.swaggergen/6.5.0", + "hashPath": "swashbuckle.aspnetcore.swaggergen.6.5.0.nupkg.sha512" + }, + "Swashbuckle.AspNetCore.SwaggerUI/6.5.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-OvbvxX+wL8skxTBttcBsVxdh73Fag4xwqEU2edh4JMn7Ws/xJHnY/JB1e9RoCb6XpDxUF3hD9A0Z1lEUx40Pfw==", + "path": "swashbuckle.aspnetcore.swaggerui/6.5.0", + "hashPath": "swashbuckle.aspnetcore.swaggerui.6.5.0.nupkg.sha512" + }, "System.Configuration.ConfigurationManager/4.5.0": { "type": "package", "serviceable": true, diff --git a/HybirdFrameworkCore/obj/HybirdFrameworkCore.csproj.nuget.g.targets b/HybirdFrameworkCore/obj/HybirdFrameworkCore.csproj.nuget.g.targets index 5f4a838..6437183 100644 --- a/HybirdFrameworkCore/obj/HybirdFrameworkCore.csproj.nuget.g.targets +++ b/HybirdFrameworkCore/obj/HybirdFrameworkCore.csproj.nuget.g.targets @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs new file mode 100644 index 0000000..105c1ce --- /dev/null +++ b/WebStarter/Controllers/SwapMonitorController.cs @@ -0,0 +1,24 @@ +using Entity.Api.Req; +using Entity.Api.Resp; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; + +namespace WebStarter.Controllers; + +/// +/// 换电控制器 +/// +[ApiController] +[Route("api/[controller]")] +public class SwapMonitorController : ControllerBase +{ + /// + /// 首页换电状态信息 + /// + /// + [HttpPost("GetSwapMonitorData")] + public async Task> GetSwapMonitorData() + { + return Result.Success(null); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs new file mode 100644 index 0000000..319d1d4 --- /dev/null +++ b/WebStarter/Controllers/SwapOrderController.cs @@ -0,0 +1,14 @@ +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; + +namespace WebStarter.Controllers; + +/** + * 换电订单 + */ +[ApiController] +[Route("[controller]")] +public class SwapOrderController : ControllerBase +{ + +} \ No newline at end of file diff --git a/WebStarter/Controllers/GenController.cs b/WebStarter/Controllers/Test/GenController.cs similarity index 100% rename from WebStarter/Controllers/GenController.cs rename to WebStarter/Controllers/Test/GenController.cs diff --git a/WebStarter/Controllers/WeatherForecastController.cs b/WebStarter/Controllers/Test/WeatherForecastController.cs similarity index 100% rename from WebStarter/Controllers/WeatherForecastController.cs rename to WebStarter/Controllers/Test/WeatherForecastController.cs diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 5cfa57f..1ccc693 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -2,7 +2,9 @@ using Autofac; using Autofac.Extensions.DependencyInjection; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; +using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Redis; +using Microsoft.OpenApi.Models; using SqlSugar; using SqlSugar.IOC; @@ -43,9 +45,36 @@ if (redisConnectionString != null && instanceName != null) builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); -builder.Logging.AddLog4Net("log4net.config"); +builder.Logging.AddLog4Net("log4net.config"); +builder.Services.AddSwaggerGen(c => +{ + var basePath = Path.GetDirectoryName(AppContext.BaseDirectory); + //c.IncludeXmlComments(Path.Combine(basePath, Assembly.GetExecutingAssembly().GetName().Name+".xml"), true); + c.IncludeXmlComments(Path.Combine(basePath, "WebStarter.xml"), true); + c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true); + c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true); + + +}); +//跨域 +builder.Services.AddCors(options => +{ + options.AddPolicy + (name: "myCors", + builde => + { + builde.WithOrigins("*", "*", "*") + .AllowAnyOrigin() + .AllowAnyHeader() + .AllowAnyMethod(); + } + ); +}); +builder.Services.AddControllers().AddJsonOptions(configure => +{ + configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter()); +}); var app = builder.Build(); @@ -54,10 +83,11 @@ if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); + app.UseStaticFiles(); } app.UseAuthorization(); - +app.UseCors("myCors"); app.MapControllers(); AppInfo.Container = app.Services.GetAutofacRoot(); diff --git a/WebStarter/WebStarter.csproj b/WebStarter/WebStarter.csproj index d876cd7..df95a28 100644 --- a/WebStarter/WebStarter.csproj +++ b/WebStarter/WebStarter.csproj @@ -6,6 +6,14 @@ enable + + bin\Debug\WebStarter.xml + + + + bin\Release\WebStarter.xml + +