|
@@ -19,6 +19,7 @@ using MathNet.Numerics.LinearAlgebra.Double;
|
|
|
using TEAMModelBI.Tool.CosmosBank;
|
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
|
using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
+using TEAMModelOS.SDK.Context.Constant;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.Census
|
|
|
{
|
|
@@ -104,29 +105,40 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 统计所有课例数量
|
|
|
+ /// 依据区级ID分析该去所有学校课例
|
|
|
/// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
- [HttpPost("get-total")]
|
|
|
- public async Task<IActionResult> GetAllCount(JsonElement jsonElement)
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-schoolan")]
|
|
|
+ public async Task<IActionResult> GetSchoolsAn(JsonElement jsonElement)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
+ if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
+ var (lWeekS, lWeekE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastterm");
|
|
|
+ var (monthS, monthE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
|
|
|
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- if ($"{site}".Equals(BIConst.Global))
|
|
|
- cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
- string lessonSql = $"select COUNT(c.id) AS totals from c where c.pk='LessonRecord'";
|
|
|
- long total = await CommonFind.FindTotals(cosmosClient, lessonSql, new List<string>() { "School","Teacher" });
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.Global))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
|
|
|
- return Ok(new { state = 200, total });
|
|
|
+ List<AreaSchools> areaSchools = new();
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AreaSchools>(queryText: $"select c.id,c.name,c.picture from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
|
|
|
+ {
|
|
|
+ areaSchools.Add(item);
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ if (areaSchools.Count > 0)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location} /lesson/get-total \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- return BadRequest();
|
|
|
+ foreach (var item in areaSchools)
|
|
|
+ {
|
|
|
+ item.allCnt = await CommonFind.GetSqlValueCount(cosmosClient,"School",$"select value(count(c.id)) from c ",$"LessonRecord-{item.id}");
|
|
|
+ item.weekCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.startTime >= {lWeekS} and c.startTime <= {lWeekE}", $"LessonRecord-{item.id}");
|
|
|
+ item.monthCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.startTime >= {monthS} and c.startTime <= {monthE}", $"LessonRecord-{item.id}");
|
|
|
+ }
|
|
|
+ //areaSchools = areaSchools.Where(w => w.allCnt != 0 && w.weekCnt != 0 && w.monthCnt != 0).ToList();
|
|
|
}
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok, areaSchools });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -602,6 +614,16 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
|
|
|
|
|
|
|
|
|
+ public record AreaSchools
|
|
|
+ {
|
|
|
+ public string id { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+ public string picture { get; set; }
|
|
|
+ public int allCnt { get; set; }
|
|
|
+ public int weekCnt { get; set; }
|
|
|
+ public int monthCnt { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public record AllAreaInfo
|
|
|
{
|