From 944d9c2291b5355da8940268c7a794fc87608203 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:30:27 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix=20=E5=AE=9E=E4=BD=93=E7=BB=A7?= =?UTF-8?q?=E6=89=BF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/MealSupplementRecordEntity.cs | 33 +++++++++++-------- .../Implements/MealSupplementService.cs | 7 ++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs index 94e5fa7e..8a993992 100644 --- a/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs @@ -9,24 +9,38 @@ namespace Dlhis.Entity.Basic.Entity; /// 餐补记录 /// [SugarTable(TableName = "MealSupplementRecord", TableDescription = "餐补记录")] -public class MealSupplementRecordEntity : SugarBaseEntity +public class MealSupplementRecordEntity : MealSupplementRequestRecordEntity { /// /// 唯一号 /// [SugarColumn(IsNullable = false, ColumnDescription = "唯一号", UniqueGroupNameList = new[] { "idx_MealSupplementRecord_UniqueId" })] - public string UniqueId { get; set; } + public override string UniqueId { get; set; } /// /// 工号 /// - [SugarColumn(IsNullable = false, ColumnDescription = "工号")] - public string Code { get; set; } + [SugarColumn(IsNullable = false, ColumnDescription = "工号", IndexGroupNameList = new[] { "idx_MealSupplementRecord_Code" })] + public override string Code { get; set; } + + /// + /// 餐补状态 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public MealSupplementStatusEnumtype Status { get; set; } +} + +[SugarTable(TableName = "MealSupplementRequestRecord", TableDescription = "餐补请求记录")] +public class MealSupplementRequestRecordEntity : SugarBaseEntity +{ + public virtual string UniqueId { get; set; } + + public virtual string Code { get; set; } /// /// 考勤日期 /// - [SugarColumn(IsNullable = false, ColumnDescription = "考勤日期")] + [SugarColumn(ColumnDataType = "date", IsNullable = false, ColumnDescription = "考勤日期")] public DateTime Date { get; set; } /// @@ -41,9 +55,6 @@ public class MealSupplementRecordEntity : SugarBaseEntity [SugarColumn(IsNullable = false, ColumnDescription = "厂区")] public string Factory { get; set; } - /// - /// 备注 - /// public string Remark { get; set; } /// @@ -51,10 +62,4 @@ public class MealSupplementRecordEntity : SugarBaseEntity /// [SugarColumn(IsNullable = false, ColumnDescription = "餐补")] public decimal Amount { get; set; } - - /// - /// 餐补状态 - /// - [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] - public MealSupplementStatusEnumtype Status { get; set; } } diff --git a/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs index 9f0a22ca..701b9430 100644 --- a/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs +++ b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs @@ -1,7 +1,9 @@ -using Dlhis.External.MealSupplement.Channel; +using Dlhis.Entity.Basic.Entity; +using Dlhis.External.MealSupplement.Channel; using Dlhis.External.MealSupplement.Request; using Kurisu.AspNetCore.EventBus.Abstractions; using Kurisu.SqlSugar.Services; +using Mapster; namespace Dlhis.External.MealSupplement.Services.Implements; @@ -10,7 +12,7 @@ public class MealSupplementService : IMealSupplementService private readonly IEventBus _eventBus; private readonly IDbContext _dbContext; - public MealSupplementService(IEventBus eventBus , IDbContext dbContext) + public MealSupplementService(IEventBus eventBus, IDbContext dbContext) { _eventBus = eventBus; _dbContext = dbContext; @@ -18,6 +20,7 @@ public class MealSupplementService : IMealSupplementService public async Task DoSupplementsAsync(List reuqests) { + await _dbContext.InsertAsync(reuqests.Adapt>()); await _eventBus.PublishAsync(new MealSupplementMessage { Items = reuqests }); } } From 6fcb73f7a98ea83a1e9161a2c00ae024772f97fe Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:42:46 +0800 Subject: [PATCH 02/13] =?UTF-8?q?fix=20=E8=90=A5=E4=B8=9A=E7=82=B9?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BE=9B=E5=BA=94=E5=95=86(=E6=89=BF?= =?UTF-8?q?=E5=8C=85=E5=95=86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessPlace/Request/BusinessPlaceSaveRequest.cs | 5 +++++ .../BusinessPlace/Response/BusinessPlaceResponse.cs | 6 ++++++ .../Services/Implements/BusinessPlaceService.cs | 5 +++-- Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs | 7 +++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs b/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs index 15abe478..35c7cb27 100644 --- a/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs +++ b/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs @@ -25,6 +25,11 @@ public class BusinessPlaceSaveRequest [Required(ErrorMessage = "营业点名称不能为空")] public string Name { get; set; } + /// + /// 供应商 + /// + public string Supplier { get; set; } + /// /// 状态 CanteenBusinessPlaceStatusEnumType /// diff --git a/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs b/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs index c954462a..ae186627 100644 --- a/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs +++ b/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs @@ -23,6 +23,12 @@ public class BusinessPlaceResponse /// public string Name { get; set; } + + /// + /// 供应商 + /// + public string Supplier { get; set; } + /// /// 状态,停用/启用 /// diff --git a/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs b/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs index a49ecf44..17e4f88e 100644 --- a/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs +++ b/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs @@ -25,7 +25,7 @@ public class BusinessPlaceService : IBusinessPlaceService var page = await _dbContext.Queryable() .LeftJoin((x, ps) => x.Code == ps.PlaceCode) .LeftJoin((x, ps, s) => s.Code == ps.ShiftCode) - .WhereIF(request.Search.IsPresent(), x => x.CustomCode.Contains(request.Search) + .WhereIF(request.Search.IsPresent(), x => x.CustomCode.Contains(request.Search) || x.Code.ToString().Contains(request.Search) || x.Name.Contains(request.Search)) .WhereIF(request.Catalog.HasValue, x => x.Catalog == request.Catalog) .WhereIF(request.Status.HasValue, x => x.Status == request.Status) @@ -39,7 +39,7 @@ public class BusinessPlaceService : IBusinessPlaceService Catalog = x.Catalog, CustomCode = x.CustomCode, Source = x.Source, - + Supplier = x.Supplier, ShiftCode = s.Code, ShiftName = s.Name }) @@ -65,6 +65,7 @@ public class BusinessPlaceService : IBusinessPlaceService if (!request.Id.HasValue) { var entity = request.Adapt(); + entity.CustomCode = request.CustomCode; entity.Code = Guid.NewGuid(); await _dbContext.InsertAsync(entity); } diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs index 866f030a..429930a1 100644 --- a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs @@ -1,6 +1,7 @@ using Dlhis.Entity.Canteen.Enums; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar; +using Mapster; using SqlSugar; using SqlSugar.DbConvert; @@ -21,9 +22,15 @@ public class BusinessPlaceEntity : SugarBaseEntity, ITenantId /// /// 自定义代号 /// + [AdaptIgnore(MemberSide.Destination)] [SugarColumn(ColumnDescription = "自定义手工号")] public string CustomCode { get; set; } + /// + /// 供应商 + /// + [SugarColumn(ColumnDescription = "供应商")] + public string Supplier { get; set; } /// /// 营业点名称 From 89a93d2a692b6ddaf6669d814ddfb28feba9d290 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:44:04 +0800 Subject: [PATCH 03/13] =?UTF-8?q?fix=20=E5=90=8C=E6=AD=A5=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E6=8E=A7=E5=88=B6=E4=BA=BA=E4=BA=8B=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs | 6 ++++++ .../SyncSapInfo/Services/Implements/JinkoSapService.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs b/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs index d3142388..845dc6bf 100644 --- a/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs @@ -16,4 +16,10 @@ public class WerkEntity : SugarBaseEntity /// 名称 /// public string Name { get; set; } + + /// + /// 是否启用 + /// + [SugarColumn(ColumnDataType = "bit", DefaultValue = "1")] + public bool Enable { get; set; } } diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs index bfd27a08..26a090a5 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs @@ -65,7 +65,7 @@ public class JinkoSapService : IJinkoSapService { var apiUrl = "/RESTAdapter/Rest/EHR_PERSONNEL/"; - var werks = await _dbContext.Queryable().ToListAsync(); + var werks = await _dbContext.Queryable().Where(x => x.Enable).ToListAsync(); List persons = new(); List jobInfos = new(); From 2cdba175bdc94bf53370d4c3a5204253cf3d435e Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:50:59 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E7=BC=96=E7=A0=81=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/BusinessPlaceShiftService.cs | 14 ++++++-------- .../Device/Services/Implements/DeviceService.cs | 1 + .../Basic/Entity/BusinessShiftEntity.cs | 2 ++ Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs index 92f5f95e..de3fa555 100644 --- a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs +++ b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs @@ -62,7 +62,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService public async Task> GetListAsync() { var result = await _dbContext.Queryable() - .Select().ToListAsync(); + .Select() + .ToListAsync(); return result; } @@ -71,15 +72,14 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService { await CheckExistsAsync(request); - Guid code = Guid.Empty; if (!request.Id.HasValue) { var entity = request.Adapt(); - + entity.CustomCode = request.CustomCode; entity.Code = Guid.NewGuid(); await _dbContext.InsertAsync(entity); - code = entity.Code; + return entity.Code; } else { @@ -89,10 +89,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService request.Adapt(entity); await _dbContext.UpdateAsync(entity); - code = entity.Code; + return entity.Code; } - - return code; } public async Task SaveMealShiftsAsync(List requests) @@ -198,7 +196,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService .ToListAsync(); var devices = await _dbContext.Queryable().ToListAsync(); - + var list = new List(); if (regiss.Count > 0) { diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs index a0524c49..c0020c88 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs @@ -82,6 +82,7 @@ public class DeviceService : IDeviceService if (!request.Id.HasValue) { entity = request.Adapt(); + entity.UniqueNo = request.UniqueNo; entity.Code = Guid.NewGuid(); await _dbContext.InsertAsync(entity); //同时保存注册信息 diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs index 9893a6c6..8964221f 100644 --- a/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs @@ -1,5 +1,6 @@ using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar; +using Mapster; using SqlSugar; namespace Dlhis.Entity.Basic.Entity; @@ -19,6 +20,7 @@ public class BusinessShiftEntity : SugarBaseEntity, ITenantId /// /// 自定义代号 /// + [AdaptIgnore(MemberSide.Destination)] [SugarColumn(ColumnDescription = "自定义手工号")] public string CustomCode { get; set; } diff --git a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs index ddedd0ec..ed046e71 100644 --- a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs @@ -1,6 +1,7 @@ using Dlhis.Entity.Device.Enums; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar; +using Mapster; using SqlSugar; using SqlSugar.DbConvert; @@ -21,6 +22,7 @@ public class DeviceEntity : SugarBaseEntity, ITenantId /// /// 设备唯一码,IP/MAC/SNO /// + [AdaptIgnore(MemberSide.Destination)] [SugarColumn(ColumnDescription = "设备唯一码", IsNullable = false, UniqueGroupNameList = new[] { "Idx_Device_UniqueNo" })] public string UniqueNo { get; set; } From efbb72105c60e9fbc13e3bc6d76dec56e6c6b8b7 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 19:29:30 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix=20=E8=81=9A=E5=90=88swagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Gateway/Gateway.csproj | 2 ++ Src/Gateway/Program.cs | 31 +++++++++++++++------------ Src/Gateway/Startup.cs | 41 ++++++++++++++++++++++++++++++++++++ Src/Gateway/appsettings.json | 10 ++++++++- Src/Gateway/ocelot.json | 11 ++++++++++ 5 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 Src/Gateway/Startup.cs diff --git a/Src/Gateway/Gateway.csproj b/Src/Gateway/Gateway.csproj index 82f8dae2..4dc2203d 100644 --- a/Src/Gateway/Gateway.csproj +++ b/Src/Gateway/Gateway.csproj @@ -10,6 +10,8 @@ + + diff --git a/Src/Gateway/Program.cs b/Src/Gateway/Program.cs index b3ba8e28..5e1e7a63 100644 --- a/Src/Gateway/Program.cs +++ b/Src/Gateway/Program.cs @@ -1,16 +1,19 @@ -using Ocelot.DependencyInjection; -using Ocelot.Middleware; -var builder = WebApplication.CreateBuilder(args); -builder.Configuration.AddJsonFile("ocelot.json", true, true); -// Add services to the container. +using Gateway; -builder.Services.AddOcelot(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. - -app.UseOcelot().Wait(); - -app.Run(); +public class Program +{ + public static void Main(string[] args) + { + Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration(builder => + { + builder.AddJsonFile("ocelot.json", true, true); + }) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .Build().Run(); + } +} diff --git a/Src/Gateway/Startup.cs b/Src/Gateway/Startup.cs new file mode 100644 index 00000000..87d10f71 --- /dev/null +++ b/Src/Gateway/Startup.cs @@ -0,0 +1,41 @@ +using Microsoft.OpenApi.Models; +using Ocelot.DependencyInjection; +using Ocelot.Middleware; + +namespace Gateway; + +public class Startup +{ + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddEndpointsApiExplorer(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "# gateway api..." }); + }); + + services.AddOcelot(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseSwagger(); + app.UseSwaggerUI(c => + { + var services = Configuration.GetSection("Services").Get>(); + foreach (var s in services) + { + c.SwaggerEndpoint($"/{s.ToLower()}/swagger/v1/swagger.json", s); + } + }); + app.UseOcelot().Wait(); + } + +} diff --git a/Src/Gateway/appsettings.json b/Src/Gateway/appsettings.json index 10f68b8c..68b1359a 100644 --- a/Src/Gateway/appsettings.json +++ b/Src/Gateway/appsettings.json @@ -5,5 +5,13 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "Services": [ + "Basic", + "Common", + "Canteen", + "Scheduled", + "User", + "Sys" + ] } diff --git a/Src/Gateway/ocelot.json b/Src/Gateway/ocelot.json index 46e3b225..52cdcdf4 100644 --- a/Src/Gateway/ocelot.json +++ b/Src/Gateway/ocelot.json @@ -84,6 +84,17 @@ "Port": 31007 } ] + }, + { + "UpstreamPathTemplate": "/{url}/swagger/v1/swagger.json", + "DownstreamPathTemplate": "/{url}/swagger/v1/swagger.json", + "DownstreamScheme": "https", + "DownstreamHostAndPorts": [ + { + "Host": "yikatong.isawesome.cn", + "Port": 443 + } + ] } ], "GlobalConfiguration": {} From 7a6bedf3f43db8b4674deaa9842ea4672b5efc0b Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 20:36:14 +0800 Subject: [PATCH 06/13] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 135 ++++++++++++++++++ .../Implements/DevicePermissionService.cs | 7 +- Src/Dlhis.Basic/Dlhis.Basic.csproj | 2 +- Src/Dlhis.Basic/Program.cs | 2 + .../Device/Entities/DeviceTaskEntity.cs | 6 + .../Device/Enums/DeviceTaskStatusEnumType.cs | 7 + 6 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs new file mode 100644 index 00000000..43c096dc --- /dev/null +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -0,0 +1,135 @@ +using System.Linq.Expressions; +using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.AspNetCore.EventBus.Abstractions.Handler; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Entity; +using Kurisu.SqlSugar.Services; +using SqlSugar; + +namespace Dlhis.Basic.Device.EventBusHandler; + +public class CancelDuplicationTaskHandler : IAsyncChannelHandler +{ + private readonly IServiceProvider _serviceProvider; + private readonly ILogger _logger; + + public CancelDuplicationTaskHandler(IServiceProvider serviceProvider, ILogger logger) + { + _serviceProvider = serviceProvider; + _logger = logger; + } + + public async Task InvokeAsync(CancelDuplicationTaskMessage message) + { + _logger.LogInformation("抵消任务开始处理"); + + using (var scope = _serviceProvider.CreateScope()) + { + var optionService = scope.ServiceProvider.GetService(); + var db = scope.ServiceProvider.GetService(); + + db.Client.QueryFilter.ClearAndBackup(); + optionService.IgnoreTenant = true; + try + { + //人员下发任务相关 + var taskTypes = new List() { DeviceTaskEnumType.Add, DeviceTaskEnumType.Delete, DeviceTaskEnumType.Update }; + + var deviceTasks = await db.Queryable() + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait)//没有被获取 + .Where(x => taskTypes.Contains(x.Type)) + .OrderBy(x => x.CreateTime, OrderByType.Desc) + .ToListAsync(); + + var groupData = deviceTasks.GroupBy(x => new { x.TenantId, x.UserNo, x.DeviceUniqueNo }); + foreach (var deviceTaskPack in groupData) + { + var uniqueInfo = deviceTaskPack.Key; + var data = deviceTaskPack.ToList(); + + + foreach (var item in data) + { + try + { + Expression> where = LinqExpressionExtension.False(); + var ignoreData = new List(); + //最新一条更新人员信息 + if (item.Type == DeviceTaskEnumType.Update && item.Status == DeviceTaskStatusEnumType.Wait) + { + //获取过往的更新人员任务 + ignoreData = data.Where(x => x.Type == DeviceTaskEnumType.Update) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); + + ignoreData.ForEach(p => + { + where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); + }); + } + else if (item.Type == DeviceTaskEnumType.Delete && item.Status == DeviceTaskStatusEnumType.Wait) + { + ignoreData = data.Where(x => (x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Delete)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); + + ignoreData.ForEach(p => + { + where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); + }); + } + + if (ignoreData.Any()) + { + await db.Updateable() + .SetColumns(x => x.Version == x.Version + 1) + .SetColumns(x => x.Status == DeviceTaskStatusEnumType.Cancel) + .SetColumns(x => x.CancellationId == item.Id) + .SetColumns(x => x.ModifiedTime == DateTime.Now) + .Where(where) + .ExecuteCommandAsync(); + + data.ForEach(x => + { + if (ignoreData.Any(p => p.Id == x.Id)) + x.Status = DeviceTaskStatusEnumType.Cancel; + }); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "抵消处理异常:{message}", ex.Message); + } + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "抵消处理异常:{message}", ex.Message); + } + finally + { + db.Client.QueryFilter.Restore(); + optionService.IgnoreTenant = false; + } + } + + + _logger.LogInformation("抵消任务处理完成"); + } +} + +public class CancelDuplicationTaskMessage : IAsyncChannelMessage +{ + +} + +public class IdVersion +{ + public long Id { get; set; } + public int Version { get; set; } +} diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index f3c56a47..d1b38a8c 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -1,4 +1,5 @@ using Dlhis.Basic.Device.Dtos; +using Dlhis.Basic.Device.EventBusHandler; using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Response; using Dlhis.Entity.Basic.Entity; @@ -6,6 +7,7 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Sys.Entities; using Dlhis.Entity.Sys.Enums; +using Kurisu.AspNetCore.EventBus.Abstractions; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.Core.DataAccess.Entity; @@ -18,11 +20,13 @@ public class DevicePermissionService : IDevicePermissionService { private readonly IDbContext _dbContext; private readonly ICurrentUser _currentUser; + private readonly IEventBus _eventBus; - public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser) + public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser, IEventBus eventBus) { _dbContext = dbContext; _currentUser = currentUser; + _eventBus = eventBus; } public async Task AssignAsync(DevicePermissionSaveReuqest reuqest) @@ -153,6 +157,7 @@ public class DevicePermissionService : IDevicePermissionService if (waitTasks.Any()) { await _dbContext.InsertAsync(waitTasks); + await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } } finally diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj index ffe86e4d..61d37f79 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/Program.cs b/Src/Dlhis.Basic/Program.cs index 953eea17..8ccfcccb 100644 --- a/Src/Dlhis.Basic/Program.cs +++ b/Src/Dlhis.Basic/Program.cs @@ -1,3 +1,4 @@ +using Kurisu.AspNetCore.EventBus.Extensions; using Kurisu.AspNetCore.Startup; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Startup; @@ -22,5 +23,6 @@ public class Startup : DefaultStartup { base.ConfigureServices(services); services.AddRedis(); + services.AddEventBus(); } } \ No newline at end of file diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs index 22d404b6..93ba3b54 100644 --- a/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs +++ b/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs @@ -47,5 +47,11 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion [SugarColumn(ColumnDataType = "longtext")] public string ResultMessage { get; set; } + /// + /// 取消id + /// + public long CancellationId { get; set; } + + public string TenantId { get; set; } } diff --git a/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs b/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs index 3c2009af..9b9cc18c 100644 --- a/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs +++ b/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs @@ -26,6 +26,13 @@ public enum DeviceTaskStatusEnumType [Description("下发完成")] Success = 10, + + /// + /// 取消 + /// + [Description("取消")] + Cancel = 95, + /// /// 异常 /// From 7da5fdcb2f304a5b7193d294a0b34f5051a55abf Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 20:53:56 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix=20=E5=88=A0=E9=99=A4=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=AE=BE=E7=BD=AE=E6=89=80=E6=9C=89=E4=B8=BA=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 43c096dc..3a00b25e 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -64,34 +64,48 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler x.Status == DeviceTaskStatusEnumType.Wait) .Where(x => x.Id != item.Id) .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); - - ignoreData.ForEach(p => - { - where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); - }); } + //最新一条删除人员信息 else if (item.Type == DeviceTaskEnumType.Delete && item.Status == DeviceTaskStatusEnumType.Wait) { - ignoreData = data.Where(x => (x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Delete)) - .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) - .Where(x => x.Id != item.Id) - .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); - - ignoreData.ForEach(p => + //判断是否成功 + if (await db.Queryable().Where(x => x.UserNo == item.UserNo) + .Where(x => x.DeviceUniqueNo == item.DeviceUniqueNo) + .Where(x => x.TenantId == item.TenantId).Where(x => x.Status == DeviceTaskStatusEnumType.Success).AnyAsync()) { - where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); - }); + var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) + .FirstOrDefault(x => x.Id != item.Id); + + if (beforeTask != null) ignoreData.Add(beforeTask); + + } + else + { + ignoreData.AddRange(data.Where(x => x.Type == DeviceTaskEnumType.Add + || x.Type == DeviceTaskEnumType.Delete + || x.Type == DeviceTaskEnumType.Update) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) + ); + } } if (ignoreData.Any()) { + ignoreData.ForEach(p => + { + where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); + }); + await db.Updateable() - .SetColumns(x => x.Version == x.Version + 1) - .SetColumns(x => x.Status == DeviceTaskStatusEnumType.Cancel) - .SetColumns(x => x.CancellationId == item.Id) - .SetColumns(x => x.ModifiedTime == DateTime.Now) - .Where(where) - .ExecuteCommandAsync(); + .SetColumns(x => x.Version == x.Version + 1) + .SetColumns(x => x.Status == DeviceTaskStatusEnumType.Cancel) + .SetColumns(x => x.CancellationId == item.Id) + .SetColumns(x => x.ModifiedTime == DateTime.Now) + .Where(where) + .ExecuteCommandAsync(); data.ForEach(x => { From b763e74c123e40a37be18c6f4c55654833bc5e73 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 20:56:37 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix=20=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=8F=96=E5=8F=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 3a00b25e..485c4296 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -68,27 +68,26 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler().Where(x => x.UserNo == item.UserNo) .Where(x => x.DeviceUniqueNo == item.DeviceUniqueNo) .Where(x => x.TenantId == item.TenantId).Where(x => x.Status == DeviceTaskStatusEnumType.Success).AnyAsync()) + { + ignoreData.AddRange(data.Where(x => x.Type == DeviceTaskEnumType.Add + || x.Type == DeviceTaskEnumType.Delete + || x.Type == DeviceTaskEnumType.Update) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) + ); + } + else { var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) .FirstOrDefault(x => x.Id != item.Id); if (beforeTask != null) ignoreData.Add(beforeTask); - - } - else - { - ignoreData.AddRange(data.Where(x => x.Type == DeviceTaskEnumType.Add - || x.Type == DeviceTaskEnumType.Delete - || x.Type == DeviceTaskEnumType.Update) - .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) - .Where(x => x.Id != item.Id) - .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) - ); } } From 62d54c1f70562120b5131d4861b3ad8ba7c2a334 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:04:45 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix=20=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 485c4296..92158487 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -83,11 +83,29 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler { item.Id }; var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) - .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) - .FirstOrDefault(x => x.Id != item.Id); + .Where(x => !currentIds.Contains(x.Id)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .FirstOrDefault(); - if (beforeTask != null) ignoreData.Add(beforeTask); + //逻辑正确,最终beforeTask.type == DeviceTaskEnumType.Add + while (beforeTask != null && beforeTask.Type == DeviceTaskEnumType.Update) + { + ignoreData.Add(new IdVersion() { Id = beforeTask.Id, Version = beforeTask.Version }); + currentIds.Add(beforeTask.Id); + + beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) + .Where(x => !currentIds.Contains(x.Id)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .FirstOrDefault(); + } + + if (beforeTask != null) + { + ignoreData.Add(new IdVersion() { Id = beforeTask.Id, Version = beforeTask.Version }); + ignoreData.Add(new IdVersion() { Id = item.Id, Version = item.Version }); + } } } From f2de9a6526953fc46dd8b362deaacb8c7ac1e114 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:08:28 +0800 Subject: [PATCH 10/13] =?UTF-8?q?fix=20=E6=95=B0=E6=8D=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=9C=80=E8=A6=81=E6=AF=94=E8=BE=83=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/EventBusHandler/CancelDuplicationTaskHandler.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 92158487..e19cf28f 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -63,6 +63,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler x.Type == DeviceTaskEnumType.Update) .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) .Where(x => x.Id != item.Id) + .Where(x => item.CreateTime > x.CreateTime) .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); } //最新一条删除人员信息 @@ -78,6 +79,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler x.Status == DeviceTaskStatusEnumType.Wait) .Where(x => x.Id != item.Id) + .Where(x => item.CreateTime > x.CreateTime) .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) ); } @@ -87,6 +89,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) .Where(x => !currentIds.Contains(x.Id)) .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => item.CreateTime > x.CreateTime) .FirstOrDefault(); //逻辑正确,最终beforeTask.type == DeviceTaskEnumType.Add @@ -98,6 +101,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) .Where(x => !currentIds.Contains(x.Id)) .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => item.CreateTime > x.CreateTime) .FirstOrDefault(); } From d3c1b45cf9f057553c7650e6249020272e0969ba Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:29:20 +0800 Subject: [PATCH 11/13] =?UTF-8?q?fix=20=E5=8F=96=E6=B6=88=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/Services/Implements/DevicePermissionService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index d1b38a8c..c0886441 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -157,8 +157,9 @@ public class DevicePermissionService : IDevicePermissionService if (waitTasks.Any()) { await _dbContext.InsertAsync(waitTasks); - await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } + + await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } finally { From 9fdb2b0159b75c86ba1a5068bc2df8cdf67a928b Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:44:02 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E6=95=88=E5=AD=97=E6=AE=B5=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Response/DeviceTaskAssignmentResponse.cs | 11 ----------- .../Implements/DeviceTaskAssignmentService.cs | 2 -- 2 files changed, 13 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs index fc9e74d2..d594c37d 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs @@ -1,6 +1,5 @@ using Dlhis.Entity.Device.Enums; using Kurisu.AspNetCore.Utils.Extensions; -using SqlSugar; namespace Dlhis.ScheduledTask.TaskAssignment.Response; @@ -83,14 +82,4 @@ public class DeviceTaskAssignmentResponse /// 部署点 /// public string DeployPlace { get; set; } - - /// - /// 连接信息 - /// - public string ConnectionInfo { get; set; } - - /// - /// 设备名称 - /// - public string DeviceName { get; set; } } diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs index 0138667d..50755267 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs @@ -54,8 +54,6 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService LastUpdateTime = deviceTask.ModifiedTime, TenantId = deviceTask.TenantId, DeployPlace = device.DeployPlace, - ConnectionInfo = device.ConnectionInfo, - DeviceName = device.Supplier }) .ToPageListAsync(request); From ccf8a88a9be103b01953f1236dac553f8c96ff88 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:59:32 +0800 Subject: [PATCH 13/13] =?UTF-8?q?fix=20=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E8=B0=83=E5=BA=A6=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/Controllers/DevicesController.cs | 3 +- .../Implements/DevicePermissionService.cs | 8 +---- Src/Dlhis.Basic/Program.cs | 2 -- .../CommonJobs/CancelDuplicationTaskJob.cs} | 29 ++++++++----------- Src/Dlhis.ScheduledTask/Packs/JobPack.cs | 8 ++++- 5 files changed, 22 insertions(+), 28 deletions(-) rename Src/{Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs => Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs} (91%) diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs index 51b5bfaa..3298137a 100644 --- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs +++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs @@ -2,6 +2,8 @@ using Dlhis.Basic.Device.Response; using Dlhis.Basic.Device.Services; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.AspNetCore.Scope; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -218,5 +220,4 @@ public class DevicesController : ControllerBase { return await _deviceService.BulkUploadsAsync(request); } - } diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index c0886441..f3c56a47 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -1,5 +1,4 @@ using Dlhis.Basic.Device.Dtos; -using Dlhis.Basic.Device.EventBusHandler; using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Response; using Dlhis.Entity.Basic.Entity; @@ -7,7 +6,6 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Sys.Entities; using Dlhis.Entity.Sys.Enums; -using Kurisu.AspNetCore.EventBus.Abstractions; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.Core.DataAccess.Entity; @@ -20,13 +18,11 @@ public class DevicePermissionService : IDevicePermissionService { private readonly IDbContext _dbContext; private readonly ICurrentUser _currentUser; - private readonly IEventBus _eventBus; - public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser, IEventBus eventBus) + public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser) { _dbContext = dbContext; _currentUser = currentUser; - _eventBus = eventBus; } public async Task AssignAsync(DevicePermissionSaveReuqest reuqest) @@ -158,8 +154,6 @@ public class DevicePermissionService : IDevicePermissionService { await _dbContext.InsertAsync(waitTasks); } - - await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } finally { diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs index 8ccfcccb..953eea17 100644 --- a/Src/Dlhis.Basic/Program.cs +++ b/Src/Dlhis.Basic/Program.cs @@ -1,4 +1,3 @@ -using Kurisu.AspNetCore.EventBus.Extensions; using Kurisu.AspNetCore.Startup; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Startup; @@ -23,6 +22,5 @@ public class Startup : DefaultStartup { base.ConfigureServices(services); services.AddRedis(); - services.AddEventBus(); } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs similarity index 91% rename from Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs rename to Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs index e19cf28f..b701c93e 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs @@ -1,27 +1,25 @@ -using System.Linq.Expressions; -using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; -using Kurisu.AspNetCore.EventBus.Abstractions; -using Kurisu.AspNetCore.EventBus.Abstractions.Handler; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar.Services; using SqlSugar; +using System.Linq.Expressions; -namespace Dlhis.Basic.Device.EventBusHandler; +namespace Dlhis.ScheduledTask.CommonJobs; -public class CancelDuplicationTaskHandler : IAsyncChannelHandler +public class CancelDuplicationTaskJob { private readonly IServiceProvider _serviceProvider; - private readonly ILogger _logger; + private readonly ILogger _logger; - public CancelDuplicationTaskHandler(IServiceProvider serviceProvider, ILogger logger) + public CancelDuplicationTaskJob(IServiceProvider serviceProvider, ILogger logger) { _serviceProvider = serviceProvider; _logger = logger; } - public async Task InvokeAsync(CancelDuplicationTaskMessage message) + public async Task RunAsync() { _logger.LogInformation("抵消任务开始处理"); @@ -156,15 +154,12 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler("CancelDuplicationTask", s => s.RunAsync(), "0/15 * * * * ?", new RecurringJobOptions + { + TimeZone = TimeZoneInfo.Local + }); + + RecurringJob.AddOrUpdate("TempCreateUser", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); - } }