|
@@ -25,6 +25,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
|
|
|
using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
using TEAMModelOS.SDK.Models.Service.BIStatsWay;
|
|
|
+using static TEAMModelBI.Controllers.Census.SchoolController;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.Census
|
|
|
{
|
|
@@ -254,7 +255,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public async Task<IActionResult> GetIdStatis(JsonElement jsonElement)
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();
|
|
|
-
|
|
|
+
|
|
|
//jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
|
|
|
|
|
|
int tecCount = 0; //学校教师数量
|
|
@@ -391,7 +392,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
comSql = BICommonWay.ManyScSql(" and c.school", scIds);
|
|
|
tActCnt = await ActivityWay.GetCnt(cosmosClient, condSql: comSql);
|
|
|
|
|
|
- return Ok(new { state = 200, scCnt=scIds.Count(), tLessCnt, tActCnt });
|
|
|
+ return Ok(new { state = 200, scCnt = scIds.Count(), tLessCnt, tActCnt });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -483,11 +484,11 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
string lesSql = $"select value(count(c.id)) from c where c.pk='LessonRecord' and {scsSql}";
|
|
|
tLessCnt = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School", "Teacher" }, lesSql);
|
|
|
|
|
|
- string actComSql = BICommonWay.ManyScSql(" and c.school", scIds);
|
|
|
+ string actComSql = BICommonWay.ManyScSql(" and c.school", scIds);
|
|
|
tActCnt = await ActivityWay.GetCnt(cosmosClient, condSql: actComSql);
|
|
|
}
|
|
|
|
|
|
- return Ok(new { state = RespondCode.Ok, scCnt = scIds.Count, tchCnt, stuCnt, allCnt = tLessCnt + tActCnt, tLessCnt, tActCnt});
|
|
|
+ return Ok(new { state = RespondCode.Ok, scCnt = scIds.Count, tchCnt, stuCnt, allCnt = tLessCnt + tActCnt, tLessCnt, tActCnt });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -498,7 +499,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-scstats")]
|
|
|
- public async Task<IActionResult> GetSchoolStats(JsonElement jsonElement)
|
|
|
+ public async Task<IActionResult> GetSchoolStats(JsonElement jsonElement)
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("scId", out JsonElement scId)) return BadRequest();
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
@@ -534,11 +535,12 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
bool isnew = false;
|
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
long now = dateTime.ToUnixTimeMilliseconds();
|
|
|
- if (!string.IsNullOrEmpty(statsInfo.id))
|
|
|
+ if (!string.IsNullOrEmpty(statsInfo.id))
|
|
|
{
|
|
|
- scStats.id= statsInfo.id;
|
|
|
+ scStats.id = statsInfo.id;
|
|
|
scStats.name = statsInfo.name;
|
|
|
scStats.picture = statsInfo.picture;
|
|
|
+ scStats.areaId = statsInfo.areaId;
|
|
|
scStats.tch = statsInfo.tch;
|
|
|
scStats.dayTch = statsInfo.dayTch;
|
|
|
scStats.weekTch = statsInfo.weekTch;
|
|
@@ -566,7 +568,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
scStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
scStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
scStats.lessStats.lastYearInter = statsInfo.lesson.lastYearInter;
|
|
|
- scStats.lessStats.yearInter=statsInfo.lesson.yearInter;
|
|
|
+ scStats.lessStats.yearInter = statsInfo.lesson.yearInter;
|
|
|
scStats.lessStats.LastYear = TimeHelper.GetYearMonth(statsInfo.lesson.LastYear, dateTime.Year, dateTime.Month);
|
|
|
scStats.lessStats.year = TimeHelper.GetYearMonth(statsInfo.lesson.year, dateTime.Year, dateTime.Month);
|
|
|
scStats.actStats.cnt = statsInfo.activity.cnt;
|
|
@@ -580,7 +582,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
scStats.actStats.week = statsInfo.activity.week;
|
|
|
scStats.actStats.lastTerm = statsInfo.activity.lastTerm;
|
|
|
scStats.actStats.term = statsInfo.activity.term;
|
|
|
- scStats.actStats.LastYear = TimeHelper.GetYearMonth(statsInfo.activity.LastYear ,dateTime.Year,dateTime.Month);
|
|
|
+ scStats.actStats.LastYear = TimeHelper.GetYearMonth(statsInfo.activity.LastYear, dateTime.Year, dateTime.Month);
|
|
|
scStats.actStats.year = TimeHelper.GetYearMonth(statsInfo.activity.year, dateTime.Year, dateTime.Month);
|
|
|
if (statsInfo.study != null)
|
|
|
{
|
|
@@ -636,7 +638,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-areastats")]
|
|
|
- public async Task<IActionResult> GetAreaStats(JsonElement jsonElement)
|
|
|
+ public async Task<IActionResult> GetAreaStats(JsonElement jsonElement)
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
|
|
@@ -658,7 +660,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
string scSql = $"select value(c.id) from c where c.areaId='{areaId}'";
|
|
|
scIds = await CommonFind.FindScIds(cosmosClient, scSql, "Base");
|
|
|
StringBuilder statsSql = new("select value(c) from c");
|
|
|
- if (scIds.Count > 0)
|
|
|
+ if (scIds.Count > 0)
|
|
|
{
|
|
|
statsSql.Append($" where {BICommonWay.ManyScSql("c.id", scIds)}");
|
|
|
}
|
|
@@ -666,18 +668,19 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
List<ScStats> scStatss = new();
|
|
|
List<StatsInfo> statsInfos = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIterator<StatsInfo>(queryText:statsSql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Stats") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StatsInfo>(queryText: statsSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Stats") }))
|
|
|
{
|
|
|
statsInfos.Add(item);
|
|
|
}
|
|
|
|
|
|
StatsInfo statsInfo = new();
|
|
|
- statsInfo = await SchoolStatsWay.GetAreaStats(cosmosClient, _httpTrigger, _option, statsInfos, scIds, area);
|
|
|
+ statsInfo = SchoolStatsWay.GetAreaStats(cosmosClient, _httpTrigger, _option, statsInfos, scIds, area);
|
|
|
if (!string.IsNullOrEmpty(statsInfo.id))
|
|
|
{
|
|
|
areaScStats.id = statsInfo.id;
|
|
|
areaScStats.name = statsInfo.name;
|
|
|
areaScStats.picture = statsInfo.picture;
|
|
|
+ areaScStats.areaId = statsInfo.areaId;
|
|
|
areaScStats.tch = statsInfo.tch;
|
|
|
areaScStats.dayTch = statsInfo.dayTch;
|
|
|
areaScStats.weekTch = statsInfo.weekTch;
|
|
@@ -733,8 +736,9 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
areaScStats.srStats.finish = statsInfo.study.finish;
|
|
|
}
|
|
|
}
|
|
|
+ var scInfos = statsInfos.Select(s => new { s.id, s.name, s.picture, actLess = (s.lesson.all + s.activity.cnt), actCnt = s.activity.cnt, lessCnt = s.lesson.all, lessOpen = s.lesson.open, lessUp = s.lesson.less }).ToList();
|
|
|
|
|
|
- return Ok(new { state = RespondCode.Ok ,areaScStats });
|
|
|
+ return Ok(new { state = RespondCode.Ok, areaScStats, });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -744,7 +748,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-scinfos")]
|
|
|
- public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
|
|
|
+ public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
|
|
|
{
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
jsonElement.TryGetProperty("role", out JsonElement role);
|
|
@@ -766,7 +770,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!string.IsNullOrEmpty($"{areaId}") && !string.IsNullOrEmpty($"{role}"))
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}") && !string.IsNullOrEmpty($"{role}"))
|
|
|
{
|
|
|
sql.Append($" where c.areaId ='{areaId}'");
|
|
|
}
|
|
@@ -774,7 +778,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
//List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
|
|
|
|
|
|
List<BIRelation> scInfos = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
|
|
|
{
|
|
|
scInfos.Add(item);
|
|
|
}
|
|
@@ -826,6 +830,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public string id { get; set; }
|
|
|
public string name { get; set; }
|
|
|
public string picture { get; set; }
|
|
|
+ public string areaId { get; set; }
|
|
|
public int tch { get; set; }
|
|
|
public int dayTch { get; set; }
|
|
|
public int weekTch { get; set; }
|
|
@@ -845,6 +850,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public ScSRStats srStats { get; set; } = new ScSRStats();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 课例活动数据
|
|
|
/// </summary>
|
|
@@ -873,7 +879,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
/// <summary>
|
|
|
/// 学校活动数据
|
|
|
/// </summary>
|
|
|
- public record ScActStats
|
|
|
+ public record ScActStats
|
|
|
{
|
|
|
public int cnt { get; set; }
|
|
|
public int exam { get; set; }
|
|
@@ -893,8 +899,8 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
/// <summary>
|
|
|
/// 研修统计数据
|
|
|
/// </summary>
|
|
|
- public record ScSRStats
|
|
|
- {
|
|
|
+ public record ScSRStats
|
|
|
+ {
|
|
|
public int learnTime { get; set; }
|
|
|
public int online { get; set; }
|
|
|
public int offline { get; set; }
|
|
@@ -904,5 +910,6 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public int ongoing { get; set; }
|
|
|
public int finish { get; set; }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|