NewGaoKaoApi/New_College.Common/Helper/UniversityCodeConvertRules.cs

90 lines
2.6 KiB
C#
Raw Permalink 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 NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace New_College.Common
{
/// <summary>
/// 院校招生代码转换
/// </summary>
public static class UniversityCodeConvertRules
{
/// <summary>
/// 山东省 部标代码前两位数字转换为字母10—>A11—>B12—>C13—>D14—>E15 —> T,16—>F18—>G19—>H50—>K51—>M81—>N91—>P
/// </summary>
/// <param name="code">院校招生代码</param>
/// <returns></returns>
public static string UniversityCodeConvertRulesMap(string code)
{
try
{
if (string.IsNullOrEmpty(code) || code.Length < 4)
{
return code;
}
int strleft = int.Parse(code.Substring(0, 2));
string strright = code.Substring(2, code.Length - 2);
string codestr = string.Empty;
switch (strleft)
{
case 10:
codestr = "A";
break;
case 11:
codestr = "B";
break;
case 12:
codestr = "C";
break;
case 13:
codestr = "D";
break;
case 14:
codestr = "E";
break;
case 15:
codestr = "T";
break;
case 16:
codestr = "F";
break;
case 18:
codestr = "G";
break;
case 19:
codestr = "H";
break;
case 50:
codestr = "K";
break;
case 51:
codestr = "M";
break;
case 81:
codestr = "N";
break;
case 91:
codestr = "P";
break;
default:
codestr = strleft.ToString();
break;
}
return codestr + strright;
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}