|
@@ -140,7 +140,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
scIds.Add(item);
|
|
|
}
|
|
|
|
|
|
- inSql = $" and {BICommonWay.ManyScSql("school", scIds)}";
|
|
|
+ inSql = $" and {BICommonWay.ManyScSql("c.school", scIds)}";
|
|
|
}
|
|
|
|
|
|
foreach (var type in StaticValue.activityTypes)
|
|
@@ -515,7 +515,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 所有区的统计接口
|
|
|
+ /// 所有区的统计接口 学区情况
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("get-all")]
|
|
@@ -526,91 +526,136 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
if ($"{site}".Equals(BIConst.Global))
|
|
|
cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
|
|
|
- List<AreaInfo> areaInfos = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
|
|
|
- {
|
|
|
- areaInfos.Add(item);
|
|
|
- }
|
|
|
-
|
|
|
var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
|
|
|
var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term");
|
|
|
+ var (monthS, monthE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
|
|
|
+
|
|
|
+ int areaCount = 0; //区域数量
|
|
|
+ int scCount = 0; //学校数量
|
|
|
+ int tecCount = 0; //教师数量
|
|
|
+ int stuCount = 0; //学生数量
|
|
|
+ int allSize = 0; //空间总量
|
|
|
+
|
|
|
+ int weekScCnt = 0; //本周学校
|
|
|
+ int weekTchCnt = 0; //本周教师
|
|
|
+ int monthScCnt = 0; //本月学校
|
|
|
+ int monthTchCnt = 0; //本月教师
|
|
|
+
|
|
|
int heCount = 0;//高教
|
|
|
int geCount = 0;//普教
|
|
|
int oeCount = 0; //其他教育
|
|
|
- int allSize = 0;//空间总量
|
|
|
- Dictionary<string, long> activitys = new(); //活动类型集合
|
|
|
- long allActivity = 0; //活动累计
|
|
|
- long weekActivity = 0;//本周活动
|
|
|
- long termActivity = 0;//本学期活动
|
|
|
- long weekLess = 0; //本周课例
|
|
|
- long termLess = 0; //本学期课例
|
|
|
- long allLess = 0; //所有课例
|
|
|
- int tecCount = 0; //教师数量
|
|
|
- int scCount = 0; //学校数量
|
|
|
- int stuCount = 0; //学生数量
|
|
|
|
|
|
- int basics = 0; //基础版数
|
|
|
- int standard = 0; //标准版数
|
|
|
- int major = 0; //专业版数
|
|
|
- long resourceCount = 0; //累计资源
|
|
|
- long totalTime = 0; //总学时
|
|
|
+ int allActivity = 0; //活动累计
|
|
|
+ int weekActivity = 0;//本周活动
|
|
|
+ int termActivity = 0;//本学期活动
|
|
|
+ int monthActCnt = 0; //本月活动
|
|
|
|
|
|
- scCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"SELECT value(count(c.id)) FROM c ", "Base");
|
|
|
- tecCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"SELECT value(count(c.id)) FROM c ", "Base");
|
|
|
- stuCount = await CommonFind.GetSqlValueCount(cosmosClient, "Student", $"SELECT value(count(c.id)) FROM c ", "Base");
|
|
|
- allSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"SELECT value(sum(c.size)) FROM c ", "Base");
|
|
|
+ int weekLess = 0; //本周课例
|
|
|
+ int termLess = 0; //本学期课例
|
|
|
+ int allLess = 0; //所有课例
|
|
|
+ int monthLesCnt = 0; //本月课例
|
|
|
|
|
|
- foreach (var area in areaInfos)
|
|
|
- {
|
|
|
- List<RecSchool> recSchools = new();
|
|
|
- await foreach (var school in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.type,c.size,c.scale from c where c.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
- {
|
|
|
- recSchools.Add(school);
|
|
|
- }
|
|
|
- //scCount += recSchools.Count;
|
|
|
- recSchools.ForEach(x => { if (x.type == 2) heCount += 1; else if (x.type == 1) geCount += 1; else oeCount += 1; });
|
|
|
- //allSize += recSchools.Select(s => s.size).Sum();
|
|
|
- area.schoolCount = recSchools.Count;
|
|
|
- //统计服务
|
|
|
- var (tempb, temps, tempm) = await ProductWay.GetVersionCount(cosmosClient, recSchools);
|
|
|
- basics += tempb;
|
|
|
- standard += temps;
|
|
|
- major += tempm;
|
|
|
- int tempCount = await CommonFind.GetPeopleNumber(cosmosClient, "School", recSchools?.Select(x => x.id).ToList(), "Teacher");
|
|
|
-
|
|
|
- //tecCount += tempCount;
|
|
|
- //查教师
|
|
|
- area.techCount = tempCount;
|
|
|
- //查询学生
|
|
|
- area.stuCount = await CommonFind.GetPeopleNumber(cosmosClient, "Student", recSchools?.Select(x => x.id).ToList(), "Base");
|
|
|
- }
|
|
|
+ int resourceCount = 0; //累计资源
|
|
|
+ int totalTime = 0; //总学时
|
|
|
|
|
|
- //统计活动
|
|
|
- foreach (var type in StaticValue.activityTypes)
|
|
|
- {
|
|
|
- string sqlTxt = $"select COUNT(c.id) AS totals from c where c.pk='{type}'";
|
|
|
- long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt, new List<string>() { "Common" });
|
|
|
+ string commSql = "select value(count(c.id)) from c";
|
|
|
+
|
|
|
+ areaCount = await CommonFind.GetSqlValueCount(cosmosClient, "Normal", commSql, "Base-Area");
|
|
|
+ scCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", commSql, "Base");
|
|
|
+ tecCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", commSql,"Base");
|
|
|
+ stuCount = await CommonFind.GetSqlValueCount(cosmosClient, "Student", commSql, "Base");
|
|
|
+ allSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", commSql, "Base");
|
|
|
+
|
|
|
+
|
|
|
+ weekScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {termStart} and c.createTime >= {termEnd}", "Base");
|
|
|
+ monthScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {monthS} and c.createTime >= {monthE}", "Base");
|
|
|
+
|
|
|
+ weekTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"{commSql} where c.createTime >= {termStart} and c.createTime >= {termEnd}", "Base");
|
|
|
+ monthTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"{commSql} where c.createTime >= {monthS} and c.createTime >= {monthE}", "Base");
|
|
|
+
|
|
|
+ heCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.type = 1", "Base");
|
|
|
+ geCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.type = 2", "Base");
|
|
|
+ oeCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.type != 1 and c.type != 2", "Base");
|
|
|
+
|
|
|
+ //活动
|
|
|
+ allActivity = await ActivityWay.GetCnt(cosmosClient);
|
|
|
|
|
|
- string weekSql = $"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.createTime>={weekStart} and c.createTime<={weekStart} ";
|
|
|
- weekActivity += await CommonFind.FindTotals(cosmosClient, weekSql, new List<string> { "Common" });
|
|
|
+ string weekSql = $" and c.createTime >= {weekStart} and c.createTime <={weekEnd}";
|
|
|
+ weekActivity = await ActivityWay.GetCnt(cosmosClient, weekSql);
|
|
|
|
|
|
- string termSql = $"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.createTime>={termStart} and c.createTime<={termEnd} ";
|
|
|
- termActivity += await CommonFind.FindTotals(cosmosClient, termSql, new List<string> { "Common" });
|
|
|
+ string termSql = $" and c.createTime >= {termStart} and c.createTime <={termEnd}";
|
|
|
+ termActivity = await ActivityWay.GetCnt(cosmosClient, termSql);
|
|
|
|
|
|
- allActivity += totals;
|
|
|
- activitys.Add(type, totals);
|
|
|
+ string monthActSql = $" and c.createTime >= {monthS} and c.createTime <={monthE}";
|
|
|
+ monthActCnt = await ActivityWay.GetCnt(cosmosClient, termSql);
|
|
|
+
|
|
|
+ //课例
|
|
|
+ string allLessSql = $"select value(count(c.id)) from c where c.pk='LessonRecord'";
|
|
|
+ allLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", allLessSql);
|
|
|
+
|
|
|
+ string weekLSql = $"{allLessSql} and c.startTime >= {weekStart} and c.startTime <={weekEnd}";
|
|
|
+ weekLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", weekLSql);
|
|
|
+
|
|
|
+ string termLSql = $"{allLessSql} and c.startTime >= {termStart} and c.startTime <={termEnd}";
|
|
|
+ termLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", termLSql);
|
|
|
+
|
|
|
+ string monthLSql = $"{allLessSql} and c.startTime >= {monthS} and c.startTime <={monthE}";
|
|
|
+ monthLesCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", termLSql);
|
|
|
+
|
|
|
+ totalTime = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", "select value(sum(c.totalTime)) from c where c.pk='TeacherTrain'");
|
|
|
+ resourceCount = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School", "Teacher" }, "select value(count(c.id)) from c where c.pk='Bloblog'");
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok, areaCount, scCount, tecCount, stuCount, allSize, weekScCnt, weekTchCnt, monthScCnt, monthTchCnt, heCount, geCount, oeCount, allActivity, weekActivity, termActivity, monthActCnt, weekLess, termLess, allLess, monthLesCnt, resourceCount, totalTime });
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 分析所有区的人数和学校 学区情况
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("get-areasanls")]
|
|
|
+ public async Task<IActionResult> GetAreasAnls(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.Global))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
+
|
|
|
+ List<AreaInfo> areaInfos = new();
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
|
|
|
+ {
|
|
|
+ areaInfos.Add(item);
|
|
|
}
|
|
|
|
|
|
- allLess = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.pk='LessonRecord'", new List<string>() { "School", "Teacher" });
|
|
|
- weekLess = await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c where c.pk='LessonRecord' and c.startTime>={weekStart} and c.startTime <={weekEnd}", new List<string>() { "School", "Teacher" });
|
|
|
- termLess = await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c where c.pk='LessonRecord' and c.startTime>={termStart} and c.startTime <={termEnd}", new List<string>() { "School", "Teacher" });
|
|
|
+ foreach (var area in areaInfos)
|
|
|
+ {
|
|
|
+ string scSql = $"select value(c.id) from c where c.areaId='{area.id}'";
|
|
|
+ List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scSql,"Base");
|
|
|
+ //allSize += recSchools.Select(s => s.size).Sum();
|
|
|
+ area.scCnt = scIds.Count;
|
|
|
+ int tTchCnt = 0;
|
|
|
+ int tStuCnt = 0;
|
|
|
+ if (scIds.Count > 0)
|
|
|
+ {
|
|
|
+ scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Teacher-', '')", scIds);
|
|
|
+
|
|
|
+ //查教师
|
|
|
+ string tchSql = $"select value(count(c.id)) from c where c.pk='Teacher' and {scSql}";
|
|
|
+ tTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", tchSql);
|
|
|
|
|
|
- totalTime = await CommonFind.FindTotals(cosmosClient, "select sum(c.totalTime) as totals from c where c.pk='TeacherTrain'", new List<string>() { "Teacher" });
|
|
|
- resourceCount = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.pk='Bloblog'", new List<string>() { "School", "Teacher" });
|
|
|
+ scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Base-', '')", scIds);
|
|
|
+ //查学生
|
|
|
+ string stuSql = $"select value(count(c.id)) from c where c.pk='Base' and {scSql}";
|
|
|
+ tStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", stuSql);
|
|
|
+ }
|
|
|
+ area.tchCnt = tTchCnt;
|
|
|
+ area.stuCnt = tStuCnt;
|
|
|
+ }
|
|
|
|
|
|
- return Ok(new { state = 200, areaCount = areaInfos.Count, scCount, tecCount, stuCount, allSize, heCount, geCount, oeCount, allLess, termLess, weekLess, allActivity, termActivity, weekActivity, resourceCount, basics, standard, major, totalTime, activitys, areaInfos });
|
|
|
+ return Ok(new { state = RespondCode.Ok, areaInfos });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 所有活动分析
|
|
|
/// </summary>
|
|
@@ -631,12 +676,13 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
int allLess = 0; //所有课例
|
|
|
int weekLess = 0; //本周课例
|
|
|
int termLess = 0; //本学期课例
|
|
|
- int monthLessCnt = 0;
|
|
|
+ int monthLessCnt = 0; //本月课例
|
|
|
|
|
|
int actAllCnt = 0; //所有活动
|
|
|
int actWeekCnt = 0; //本周活动
|
|
|
int actTermCnt = 0; //本学期活动
|
|
|
- int actMonthCnt = 0;
|
|
|
+ int actMonthCnt = 0; //本月活动
|
|
|
+
|
|
|
//课例
|
|
|
string allLessSql = $"select value(count(c.id)) from c where c.pk='LessonRecord'";
|
|
|
allLess = await CommonFind.GetSqlValueCount(cosmosClient,"School", allLessSql);
|
|
@@ -724,9 +770,9 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public string name { get; set; }
|
|
|
public string standard { get; set; }
|
|
|
public string standardName { get; set; }
|
|
|
- public int schoolCount { get; set; }
|
|
|
- public int techCount { get; set; }
|
|
|
- public int stuCount { get; set; }
|
|
|
+ public int scCnt { get; set; } = 0;
|
|
|
+ public int tchCnt { get; set; } = 0;
|
|
|
+ public int stuCnt { get; set; } = 0;
|
|
|
}
|
|
|
|
|
|
|