diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs index f71f6073..d0df9c4c 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs @@ -7,6 +7,7 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.CustomClass; using Kurisu.Core.DataAccess.Dto; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceTemplateService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceTemplateService.cs index c9c7accb..3e06e718 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceTemplateService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceTemplateService.cs @@ -1,8 +1,8 @@ using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Response; using Dlhis.Entity.Basic.Entity; -using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.CustomClass; using Kurisu.Core.DataAccess.Dto; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; @@ -74,7 +74,7 @@ public class DeviceTemplateService : IDeviceTemplateService duplicate.ThrowIfTrue("品牌和型号重复"); } - private void CheckJsonFormat(string template) + private static void CheckJsonFormat(string template) { try { diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesMenuService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesMenuService.cs index 4c372a00..f89bb400 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesMenuService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesMenuService.cs @@ -164,7 +164,7 @@ public class DishesMenuService : IDishesMenuService var keys = entities.DistinctBy(x => new { x.CustomCode, x.StartDate, x.EndDate, x.ShiftType }) .Select(x => new { x.CustomCode, x.StartDate, x.EndDate, x.ShiftType }) .ToList(); - var deleteWhere = LinqExpressionExtension.False(); + var deleteWhere = LinqExpressionExtensions.False(); keys.ForEach(x => { deleteWhere = deleteWhere.Or(item => item.BusinessPlaceCode == request.BusinessPlaceCode @@ -178,7 +178,7 @@ public class DishesMenuService : IDishesMenuService if (request.Items.Any()) { - Expression> whereCheck = LinqExpressionExtension.False(); + Expression> whereCheck = LinqExpressionExtensions.False(); request.Items.ForEach(p => { whereCheck = whereCheck.Or(x => x.BusinessPlaceCode == request.BusinessPlaceCode diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj index fa24f2db..f3a3104d 100644 --- a/Src/Dlhis.Basic/Dlhis.Basic.csproj +++ b/Src/Dlhis.Basic/Dlhis.Basic.csproj @@ -17,7 +17,7 @@ - + diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index a2ca22a7..c82d86d1 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -61,7 +61,7 @@ public class GainfoService : IGainfoService var currentTenantId = _currentUser.GetStringTenantId(); //根据组织架构搜索档案 - Expression> where = LinqExpressionExtension.False(); + Expression> where = LinqExpressionExtensions.False(); foreach (var item in request.DepartmentSelections) { var depts = await GetRecursionDepartmentNosAsync(item.DepartmentNos); diff --git a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj index a17298ed..fe9ff0e0 100644 --- a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj +++ b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj @@ -36,7 +36,7 @@ - + diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs index 98aa0ded..9e412456 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs @@ -7,7 +7,7 @@ using Dlhis.Entity.Canteen.Enums; using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Sys.Api; -using Kurisu.AspNetCore.UnifyResultAndValidation; +using Kurisu.AspNetCore.Utils; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.Core.User.Abstractions; @@ -561,8 +561,7 @@ public class BalanceService : IBalanceService balanceRecord.Status = BalanceRecordStatusEnumType.Obsolute; balanceRecord.Remark = request.Reason; - - await ContinueUpdateAsync(async () => + await CommonHelper.RetryAsync(async () => { //重算金额 var canteenUser = await _dbContext.Queryable().Where(x => x.UserNo == balanceRecord.UserNo).SingleAsync(); @@ -899,29 +898,4 @@ public class BalanceService : IBalanceService return days; } - - - //************************************************************** help methods ****************************************************************** - - private async Task ContinueUpdateAsync(Func func, int retry) - { - for (int i = 0; i < retry; i++) - { - try - { - await func(); - return; - } - catch (Exception ex) when (ex is VersionExceptions) - { - _logger.LogWarning(ex, "{message}", ex.Message); - } - catch (Exception) - { - throw; - } - } - - throw new UserFriendlyException("操作失败,请重试"); - } } diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs index 271c3291..21cc28b5 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BaseOrderService.cs @@ -2,12 +2,10 @@ using Dlhis.Canteen.Setting.Services; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Canteen.Enums; -using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.User.Abstractions; using Kurisu.SqlSugar.Services; using Mapster; -using SqlSugar; namespace Dlhis.Canteen.Order.Services.Implements; @@ -52,38 +50,6 @@ public abstract class BaseOrderService uniqueNos.Contains(deviceUniqueNo).ThrowIfFalse("无消费权限"); } - - /// - /// 设备并发更新 需要抛出VersionExceptions - /// - /// - /// - /// - /// - /// - protected async Task ContinueUpdateAsync(Func func, int retry, string errorMessage = null) - { - for (int i = 0; i < retry; i++) - { - try - { - await func(); - return; - } - catch (Exception ex) when (ex is VersionExceptions) - { - _logger.LogWarning(ex, "{message}", ex.Message); - } - catch (Exception) - { - throw; - } - } - - throw new UserFriendlyException(errorMessage ?? "操作失败,请重试"); - } - - /// /// 获取参数配置 /// diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BookingOrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BookingOrderService.cs index 9ea6e736..4c9a18e0 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BookingOrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BookingOrderService.cs @@ -87,7 +87,7 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService }; var orderId = await DbContext.InsertReturnIdentityAsync(order); - await ContinueUpdateAsync(async () => + await CommonHelper.RetryAsync(async () => { await _disheMenuApi.GetBookingDishesDetailAsync(request.BookingDate, request.BusinessPlaceCode, (int)request.ShiftType, request.DishesCode); var menuDetail = menuDetailResult.Data; diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index ef8c57a2..77e36c61 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -5,7 +5,6 @@ using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Canteen.Entities; using Dlhis.Entity.Canteen.Enums; using Dlhis.Entity.Device.Entities; -using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.CustomClass; @@ -425,7 +424,7 @@ public class OrderService : BaseOrderService, IOrderService { var order = await DbContext.Queryable().Where(x => x.Id == orderId).FirstAsync(); - await ContinueUpdateAsync(async () => + await CommonHelper.RetryAsync(async () => { var canteenUser = await DbContext.Queryable().Where(x => x.UserNo == order.UserNo).FirstAsync(); //金额+- @@ -463,7 +462,7 @@ public class OrderService : BaseOrderService, IOrderService var allowNoBalance = await GetSettingAsync(CanteenSettingItemEnumType.AllowNoBalance); - await ContinueUpdateAsync(async () => + await CommonHelper.RetryAsync(async () => { if (!allowNoBalance) { diff --git a/Src/Dlhis.Canteen/Program.cs b/Src/Dlhis.Canteen/Program.cs index 198c78c7..4a463298 100644 --- a/Src/Dlhis.Canteen/Program.cs +++ b/Src/Dlhis.Canteen/Program.cs @@ -29,6 +29,6 @@ public class Startup : DefaultStartup public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) { base.Configure(app, env); - app.UseSnowFlakeInit(); + app.UseSnowFlakeDistributedInitialize(); } } \ No newline at end of file diff --git a/Src/Dlhis.Common/Dlhis.Common.csproj b/Src/Dlhis.Common/Dlhis.Common.csproj index fd153a15..a2e461e0 100644 --- a/Src/Dlhis.Common/Dlhis.Common.csproj +++ b/Src/Dlhis.Common/Dlhis.Common.csproj @@ -21,8 +21,8 @@ - - + + diff --git a/Src/Dlhis.Entity/Dlhis.Entity.csproj b/Src/Dlhis.Entity/Dlhis.Entity.csproj index 8000930a..31994a94 100644 --- a/Src/Dlhis.Entity/Dlhis.Entity.csproj +++ b/Src/Dlhis.Entity/Dlhis.Entity.csproj @@ -11,7 +11,7 @@ - + diff --git a/Src/Dlhis.External/Dlhis.External.csproj b/Src/Dlhis.External/Dlhis.External.csproj index e89418db..883e35c3 100644 --- a/Src/Dlhis.External/Dlhis.External.csproj +++ b/Src/Dlhis.External/Dlhis.External.csproj @@ -9,7 +9,7 @@ - + diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs index 12ec6deb..07e27b69 100644 --- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs +++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs @@ -56,7 +56,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService public async Task UploadLogsAsync(List requests) { //判断存在的记录 - Expression> where = LinqExpressionExtension.False(); + Expression> where = LinqExpressionExtensions.False(); requests.ForEach(p => { where = where.Or(x => x.DeviceUniqueNo == p.DeviceUniqueNo && x.SerialNo == p.SerialNo && x.RaiseDateTime == p.RaiseDateTime); diff --git a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj index bfad9e56..44380fe5 100644 --- a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj +++ b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj @@ -20,7 +20,7 @@ - + diff --git a/Src/Dlhis.ScheduledTask/IPPortDto.cs b/Src/Dlhis.ScheduledTask/IPPortDto.cs deleted file mode 100644 index 6a1bbd8a..00000000 --- a/Src/Dlhis.ScheduledTask/IPPortDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Dlhis.ScheduledTask -{ - public class IPPortDto - { - public string IP { get; set; } - public int Port { get; set; } - } -} diff --git a/Src/Dlhis.ScheduledTask/Jobs/CancelDuplicationTaskJob.cs b/Src/Dlhis.ScheduledTask/Jobs/CancelDuplicationTaskJob.cs index 55ae7aa0..d686ec38 100644 --- a/Src/Dlhis.ScheduledTask/Jobs/CancelDuplicationTaskJob.cs +++ b/Src/Dlhis.ScheduledTask/Jobs/CancelDuplicationTaskJob.cs @@ -40,7 +40,7 @@ public class CancelDuplicationTaskJob : BaseJob { try { - Expression> where = LinqExpressionExtension.False(); + Expression> where = LinqExpressionExtensions.False(); var ignoreData = new List(); //最新一条更新人员信息 if (item.Type == DeviceTaskEnumType.Update && item.Status == DeviceTaskStatusEnumType.Wait) diff --git a/Src/Dlhis.ScheduledTask/Jobs/HeartbeatJob.cs b/Src/Dlhis.ScheduledTask/Jobs/HeartbeatJob.cs index ba424a1f..1ae4e240 100644 --- a/Src/Dlhis.ScheduledTask/Jobs/HeartbeatJob.cs +++ b/Src/Dlhis.ScheduledTask/Jobs/HeartbeatJob.cs @@ -2,6 +2,7 @@ using System.Net.Sockets; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Device.Entities; +using Kurisu.Core.CustomClass; using Kurisu.Scheduled; using Kurisu.Scheduled.Attributes; using Newtonsoft.Json; diff --git a/Src/Dlhis.ScheduledTask/Jobs/MealSupplementHandlerJob.cs b/Src/Dlhis.ScheduledTask/Jobs/MealSupplementHandlerJob.cs index a6aa2520..18228d1e 100644 --- a/Src/Dlhis.ScheduledTask/Jobs/MealSupplementHandlerJob.cs +++ b/Src/Dlhis.ScheduledTask/Jobs/MealSupplementHandlerJob.cs @@ -6,7 +6,6 @@ using Dlhis.Entity.Canteen.Entities; using Dlhis.Entity.Canteen.Enums; using Dlhis.ScheduledTask.SyncSapInfo; using Dlhis.ScheduledTask.SyncSapInfo.Services; -using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Scheduled; @@ -92,7 +91,7 @@ public class MealSupplementHandlerJob : BaseJob await DbContext.Client.Ado.BeginTranAsync(); try { - await ContinueUpdateAsync(async () => + await CommonHelper.RetryAsync(async () => { var mealUser = await DbContext.Queryable().Where(x => x.UserCode == mealSupplement.Code).FirstAsync(); var b = mealUser.Balance += mealSupplement.Amount; @@ -107,7 +106,6 @@ public class MealSupplementHandlerJob : BaseJob { throw new VersionExceptions("餐补写入错误"); } - }, 5); var r = await _jinkoJIPService.SyncMealSupplementRecordsAsync(new List @@ -227,26 +225,4 @@ public class MealSupplementHandlerJob : BaseJob .ExecuteCommandAsync(); } } - - private async Task ContinueUpdateAsync(Func func, int retry, string errorMessage = null) - { - for (int i = 0; i < retry; i++) - { - try - { - await func(); - return; - } - catch (Exception ex) when (ex is VersionExceptions) - { - Logger.LogWarning(ex, ex.Message); - } - catch (Exception) - { - throw; - } - } - - throw new UserFriendlyException(errorMessage ?? "操作失败,请重试"); - } } diff --git a/Src/Dlhis.ScheduledTask/Program.cs b/Src/Dlhis.ScheduledTask/Program.cs index 27e7b9cc..c456425f 100644 --- a/Src/Dlhis.ScheduledTask/Program.cs +++ b/Src/Dlhis.ScheduledTask/Program.cs @@ -25,5 +25,6 @@ public class Startup : DefaultStartup public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) { base.Configure(app, env); + app.UseSnowFlakeDistributedInitialize(); } } \ No newline at end of file diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs index 043d45f4..eabf443b 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Dlhis.ScheduledTask.TaskAssignment.Request; using Dlhis.ScheduledTask.TaskAssignment.Response; using Kurisu.AspNetCore.Scope; -using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.SqlSugar.Services; using Microsoft.AspNetCore.DataProtection; @@ -69,7 +68,7 @@ public class AssignmentService : IAssignmentService } var taskIdVs = page.Data.Select(x => new { x.TaskId, x.Version }).ToList(); - Expression> where = LinqExpressionExtension.False(); + Expression> where = LinqExpressionExtensions.False(); taskIdVs.ForEach(p => { where = where.Or(x => x.Id == p.TaskId && x.Version == p.Version && x.Status != DeviceTaskStatusEnumType.Success); diff --git a/Src/Dlhis.Sys/Dlhis.Sys.csproj b/Src/Dlhis.Sys/Dlhis.Sys.csproj index 60ff68d5..8c2f599f 100644 --- a/Src/Dlhis.Sys/Dlhis.Sys.csproj +++ b/Src/Dlhis.Sys/Dlhis.Sys.csproj @@ -17,7 +17,7 @@ - + diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs index 7dfb9667..da381fca 100644 --- a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs +++ b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs @@ -5,6 +5,7 @@ using Dlhis.User.Identity.Services; using Kurisu.AspNetCore.Scope; using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.CustomClass; using Kurisu.Core.DataAccess.Dto; using Kurisu.Core.User.Abstractions; using Kurisu.SqlSugar.Extensions; diff --git a/Src/Dlhis.User/Dlhis.User.csproj b/Src/Dlhis.User/Dlhis.User.csproj index 7934a4d0..56df2db2 100644 --- a/Src/Dlhis.User/Dlhis.User.csproj +++ b/Src/Dlhis.User/Dlhis.User.csproj @@ -17,6 +17,6 @@ - +