|
@@ -1,5 +1,6 @@
|
|
using Azure.Cosmos;
|
|
using Azure.Cosmos;
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
|
+using DocumentFormat.OpenXml.Office2013.Drawing.Chart;
|
|
using HTEXLib.COMM.Helpers;
|
|
using HTEXLib.COMM.Helpers;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
@@ -139,6 +140,7 @@ namespace TEAMModelOS.Controllers
|
|
json.TryGetProperty("year", out JsonElement _year);
|
|
json.TryGetProperty("year", out JsonElement _year);
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_school}", new PartitionKey("Base"));
|
|
School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_school}", new PartitionKey("Base"));
|
|
|
|
+ SchoolSetting schoolSetting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolSetting>($"{_school}", new PartitionKey("SchoolSetting"));
|
|
Dictionary<string, object> dict = OverallEducationService.GetQueryCond(json);
|
|
Dictionary<string, object> dict = OverallEducationService.GetQueryCond(json);
|
|
#region 此处代码用于处理 根据年级 学段获取 相关的班级。
|
|
#region 此处代码用于处理 根据年级 学段获取 相关的班级。
|
|
List<int > years = null ;
|
|
List<int > years = null ;
|
|
@@ -186,14 +188,237 @@ namespace TEAMModelOS.Controllers
|
|
string oesql = $"select value c from c where c.semesterId='{_semesterId}' and c.year={_year} and c.periodId='{_periodId}' " +
|
|
string oesql = $"select value c from c where c.semesterId='{_semesterId}' and c.year={_year} and c.periodId='{_periodId}' " +
|
|
$"and c.classId in {string.Join(",",classes.Select(z=>$"'{z}'"))} ";
|
|
$"and c.classId in {string.Join(",",classes.Select(z=>$"'{z}'"))} ";
|
|
var oeresults = await client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<OverallEducation>(oesql, $"OverallEducation-{_school}");
|
|
var oeresults = await client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<OverallEducation>(oesql, $"OverallEducation-{_school}");
|
|
- double excellence_count = 0;
|
|
|
|
- double pass_Count = 0;
|
|
|
|
double dataCount = 0;
|
|
double dataCount = 0;
|
|
|
|
+ double sports_count90 = 0;
|
|
|
|
+ double sports_count60 = 0;
|
|
|
|
+ double sports_count = 0;
|
|
|
|
+ double art_count90 = 0;
|
|
|
|
+ double art_count60 = 0;
|
|
|
|
+ double art_count = 0;
|
|
|
|
+ double intelligence_count90 = 0;
|
|
|
|
+ double intelligence_count60 = 0;
|
|
|
|
+ double intelligence_count = 0;
|
|
|
|
+ double labour_count90 = 0;
|
|
|
|
+ double labour_count60 = 0;
|
|
|
|
+ double labour_count = 0;
|
|
|
|
+ double virtue_count90 = 0;
|
|
|
|
+ double virtue_count60 = 0;
|
|
|
|
+ double virtue_count = 0;
|
|
|
|
+ List<(double score, OverallEducation student)> ranking = new List<(double score, OverallEducation student)>();
|
|
|
|
+ List<(string classId, double last, double best, double sum, double avg)> classDatas = new List<(string classId, double last, double best, double sum, double avg)>();
|
|
if (oeresults.list.IsNotEmpty()) {
|
|
if (oeresults.list.IsNotEmpty()) {
|
|
- dataCount=oeresults.list.Count();
|
|
|
|
|
|
+ dataCount = oeresults.list.Count();
|
|
|
|
+
|
|
|
|
+ oeresults.list.ForEach(z => {
|
|
|
|
+ double score = 0;
|
|
|
|
+ //体育
|
|
|
|
+ {
|
|
|
|
+ if (schoolSetting.overallEducationSetting.sports.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ score += z.sports.Average(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.sports.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ score += z.sports.OrderByDescending(x => x.examDate).First().sumScore;
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.sports.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ score += z.sports.Sum(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //劳动
|
|
|
|
+ {
|
|
|
|
+ if (schoolSetting.overallEducationSetting.labour.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ score += z.labour.Average(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.labour.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ score += z.labour.OrderByDescending(x => x.examDate).First().sumScore;
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.labour.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ score += z.labour.Sum(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //智育
|
|
|
|
+ {
|
|
|
|
+ if (schoolSetting.overallEducationSetting.intelligence.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ score += z.intelligence.Average(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.intelligence.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ score += z.intelligence.OrderByDescending(x => x.examDate).First().sumScore;
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.intelligence.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ score += z.intelligence.Sum(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //艺术
|
|
|
|
+ {
|
|
|
|
+ if (schoolSetting.overallEducationSetting.art.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ score += z.art.Average(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.art.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ score += z.art.OrderByDescending(x => x.examDate).First().sumScore;
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.art.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ score += z.art.Sum(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //德育
|
|
|
|
+ {
|
|
|
|
+ if (schoolSetting.overallEducationSetting.virtue.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ score += z.virtue.Average(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.virtue.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ score += z.virtue.OrderByDescending(x => x.examDate).First().sumScore;
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.virtue.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ score += z.virtue.Sum(x => x.sumScore);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ranking.Add((score, z));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var classGroup= ranking.GroupBy(x => x.student.classId).Select(g => new {key = g.Key,list = g.ToList()});
|
|
|
|
+ classGroup.ToList().ForEach(x => {
|
|
|
|
+ var key = x.key;
|
|
|
|
+ var sort = x.list.OrderBy(o => o.score);
|
|
|
|
+ double last = sort.First().score;
|
|
|
|
+ double best = sort.Last().score;
|
|
|
|
+ double sum = x.list.Select(s => s.score).Sum();
|
|
|
|
+ double avg = x.list.Count()>0 ? sum/x.list.Count():0;
|
|
|
|
+ classDatas.Add((key, last, best, sum, avg));
|
|
|
|
+ });
|
|
|
|
+ ranking= ranking.OrderByDescending(x=>x.score).Take(10).ToList();
|
|
|
|
+ #region 体育
|
|
|
|
+ sports_count = oeresults.list.Where(z => z.sports.IsNotEmpty()).Count();
|
|
|
|
+ if (schoolSetting.overallEducationSetting.sports.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ sports_count90 = oeresults.list.Where(z => z.sports.IsNotEmpty() && z.sports.Average(x => x.sumScore) >= 90).Count();
|
|
|
|
+ sports_count60 = oeresults.list.Where(z => z.sports.IsNotEmpty() && z.sports.Average(x => x.sumScore) >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.sports.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ sports_count90 = oeresults.list.Where(z => z.sports.IsNotEmpty() && z.sports.OrderByDescending(x => x.examDate).First().sumScore >= 90).Count();
|
|
|
|
+ sports_count60 = oeresults.list.Where(z => z.sports.IsNotEmpty() && z.sports.OrderByDescending(x => x.examDate).First().sumScore >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.sports.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ sports_count90 = oeresults.list.Where(z => z.sports.IsNotEmpty() && z.sports.Sum(x => x.sumScore) >= 90).Count();
|
|
|
|
+ sports_count60 = oeresults.list.Where(z => z.sports.IsNotEmpty() && z.sports.Sum(x => x.sumScore) >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ #region 艺术
|
|
|
|
+ art_count = oeresults.list.Where(z => z.art.IsNotEmpty()).Count();
|
|
|
|
+ if (schoolSetting.overallEducationSetting.art.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ art_count90 = oeresults.list.Where(z => z.art.IsNotEmpty() && z.art.Average(x => x.sumScore) >= 90).Count();
|
|
|
|
+ art_count60 = oeresults.list.Where(z => z.art.IsNotEmpty() && z.art.Average(x => x.sumScore) >= 60).Count();
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.art.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ art_count90 = oeresults.list.Where(z => z.art.IsNotEmpty() && z.art.OrderByDescending(x => x.examDate).First().sumScore >= 90).Count();
|
|
|
|
+ art_count60 = oeresults.list.Where(z => z.art.IsNotEmpty() && z.art.OrderByDescending(x => x.examDate).First().sumScore >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.art.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ art_count90 = oeresults.list.Where(z => z.art.IsNotEmpty() && z.art.Sum(x => x.sumScore) >= 90).Count();
|
|
|
|
+ art_count60 = oeresults.list.Where(z => z.art.IsNotEmpty() && z.art.Sum(x => x.sumScore) >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ #region 智育
|
|
|
|
+ intelligence_count = oeresults.list.Where(z => z.intelligence.IsNotEmpty()).Count();
|
|
|
|
+ if (schoolSetting.overallEducationSetting.intelligence.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ intelligence_count90 = oeresults.list.Where(z => z.intelligence.IsNotEmpty() && z.intelligence.Average(x => x.sumScore) >= 90).Count();
|
|
|
|
+ intelligence_count60 = oeresults.list.Where(z => z.intelligence.IsNotEmpty() && z.intelligence.Average(x => x.sumScore) >= 60).Count();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.intelligence.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ intelligence_count90 = oeresults.list.Where(z => z.intelligence.IsNotEmpty() && z.intelligence.OrderByDescending(x => x.examDate).First().sumScore >= 90).Count();
|
|
|
|
+ intelligence_count60 = oeresults.list.Where(z => z.intelligence.IsNotEmpty() && z.intelligence.OrderByDescending(x => x.examDate).First().sumScore >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.intelligence.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ intelligence_count90 = oeresults.list.Where(z => z.intelligence.IsNotEmpty() && z.intelligence.Sum(x => x.sumScore) >= 90).Count();
|
|
|
|
+ intelligence_count60 = oeresults.list.Where(z => z.intelligence.IsNotEmpty() && z.intelligence.Sum(x => x.sumScore) >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ #region 劳动
|
|
|
|
+ labour_count = oeresults.list.Where(z => z.labour.IsNotEmpty()).Count();
|
|
|
|
+ if (schoolSetting.overallEducationSetting.labour.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ labour_count90 = oeresults.list.Where(z => z.labour.IsNotEmpty() && z.labour.Average(x => x.sumScore) >= 90).Count();
|
|
|
|
+ labour_count60 = oeresults.list.Where(z => z.labour.IsNotEmpty() && z.labour.Average(x => x.sumScore) >= 60).Count();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.labour.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ labour_count90 = oeresults.list.Where(z => z.labour.IsNotEmpty() && z.labour.OrderByDescending(x => x.examDate).First().sumScore >= 90).Count();
|
|
|
|
+ labour_count60 = oeresults.list.Where(z => z.labour.IsNotEmpty() && z.labour.OrderByDescending(x => x.examDate).First().sumScore >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.labour.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ labour_count90 = oeresults.list.Where(z => z.labour.IsNotEmpty() && z.labour.Sum(x => x.sumScore) >= 90).Count();
|
|
|
|
+ labour_count60 = oeresults.list.Where(z => z.labour.IsNotEmpty() && z.labour.Sum(x => x.sumScore) >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ #region 德育
|
|
|
|
+ virtue_count = oeresults.list.Where(z => z.virtue.IsNotEmpty()).Count();
|
|
|
|
+ if (schoolSetting.overallEducationSetting.virtue.Equals("avg"))
|
|
|
|
+ {
|
|
|
|
+ virtue_count90 = oeresults.list.Where(z => z.virtue.IsNotEmpty() && z.virtue.Average(x => x.sumScore) >= 90).Count();
|
|
|
|
+ virtue_count60 = oeresults.list.Where(z => z.virtue.IsNotEmpty() && z.virtue.Average(x => x.sumScore) >= 60).Count();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.virtue.Equals("newest"))
|
|
|
|
+ {
|
|
|
|
+ virtue_count90 = oeresults.list.Where(z => z.virtue.IsNotEmpty() && z.virtue.OrderByDescending(x => x.examDate).First().sumScore >= 90).Count();
|
|
|
|
+ virtue_count60 = oeresults.list.Where(z => z.virtue.IsNotEmpty() && z.virtue.OrderByDescending(x => x.examDate).First().sumScore >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ else if (schoolSetting.overallEducationSetting.virtue.Equals("sum"))
|
|
|
|
+ {
|
|
|
|
+ virtue_count90 = oeresults.list.Where(z => z.virtue.IsNotEmpty() && z.virtue.Sum(x => x.sumScore) >= 90).Count();
|
|
|
|
+ virtue_count60 = oeresults.list.Where(z => z.virtue.IsNotEmpty() && z.virtue.Sum(x => x.sumScore) >= 60).Count();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
}
|
|
}
|
|
- return Ok(new { studentCount ,classCount=classes.Count, grade=years.Count });
|
|
|
|
|
|
+ return Ok(new {
|
|
|
|
+ studentCount,
|
|
|
|
+ classCount = classes.Count,
|
|
|
|
+ gradeCount = years.Count,
|
|
|
|
+ dataCount,
|
|
|
|
+ sports_count60,
|
|
|
|
+ sports_count90,
|
|
|
|
+ art_count60,
|
|
|
|
+ art_count90,
|
|
|
|
+ labour_count60,
|
|
|
|
+ labour_count90,
|
|
|
|
+ virtue_count60,
|
|
|
|
+ virtue_count90,
|
|
|
|
+ intelligence_count60,
|
|
|
|
+ intelligence_count90,
|
|
|
|
+ sports_count,
|
|
|
|
+ art_count,
|
|
|
|
+ intelligence_count,
|
|
|
|
+ virtue_count,
|
|
|
|
+ labour_count,
|
|
|
|
+ ranking=ranking.Select(x=>new { score=x.score,student=x.student }),
|
|
|
|
+ classDatas= classDatas.Select(z=>new { z.classId,z.last,z.best,z.avg})
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|