|
@@ -14,6 +14,7 @@ using System.Text;
|
|
|
using StackExchange.Redis;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelBI.Tool;
|
|
|
+using TEAMModelBI.Tool.Context;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BIHome
|
|
|
{
|
|
@@ -43,11 +44,14 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-allnumber")]
|
|
|
- public async Task<IActionResult> GetAllNumber()
|
|
|
+ public async Task<IActionResult> GetAllNumber(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var client = _azureCosmos.GetCosmosClient();;
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ client = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
|
|
//查询全部教师人数
|
|
|
long teacherCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.code='Base'", new List<string>() { "Teacher" });
|
|
@@ -79,6 +83,10 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
try
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
|
|
int surveyJoinCount = 0; //调查参加数量
|
|
|
int surveyDoneCount = 0; //调查完成数量
|
|
@@ -94,7 +102,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
int voteAreaDoneCount = 0; //投票区域完成数量
|
|
|
|
|
|
//问卷调查
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher")
|
|
|
.GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Survey' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.owner))
|
|
@@ -119,7 +127,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
}
|
|
|
|
|
|
//评量检测
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher")
|
|
|
.GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'ExamLite' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.owner))
|
|
@@ -144,7 +152,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
}
|
|
|
|
|
|
//投票活动
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher")
|
|
|
.GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Vote' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.owner))
|
|
@@ -184,11 +192,15 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-alldiststics")]
|
|
|
- public async Task<IActionResult> GetAllDistStics()
|
|
|
+ public async Task<IActionResult> GetAllDistStics(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+
|
|
|
List<SticsCity> standards = new();
|
|
|
StringBuilder stringBuder = new("select c.id,c.name,c.provName,c.cityName,c.standard from c");
|
|
|
//查询省份区域
|
|
@@ -266,8 +278,11 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
try
|
|
|
{
|
|
|
if(!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
|
|
|
-
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+
|
|
|
List<string> areaStandard = new();
|
|
|
//查询省份区域
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
|
|
@@ -311,11 +326,15 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-provincestics")]
|
|
|
- public async Task<IActionResult> GetProvinceStics()
|
|
|
+ public async Task<IActionResult> GetProvinceStics(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+
|
|
|
List<ProvinceStandard> standards = new();
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
|
|
|
{
|
|
@@ -416,11 +435,14 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-cityschool")]
|
|
|
- public async Task<IActionResult> GetCitySchool()
|
|
|
+ public async Task<IActionResult> GetCitySchool(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
|
|
List<CityStandard> standards = new();
|
|
|
//查询省份区域
|
|
@@ -486,7 +508,10 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
try
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
|
|
|
List<DistrictStandard> districtStandards = new();
|
|
|
//查询省份区域
|
|
@@ -537,7 +562,6 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
districtSticss.Add(districtStics);
|
|
|
}
|
|
|
return Ok(new { state = 200, districtSticss });
|
|
|
-
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -558,7 +582,11 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+
|
|
|
List<AllCityStics> tempAllCityStics = new();
|
|
|
//查询省份区域
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
|
|
@@ -641,7 +669,6 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
|
|
|
//查询学校学生人数
|
|
|
districtStics.studentCount += await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c", "Student","Base");
|
|
|
-
|
|
|
}
|
|
|
tempDistrictStics.Add(districtStics);
|
|
|
}
|
|
@@ -666,15 +693,22 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-sticsbipower")]
|
|
|
- public async Task<IActionResult> GetSticsBIPower()
|
|
|
+ public async Task<IActionResult> GetSticsBIPower(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
Dictionary<string, object> dic = new() { { "PartitionKey", "authority-bi" } };
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("SchoolSetting");
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ {
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+ table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("SchoolSetting");
|
|
|
+ }
|
|
|
+
|
|
|
List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
|
|
|
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
List<PowerStics> powerStics = new();
|
|
|
foreach (var temp in authorityBIList)
|
|
|
{
|
|
@@ -708,10 +742,12 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("get-datatypestics")]
|
|
|
- public async Task<IActionResult> GetDataTypeStics()
|
|
|
+ public async Task<IActionResult> GetDataTypeStics(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
+
|
|
|
long totalSize = 0; //总空间
|
|
|
long useSize = 0; //已使用空间
|
|
|
long teach = 0; //学校已经分配给所有教师的空间大小GB。
|
|
@@ -720,6 +756,13 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
|
|
|
List<string> schoolId = new();
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ var redisClinet = _azureRedis.GetRedisClient(8);
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ {
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+ redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//查询学校空间和学校Id
|
|
|
totalSize = await CommonFind.FindTotals(cosmosClient, "select sum(c.size) as totals from c", "School", "Base");
|
|
@@ -728,7 +771,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
//查询学校已使用空间大小
|
|
|
foreach (var itemId in schoolId)
|
|
|
{
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
|
|
|
{
|
|
|
var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -744,7 +787,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
|
|
|
long blobsize = 0;
|
|
|
RedisValue value = default;
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
|
|
|
+ value = redisClinet.HashGet($"Blob:Record", itemId);
|
|
|
if (value != default && !value.IsNullOrEmpty)
|
|
|
{
|
|
|
JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
@@ -753,12 +796,16 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
else
|
|
|
{
|
|
|
var client = _azureStorage.GetBlobContainerClient(itemId);
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ {
|
|
|
+ client = _azureStorage.GetBlobContainerClient(containerName: itemId, name: BIConst.GlobalSite);
|
|
|
+ }
|
|
|
var size = await client.GetBlobsCatalogSize();
|
|
|
- await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
|
|
|
+ await redisClinet.HashSetAsync($"Blob:Record", itemId, size.Item1);
|
|
|
foreach (var key in size.Item2.Keys)
|
|
|
{
|
|
|
- await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
|
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
|
|
|
+ await redisClinet.SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
|
|
|
+ await redisClinet.SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
|
|
|
}
|
|
|
useSize += size.Item1.Value;
|
|
|
typeStics1 = typeStics1.Concat(size.Item2).GroupBy(g => g.Key).ToDictionary(k => k.Key, k => k.Sum(kvp => kvp.Value)); //lamebda表达式
|
|
@@ -766,7 +813,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
|
|
|
+ SortedSetEntry[] Scores = redisClinet.SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
|
|
|
if (Scores != null)
|
|
|
{
|
|
|
Dictionary<string, double?> schoolStics = new(); //学校空间
|
|
@@ -786,12 +833,16 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
else
|
|
|
{
|
|
|
var client = _azureStorage.GetBlobContainerClient(itemId);
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ {
|
|
|
+ client = _azureStorage.GetBlobContainerClient(containerName: itemId, name: BIConst.GlobalSite);
|
|
|
+ }
|
|
|
var size = await client.GetBlobsCatalogSize();
|
|
|
- await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
|
|
|
+ await redisClinet.HashSetAsync($"Blob:Record", itemId, size.Item1);
|
|
|
foreach (var key in size.Item2.Keys)
|
|
|
{
|
|
|
- await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
|
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
|
|
|
+ await redisClinet.SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
|
|
|
+ await redisClinet.SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
|
|
|
}
|
|
|
|
|
|
useSize += size.Item1.Value;
|
|
@@ -955,15 +1006,22 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("get-teachetypestics")]
|
|
|
- public async Task<IActionResult> GetTeachDataTypeStics()
|
|
|
+ public async Task<IActionResult> GetTeachDataTypeStics(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
long teacheSize = 0; //教师空间
|
|
|
long sizeT = 0; //教师空间
|
|
|
List<string> teacherId = new(); //教师Id集合
|
|
|
Dictionary<string, long> typeStics = new(); //所有类型
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ var redisClinet = _azureRedis.GetRedisClient(8);
|
|
|
+ if ($"{site}".Equals(BIConst.GlobalSite))
|
|
|
+ {
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
|
|
|
+ redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
|
|
|
+ }
|
|
|
|
|
|
//查询教师的大小和教师集合信息
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
@@ -979,7 +1037,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
//查询教师已使用空间大小
|
|
|
foreach (var itemTeach in teacherId)
|
|
|
{
|
|
|
- RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
|
|
|
+ RedisValue tempValue = redisClinet.HashGet($"Blob:Record", itemTeach);
|
|
|
if (!tempValue.IsNullOrEmpty)
|
|
|
{
|
|
|
sizeT += Convert.ToInt64(tempValue);
|
|
@@ -991,7 +1049,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
- SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
|
|
|
+ SortedSetEntry[] tempSorted = await redisClinet.SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
|
|
|
if (tempSorted != null)
|
|
|
{
|
|
|
foreach (var itemSorted in tempSorted)
|
|
@@ -1011,11 +1069,8 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-datatypestics \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 存放的类型
|
|
|
/// </summary>
|
|
@@ -1099,13 +1154,10 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
public string standard { get; set; }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public record PowerStics
|
|
|
{
|
|
|
public string powerName { get; set; }
|
|
|
-
|
|
|
- public int powerCount { get; set; }
|
|
|
-
|
|
|
+ public int powerCount { get; set; }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|