tuiwucarrer/Admin.NET/Admin.NET.Core/Util/CalcuScoreFinder.cs

183 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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