소스 검색

优化查询全部学校空间类型统计

Li 3 년 전
부모
커밋
6ac2c8bbe8
1개의 변경된 파일274개의 추가작업 그리고 124개의 파일을 삭제
  1. 274 124
      TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

+ 274 - 124
TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

@@ -13,6 +13,7 @@ using TEAMModelOS.Models;
 using System.Text;
 using StackExchange.Redis;
 using TEAMModelOS.SDK.Extension;
+using TEAMModelBI.Models;
 
 namespace TEAMModelBI.Controllers.BIHome
 {
@@ -46,74 +47,83 @@ namespace TEAMModelBI.Controllers.BIHome
         {
             try
             {
-                var client = _azureCosmos.GetCosmosClient();
-
-                //依据学校查询教师人数
-                List<string> teacherCount_list = new();
-                //依据学校查询学生信息
-                List<string> studentCount_List = new();
-                //学校数
-                List<string> schoolCount_List = new();
-                //学校空间大小
-                long schoolsize = 0;
+                var client = _azureCosmos.GetCosmosClient();;
 
                 //查询全部教师人数
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            teacherCount_list.Add(account.GetProperty("id").GetString());
-                        }
-                    }
-                }
-
-                //查询全部学生人数
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.pk='Base'"))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            studentCount_List.Add(account.GetProperty("id").GetString());
-                        }
-                    }
-                }
-
+                long teacherCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.code='Base'", new List<string>() { "Teacher" });
+                //查询全部教师人数
+                long studentCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.pk='Base'", new List<string>() { "Student" });
                 //查询已创建多少学校
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            schoolCount_List.Add(account.GetProperty("id").GetString());
-                            schoolsize += account.GetProperty("size").GetInt64();
-                        }
-                    }
-                }
-
-                //查询教师的大小和教师集合信息
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select sum(c.size) as size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                    {
-                        schoolsize += obj.GetProperty("size").GetInt64();
-                    }
-                }
-                return Ok(new { state = 200, teacherCount = teacherCount_list.Count, studentCount = studentCount_List.Count, schoolCount = schoolCount_List.Count, schoolSize = schoolsize });
-
+                long schoolCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.code='Base'", new List<string>() { "School" });
+                //空间
+                long schoolSize = await CommonFind.FindTotals(client, "select sum(c.size) as totals from c where c.code='Base'", new List<string>() { "School" });
+
+                return Ok(new { state = 200, teacherCount, studentCount,  schoolCount, schoolSize });
+
+                ////依据学校查询教师人数
+                //List<string> teacherCount_list = new();
+                ////依据学校查询学生信息
+                //List<string> studentCount_List = new();
+                ////学校数
+                //List<string> schoolCount_List = new();
+                ////学校空间大小
+                //long schoolsize = 0
+                ////查询全部教师人数
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                //{
+                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                //    {
+                //        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                //        while (accounts.MoveNext())
+                //        {
+                //            JsonElement account = accounts.Current;
+                //            teacherCount_list.Add(account.GetProperty("id").GetString());
+                //        }
+                //    }
+                //}
+
+                ////查询全部学生人数
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.pk='Base'"))
+                //{
+                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                //    {
+                //        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                //        while (accounts.MoveNext())
+                //        {
+                //            JsonElement account = accounts.Current;
+                //            studentCount_List.Add(account.GetProperty("id").GetString());
+                //        }
+                //    }
+                //}
+
+                ////查询已创建多少学校
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //{
+                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                //    {
+                //        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                //        while (accounts.MoveNext())
+                //        {
+                //            JsonElement account = accounts.Current;
+                //            schoolCount_List.Add(account.GetProperty("id").GetString());
+                //            schoolsize += account.GetProperty("size").GetInt64();
+                //        }
+                //    }
+                //}
+
+                ////查询教师的大小和教师集合信息
+                //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select sum(c.size) as size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                //{
+                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                //    {
+                //        schoolsize += obj.GetProperty("size").GetInt64();
+                //    }
+                //}
+                //return Ok(new { state = 200, teacherCount = teacherCount_list.Count, studentCount = studentCount_List.Count, schoolCount = schoolCount_List.Count, schoolSize = schoolsize });
             }
             catch (Exception ex)
             {
@@ -1025,8 +1035,10 @@ namespace TEAMModelBI.Controllers.BIHome
             try
             {
                 long totalSize = 0; //总空间
-                long useSize = 0; //已使用空间
+                long useSize = 0; //已使用空间                
+                long teach = 0;  //学校已经分配给所有教师的空间大小GB。
                 Dictionary<string, long> typeStics = new Dictionary<string, long>(); //所有类型
+                Dictionary<string, double?> typeStics1 = new Dictionary<string, double?>(); //所有类型
 
                 List<string> schoolId = new List<string>();
                 var cosmosClient = _azureCosmos.GetCosmosClient();
@@ -1044,84 +1056,222 @@ namespace TEAMModelBI.Controllers.BIHome
                 //查询学校已使用空间大小
                 foreach (var itemId in schoolId)
                 {
-                    RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
-                    if (!value.IsNullOrEmpty)
+                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
+                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
                     {
-                        useSize += Convert.ToInt64(value);
-                        //JsonElement record = value.ToString().ToObject<JsonElement>();
-                        //long tempSize = 0;
-                        //if (record.TryGetInt64(out tempSize))
-                        //{
-                        //    sizeS += tempSize;
-                        //}
+                        var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
+                            {
+                                teach += _size.GetInt32();
+                                break;
+                            }
+                        }
+                    }
+
+                    Dictionary<string, double?> schoolStics = new Dictionary<string, double?>(); //学校空间
+                    long blobsize = 0;
+                    RedisValue value = default;
+                    value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
+                    if (value != default && !value.IsNullOrEmpty)
+                    {
+                        JsonElement record = value.ToString().ToObject<JsonElement>();
+                        if (record.TryGetInt64(out blobsize))
+                        {
+                        }
                     }
                     else
                     {
                         var client = _azureStorage.GetBlobContainerClient(itemId);
                         var size = await client.GetBlobsCatalogSize();
-                        var temp = await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
-                        foreach (var itemKey in size.Item2.Keys)
+                        await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
+                        foreach (var key in size.Item2.Keys)
                         {
-                            var temp1 = await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", itemKey);
-                            var temp2 = await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", itemKey, size.Item2[itemKey].HasValue ? size.Item2[itemKey].Value : 0);
-                            useSize += Convert.ToInt64(temp2);
+                            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);
                         }
+                        useSize += (long)size.Item1;
+                        schoolStics = size.Item2;
+                        typeStics1 = (from e in typeStics1.Concat(schoolStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
+                        continue;
                     }
 
-                    SortedSetEntry[] sortedSetEntries = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemId}");
-                    if (sortedSetEntries != null)
+                    SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
+                    if (Scores != null)
                     {
-                        foreach (var tempSorted in sortedSetEntries)
+                        foreach (var score in Scores)
                         {
-                            if (typeStics.TryGetValue($"{tempSorted.Element}", out long val))
-                                typeStics[$"{tempSorted.Element}"] = Convert.ToInt64(tempSorted.Score) != 0 ? val + Convert.ToInt64(tempSorted.Score) : 0;
-                            else
-                                typeStics.Add($"{tempSorted.Element}", Convert.ToInt64(tempSorted.Score));
+                            double val = score.Score;
+                            string key = score.Element.ToString();
+                            schoolStics.Add(key, val);
                         }
-                    }
-                }
-                
-                List<string> teacherId = new List<string>(); //教师Id集合
-                //查询教师的大小和教师集合信息
-                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") }))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                    {
-                        totalSize += obj.GetProperty("size").GetInt64();
-                        teacherId.Add(obj.GetProperty("id").GetString());
-                    }
-                }
 
-                //查询教师已使用空间大小
-                foreach (var itemTeach in teacherId)
-                {
-                    RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
-                    if (!tempValue.IsNullOrEmpty)
-                    {
-                        useSize += Convert.ToInt64(tempValue);
-                        //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
-                        //long tempSize = 0;
-                        //if (record.TryGetInt64(out tempSize))
-                        //{
-                        //    sizeT += tempSize;
-                        //}
-                    }
+                        useSize += blobsize;
+                        typeStics1 = (from e in typeStics1.Concat(schoolStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
+                        continue;
 
-                    SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
-                    if (tempSorted != null)
+                        //return Ok(new { size = blobsize, catalog = catalog, teach });
+                    }
+                    else
                     {
-                        foreach (var itemSorted in tempSorted)
+                        var client = _azureStorage.GetBlobContainerClient(itemId);
+                        var size = await client.GetBlobsCatalogSize();
+                        await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
+                        foreach (var key in size.Item2.Keys)
                         {
-                            if (typeStics.TryGetValue($"{itemSorted.Element}", out long val))
-                                typeStics[$"{itemSorted.Element}"] = Convert.ToInt64(itemSorted.Score) != 0 ? val + Convert.ToInt64(itemSorted.Score) : 0;
-                            else
-                                typeStics.Add($"{itemSorted.Element}", Convert.ToInt64(itemSorted.Score));
+                            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);
                         }
+
+                        useSize += (long)size.Item1;
+                        schoolStics = size.Item2;
+                        typeStics1 = (from e in typeStics1.Concat(schoolStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
+                        continue;
                     }
-                }
 
-                return Ok(new { state = 200, totalSize, useSize, stics = typeStics.ToList() });
+                    ////RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
+                    //if (!value.IsNullOrEmpty)
+                    //{
+                    //    useSize += Convert.ToInt64(value);
+                    //    //JsonElement record = value.ToString().ToObject<JsonElement>();
+                    //    //long tempSize = 0;
+                    //    //if (record.TryGetInt64(out tempSize))
+                    //    //{
+                    //    //    sizeS += tempSize;
+                    //    //}
+                    //}
+                    //else
+                    //{
+                    //    var client = _azureStorage.GetBlobContainerClient(itemId);
+                    //    var size = await client.GetBlobsCatalogSize();
+                    //    var temp = await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
+                    //    foreach (var itemKey in size.Item2.Keys)
+                    //    {
+                    //        var temp1 = await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", itemKey);
+                    //        var temp2 = await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", itemKey, size.Item2[itemKey].HasValue ? size.Item2[itemKey].Value : 0);
+                    //        useSize += Convert.ToInt64(temp2);
+                    //    }
+                    //}
+
+                    //SortedSetEntry[] sortedSetEntries = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemId}");
+                    //if (sortedSetEntries != null)
+                    //{
+                    //    foreach (var tempSorted in sortedSetEntries)
+                    //    {
+                    //        if (typeStics.TryGetValue($"{tempSorted.Element}", out long val))
+                    //            typeStics[$"{tempSorted.Element}"] = Convert.ToInt64(tempSorted.Score) != 0 ? val + Convert.ToInt64(tempSorted.Score) : 0;
+                    //        else
+                    //            typeStics.Add($"{tempSorted.Element}", Convert.ToInt64(tempSorted.Score));
+                    //    }
+                    //}
+                }
+                
+                ////教师数据
+                //List<string> teacherId = new List<string>(); //教师Id集合
+                ////查询教师的大小和教师集合信息
+                //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") }))
+                //{
+                //    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                //    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                //    {
+                //        totalSize += obj.GetProperty("size").GetInt64();
+                //        teacherId.Add(obj.GetProperty("id").GetString());
+                //    }
+                //}
+
+                ////查询教师已使用空间大小
+                //foreach (var itemTeach in teacherId)
+                //{
+
+                //    Dictionary<string, double?> teachStics = new Dictionary<string, double?>(); //学校空间
+
+                //    long blobsize = 0;
+                //    RedisValue value = default;
+                //    value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
+                //    if (value != default && !value.IsNullOrEmpty)
+                //    {
+                //        JsonElement record = value.ToString().ToObject<JsonElement>();
+                //        if (record.TryGetInt64(out blobsize))
+                //        {
+                //        }
+                //    }
+                //    else
+                //    {
+                //        var client = _azureStorage.GetBlobContainerClient(itemTeach);
+                //        var size = await client.GetBlobsCatalogSize();
+                //        await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemTeach, size.Item1);
+                //        foreach (var key in size.Item2.Keys)
+                //        {
+                //            await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemTeach}", key);
+                //            await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemTeach}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
+                //        }
+
+                //        useSize += (long)size.Item1;
+                //        teachStics = size.Item2;
+                //        typeStics1 = (from e in typeStics1.Concat(teachStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
+                //        continue;
+
+                //    }
+
+                //    SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemTeach}");
+                //    if (Scores != null)
+                //    {
+                //        foreach (var score in Scores)
+                //        {
+                //            double val = score.Score;
+                //            string key = score.Element.ToString();
+                //            teachStics.Add(key, val);
+                //        }
+
+                //        useSize += blobsize;
+                //        typeStics1 = (from e in typeStics1.Concat(teachStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
+                //        continue;
+
+                //    }
+                //    else
+                //    {
+                //        var client = _azureStorage.GetBlobContainerClient(itemTeach);
+                //        var size = await client.GetBlobsCatalogSize();
+                //        await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemTeach, size.Item1);
+                //        foreach (var key in size.Item2.Keys)
+                //        {
+                //            await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemTeach}", key);
+                //            await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemTeach}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
+                //        }
+
+                //        useSize += (long)size.Item1;
+                //        teachStics = size.Item2;
+                //        typeStics1 = (from e in typeStics1.Concat(teachStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
+                //        continue;
+                //    }
+
+                //    //RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
+                //    //if (!tempValue.IsNullOrEmpty)
+                //    //{
+                //    //    useSize += Convert.ToInt64(tempValue);
+                //    //    //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
+                //    //    //long tempSize = 0;
+                //    //    //if (record.TryGetInt64(out tempSize))
+                //    //    //{
+                //    //    //    sizeT += tempSize;
+                //    //    //}
+                //    //}
+
+                //    //SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
+                //    //if (tempSorted != null)
+                //    //{
+                //    //    foreach (var itemSorted in tempSorted)
+                //    //    {
+                //    //        if (typeStics.TryGetValue($"{itemSorted.Element}", out long val))
+                //    //            typeStics[$"{itemSorted.Element}"] = Convert.ToInt64(itemSorted.Score) != 0 ? val + Convert.ToInt64(itemSorted.Score) : 0;
+                //    //        else
+                //    //            typeStics.Add($"{itemSorted.Element}", Convert.ToInt64(itemSorted.Score));
+                //    //    }
+                //    //}
+                //}
+
+                return Ok(new { state = 200, totalSize, teach, useSize, stics = typeStics1.ToList() });
             }
             catch (Exception ex)
             {