|
@@ -296,7 +296,9 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public async Task<IActionResult> GetAreaStics(JsonElement jsonElement)
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ var (dayStart, dayEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow);
|
|
|
var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
|
|
|
+ var (monthStart, monthEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
|
|
|
var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term");
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
@@ -330,8 +332,17 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
int heCount = 0; //高教
|
|
|
int oeCount = 0; //其他教育
|
|
|
|
|
|
+ int dayLess = 0; //当天课例
|
|
|
+ int weekLess = 0; //周课例
|
|
|
+ int monthLess = 0; //月课例
|
|
|
+ int termLess = 0; //学期课例
|
|
|
+ double teachCount = 0; //课例教师
|
|
|
+
|
|
|
List<SchoolLesson> schoolLessons = new(); //学校课例集合
|
|
|
- List<SchoolInfo> schoolInfos = new();
|
|
|
+ List<SchoolInfo> schoolInfos = new();
|
|
|
+ List<LessonRecord> records = new();//所有的课程记录
|
|
|
+
|
|
|
+ List<string> scIds = schools.Select(x => x.id).ToList();
|
|
|
|
|
|
int totalTime = 0;
|
|
|
foreach (var school in schools)
|
|
@@ -372,6 +383,12 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
standard += 1;
|
|
|
else basics += 1;
|
|
|
|
|
|
+ string sqlTxt = $"select value(c) from c where c.code='LessonRecord-{school}'";
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
|
|
|
+ {
|
|
|
+ records.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
//课例
|
|
|
int lessCount = await CommonFind.FindTotals(cosmosClient, "select count(c.id) totals from c", "School", $"LessonRecord-{school.id}");
|
|
|
SchoolLesson schoolLesson = new()
|
|
@@ -398,12 +415,12 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
long totals = await CommonFind.FindTotals(cosmosClient, $"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.school='{school.id}' ", new List<string>() { "Common" });
|
|
|
|
|
|
string weekSql= $"select count(c.id) as totals from c where c.pk='{type}' and c.school='{school.id}' and c.createTime>={weekStart} and c.createTime<={weekEnd}";
|
|
|
- long weekCount = await CommonFind.FindTotals(cosmosClient, weekSql, new List<string>() { "Common" });
|
|
|
- weekActivity += weekCount;
|
|
|
+ long weekActCount = await CommonFind.FindTotals(cosmosClient, weekSql, new List<string>() { "Common" });
|
|
|
+ weekActivity += weekActCount;
|
|
|
|
|
|
string termSql = $"select count(c.id) as totals from c where c.pk='{type}' and c.school='{school.id}' and c.createTime>={termStart} and c.createTime<={termEnd}";
|
|
|
- long termCount = await CommonFind.FindTotals(cosmosClient, termSql, new List<string>() { "Common" });
|
|
|
- termActivity += termCount;
|
|
|
+ long termActCount = await CommonFind.FindTotals(cosmosClient, termSql, new List<string>() { "Common" });
|
|
|
+ termActivity += termActCount;
|
|
|
|
|
|
switch (type)
|
|
|
{
|
|
@@ -426,7 +443,29 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
schoolLessons.Add(schoolLesson);
|
|
|
}
|
|
|
|
|
|
- return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, major, standard, oeCount, schools = schoolInfos, schoolLessons });
|
|
|
+ List<string> tecIds = await CommonFind.FindRolesId(cosmosClient, scIds);
|
|
|
+
|
|
|
+ //查询去下面所有学校教师课例
|
|
|
+ foreach (var tecId in tecIds)
|
|
|
+ {
|
|
|
+ string sqlTxt = $"select value(c) from c";
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{tecId}") }))
|
|
|
+ {
|
|
|
+ records.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //课例统计
|
|
|
+ if (records.Count > 0)
|
|
|
+ {
|
|
|
+ records.ForEach(x => { if (x.startTime >= dayStart && x.startTime <= dayEnd) dayLess += 1; });
|
|
|
+ records.ForEach(x => { if (x.startTime >= weekStart && x.startTime <= weekEnd) weekLess += 1; });
|
|
|
+ records.ForEach(x => { if (x.startTime >= monthStart && x.startTime <= monthEnd) monthLess += 1; });
|
|
|
+ records.ForEach(x => { if (x.startTime >= termStart && x.startTime <= termEnd) termLess += 1; });
|
|
|
+ teachCount = records.Where(r => r.tmdid != null).Where((x, i) => records.FindIndex(z => z.tmdid == x.tmdid) == i).ToList().Count;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, major, standard, oeCount, dayLess,weekLess,monthLess,termLess,teachCount, schools = schoolInfos, schoolLessons });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|