|
@@ -4,6 +4,7 @@ using DocumentFormat.OpenXml.Math;
|
|
|
using MathNet.Numerics.LinearAlgebra.Double;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Azure.Amqp.Framing;
|
|
|
+using StackExchange.Redis;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -26,11 +27,18 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
|
|
|
/// <param name="cosmosClient"></param>
|
|
|
/// <param name="scId"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<StatsInfo> GetSingleSc(CosmosClient cosmosClient, string scId, int year = 0)
|
|
|
+ public static async Task<StatsInfo> GetSingleSc(CosmosClient cosmosClient,IDatabase redisClinet, string scId, int year = 0)
|
|
|
{
|
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
if (year < dateTime.Year)
|
|
|
dateTime = new(year, 12, 31, 23, 59, 59, TimeSpan.Zero);
|
|
|
+ long userSize = 0;
|
|
|
+ RedisValue redisValue = redisClinet.HashGet($"Blob:Record", scId);
|
|
|
+ if (redisValue != default && !redisValue.IsNullOrEmpty)
|
|
|
+ {
|
|
|
+ JsonElement record = redisValue.ToString().ToObject<JsonElement>();
|
|
|
+ if (record.TryGetInt64(out userSize)) { }
|
|
|
+ }
|
|
|
|
|
|
StatsInfo statsInfo = new() { id = $"{year}-{scId}" };
|
|
|
var (dayS, dayE) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
|
|
@@ -62,6 +70,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
|
|
|
statsInfo.scCreateTime = scBase.createTime;
|
|
|
statsInfo.areaId = scBase.areaId;
|
|
|
statsInfo.year = year;
|
|
|
+ statsInfo.useSize = userSize;
|
|
|
|
|
|
string tchSql = $"{currSql} where ARRAY_CONTAINS(c.roles, 'teacher', true) AND c.status = 'join'";
|
|
|
statsInfo.tch = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Teacher-{scBase.id}", tchSql);
|
|
@@ -138,7 +147,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
|
|
|
monthStu = statsInfos.Select(s => s.monthStu).Sum(),
|
|
|
room = statsInfos.Select(s => s.room).Sum(),
|
|
|
witRoom = statsInfos.Select(s => s.witRoom).Sum(),
|
|
|
- size = statsInfos.Select(s => s.size).Sum()
|
|
|
+ size = statsInfos.Select(s => s.size).Sum(),
|
|
|
+ useSize = statsInfos.Select(s => s.useSize).Sum()
|
|
|
};
|
|
|
areaInfo.lesson.all = statsInfos.Select(s => s.lesson.all).Sum();
|
|
|
areaInfo.lesson.open = statsInfos.Select(s => s.lesson.open).Sum();
|