|
@@ -241,36 +241,35 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
int day = dateTime.Day; //当天
|
|
|
int hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {dateTime.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH")); //当前小时
|
|
|
|
|
|
- Dictionary<int, int> scLessCnt = new(); //学校课例
|
|
|
- Dictionary<int, int> tchLessCnt = new(); //教师课例
|
|
|
- Dictionary<int, int> yesterdayCnt = new(); //昨天24小时课例
|
|
|
-
|
|
|
var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
|
var (lastDayS, lastdayE) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{dateTime.Year}-{dateTime.Month}-{dateTime.Day - 1}")); //昨天开始时间
|
|
|
|
|
|
- List<RecLesn> scRecLesn = new(); //学校课例
|
|
|
- List<RecLesn> tchRecLesn = new(); //个人课例
|
|
|
- List<RecLesn> allRecLesn = new(); //昨天所有课例
|
|
|
+ Dictionary<int, int> sdOpenLesn = new(); //今日开课
|
|
|
+ Dictionary<int, int> sdUpdLesn = new(); //今日上传课例
|
|
|
+ Dictionary<int, int> ydOpenLesn = new(); //昨日开课
|
|
|
+ Dictionary<int, int> ydUpdLesn = new(); //昨日上传课例
|
|
|
+
|
|
|
+ List<RecLesn> sameDayLesn = new(); //今天课例
|
|
|
+ List<RecLesn> yesterDayLesn = new(); //昨日课例
|
|
|
string lesnSql = $"select c.id,c.name,c.code,c.school,c.scope,c.startTime from c where c.pk='LessonRecord' and c.startTime >={daySt} and c.startTime <= {dayEt}";
|
|
|
await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecLesn>(queryText: lesnSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
{
|
|
|
- scRecLesn.Add(item);
|
|
|
+ sameDayLesn.Add(item);
|
|
|
}
|
|
|
-
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecLesn>(queryText: lesnSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecLesn>(queryText: lesnSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
{
|
|
|
- tchRecLesn.Add(item);
|
|
|
+ sameDayLesn.Add(item);
|
|
|
}
|
|
|
|
|
|
- string allLesnSql = $"select c.id,c.name,c.code,c.school,c.scope,c.startTime from c where c.pk='LessonRecord' and c.startTime >={lastDayS} and c.startTime <= {lastdayE}";
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecLesn>(queryText: allLesnSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
+ string yesterDayLesnSql = $"select c.id,c.name,c.code,c.school,c.scope,c.startTime from c where c.pk='LessonRecord' and c.startTime >={lastDayS} and c.startTime <= {lastdayE}";
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecLesn>(queryText: yesterDayLesnSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
{
|
|
|
- allRecLesn.Add(item);
|
|
|
+ yesterDayLesn.Add(item);
|
|
|
}
|
|
|
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecLesn>(queryText: allLesnSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecLesn>(queryText: yesterDayLesnSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
|
|
|
{
|
|
|
- allRecLesn.Add(item);
|
|
|
+ yesterDayLesn.Add(item);
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < 24; i++)
|
|
@@ -280,46 +279,25 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
DateTimeOffset timeHour = new DateTime(year, month, day, i, 0, 0);
|
|
|
var (hourS, hourE) = TimeHelper.GetStartOrEnd(timeHour, type: "hour");
|
|
|
|
|
|
- var scLesn = scRecLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE).ToList();
|
|
|
- scLessCnt.Add(i, scLesn.Count());
|
|
|
+ var openLesn = sameDayLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE && item.upload == 0);
|
|
|
+ sdOpenLesn.Add(i, openLesn.Count());
|
|
|
+
|
|
|
+ var UpdLesn = sameDayLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE && item.upload == 1);
|
|
|
+ sdUpdLesn.Add(i, openLesn.Count());
|
|
|
|
|
|
- var tchLesn = tchRecLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE).ToList();
|
|
|
- tchLessCnt.Add(i, tchLesn.Count());
|
|
|
}
|
|
|
|
|
|
DateTimeOffset yesterday = new DateTime(year, month, day - 1, i, 0, 0);
|
|
|
var (yHourS, yHourE) = TimeHelper.GetStartOrEnd(yesterday, type: "hour");
|
|
|
|
|
|
- var allLesn = allRecLesn.Where(item => item.startTime >= yHourS && item.startTime <= yHourE).ToList();
|
|
|
- yesterdayCnt.Add(i, allLesn.Count());
|
|
|
- }
|
|
|
+ var yOpenLesn = yesterDayLesn.Where(item => item.startTime >= yHourS && item.startTime <= yHourE && item.upload == 0).ToList();
|
|
|
+ ydOpenLesn.Add(i, yOpenLesn.Count);
|
|
|
|
|
|
- ////通过循环实时查询课例统计
|
|
|
- //for (int i = 0; i < 24; i++)
|
|
|
- //{
|
|
|
- // if (hour >= i)
|
|
|
- // {
|
|
|
- // DateTimeOffset timeHour = new DateTime(year, month, day, i, 0, 0);
|
|
|
- // var (hourS, hourE) = TimeHelper.GetStartOrEnd(timeHour, type: "hour");
|
|
|
- // await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<int>(queryText: $"select value(count(c.id)) from c where c.pk='LessonRecord' and c.startTime >={hourS} and c.startTime <= {hourE}", requestOptions: new QueryRequestOptions() { }))
|
|
|
- // {
|
|
|
- // scLessCnt.Add(i, item);
|
|
|
- // }
|
|
|
-
|
|
|
- // await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(queryText: $"select value(count(c.id)) from c where c.startTime >={hourS} and c.startTime <= {hourE}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("LessonRecord") }))
|
|
|
- // {
|
|
|
- // tchLessCnt.Add(i, item);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // DateTimeOffset yesterday = new DateTime(year, month, day - 1, i, 0, 0);
|
|
|
- // var (yHourS, yHourE) = TimeHelper.GetStartOrEnd(yesterday, type: "hour");
|
|
|
- // string sql = $"select value(count(c.id)) from c where c.pk='LessonRecord' and c.startTime >= {yHourS} and c.startTime <= {yHourE}";
|
|
|
- // int hourLessCnt = await CommonFind.GetSqlValueCount(cosmosClient, new List<string> { "School", "Teacher" }, sql);
|
|
|
- // yesterdayCnt.Add(i, hourLessCnt);
|
|
|
- //}
|
|
|
+ var yUpdLesn = yesterDayLesn.Where(item => item.startTime >= yHourS && item.startTime <= yHourE && item.upload == 1).ToList();
|
|
|
+ ydUpdLesn.Add(i, yUpdLesn.Count);
|
|
|
+ }
|
|
|
|
|
|
- return Ok(new { state = 200, scLessCnt = scLessCnt.ToList(), tchLessCnt = tchLessCnt.ToList(), yesterdayCnt = yesterdayCnt.ToList() });
|
|
|
+ return Ok(new { state = 200, sdOpenLesn = sdOpenLesn.ToList(), sdUpdLesn = sdUpdLesn.ToList(), ydOpenLesn = ydOpenLesn.ToList(), ydUpdLesn = ydUpdLesn.ToList() });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -405,6 +383,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
public string school { get; set; }
|
|
|
public string scope{get;set;}
|
|
|
public long startTime { get; set; }
|
|
|
+ public int upload { get; set; }
|
|
|
}
|
|
|
}
|
|
|
}
|