using HTEXLib.COMM.Helpers; using Newtonsoft.Json; using System.Security.Policy; using System.Text; using System.Web; 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 uri = HttpUtility.UrlDecode("https://teammodeltest.blob.core.chinacloudapi.cn/hbcn/art/e9a5ec36-7299-45dc-9517-7457960346c4/report/202106005.pdf"); var paths = uri.Split("/art/"); if (paths.Length == 2) { var ps = paths[1].Split("/"); if (ps.Length == 3) { Uri uris = new Uri(paths[0]); // 获取URL的Segments属性,这是一个String数组,包含URL中的每个部分 string[] segments = uris.Segments; string key = $"ArtPDF:{ps[0]}"; // 确保segments数组至少有一个元素 if (segments.Length > 0) { // 获取数组中的最后一个元素,即最后一个'/'之后的部分 string lastSegment = segments[segments.Length - 1]; key = $"ArtPDF:{ps[0]}:{lastSegment}"; } } } List> jsonData = new List> { new Dictionary { { "user", "A" }, { "time", 1711414573130 } }, new Dictionary { { "user", "A" }, { "time", 1711414673130 } }, new Dictionary { { "user", "A" }, { "time", 1711415673130 } }, new Dictionary { { "user", "A" }, { "time", 1711435873130 } }, new Dictionary { { "user", "A" }, { "time", 1711436873130 } }, new Dictionary { { "user", "A" }, { "time", 1711455873130 } }, new Dictionary { { "user", "A" }, { "time", 1711495873130 } }, new Dictionary { { "user", "A" }, { "time", 1711495973130 } } }; double totalDuration = GetUserDuration(jsonData); Console.WriteLine("用户使用时长: " + totalDuration + "小时"); // 作品数据 var works = new List { 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 { //new ExpertS { ExpertId = "a", Subjects = new List { "语文", "数学" ,"英语"} }, new ExpertS { ExpertId = "b", Subjects = new List { "数学" } }, //new ExpertS { ExpertId = "c", Subjects = new List { "英语", "英语" } }, new ExpertS { ExpertId = "d", Subjects = new List { "数学" } }, new ExpertS { ExpertId = "e", Subjects = new List { "英语", "数学" } }, //new ExpertS { ExpertId = "f", Subjects = new List { "语文" } } }; // 分配作品给专家 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> inputArray = new List> { new List { "2", "11" }, new List { "1", "22" }, new List { "1", "11", "111" }, new List { "2", "22", "222" }, new List { "1", "11" }, new List { "1", "11" }, new List { "1" }, new List { "2", "22", "222" }, new List { "2", "22" } , }; // 转换为层级结构 List result = ClassifyHierarchy(inputArray); // 输出结果 foreach (var item in result) { Console.WriteLine($"id: {item.Id}, count: {item.Count}, pid: {item.Pid}"); } } static double GetUserDuration(List> jsonData) { double totalDuration = 0; // DateTime lastTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsonData[0]["time"]).UtcDateTime; long ltime = (long)jsonData[0]["time"]; for (int i = 1; i < jsonData.Count; i++) { long ctime = (long)jsonData[i]["time"]; //DateTime currentTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsonData[i]["time"]).UtcDateTime; long timeDifference = ctime - ltime; if (timeDifference < 3600000) { totalDuration += timeDifference; } else { totalDuration += 1; } ltime = ctime; } return totalDuration; } static List AssignWorksToExperts(List works, List experts, int N) { var assignments = new List(); 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 ClassifyHierarchy(List> inputArray) { Dictionary hierarchyCount = new Dictionary(); List result = new List(); 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 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; } /// /// 1开始,groupIndex=0 表示未分组 /// public int groupIndex { get; set; } public int seatID { get; set; } public int studentIndex { get; set; } public string? studentName { get; set; } /// /// 学生类型 1 醍摩豆id, 2校内账号 ==对应字段 ies_Type //ID類型 1 tmdid,2 student 本地或動態班級的話會是0 /// public int type { get; set; } /// /// 名单id /// public string? classId { get; set; } /// ///Uncall,//未點名 ///Attended,//已出席 ///Absent,//缺席 ///DayOff,//請假 ///Absent_Sick,//病假 ///Absent_Personal,//事假 ///Absent_Official,//公假 /// public string? AttendState { get; set; } /// /// 个人积分 /// public double score { get; set; } /// /// 小组积分 /// public double groupScore { get; set; } /// /// 互动积分 /// public double interactScore { get; set; } } // 用于反序列化JSON数据的类 public class UsageRecord { [JsonProperty("user")] public string user { get; set; } [JsonProperty("time")] public long time { get; set; } } }