This commit is contained in:
he
2022-04-07 14:11:01 +08:00
parent 7a1cc3e29f
commit c72a73d339
6 changed files with 94 additions and 50 deletions
@@ -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("名称重复");
}
@@ -44,21 +44,23 @@ namespace IRaCIS.Core.Application.Service.Inspection
from leftuser in usertemp.DefaultIfEmpty()
join moduleTyped in _repository.GetQueryable<Dictionary>().Where(x => x.Code == "ModuleType") on 1 equals 1
join moduleTypec in _repository.GetQueryable<Dictionary>() 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<Dictionary>().Where(x => x.Code == "ChildrenType") on 1 equals 1
//join childrenTypec in _repository.GetQueryable<Dictionary>() 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<Dictionary>().Where(x => x.Code == "ObjectType") on 1 equals 1
//join ObjectTypec in _repository.GetQueryable<Dictionary>() 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<Dictionary>().Where(x => x.Code == "OptType") on 1 equals 1
//join OptTypec in _repository.GetQueryable<Dictionary>() 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<Dictionary>().Where(x => x.Code == "ModuleType") on 1 equals 1
//join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ParentId = moduleTyped.Id, ModuleType = data.ModuleType } equals new { ParentId = moduleTypec.ParentId.Value, ModuleType = moduleTypec.Value } into moduleTypectemp
//join childrenTyped in _repository.GetQueryable<Dictionary>().Where(x => x.Code == "ChildrenType") on 1 equals 1
//join childrenTypec in _repository.GetQueryable<Dictionary>() 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<Dictionary>().Where(x => x.Code == "ObjectType") on 1 equals 1
//join ObjectTypec in _repository.GetQueryable<Dictionary>() 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<Dictionary>().Where(x => x.Code == "OptType") on 1 equals 1
//join OptTypec in _repository.GetQueryable<Dictionary>() 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<TrialSign>() 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<Dictionary>() 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
/// <param name="SignInfo">用户签名</param>
/// <param name="fun">委托</param>
/// <param name="response">方法返回的结果</param>
/// <param name="Statusdata">添加状态的对象</param>
/// <returns></returns>
public async Task<dynamic> Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response=null, object? Statusdata=null)
public async Task<dynamic> 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
/// <param name="signId">签名Id</param>
/// <param name="Statusdata">初始化状态对象</param>
/// <returns></returns>
public async Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId=null, object? Statusdata = null)
public async Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId=null)
{
await SetEnum(addDto);
var add = _mapper.Map<DataInspection>(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<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);
}
//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);
@@ -300,6 +306,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
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 SetInspectionNameValue(add);
}
await _dataInspectionRepository.AddRangeAsync(datas);
@@ -19,12 +19,12 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface
Task<Guid> AddSignRecordAsync(SignDTO signDTO);
Task<dynamic> Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null, object? Statusdata = null);
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, object? Statusdata = null);
Task<IResponseOutput> AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId = null);
/// <summary>
/// 批量添加稽查记录
@@ -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<Subject> _subjectRepository;
private readonly IInspectionService _inspectionService;
public SubjectService(IRepository<Subject> subjectRepository)
public SubjectService(IRepository<Subject> subjectRepository, IInspectionService inspectionService)
{
_subjectRepository = subjectRepository;
this._inspectionService = inspectionService;
}
/// <summary>
@@ -95,6 +99,26 @@ namespace IRaCIS.Application.Services
await _repository.SaveChangesAsync();
var createtime = DateTime.Now.AddSeconds(1);
// 添加稽查记录
if (subjectCommand.Id == null)
{
List<DataInspection> datas = new List<DataInspection>();
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());
}