64 lines
2.8 KiB
C#
64 lines
2.8 KiB
C#
using Competition.Common.Util;
|
|
using CompetitionAPI.api.back;
|
|
using CompetitionAPI.Util;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CompetitionAPI.Controllers.back.analysis
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class GetEndExamController : Controller
|
|
{
|
|
Competition.Mysql.BLL.pow_exam exam_bll = new Competition.Mysql.BLL.pow_exam();
|
|
|
|
Competition.Mysql.BLL.pow_achievement achievement_bll = new Competition.Mysql.BLL.pow_achievement();
|
|
|
|
public GetEndExamController()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 各个考试的良中优学生数量
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
[APIFilter]
|
|
public JsonResult Index()
|
|
{
|
|
try
|
|
{
|
|
var res = new List<GetEndExamResponse>();
|
|
var achievement_list = achievement_bll.GetExamList(" T2.`Status`='已结束' and T2.Type='考试' order by T2.CreateTime desc ");
|
|
var exam_list = achievement_list.GroupBy(a => a.ExamId).ToList();
|
|
foreach (var item in exam_list)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.Key))
|
|
{
|
|
var exam_model = achievement_list.Where(a => a.ExamId == item.Key).FirstOrDefault();
|
|
var model = new GetEndExamResponse();
|
|
model.ExamId = exam_model.ExamId;
|
|
model.ExamName = exam_model.ExamName;
|
|
var excellent_count = achievement_list.Where(a => a.ExamId == exam_model.ExamId && a.TotalScore >= 90 && a.TotalScore <= 100).Count();
|
|
var good_count = achievement_list.Where(a => a.ExamId == exam_model.ExamId && a.TotalScore >= 75 && a.TotalScore <= 89).Count();
|
|
var secondary_count = achievement_list.Where(a => a.ExamId == exam_model.ExamId && a.TotalScore >= 60 && a.TotalScore <= 74).Count();
|
|
var poor_count = achievement_list.Where(a => a.ExamId == exam_model.ExamId && a.TotalScore < 60).Count();
|
|
var data = new ScoreStatisticsData() { ExcellentCount = excellent_count, GoodCount = good_count, SecondaryCount = secondary_count, PoorCount = poor_count };
|
|
model.Data = data;
|
|
res.Add(model);
|
|
}
|
|
}
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, res));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|