diff --git a/IRaCIS.Core.API/Controllers/InspectionController.cs b/IRaCIS.Core.API/Controllers/InspectionController.cs index 11757f537..4d0dba947 100644 --- a/IRaCIS.Core.API/Controllers/InspectionController.cs +++ b/IRaCIS.Core.API/Controllers/InspectionController.cs @@ -87,15 +87,15 @@ namespace IRaCIS.Core.API.Controllers return ResponseOutput.NotOk(fun.ErrorMessage); } opt.AuditInfo.SubjectId = Guid.Parse(fun.Data); - var statusdata = new - { - Status = 1, - //OutEnrollmentTime = DateTime.Now.ToString("yyyy-MM-dd"), - //VisitOverTime = DateTime.Now.ToString("yyyy-MM-dd"), - Reason = string.Empty, - }; + //var statusdata = new + //{ + // Status = 1, + // //OutEnrollmentTime = DateTime.Now.ToString("yyyy-MM-dd"), + // //VisitOverTime = DateTime.Now.ToString("yyyy-MM-dd"), + // Reason = string.Empty, + //}; - return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, null, fun, statusdata); + return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, null, fun); } #endregion @@ -160,15 +160,15 @@ namespace IRaCIS.Core.API.Controllers opt.AuditInfo.SubjectCode = opt.OptCommand.Code; var fun = await _subjectService.AddOrUpdateSubject(opt.OptCommand); opt.AuditInfo.SubjectId = Guid.Parse(fun.Data); - var statusdata = new - { - Status = "OnVisit", - //OutEnrollmentTime = DateTime.Now.ToString("yyyy-MM-dd"), - //VisitOverTime = DateTime.Now.ToString("yyyy-MM-dd"), - Reason = string.Empty, - }; + //var statusdata = new + //{ + // Status = "OnVisit", + // //OutEnrollmentTime = DateTime.Now.ToString("yyyy-MM-dd"), + // //VisitOverTime = DateTime.Now.ToString("yyyy-MM-dd"), + // Reason = string.Empty, + //}; - return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, null, fun, statusdata); + return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, null, fun); } /// diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 69c2c262f..e2d1c83dc 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -234,7 +234,7 @@ 对象名称 - + 通用逻辑封装 @@ -243,7 +243,6 @@ 用户签名 委托 方法返回的结果 - 添加状态的对象 @@ -259,7 +258,7 @@ 添加签名记录 /// - + 添加稽查记录 @@ -268,6 +267,13 @@ 初始化状态对象 + + + 批量添加稽查记录 + + + + 处理枚举 @@ -281,6 +287,13 @@ + + + 批量添加稽查记录 + + + + 项目外部人员 录入流程相关 diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index c3a4565ab..8f26c8afe 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -177,13 +177,13 @@ namespace IRaCIS.Core.Application.Service // CreateMap< FrontAuditConfig,FrontAuditConfigAddOrEdit>().ReverseMap(); - if (await _frontAuditConfigRepository.AnyAsync(x => x.Identification == addOrEditFrontAuditConfig.Identification && x.Id != addOrEditFrontAuditConfig.Id&&x.ConfigType=="M")) + if (await _frontAuditConfigRepository.AnyAsync(x => x.Identification == addOrEditFrontAuditConfig.Identification && x.Id != addOrEditFrontAuditConfig.Id&&x.ConfigType=="M"&& addOrEditFrontAuditConfig.ConfigType== "M")) { return ResponseOutput.NotOk("标识重复"); } - if (await _frontAuditConfigRepository.AnyAsync(x => x.Description == addOrEditFrontAuditConfig.Description && x.Id != addOrEditFrontAuditConfig.Id && x.ConfigType == "M")) + if (await _frontAuditConfigRepository.AnyAsync(x => x.Description == addOrEditFrontAuditConfig.Description && x.Id != addOrEditFrontAuditConfig.Id && x.ConfigType == "M" && addOrEditFrontAuditConfig.ConfigType == "M")) { return ResponseOutput.NotOk("名称重复"); } diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 28ec2bed0..7001c87f4 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -44,21 +44,23 @@ namespace IRaCIS.Core.Application.Service.Inspection from leftuser in usertemp.DefaultIfEmpty() - join moduleTyped in _repository.GetQueryable().Where(x => x.Code == "ModuleType") on 1 equals 1 - join moduleTypec in _repository.GetQueryable() on new { ParentId = moduleTyped.Id, ModuleType = data.ModuleType } equals new { ParentId = moduleTypec.ParentId.Value, ModuleType = moduleTypec.Value } into moduleTypectemp - from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty() - //join childrenTyped in _repository.GetQueryable().Where(x => x.Code == "ChildrenType") on 1 equals 1 - //join childrenTypec in _repository.GetQueryable() on new { ParentId = childrenTyped.Id, ModuleType = data.ChildrenType } equals new { ParentId = childrenTypec.ParentId.Value, ModuleType = childrenTypec.Value } into childrenTypectemp - //from leftchildrenTypec in childrenTypectemp.DefaultIfEmpty() - //join ObjectTyped in _repository.GetQueryable().Where(x => x.Code == "ObjectType") on 1 equals 1 - //join ObjectTypec in _repository.GetQueryable() on new { ParentId = ObjectTyped.Id, ModuleType = data.ObjectType } equals new { ParentId = ObjectTypec.ParentId.Value, ModuleType = ObjectTypec.Value } into objectTypetemp - //from leftObjectType in objectTypetemp.DefaultIfEmpty() - //join OptTyped in _repository.GetQueryable().Where(x => x.Code == "OptType") on 1 equals 1 - //join OptTypec in _repository.GetQueryable() on new { ParentId = OptTyped.Id, ModuleType = data.OptType } equals new { ParentId = OptTypec.ParentId.Value, ModuleType = OptTypec.Value } into optTypetemp - //from leftOptType in optTypetemp.DefaultIfEmpty() + //join moduleTyped in _repository.GetQueryable().Where(x => x.Code == "ModuleType") on 1 equals 1 + //join moduleTypec in _repository.GetQueryable() on new { ParentId = moduleTyped.Id, ModuleType = data.ModuleType } equals new { ParentId = moduleTypec.ParentId.Value, ModuleType = moduleTypec.Value } into moduleTypectemp + + //join childrenTyped in _repository.GetQueryable().Where(x => x.Code == "ChildrenType") on 1 equals 1 + //join childrenTypec in _repository.GetQueryable() on new { ParentId = childrenTyped.Id, ModuleType = data.ChildrenType } equals new { ParentId = childrenTypec.ParentId.Value, ModuleType = childrenTypec.Value } into childrenTypectemp + //from leftchildrenTypec in childrenTypectemp.DefaultIfEmpty() + + //join ObjectTyped in _repository.GetQueryable().Where(x => x.Code == "ObjectType") on 1 equals 1 + //join ObjectTypec in _repository.GetQueryable() on new { ParentId = ObjectTyped.Id, ModuleType = data.ObjectType } equals new { ParentId = ObjectTypec.ParentId.Value, ModuleType = ObjectTypec.Value } into objectTypetemp + //from leftObjectType in objectTypetemp.DefaultIfEmpty() + + //join OptTyped in _repository.GetQueryable().Where(x => x.Code == "OptType") on 1 equals 1 + //join OptTypec in _repository.GetQueryable() on new { ParentId = OptTyped.Id, ModuleType = data.OptType } equals new { ParentId = OptTypec.ParentId.Value, ModuleType = OptTypec.Value } into optTypetemp + //from leftOptType in optTypetemp.DefaultIfEmpty() join trialSign in _repository.GetQueryable() on data.SignId equals trialSign.Id into trialSigntemp @@ -74,6 +76,11 @@ namespace IRaCIS.Core.Application.Service.Inspection } into frontAuditConfigtemp from leftfrontAuditConfig in frontAuditConfigtemp.DefaultIfEmpty() + + + join moduleTypec in _repository.GetQueryable() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId } equals new { ModuleType = moduleTypec.Id.ToString() } into moduleTypectemp + from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty() + select new GetDataInspectionOutDto() { CreateTime = data.CreateTime, @@ -145,9 +152,8 @@ namespace IRaCIS.Core.Application.Service.Inspection /// 用户签名 /// 委托 /// 方法返回的结果 - /// 添加状态的对象 /// - public async Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response=null, object? Statusdata=null) + public async Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response=null) { Guid? signId = null; MapData(OptCommand, AuditInfo); @@ -184,7 +190,7 @@ namespace IRaCIS.Core.Application.Service.Inspection // 判断是否需要前面 - await AddInspectionRecordAsync(AuditInfo, signId, Statusdata); + await AddInspectionRecordAsync(AuditInfo, signId); if (bResult.IsSuccess == false) { @@ -251,7 +257,7 @@ namespace IRaCIS.Core.Application.Service.Inspection /// 签名Id /// 初始化状态对象 /// - public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId=null, object? Statusdata = null) + public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId=null) { await SetEnum(addDto); var add = _mapper.Map(addDto); @@ -264,16 +270,16 @@ namespace IRaCIS.Core.Application.Service.Inspection add.IP = _userInfo.IP; await SetInspectionNameValue(add); await _repository.AddAsync(add); - if (addDto.OptType.ToLower() == "Add".ToLower()&& Statusdata!=null) - { - DataInspection ststus=JsonConvert.DeserializeObject(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); - } + //if (addDto.OptType.ToLower() == "Add".ToLower()&& Statusdata!=null) + //{ + // DataInspection ststus=JsonConvert.DeserializeObject(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); @@ -300,6 +306,7 @@ namespace IRaCIS.Core.Application.Service.Inspection add.ParentId = (await _repository.GetQueryable().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 SetInspectionNameValue(add); } await _dataInspectionRepository.AddRangeAsync(datas); diff --git a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs index 8e7d304c3..a8ab1d8e7 100644 --- a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs @@ -19,12 +19,12 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface Task AddSignRecordAsync(SignDTO signDTO); - Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null, object? Statusdata = null); + Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null); Task SetEnum(DataInspectionAddDTO Data); - Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null, object? Statusdata = null); + Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null); /// /// 批量添加稽查记录 diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs index 1c0a790bf..eccbcb5ec 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs @@ -4,6 +4,8 @@ using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Application.Filter; using IRaCIS.Core.Domain.Share; using Microsoft.AspNetCore.Mvc; +using IRaCIS.Core.Application.Service.Inspection.Interface; +using Newtonsoft.Json; namespace IRaCIS.Application.Services { @@ -11,10 +13,12 @@ namespace IRaCIS.Application.Services public class SubjectService : BaseService, ISubjectService { private readonly IRepository _subjectRepository; + private readonly IInspectionService _inspectionService; - public SubjectService(IRepository subjectRepository) + public SubjectService(IRepository subjectRepository, IInspectionService inspectionService) { _subjectRepository = subjectRepository; + this._inspectionService = inspectionService; } /// @@ -95,6 +99,26 @@ namespace IRaCIS.Application.Services await _repository.SaveChangesAsync(); + var createtime = DateTime.Now.AddSeconds(1); + // 添加稽查记录 + if (subjectCommand.Id == null) + { + List datas = new List(); + datas.Add(new DataInspection() + { + TrialId = subjectCommand.TrialId, + SiteId = subjectCommand.SiteId, + SubjectId = subjectCommand.Id, + SubjectCode = subjectCommand.Code, + IsSign=false, + Identification= "Subject|Init|Subject|Status", + JsonDetail= JsonConvert.SerializeObject(new { + Status= "OnVisit", + }) + }); + await _inspectionService.AddListInspectionRecordAsync(datas); + } + return ResponseOutput.Ok(mapedSubject.Id.ToString()); }