From 9180fd38dfb27b8f93f845e31bba4f299b3cb8cc Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Wed, 27 Apr 2022 13:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/FrontAuditConfigService.cs | 4 +- .../Service/Inspection/DTO/InspectionModel.cs | 8 ++- .../Service/QC/QCOperationService.cs | 3 + .../Service/Visit/VisitPlanService.cs | 60 +++++++++---------- .../Triggers/SubjectVisitTrigger.cs | 1 + .../Dto/SetDictionaryValueDto.cs | 6 +- .../Repository/IRepository.cs | 4 +- .../Repository/Repository.cs | 22 ++++--- 8 files changed, 59 insertions(+), 49 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index a08468436..cab018157 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -33,9 +33,9 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task> SetDictionaryValue(SetDictionaryValueDto dto) + public async Task> SetInspectionEnumValue(SetInspectionEnumValueDto dto) { - return await _frontAuditConfigRepository.SetDictionaryValue(dto); + return await _frontAuditConfigRepository.SetInspectionEnumValue(dto); } /// diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs index 86d754822..c68303aa5 100644 --- a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs +++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs @@ -253,6 +253,10 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO public bool obtaionOrCancel { get; set; } } + /// + /// 稽查泛型Dto + /// + /// 泛型 public class DataInspectionDto : IInspectionDTO, ISignDTO { @@ -267,9 +271,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO { if (auditInfo.JsonDetail.IsNullOrEmpty()) { - IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); - timeFormat.DateTimeFormat = "yyyy-MM-dd"; - auditInfo.JsonDetail = JsonConvert.SerializeObject(OptCommand, Newtonsoft.Json.Formatting.Indented, timeFormat); + auditInfo.JsonDetail = JsonConvert.SerializeObject(OptCommand); } return auditInfo; diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 7d9f4bfa2..d7e752a9a 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -922,6 +922,7 @@ namespace IRaCIS.Core.Application.Image.QA } + // 移动不进去 await _trialRepository.AddListInspectionRecordAsync(datas); await _repository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -2051,6 +2052,8 @@ namespace IRaCIS.Core.Application.Image.QA data.JsonDetail = JsonConvert.SerializeObject(keyValuePairs); datas.Add(data); } + + // 这里使用的是批量更新 await _subjectVisitRepository.AddListInspectionRecordAsync(datas); await _subjectVisitRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index e88441e3d..da3a8ee5a 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -296,38 +296,38 @@ namespace IRaCIS.Application.Services - foreach (var changedItem in changedList) - { + //foreach (var changedItem in changedList) + //{ - var list = await _subjectVisitRepository.Where(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id).ToListAsync(); - list.ForEach(x => - { - datas.Add(new DataInspection() - { - BlindName = x.BlindName, - IsSign = false, - SiteId = x.SiteId, - SubjectId = x.SubjectId, - SubjectVisitId = x.Id, - CreateTime = createtime, - SubjectVisitName = x.VisitName, - TrialId = x.TrialId, - Reason = "确认访视修改状态", - JsonDetail = JsonConvert.SerializeObject(new - { - IsBaseLine = changedItem.IsBaseLine, - VisitName = changedItem.VisitName, - VisitNum = changedItem.VisitNum, - VisitDay = changedItem.VisitDay, - SubmitState = x.SubmitState, - VisitWindowLeft = changedItem.VisitWindowLeft, - VisitWindowRight = changedItem.VisitWindowRight - }), - Identification = "Edit|Visit|Info|Visit-Image Upload" - }); - }); + // var list = await _subjectVisitRepository.Where(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id).ToListAsync(); + // list.ForEach(x => + // { + // datas.Add(new DataInspection() + // { + // BlindName = x.BlindName, + // IsSign = false, + // SiteId = x.SiteId, + // SubjectId = x.SubjectId, + // SubjectVisitId = x.Id, + // CreateTime = createtime, + // SubjectVisitName = x.VisitName, + // TrialId = x.TrialId, + // Reason = "确认访视修改状态", + // JsonDetail = JsonConvert.SerializeObject(new + // { + // IsBaseLine = changedItem.IsBaseLine, + // VisitName = changedItem.VisitName, + // VisitNum = changedItem.VisitNum, + // VisitDay = changedItem.VisitDay, + // SubmitState = x.SubmitState, + // VisitWindowLeft = changedItem.VisitWindowLeft, + // VisitWindowRight = changedItem.VisitWindowRight + // }), + // Identification = "Edit|Visit|Info|Visit-Image Upload" + // }); + // }); - } + //} var subjectsids = _repository.GetQueryable().Where(x => x.TrialId == trialId).Select(x => new { diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs index f21400bcd..63b77b62f 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs @@ -86,6 +86,7 @@ namespace IRaCIS.Core.Application.Triggers JsonDetail = subjectvisit.ToJcJson(), }); + // 这里是触发器的位置 await _subjectVisitRepository.AddListInspectionRecordAsync(datas); await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, diff --git a/IRaCIS.Core.Infra.EFCore/Dto/SetDictionaryValueDto.cs b/IRaCIS.Core.Infra.EFCore/Dto/SetDictionaryValueDto.cs index 20eb85402..88cce23c7 100644 --- a/IRaCIS.Core.Infra.EFCore/Dto/SetDictionaryValueDto.cs +++ b/IRaCIS.Core.Infra.EFCore/Dto/SetDictionaryValueDto.cs @@ -6,15 +6,15 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Infra.EFCore.Dto { - public class SetDictionaryValueDto + public class SetInspectionEnumValueDto { public Guid TrialId { get; set; } - public List Items { get; set; } + public List Items { get; set; } } - public class SetDictionaryDto + public class SetInspectionEnum { public string Identification { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs index 63d4bb1dc..e16681209 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs @@ -59,7 +59,7 @@ namespace IRaCIS.Core.Infra.EFCore /// 要查询的外键值 /// 传入的纸 /// - Task GetDictionaryValue(string Identification, string json); + Task GetInspectionEnumValue(string Identification, string json); /// @@ -67,7 +67,7 @@ namespace IRaCIS.Core.Infra.EFCore /// /// 传入Dto /// - Task> SetDictionaryValue(SetDictionaryValueDto dto); + Task> SetInspectionEnumValue(SetInspectionEnumValueDto dto); } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 976750940..955c6ecbb 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -569,12 +569,11 @@ namespace IRaCIS.Core.Infra.EFCore /// /// 传入Dto /// - public async Task> SetDictionaryValue(SetDictionaryValueDto dto) + public async Task> SetInspectionEnumValue(SetInspectionEnumValueDto dto) { - foreach (var item in dto.Items) { - item.Json = await GetDictionaryValue(item.Identification,item.Json); + item.Json = await GetInspectionEnumValue(item.Identification,item.Json); item.Json = await SetEnum(dto.TrialId, item.Identification, item.Json); } @@ -590,9 +589,9 @@ namespace IRaCIS.Core.Infra.EFCore /// 要查询的外键值 /// 传入的纸 /// - public async Task GetDictionaryValue(string Identification, string json) + public async Task GetInspectionEnumValue(string identification, string json) { - var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == Identification) + var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == identification) join p in _dbContext.FrontAuditConfig.Where(x => x.EnumType == "Foreign") on u.Id equals p.ParentId select new { @@ -645,9 +644,9 @@ namespace IRaCIS.Core.Infra.EFCore /// Json对象 /// /// - public async Task SetEnum(Guid trilaid, string Identification, string json) + public async Task SetEnum(Guid trilaid, string identification, string json) { - var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == Identification) + var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == identification) join p in _dbContext.FrontAuditConfig.Where(x => x.Code != "AuditState" && (x.DictionaryCode != null && x.DictionaryCode != string.Empty && x.DictionaryType != null && x.DictionaryType != string.Empty)) on u.Id equals p.ParentId select new { @@ -767,6 +766,12 @@ namespace IRaCIS.Core.Infra.EFCore } + /// + /// 添加稽查记录 + /// + /// 实体 + /// + /// private async Task AddInspectionAsync(TEntity entity, bool isSaveAudit = false) { List datas = new List(); @@ -800,7 +805,6 @@ namespace IRaCIS.Core.Infra.EFCore SiteId = data.SiteId, SubjectId = data.Id, SubjectCode = data.Code, - IsSign = false, CreateTime = createtime, Identification = "Init|Subject|Status|Subject", // 初始化受试者信息 @@ -935,7 +939,7 @@ namespace IRaCIS.Core.Infra.EFCore /// /// 格式化日期和时间 /// - /// + /// 稽查数据 /// public async Task SetDataInspectionDateType(DataInspection Data) {