|
@@ -8,6 +8,7 @@ using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using TEAMModelBI.Tool;
|
|
using TEAMModelBI.Tool;
|
|
|
|
+using TEAMModelBI.Tool.Context;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
@@ -35,10 +36,17 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("get-count")]
|
|
[HttpPost("get-count")]
|
|
- public async Task<IActionResult> GetCount()
|
|
|
|
|
|
+ public async Task<IActionResult> GetCount(JsonElement jsonElement)
|
|
{
|
|
{
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
|
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
|
+ {
|
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
+ table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
|
|
|
|
+ }
|
|
|
|
+
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
|
|
|
var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
@@ -107,6 +115,14 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
{
|
|
{
|
|
|
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
|
|
|
|
+ var redisClinet = _azureRedis.GetRedisClient(8);
|
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
|
+ {
|
|
|
|
+ table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
|
|
|
|
+ redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
|
|
|
|
+ }
|
|
|
|
+
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
|
|
|
var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
@@ -119,7 +135,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
Dictionary<long, int> stuDays = new(); //学生在线人数
|
|
Dictionary<long, int> stuDays = new(); //学生在线人数
|
|
Dictionary<long, int> tmdDays = new(); //醍摩豆账户学生
|
|
Dictionary<long, int> tmdDays = new(); //醍摩豆账户学生
|
|
|
|
|
|
- SortedSetEntry[] tchDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
|
|
|
|
|
|
+ SortedSetEntry[] tchDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
|
|
if (tchDay.Length > 0)
|
|
if (tchDay.Length > 0)
|
|
{
|
|
{
|
|
foreach (var item in tchDay)
|
|
foreach (var item in tchDay)
|
|
@@ -144,7 +160,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
{
|
|
{
|
|
foreach (var item in hourLoginsTch)
|
|
foreach (var item in hourLoginsTch)
|
|
{
|
|
{
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:teacher:{dateDay}", $"{item.Hour}", item.Teacher);//存一天24小时
|
|
|
|
|
|
+ await redisClinet.SortedSetIncrementAsync($"Login:IES:teacher:{dateDay}", $"{item.Hour}", item.Teacher);//存一天24小时
|
|
var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 0, 0)).Hour;
|
|
var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 0, 0)).Hour;
|
|
//var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
|
|
//var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
|
|
tchDays.Add(utcTo, item.Teacher);
|
|
tchDays.Add(utcTo, item.Teacher);
|
|
@@ -156,7 +172,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- SortedSetEntry[] stuDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:student:{dateDay}");
|
|
|
|
|
|
+ SortedSetEntry[] stuDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:student:{dateDay}");
|
|
if (stuDay.Length > 0)
|
|
if (stuDay.Length > 0)
|
|
{
|
|
{
|
|
foreach (var item in stuDay)
|
|
foreach (var item in stuDay)
|
|
@@ -182,7 +198,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
{
|
|
{
|
|
foreach (var item in hourLoginsStu)
|
|
foreach (var item in hourLoginsStu)
|
|
{
|
|
{
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:student:{dateDay}", $"{item.Hour}", item.Student);//存一天24小时
|
|
|
|
|
|
+ await redisClinet.SortedSetIncrementAsync($"Login:IES:student:{dateDay}", $"{item.Hour}", item.Student);//存一天24小时
|
|
var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 0, 0)).Hour;
|
|
var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 0, 0)).Hour;
|
|
//var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
|
|
//var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
|
|
stuDays.Add(utcTo, item.Student);
|
|
stuDays.Add(utcTo, item.Student);
|
|
@@ -194,7 +210,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- SortedSetEntry[] tmdDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:tmduser:{dateDay}");
|
|
|
|
|
|
+ SortedSetEntry[] tmdDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:tmduser:{dateDay}");
|
|
if (tmdDay.Length > 0)
|
|
if (tmdDay.Length > 0)
|
|
{
|
|
{
|
|
foreach (var item in stuDay)
|
|
foreach (var item in stuDay)
|
|
@@ -220,7 +236,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
{
|
|
{
|
|
foreach (var item in hourLoginsTmd)
|
|
foreach (var item in hourLoginsTmd)
|
|
{
|
|
{
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:tmduser:{dateDay}", $"{item.Hour}", item.TmdUser);//存一天24小时
|
|
|
|
|
|
+ await redisClinet.SortedSetIncrementAsync($"Login:IES:tmduser:{dateDay}", $"{item.Hour}", item.TmdUser);//存一天24小时
|
|
var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 00, 00)).Hour;
|
|
var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 00, 00)).Hour;
|
|
//var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
|
|
//var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
|
|
tmdDays.Add(utcTo, item.TmdUser);
|
|
tmdDays.Add(utcTo, item.TmdUser);
|
|
@@ -240,10 +256,15 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("get-lessontrend")]
|
|
[HttpPost("get-lessontrend")]
|
|
- public async Task<IActionResult> GetLessonTrend()
|
|
|
|
|
|
+ public async Task<IActionResult> GetLessonTrend(JsonElement jsonElement)
|
|
{
|
|
{
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
|
+ {
|
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
+ }
|
|
int year = dateTime.Year; //当前年
|
|
int year = dateTime.Year; //当前年
|
|
int month = dateTime.Month; //当前月
|
|
int month = dateTime.Month; //当前月
|
|
int day = dateTime.Day; //当天
|
|
int day = dateTime.Day; //当天
|
|
@@ -313,9 +334,15 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("get-edition")]
|
|
[HttpPost("get-edition")]
|
|
- public async Task<IActionResult> GetEdition()
|
|
|
|
|
|
+ public async Task<IActionResult> GetEdition(JsonElement jsonElement)
|
|
{
|
|
{
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
|
+ {
|
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
+ }
|
|
|
|
+
|
|
int beCnt = 0; //基础班
|
|
int beCnt = 0; //基础班
|
|
int seCnt = 0; //标准版
|
|
int seCnt = 0; //标准版
|
|
int peCnt = 0; //专业版
|
|
int peCnt = 0; //专业版
|