From 3d899371a13f93f0edcfab017043322559d324be Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 25 Jul 2024 17:47:25 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96sqlsugarpack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Canteen/SqlSugarPack.cs | 12 ---- Src/Dlhis.Common/Packs/SqlSugarPack.cs | 35 ----------- .../Packs => Dlhis.Entity}/SqlSugarPack.cs | 38 ++++++++++-- .../Implements/GainfoUpdateService.cs | 4 +- Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs | 62 ------------------- Src/Dlhis.Sys/SqlSugarPack.cs | 48 -------------- Src/Dlhis.Sys/appsettings.Development.json | 8 +++ Src/Dlhis.Visitor/Packs/SqlSugarPack.cs | 34 ---------- 8 files changed, 44 insertions(+), 197 deletions(-) delete mode 100644 Src/Dlhis.Canteen/SqlSugarPack.cs delete mode 100644 Src/Dlhis.Common/Packs/SqlSugarPack.cs rename Src/{Dlhis.Basic/Packs => Dlhis.Entity}/SqlSugarPack.cs (66%) delete mode 100644 Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs delete mode 100644 Src/Dlhis.Sys/SqlSugarPack.cs delete mode 100644 Src/Dlhis.Visitor/Packs/SqlSugarPack.cs diff --git a/Src/Dlhis.Canteen/SqlSugarPack.cs b/Src/Dlhis.Canteen/SqlSugarPack.cs deleted file mode 100644 index 7bb48e6a..00000000 --- a/Src/Dlhis.Canteen/SqlSugarPack.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -using Kurisu.AspNetCore.Startup; - -namespace Dlhis.Canteen; - -public class SqlSugarPack : BaseAppPack -{ - public override void ConfigureServices(IServiceCollection services) - { - services.AddSqlSugar(); - } -} \ No newline at end of file diff --git a/Src/Dlhis.Common/Packs/SqlSugarPack.cs b/Src/Dlhis.Common/Packs/SqlSugarPack.cs deleted file mode 100644 index e3402b0d..00000000 --- a/Src/Dlhis.Common/Packs/SqlSugarPack.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -using Kurisu.AspNetCore.Startup; -using SqlSugar; - -namespace Dlhis.Common.Packs; - -public class SqlSugarPack : BaseAppPack -{ - - public override void ConfigureServices(IServiceCollection services) - { - services.AddSqlSugar(sp => - { - var configuration = sp.GetService(); - - return new List - { - new() - { - ConfigId = "log", - - ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - }, - }; - }); - } -} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Entity/SqlSugarPack.cs similarity index 66% rename from Src/Dlhis.Basic/Packs/SqlSugarPack.cs rename to Src/Dlhis.Entity/SqlSugarPack.cs index 6d176626..77ba0c10 100644 --- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs +++ b/Src/Dlhis.Entity/SqlSugarPack.cs @@ -3,14 +3,16 @@ using Kurisu.AspNetCore; using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Kurisu.AspNetCore.Startup; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using SqlSugar; -namespace Dlhis.Basic.Packs; +namespace Dlhis.Entity; public class SqlSugarPack : BaseAppPack { - public override bool IsBeforeUseRouting { get; } - public override void ConfigureServices(IServiceCollection services) { services.AddSqlSugar(sp => @@ -19,6 +21,34 @@ public class SqlSugarPack : BaseAppPack return new List { + new() + { + ConfigId = "default", + + ConnectionString = configuration.GetSection("SqlSugarOptions:DefaultConnectionString").Value, + DbType = DbType.MySqlConnector, + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + + MoreSettings = new ConnMoreSettings + { + DisableNvarchar = true, + } + }, + new() + { + ConfigId = "identity", + + ConnectionString = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value, + DbType = DbType.MySqlConnector, + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + + MoreSettings = new ConnMoreSettings + { + DisableNvarchar = true, + } + }, new() { ConfigId = "face", @@ -50,7 +80,7 @@ public class SqlSugarPack : BaseAppPack }; }); } - + public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) { var isGenerate = Configuration.GetSection("SqlSugarOptions").GetValue("Generate"); diff --git a/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs index 747cd761..0aa4207e 100644 --- a/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.ScheduledTask/Common/Services/Implements/GainfoUpdateService.cs @@ -267,7 +267,7 @@ public class GainfoUpdateService : IGainfoUpdateService EntryDate = item.createdate, ResignationDate = item.ZLZRQ, CardType = Convert.ToInt32(item.ZZ_KLX), - Workplace = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM, + Workplace = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM, Factory = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM, }; @@ -308,7 +308,7 @@ public class GainfoUpdateService : IGainfoUpdateService if (gainfo != null) { var workplace = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM; - var factory = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM; + var factory = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM; await _dbContext.Updateable().SetColumns(g => new GainfoEntity { SapNo = item.PERNR, diff --git a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs deleted file mode 100644 index ceee1a77..00000000 --- a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -using Kurisu.AspNetCore.Startup; -using SqlSugar; - -namespace Dlhis.ScheduledTask.Packs; - -public class SqlSugarPack : BaseAppPack -{ - public override void ConfigureServices(IServiceCollection services) - { - services.AddSqlSugar(sp => - { - var configuration = sp.GetService(); - - return new List - { - new() - { - ConfigId = "identity", - - ConnectionString = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - }, - new() - { - ConfigId = "face", - - ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - }, - new() - { - ConfigId = "log", - - ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - }, - }; - }); - } -} \ No newline at end of file diff --git a/Src/Dlhis.Sys/SqlSugarPack.cs b/Src/Dlhis.Sys/SqlSugarPack.cs deleted file mode 100644 index 91ff172a..00000000 --- a/Src/Dlhis.Sys/SqlSugarPack.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -using Kurisu.AspNetCore.Startup; -using SqlSugar; - -namespace Dlhis.Sys; - -public class SqlSugarPack : BaseAppPack -{ - public override void ConfigureServices(IServiceCollection services) - { - services.AddSqlSugar(sp => - { - var configuration = sp.GetService(); - - return new List - { - new() - { - ConfigId = "identity", - - ConnectionString = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - }, - new() - { - ConfigId = "default", - - ConnectionString = configuration.GetSection("SqlSugarOptions:DefaultConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - } - }; - }); - } -} \ No newline at end of file diff --git a/Src/Dlhis.Sys/appsettings.Development.json b/Src/Dlhis.Sys/appsettings.Development.json index ae653872..dca593e3 100644 --- a/Src/Dlhis.Sys/appsettings.Development.json +++ b/Src/Dlhis.Sys/appsettings.Development.json @@ -20,6 +20,14 @@ "yikatong": "yikatong" } }, + "SqlSugarOptions": { + "DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;", + "IdentityConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=identity;charset=utf8mb4;", + "SlaveConnectionString": [], + "Timeout": 30, + "SlowSqlTime": 1, + "EnableSqlLog": true + }, "IdentityServerOptions": { "Authority": "https://yikatong.isawesome.cn/oauth2", "RequireHttpsMetadata": true, diff --git a/Src/Dlhis.Visitor/Packs/SqlSugarPack.cs b/Src/Dlhis.Visitor/Packs/SqlSugarPack.cs deleted file mode 100644 index a92ef941..00000000 --- a/Src/Dlhis.Visitor/Packs/SqlSugarPack.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -using Kurisu.AspNetCore.Startup; -using SqlSugar; - -namespace Dlhis.Visitor.Packs; - -public class SqlSugarPack : BaseAppPack -{ - public override void ConfigureServices(IServiceCollection services) - { - services.AddSqlSugar(sp => - { - var configuration = sp.GetService(); - - return new List - { - new() - { - ConfigId = "face", - - ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value, - DbType = DbType.MySqlConnector, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - } - } - }; - }); - } -} \ No newline at end of file