using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Admin.NET.Core; public class CalcuScoreFinder { /// /// 根据给定的位次找到对应的分数。 /// /// 考生位次。 /// 分数段数据。 /// 对应位次的分数。 public static int FindScoreByRank(int rank, List data) { var result = data.FirstOrDefault(x => x.CumulativeCount.Value >= rank); return result?.Score.Value ?? 0; } /// /// 根据给定的分数找到对应的位次。 /// /// /// /// public static int FindPostion(int score, List data) { var result = data.FirstOrDefault(x => score >= x.Score.Value); return result?.CumulativeCount.Value ?? 0; } /// /// 类型转换0综合 1物理 2历史 3理科 4文科 /// /// /// public static int ChangeSubjectName(string s) { int result = 0; switch (s) { case "综合": result = 0; break; case "物理": result = 1; break; case "历史": result = 2; break; case "理科": result = 3; break; case "文科": result = 4; break; } return result; } /// /// 获取科目名称 /// /// /// public static string GetSubjectid(int s) { string name = ""; switch (s) { case 0: name = "综合"; break; case 1: name = "物理"; break; case 2: name = "历史"; break; case 3: name = "理科"; break; case 4: name = "文科"; break; } return name; } /// /// 调整选科数据格式 /// /// /// public static List GetSubjects(string s) { s = s.Replace("&", "和").Replace("|", "或"); var sss = new List(); if (string.IsNullOrWhiteSpace(s)) { return new List() { }; }; string str = s.Replace("思想政治", "政治").Replace("不限科目", "不限"); return str.Contains("或") ? str.Split("或").ToList() : str.Contains("和") ? str.Split("和").ToList() : new List { str }; } /// /// 转换选科id类型:0 综合||1(物理)|2(历史)|3理科 |4 文科 /// /// /// public static int subjectidChange(int sub) { int result = 0; switch (sub) { case 3: result = 0; break; case 4: result = 1; break; case 5: result = 2; break; case 2: result = 3; break; case 1: result = 4; break; } return result; } /// /// 选科组合文字转换 /// /// /// public static string GetTitle(string s) { string title = string.Empty; switch (s) { case "物": title = "物理"; break; case "化": title = "化学"; break; case "生": title = "生物"; break; case "政": title = "政治"; break; case "史": title = "历史"; break; case "地": title = "地理"; break; case "技": title = "技术"; break; default: title = s; break; } return title; } }