|
@@ -73,24 +73,28 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
todayTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", addSql, "Base");
|
|
|
todayStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", addSql, "Base");
|
|
|
|
|
|
- List<RecOnLine> recStuOnLines = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<RecOnLine>(queryText: "select c.id,c.name,c.code,c.loginInfos from c where c.pk='Base' and array_length(c.loginInfos) > 0 ", requestOptions:new QueryRequestOptions() { }))
|
|
|
- {
|
|
|
- recStuOnLines.Add(item);
|
|
|
- }
|
|
|
+ string onStuSql = $"select value(count(c.id)) from c join t in c.loginInfos where array_length(c.loginInfos) > 0 and t.expire > {hour1}";
|
|
|
+ onTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", onStuSql, "Base");
|
|
|
+ onStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", onStuSql, "Base");
|
|
|
|
|
|
- List<RecOnLine> recTecOnLines = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecOnLine>(queryText: "select c.id,c.name,c.code,c.loginInfos from c where array_length(c.loginInfos) > 0 ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
- {
|
|
|
- recTecOnLines.Add(item);
|
|
|
- }
|
|
|
+ //List<RecOnLine> recStuOnLines = new();
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<RecOnLine>(queryText: "select c.id,c.name,c.code,c.loginInfos from c where c.pk='Base' and array_length(c.loginInfos) > 0 ", requestOptions:new QueryRequestOptions() { }))
|
|
|
+ //{
|
|
|
+ // recStuOnLines.Add(item);
|
|
|
+ //}
|
|
|
+
|
|
|
+ //List<RecOnLine> recTecOnLines = new();
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecOnLine>(queryText: "select c.id,c.name,c.code,c.loginInfos from c where array_length(c.loginInfos) > 0 ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ //{
|
|
|
+ // recTecOnLines.Add(item);
|
|
|
+ //}
|
|
|
|
|
|
- //onStuCnt = (from rs in recStuOnLines from l in rs.loginInfos where l.expire >= hour1 select rs).ToList().Count(); //linq查询 学生在线人数
|
|
|
- onStuCnt = recStuOnLines.Select(rss => new RecOnLine { id = rss.id,code=rss.code, name =rss.name,loginInfos = new List<Teacher.LoginInfo> { rss.loginInfos.Find(f => f.expire >= hour1) } }).Where(w => w.loginInfos.FirstOrDefault() != null).ToList().Count(); //lambda 表达式查询 教师查询人数
|
|
|
+ ////onStuCnt = (from rs in recStuOnLines from l in rs.loginInfos where l.expire >= hour1 select rs).ToList().Count(); //linq查询 学生在线人数
|
|
|
+ //onStuCnt = recStuOnLines.Select(rss => new RecOnLine { id = rss.id,code=rss.code, name =rss.name,loginInfos = new List<Teacher.LoginInfo> { rss.loginInfos.Find(f => f.expire >= hour1) } }).Where(w => w.loginInfos.FirstOrDefault() != null).ToList().Count(); //lambda 表达式查询 教师查询人数
|
|
|
+
|
|
|
+ ////onTchCnt = (from rs in recTecOnLines from l in rs.loginInfos where l.expire >= hour1 select rs).ToList().Count(); //linq查询 教师查询人数
|
|
|
+ //onTchCnt = recTecOnLines.Select(rss => new RecOnLine { id = rss.id,code=rss.code, name =rss.name,loginInfos = new List<Teacher.LoginInfo> { rss.loginInfos.Find(f => f.expire >= hour1) } }).Where(w => w.loginInfos.FirstOrDefault() != null).ToList().Count(); //lambda 表达式查询 教师查询人数
|
|
|
|
|
|
- //onTchCnt = (from rs in recTecOnLines from l in rs.loginInfos where l.expire >= hour1 select rs).ToList().Count(); //linq查询 教师查询人数
|
|
|
- onTchCnt = recTecOnLines.Select(rss => new RecOnLine { id = rss.id,code=rss.code, name =rss.name,loginInfos = new List<Teacher.LoginInfo> { rss.loginInfos.Find(f => f.expire >= hour1) } }).Where(w => w.loginInfos.FirstOrDefault() != null).ToList().Count(); //lambda 表达式查询 教师查询人数
|
|
|
-
|
|
|
return Ok(new { state = 200, areaCnt, scCnt, tchCnt, stuCnt, todayScCnt, todayTchCnt, todayStuCnt, onStuCnt, onTchCnt});
|
|
|
}
|
|
|
|
|
@@ -258,7 +262,6 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
tchRecLesn.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() { }))
|
|
|
{
|
|
@@ -280,7 +283,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
var scLesn = scRecLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE).ToList();
|
|
|
scLessCnt.Add(i, scLesn.Count());
|
|
|
|
|
|
- var tchLesn = scRecLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE).ToList();
|
|
|
+ var tchLesn = tchRecLesn.Where(item => item.startTime >= hourS && item.startTime <= hourE).ToList();
|
|
|
tchLessCnt.Add(i, tchLesn.Count());
|
|
|
}
|
|
|
|
|
@@ -327,6 +330,10 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
public async Task<IActionResult> GetEdition()
|
|
|
{
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ int beCnt = 0; //基础班
|
|
|
+ int seCnt = 0; //标准版
|
|
|
+ int peCnt = 0; //专业版
|
|
|
+
|
|
|
List<RecScEd> scEdCnt = new();
|
|
|
var ScSql = $"select c.id,c.name,c.size,c.scale from c";
|
|
|
await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions:new QueryRequestOptions() { PartitionKey= new PartitionKey("Base")}))
|
|
@@ -334,20 +341,32 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
scEdCnt.Add(item);
|
|
|
}
|
|
|
|
|
|
- scEdCnt.ForEach(async scProductCnt =>
|
|
|
+ scEdCnt.ForEach(async scProCnt =>
|
|
|
{
|
|
|
- var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProductCnt.id, new PartitionKey("ProductSum"));
|
|
|
+ var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProCnt.id, new PartitionKey("ProductSum"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
SchoolProductSum ScProductSum = json.ToObject<SchoolProductSum>();
|
|
|
- scProductCnt.serial = ScProductSum.serial.Count();
|
|
|
- scProductCnt.service = ScProductSum.service.Count();
|
|
|
- scProductCnt.hard = ScProductSum.hard.Count();
|
|
|
+ //scProCnt.serial = ScProductSum.serial.Count();
|
|
|
+ //scProCnt.service = ScProductSum.service.Count();
|
|
|
+ //scProCnt.hard = ScProductSum.hard.Count();
|
|
|
+ int pSeriCnt = ScProductSum.serial.Count();
|
|
|
+ int pServCnt = ScProductSum.service.Count();
|
|
|
+ int pHardCnt = ScProductSum.hard.Count();
|
|
|
+ scProCnt.serial = pSeriCnt;
|
|
|
+ scProCnt.service = pServCnt;
|
|
|
+ scProCnt.hard = pHardCnt;
|
|
|
+ if (scProCnt.scale >= 500 && (pSeriCnt > 0 || pServCnt > 0 || pHardCnt > 0)) peCnt += 1;
|
|
|
}
|
|
|
+
|
|
|
+ if (scProCnt.scale >= 500 && scProCnt.serial == 0 && scProCnt.service == 0 && scProCnt.hard == 0) seCnt += 1;
|
|
|
+ if (scProCnt.scale == 0) beCnt += 1;
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
|
|
|
- return Ok(new { state = 200, scEdCnt });
|
|
|
+ return Ok(new { state = 200, beCnt, seCnt, peCnt, scEdCnt });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|