增加查询接口

Uat_Study
hang 2022-08-22 11:50:52 +08:00
parent 371261cd0f
commit 071ad5acd5
5 changed files with 186 additions and 90 deletions

View File

@ -692,7 +692,7 @@
<param name="dto"></param> <param name="dto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetInspectionEnumValueDataList(IRaCIS.Core.Infra.EFCore.Common.Dto.SetInspectionEnumValueDto)"> <member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetInspectionEnumValueDataList(IRaCIS.Core.Infra.EFCore.Common.Dto.SetInspectionEnumValueDto,System.Guid)">
<summary> <summary>
翻译稽查数据 翻译稽查数据
</summary> </summary>

View File

@ -184,22 +184,47 @@ namespace IRaCIS.Core.Application.Service
[HttpPost] [HttpPost]
public async Task<List<string>> SetInspectionEnumValue(SetInspectionEnumValueDto dto) public async Task<List<string>> SetInspectionEnumValue(SetInspectionEnumValueDto dto)
{ {
return await SetInspectionEnumValueDataList(dto); return await SetInspectionEnumValueDataList(dto, dto.AuditDataIds.FirstOrDefault());
} }
public async Task<List<string>> GetInspectionJsonDataList(Guid trialId, Guid id)
{
//找到上一条Id
var currentInspection = await _dataInspectionRepository.Where(t => t.Id == id).Select(t => new { t.GeneralId, t.ObjectRelationParentId, t.CreateTime }).FirstOrDefaultAsync();
var beforeId = await _dataInspectionRepository.Where(x => x.GeneralId == currentInspection.GeneralId && x.ObjectRelationParentId == currentInspection.ObjectRelationParentId && x.CreateTime <= currentInspection.CreateTime).OrderByDescending(x => x.CreateTime).Select(t => t.Id)
.FirstOrDefaultAsync();
List<Guid> searchGuidList = new List<Guid>() { id };
if (beforeId != Guid.Empty)
{
searchGuidList.Add(beforeId);
}
return await SetInspectionEnumValueDataList(new SetInspectionEnumValueDto() { TrialId = trialId, AuditDataIds = searchGuidList }, id);
}
/// <summary> /// <summary>
/// 翻译稽查数据 /// 翻译稽查数据
/// </summary> /// </summary>
/// <param name="dto">传入Dto</param> /// <param name="dto">传入Dto</param>
/// <returns></returns> /// <returns></returns>
private async Task<List<string>> SetInspectionEnumValueDataList(SetInspectionEnumValueDto dto) private async Task<List<string>> SetInspectionEnumValueDataList(SetInspectionEnumValueDto dto, Guid currentInspectionId)
{
var auditDatas = await _dataInspectionRepository.AsQueryable().Where(x => dto.AuditDataIds.Contains(x.Id)).Select(x => new SetInspectionEnumDataDto()
{ {
var auditDatas =await _dataInspectionRepository.AsQueryable().Where(x => dto.AuditDataIds.Contains(x.Id)).Select(x=> new SetInspectionEnumDataDto() {
Id = x.Id, Id = x.Id,
JsonStr = x.JsonDetail, JsonStr = x.JsonDetail,
Identification=x.Identification Identification = x.Identification,
ObjectRelationParentId = x.ObjectRelationParentId,
CreateTime=x.CreateTime
}).ToListAsync(); }).ToListAsync();
@ -210,6 +235,36 @@ namespace IRaCIS.Core.Application.Service
{ {
Dictionary<string, object> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(item.JsonStr); Dictionary<string, object> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(item.JsonStr);
//查询关联父层级数据
if (item.Id == currentInspectionId)
{
//把父层级的数据的 CommonData 数据合并
var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.CreateTime);
var currentDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonDict[nameof(InspectionJsonDetail.CommonData)].ToJsonStr());
foreach (var commonDataObj in commonDataObjList)
{
var otherDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(commonDataObj.ToJsonStr());
foreach (var valuePair in otherDic)
{
if (currentDic.ContainsKey(valuePair.Key))
{
currentDic[valuePair.Key] = valuePair.Value;
}
else
{
currentDic.Add(valuePair.Key, valuePair.Value);
}
}
}
jsonDict[nameof(InspectionJsonDetail.CommonData)] = currentDic;
}
item.JsonStr = jsonDict[nameof(InspectionJsonDetail.Data)].ToString(); item.JsonStr = jsonDict[nameof(InspectionJsonDetail.Data)].ToString();
if (item.Identification == string.Empty || item.JsonStr == string.Empty) if (item.Identification == string.Empty || item.JsonStr == string.Empty)
@ -219,6 +274,10 @@ namespace IRaCIS.Core.Application.Service
item.JsonStr = await GetInspectionEnumValue(listIdentification, item.JsonStr); item.JsonStr = await GetInspectionEnumValue(listIdentification, item.JsonStr);
item.JsonStr = await SetEnum(dto.TrialId, listIdentification, item.JsonStr); item.JsonStr = await SetEnum(dto.TrialId, listIdentification, item.JsonStr);
item.JsonStr = await SetDataInspectionDateType(listIdentification, item.JsonStr); item.JsonStr = await SetDataInspectionDateType(listIdentification, item.JsonStr);
jsonDict[nameof(InspectionJsonDetail.Data)] = JsonConvert.DeserializeObject<object>(item.JsonStr); jsonDict[nameof(InspectionJsonDetail.Data)] = JsonConvert.DeserializeObject<object>(item.JsonStr);
item.JsonStr = JsonConvert.SerializeObject(jsonDict); item.JsonStr = JsonConvert.SerializeObject(jsonDict);
@ -229,6 +288,7 @@ namespace IRaCIS.Core.Application.Service
dto.AuditDataIds.ForEach(x => dto.AuditDataIds.ForEach(x =>
{ {
var auditData = auditDatas.FirstOrDefault(y => y.Id == x); var auditData = auditDatas.FirstOrDefault(y => y.Id == x);
resultJsonStrList.Add(auditData?.JsonStr); resultJsonStrList.Add(auditData?.JsonStr);
}); });
@ -241,6 +301,37 @@ namespace IRaCIS.Core.Application.Service
private async Task<List<object>> GetRelationParentData(Guid? objectRelationParentId, DateTime createTime)
{
var objectLsit = new List<object>();
if (objectRelationParentId != null)
{
var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && t.CreateTime <= createTime).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail }).FirstOrDefaultAsync();
if (relationParentInspection != null)
{
Dictionary<string, object> jsonDic = JsonConvert.DeserializeObject<Dictionary<string, object>>(relationParentInspection.JsonDetail);
var commonDataDicObj = jsonDic[nameof(InspectionJsonDetail.CommonData)];
objectLsit.Add(commonDataDicObj);
await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.CreateTime);
}
}
return objectLsit;
}
/// <summary> /// <summary>

View File

@ -166,6 +166,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
//.WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo)) //.WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo))
.WhereIf(dto.IsSign != null, x => x.IsSign == dto.IsSign); .WhereIf(dto.IsSign != null, x => x.IsSign == dto.IsSign);
#endregion #endregion
if (dto.VisitPlanInfo != null && dto.VisitPlanInfo.Value != (decimal)1.11) if (dto.VisitPlanInfo != null && dto.VisitPlanInfo.Value != (decimal)1.11)
{ {
query = query.Where(x => x.VisitNum == dto.VisitPlanInfo.Value); query = query.Where(x => x.VisitNum == dto.VisitPlanInfo.Value);

View File

@ -932,7 +932,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
//inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == inspection.TrialId && x.SubjectVisitId == inspection.SubjectVisitId && x.SubjectId == inspection.SubjectId && x.SiteId == inspection.SiteId && x.GeneralId == inspection.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; //inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == inspection.TrialId && x.SubjectVisitId == inspection.SubjectVisitId && x.SubjectId == inspection.SubjectId && x.SiteId == inspection.SiteId && x.GeneralId == inspection.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.GeneralId == inspection.GeneralId && x.ObjectRelationParentId==x.ObjectRelationParentId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.GeneralId == inspection.GeneralId && x.ObjectRelationParentId== inspection.ObjectRelationParentId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
} }
inspection.CreateUserId = _userInfo.Id; inspection.CreateUserId = _userInfo.Id;
inspection.IP = _userInfo.IP; inspection.IP = _userInfo.IP;

View File

@ -27,6 +27,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto
public string Identification { get; set; } public string Identification { get; set; }
public string JsonStr { get; set; } public string JsonStr { get; set; }
public Guid? ObjectRelationParentId { get; set; }
public DateTime CreateTime { get; set; }
} }