|
@@ -1,12 +1,17 @@
|
|
|
using Azure.Cosmos;
|
|
|
+using Azure.Storage.Blobs;
|
|
|
+using Azure.Storage.Blobs.Models;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using StackExchange.Redis;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Text;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
|
+using TEAMModelBI.Models.RecordM;
|
|
|
using TEAMModelBI.Tool;
|
|
|
using TEAMModelBI.Tool.Context;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
@@ -40,14 +45,17 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
{
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient($"0-public");
|
|
|
jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
{
|
|
|
cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient($"0-public", BIConst.GlobalSite);
|
|
|
}
|
|
|
|
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
+ string cDay = dateTime.ToString("yyyyMMdd");
|
|
|
|
|
|
var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
|
var (daySf, dayEf) = TimeHelper.GetStartOrEnd(dateTime, dateLenth: false); //今天开始时间 10位
|
|
@@ -61,6 +69,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
int scCnt = 0; //学校总数
|
|
|
int tchCnt = 0; //教师总数
|
|
|
int stuCnt = 0; //学生总数
|
|
|
+ int apiCnt = 0; //当天接口访问总量
|
|
|
|
|
|
int onStuCnt = 0; //学生在线人数
|
|
|
int onTchCnt = 0; //教师在线人数
|
|
@@ -85,6 +94,23 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
onTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", onStuSql, "Base");
|
|
|
onStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", onStuSql, "Base");
|
|
|
|
|
|
+ //接口访问量
|
|
|
+ List<RecCnt> recCnts = new();
|
|
|
+ await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"visitCnt/{cDay}"))
|
|
|
+ {
|
|
|
+ BlobClient tempBlobClient = blobClient.GetBlobClient(blobItem.Name);
|
|
|
+ if (await tempBlobClient.ExistsAsync())
|
|
|
+ {
|
|
|
+ using (var meomoryStream = new MemoryStream())
|
|
|
+ {
|
|
|
+ var response = blobClient.GetBlobClient($"{blobItem.Name}").DownloadTo(meomoryStream);
|
|
|
+ RecCnt recCnt = Encoding.UTF8.GetString(meomoryStream.ToArray()).ToString().ToObject<RecCnt>();
|
|
|
+ recCnts.Add(recCnt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ apiCnt = recCnts.Select(x => x.apiCnt.Select(s => s.count).Sum()).Sum();
|
|
|
+
|
|
|
//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() { }))
|
|
|
//{
|
|
@@ -103,7 +129,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
////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});
|
|
|
+ return Ok(new { state = 200, areaCnt, scCnt, tchCnt, stuCnt, todayScCnt, todayTchCnt, todayStuCnt, onStuCnt, onTchCnt, apiCnt });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|