|
@@ -13,6 +13,8 @@ using TEAMModelOS.Models;
|
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
|
+using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.Census
|
|
|
{
|
|
@@ -51,35 +53,30 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
StringBuilder sqlSize = new($"select value(sum(c.size)) from c ");
|
|
|
long useSize = 0; //使用大小
|
|
|
- List<RecBlobFile> blobFiles = new();
|
|
|
+ Dictionary<string, int> typeCnt = new();
|
|
|
|
|
|
+ List<string> schoolIds = new();
|
|
|
if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
{
|
|
|
string sqlTxt = $"select c.id from c where c.areaId='{areaId}'";
|
|
|
sqlSize.Append($" where c.areaId = '{areaId}'");
|
|
|
-
|
|
|
- List<string> schools = await CommonFind.FindSchoolIds(cosmosClient, sqlTxt.ToString(), "Base");
|
|
|
- foreach (var id in schools)
|
|
|
+ schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlTxt.ToString(), "Base");
|
|
|
+ foreach (var item in StaticValue.fileType)
|
|
|
{
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecBlobFile>(queryText: "SELECT c.id,c.code,c.name,c.size,c.type FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{id}") }))
|
|
|
- {
|
|
|
- blobFiles.Add(item);
|
|
|
- }
|
|
|
-
|
|
|
- List<string> tecId = await CommonFind.FindRolesId(cosmosClient, schools);
|
|
|
- List<RecBlobFile> tecBlob = await GetBlobTeache(cosmosClient, tecId);
|
|
|
- if (tecBlob.Count > 0)
|
|
|
- {
|
|
|
- blobFiles.Concat(tecBlob);
|
|
|
- }
|
|
|
-
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecBlobFile>(queryText: $"SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { }))
|
|
|
+ int fileCnt = 0;
|
|
|
+ if (schoolIds.Count > 0)
|
|
|
{
|
|
|
- blobFiles.Add(item);
|
|
|
+ string inScStr = BICommonWay.ManyScSql(" REPLACE(c.code, 'Bloblog-', '')", schoolIds);
|
|
|
+ string typeSql = $"select value(count(c.id)) from c where c.pk='Bloblog' and {inScStr} and c.type='{item}'";
|
|
|
+ fileCnt = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School", "Teacher" }, typeSql);
|
|
|
}
|
|
|
+ typeCnt.Add(item, fileCnt);
|
|
|
+ }
|
|
|
|
|
|
+ foreach (var scId in schoolIds)
|
|
|
+ {
|
|
|
long blobsize = 0;
|
|
|
- RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", $"{id}");
|
|
|
+ RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", $"{scId}");
|
|
|
if (!value.IsNullOrEmpty)
|
|
|
{
|
|
|
JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
@@ -92,19 +89,15 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecBlobFile>(queryText: "SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { }))
|
|
|
+ foreach (var item in StaticValue.fileType)
|
|
|
{
|
|
|
- blobFiles.Add(item);
|
|
|
- }
|
|
|
+ string typeSql = $"select value(count(c.id)) from c where c.pk='Bloblog' and c.type='{item}'";
|
|
|
+ int fileCnt = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School", "Teacher" }, typeSql);
|
|
|
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<RecBlobFile>(queryText: "SELECT c.id,c.code,c.name,c.size,c.type FROM c where c.pk='Bloblog'", requestOptions: new QueryRequestOptions() { }))
|
|
|
- {
|
|
|
- blobFiles.Add(item);
|
|
|
+ typeCnt.Add(item, fileCnt);
|
|
|
}
|
|
|
-
|
|
|
- List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c", "Base");
|
|
|
-
|
|
|
- foreach (var id in schoolIds)
|
|
|
+ schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c", "Base");
|
|
|
+ foreach (var id in schoolIds)
|
|
|
{
|
|
|
long blobsize = 0;
|
|
|
RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", $"{id}");
|
|
@@ -119,11 +112,9 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var typeCount = blobFiles.GroupBy(m => new { m.type }).Select(y => new { key = y.Key.type, value = y.Count() }).ToList();
|
|
|
var areaSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", sqlSize.ToString(), "Base");
|
|
|
|
|
|
- return Ok(new { state = 200, areaSize, useSize, recCount= blobFiles.Count, typeCount });
|
|
|
-
|
|
|
+ return Ok(new { state = 200, areaSize, useSize, typeCount = typeCnt.ToList() });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|