新增 考试流程接口
This commit is contained in:
parent
43af37af88
commit
549ec66f80
|
|
@ -0,0 +1,121 @@
|
||||||
|
using MiniExcelLibs.Attributes;
|
||||||
|
|
||||||
|
namespace Learn.Archives.API.Controllers.Dto
|
||||||
|
{
|
||||||
|
public class ImportDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 导入文件
|
||||||
|
/// </summary>
|
||||||
|
public IFormFile? File { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 考试id
|
||||||
|
/// </summary>
|
||||||
|
public long eId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 导入的错误结果
|
||||||
|
/// </summary>
|
||||||
|
public class ImportExamInfoError: ImportExamInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 学校
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("错误信息")]
|
||||||
|
public string? Error { get; set; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 导入考试成绩
|
||||||
|
/// </summary>
|
||||||
|
public class ImportExamInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 学校
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("学校")]
|
||||||
|
public string School { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 年级
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("年级")]
|
||||||
|
public string Grade { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 云校班级号
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("云校班级号")]
|
||||||
|
public string Class { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("班级类型")]
|
||||||
|
public string ClassType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 学生姓名0.
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("学生姓名")]
|
||||||
|
public string Student { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 语文
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("语文")]
|
||||||
|
public decimal 语文 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数学
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("数学")]
|
||||||
|
public decimal 数学 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 英语
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("英语")]
|
||||||
|
public decimal 英语 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物理
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("物理")]
|
||||||
|
public decimal 物理 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 化学
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("化学")]
|
||||||
|
public decimal 化学 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生物
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("生物")]
|
||||||
|
public decimal 生物 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 政治
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("政治")]
|
||||||
|
public decimal 政治 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 历史
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("历史")]
|
||||||
|
public decimal 历史 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 地理
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("地理")]
|
||||||
|
public decimal 地理 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 赋分后总分
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnName("赋分后总分")]
|
||||||
|
public decimal 赋分后总分 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,229 @@
|
||||||
|
using Learn.Archives.API.Controllers.Dto;
|
||||||
|
using Learn.Archives.API.Expand;
|
||||||
|
using Learn.Archives.Core.Common;
|
||||||
|
using Learn.Archives.Core.Model;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using MiniExcelLibs;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using UserCenter.Model;
|
||||||
|
using UserCenter.Model.Common;
|
||||||
|
using UserCenter.Model.Enum;
|
||||||
|
|
||||||
|
namespace Learn.Archives.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 年级控制器
|
||||||
|
/// </summary>
|
||||||
|
public class ExamClassInfoController : BackController<ExamClassInfo>
|
||||||
|
{
|
||||||
|
readonly Repository<ExamClassInfo> baseService;
|
||||||
|
readonly Repository<Exam> examService;
|
||||||
|
readonly Repository<School> schoolService;
|
||||||
|
readonly Repository<ExamUserInfo> examUserInfoService;
|
||||||
|
readonly LiveUserInfo userInfo;
|
||||||
|
readonly IHttpContextAccessor accessor;
|
||||||
|
public ExamClassInfoController(Repository<ExamClassInfo> baseService, LiveUserInfo userInfo, IHttpContextAccessor httpContext, Repository<ExamUserInfo> examUserInfoService, Repository<Exam> examService, Repository<School> schoolService) : base(baseService)
|
||||||
|
{
|
||||||
|
this.baseService = baseService;
|
||||||
|
this.userInfo = userInfo;
|
||||||
|
this.accessor = httpContext;
|
||||||
|
this.examUserInfoService = examUserInfoService;
|
||||||
|
this.examService = examService;
|
||||||
|
this.schoolService = schoolService;
|
||||||
|
}
|
||||||
|
[NonAction]
|
||||||
|
private Dictionary<SubjectEnum, decimal>? ImportExamInfoSubjectDic(ImportExamInfo info)
|
||||||
|
{
|
||||||
|
return new Dictionary<SubjectEnum, decimal>()
|
||||||
|
{
|
||||||
|
{ SubjectEnum.语文, info.语文},
|
||||||
|
{ SubjectEnum.数学, info.数学},
|
||||||
|
{ SubjectEnum.英语, info.英语},
|
||||||
|
{ SubjectEnum.物理, info.物理},
|
||||||
|
{ SubjectEnum.化学, info.化学},
|
||||||
|
{ SubjectEnum.生物, info.生物},
|
||||||
|
{ SubjectEnum.政治, info.政治},
|
||||||
|
{ SubjectEnum.历史, info.历史},
|
||||||
|
{ SubjectEnum.地理, info.地理},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 导入考试信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, ResultIgnore]
|
||||||
|
[HttpLogEnable]
|
||||||
|
public async Task<IActionResult> Import(ImportDto dto)
|
||||||
|
{
|
||||||
|
var exam = await examService.GetByIdAsync(dto.eId);
|
||||||
|
var fl = dto.File!=null? dto .File: accessor.HttpContext?.Request.Form.Files[0];
|
||||||
|
if (exam == null || fl == null) Oh.ModelError("为传入有效的数据");
|
||||||
|
if (!Path.GetExtension(fl.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
|
||||||
|
Oh.ModelError("请选择导入文件为.xlsx的后缀名!");
|
||||||
|
//分析excel
|
||||||
|
IEnumerable<ImportExamInfoError> dataList;
|
||||||
|
using var stream = new MemoryStream();
|
||||||
|
{
|
||||||
|
await fl.CopyToAsync(stream);
|
||||||
|
dataList = stream.Query<ImportExamInfoError>()
|
||||||
|
.Where(s => string.IsNullOrEmpty(s.Student));
|
||||||
|
}
|
||||||
|
if (dataList == null || dataList.Count() == 0)
|
||||||
|
Oh.ModelError("导入失败:无有效数据");
|
||||||
|
//处理数据
|
||||||
|
var errorExcelInfo = new List<ImportExamInfoError>();
|
||||||
|
var insertUserInfo = new List<ExamUserInfo>();
|
||||||
|
var insertClassInfo = new List<ExamClassInfo>();
|
||||||
|
var db = schoolService.Context;
|
||||||
|
foreach (var schoolArr in dataList.GroupBy(s => s.School))
|
||||||
|
{
|
||||||
|
var school = await schoolService.GetFirstAsync(s => s.Name == schoolArr.Key);
|
||||||
|
if (school == null) Oh.ModelError($"导入失败:学校 [{schoolArr.Key}] 未找到!");
|
||||||
|
var gradeInfo = GradeHelper.GetStudentGradeBaseByGrade(schoolArr.First().Grade);
|
||||||
|
if (gradeInfo == null) Oh.ModelError($"导入失败:学校 [{schoolArr.Key}] 年级[{schoolArr.First().Grade}]不符合规范!");
|
||||||
|
//学校下的所属班级
|
||||||
|
var classArr = await db.Queryable<Classes>().Where(c => c.SchoolId == school.Id &&
|
||||||
|
c.GradeLevel == gradeInfo.GradeLevel &&
|
||||||
|
c.GraduationYear == gradeInfo.GradeYear && !c.DeleteState).ToArrayAsync();
|
||||||
|
var userDic = await db.Queryable<School>()
|
||||||
|
.InnerJoin<Classes>((s, c) => c.SchoolId == s.Id)
|
||||||
|
.InnerJoin<Position>((s, c, p) => p.ClassId == c.Id)
|
||||||
|
.InnerJoin<PositionRelation>((s, c, p, pr) => pr.PositionId == p.Id)
|
||||||
|
.InnerJoin<User>((s, c, p, pr, u) => u.Id == pr.UserId)
|
||||||
|
.Where((s, c, p, pr, u) =>
|
||||||
|
s.Id == school.Id &&
|
||||||
|
c.GradeLevel == gradeInfo.GradeLevel &&
|
||||||
|
c.GraduationYear == gradeInfo.GradeYear &&
|
||||||
|
s.Enable && p.Enable && pr.Enable &&
|
||||||
|
p.DeleteState != false && c.DeleteState != false && u.DeleteState != false && s.DeleteState != false)
|
||||||
|
.Select((s, c, p, pr, u) => new
|
||||||
|
{
|
||||||
|
Name = c.Name + c.Type.ToString() + u.RealName,
|
||||||
|
u.Id,
|
||||||
|
}).ToDictionaryAsync(s => s.Id, s => s.Name);
|
||||||
|
//处理学生成绩数据
|
||||||
|
var userList = dataList.Select(s =>
|
||||||
|
{
|
||||||
|
var classInfo = classArr
|
||||||
|
.FirstOrDefault(x => x.Name == s.Class && x.Type == s.ClassType.ToEnum<ClassTypeEnum>());
|
||||||
|
if (classInfo == null)
|
||||||
|
{
|
||||||
|
s.Error = "未能匹配班级";
|
||||||
|
errorExcelInfo.Add(s);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var grade = GradeHelper.GetStudentGradeBaseByGrade(s.Grade);
|
||||||
|
var sub = ImportExamInfoSubjectDic(s);
|
||||||
|
var name = s.Class + s.ClassType.ToEnum<ClassTypeEnum>().GetHashCode() + s.Student;
|
||||||
|
if (userDic.ContainsKey(name))
|
||||||
|
{
|
||||||
|
s.Error = "未能匹配到年级班级下对应的学生";
|
||||||
|
errorExcelInfo.Add(s);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var uid = userDic[name];
|
||||||
|
return new ExamUserInfo()
|
||||||
|
{
|
||||||
|
ExamId = exam.Id,
|
||||||
|
ExamName = exam.Name,
|
||||||
|
GradeYear = grade.GradeYear,
|
||||||
|
GradeLevel = grade.GradeLevel,
|
||||||
|
TestPaperType = exam.TestPaperType,
|
||||||
|
UserId = (long)userDic[name],
|
||||||
|
ClassId = classInfo.Id,
|
||||||
|
SchoolId = classInfo.SchoolId,
|
||||||
|
Type = exam.Type,
|
||||||
|
SubjectDic = sub,
|
||||||
|
AssignScore = s.赋分后总分,
|
||||||
|
AssignRanking = 0,
|
||||||
|
};
|
||||||
|
}).ToList();
|
||||||
|
insertUserInfo.AddRange(userList);
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var classUserArr in insertUserInfo.GroupBy(s => s.ClassId))
|
||||||
|
{
|
||||||
|
var classInfo = classArr.First(s => s.Id == classUserArr.Key);
|
||||||
|
var eCInfo = new ExamClassInfo()
|
||||||
|
{
|
||||||
|
ExamId = exam.Id,
|
||||||
|
ExamName = exam.Name,
|
||||||
|
SchoolId = classInfo.SchoolId,
|
||||||
|
SchoolName = school.Name,
|
||||||
|
ClassId = classInfo.Id,
|
||||||
|
ClassName = classInfo.Name,
|
||||||
|
GradeLevel = classInfo.GradeLevel,
|
||||||
|
GradeYear = classInfo.GraduationYear,
|
||||||
|
PeopleCount = classUserArr.Count(),
|
||||||
|
MinScore = int.MaxValue,
|
||||||
|
EntryPersonId = userInfo.Id,
|
||||||
|
EntryPerson = userInfo.Name,
|
||||||
|
};
|
||||||
|
insertClassInfo.Add(eCInfo);
|
||||||
|
var avgTotal = 0m;
|
||||||
|
foreach (var eUserInfo in classUserArr)
|
||||||
|
{
|
||||||
|
var v = eUserInfo.AssignScore;
|
||||||
|
//上线人数
|
||||||
|
if (v>=exam.ScoreLine)
|
||||||
|
eCInfo.OnLineCount ++;
|
||||||
|
//最大小分
|
||||||
|
if (v < eCInfo.MinScore)
|
||||||
|
eCInfo.MinScore = v;
|
||||||
|
else if(v > eCInfo.MaxScore)
|
||||||
|
eCInfo.MaxScore = v;
|
||||||
|
avgTotal += v;//追加得分
|
||||||
|
}
|
||||||
|
//总分平均分
|
||||||
|
eCInfo.Average = avgTotal / eCInfo.PeopleCount;
|
||||||
|
//计算上线率
|
||||||
|
eCInfo.OnLineRate = eCInfo.OnLineCount / eCInfo.PeopleCount;
|
||||||
|
//处理学生班级排名
|
||||||
|
var i = 0;
|
||||||
|
foreach (var item in classUserArr.OrderByDescending(s => s.AssignScore)
|
||||||
|
.GroupBy(s => s.AssignScore))
|
||||||
|
{
|
||||||
|
foreach (var u in item)
|
||||||
|
u.AssignRanking =++ i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
{ //计算年级上线率排名
|
||||||
|
var i = 0;
|
||||||
|
foreach (var item in insertClassInfo.OrderByDescending(s => s.OnLineRate)
|
||||||
|
.GroupBy(s => s.OnLineRate))
|
||||||
|
{
|
||||||
|
foreach (var u in item)
|
||||||
|
u.OnLineRanking = ++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算年级平均分排名
|
||||||
|
i = 0;
|
||||||
|
foreach (var item in insertClassInfo.OrderByDescending(s => s.Average)
|
||||||
|
.GroupBy(s => s.Average))
|
||||||
|
{
|
||||||
|
foreach (var u in item)
|
||||||
|
u.AverageRank = ++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errorExcelInfo.Count != 0)
|
||||||
|
return File(errorExcelInfo.ExportExcel(), "application/ms-excel");
|
||||||
|
|
||||||
|
//写入数据库
|
||||||
|
var baseDB = baseService.Context;
|
||||||
|
baseDB.Ado.BeginTran();
|
||||||
|
await db.Insertable(insertUserInfo).ExecuteCommandAsync();
|
||||||
|
await db.Insertable(insertClassInfo).ExecuteCommandAsync();
|
||||||
|
baseDB.Ado.CommitTran();
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
using Learn.Archives.API.Controllers.Dto;
|
||||||
|
using Learn.Archives.API.Expand;
|
||||||
|
using Learn.Archives.Core.Common;
|
||||||
|
using Learn.Archives.Core.Model;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using UserCenter.Model;
|
||||||
|
|
||||||
|
namespace Learn.Archives.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 年级控制器
|
||||||
|
/// </summary>
|
||||||
|
public class ExamController : BackController<Exam>
|
||||||
|
{
|
||||||
|
readonly Repository<Exam> baseService;
|
||||||
|
readonly LiveUserInfo userInfo;
|
||||||
|
public ExamController(Repository<Exam> baseService, LiveUserInfo userInfo) : base(baseService)
|
||||||
|
{
|
||||||
|
this.baseService = baseService;
|
||||||
|
this.userInfo = userInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
using Learn.Archives.API.Controllers.Dto;
|
||||||
|
using Learn.Archives.API.Expand;
|
||||||
|
using Learn.Archives.Core.Common;
|
||||||
|
using Learn.Archives.Core.Model;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using UserCenter.Model;
|
||||||
|
|
||||||
|
namespace Learn.Archives.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 年级控制器
|
||||||
|
/// </summary>
|
||||||
|
public class ExamUserInfoController : BackController<ExamUserInfo>
|
||||||
|
{
|
||||||
|
readonly Repository<ExamUserInfo> baseService;
|
||||||
|
readonly LiveUserInfo userInfo;
|
||||||
|
public ExamUserInfoController(Repository<ExamUserInfo> baseService, LiveUserInfo userInfo) : base(baseService)
|
||||||
|
{
|
||||||
|
this.baseService = baseService;
|
||||||
|
this.userInfo = userInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />
|
||||||
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.13.0" />
|
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.13.0" />
|
||||||
|
<PackageReference Include="MiniExcel" Version="1.41.3" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.13.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.13.0" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"DB": {
|
"DB": {
|
||||||
"ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=learn.archives;CharSet=utf8mb4;pooling=true;SslMode=None",
|
"ConnectionString": "AllowLoadLocalInfile=true;Server=192.168.2.9;User ID=root;Password=qwe123!@#;Port=3306;Database=learn.archives;CharSet=utf8mb4;pooling=true;SslMode=None",
|
||||||
"SqlType": "MySql",
|
"SqlType": "MySql",
|
||||||
"UpdateTable": false
|
"UpdateTable": true
|
||||||
},
|
},
|
||||||
"AuthKey": {
|
"AuthKey": {
|
||||||
"Secret": "9FAB7AC7-F1DB-4C56-B84F-044055A34AF2",
|
"Secret": "9FAB7AC7-F1DB-4C56-B84F-044055A34AF2",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UserCenter.Model.Interface;
|
using UserCenter.Model.Interface;
|
||||||
|
using MiniExcelLibs;
|
||||||
|
using MiniExcelLibs.OpenXml;
|
||||||
|
|
||||||
namespace Learn.Archives.Core.Common
|
namespace Learn.Archives.Core.Common
|
||||||
{
|
{
|
||||||
|
|
@ -53,8 +55,9 @@ namespace Learn.Archives.Core.Common
|
||||||
|
|
||||||
|
|
||||||
EnumType = Assemblies
|
EnumType = Assemblies
|
||||||
.Where(s => s.FullName.Contains("Model"))
|
.Where(s => s.FullName.Contains("Model")|| s.FullName.Contains("Core"))
|
||||||
.SelectMany(s => s.GetTypes().Where(x => x.IsEnum))
|
.SelectMany(s => s.GetTypes().Where(x => x.IsEnum))
|
||||||
|
.DistinctBy(s=>s.Name)
|
||||||
.ToDictionary(s => s.Name, s => s);
|
.ToDictionary(s => s.Name, s => s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -79,9 +82,18 @@ namespace Learn.Archives.Core.Common
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ExpandFunction
|
public static class ExpandFunction
|
||||||
{
|
{
|
||||||
|
const string SheetName = "Sheet1";
|
||||||
|
public static byte[] ExportExcel(this IEnumerable<object> resultList)
|
||||||
|
{
|
||||||
|
var config = new OpenXmlConfiguration()
|
||||||
|
{
|
||||||
|
TableStyles = TableStyles.None
|
||||||
|
};
|
||||||
|
using var memoryStream = new MemoryStream();
|
||||||
|
memoryStream.SaveAs(resultList, true, SheetName, ExcelType.XLSX, config);
|
||||||
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return memoryStream.ToArray();
|
||||||
|
}
|
||||||
public static string GetMD5(this string input)
|
public static string GetMD5(this string input)
|
||||||
{
|
{
|
||||||
using (MD5 md5 = MD5.Create())
|
using (MD5 md5 = MD5.Create())
|
||||||
|
|
|
||||||
|
|
@ -44,5 +44,13 @@ namespace Learn.Archives.Core.Common
|
||||||
{
|
{
|
||||||
get => long.Parse(_httpContextAccessor.HttpContext?.User.FindFirst(ClaimEnum.Id)?.Value ?? "0");
|
get => long.Parse(_httpContextAccessor.HttpContext?.User.FindFirst(ClaimEnum.Id)?.Value ?? "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 管理员id
|
||||||
|
/// </summary>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimEnum.Name)?.Value??string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
<PackageReference Include="Coravel" Version="6.0.2" />
|
<PackageReference Include="Coravel" Version="6.0.2" />
|
||||||
<PackageReference Include="FreeRedis" Version="1.3.2" />
|
<PackageReference Include="FreeRedis" Version="1.3.2" />
|
||||||
<PackageReference Include="Downloader" Version="3.2.1" />
|
<PackageReference Include="Downloader" Version="3.2.1" />
|
||||||
|
<PackageReference Include="MiniExcel" Version="1.41.3" />
|
||||||
<PackageReference Include="Mapster" Version="7.4.1-pre01" />
|
<PackageReference Include="Mapster" Version="7.4.1-pre01" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.3.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0" />
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,7 @@ namespace Learn.Archives.Core.Model
|
||||||
/// 考试名称
|
/// 考试名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 20)]
|
[SugarColumn(Length = 20)]
|
||||||
public required string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 考试名称
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(Length = 20)]
|
|
||||||
public required string AdminName { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 年级
|
/// 年级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -49,6 +43,7 @@ namespace Learn.Archives.Core.Model
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与班级数量
|
/// 参与班级数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
public int? ClassCount { get; set; }
|
public int? ClassCount { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
|
|
|
||||||
|
|
@ -20,27 +20,27 @@ namespace Learn.Archives.Core.Model
|
||||||
/// 考试Id
|
/// 考试Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 20)]
|
[SugarColumn(Length = 20)]
|
||||||
public required string ExamId { get; set; }
|
public long ExamId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 考试名称
|
/// 考试名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 20)]
|
[SugarColumn(Length = 20)]
|
||||||
public required string ExamName { get; set; }
|
public string ExamName { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 考试班级名称
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(Length = 20)]
|
|
||||||
public required string ClassName { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 考试班级id
|
/// 考试班级id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long ClassId { get; set; }
|
public long ClassId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 考试班级名称
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 20)]
|
||||||
|
public string ClassName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 考试班级所属学校ID
|
/// 考试班级所属学校ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 20)]
|
[SugarColumn(Length = 20)]
|
||||||
public required string SchoolName { get; set; }
|
public string SchoolName { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 考试班级所属学校名称
|
/// 考试班级所属学校名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -49,7 +49,7 @@ namespace Learn.Archives.Core.Model
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 年级
|
/// 年级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GradeLevelEnum GradeLevel { get; set; }
|
public string GradeLevel { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 毕业年份 毕业届
|
/// 毕业年份 毕业届
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -71,6 +71,42 @@ namespace Learn.Archives.Core.Model
|
||||||
/// 参加人数
|
/// 参加人数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int PeopleCount { get; set; }
|
public int PeopleCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最高分(赋分)
|
||||||
|
/// </summary>
|
||||||
|
public decimal MaxScore { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最低分(赋分)
|
||||||
|
/// </summary>
|
||||||
|
public decimal MinScore { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 平均分(赋分)
|
||||||
|
/// </summary>
|
||||||
|
public decimal Average { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 平均分排名(赋分)
|
||||||
|
/// </summary>
|
||||||
|
public decimal AverageRank { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源校平均分
|
||||||
|
/// </summary>
|
||||||
|
public decimal Average1 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 资源校平均分 排名
|
||||||
|
/// </summary>
|
||||||
|
public decimal AverageRank1 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 录入人Id
|
||||||
|
/// </summary>
|
||||||
|
public long EntryPersonId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 录入人名称
|
||||||
|
/// </summary>
|
||||||
|
public string EntryPerson { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,22 @@ namespace Learn.Archives.Core.Model
|
||||||
/// 考试Id
|
/// 考试Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 20)]
|
[SugarColumn(Length = 20)]
|
||||||
public required string ExamId { get; set; }
|
public long ExamId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 考试名称
|
/// 考试名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 20)]
|
[SugarColumn(Length = 20)]
|
||||||
public required string ExamName { get; set; }
|
public string ExamName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毕业届
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 4)]
|
||||||
|
public int GradeYear { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 年级
|
/// 年级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 12)]
|
public string GradeLevel { get; set; }
|
||||||
public GradeEnum Level { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 试卷类型
|
/// 试卷类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -48,6 +52,17 @@ namespace Learn.Archives.Core.Model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 班级id
|
||||||
|
/// 来自<see cref="ClassId.Id"/>
|
||||||
|
/// </summary>
|
||||||
|
public long ClassId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 学校id
|
||||||
|
/// 来自<see cref="SchoolId.Id"/>
|
||||||
|
/// </summary>
|
||||||
|
public long SchoolId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 赋分后的总分
|
/// 赋分后的总分
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue