|
@@ -18,6 +18,8 @@ using TEAMModelOS.SDK;
|
|
using TEAMModelBI.Tool.CosmosBank;
|
|
using TEAMModelBI.Tool.CosmosBank;
|
|
using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
|
|
+using TEAMModelOS.SDK.Context.Constant;
|
|
|
|
+using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.Census
|
|
namespace TEAMModelBI.Controllers.Census
|
|
{
|
|
{
|
|
@@ -120,18 +122,43 @@ namespace TEAMModelBI.Controllers.Census
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ jsonElement.TryGetProperty("areaId", out JsonElement areaId);
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
if ($"{site}".Equals(BIConst.Global))
|
|
if ($"{site}".Equals(BIConst.Global))
|
|
cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
- List<KeyValuePair<string, long>> typeCount = new List<KeyValuePair<string, long>>();
|
|
|
|
- foreach (var type in StaticValue.activityTypes)
|
|
|
|
|
|
+ List<KeyValuePair<string, long>> typeCount = new();
|
|
|
|
+
|
|
|
|
+ string inSql = null;
|
|
|
|
+ List<string> scIds = new();
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}"))
|
|
{
|
|
{
|
|
- string querySql = $"SELECT Count(c.id) as totals FROM c where c.pk='{type}' ";
|
|
|
|
|
|
+ string areaSc = $"select value(c.id) from c where c.pk='School' and c.areaId='{areaId}'";
|
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("", "School").GetItemQueryIterator<string>(queryText: areaSc, requestOptions: new QueryRequestOptions() { }))
|
|
|
|
+ {
|
|
|
|
+ scIds.Add(item);
|
|
|
|
+ }
|
|
|
|
|
|
- long totals = await CommonFind.FindTotals(cosmosClient, querySql, new List<string>() { "Common" });
|
|
|
|
|
|
+ inSql = $" and {BICommonWay.ManyScSql("school", scIds)}";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (var type in StaticValue.activityTypes)
|
|
|
|
+ {
|
|
|
|
+ string querySql = $"SELECT value(count(c.id)) FROM c where c.pk='{type}' ";
|
|
|
|
+ long totals = 0;
|
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
|
+ {
|
|
|
|
+ if (!string.IsNullOrEmpty(inSql) && scIds.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ querySql = $"{querySql}{inSql}";
|
|
|
|
+ totals = await CommonFind.GetSqlValueCount(cosmosClient, "Common", querySql);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ totals = await CommonFind.GetSqlValueCount(cosmosClient, "Common", querySql);
|
|
|
|
|
|
- KeyValuePair<string, long> valuePair = new KeyValuePair<string, long>(type, totals);
|
|
|
|
|
|
+ KeyValuePair<string, long> valuePair = new(type, totals);
|
|
typeCount.Add(valuePair);
|
|
typeCount.Add(valuePair);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -528,10 +555,10 @@ namespace TEAMModelBI.Controllers.Census
|
|
long resourceCount = 0; //累计资源
|
|
long resourceCount = 0; //累计资源
|
|
long totalTime = 0; //总学时
|
|
long totalTime = 0; //总学时
|
|
|
|
|
|
- scCount = await CommonFind.FindTotals(cosmosClient, $"SELECT count(c.id) as totals FROM c ", "School", "Base");
|
|
|
|
- tecCount = await CommonFind.FindTotals(cosmosClient, $"SELECT count(c.id) as totals FROM c ", "Teacher", "Base");
|
|
|
|
- stuCount = await CommonFind.FindTotals(cosmosClient, $"SELECT count(c.id) as totals FROM c ", "Student", "Base");
|
|
|
|
- allSize = await CommonFind.FindTotals(cosmosClient, $"SELECT sum(c.size) as totals FROM c ", "School", "Base");
|
|
|
|
|
|
+ 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");
|
|
|
|
|
|
foreach (var area in areaInfos)
|
|
foreach (var area in areaInfos)
|
|
{
|
|
{
|
|
@@ -584,6 +611,61 @@ namespace TEAMModelBI.Controllers.Census
|
|
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 = 200, areaCount = areaInfos.Count, scCount, tecCount, stuCount, allSize, heCount, geCount, oeCount, allLess, termLess, weekLess, allActivity, termActivity, weekActivity, resourceCount, basics, standard, major, totalTime, activitys, areaInfos });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 所有活动分析
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get-allanls")]
|
|
|
|
+ public async Task<IActionResult> GetAllAnls(JsonElement jsonElement)
|
|
|
|
+ {
|
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+ if ($"{site}".Equals(BIConst.Global))
|
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
|
+ DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
|
+ var (weeks, weeke) = TimeHelper.GetStartOrEnd(dateTime, "week");
|
|
|
|
+ var (terms, terme) = TimeHelper.GetStartOrEnd(dateTime, "term");
|
|
|
|
+ var (months, monthe) = TimeHelper.GetStartOrEnd(dateTime, "month");
|
|
|
|
+
|
|
|
|
+ int allLess = 0; //所有课例
|
|
|
|
+ int weekLess = 0; //本周课例
|
|
|
|
+ int termLess = 0; //本学期课例
|
|
|
|
+ int monthLessCnt = 0;
|
|
|
|
+
|
|
|
|
+ int actAllCnt = 0; //所有活动
|
|
|
|
+ int actWeekCnt = 0; //本周活动
|
|
|
|
+ int actTermCnt = 0; //本学期活动
|
|
|
|
+ int actMonthCnt = 0;
|
|
|
|
+ //课例
|
|
|
|
+ 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 >= {weeks} and c.startTime <={weeke}";
|
|
|
|
+ weekLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", weekLSql);
|
|
|
|
+
|
|
|
|
+ string termLSql = $"{allLessSql} and c.startTime >= {terms} and c.startTime <={terme}";
|
|
|
|
+ termLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", termLSql);
|
|
|
|
+
|
|
|
|
+ string monthLSql = $"{allLessSql} and c.startTime >= {months} and c.startTime <={monthe}";
|
|
|
|
+ monthLessCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", monthLSql);
|
|
|
|
+
|
|
|
|
+ //活动
|
|
|
|
+ actAllCnt = await ActivityWay.GetCnt(cosmosClient);
|
|
|
|
+
|
|
|
|
+ string weekSql = $" and c.createTime >= {weeks} and c.createTime <={weeke}";
|
|
|
|
+ actWeekCnt = await ActivityWay.GetCnt(cosmosClient, weekSql);
|
|
|
|
+
|
|
|
|
+ string termSql = $" and c.createTime >= {terms} and c.createTime <={terme}";
|
|
|
|
+ actTermCnt = await ActivityWay.GetCnt(cosmosClient,termSql);
|
|
|
|
+
|
|
|
|
+ string monthSql = $" and c.createTime >= {months} and c.createTime <={monthe}";
|
|
|
|
+ actMonthCnt = await ActivityWay.GetCnt(cosmosClient, monthSql);
|
|
|
|
+
|
|
|
|
+ return Ok(new {state = RespondCode.Ok, allLess, weekLess, termLess, monthLessCnt, actAllCnt, actWeekCnt, actTermCnt, actMonthCnt });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 依据活动Id查询活动详情信息 数据管理工具——查询工具
|
|
/// 依据活动Id查询活动详情信息 数据管理工具——查询工具
|