|
@@ -11,11 +11,40 @@ namespace TEAMModelOS.TEST
|
|
|
{
|
|
|
static void Main(string[] args)
|
|
|
{
|
|
|
+ // 作品数据
|
|
|
+ var works = new List<Work>
|
|
|
+ {
|
|
|
+ new Work { WorkId = "1", Subject = "语文" },
|
|
|
+ new Work { WorkId = "2", Subject = "数学" },
|
|
|
+ new Work { WorkId = "3", Subject = "英语" },
|
|
|
+ new Work { WorkId = "4", Subject = "数学" },
|
|
|
+ new Work { WorkId = "5", Subject = "英语" },
|
|
|
+ new Work { WorkId = "6", Subject = "语文" },
|
|
|
+ new Work { WorkId = "7", Subject = "语文" }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 专家数据
|
|
|
+ var experts = new List<ExpertS>
|
|
|
+ {
|
|
|
+ //new ExpertS { ExpertId = "a", Subjects = new List<string> { "语文", "数学" ,"英语"} },
|
|
|
+ new ExpertS { ExpertId = "b", Subjects = new List<string> { "数学" } },
|
|
|
+ //new ExpertS { ExpertId = "c", Subjects = new List<string> { "英语", "英语" } },
|
|
|
+ new ExpertS { ExpertId = "d", Subjects = new List<string> { "数学" } },
|
|
|
+ new ExpertS { ExpertId = "e", Subjects = new List<string> { "英语", "数学" } },
|
|
|
+ //new ExpertS { ExpertId = "f", Subjects = new List<string> { "语文" } }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 分配作品给专家
|
|
|
+ int N = 1; // 指定评审次数
|
|
|
+ var assignments = AssignWorksToExperts(works, experts, N);
|
|
|
+
|
|
|
+ // 输出结果
|
|
|
+ foreach (var assignment in assignments)
|
|
|
+ {
|
|
|
+ Console.WriteLine($"WorkId: {assignment.WorkId}, ExpertId: {assignment.ExpertId}");
|
|
|
+ }
|
|
|
|
|
|
- //List<string> groupNames = new List<string>() { "組別4", "組別2", "組別3", "組別4", "組別1", "組別1" };
|
|
|
- //groupNames =groupNames.OrderBy(x => x).ToList();
|
|
|
- //var jsonAuth = System.IO.File.ReadAllText("C:\\Users\\CrazyIter\\Downloads\\492266088181141504\\ActivityInfo.json", Encoding.UTF8);
|
|
|
- //var jsonData = jsonAuth.ToObject<LessonRecordActivityInfo>();
|
|
|
+
|
|
|
string path = "C:\\Users\\CrazyIter\\Downloads\\消费清单(2022-2023)\\bill";
|
|
|
List<List<string>> inputArray = new List<List<string>>
|
|
|
{
|
|
@@ -39,6 +68,33 @@ namespace TEAMModelOS.TEST
|
|
|
Console.WriteLine($"id: {item.Id}, count: {item.Count}, pid: {item.Pid}");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ static List<Assignment> AssignWorksToExperts(List<Work> works, List<ExpertS> experts, int N)
|
|
|
+ {
|
|
|
+ var assignments = new List<Assignment>();
|
|
|
+ foreach (var work in works)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < N; i++)
|
|
|
+ {
|
|
|
+ var availableExperts = experts
|
|
|
+ .OrderBy(expert => assignments.Count(a => a.ExpertId == expert.ExpertId))
|
|
|
+ .Where(expert => expert.Subjects.Contains(work.Subject) && !assignments.Any(a => a.WorkId == work.WorkId && a.ExpertId == expert.ExpertId))
|
|
|
+ .ToList();
|
|
|
+ if (availableExperts.Count > 0)
|
|
|
+ {
|
|
|
+ var selectedExpert = availableExperts.First();
|
|
|
+ assignments.Add(new Assignment { WorkId = work.WorkId, ExpertId = selectedExpert.ExpertId });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine($"No available expert for WorkId {work.WorkId} and subject {work.Subject} in attempt {i + 1}.");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return assignments;
|
|
|
+ }
|
|
|
static List<ClassifiedItem> ClassifyHierarchy(List<List<string>> inputArray)
|
|
|
{
|
|
|
Dictionary<string, int> hierarchyCount = new Dictionary<string, int>();
|
|
@@ -89,7 +145,23 @@ namespace TEAMModelOS.TEST
|
|
|
public string Pid { get; set; }
|
|
|
}
|
|
|
}
|
|
|
+ class Work
|
|
|
+ {
|
|
|
+ public string WorkId { get; set; }
|
|
|
+ public string Subject { get; set; }
|
|
|
+ }
|
|
|
|
|
|
+ class ExpertS
|
|
|
+ {
|
|
|
+ public string ExpertId { get; set; }
|
|
|
+ public List<string> Subjects { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ class Assignment
|
|
|
+ {
|
|
|
+ public string WorkId { get; set; }
|
|
|
+ public string ExpertId { get; set; }
|
|
|
+ }
|
|
|
public class LessonBase {
|
|
|
public string? id { get; set; }
|
|
|
public string? duration { get; set; }
|