Merge branch 'Test_IRC_Net8' of http://192.168.3.68:2000/XCKJ/irc-netcore-api into Test_IRC_Net8

IRC_NewDev
he 2024-03-13 16:31:22 +08:00
commit 658e8d983c
5 changed files with 34 additions and 4 deletions

View File

@ -291,7 +291,8 @@ namespace IRaCIS.Core.Application.Service
if (filterObj == null)
{
return ResponseOutput.Ok(new PageOutput<DoctorGroupConsistentSubjectView>()) ;
object tt = null;
return ResponseOutput.Ok(new PageOutput<DoctorGroupConsistentSubjectView>(), new { Rule = tt, IsAllowAutoAllocate = false }) ;
}
var query = await GetGroupConsistentQueryAsync(filterObj);
@ -300,7 +301,12 @@ namespace IRaCIS.Core.Application.Service
var pagedList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(DoctorSelfConsistentSubjectView.SubjectCode) : inQuery.SortField, inQuery.Asc);
var rule = await _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsSelfAnalysis == false && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId).ProjectTo<TaskConsistentRuleBasic>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
return ResponseOutput.Ok(pagedList, rule);
var list = await GetGroupConsistentRuleMatchSubjectIdListAsync(new GroupConsistentSimpleQuery() { TrialId = inQuery.TrialId, TrialReadingCriterionId = inQuery.TrialReadingCriterionId });
var isAllowAutoAllocate = !list.Any(t => t.IsHaveGeneratedTask) && list.Count() > 2*(rule?.PlanSubjectCount??0);
return ResponseOutput.Ok(pagedList, new {Rule=rule, IsAllowAutoAllocate = isAllowAutoAllocate });
}
@ -829,8 +835,15 @@ namespace IRaCIS.Core.Application.Service
public async Task<IResponseOutput> UpdateTrialVirtualSiteCode(UpdateTrialSiteCodeCommand inCommand)
{
if (_trialSiteRepository.Where(t => t.TrialId == inCommand.TrialId, false, true).Any(t => t.TrialSiteCode == inCommand.VirtualSiteCode))
{
return ResponseOutput.NotOk(_localizer["TaskConsistent_SiteCodeExists"]);
}
var trial = await _trialRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TrialId);
var oldCode = trial.VitrualSiteCode;
trial.VitrualSiteCode = inCommand.VirtualSiteCode;
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trial.Id, u => new VisitTask() { BlindTrialSiteCode = inCommand.VirtualSiteCode });
@ -838,6 +851,8 @@ namespace IRaCIS.Core.Application.Service
await _taskConsistentRuleRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trial.Id, u => new TaskConsistentRule() { BlindTrialSiteCode = inCommand.VirtualSiteCode });
await _visitTaskRepository.ExecuteUpdateAsync(t => t.TrialId == trial.Id, s => s.SetProperty(e => e.BlindSubjectCode, u => u.BlindSubjectCode.Replace(oldCode, inCommand.VirtualSiteCode)));
await _trialVirtualSiteCodeUpdateRepository.AddAsync(new TrialVirtualSiteCodeUpdate() { VirturalSiteCode = inCommand.VirtualSiteCode, TrialId = inCommand.TrialId });
await _trialRepository.SaveChangesAsync();

View File

@ -274,7 +274,7 @@ namespace IRaCIS.Core.Application.Services
return ResponseOutput.NotOk(_localizer["TrialSite_CodeDuplicate"]);
}
if(!string.IsNullOrEmpty(editTrialSiteCommand.TrialSiteCode) && await _trialRepository.AnyAsync(t=>t.Id==trialId && t.VitrualSiteCode == editTrialSiteCommand.TrialSiteCode) )
if(!string.IsNullOrEmpty(editTrialSiteCommand.TrialSiteCode) && await _trialRepository.AnyAsync(t=>t.Id==trialId && t.VitrualSiteCode == editTrialSiteCommand.TrialSiteCode,true) )
{
return ResponseOutput.NotOk(_localizer["TrialSite_CodeDuplicate2"]);
}

View File

@ -6,6 +6,7 @@ using System.Threading;
using System.Threading.Tasks;
using IRaCIS.Core.Domain.Models;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Query;
namespace IRaCIS.Core.Infra.EFCore
{
@ -82,6 +83,8 @@ namespace IRaCIS.Core.Infra.EFCore
/// <summary>批量更新相当于原生sql 没用EF跟踪方式所有查询出来再更新 浪费性能)</summary>
Task<bool> BatchUpdateNoTrackingAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory);
Task<bool> ExecuteUpdateAsync(Expression<Func<TEntity, bool>> where, Expression<Func<SetPropertyCalls<TEntity>, SetPropertyCalls<TEntity>>> setPropertyCalls);
#endregion

View File

@ -232,6 +232,12 @@ namespace IRaCIS.Core.Infra.EFCore
}
public static async Task<bool> ExecuteUpdateAsync<T>(this IRaCISDBContext _dbContext, Expression<Func<T, bool>> where, Expression<Func<SetPropertyCalls<T>, SetPropertyCalls<T>>> setPropertyCalls) where T : Entity
{
return await _dbContext.Set<T>().Where(where).ExecuteUpdateAsync<T>(setPropertyCalls)>0;
}
#endregion

View File

@ -14,6 +14,7 @@ using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.Extensions.Localization;
using Microsoft.EntityFrameworkCore.Query;
namespace IRaCIS.Core.Infra.EFCore
{
@ -369,12 +370,17 @@ namespace IRaCIS.Core.Infra.EFCore
}
public async Task<bool> ExecuteUpdateAsync(Expression<Func<TEntity, bool>> where, Expression<Func<SetPropertyCalls<TEntity>, SetPropertyCalls<TEntity>>> setPropertyCalls)
{
return await _dbContext.ExecuteUpdateAsync(where, setPropertyCalls);
}
#endregion
#region 保存 、忽略 、验证
#region 保存 、忽略 、验证
public async Task<TEntity> InsertOrUpdateAsync<TFrom>(TFrom from, bool autoSave = false, params EntityVerifyExp<TEntity>[] verify)
{
var entity = _mapper.Map<TEntity>(from);