This commit is contained in:
he
2022-05-23 17:49:16 +08:00
parent 13ef3e69b9
commit ffa87ed1c3
6 changed files with 5 additions and 659 deletions
@@ -230,12 +230,6 @@ namespace IRaCIS.Core.Application.Service.Inspection
var signSuccess = await _repository.BatchUpdateAsync<TrialSign>(t => t.Id == signId, u => new TrialSign() { IsCompleted = true });
}
//// 判断是否需要前面
//if (AuditInfo.NeedSava)
//{
// await AddInspectionRecordAsync(AuditInfo, signId);
//}
return bResult;
}
@@ -295,95 +289,9 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
/// <summary>
/// 添加稽查记录
/// </summary>
/// <param name="addDto">添加对象</param>
/// <param name="signId">签名Id</param>
/// <returns></returns>
public async Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null)
{
if (addDto == new DataInspectionAddDTO())
{
return ResponseOutput.Ok();
}
//await SetEnum(addDto);
var add = _mapper.Map<DataInspection>(addDto);
await SetInspectionNameValue(add);
Guid? parentId = null;
parentId = (await _repository.GetQueryable<DataInspection>().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.ChildrenType == add.ChildrenType && x.ObjectType == add.ObjectType && x.VisitStageId == add.VisitStageId && x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
add.ParentId = parentId;
if (add.CreateTime == default(DateTime))
{
add.CreateTime = DateTime.Now;
}
add.CreateUserId = _userInfo.Id;
add.SignId = signId;
add.IP = _userInfo.IP;
add =await _dataInspectionRepository.SetDataInspectionDateType(add);
//await _repository.AddAsync(add);
//var success = await _repository.SaveChangesAsync();
return ResponseOutput.Ok();
}
/// <summary>
/// 批量添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
public async Task AddListInspectionRecordAsync(List<DataInspection> datas)
{
//var trialIds= datas.Select(x=>x.TrialId).Distinct().ToList();
//var subjectVisitIds= datas.Select(x=>x.SubjectVisitId).Distinct().ToList();
//var subjectIds = datas.Select(x => x.SubjectId).Distinct().ToList();
//var siteIds = datas.Select(x => x.SiteId).Distinct().ToList();
//var childrenTypes= datas.Select(x => x.ChildrenType).Distinct().ToList();
//var objectTypes = datas.Select(x => x.ObjectType).Distinct().ToList();
await _dataInspectionRepository.AddListInspectionRecordAsync(datas);
await _dataInspectionRepository.SaveChangesAsync();
//foreach (var add in datas)
//{
// await SetInspectionNameValue(add);
// add.ParentId = (await _repository.GetQueryable<DataInspection>().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId && x.ChildrenType == add.ChildrenType && x.ObjectType == add.ObjectType&&x.VisitStageId==add.VisitStageId&& x.GeneralId == add.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
// add.CreateUserId = _userInfo.Id;
// add.IP = _userInfo.IP;
// var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(add.JsonDetail);
// foreach (var item in JsonData.Keys)
// {
// if (JsonData[item].ToString().ToLower() == "true".ToLower())
// {
// JsonData[item] = "是";
// } else if (JsonData[item].ToString().ToLower() == "false".ToLower())
// {
// JsonData[item] = "否";
// }
// }
// add.JsonDetail= JsonConvert.SerializeObject(JsonData);
//}
//await _dataInspectionRepository.AddRangeAsync(datas);
}
/// <summary>
/// 往json里面添加属性
/// </summary>
@@ -410,113 +318,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
///// <summary>
///// 处理枚举
///// </summary>
///// <returns></returns>
//public async Task SetEnum(DataInspectionAddDTO Data)
//{
// //Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.TrialId.Value, Data.Identification, Data.JsonDetail);
// #region 枚举
// //try
// //{
// // var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(Data.JsonDetail);
// // foreach (var item in Data.EnumList)
// // {
// // if (!JsonData.ContainsKey(item.Key))
// // {
// // continue;
// // }
// // var value = JsonData[item.Key];
// // if (value.GetType() == typeof(JArray))
// // {
// // JArray arrays = (JArray)value;
// // if (item.Type.ToLower() == "id".ToLower())
// // {
// // List<Guid> guids = new List<Guid>();
// // arrays.ForEach(x =>
// // {
// // guids.Add(Guid.Parse(x.ToString()));
// // });
// // JsonData[item.Key] = string.Join(',', await _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync());
// // }
// // else if (item.Type.ToLower() == "ChildGroup".ToLower())
// // {
// // List<string> guids = new List<string>();
// // arrays.ForEach(x =>
// // {
// // guids.Add(x.ToString());
// // });
// // JsonData[item.Key] = string.Join(',', await
// // _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
// // _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.ChildGroup)), a => a.Id, b => b.ParentId, (a, b) => new
// // {
// // parent = b
// // }).SelectMany(a => a.parent, (m, n) => new
// // {
// // value = n.ValueCN
// // }).Select(x => x.value).ToListAsync()
// // );
// // }
// // else
// // {
// // List<string> guids =new List<string>();
// // arrays.ForEach(x =>
// // {
// // guids.Add(x.ToString());
// // });
// // JsonData[item.Key] = string.Join(',', await
// // _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
// // _repository.GetQueryable<Dictionary>().Where(x=>guids.Contains(x.Code)), a => a.Id, b => b.ParentId, (a, b) => new
// // {
// // parent = b
// // }).SelectMany(a => a.parent, (m, n) => new
// // {
// // value = n.ValueCN
// // }).Select(x => x.value).ToListAsync()
// // );
// // }
// // }
// // else
// // {
// // if (item.Type.ToLower() == "id".ToLower())
// // {
// // Guid guid = Guid.Parse(value.ToString());
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync();
// // }
// // else if (item.Type.ToLower() == "ChildGroup".ToLower())
// // {
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).Join(_repository.GetQueryable<Dictionary>().Where(x => x.ChildGroup == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
// // {
// // value = b.ValueCN
// // }).Select(x => x.value).FirstOrDefaultAsync();
// // }
// // else
// // {
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x=>x.Code==item.Code).Join(_repository.GetQueryable<Dictionary>().Where(x=>x.Code== value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
// // {
// // value=b.ValueCN
// // }).Select(x=>x.value).FirstOrDefaultAsync();
// // }
// // }
// // }
// // Data.JsonDetail = JsonConvert.SerializeObject(JsonData);
// //}
// //catch (Exception)
// //{
// // throw new BusinessValidationFailedException("Json 对象枚举异常");
// //}
// #endregion
//}
/// <summary>
@@ -526,96 +328,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
/// <returns></returns>
public async Task SetInspectionNameValue(DataInspection Data)
{
await _dataInspectionRepository.SetInspectionNameValue(Data);
//#region 项目名称
//var trialdata = await _repository.GetQueryable<Trial>().FirstOrDefaultAsync(x => x.Id == Data.TrialId);
//Data.ResearchProgramNo = trialdata?.ResearchProgramNo;
//if (Data.TrialName.IsNullOrEmpty())
//{
// Data.TrialName = trialdata?.ExperimentName;
//}
//#endregion
//#region 测试中心名称
//Data.SiteCode = (await _repository.GetQueryable<TrialSite>().FirstOrDefaultAsync(x => x.TrialId == Data.TrialId && x.SiteId == Data.SiteId))?.TrialSiteCode;
//var sitedata = await _repository.GetQueryable<Site>().FirstOrDefaultAsync(x => x.Id == Data.SiteId);
//if (Data.SiteName.IsNullOrEmpty())
//{
// Data.SiteName = sitedata?.SiteName;
//}
//#endregion
//#region 受试者
//if (Data.SubjectCode.IsNullOrEmpty())
//{
// Data.SubjectCode = (await _repository.GetQueryable<Subject>().FirstOrDefaultAsync(x => x.Id == Data.SubjectId))?.Code;
//}
//#endregion
//#region 访视
//if (Data.SubjectVisitName.IsNullOrEmpty())
//{
// Data.SubjectVisitName = (await _repository.GetQueryable<SubjectVisit>().FirstOrDefaultAsync(x => x.Id == Data.SubjectVisitId))?.VisitName;
//}
//#endregion
//#region 创建者
//if (Data.CreateUserName.IsNullOrEmpty() || Data.RoleName.IsNullOrEmpty())
//{
// var userdata = await _repository.GetQueryable<User>().Where(x => x.Id == Data.CreateUserId).GroupJoin(_repository.GetQueryable<UserType>(), a => a.UserTypeId, b => b.Id, (a, b) => new
// {
// UserName = a.FirstName + a.LastName,
// Role = b
// }).SelectMany(a => a.Role, (m, n) => new
// {
// UserName = m.UserName,
// RoleName = n.UserTypeShortName
// }).FirstOrDefaultAsync();
// if (userdata != null)
// {
// if (Data.CreateUserName.IsNullOrEmpty())
// {
// Data.CreateUserName = userdata?.UserName;
// }
// if (Data.RoleName.IsNullOrEmpty())
// {
// Data.RoleName = userdata?.RoleName;
// }
// }
//}
//#endregion
//#region 取操作类型
//try
//{
// var from = await _frontAuditConfigRepository.FirstOrDefaultAsync(x => x.Identification == Data.Identification);
// Data.ObjectType = from.ObjectTypeId;
// Data.OptType = from.OptTypeId;
// Data.ChildrenType = from.ChildrenTypeId;
// Data.ModuleType = from.ModuleTypeId;
//}
//catch (Exception)
//{
// throw new BusinessValidationFailedException("操作标识异常");
//}
//#endregion
}
@@ -23,16 +23,6 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface
Task RecordSing(SignDTO SignInfo);
Task<dynamic> Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null);
//Task SetEnum(DataInspectionAddDTO Data);
Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null);
/// <summary>
/// 批量添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
//Task AddListInspectionRecordAsync(List<DataInspection> datas);
}
}
@@ -356,13 +356,6 @@ namespace IRaCIS.Core.Application.Contracts
{
var file = this._httpContext.HttpContext?.Request.Form;
var result = await UploadNoneDicomFile(file, fileDto.subjectVisitId, fileDto.noneDicomStudyId);
if (result.IsSuccess)
{
var data = JsonConvert.DeserializeObject<DataInspectionAddDTO>(fileDto.AuditInfo);
data.GeneralId = fileDto.noneDicomStudyId;
await _inspectionService.AddInspectionRecordAsync(data);
}
return result;
}