|
@@ -16,6 +16,7 @@ using TEAMModelOS.SDK.Extension;
|
|
|
using System.Text;
|
|
|
using TEAMModelBI.Tool;
|
|
|
using MathNet.Numerics.LinearAlgebra.Double;
|
|
|
+using TEAMModelBI.Tool.CosmosBank;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.Census
|
|
|
{
|
|
@@ -27,6 +28,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
|
private readonly DingDing _dingDing;
|
|
|
private readonly Option _option;
|
|
|
+ public readonly List<string> types = new() { "Exam", "Survey", "Vote", "Homework" };
|
|
|
|
|
|
public LessonSticsController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureFactory, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
{
|
|
@@ -325,11 +327,17 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
[HttpPost("get-areacount")]
|
|
|
public async Task<IActionResult> GetAreaCount(JsonElement jsonElement)
|
|
|
{
|
|
|
- if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ if(!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
List<string> schools = new();
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
- schools = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c where c.areaId='{areaId}'", "Base");
|
|
|
+ StringBuilder scSqlTxt = new("select c.id from c");
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
+ {
|
|
|
+ scSqlTxt.Append($" where c.areaId='{areaId}'");
|
|
|
+ }
|
|
|
+
|
|
|
+ schools = await CommonFind.FindSchoolIds(cosmosClient, scSqlTxt.ToString(), "Base");
|
|
|
|
|
|
//所有的课程记录
|
|
|
List<LessonRecord> records = new();
|
|
@@ -376,6 +384,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
return Ok(new { state = 200, lessonCount = records.Count, teachCount, dayCount, weekCount, monthCount, termCount });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 统计区级一年每周的课例数据趋势
|
|
|
/// </summary>
|
|
@@ -385,18 +394,28 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
[HttpPost("get-weekcount")]
|
|
|
public async Task<IActionResult> GetWeekCount(JsonElement jsonElement)
|
|
|
{
|
|
|
- if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ jsonElement.TryGetProperty("areaId", out JsonElement areaId);
|
|
|
|
|
|
Dictionary<int, double> weeks = new();
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
int year = DateTimeOffset.UtcNow.Year;
|
|
|
int dayOfweek = (int)DateTimeOffset.Parse($"{year}-1-1").DayOfWeek;
|
|
|
+ int currentTime = DateTimeOffset.UtcNow.DayOfYear / 7 + 1;
|
|
|
+ int currentTime1 = DateTimeOffset.UtcNow.DayOfYear / 7;
|
|
|
+
|
|
|
var sqlTxts = "select value(c) from c";
|
|
|
List<LessonCount> scount = new();
|
|
|
List<LessonCount> tcount = new();
|
|
|
|
|
|
- List<string> schools = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c where c.areaId='{areaId}'", "Base");
|
|
|
+ StringBuilder sqlTxt = new("select c.id from c");
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
+ {
|
|
|
+ sqlTxt.Append($" where c.areaId='{areaId}'");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<string> schools = await CommonFind.FindSchoolIds(cosmosClient, sqlTxt.ToString(), "Base");
|
|
|
+
|
|
|
foreach (var sId in schools)
|
|
|
{
|
|
|
await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText:sqlTxts,requestOptions:new QueryRequestOptions() { PartitionKey =new PartitionKey($"LessonCount-{sId}-{year}")}))
|
|
@@ -448,11 +467,11 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
int sweeks = days / 7;
|
|
|
//查询天数
|
|
|
int dayYear = 0;
|
|
|
- if (sweeks > 0)
|
|
|
+ if (currentTime > 0)
|
|
|
{
|
|
|
- for (int i = 1; i <= sweeks; i++)
|
|
|
+ for (int i = 0; i <= currentTime; i++)
|
|
|
{
|
|
|
- if (i == 1)
|
|
|
+ if (i == 0)
|
|
|
{
|
|
|
var bsum = bmatrix.SubMatrix(dayYear, dd, 0, bmatrix.ColumnCount).ColumnSums().Sum();
|
|
|
dayYear += dd;
|
|
@@ -478,6 +497,35 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
return Ok(new { state = 200, weeks });
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 统计所有区级的课例和活动
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("get-allarea")]
|
|
|
+ public async Task<IActionResult> GetAllArea()
|
|
|
+ {
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+
|
|
|
+ List<AllAreaInfo> areaInfos = new();
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AllAreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
|
|
|
+ {
|
|
|
+ areaInfos.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var area in areaInfos)
|
|
|
+ {
|
|
|
+ List<string> schooId = await CommonFind.FindSchoolIds(cosmosClient,$"select c.id from c where c.areaId='{area.id}'","Base");
|
|
|
+ List<string> tecId = await CommonFind.FindRolesId(cosmosClient, schooId);
|
|
|
+
|
|
|
+ area.lessCount = await LessonStatisWay.GetAll(cosmosClient, schooId, tecId);
|
|
|
+ area.activityCount = await ActivityWay.GetAll(cosmosClient, schooId, tecId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return Ok(new { state = 200 , areaInfos });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 依据课例Id获取课例详情 数据管理工具——查询工具
|
|
|
/// </summary>
|
|
@@ -505,7 +553,16 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
|
|
|
|
|
|
|
|
|
+ public record AllAreaInfo
|
|
|
+ {
|
|
|
+ public string id { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+ public string standard { get; set; }
|
|
|
+ public string standardName { get; set; }
|
|
|
+ public int lessCount { get; set; }
|
|
|
+ public int activityCount { get; set; }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
public record SchoolLen
|
|
|
{
|