123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- using HTEXLib.COMM.Helpers;
- using System.Text;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
- using TEAMModelOS.SDK.Models.Dtos;
- namespace TEAMModelOS.TEST
- {
- public class Program
- {
- 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}");
- }
-
- string path = "C:\\Users\\CrazyIter\\Downloads\\消费清单(2022-2023)\\bill";
- List<List<string>> inputArray = new List<List<string>>
- {
- new List<string> { "2", "11" },
- new List<string> { "1", "22" },
- new List<string> { "1", "11", "111" },
- new List<string> { "2", "22", "222" },
- new List<string> { "1", "11" },
- new List<string> { "1", "11" },
- new List<string> { "1" },
- new List<string> { "2", "22", "222" },
- new List<string> { "2", "22" } ,
- };
- // 转换为层级结构
- List<ClassifiedItem> result = ClassifyHierarchy(inputArray);
- // 输出结果
- foreach (var item in result)
- {
- 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>();
- List<ClassifiedItem> result = new List<ClassifiedItem>();
- foreach (var list in inputArray)
- {
- for (int i = 0; i < list.Count; i++)
- {
- string currentId = list[i];
- string parentId = (i > 0) ? list[i - 1] : null;
- string hierarchyKey = $"{currentId}|{parentId}";
- if (hierarchyCount.ContainsKey(hierarchyKey))
- {
- hierarchyCount[hierarchyKey]++;
- }
- else
- {
- hierarchyCount[hierarchyKey] = 1;
- }
- var item = result.Find(item => item.Id == currentId && item.Pid == parentId);
- if (item== null )
- {
- result.Add(new ClassifiedItem
- {
- Id = currentId,
- Pid = parentId,
- Count = 0
- });
- }
- }
- }
- foreach (var item in result)
- {
- string hierarchyKey = $"{item.Id}|{item.Pid}";
- item.Count = hierarchyCount.ContainsKey(hierarchyKey) ? hierarchyCount[hierarchyKey] : 0;
- }
- return result;
- }
- class ClassifiedItem
- {
- public string Id { get; set; }
- public int Count { get; set; }
- 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; }
- public string? schoolId { get; set; }
- public string? schoolName { get; set; }
- public string? scope { get; set; }
- public string? subjectId { get; set; }
- public string? subjectName { get; set; }
- public string? courseId { get; set; }
- public string? courseName { get; set; }
- public string? classId { get; set; }
- public string? className { get; set; }
- public string? gradeId { get; set; }
- public string? gradeName { get; set; }
- public string? teacherId { get; set; }
- public string? teacherName { get; set; }
- public long time { get; set; }
- public int memberCount { get; set; }
- }
- public class LessonStudent {
- public string? studentID { get; set; }
- public string? groupName { get; set; }
- public string? groupId { get; set; }
- /// <summary>
- /// 1开始,groupIndex=0 表示未分组
- /// </summary>
- public int groupIndex { get; set; }
- public int seatID { get; set; }
- public int studentIndex { get; set; }
- public string? studentName { get; set; }
- /// <summary>
- /// 学生类型 1 醍摩豆id, 2校内账号 ==对应字段 ies_Type //ID類型 1 tmdid,2 student 本地或動態班級的話會是0
- /// </summary>
- public int type { get; set; }
- /// <summary>
- /// 名单id
- /// </summary>
- public string? classId { get; set; }
- /// <summary>
- ///Uncall,//未點名
- ///Attended,//已出席
- ///Absent,//缺席
- ///DayOff,//請假
- ///Absent_Sick,//病假
- ///Absent_Personal,//事假
- ///Absent_Official,//公假
- /// </summary>
- public string? AttendState { get; set; }
- /// <summary>
- /// 个人积分
- /// </summary>
- public double score { get; set; }
- /// <summary>
- /// 小组积分
- /// </summary>
- public double groupScore { get; set; }
- /// <summary>
- /// 互动积分
- /// </summary>
- public double interactScore { get; set; }
- }
- }
|