feat:bug fixed
parent
fe2a7d52b8
commit
0b67c773a4
|
|
@ -11,6 +11,9 @@ using New_College.Model.ViewModels;
|
|||
using New_College.Services;
|
||||
using System.Linq;
|
||||
using SqlSugar;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using New_College.Common;
|
||||
|
||||
namespace New_College.Api.Controllers
|
||||
{
|
||||
|
|
@ -28,12 +31,53 @@ namespace New_College.Api.Controllers
|
|||
/// </summary>
|
||||
private readonly ID_PlanMajorScoreLineServices _d_PlanMajorScoreLineServices;
|
||||
|
||||
public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices)
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private readonly ID_ScoreLineServices id_coreLineServices;
|
||||
public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices, ID_ScoreLineServices _ScoreLineServices)
|
||||
{
|
||||
_d_PlanMajorScoreLineServices = D_PlanMajorScoreLineServices;
|
||||
id_coreLineServices = _ScoreLineServices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入专业最低录取位次表=同步更新专业数据与学校专业分数线(--高考时可通用此功能)
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<MessageModel<bool>> ImportMajorData(IFormFile file)
|
||||
{
|
||||
var _list = new List<D_PlanMajorScoreLine>();
|
||||
var list = ExcelProUtil<ImportPlanMajorScoreRequest>.InputExcel(file);
|
||||
//1. 查询匹配一分一段表数据
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//2. 更新招生计划专业数据
|
||||
|
||||
|
||||
|
||||
//3. 更新学校最低专业录取线
|
||||
|
||||
|
||||
|
||||
// await _d_PlanMajorScoreLineServices.Add(_list);
|
||||
return new MessageModel<bool>()
|
||||
{
|
||||
success = true,
|
||||
response = true,
|
||||
status = 200,
|
||||
msg = "ok"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学校专业分数线
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -4040,6 +4040,11 @@
|
|||
专业组
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:New_College.Model.ViewModels.ImportPlanMajorScoreRequest">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CategoryInfoQuery.Type">
|
||||
<summary>
|
||||
测评类型
|
||||
|
|
@ -7025,6 +7030,11 @@
|
|||
学校logo
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.SimuVolunteerTableResult.UniversityCode">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.SimuVolunteerTableResult.Nature">
|
||||
<summary>
|
||||
办学性质
|
||||
|
|
|
|||
|
|
@ -163,6 +163,13 @@
|
|||
服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.PlanMajorScoreLineController.ImportMajorData(Microsoft.AspNetCore.Http.IFormFile)">
|
||||
<summary>
|
||||
导入专业最低录取位次表=同步更新专业数据与学校专业分数线(--高考时可通用此功能)
|
||||
</summary>
|
||||
<param name="file"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.PlanMajorScoreLineController.Get(New_College.Model.ViewModels.PlanMajorScoreLineRequest)">
|
||||
<summary>
|
||||
获取学校专业分数线
|
||||
|
|
|
|||
|
|
@ -0,0 +1,159 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using NPOI.SS.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Common
|
||||
{
|
||||
public class ExcelProUtil<T> where T : new()
|
||||
{ //合法文件扩展名
|
||||
private static List<string> extName = new List<string>() { ".xls", ".xlsx" };
|
||||
/// <summary>
|
||||
/// 导入Excel内容读取到List<T>中
|
||||
/// </summary>
|
||||
/// <param name="file">导入Execl文件</param>
|
||||
/// <param name="sheetName">指定读取excel工作薄sheet的名称</param>
|
||||
/// <returns>List<T></returns>
|
||||
public static List<T> InputExcel(IFormFile file, string sheetName = null)
|
||||
{
|
||||
//获取文件后缀名
|
||||
string type = Path.GetExtension(file.FileName);
|
||||
//判断是否导入合法文件
|
||||
if (!extName.Contains(type))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//转成为文件流
|
||||
MemoryStream ms = new MemoryStream();
|
||||
file.CopyTo(ms);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
//实例化T数组
|
||||
List<T> list = new List<T>();
|
||||
//获取数据
|
||||
list = InputExcel(ms, sheetName);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将Excel文件内容读取到List<T>中
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件完整路径名</param>
|
||||
/// <param name="sheetName">指定读取excel工作薄sheet的名称</param>
|
||||
/// <returns>List<T></returns>
|
||||
public static List<T> InputExcel(string fileName, string sheetName = null)
|
||||
{
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//根据指定路径读取文件
|
||||
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
||||
//实例化T数组
|
||||
List<T> list = new List<T>();
|
||||
//获取数据
|
||||
list = InputExcel(fs, sheetName);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将Excel文件内容读取到List<T>中
|
||||
/// </summary>
|
||||
/// <param name="fileStream">文件流</param>
|
||||
/// <param name="sheetName">指定读取excel工作薄sheet的名称</param>
|
||||
/// <returns>List<T></returns>
|
||||
private static List<T> InputExcel(Stream fileStream, string sheetName = null)
|
||||
{
|
||||
//创建Excel数据结构
|
||||
IWorkbook workbook = WorkbookFactory.Create(fileStream);
|
||||
//如果有指定工作表名称
|
||||
ISheet sheet = null;
|
||||
if (!string.IsNullOrEmpty(sheetName))
|
||||
{
|
||||
sheet = workbook.GetSheet(sheetName);
|
||||
//如果没有找到指定的sheetName对应的sheet,则尝试获取第一个sheet
|
||||
if (sheet == null)
|
||||
{
|
||||
sheet = workbook.GetSheetAt(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果没有指定的sheetName,则尝试获取第一个sheet
|
||||
sheet = workbook.GetSheetAt(0);
|
||||
}
|
||||
//实例化T数组
|
||||
List<T> list = new List<T>();
|
||||
if (sheet != null)
|
||||
{
|
||||
//一行最后一个cell的编号 即总的列数
|
||||
IRow cellNum = sheet.GetRow(0);
|
||||
int num = cellNum.LastCellNum;
|
||||
//获取泛型对象T的所有属性
|
||||
var propertys = typeof(T).GetProperties();
|
||||
//每行转换为单个T对象
|
||||
for (int i = 1; i <= sheet.LastRowNum; i++)
|
||||
{
|
||||
IRow row = sheet.GetRow(i);
|
||||
var obj = new T();
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
//没有数据的单元格都默认是null
|
||||
ICell cell = row.GetCell(j);
|
||||
if (cell != null)
|
||||
{
|
||||
var value = row.GetCell(j).ToString();
|
||||
string str = (propertys[j].PropertyType).FullName;
|
||||
if (str == "System.String")
|
||||
{
|
||||
propertys[j].SetValue(obj, value, null);
|
||||
}
|
||||
else if (str == "System.DateTime")
|
||||
{
|
||||
DateTime pdt = Convert.ToDateTime(value, CultureInfo.InvariantCulture);
|
||||
propertys[j].SetValue(obj, pdt, null);
|
||||
}
|
||||
else if (str == "System.Boolean")
|
||||
{
|
||||
bool pb = Convert.ToBoolean(value);
|
||||
propertys[j].SetValue(obj, pb, null);
|
||||
}
|
||||
else if (str == "System.Int16")
|
||||
{
|
||||
short pi16 = Convert.ToInt16(value);
|
||||
propertys[j].SetValue(obj, pi16, null);
|
||||
}
|
||||
else if (str == "System.Int32")
|
||||
{
|
||||
int pi32 = Convert.ToInt32(value);
|
||||
propertys[j].SetValue(obj, pi32, null);
|
||||
}
|
||||
else if (str == "System.Int64")
|
||||
{
|
||||
long pi64 = Convert.ToInt64(value);
|
||||
propertys[j].SetValue(obj, pi64, null);
|
||||
}
|
||||
else if (str == "System.Byte")
|
||||
{
|
||||
byte pb = Convert.ToByte(value);
|
||||
propertys[j].SetValue(obj, pb, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
propertys[j].SetValue(obj, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(obj);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -139,5 +139,8 @@ namespace New_College.Common.Excel
|
|||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace New_College.Common
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// 冲稳保百分比
|
||||
/// 冲稳保百分比(逻辑待调整)
|
||||
/// </summary>
|
||||
/// <param name="LowScore"></param>
|
||||
/// <param name="requestScore"></param>
|
||||
|
|
@ -27,7 +27,7 @@ namespace New_College.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 冲稳保计算
|
||||
/// 冲稳保计算(逻辑待调整)
|
||||
/// </summary>
|
||||
/// <param name="score"></param>
|
||||
/// <returns></returns>
|
||||
|
|
@ -36,7 +36,7 @@ namespace New_College.Common
|
|||
int minscore = requestScore - 15;//最小
|
||||
int constscore = requestScore;//中位数
|
||||
int maxscore = requestScore + 15;//最大
|
||||
int type = LowScore <= minscore ? 0 : minscore < LowScore && LowScore <= constscore ? 1 : LowScore > constscore && LowScore <= maxscore ? 2 : -1;
|
||||
int type = LowScore <= minscore ? 0 : minscore < LowScore && LowScore <= constscore ? 1 : LowScore > constscore && LowScore <= maxscore ? 2 : 0;
|
||||
|
||||
return type;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,4 +85,20 @@ namespace New_College.Model.ViewModels
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ImportPlanMajorScoreRequest
|
||||
{
|
||||
public string Major { get; set; }
|
||||
public string UniversityName { get; set; }
|
||||
public string PlanCount { get; set; }
|
||||
public string LowScoreRank { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace New_College.Model.ViewModels
|
|||
{
|
||||
public int CustomerId { get; set; }
|
||||
|
||||
public int? Score { get; set; }
|
||||
public List<VolunteerDetail> details { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ namespace New_College.Model.ViewModels
|
|||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
public int Type { get; set; }
|
||||
|
||||
public int Percentage { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ namespace New_College.Repository
|
|||
.Select(p => new UniversityEnrollmentPlanResult()
|
||||
{
|
||||
UniversityId = p.UId,
|
||||
PlanId = p.Id
|
||||
PlanId = p.Id,
|
||||
// Scoreline = p.LowScore
|
||||
})
|
||||
.ToListAsync();
|
||||
var universitylist = recommendInfo.Select(c => c.UniversityId).Distinct().ToList();
|
||||
|
|
@ -106,7 +107,7 @@ namespace New_College.Repository
|
|||
response.Add(new UniversityMapMajorItems()
|
||||
{
|
||||
UId = a,
|
||||
MIds = recommendInfo.Where(e => e.UniversityId == a && e.Scoreline > 0).Select(c => c.PlanId).ToList()
|
||||
MIds = recommendInfo.Where(e => e.UniversityId == a).Select(c => c.PlanId).ToList()
|
||||
});
|
||||
});
|
||||
return new MessageModel<List<UniversityMapMajorItems>>() { response = response };
|
||||
|
|
|
|||
|
|
@ -1255,7 +1255,7 @@ namespace New_College.Services
|
|||
Syl = nowuniversityinfo.Syl > 0,
|
||||
UniversityId = item.UniversityId,
|
||||
UniversityName = item.UniversityName,
|
||||
UniversityCode = nowdesc.Any()?nowdesc.FirstOrDefault().EnrollmentCode:"",
|
||||
UniversityCode = nowdesc.Any() ? nowdesc.FirstOrDefault().EnrollmentCode : "",
|
||||
Province = nowuniversityinfo.Area_Name,
|
||||
Nature = nowuniversityinfo.Nature,
|
||||
Infos = nowdesc.Select(x => new PlanInfo()
|
||||
|
|
@ -1267,7 +1267,9 @@ namespace New_College.Services
|
|||
PlanNum = x.PlanCount,
|
||||
Scoreline = x.LowScore == 0 ? "-" : x.LowScore.ToString(),
|
||||
LowScoreRank = x.LowScoreRank == 0 ? "-" : x.LowScoreRank.ToString(),
|
||||
YearName = yearName
|
||||
YearName = yearName,
|
||||
Type = query.Score.HasValue ? MajorPlanScoreTool.GetPlanScore(x.LowScore, query.Score.Value) : 0,//还缺冲稳保
|
||||
Percentage = query.Score.HasValue ? MajorPlanScoreTool.GetPlanPercentage(x.LowScore, query.Score.Value) : 0,
|
||||
}).ToList()
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue