From ff333219d414352602f976fff865eb7bc9b8bfe5 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 9 Jan 2024 14:27:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/InternationalizationViewModel.cs | 16 +++-- .../Common/InternationalizationService.cs | 68 +++++++++++++++++-- .../Service/Common/_MapConfig.cs | 3 + .../Common/Internationalization.cs | 10 +-- 4 files changed, 82 insertions(+), 15 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/DTO/InternationalizationViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/InternationalizationViewModel.cs index 16ed714b1..c6b7567b3 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/InternationalizationViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/InternationalizationViewModel.cs @@ -42,6 +42,8 @@ namespace IRaCIS.Core.Application.ViewModel public string Value { get; set; } = string.Empty; public string ValueCN { get; set; } = string.Empty; + public string FrontType { get; set; } = string.Empty; + public int InternationalizationType { get; set; } } @@ -55,19 +57,23 @@ namespace IRaCIS.Core.Application.ViewModel } - public class BatchAddInternationalizationDto + public class BatchInternationalizationDto { public string Description { get; set; } = string.Empty; public string Code { get; set; } = string.Empty; public string Value { get; set; } = string.Empty; + public string FrontType { get; set; } = string.Empty; public string ValueCN { get; set; } = string.Empty; } - public class InternationalizationSimpleDto + public class BatchAddInternationalizationDto : BatchInternationalizationDto { - public string Code { get; set; } = string.Empty; - public string Value { get; set; } = string.Empty; - public string ValueCN { get; set; } = string.Empty; + + } + + public class InternationalizationSimpleDto: BatchInternationalizationDto + { + } } diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index efdcd51e5..7a422f521 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -27,22 +27,56 @@ namespace IRaCIS.Core.Application.Service _internationalizationRepository = internationalizationRepository; } - + /// + /// 前端国际化内容接口 + /// + /// [AllowAnonymous] - - public async Task> GetFrontInternationalizationList() + [HttpGet] + public async Task> GetFrontInternationalizationList() { var list = await _internationalizationRepository.Where(t => t.InternationalizationType == 0).Select(t => new InternationalizationSimpleDto() { Code = t.Code, Value = t.Value, - ValueCN = t.ValueCN + ValueCN = t.ValueCN, + FrontType = t.FrontType, + Description = t.Description, }).ToListAsync(); return list; } + /// + /// 前端批量提交,后端判断不存在就添加,存在就更新 + /// + /// + public async Task BatchAddOrUpdateFrontInternationalization(List batchList) + { + foreach (var item in batchList) + { + var find = await _internationalizationRepository.FirstOrDefaultAsync(t => t.Code == item.Code && t.Description == item.Description && t.InternationalizationType == 0); + + if (find != null) + { + _mapper.Map(item, find); + } + else + { + var mapItem = _mapper.Map(item); + mapItem.InternationalizationType = 0; + mapItem.State = 1; + + await _internationalizationRepository.AddAsync(mapItem); + } + } + + await _internationalizationRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + [HttpPost] public async Task> GetInternationalizationList(InternationalizationQuery inQuery) { @@ -63,6 +97,11 @@ namespace IRaCIS.Core.Application.Service return pageList; } + /// + /// 后端之前批量添加接口 + /// + /// + /// [HttpPost] public async Task BatchAddInternationalization(BatchAddInternationalization batchAdd) { @@ -91,17 +130,34 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(); } + /// + /// 前后端添加的时候,区分了,前端判断重复多了多了一个路由 路由+标识唯一 + /// + /// + /// public async Task AddOrUpdateInternationalization(InternationalizationAddOrEdit addOrEditInternationalization) { + var internationalizationType = addOrEditInternationalization.InternationalizationType; + + //后端验证标识重复与否 var verifyExp1 = new EntityVerifyExp() { VerifyExp = t => t.Code == addOrEditInternationalization.Code && t.InternationalizationType == addOrEditInternationalization.InternationalizationType, VerifyMsg = $"该类型已有{addOrEditInternationalization.Code}名称的国际化标识", - IsVerify = true + IsVerify = internationalizationType == 1 }; - var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true, verifyExp1); + //前端验证标识重复与否 + var verifyExp2 = new EntityVerifyExp() + { + VerifyExp = t => t.Code == addOrEditInternationalization.Code && t.InternationalizationType == addOrEditInternationalization.InternationalizationType && t.Description == addOrEditInternationalization.Description, + + VerifyMsg = $"该类型已有{addOrEditInternationalization.Description}下的{addOrEditInternationalization.Code}名称的国际化标识", + IsVerify = internationalizationType == 0 + }; + + var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true, verifyExp1, verifyExp2); if (addOrEditInternationalization.InternationalizationType == 1) { diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs index f157924cb..c8c297ede 100644 --- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs @@ -74,6 +74,9 @@ namespace IRaCIS.Core.Application.Service CreateMap(); CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + + CreateMap(); diff --git a/IRaCIS.Core.Domain/Common/Internationalization.cs b/IRaCIS.Core.Domain/Common/Internationalization.cs index dc3292224..e4a7be5e9 100644 --- a/IRaCIS.Core.Domain/Common/Internationalization.cs +++ b/IRaCIS.Core.Domain/Common/Internationalization.cs @@ -33,16 +33,18 @@ namespace IRaCIS.Core.Domain.Models public int State { get; set; } - public string Description { get; set; } + public string Description { get; set; } = string.Empty; - public string Code { get; set; } + public string Code { get; set; } = string.Empty; - public string Value { get; set; } + public string Value { get; set; } = string.Empty; - public string ValueCN { get; set; } + public string ValueCN { get; set; } = string.Empty; public int InternationalizationType { get; set; } + public string FrontType { get; set; }=string.Empty; + } } From 7cc9731edf1786e0308a0e45147ec973ed5b02d8 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 10 Jan 2024 10:23:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E5=8F=96=E6=B6=88=E6=9D=83=E9=99=90=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/InternationalizationService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index 7a422f521..20345c647 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -52,6 +52,7 @@ namespace IRaCIS.Core.Application.Service /// 前端批量提交,后端判断不存在就添加,存在就更新 /// /// + [AllowAnonymous] public async Task BatchAddOrUpdateFrontInternationalization(List batchList) { foreach (var item in batchList) From 2491fd1fffd8922e1ff95fb2b44a84dbb8669014 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 10 Jan 2024 15:24:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E5=A2=9E=E5=8A=A0=E7=BC=93=E5=AD=98?= =?UTF-8?q?-=E9=9C=80=E8=A6=81=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/InternationalizationService.cs | 39 +++++++++++++------ IRaCIS.Core.Domain/_Config/_StaticData.cs | 5 ++- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index 20345c647..46ed1e447 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -10,6 +10,9 @@ using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using Microsoft.AspNetCore.Authorization; using IRaCIS.Core.Application.Helper; +using EasyCaching.Core; +using IRaCIS.Core.Domain.Share; +using OfficeOpenXml.FormulaParsing.Utilities; namespace IRaCIS.Core.Application.Service { @@ -19,12 +22,13 @@ namespace IRaCIS.Core.Application.Service [ApiExplorerSettings(GroupName = "Common")] public class InternationalizationService : BaseService, IInternationalizationService { - + private readonly IEasyCachingProvider _provider; private readonly IRepository _internationalizationRepository; - public InternationalizationService(IRepository internationalizationRepository) + public InternationalizationService(IRepository internationalizationRepository, IEasyCachingProvider provider) { _internationalizationRepository = internationalizationRepository; + _provider = provider; } /// @@ -35,17 +39,28 @@ namespace IRaCIS.Core.Application.Service [HttpGet] public async Task> GetFrontInternationalizationList() { + var cacheList= _provider.Get>(StaticData.InternationalData.Front).Value; - var list = await _internationalizationRepository.Where(t => t.InternationalizationType == 0).Select(t => new InternationalizationSimpleDto() + if(cacheList != null && cacheList.Count!=0) { - Code = t.Code, - Value = t.Value, - ValueCN = t.ValueCN, - FrontType = t.FrontType, - Description = t.Description, - }).ToListAsync(); + return cacheList; + } + else + { + var list = await _internationalizationRepository.Where(t => t.InternationalizationType == 0).Select(t => new InternationalizationSimpleDto() + { + Code = t.Code, + Value = t.Value, + ValueCN = t.ValueCN, + FrontType = t.FrontType, + Description = t.Description, + }).ToListAsync(); - return list; + _provider.Set>(StaticData.InternationalData.Front, list, TimeSpan.FromDays(1)); + + return list; + } + } /// @@ -72,9 +87,11 @@ namespace IRaCIS.Core.Application.Service await _internationalizationRepository.AddAsync(mapItem); } } - await _internationalizationRepository.SaveChangesAsync(); + //清理缓存 + _provider.Set>(StaticData.InternationalData.Front, new List(), TimeSpan.FromDays(1)); + return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Domain/_Config/_StaticData.cs b/IRaCIS.Core.Domain/_Config/_StaticData.cs index 83954751b..2791b6f50 100644 --- a/IRaCIS.Core.Domain/_Config/_StaticData.cs +++ b/IRaCIS.Core.Domain/_Config/_StaticData.cs @@ -183,7 +183,10 @@ public static class StaticData - + public static class InternationalData + { + public const string Front = "Front"; + } /// /// 匿名化配置 key From 49d4a71f364d5be93730e1d13da51145d6f5daf7 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 24 Jan 2024 14:20:20 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[=E4=BF=AE=E6=94=B9=E5=9B=9E=E9=80=80]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index a1a708029..1df7e3627 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1547,7 +1547,10 @@ namespace IRaCIS.Core.Application.Service.Allocation #region 方式二 - var origenalTask = influenceTaskList.Where(t => t.Id == task.Id).FirstOrDefault(); + //var origenalTask = influenceTaskList.Where(t => t.Id == task.Id).FirstOrDefault(); + + var origenalTask = await _visitTaskRepository.FindAsync(task.Id); + foreach (var influenceTask in influenceTaskList) { @@ -1610,7 +1613,9 @@ namespace IRaCIS.Core.Application.Service.Allocation await SetMedicalReviewInvalidAsync(currentVisitList); - var origenalTask = currentVisitList.Where(t => t.Id == task.Id).First(); + //var origenalTask = currentVisitList.Where(t => t.Id == task.Id).First(); + + var origenalTask = await _visitTaskRepository.FindAsync(task.Id); foreach (var influenceTask in currentVisitList) {