修改一致性分析 以及项目部位编辑
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f446d400a1
commit
f158f092ce
|
@ -5262,6 +5262,16 @@
|
||||||
路径
|
路径
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.FileDto.Size">
|
||||||
|
<summary>
|
||||||
|
大小
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.FileDto.Type">
|
||||||
|
<summary>
|
||||||
|
文件类型
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetReadingOrTaskClinicalDataListInDto.ClinicalDataTrialSetId">
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetReadingOrTaskClinicalDataListInDto.ClinicalDataTrialSetId">
|
||||||
<summary>
|
<summary>
|
||||||
临床数据类型Id
|
临床数据类型Id
|
||||||
|
@ -5462,6 +5472,16 @@
|
||||||
FileName
|
FileName
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetFileDto.Size">
|
||||||
|
<summary>
|
||||||
|
大小
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetFileDto.Type">
|
||||||
|
<summary>
|
||||||
|
文件类型
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetFileDto.CreateTime">
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetFileDto.CreateTime">
|
||||||
<summary>
|
<summary>
|
||||||
上传时间
|
上传时间
|
||||||
|
@ -11340,6 +11360,11 @@
|
||||||
组件一致性和原Arm2是否有差异
|
组件一致性和原Arm2是否有差异
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:IRaCIS.Core.Application.Contracts.GetNextCRCChallengeInDto.QCChallengeId">
|
||||||
|
<summary>
|
||||||
|
QCChallengeId
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:IRaCIS.Core.Application.Contracts.QCQuestionViewInDto">
|
<member name="T:IRaCIS.Core.Application.Contracts.QCQuestionViewInDto">
|
||||||
<summary>
|
<summary>
|
||||||
|
|
||||||
|
@ -12336,6 +12361,14 @@
|
||||||
<param name="visitSearchDTO"></param>
|
<param name="visitSearchDTO"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:IRaCIS.Core.Application.Image.QA.QCListService.GetNextCRCChallenge(IRaCIS.Core.Application.Contracts.GetNextCRCChallengeInDto)">
|
||||||
|
<summary>
|
||||||
|
获取下一个crc的未关闭的质疑
|
||||||
|
</summary>
|
||||||
|
<param name="inDto"></param>
|
||||||
|
<returns></returns>
|
||||||
|
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
|
||||||
|
</member>
|
||||||
<member name="M:IRaCIS.Core.Application.Image.QA.QCListService.GetCRCChallengeList(IRaCIS.Core.Application.Contracts.ChallengeQuery)">
|
<member name="M:IRaCIS.Core.Application.Image.QA.QCListService.GetCRCChallengeList(IRaCIS.Core.Application.Contracts.ChallengeQuery)">
|
||||||
<summary>
|
<summary>
|
||||||
CRC 质疑列表
|
CRC 质疑列表
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId);
|
var filterObj = await _taskConsistentRuleRepository.Where(t => t.Id == inCommand.TaskConsistentRuleId).Include(t=>t.TrialReadingCriterion).FirstOrDefaultAsync();
|
||||||
var doctorUserId = inCommand.DoctorUserId;
|
var doctorUserId = inCommand.DoctorUserId;
|
||||||
var trialReadingCriterionId = filterObj.TrialReadingCriterionId;
|
var trialReadingCriterionId = filterObj.TrialReadingCriterionId;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
throw new BusinessValidationFailedException(_localizer["TaskConsistent_NotAllowedGenerate1"]);
|
throw new BusinessValidationFailedException(_localizer["TaskConsistent_NotAllowedGenerate1"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inCommand.SubejctIdList = GetRandomSubjectIdList(subjectList.Select(t => t.SubjectId).ToList(), filterObj.PlanSubjectCount);
|
inCommand.SubejctIdList = subjectList.Select(t => t.SubjectId).ToList().GetRandomCountList(filterObj.PlanSubjectCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, doctorUserId, inCommand.SubejctIdList).ToListAsync();
|
var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, doctorUserId, inCommand.SubejctIdList).ToListAsync();
|
||||||
|
@ -212,7 +212,18 @@ namespace IRaCIS.Core.Application.Service
|
||||||
blindSubjectCode = filterObj.BlindTrialSiteCode + (maxCodeInt + 1).ToString($"D{filterObj.BlindSubjectNumberOfPlaces}");
|
blindSubjectCode = filterObj.BlindTrialSiteCode + (maxCodeInt + 1).ToString($"D{filterObj.BlindSubjectNumberOfPlaces}");
|
||||||
}
|
}
|
||||||
|
|
||||||
subject.VisitTaskList = subject.VisitTaskList.Take(filterObj.PlanVisitCount).ToList();
|
//有序阅片
|
||||||
|
if (filterObj.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.InOrder)
|
||||||
|
{
|
||||||
|
subject.VisitTaskList = subject.VisitTaskList.Take(filterObj.PlanVisitCount).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//完全随机 和受试者随机,都是随机挑选访视
|
||||||
|
subject.VisitTaskList = subject.VisitTaskList.GetRandomCountList(filterObj.PlanVisitCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
subject.VisitTaskList.ForEach(t =>
|
subject.VisitTaskList.ForEach(t =>
|
||||||
{
|
{
|
||||||
|
@ -325,10 +336,12 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
var trialId = inCommand.TrialId;
|
var trialId = inCommand.TrialId;
|
||||||
|
|
||||||
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.TrialReadingCriterionId == inCommand.TrialReadingCriterionId && t.IsSelfAnalysis == false);
|
var filterObj = await _taskConsistentRuleRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == inCommand.TrialReadingCriterionId && t.IsSelfAnalysis == false).Include(t=>t.TrialReadingCriterion).FirstNotNullAsync();
|
||||||
|
|
||||||
var trialReadingCriterionId = filterObj.TrialReadingCriterionId;
|
var trialReadingCriterionId = filterObj.TrialReadingCriterionId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//随机分配
|
//随机分配
|
||||||
if (inCommand.IsAutoAllocateGenerateTask)
|
if (inCommand.IsAutoAllocateGenerateTask)
|
||||||
{
|
{
|
||||||
|
@ -345,7 +358,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
throw new BusinessValidationFailedException(_localizer["TaskConsistent_NotAllowedGenerate1"]);
|
throw new BusinessValidationFailedException(_localizer["TaskConsistent_NotAllowedGenerate1"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inCommand.SubejctIdList = GetRandomSubjectIdList(subjectSelectList.Select(t => t.SubjectId).ToList(), filterObj.PlanSubjectCount);
|
inCommand.SubejctIdList = subjectSelectList.Select(t => t.SubjectId).ToList().GetRandomCountList(filterObj.PlanSubjectCount) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,6 +428,11 @@ namespace IRaCIS.Core.Application.Service
|
||||||
foreach (var needAddDoctorUserId in needAddDoctorUserIdList)
|
foreach (var needAddDoctorUserId in needAddDoctorUserIdList)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//if(filterObj.TrialReadingCriterion.IsReadingTaskViewInOrder== ReadingOrder.InOrder)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
//每个医生 都生成处理的任务
|
//每个医生 都生成处理的任务
|
||||||
foreach (var task in subject.SubjectTaskVisitList.Take(filterObj.PlanVisitCount))
|
foreach (var task in subject.SubjectTaskVisitList.Take(filterObj.PlanVisitCount))
|
||||||
{
|
{
|
||||||
|
@ -995,5 +1013,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
//return matchSubjectIdList.OrderBy(g => random.Next()).Take(countToSelect).ToList();
|
//return matchSubjectIdList.OrderBy(g => random.Next()).Take(countToSelect).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1411,6 +1411,18 @@ namespace IRaCIS.Core.Application.Service
|
||||||
break;
|
break;
|
||||||
case GenerateTaskCategory.SelfConsistent:
|
case GenerateTaskCategory.SelfConsistent:
|
||||||
|
|
||||||
|
var readingCriterionId = generateTaskCommand.GenerataConsistentTaskList.First().TrialReadingCriterionId;
|
||||||
|
//var trialReadingCriterion=_trialReadingCriterionRepository.Where(t=>t.Id== trialReadingCriterionId).FirstOrDefault();
|
||||||
|
|
||||||
|
//判断是否存在传输方式为Pdf得临床数据
|
||||||
|
|
||||||
|
var exsitPDF = await _trialClinicalDataSetRepository.AnyAsync(t => t.TrialId == trialId &&
|
||||||
|
t.TrialClinicalDataSetCriteriaList.Any(c => c.TrialReadingCriterionId == readingCriterionId)
|
||||||
|
&& t.ClinicalUploadType == ClinicalUploadType.PDF);
|
||||||
|
|
||||||
|
var taskState = exsitPDF ? TaskState.NotEffect : TaskState.Effect;
|
||||||
|
|
||||||
|
|
||||||
foreach (var task in generateTaskCommand.GenerataConsistentTaskList)
|
foreach (var task in generateTaskCommand.GenerataConsistentTaskList)
|
||||||
{
|
{
|
||||||
var consistentTask = new VisitTask()
|
var consistentTask = new VisitTask()
|
||||||
|
@ -1424,7 +1436,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
VisitTaskNum = task.VisitTaskNum,
|
VisitTaskNum = task.VisitTaskNum,
|
||||||
ReadingCategory = task.ReadingCategory,
|
ReadingCategory = task.ReadingCategory,
|
||||||
|
|
||||||
TaskState = TaskState.Effect,
|
TaskState = taskState,
|
||||||
Code = currentMaxCodeInt + 1,
|
Code = currentMaxCodeInt + 1,
|
||||||
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
|
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
|
||||||
|
|
||||||
|
|
|
@ -1106,6 +1106,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
[NotDefault]
|
[NotDefault]
|
||||||
public Guid TrialId { get; set; }
|
public Guid TrialId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool IsHandAdd { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TrialBodyPartView
|
public class TrialBodyPartView
|
||||||
|
@ -1114,5 +1117,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public bool IsHandAdd { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1318,7 +1318,7 @@ namespace IRaCIS.Core.Application
|
||||||
|
|
||||||
public async Task<IResponseOutput<List<TrialBodyPartView>>> GetTrialBodyPartList(Guid trialId)
|
public async Task<IResponseOutput<List<TrialBodyPartView>>> GetTrialBodyPartList(Guid trialId)
|
||||||
{
|
{
|
||||||
var list = await _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialBodyPartList).Select(t => new TrialBodyPartView() { Code = t.Code, Name = _userInfo.IsEn_Us ? t.Name : t.NameCN }).ToListAsync();
|
var list = await _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialBodyPartList).Select(t => new TrialBodyPartView() { Code = t.Code, Name = _userInfo.IsEn_Us ? t.Name : t.NameCN ,Id=t.Id,IsHandAdd=t.IsHandAdd}).ToListAsync();
|
||||||
|
|
||||||
return ResponseOutput.Ok(list);
|
return ResponseOutput.Ok(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ namespace IRaCIS.Core.Domain.Share
|
||||||
Effect = 0,
|
Effect = 0,
|
||||||
|
|
||||||
//未生效
|
//未生效
|
||||||
//NotEffect = 1,
|
NotEffect = 1,
|
||||||
|
|
||||||
// 失效
|
// 失效
|
||||||
Adbandon = 3,
|
Adbandon = 3,
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Domain.Models
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 项目的临床数据
|
||||||
|
///</summary>
|
||||||
|
[Table("ReadingConsistentClinicalData")]
|
||||||
|
public class ReadingConsistentClinicalData : Entity, IAuditAdd
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 项目ID
|
||||||
|
/// </summary>
|
||||||
|
public Guid TrialId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 访视Id 或者模块Id
|
||||||
|
/// </summary>
|
||||||
|
public Guid ReadingId { get; set; }
|
||||||
|
|
||||||
|
public Guid? StudyId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 受试者ID
|
||||||
|
/// </summary>
|
||||||
|
public Guid SubjectId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 临床数据类型Id
|
||||||
|
/// </summary>
|
||||||
|
public Guid ClinicalDataTrialSetId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为访视
|
||||||
|
/// </summary>xiu
|
||||||
|
public bool IsVisit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否签名
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSign { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否盲化
|
||||||
|
/// </summary>
|
||||||
|
public bool? IsBlind { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否完整
|
||||||
|
/// </summary>
|
||||||
|
public bool? IsComplete { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
public Guid CreateUserId { get; set; }
|
||||||
|
|
||||||
|
public int FileCount { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
//临床数据状态
|
||||||
|
public ReadingClinicalDataStatus ReadingClinicalDataState { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[ForeignKey("ClinicalDataTrialSetId")]
|
||||||
|
|
||||||
|
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
|
||||||
|
public DicomStudy? DicomStudy { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[ForeignKey("TrialId")]
|
||||||
|
|
||||||
|
public Trial Trial { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[ForeignKey("ReadingId")]
|
||||||
|
|
||||||
|
public SubjectVisit SubjectVisit { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[ForeignKey("SubjectId")]
|
||||||
|
|
||||||
|
public Subject Subject { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[ForeignKey("ReadingId")]
|
||||||
|
|
||||||
|
public ReadModule ReadModule { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PDF文件
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<ReadingClinicalDataPDF> ReadingClinicalDataPDFList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Domain.Models
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 项目的临床数据
|
||||||
|
///</summary>
|
||||||
|
[Table("ReadingConsistentClinicalDataPDF")]
|
||||||
|
public class ReadingConsistentClinicalDataPDF : Entity, IAuditAdd
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[ForeignKey("ReadingConsistentClinicalDataId")]
|
||||||
|
public ReadingConsistentClinicalData ReadingConsistentClinicalData { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 阅片临床数据ID
|
||||||
|
/// </summary>
|
||||||
|
public Guid ReadingConsistentClinicalDataId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Path
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// FileName
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string FileName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
public Guid CreateUserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 大小
|
||||||
|
/// </summary>
|
||||||
|
public int Size { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件类型
|
||||||
|
/// </summary>
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -35,5 +35,8 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Trial Trial { get; set; }
|
public Trial Trial { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool IsHandAdd { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
//public virtual DbSet<ReadingClinicalDataView> ReadingClinicalDataView { get; set; }
|
//public virtual DbSet<ReadingClinicalDataView> ReadingClinicalDataView { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<ReadingClinicalDataPDF> ReadingClinicalDataPDF { get; set; }
|
public virtual DbSet<ReadingClinicalDataPDF> ReadingClinicalDataPDF { get; set; }
|
||||||
|
public virtual DbSet<ReadingConsistentClinicalData> ReadingConsistentClinicalData { get; set; }
|
||||||
|
public virtual DbSet<ReadingConsistentClinicalDataPDF> ReadingConsistentClinicalDataPDF { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<ReadingJudgeInfo> ReadingJudgeInfo { get; set; }
|
public virtual DbSet<ReadingJudgeInfo> ReadingJudgeInfo { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
|
{
|
||||||
|
public static class RandomExtensions
|
||||||
|
{
|
||||||
|
private static Random _random = new Random();
|
||||||
|
|
||||||
|
public static List<T> GetRandomCountList<T>(this List<T> list, int count)
|
||||||
|
{
|
||||||
|
if (count > list.Count)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Sample size cannot be greater than list size.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用 Fisher-Yates 洗牌算法来随机选择元素
|
||||||
|
List<T> result = list.ToList(); // 复制原始列表,以避免修改原始列表
|
||||||
|
int n = result.Count;
|
||||||
|
|
||||||
|
while (n > 1)
|
||||||
|
{
|
||||||
|
n--;
|
||||||
|
int k = _random.Next(n + 1);
|
||||||
|
T value = result[k];
|
||||||
|
result[k] = result[n];
|
||||||
|
result[n] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回所需数量的元素
|
||||||
|
return result.Take(count).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue