This commit is contained in:
he
2022-04-14 16:18:06 +08:00
parent f2132e1e8d
commit 33a26641d7
2 changed files with 25 additions and 15 deletions
@@ -20,10 +20,14 @@ namespace IRaCIS.Core.Application.Service.Inspection
public class InspectionService : BaseService, IInspectionService
{
private readonly IRepository<DataInspection> _dataInspectionRepository;
private readonly IRepository<FrontAuditConfig> _frontAuditConfigRepository;
public InspectionService(IRepository<DataInspection> dataInspectionRepository)
public InspectionService(IRepository<DataInspection> dataInspectionRepository,
IRepository<FrontAuditConfig> frontAuditConfigRepository
)
{
this._dataInspectionRepository = dataInspectionRepository;
this._frontAuditConfigRepository = frontAuditConfigRepository;
}
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto)
{
@@ -282,6 +286,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
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;
@@ -289,18 +294,9 @@ namespace IRaCIS.Core.Application.Service.Inspection
add.CreateUserId = _userInfo.Id;
add.SignId = signId;
add.IP = _userInfo.IP;
await SetInspectionNameValue(add);
await _repository.AddAsync(add);
//if (addDto.OptType.ToLower() == "Add".ToLower()&& Statusdata!=null)
//{
// DataInspection ststus=JsonConvert.DeserializeObject<DataInspection>(JsonConvert.SerializeObject(add))??new DataInspection();
// ststus.CreateTime = add.CreateTime.AddSeconds(1);
// ststus.JsonDetail = JsonConvert.SerializeObject(Statusdata);
// ststus.ChildrenType = "Status";
// ststus.OptType = "Init";
// ststus.Id = Guid.NewGuid();
// await _repository.AddAsync(ststus);
//}
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Ok(success);
@@ -324,10 +320,11 @@ namespace IRaCIS.Core.Application.Service.Inspection
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;
await SetInspectionNameValue(add);
}
await _dataInspectionRepository.AddRangeAsync(datas);
@@ -486,7 +483,6 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
#endregion
#region
@@ -546,7 +542,14 @@ namespace IRaCIS.Core.Application.Service.Inspection
}
#endregion
#region
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;
#endregion
}