修改系统框架

zw
smartwyy 6 months ago
parent 2d58c230f0
commit 1023065654

@ -234,7 +234,7 @@ public partial class AddChargeOrderReq
/// <summary>
/// 云平台充电订单
/// </summary>
public string? CloudSn { get; set; }
public string? CloudChargeOrder { get; set; }
}

@ -246,7 +246,7 @@ namespace Entity.Api.Req
/// <summary>
/// 云平台充电订单
/// </summary>
public string? CloudSn { get; set; }
public string? CloudChargeOrder { get; set; }
}

@ -116,8 +116,15 @@ namespace Entity.Api.Req
/// <summary>
/// 云平台充电订单
/// </summary>
public string? CloudSn { get; set; }
public string? CloudChargeOrder { get; set; }
/// <summary>
/// Desc:是否可以上传云平台
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "can_upload")]
public int? CanUpload { get; set; }
}
}

@ -245,8 +245,13 @@ namespace Entity.Api.Resp
/// <summary>
/// 云平台充电订单
/// </summary>
public string? CloudSn { get; set; }
public string? CloudChargeOrder { get; set; }
/// <summary>
/// Desc:是否可以上传云平台
/// Default:
/// Nullable:True
/// </summary>
public int? CanUpload { get; set; }
}
}

@ -290,12 +290,6 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
/// <summary>
/// 云平台充电订单
/// </summary>
[SugarColumn(ColumnName = "cloud_sn")]
public string? CloudSn { get; set; }
/// <summary>
/// Desc:云平台订单编号
/// Default:

@ -50,17 +50,14 @@ public class AutofacModuleRegister : Module
{
if (ScopeConst.InstancePerLifetimeScope == scope.Scope)
{
Log.Debug($"register InstancePerLifetimeScope {type}");
instancePerLifetimeScopeList.Add(type);
}
else if (ScopeConst.InstancePerDependency == scope.Scope)
{
Log.Debug($"register InstancePerDependency {type}");
instancePerDependencyList.Add(type);
}
else
{
Log.Debug($"register SingleInstance {type}");
defaultList.Add(type);
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using log4net;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@ -10,11 +11,8 @@ namespace HybirdFrameworkCore.Configuration;
/// </summary>
public class AppSettingsHelper
{
public AppSettingsHelper(string contentPath)
{
}
private static IConfiguration Configuration { get; set; }
private static readonly ILog Log = LogManager.GetLogger(typeof(AppSettingsHelper));
private static IConfiguration? Configuration { get; set; }
/// <summary>
/// 封装要操作的字符
@ -22,21 +20,35 @@ public class AppSettingsHelper
/// </summary>
/// <param name="sections">节点配置</param>
/// <returns></returns>
public static string GetContent(params string[] sections)
public static string? GetContent(params string[] sections)
{
try
{
if (Configuration == null)
{
string? activeProfile = Environment.GetEnvironmentVariable("profiles_active");
if (activeProfile == null)
{
activeProfile = "";
}
else
{
activeProfile += ".";
}
var path = "appsettings."+ activeProfile+ "json";
Log.Info($"read path={path}");
var contentPath = AppDomain.CurrentDomain.BaseDirectory;
var Path = "appsettings.json";
Configuration = new ConfigurationBuilder().SetBasePath(contentPath).Add(new JsonConfigurationSource
{ Path = Path, Optional = false, ReloadOnChange = true }).Build();
{ Path = path, Optional = false, ReloadOnChange = true }).Build();
}
if (sections.Any()) return Configuration[string.Join(":", sections)];
}
catch (Exception)
{
}
return "";
return null;
}
public static bool SetContent(string value, params string[] sections)
@ -44,9 +56,18 @@ public class AppSettingsHelper
try
{
var contentPath = AppDomain.CurrentDomain.BaseDirectory;
var Path = contentPath + "appsettings.json";
string? activeProfile = Environment.GetEnvironmentVariable("profiles_active");
if (activeProfile == null)
{
activeProfile = "";
}
else
{
activeProfile += ".";
}
var path = "appsettings."+ activeProfile+ "json";
JObject jsonObject;
using (var file = new StreamReader(Path))
using (var file = new StreamReader(path))
using (var reader = new JsonTextReader(file))
{
jsonObject = (JObject)JToken.ReadFrom(reader);
@ -54,7 +75,7 @@ public class AppSettingsHelper
jsonObject[sections[0]][sections[1]] = value;
}
using (var writer = new StreamWriter(Path))
using (var writer = new StreamWriter(path))
using (var jsonwriter = new JsonTextWriter(writer))
{
jsonObject.WriteTo(jsonwriter);
@ -67,4 +88,24 @@ public class AppSettingsHelper
return true;
}
/// <summary>
///
/// </summary>
/// <param name="sections"></param>
/// <returns></returns>
public static bool GetBool(params string[] sections)
{
string s = GetContent(sections);
if (string.IsNullOrWhiteSpace(s))
{
return false;
}
if (bool.TryParse(s, out var result))
{
return result;
}
return false;
}
}

@ -1,4 +1,6 @@
using Service.BusinessTask;
using Autofac;
using HybirdFrameworkCore.Autofac;
using Service.BusinessTask;
using Service.BusinessTask.MyTask;
using Service.Cloud.Client.MyTask;
@ -14,7 +16,7 @@ namespace Service.Execute
private static readonly AbstractTaskHandler SwapOrderReportCloudTask = new SwapOrderReportCloudTask();
private static readonly AbstractTaskHandler BatteryMoveTask = new BatteryMoveTask();
private static readonly AbstractTaskHandler ChargeOrderUploadTask = new ChargeOrderUploadTask();
private static readonly AbstractTaskHandler ChargeOrderUploadTask = AppInfo.Container.Resolve<ChargeOrderUploadTask>();
#region Task

@ -112,9 +112,9 @@ public class ChargeOrderService : BaseServices<ChargeOrder>
Expression<Func<ChargeOrder, bool>> condition2Expr = u => u.CloudReportStatus == chargeOrder.CloudReportStatus;
where = where == null ? condition2Expr : Expression.Lambda<Func<ChargeOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
if (!string.IsNullOrEmpty(chargeOrder.CloudSn))
if (!string.IsNullOrEmpty(chargeOrder.CloudChargeOrder))
{
Expression<Func<ChargeOrder, bool>> condition2Expr = u => u.CloudSn == chargeOrder.CloudSn;
Expression<Func<ChargeOrder, bool>> condition2Expr = u => u.CloudChargeOrder == chargeOrder.CloudChargeOrder;
where = where == null ? condition2Expr : Expression.Lambda<Func<ChargeOrder, bool>>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter);
}
#endregion

@ -6,17 +6,18 @@ using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Redis;
using log4net;
using Mapster;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Service.Cloud.Client;
using Service.Execute;
using Service.Execute.StaticTools;
using Service.Plc.Client;
using SqlSugar;
using SqlSugar.IOC;
var builder = WebApplication.CreateBuilder(args);
var log = LogManager.GetLogger(typeof(Program));
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
@ -63,17 +64,12 @@ builder.Services.AddCors(options =>
);
});
//redis
var section = builder.Configuration.GetSection("Redis");
//连接字符串
var redisConnectionString = section.GetSection("Connection").Value;
//实例名称
var instanceName = section.GetSection("InstanceName").Value;
//默认数据库
var _defaultDB = int.Parse(section.GetSection("DefaultDB").Value ?? "0");
var redisConnectionString = AppSettingsHelper.GetContent("Redis", "Connection");
var instanceName = AppSettingsHelper.GetContent("Redis", "InstanceName");//默认数据库
var defaultDb = int.Parse(AppSettingsHelper.GetContent("Redis", "DefaultDB") ?? "0");
if (redisConnectionString != null && instanceName != null)
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, _defaultDB));
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, defaultDb));
builder.Services.AddControllers().AddJsonOptions(configure =>
{
@ -122,12 +118,6 @@ builder.Services.AddAuthentication(options =>
};
});
//Json 序列化
builder.Services.AddControllers().AddJsonOptions(configure =>
{
configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
});
@ -136,12 +126,9 @@ var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseStaticFiles();
}
app.UseAuthorization();
app.UseCors("myCors");
@ -150,6 +137,7 @@ app.MapControllers();
var list = AppSettingsHelper.GetContent("Kestrel", "Endpoints", "http", "Url");
foreach (var s in list.Split(";"))
{
log.Info($"use url={s}");
app.Urls.Add(s);
}
@ -157,10 +145,28 @@ foreach (var s in list.Split(";"))
AppInfo.Container = app.Services.GetAutofacRoot();
//云平台
if (AppSettingsHelper.GetBool("cloud", "enable"))
{
CloudClientMgr.Init();
}
//PLC
if (AppSettingsHelper.GetBool("plc", "enable"))
{
PlcMgr.Init();
}
//启动换电流程
//StationSoftMgr.SwappingStateMachineStart();
//StationSoftMgr.StartTasks();
if (AppSettingsHelper.GetBool("swap", "enable"))
{
StationSoftMgr.SwappingStateMachineStart();
}
//Task
if (AppSettingsHelper.GetBool("task", "enable"))
{
StationSoftMgr.StartTasks();
}
app.Run();

@ -16,7 +16,8 @@
"launchUrl": "swagger",
"applicationUrl": "http://0.0.0.0:5034",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"profiles_active": "dev"
}
},
"IIS Express": {
@ -24,7 +25,9 @@
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"applicationUrl": "http://0.0.0.0:5034",
"profiles_active": "dev"
}
}
}

@ -29,7 +29,7 @@
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<Content Update="appsettings.prod.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,91 @@
{
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
"Version": "1.1.0.1",
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "106.12.36.89:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"": null,
"Cryptogram": {
"StrongPassword": "false", //
"PasswordStrengthValidation": "(?=^.{6,16}$)(?=.*\\d)(?=.*\\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\\n).*$", // 6-16
"PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合长度在6-16之间", //
"CryptoType": "SM2", // MD5SM2SM4
"PublicKey": "0484C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312", //
"PrivateKey": "8EDB615B1D48B8BE188FC0F18EC08A41DF50EA731FA28BF409E6552809E3A111" //
},
//Login
"TokenOptions": {
"SecurityKey": "s4104j1401kopposdfjsfj091541111111111",
"Domain": "*",
"Audience": "jwtAudience",
"Issuer": "jwtIssuer"
},
"Upload": {
"Path": "Upload/{yyyy}/{MM}/{dd}", //
"MaxSize": 20480, // KB1024*20
"ContentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif", "image/bmp", "text/plain", "application/pdf", "application/msword", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "video/mp4" ],
"EnableMd5": false // MDF5-
},
//SysLogin
"JWTSettings": {
"ValidateIssuerSigningKey": true, // bool true
"IssuerSigningKey": "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a", // string 16
"ValidateIssuer": true, // bool true
"ValidIssuer": "Admin.NET", // string
"ValidateAudience": true, // bool true
"ValidAudience": "Admin.NET", // string
"ValidateLifetime": true, // bool truetrue
//"ExpiredTime": 20, // long 20 13
"ClockSkew": 5, // long 5
"Algorithm": "HS256", // string HS256
"RequireExpirationTime": true // false
},
"SnowId": {
"WorkerId": 1, //
"WorkerIdBitLength": 6, // 6 [1, 19]
"SeqBitLength": 6, // 6 [3, 21]4Id
"WorkerPrefix": "adminnet_" //
},
"HttpContextRequest": {
"Scheme": ""
},
"Kestrel": {
"Endpoints": {
"http": {
"Url": "http://*:15034"
}
}
},
"cloud": {
"enable": true
},
"plc": {
"enable": true
},
"swap": {
"enable": true
},
"task": {
"enable": true
}
}

@ -1,79 +1,8 @@
{
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
"Version": "1.1.0.1",
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "106.12.36.89:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"": null,
"Cryptogram": {
"StrongPassword": "false", //
"PasswordStrengthValidation": "(?=^.{6,16}$)(?=.*\\d)(?=.*\\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\\n).*$", // 6-16
"PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合长度在6-16之间", //
"CryptoType": "SM2", // MD5SM2SM4
"PublicKey": "0484C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312", //
"PrivateKey": "8EDB615B1D48B8BE188FC0F18EC08A41DF50EA731FA28BF409E6552809E3A111" //
},
//Login
"TokenOptions": {
"SecurityKey": "s4104j1401kopposdfjsfj091541111111111",
"Domain": "*",
"Audience": "jwtAudience",
"Issuer": "jwtIssuer"
},
"Upload": {
"Path": "Upload/{yyyy}/{MM}/{dd}", //
"MaxSize": 20480, // KB1024*20
"ContentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif", "image/bmp", "text/plain", "application/pdf", "application/msword", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "video/mp4" ],
"EnableMd5": false // MDF5-
},
//SysLogin
"JWTSettings": {
"ValidateIssuerSigningKey": true, // bool true
"IssuerSigningKey": "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a", // string 16
"ValidateIssuer": true, // bool true
"ValidIssuer": "Admin.NET", // string
"ValidateAudience": true, // bool true
"ValidAudience": "Admin.NET", // string
"ValidateLifetime": true, // bool truetrue
//"ExpiredTime": 20, // long 20 13
"ClockSkew": 5, // long 5
"Algorithm": "HS256", // string HS256
"RequireExpirationTime": true // false
},
"SnowId": {
"WorkerId": 1, //
"WorkerIdBitLength": 6, // 6 [1, 19]
"SeqBitLength": 6, // 6 [3, 21]4Id
"WorkerPrefix": "adminnet_" //
},
"HttpContextRequest": {
"Scheme": "http://0.0.0.0:5034"
},
"Kestrel": {
"Endpoints": {
"http": {
"Url": "http://0.0.0.0:5034"
}
}
}
}

@ -0,0 +1,125 @@
{
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
"Version": "1.1.0.1",
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "106.12.36.89:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"": null,
"Cryptogram": {
"StrongPassword": "false",
//
"PasswordStrengthValidation": "(?=^.{6,16}$)(?=.*\\d)(?=.*\\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\\n).*$",
// 6-16
"PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合长度在6-16之间",
//
"CryptoType": "SM2",
// MD5SM2SM4
"PublicKey": "0484C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312",
//
"PrivateKey": "8EDB615B1D48B8BE188FC0F18EC08A41DF50EA731FA28BF409E6552809E3A111"
//
},
//Login
"TokenOptions": {
"SecurityKey": "s4104j1401kopposdfjsfj091541111111111",
"Domain": "*",
"Audience": "jwtAudience",
"Issuer": "jwtIssuer"
},
"Upload": {
"Path": "Upload/{yyyy}/{MM}/{dd}",
//
"MaxSize": 20480,
// KB1024*20
"ContentType": [
"image/jpg",
"image/png",
"image/jpeg",
"image/gif",
"image/bmp",
"text/plain",
"application/pdf",
"application/msword",
"application/vnd.ms-excel",
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"video/mp4"
],
"EnableMd5": false
// MDF5-
},
//SysLogin
"JWTSettings": {
"ValidateIssuerSigningKey": true,
// bool true
"IssuerSigningKey": "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a",
// string 16
"ValidateIssuer": true,
// bool true
"ValidIssuer": "Admin.NET",
// string
"ValidateAudience": true,
// bool true
"ValidAudience": "Admin.NET",
// string
"ValidateLifetime": true,
// bool truetrue
//"ExpiredTime": 20, // long 20 13
"ClockSkew": 5,
// long 5
"Algorithm": "HS256",
// string HS256
"RequireExpirationTime": true
// false
},
"SnowId": {
"WorkerId": 1,
//
"WorkerIdBitLength": 6,
// 6 [1, 19]
"SeqBitLength": 6,
// 6 [3, 21]4Id
"WorkerPrefix": "adminnet_"
//
},
"HttpContextRequest": {
"Scheme": "http://0.0.0.0:5034"
},
"Kestrel": {
"Endpoints": {
"http": {
"Url": "http://*:5034"
}
}
},
"cloud": {
"enable": true
},
"plc": {
"enable": true
},
"swap": {
"enable": true
},
"task": {
"enable": true
}
}

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Loading…
Cancel
Save