|
@@ -258,7 +258,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
ActivityCount tempCount = new ActivityCount() { id = school.id, name = school.name != null ? school.name : school.id };
|
|
ActivityCount tempCount = new ActivityCount() { id = school.id, name = school.name != null ? school.name : school.id };
|
|
foreach (var type in types)
|
|
foreach (var type in types)
|
|
{
|
|
{
|
|
- StringBuilder sqlTxt = new StringBuilder($"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.school='{school.id}' ");
|
|
|
|
|
|
+ StringBuilder sqlTxt = new($"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.school='{school.id}' ");
|
|
long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt.ToString(), new List<string>() { "Common" });
|
|
long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt.ToString(), new List<string>() { "Common" });
|
|
|
|
|
|
switch (type)
|
|
switch (type)
|
|
@@ -299,7 +299,15 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
List<RecSchool> schools = new();
|
|
List<RecSchool> schools = new();
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.size,c.scale,c.type from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ StringBuilder scSqlTxt = new("select c.id,c.name,c.picture,c.size,c.scale,c.type from c");
|
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
|
+ {
|
|
|
|
+ scSqlTxt.Append($" where c.areaId='{areaId}'");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
{
|
|
{
|
|
schools.Add(item);
|
|
schools.Add(item);
|
|
}
|
|
}
|
|
@@ -331,7 +339,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
heCount += 1;
|
|
heCount += 1;
|
|
else if (school.type == 1)
|
|
else if (school.type == 1)
|
|
geCount += 1;
|
|
geCount += 1;
|
|
- else oeCount += 0;
|
|
|
|
|
|
+ else oeCount += 1;
|
|
|
|
|
|
areaSize += school.size;
|
|
areaSize += school.size;
|
|
|
|
|
|
@@ -387,8 +395,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
ActivityCount tempActivity = new ActivityCount() { id = school.id, name = school.name != null ? school.name : school.id };
|
|
ActivityCount tempActivity = new ActivityCount() { id = school.id, name = school.name != null ? school.name : school.id };
|
|
foreach (var type in types)
|
|
foreach (var type in types)
|
|
{
|
|
{
|
|
- string sqlTxt = new string($"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.school='{school.id}' ");
|
|
|
|
- long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt, new List<string>() { "Common" });
|
|
|
|
|
|
+ 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}";
|
|
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" });
|
|
long weekCount = await CommonFind.FindTotals(cosmosClient, weekSql, new List<string>() { "Common" });
|
|
@@ -422,6 +429,76 @@ namespace TEAMModelBI.Controllers.Census
|
|
return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, schools = schoolInfos, schoolLessons });
|
|
return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, schools = schoolInfos, schoolLessons });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 所有区的统计接口
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get-all")]
|
|
|
|
+ public async Task<IActionResult> GetAll()
|
|
|
|
+ {
|
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+
|
|
|
|
+ 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");
|
|
|
|
+ int heCount = 0;//高教
|
|
|
|
+ int geCount = 0;//普教
|
|
|
|
+ int oeCount = 0; //其他教育
|
|
|
|
+ int allSize = 0;//空间总量
|
|
|
|
+ Dictionary<string, long> activitys = new(); //活动类型集合
|
|
|
|
+ long allActivity = 0; //活动累计
|
|
|
|
+ long weekActivity = 0;//本周活动
|
|
|
|
+ long tearActivity = 0;//本学期活动
|
|
|
|
+ long weekLess = 0; //本周课例
|
|
|
|
+ long termLess = 0; //本学期课例
|
|
|
|
+ long allLess = 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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ //查教师
|
|
|
|
+ area.techCount = await CommonFind.GetPeopleNumber(cosmosClient,"School",recSchools?.Select(x=>x.id).ToList(), "Teacher");
|
|
|
|
+ //查询省
|
|
|
|
+ area.stuCount = await CommonFind.GetPeopleNumber(cosmosClient, "Student", recSchools?.Select(x => x.id).ToList(), "Base");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //统计活动
|
|
|
|
+ foreach (var type in types)
|
|
|
|
+ {
|
|
|
|
+ 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 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 termSql = $"select COUNT(c.id) AS totals from c where c.pk='{type}' and c.createTime>={termStart} and c.createTime<={termEnd} ";
|
|
|
|
+ tearActivity += await CommonFind.FindTotals(cosmosClient, termSql, new List<string> { "Common" });
|
|
|
|
+
|
|
|
|
+ allActivity += totals;
|
|
|
|
+ activitys.Add(type, totals);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ allLess = await CommonFind.FindTotals(cosmosClient, "select count(c.id) as totals from c where c.pk='LessonRecord'", new List<string>() { "School" });
|
|
|
|
+ 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" });
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, areaCount = areaInfos.Count, allSize, heCount, geCount, oeCount, allLess, termLess, weekLess, allActivity, tearActivity,weekActivity, areaInfos });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 依据活动Id查询活动详情信息 数据管理工具——查询工具
|
|
/// 依据活动Id查询活动详情信息 数据管理工具——查询工具
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -467,7 +544,23 @@ namespace TEAMModelBI.Controllers.Census
|
|
return Ok(new { state = 200, infos });
|
|
return Ok(new { state = 200, infos });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 区级信息
|
|
|
|
+ /// </summary>
|
|
|
|
+ public record AreaInfo
|
|
|
|
+ {
|
|
|
|
+ public string id { get; set; }
|
|
|
|
+ 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; }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 区级下学校信息显示
|
|
|
|
+ /// </summary>
|
|
public record RecSchool
|
|
public record RecSchool
|
|
{
|
|
{
|
|
public string id { get; set; }
|
|
public string id { get; set; }
|
|
@@ -500,10 +593,10 @@ namespace TEAMModelBI.Controllers.Census
|
|
public string id { get; set; }
|
|
public string id { get; set; }
|
|
public string name { get; set; }
|
|
public string name { get; set; }
|
|
public string picture { get; set; }
|
|
public string picture { get; set; }
|
|
- public int count{get;set;}
|
|
|
|
|
|
+ public int count { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
- public record ActivityCount
|
|
|
|
|
|
+ public record ActivityCount
|
|
{
|
|
{
|
|
public string id { get; set; }
|
|
public string id { get; set; }
|
|
public string name { get; set; }
|
|
public string name { get; set; }
|