From 89db005f0dbf09e9a3e49e18520fdcd02bd10b24 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Sat, 23 Mar 2024 01:14:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor=20=E8=AD=A6=E5=91=8A/=E6=8F=90?= =?UTF-8?q?=E9=86=92=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/DeviceService.cs | 10 +- .../Implements/DishesCategoryService.cs | 1 + .../Services/Implements/GainfoPermissions.cs | 2 +- Src/Dlhis.Basic/Packs/SqlSugarPack.cs | 7 +- .../Services/Implements/SummaryService.cs | 8 +- .../Services/Implements/BalanceService.cs | 31 ++- .../Services/Implements/BaseOrderService.cs | 5 +- .../Controllers/ApkFileController.cs | 2 +- .../FileOperation/Response/ApkFileResponse.cs | 2 +- .../Services/Implements/MinioService.cs | 3 +- Src/Dlhis.Common/SqlSugarPack.cs | 4 +- .../Channel/MealSupplementHandler.cs | 14 +- .../CommonJobs/HeartbeatJob.cs | 6 +- .../CommonJobs/TempCreateUserJob.cs | 212 +++++++++--------- Src/Dlhis.ScheduledTask/Packs/JobPack.cs | 8 +- Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs | 6 +- .../Comparers/SapPersonComparer.cs | 4 +- .../SyncSapInfo/Job/SyncPersonJob.cs | 8 +- .../Services/Implements/AssignmentService.cs | 6 +- .../Services/Implements/RoleService.cs | 2 +- .../Services/Implements/TenantService.cs | 2 +- .../Menu/Services/Implements/MenuService.cs | 2 +- Src/Gateway/Startup.cs | 2 +- 23 files changed, 170 insertions(+), 177 deletions(-) diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs index 2eb8f9df..468ed8eb 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs @@ -376,13 +376,13 @@ public class DeviceService : IDeviceService .Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo)) .Select((x, d) => new { - UniqueNo = d.UniqueNo, + d.UniqueNo, d.HeartbeatInterval, x.LastHeartbeatTime }) .ToListAsync(); - var OnlineDevices = deviceRegistries + var onlineDevices = deviceRegistries .Where(x => { if (x.HeartbeatInterval <= 0) @@ -395,11 +395,11 @@ public class DeviceService : IDeviceService }) .Select(x => new { - UniqueNo = x.UniqueNo, + x.UniqueNo, }) .ToList(); var onlineUniqueNos = new List(); - OnlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo)); + onlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo)); var offUniqueNos = deviceUniqueNos.Except(onlineUniqueNos).ToList(); var list = devices.Where(x => offUniqueNos.Contains(x.UniqueNo)).ToList(); @@ -518,7 +518,7 @@ public class DeviceService : IDeviceService { //获取近30天并转化为"yyyy-MM-dd"集合 DateTime currentDate = DateTime.Now; - List times = new List(); + var times = new List(); for (int i = 0; i < 30; i++) { DateTime date = currentDate.AddDays(-i); diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs index 049e9837..092ce609 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs @@ -17,6 +17,7 @@ public class DishesCategoryService : IDishesCategoryService public DishesCategoryService(IDbContext dbContext, IBusinessPlacePermissionsService businessPlacePermissionsService) { _dbContext = dbContext; + _businessPlacePermissionsService = businessPlacePermissionsService; } public async Task> TreeAsync(Guid businessPlaceCode) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs index 2e6644c4..deab9327 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs @@ -206,7 +206,7 @@ public class GainfoPermissions : IGainfoPermissions .ToListAsync(); } - private IEnumerable RecursionGetNext(DeviceGroupEntity current, List deviceGroups) + private static IEnumerable RecursionGetNext(DeviceGroupEntity current, List deviceGroups) { var next = deviceGroups.Where(x => x.PCode == current.Code).ToList(); foreach (var item in next) diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs index 33e25f49..5dbaabc5 100644 --- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs +++ b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs @@ -1,11 +1,8 @@ using Dlhis.Entity.Basic.Entity; using Kurisu.AspNetCore; using Kurisu.AspNetCore.Startup; -using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; -using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.Configuration; using SqlSugar; namespace Dlhis.Basic.Packs; @@ -22,7 +19,7 @@ public class SqlSugarPack : BaseAppPack return new List { - new ConnectionConfig + new() { ConfigId = "face", @@ -36,7 +33,7 @@ public class SqlSugarPack : BaseAppPack DisableNvarchar = true, } }, - new ConnectionConfig + new() { ConfigId = "log", diff --git a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs index d35cc869..c48fd8dc 100644 --- a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs +++ b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs @@ -94,7 +94,7 @@ public class SummaryService : ISummaryService //获取近30天并转化为"yyyy-MM-dd"集合 DateTime currentDate = DateTime.Now; - List times = new List(); + var times = new List(); for (int i = 0; i < 30; i++) { DateTime date = currentDate.AddDays(-i); @@ -125,7 +125,7 @@ public class SummaryService : ISummaryService public async Task GetDoorDataAsync() { var res = new DoorDataResponse(); - List workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync(); + var workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync(); var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync(); res.Employed = workingGainfos.Count; res.Unemployed = leaveGainfos.Count; @@ -134,8 +134,8 @@ public class SummaryService : ISummaryService var unemployedTrend = new List(); //获取近7天并转化为"yyyy-MM-dd"集合 - DateTime currentDate = DateTime.Now; - List times = new List(); + var currentDate = DateTime.Now; + var times = new List(); for (int i = 0; i < 7; i++) { DateTime date = currentDate.AddDays(-i); diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs index b669579f..49211b0d 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs @@ -404,19 +404,18 @@ public class BalanceService : IBalanceService var lst = new List(); foreach (var first in pageinfo.GroupBy(record => record.CostDateTime.ToString("yyyy-MM-dd"))) { - var obj = new BalanceRecordAnalysisRespones() + var obj = new BalanceRecordAnalysisRespones { CostDate = DateOnly.FromDateTime(Convert.ToDateTime(first.Key)), + //每个餐次人数 + BreakfastNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count(), + LunchNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count(), + DinnerNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count(), + LateNightNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count(), + + TotalNumberOfPeople = first.Where(x => x.CostDate.ToString("yyyy-MM-dd") == first.Key).Select(x => x.UserNo).Distinct().Count() }; - //每个餐次人数 - obj.BreakfastNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count(); - obj.LunchNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count(); - obj.DinnerNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count(); - obj.LateNightNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count(); - - obj.TotalNumberOfPeople = first.Where(x => x.CostDate.ToString("yyyy-MM-dd") == first.Key).Select(x => x.UserNo).Distinct().Count(); - lst.Add(obj); } // 分页操作 @@ -624,7 +623,7 @@ public class BalanceService : IBalanceService /// /// /// - private int SameDay(List bs, string userCode) + private static int SameDay(List bs, string userCode) { var time = DateTime.Now.ToString("yyyy-MM-dd"); var b = userCode.IsEmpty(); @@ -858,13 +857,13 @@ public class BalanceService : IBalanceService /// private List GetMonthsOfYear() { - List months = new List(); + var months = new List(); // 获取当前年份 int year = DateTime.Now.Year; // 遍历12个月份并添加到列表中 for (int month = 1; month <= 12; month++) { - DateTime monthDate = new DateTime(year, month, 1); + var monthDate = new DateTime(year, month, 1); months.Add(monthDate.ToString("yyyy-MM")); } return months; @@ -876,15 +875,15 @@ public class BalanceService : IBalanceService /// private List GetDaysOfMonth() { - List days = new List(); + var days = new List(); // 获取当前年份和月份 int year = DateTime.Now.Year; int month = DateTime.Now.Month; // 获取当前月份的第一天和最后一天 - DateTime firstDayOfMonth = new DateTime(year, month, 1); - DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); + var firstDayOfMonth = new DateTime(year, month, 1); + var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); // 遍历当前月的所有日期并添加到列表中 for (DateTime date = firstDayOfMonth; date <= lastDayOfMonth; date = date.AddDays(1)) @@ -909,7 +908,7 @@ public class BalanceService : IBalanceService } catch (Exception ex) when (ex is VersionExceptions) { - _logger.LogWarning(ex, ex.Message); + _logger.LogWarning(ex, "{message}", ex.Message); } catch (Exception) { diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs index 33ee4ffc..271c3291 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs @@ -56,9 +56,8 @@ public abstract class BaseOrderService /// /// 设备并发更新 需要抛出VersionExceptions /// - /// /// - /// 并发冲突处理次数 + /// /// /// /// @@ -73,7 +72,7 @@ public abstract class BaseOrderService } catch (Exception ex) when (ex is VersionExceptions) { - _logger.LogWarning(ex, ex.Message); + _logger.LogWarning(ex, "{message}", ex.Message); } catch (Exception) { diff --git a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs index a57f65ef..6036920e 100644 --- a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs +++ b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs @@ -16,7 +16,7 @@ namespace Dlhis.Common.FileOperation.Controllers; [ApiController] public class ApkFileController : ControllerBase { - private IApkFIileService _apkFIileService; + private readonly IApkFIileService _apkFIileService; public ApkFileController(IApkFIileService apkFIileService) { diff --git a/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs b/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs index 763f5cf9..78a8db3f 100644 --- a/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs +++ b/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs @@ -32,6 +32,6 @@ namespace Dlhis.Common.FileOperation.Response /// /// url /// - public string? Url { get; set; } + public string Url { get; set; } } } diff --git a/Src/Dlhis.Common/FileOperation/Services/Implements/MinioService.cs b/Src/Dlhis.Common/FileOperation/Services/Implements/MinioService.cs index f18cfb9c..70d82c49 100644 --- a/Src/Dlhis.Common/FileOperation/Services/Implements/MinioService.cs +++ b/Src/Dlhis.Common/FileOperation/Services/Implements/MinioService.cs @@ -1,5 +1,6 @@ using Dlhis.Common.FileOperation.Configurations; using Dlhis.Common.FileOperation.Request; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Extensions.Options; using Minio; using Minio.DataModel.Args; @@ -81,7 +82,7 @@ public class MinioService : IMinioService { string fileName = request.formFile.FileName; - using (MemoryStream filestream = new MemoryStream()) + using (var filestream = new MemoryStream()) { await request.formFile.CopyToAsync(filestream); filestream.Position = 0; diff --git a/Src/Dlhis.Common/SqlSugarPack.cs b/Src/Dlhis.Common/SqlSugarPack.cs index 185e346e..5af46c42 100644 --- a/Src/Dlhis.Common/SqlSugarPack.cs +++ b/Src/Dlhis.Common/SqlSugarPack.cs @@ -16,7 +16,7 @@ public class SqlSugarPack : BaseAppPack var configuration = sp.GetService(); return new List { - new ConnectionConfig + new() { ConfigId = "face", ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value, @@ -28,7 +28,7 @@ public class SqlSugarPack : BaseAppPack DisableNvarchar = true, } }, - new ConnectionConfig + new() { ConfigId = "log", ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value, diff --git a/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs b/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs index fad99d18..05f0f40c 100644 --- a/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs +++ b/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs @@ -18,16 +18,14 @@ public class MealSupplementHandler : IAsyncChannelHandler public async Task InvokeAsync(MealSupplementMessage message) { - using (var scope = _serviceProvider.CreateScope()) - { - var db = scope.ServiceProvider.GetService(); + using var scope = _serviceProvider.CreateScope(); + var db = scope.ServiceProvider.GetService(); - var existsIds = await db.Queryable().Select(x => x.UniqueId).ToListAsync(); - var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList(); + var existsIds = await db.Queryable().Select(x => x.UniqueId).ToListAsync(); + var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList(); - var entities = items.Adapt>(); - await db.InsertAsync(entities); - } + var entities = items.Adapt>(); + await db.InsertAsync(entities); } } diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/HeartbeatJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/HeartbeatJob.cs index bd7cdb19..59e4a97f 100644 --- a/Src/Dlhis.ScheduledTask/CommonJobs/HeartbeatJob.cs +++ b/Src/Dlhis.ScheduledTask/CommonJobs/HeartbeatJob.cs @@ -11,12 +11,10 @@ namespace Dlhis.ScheduledTask.CommonJobs; public class HeartbeatJob { private readonly IDbContext _dbContext; - private readonly ILogger _logger; - public HeartbeatJob(IDbContext dbContext, ILogger logger) + public HeartbeatJob(IDbContext dbContext) { _dbContext = dbContext; - _logger = logger; } public async Task RunAsync() @@ -38,7 +36,7 @@ public class HeartbeatJob await _dbContext.Updateable().SetColumns(x => x.LastHeartbeatTime == DateTime.Now) .Where(x => x.DeviceUniqueNo == device.UniqueNo).ExecuteCommandAsync(); - // _logger.LogInformation("心跳设备成功:{no}", device.UniqueNo); + // _logger.LogInformation("心跳设备成功:{no}", device.UniqueNo); } catch (Exception) { diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/TempCreateUserJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/TempCreateUserJob.cs index e47bca62..8ff12d6c 100644 --- a/Src/Dlhis.ScheduledTask/CommonJobs/TempCreateUserJob.cs +++ b/Src/Dlhis.ScheduledTask/CommonJobs/TempCreateUserJob.cs @@ -1,121 +1,121 @@ -using Dlhis.Entity.Basic.Entity; -using Dlhis.Entity.Sys.Entities; -using Kurisu.AspNetCore.Authentication.Options; -using Kurisu.AspNetCore.Utils.Extensions; -using Kurisu.Core.DataAccess.Entity; -using Kurisu.SqlSugar.Services; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.Options; +//using Dlhis.Entity.Basic.Entity; +//using Dlhis.Entity.Sys.Entities; +//using Kurisu.AspNetCore.Authentication.Options; +//using Kurisu.AspNetCore.Utils.Extensions; +//using Kurisu.Core.DataAccess.Entity; +//using Kurisu.SqlSugar.Services; +//using Microsoft.AspNetCore.Identity; +//using Microsoft.Extensions.Options; -namespace Dlhis.ScheduledTask.CommonJobs -{ - public class TempCreateUserJob - { - private readonly IDbContext _dbContext; - private readonly ILogger _logger; - private readonly IdentityServerOptions _identityServerOptions; - private readonly IHttpClientFactory _httpClientFactory; +//namespace Dlhis.ScheduledTask.CommonJobs +//{ +// public class TempCreateUserJob +// { +// private readonly IDbContext _dbContext; +// private readonly ILogger _logger; +// private readonly IdentityServerOptions _identityServerOptions; +// private readonly IHttpClientFactory _httpClientFactory; - public TempCreateUserJob( - IDbContext dbContext, - ILogger logger, - IOptions options, - IHttpClientFactory httpClientFactory) - { - _dbContext = dbContext; - _logger = logger; - _httpClientFactory = httpClientFactory; - _identityServerOptions = options.Value; - } +// public TempCreateUserJob( +// IDbContext dbContext, +// ILogger logger, +// IOptions options, +// IHttpClientFactory httpClientFactory) +// { +// _dbContext = dbContext; +// _logger = logger; +// _httpClientFactory = httpClientFactory; +// _identityServerOptions = options.Value; +// } - public async Task RunAsync() - { - _dbContext.Client.QueryFilter.ClearAndBackup(); - try - { +// public async Task RunAsync() +// { +// _dbContext.Client.QueryFilter.ClearAndBackup(); +// try +// { - //var identityDbContext = _dbContext.ChangeDb("identity"); +// //var identityDbContext = _dbContext.ChangeDb("identity"); - ////HST0001 - //var users = await identityDbContext.Queryable().Where(x => x.UserName != "HST0001") - // .Where(x => x.Id > 21) - // .ToListAsync(); +// ////HST0001 +// //var users = await identityDbContext.Queryable().Where(x => x.UserName != "HST0001") +// // .Where(x => x.Id > 21) +// // .ToListAsync(); - //var gainfos = await _dbContext.Queryable().ToListAsync(); +// //var gainfos = await _dbContext.Queryable().ToListAsync(); - //var hasher = new PasswordHasher(); - //foreach (var user in users) - //{ - // var gainfo = gainfos.FirstOrDefault(x => x.Code == user.UserName); - // if (gainfo != null && gainfo.IdNo.IsPresent()) - // { - // var password = gainfo.IdNo.TakeLast(6).Join(""); - // password = hasher.HashPassword(user, password); - // user.PasswordHash = password; - // await identityDbContext.UpdateAsync(user); - // } - //} +// //var hasher = new PasswordHasher(); +// //foreach (var user in users) +// //{ +// // var gainfo = gainfos.FirstOrDefault(x => x.Code == user.UserName); +// // if (gainfo != null && gainfo.IdNo.IsPresent()) +// // { +// // var password = gainfo.IdNo.TakeLast(6).Join(""); +// // password = hasher.HashPassword(user, password); +// // user.PasswordHash = password; +// // await identityDbContext.UpdateAsync(user); +// // } +// //} - //var userNames = await identityDbContext.Queryable().Select(x => x.UserName).ToListAsync(); - //var newUser = await _dbContext.Queryable() - // .Where(x => !string.IsNullOrEmpty(x.Code)) - // .Where(x => !userNames.Contains(x.Code)) - // .Select(x => new - // { - // x.Code, - // x.Factory, - // x.Name, - // }) - // .ToListAsync(); +// //var userNames = await identityDbContext.Queryable().Select(x => x.UserName).ToListAsync(); +// //var newUser = await _dbContext.Queryable() +// // .Where(x => !string.IsNullOrEmpty(x.Code)) +// // .Where(x => !userNames.Contains(x.Code)) +// // .Select(x => new +// // { +// // x.Code, +// // x.Factory, +// // x.Name, +// // }) +// // .ToListAsync(); - //var httpClient = _httpClientFactory.CreateClient(); - //httpClient.BaseAddress = new Uri(_identityServerOptions.Authority); +// //var httpClient = _httpClientFactory.CreateClient(); +// //httpClient.BaseAddress = new Uri(_identityServerOptions.Authority); - //var hasher = new PasswordHasher(); - //foreach (var item in newUser) - //{ - // var userName = item.Code; - // var password = item.Code; - // var factory = item.Factory; +// //var hasher = new PasswordHasher(); +// //foreach (var item in newUser) +// //{ +// // var userName = item.Code; +// // var password = item.Code; +// // var factory = item.Factory; - // if (password.Length > 6) - // { - // password = string.Join("", password.TakeLast(6)); - // } - // else - // { - // password = password.PadLeft(6, '0'); - // } - // var user = new UserEntity - // { - // UserName = userName, - // NormalizedUserName = userName.ToUpper(), - // ConcurrencyStamp = Guid.NewGuid().ToString(), - // SecurityStamp = Guid.NewGuid().ToString(), - // }; +// // if (password.Length > 6) +// // { +// // password = string.Join("", password.TakeLast(6)); +// // } +// // else +// // { +// // password = password.PadLeft(6, '0'); +// // } +// // var user = new UserEntity +// // { +// // UserName = userName, +// // NormalizedUserName = userName.ToUpper(), +// // ConcurrencyStamp = Guid.NewGuid().ToString(), +// // SecurityStamp = Guid.NewGuid().ToString(), +// // }; - // password = hasher.HashPassword(user, password); - // user.PasswordHash = password; - // var id = (int)await identityDbContext.InsertReturnIdentityAsync(user); +// // password = hasher.HashPassword(user, password); +// // user.PasswordHash = password; +// // var id = (int)await identityDbContext.InsertReturnIdentityAsync(user); - // await identityDbContext.InsertAsync(new UserTenantEntity() { UserId = id, TenantCode = factory }); - // await identityDbContext.InsertAsync(new List - // { - // new UserClaimEntity{ UserId = id , ClaimType ="preferred_username", ClaimValue = item.Name}, - // new UserClaimEntity{ UserId = id , ClaimType ="jinko-code", ClaimValue = item.Code}, - // }); - //} - } - catch (Exception ex) - { - _logger.LogError(ex, "创建用户失败:{message}", ex.Message); - } - finally - { - _dbContext.Client.QueryFilter.Restore(); - } - } - } +// // await identityDbContext.InsertAsync(new UserTenantEntity() { UserId = id, TenantCode = factory }); +// // await identityDbContext.InsertAsync(new List +// // { +// // new UserClaimEntity{ UserId = id , ClaimType ="preferred_username", ClaimValue = item.Name}, +// // new UserClaimEntity{ UserId = id , ClaimType ="jinko-code", ClaimValue = item.Code}, +// // }); +// //} +// } +// catch (Exception ex) +// { +// _logger.LogError(ex, "创建用户失败:{message}", ex.Message); +// } +// finally +// { +// _dbContext.Client.QueryFilter.Restore(); +// } +// } +// } -} +//} diff --git a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs index ca89b3d2..83aed8e0 100644 --- a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs +++ b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs @@ -60,10 +60,10 @@ public class JobPack : BaseAppPack }); - RecurringJob.AddOrUpdate("TempCreateUser", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions - { - TimeZone = TimeZoneInfo.Local - }); + //RecurringJob.AddOrUpdate("TempCreateUser", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions + //{ + // TimeZone = TimeZoneInfo.Local + //}); //删除前三天前的日志 RecurringJob.AddOrUpdate("DelApiLogTask", s => s.RunAsync(), "0 0 */7 * *", new RecurringJobOptions diff --git a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs index ae038436..116c1c6b 100644 --- a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs +++ b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs @@ -16,7 +16,7 @@ public class SqlSugarPack : BaseAppPack return new List { - new ConnectionConfig + new() { ConfigId = "identity", @@ -30,8 +30,8 @@ public class SqlSugarPack : BaseAppPack DisableNvarchar = true, } }, - new ConnectionConfig - { + new() + { ConfigId = "log", ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value, diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Comparers/SapPersonComparer.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Comparers/SapPersonComparer.cs index fdea7c12..65bdb11b 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Comparers/SapPersonComparer.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Comparers/SapPersonComparer.cs @@ -69,7 +69,7 @@ public class SapPersonComparer : IEqualityComparer } - private string SubString(string s, int len) + private static string SubString(string s, int len) { if (string.IsNullOrWhiteSpace(s)) { @@ -87,7 +87,7 @@ public class SapPersonComparer : IEqualityComparer } - private DateTime? SafeParseDate(string str) + private static DateTime? SafeParseDate(string str) { if (str == "0000-00-00" || str == "0001-01-01" || str == "1900-01-01") return null; diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs index ad15c0c1..f6aa1900 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs @@ -79,7 +79,7 @@ public class SyncPersonJob foreach (var searchCodes in chunks) { - _logger.LogInformation("SAP分批处理Chunk数量:{count}", searchCodes.Count()); + _logger.LogInformation("SAP分批处理Chunk数量:{count}", searchCodes.Length); var existsWorkCodes = dbContext.Queryable() .Where(x => searchCodes.Contains(x.ename)) .Select(x => x.ename) @@ -390,7 +390,7 @@ public class SyncPersonJob return o; } - catch (Exception ex) + catch (Exception) { throw; } @@ -398,14 +398,14 @@ public class SyncPersonJob }).ToList(); } - private string GetNative(string idno) + private static string GetNative(string idno) { if (string.IsNullOrWhiteSpace(idno) || idno.Length < 6) return null; idno = idno.TrimStart(); return idno.Substring(0, 6); } - private DateTime? SafeParseDate(string str) + private static DateTime? SafeParseDate(string str) { if (string.IsNullOrEmpty(str)) { diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs index 2cd633bd..043d45f4 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs @@ -210,12 +210,12 @@ public class AssignmentService : IAssignmentService Enable = true, Sections = new List() { - new TimePeriodWeekDaySection() + new() { DayOfWeek= DayOfWeek.Monday, TimePeriods = new List() { - new TimePeriod + new() { Start = TimeOnly.Parse("08:00:00"), End = TimeOnly.Parse("17:30:00"), @@ -236,7 +236,7 @@ public class AssignmentService : IAssignmentService Name = "计划的一部分", Schedules = new List { - new ScheduleDto + new() { Name = "国庆节", DateTimePeriod = new DateTimePeriod diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs index 2702f1a2..7dfb9667 100644 --- a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs +++ b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs @@ -97,7 +97,7 @@ public class RoleService : IRoleService } - private async Task CheckDuplicateNameAsync(IDbContext db, RoleSaveRequest request) + private static async Task CheckDuplicateNameAsync(IDbContext db, RoleSaveRequest request) { var exists = await db.Queryable() .WhereIF(request.Id.HasValue, x => x.Id != request.Id) diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/TenantService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/TenantService.cs index 653d2846..70642c2f 100644 --- a/Src/Dlhis.Sys/Identity/Services/Implements/TenantService.cs +++ b/Src/Dlhis.Sys/Identity/Services/Implements/TenantService.cs @@ -118,7 +118,7 @@ public class TenantService : ITenantService } - private void RecursionGetNext(TenantTreeResponse current, List data) + private static void RecursionGetNext(TenantTreeResponse current, List data) { var next = data.Where(x => x.PCode == current.Code).ToList(); current.Next = next; diff --git a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs index 9fd30309..495d05e0 100644 --- a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs +++ b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs @@ -214,7 +214,7 @@ public class MenuService : IMenuService } - private void RecursionGetNext(MenuResponse current, List menus) + private static void RecursionGetNext(MenuResponse current, List menus) { var nextMenus = menus.Where(x => x.PCode == current.Code).ToList(); current.Items = nextMenus; diff --git a/Src/Gateway/Startup.cs b/Src/Gateway/Startup.cs index 87d10f71..7f462d5e 100644 --- a/Src/Gateway/Startup.cs +++ b/Src/Gateway/Startup.cs @@ -24,7 +24,7 @@ public class Startup services.AddOcelot(); } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseSwagger(); app.UseSwaggerUI(c =>