copy功能新增复制value
parent
2a1f15996d
commit
5241e62fe3
|
@ -49,16 +49,16 @@ namespace IRaCIS.Core.Application.Service
|
|||
public async Task<IResponseOutput> CopyOtherToThisItem(CopyOtherToThisItem item)
|
||||
{
|
||||
|
||||
var names = _frontAuditConfigRepository.Where(x => x.ParentId == item.AddItem).Select(x => x.ValueCN).ToList();
|
||||
var lists = _frontAuditConfigRepository.Where(x => x.ParentId == item.AddItem).ToList();
|
||||
|
||||
var additem = await _frontAuditConfigRepository.FirstOrDefaultAsync(x => x.Id == item.AddItem);
|
||||
|
||||
var list = _frontAuditConfigRepository.Where(x => item.DataSource.Contains(x.ParentId)).ToList().GroupBy(x => new { x.ValueCN }, (key, lst) => new FrontAuditConfig
|
||||
var alllist = _frontAuditConfigRepository.Where(x => item.DataSource.Contains(x.ParentId)).ToList().GroupBy(x => new { x.ValueCN }, (key, lst) => new FrontAuditConfig
|
||||
{
|
||||
Sort = lst.Select(x => x.Sort).FirstOrDefault(),
|
||||
IsShowByTrialConfig= lst.Select(x => x.IsShowByTrialConfig).FirstOrDefault(),
|
||||
ByTrialConfig = lst.Select(x => x.ByTrialConfig).FirstOrDefault(),
|
||||
Code = lst.Select(x => x.Code).FirstOrDefault(),
|
||||
Code = lst.Max(x => x.Code),
|
||||
ConfigType = lst.Select(x => x.ConfigType).FirstOrDefault(),
|
||||
CreateTime = DateTime.Now,
|
||||
Description = lst.Select(x => x.Description).FirstOrDefault(),
|
||||
|
@ -72,7 +72,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
EnumType = lst.Select(x => x.EnumType).FirstOrDefault(),
|
||||
UpdateTime = DateTime.Now,
|
||||
ValueCN = lst.Select(x => x.ValueCN).FirstOrDefault(),
|
||||
Value = lst.Select(x => x.Value).FirstOrDefault(),
|
||||
Value = lst.Max(x => x.Value),
|
||||
UpdateUserId = _userInfo.Id,
|
||||
ChildrenTypeId= additem?.ChildrenTypeId,
|
||||
ModuleTypeId = additem?.ModuleTypeId,
|
||||
|
@ -81,7 +81,31 @@ namespace IRaCIS.Core.Application.Service
|
|||
Id =Guid.NewGuid(),
|
||||
}).ToList();
|
||||
|
||||
list = list.Where(x => !names.Contains(x.ValueCN)).ToList();
|
||||
// 获取已存在的所有名称
|
||||
var names = lists.Select(x => x.ValueCN).ToList();
|
||||
|
||||
// 获取不存在的数据
|
||||
var list = alllist.Where(x => !names.Contains(x.ValueCN)).ToList();
|
||||
|
||||
// 获取要添加的name
|
||||
var addvaluecns = list.Select(x => x.ValueCN);
|
||||
|
||||
// 获取要修改的数据
|
||||
var neewupdate = lists.Where(x => !addvaluecns.Contains(x.ValueCN));
|
||||
|
||||
neewupdate.ForEach(x =>
|
||||
{
|
||||
var item = alllist.FirstOrDefault(y => y.ValueCN == x.ValueCN);
|
||||
if (item != null)
|
||||
{
|
||||
x.Code=x.Code.IsNullOrEmpty()?item.Code:x.Code;
|
||||
x.Value = x.Code.IsNullOrEmpty() ? item.Value : x.Value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
await _repository.UpdateRange(neewupdate);
|
||||
await _repository.AddRangeAsync(list);
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
|
|
|
@ -105,11 +105,11 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
TrialId = subjectCommand.TrialId,
|
||||
SiteId = subjectCommand.SiteId,
|
||||
SubjectId = subjectCommand.Id,
|
||||
SubjectId = mapedSubject.Id,
|
||||
SubjectCode = subjectCommand.Code,
|
||||
IsSign=false,
|
||||
CreateTime = createtime,
|
||||
Identification = "Subject|Init|Subject|Status",
|
||||
Identification = "Init|Subject|Status|Subject",
|
||||
JsonDetail= JsonConvert.SerializeObject(new {
|
||||
Status= "OnVisit",
|
||||
})
|
||||
|
@ -122,10 +122,11 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
TrialId = subjectCommand.TrialId,
|
||||
SiteId = subjectCommand.SiteId,
|
||||
SubjectId = subjectCommand.Id,
|
||||
SubjectId = mapedSubject.Id,
|
||||
SubjectCode = subjectCommand.Code,
|
||||
SubjectVisitId= item.Id,
|
||||
SubjectVisitName=item.VisitName,
|
||||
BlindName=item.BlindName,
|
||||
IsSign = false,
|
||||
CreateTime = visittime,
|
||||
Identification = "Add|Visit|Info|Visit-Image Upload",
|
||||
|
@ -145,9 +146,10 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
TrialId = subjectCommand.TrialId,
|
||||
SiteId = subjectCommand.SiteId,
|
||||
SubjectId = subjectCommand.Id,
|
||||
SubjectId = mapedSubject.Id,
|
||||
SubjectCode = subjectCommand.Code,
|
||||
SubjectVisitId = item.Id,
|
||||
BlindName = item.BlindName,
|
||||
SubjectVisitName = item.VisitName,
|
||||
IsSign = false,
|
||||
CreateTime = visittime.AddSeconds(1),
|
||||
|
|
|
@ -9,6 +9,8 @@ using IRaCIS.Core.Application.MediatR.CommandAndQueries;
|
|||
using Magicodes.ExporterAndImporter.Core;
|
||||
using Magicodes.ExporterAndImporter.Excel;
|
||||
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
|
||||
using IRaCIS.Core.Application.Service.Inspection.Interface;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
|
@ -17,11 +19,13 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
private readonly IRepository<VisitStage> _visitStageRepository;
|
||||
private readonly IRepository<Trial> _trialRepository;
|
||||
private readonly IInspectionService _inspectionService;
|
||||
|
||||
public VisitPlanService(IRepository<VisitStage> visitStageRepository,IRepository<Trial> trialRepository)
|
||||
public VisitPlanService(IRepository<VisitStage> visitStageRepository,IRepository<Trial> trialRepository, IInspectionService inspectionService)
|
||||
{
|
||||
_visitStageRepository = visitStageRepository;
|
||||
_trialRepository = trialRepository;
|
||||
this._inspectionService = inspectionService;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,6 +81,8 @@ namespace IRaCIS.Application.Services
|
|||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> AddOrUpdateVisitStage(VisitPlanCommand visitPlan)
|
||||
{
|
||||
DateTime createtime = DateTime.Now;
|
||||
List<DataInspection> datas = new List<DataInspection>();
|
||||
if (!await _repository.Where<Trial>(t => t.Id == visitPlan.TrialId).IgnoreQueryFilters().AnyAsync(t => t.TrialStatusStr == StaticData.TrialOngoing || t.TrialStatusStr == StaticData.TrialInitializing))
|
||||
{
|
||||
return ResponseOutput.NotOk(" only in Initializing or Ongoing State can operate ");
|
||||
|
@ -108,7 +114,6 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (visitPlan.Id == Guid.Empty || visitPlan.Id == null)//add
|
||||
{
|
||||
|
||||
|
@ -136,13 +141,40 @@ namespace IRaCIS.Application.Services
|
|||
svItem.SiteId = subject.SiteId;
|
||||
|
||||
svItem.SubjectId = subject.SubjectId;
|
||||
svItem.Id = Guid.NewGuid();
|
||||
|
||||
//设置了末次访视,那么加访视计划的时候,设置为不可用
|
||||
if (subjectSVS.Any(t => t.SubjectId == svItem.SubjectId && t.IsFinalVisit))
|
||||
{
|
||||
svItem.VisitExecuted = VisitExecutedEnum.Unavailable;
|
||||
}
|
||||
datas.Add(new DataInspection()
|
||||
{
|
||||
SubjectVisitId = svItem.Id,
|
||||
SubjectVisitName = svItem.VisitName,
|
||||
BlindName = visitPlan.BlindName,
|
||||
Identification = "Add|Visit|Info|Visit-Image Upload",
|
||||
SiteId = svItem.SiteId,
|
||||
TrialId = svItem.TrialId,
|
||||
SubjectId = svItem.SubjectId,
|
||||
IsSign = false,
|
||||
CreateTime = createtime,
|
||||
JsonDetail = JsonConvert.SerializeObject(svItem)
|
||||
});
|
||||
|
||||
datas.Add(new DataInspection()
|
||||
{
|
||||
SubjectVisitId = svItem.Id,
|
||||
SubjectVisitName = svItem.VisitName,
|
||||
BlindName = visitPlan.BlindName,
|
||||
Identification = "Add|Visit|Info|Visit-Image Upload",
|
||||
SiteId = svItem.SiteId,
|
||||
TrialId = svItem.TrialId,
|
||||
SubjectId = svItem.SubjectId,
|
||||
IsSign = false,
|
||||
CreateTime = createtime.AddSeconds(1),
|
||||
JsonDetail = JsonConvert.SerializeObject(svItem)
|
||||
});
|
||||
await _repository.AddAsync(svItem);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +191,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok(result.Id.ToString());
|
||||
//return ResponseOutput.Ok(result.Id.ToString());
|
||||
|
||||
|
||||
}
|
||||
|
@ -201,9 +233,12 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
//return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
await _inspectionService.AddListInspectionRecordAsync(datas);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary> 删除项目计划某一项[New]</summary>
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
ValueTask<T> AddAsync<T>(T entity, bool autoSave = false) where T : Entity;
|
||||
|
||||
Task UpdateRange<T>(IEnumerable<T> entities, bool autoSave = false) where T : Entity;
|
||||
Task<bool> AddRangeAsync<T>(IEnumerable<T> entities, bool autoSave = false) where T : Entity;
|
||||
|
||||
Task<bool> UpdateAsync<T>(T entity, bool autoSave = false) where T : Entity;
|
||||
|
@ -332,6 +333,17 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
}
|
||||
}
|
||||
|
||||
public async Task UpdateRange<T>(IEnumerable<T> entities, bool autoSave = false) where T : Entity
|
||||
{
|
||||
_dbContext.Set<T>().UpdateRange(entities);
|
||||
|
||||
if (autoSave)
|
||||
{
|
||||
await SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync<T>(T entity, bool autoSave = false) where T : Entity
|
||||
{
|
||||
_dbContext.Set<T>().Update(entity);
|
||||
|
|
Loading…
Reference in New Issue