diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 91b0e60b..fcbd98e3 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -86,7 +86,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common { await InsertInspection(item, type, x => new DataInspection() { - SubjectId = x.Id + SubjectId = x.Id, + SubjectCode=x.Code, }); } @@ -95,7 +96,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common { await InsertInspection(item, type, x => new DataInspection() { - SubjectVisitId = x.Id + SubjectVisitId = x.Id, + SubjectVisitName=x.VisitName, }); } #endregion @@ -234,7 +236,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common Inspection = generalData }; add.JsonDetail = inspectionData.ToJcJson(); - await SetDataInspectionDateType(add); + await _dbContext.DataInspection.AddAsync(add); } @@ -323,53 +325,5 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion } - - - /// - /// 格式化日期和时间 - /// - /// 稽查数据 - /// - public async Task SetDataInspectionDateType(DataInspection Data) - { - var list = await (from parent in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.Identification == Data.Identification) - join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType == "Date") on parent.Id equals child.ParentId - select new DateDto() - { - Code = child.Code, - DateType = child.DateType, - }).ToListAsync(); - - var JsonData = JsonConvert.DeserializeObject>(Data.JsonDetail); - - foreach (var item in JsonData.Keys) - { - var datefirst = list.FirstOrDefault(x => x.Code.ToLower() == item.ToLower()); - if (datefirst != null && !IsNullOrEmpty(JsonData[item])) - { - try - { - if (datefirst.DateType == "Date") - { - JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd"); - } - - if (datefirst.DateType == "DateTime") - { - JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); - } - } - catch (Exception) - { - continue; - } - } - - } - Data.JsonDetail = JsonConvert.SerializeObject(JsonData); - - return Data; - } - } } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 2c99cadc..3c8858fc 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -574,12 +574,63 @@ namespace IRaCIS.Core.Infra.EFCore { item.Json = await GetInspectionEnumValue(item.Identification, item.Json); item.Json = await SetEnum(dto.TrialId, item.Identification, item.Json); + item.Json = await SetDataInspectionDateType(item.Identification, item.Json); } return dto.Items.Select(x => x.Json).ToList(); } + + + + /// + /// 格式化日期和时间 + /// + /// 稽查数据 + /// + public async Task SetDataInspectionDateType(string identification, string json) + { + var list = await (from parent in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.Identification == identification) + join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType == "Date") on parent.Id equals child.ParentId + select new DateDto() + { + Code = child.Code, + DateType = child.DateType, + }).ToListAsync(); + + var JsonData = JsonConvert.DeserializeObject>(json); + + foreach (var item in JsonData.Keys) + { + var datefirst = list.FirstOrDefault(x => x.Code.ToLower() == item.ToLower()); + if (datefirst != null && !IsNullOrEmpty(JsonData[item])) + { + try + { + if (datefirst.DateType == "Date") + { + JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd"); + } + + if (datefirst.DateType == "DateTime") + { + JsonData[item] = DateTime.Parse(JsonData[item].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); + } + } + catch (Exception) + { + continue; + } + } + + } + + return JsonConvert.SerializeObject(JsonData); + + + } + /// /// 获取外键表数据 ///