添加批量插入稽查方法

Uat_Study
he 2022-04-07 12:01:57 +08:00
parent 2fc57f7041
commit 7a1cc3e29f
3 changed files with 39 additions and 4 deletions

View File

@ -36,7 +36,7 @@ namespace IRaCIS.Core.Application.Service
{
var list =await (from data in _repository.GetQueryable<FrontAuditConfig>().Where(x => x.Identification == item.Identification)
join childrenType in _repository.GetQueryable<FrontAuditConfig>() on data.Id equals childrenType.ParentId
select childrenType).ToListAsync();
select childrenType).OrderBy(x=>x.Sort).ToListAsync();
return list;
}

View File

@ -18,9 +18,11 @@ namespace IRaCIS.Core.Application.Service.Inspection
[NonDynamicWebApi]
public class InspectionService : BaseService, IInspectionService
{
public InspectionService()
{
private readonly IRepository<DataInspection> _dataInspectionRepository;
public InspectionService(IRepository<DataInspection> dataInspectionRepository)
{
this._dataInspectionRepository = dataInspectionRepository;
}
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto)
{
@ -278,6 +280,32 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
/// <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();
foreach (var add in datas)
{
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).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id;
add.CreateUserId = _userInfo.Id;
add.IP = _userInfo.IP;
}
await _dataInspectionRepository.AddRangeAsync(datas);
}
/// <summary>
/// 处理枚举
/// </summary>

View File

@ -25,5 +25,12 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface
Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null, object? Statusdata = null);
/// <summary>
/// 批量添加稽查记录
/// </summary>
/// <param name="datas"></param>
/// <returns></returns>
Task AddListInspectionRecordAsync(List<DataInspection> datas);
}
}