diff --git a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs index 2f9feb922..752d76ce7 100644 --- a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs @@ -238,7 +238,7 @@ namespace IRaCIS.Core.Application.Service - //var listIdentification = auditDatas.Select(x => x.Identification).Distinct().ToList(); + var listIdentification = auditDatas.Select(x => x.Identification).Distinct().ToList(); foreach (var item in auditDatas) { Dictionary jsonDict = (JsonConvert.DeserializeObject>(item.JsonStr)).IfNullThrowException(); @@ -319,9 +319,9 @@ namespace IRaCIS.Core.Application.Service { continue; } - str = await GetInspectionEnumValue(new List() { item.Identification }, str); - str = await SetEnum(dto.TrialId, new List() { item.Identification }, str); - str = await SetDataInspectionDateType(new List() { item.Identification }, str); + str = await GetInspectionEnumValue(listIdentification, item.Identification, str); + str = await SetEnum(dto.TrialId, listIdentification, item.Identification, str); + str = await SetDataInspectionDateType(listIdentification, item.Identification, str); jsonDict[nameof(InspectionJsonDetail.Data)] = JsonConvert.DeserializeObject(str); @@ -331,9 +331,9 @@ namespace IRaCIS.Core.Application.Service { continue; } - str2 = await GetInspectionEnumValue(new List() { item.Identification }, str2); - str2 = await SetEnum(dto.TrialId, new List() { item.Identification }, str2); - str2 = await SetDataInspectionDateType(new List() { item.Identification }, str2); + str2 = await GetInspectionEnumValue(listIdentification, item.Identification, str2); + str2 = await SetEnum(dto.TrialId, listIdentification, item.Identification, str2); + str2 = await SetDataInspectionDateType(listIdentification, item.Identification, str2); jsonDict[nameof(InspectionJsonDetail.CommonData)] = JsonConvert.DeserializeObject(str2); #endregion @@ -456,20 +456,23 @@ namespace IRaCIS.Core.Application.Service /// /// /// - private async Task SetDataInspectionDateType(List identificationList, string jsonStr) + private async Task SetDataInspectionDateType(List identificationList,string identification, string jsonStr) { var list = await (from parent in _frontAuditConfigRepository.AsQueryable().Where(x => identificationList.Contains(x.Identification)) join child in _frontAuditConfigRepository.AsQueryable().Where(x => x.EnumType == "Date" && x.IsEnable) on parent.Id equals child.ParentId select new DateDto() { - Code = child.Code, + Identification= parent.Identification, + + Code = child.Code, DateType = child.DateType, }).ToListAsync(); list = list.GroupBy(x => new { x.Code }, (key, lst) => new DateDto() { + Code = key.Code, - DateType = lst.Max(x => x.DateType), + DateType = lst.FirstOrDefault(y => y.Identification == identification)?.DateType ?? lst.Max(x => x.DateType), }).ToList(); var jsonDataDic = JsonConvert.DeserializeObject>(jsonStr); @@ -519,23 +522,25 @@ namespace IRaCIS.Core.Application.Service ///// 外键value ///// 要查询的外键值 ///// 传入的纸 - private async Task GetInspectionEnumValue(List identificationList, string jsonStr) + private async Task GetInspectionEnumValue(List identificationList,string identification, string jsonStr) { var list = await (from u in _frontAuditConfigRepository.Where(x => identificationList.Contains(x.Identification)) join p in _frontAuditConfigRepository.Where(x => x.EnumType == "Foreign" && x.IsEnable) on u.Id equals p.ParentId select new { Key = p.Code, - ForeignKeyValue = p.ForeignKeyValue, + Identification=u.Identification, + ForeignKeyValue = p.ForeignKeyValue, ForeignKeyText = p.ForeignKeyText, ForeignKeyTable = p.ForeignKeyTableName }).ToListAsync(); list = list.GroupBy(x => new { x.Key }, (key, lst) => new { Key = key.Key, - ForeignKeyValue = lst.Max(x => x.ForeignKeyValue), - ForeignKeyText = lst.Max(x => x.ForeignKeyText), - ForeignKeyTable = lst.Max(x => x.ForeignKeyTable), + Identification=string.Empty, + ForeignKeyValue= lst.FirstOrDefault(y => y.Identification == identification)?.ForeignKeyValue ?? lst.Max(x => x.ForeignKeyValue), + ForeignKeyText = lst.FirstOrDefault(y => y.Identification == identification)?.ForeignKeyText ?? lst.Max(x => x.ForeignKeyText), + ForeignKeyTable = lst.FirstOrDefault(y => y.Identification == identification)?.ForeignKeyTable ?? lst.Max(x => x.ForeignKeyTable), }).ToList(); @@ -585,7 +590,7 @@ namespace IRaCIS.Core.Application.Service /// 标识 /// Json对象 /// - private async Task SetEnum(Guid trialId, List identificationList, string jsonStr) + private async Task SetEnum(Guid trialId, List identificationList, string identification, string jsonStr) { if (jsonStr == null || jsonStr == "null") { @@ -598,27 +603,41 @@ namespace IRaCIS.Core.Application.Service join p in _frontAuditConfigRepository.Where(x => (x.DictionaryCode != string.Empty && x.EnumType == "Dictionary") || (x.DataType == "Table") && x.IsEnable) on u.Id equals p.ParentId select new { - //前端展示类型 - DataType = p.DataType, - TableConfigJsonStr = p.TableConfigJsonStr, - Key = p.Code, + Key = p.Code, + Identification = u.Identification, + //前端展示类型 + DataType = p.DataType, + + TableConfigJsonStr = p.TableConfigJsonStr, + Code = p.DictionaryCode, Type = p.DictionaryType }).ToListAsync(); //两条不同的标识 但是里面配置有相同的翻译字典 - list = list.Distinct().ToList(); + list = list.GroupBy(x => new { x.Key }, (key, lst) => new + { + Key = key.Key, + Identification = string.Empty, + DataType = lst.FirstOrDefault(y => y.Identification == identification)?.DataType ?? lst.Max(x => x.DataType), + TableConfigJsonStr = lst.FirstOrDefault(y => y.Identification == identification)?.TableConfigJsonStr ?? lst.Max(x => x.TableConfigJsonStr), + Code = lst.FirstOrDefault(y => y.Identification == identification)?.Code ?? lst.Max(x => x.Code), + Type = lst.FirstOrDefault(y => y.Identification == identification)?.Type ?? lst.Max(x => x.Type), + - // 添加单双审 - var trialtype = await _trialRepository.AsQueryable().Where(x => x.Id == trialId).Select(x => x.QCProcessEnum).FirstOrDefaultAsync(); + }).ToList(); + + // 添加单双审 + var trialtype = await _trialRepository.AsQueryable().Where(x => x.Id == trialId).Select(x => x.QCProcessEnum).FirstOrDefaultAsync(); if (!list.Any(x => x.Key == "AuditState")) { list.Add(new - { - DataType = string.Empty, - TableConfigJsonStr = string.Empty, - Key = "AuditState", + { + Key = "AuditState", + Identification = string.Empty, + DataType = string.Empty, + TableConfigJsonStr = string.Empty, Code = trialtype == TrialQCProcess.SingleAudit ? "AuditStatePE" : "AuditStateRC", Type = "Code", }); diff --git a/IRaCIS.Core.Infra.EFCore/Common/Dto/DateDto.cs b/IRaCIS.Core.Infra.EFCore/Common/Dto/DateDto.cs index 9bd9e5ac3..6256cd01b 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/Dto/DateDto.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/Dto/DateDto.cs @@ -10,7 +10,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto { public string Code { get; set; } - public string DateType { get; set; } + public string Identification { get; set; } + public string DateType { get; set; } } public class TypeNameDto