Browse Source

删除第一本首页多余的接口。

Li 2 năm trước cách đây
mục cha
commit
4e297335c5
1 tập tin đã thay đổi với 0 bổ sung472 xóa
  1. 0 472
      TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

+ 0 - 472
TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

@@ -71,255 +71,6 @@ namespace TEAMModelBI.Controllers.BIHome
             }
         }
 
-        /// <summary>
-        /// 获取其它类型的统计:问卷调查、评量检测、投票活动
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-othertypes")]
-        public async Task<IActionResult> GetOtherTypes(JsonElement jsonElement) 
-        {
-            try
-            {
-                if (!jsonElement.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
-                jsonElement.TryGetProperty("site", out JsonElement site);
-                var cosmosClient = _azureCosmos.GetCosmosClient(); 
-                if ($"{site}".Equals(BIConst.Global))
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-
-                int surveyJoinCount = 0;        //调查参加数量
-                int surveyDoneCount = 0;        //调查完成数量
-                int surveyAreaJoinCount = 0;    //调查区域参加数量
-                int surveyAreaDoneCount = 0;    //调查区域完成数量
-                int examJoinCount = 0;          //评量检测参加数量
-                int examDoneCount = 0;          //评量检测完成数量
-                int examAreaJoinCount = 0;      //评量检测区域参加数量
-                int examAreaDoneCount = 0;      //评量检测区域完成数量
-                int voteJoinCount = 0;          //投票参加数量
-                int voteDoneCount = 0;          //投票完成数量
-                int voteAreaJoinCount = 0;      //投票区域参加数量  
-                int voteAreaDoneCount = 0;      //投票区域完成数量
-
-                //问卷调查
-                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))
-                    {
-                        if (item.owner.Equals("school"))
-                        {
-                            surveyJoinCount += 1;
-                            if (item.taskStatus > 0)
-                            {
-                                surveyDoneCount += 1;
-                            }
-                        }
-                        else if (item.owner.Equals("area"))
-                        {
-                            surveyAreaJoinCount += 1;
-                            if (item.taskStatus > 0)
-                            {
-                                surveyAreaDoneCount += 1;
-                            }
-                        }
-                    }
-                }
-
-                //评量检测
-                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))
-                    {
-                        if (item.owner.Equals("school"))
-                        {
-                            examJoinCount += 1;
-                            if (item.taskStatus > 0)
-                            {
-                                examDoneCount += 1;
-                            }
-                        }
-                        else if (item.owner.Equals("area"))
-                        {
-                            examAreaJoinCount += 1;
-                            if (item.taskStatus > 0)
-                            {
-                                examAreaDoneCount += 1;
-                            }
-                        }
-                    }
-                }
-
-                //投票活动
-                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))
-                    {
-                        if (item.owner.Equals("school"))
-                        {
-                            voteJoinCount += 1;
-                            if (item.taskStatus > 0)
-                            {
-                                voteDoneCount += 1;
-                            }
-                        }
-                        else if (item.owner.Equals("area"))
-                        {
-                            voteAreaJoinCount += 1;
-                            if (item.taskStatus > 0)
-                            {
-                                voteAreaDoneCount += 1;
-                            }
-                        }
-                    }
-                }
-
-                return Ok(new { state = 200, surveyJoinCount, surveyDoneCount, surveyAreaJoinCount, surveyAreaDoneCount, examJoinCount, examDoneCount, examAreaJoinCount, examAreaDoneCount, voteJoinCount, voteDoneCount, voteAreaJoinCount, voteAreaDoneCount });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-othertypes \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 查询所有区级信息统计数据
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-alldiststics")]
-        public async Task<IActionResult> GetAllDistStics(JsonElement jsonElement) 
-        {
-            try
-            {
-                jsonElement.TryGetProperty("site", out JsonElement site);
-                var cosmosClient = _azureCosmos.GetCosmosClient();
-                if ($"{site}".Equals(BIConst.Global))
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-
-                List<SticsCity> standards = new();
-                StringBuilder stringBuder = new("select c.id,c.name,c.provName,c.cityName,c.standard from c");
-                //查询省份区域
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: stringBuder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
-                {
-                    SticsCity sticsCity = new()
-                    {
-                        areaId = item.id,
-                        provName = item.provName,
-                        cityName = item.cityName,
-                        distName = item.name,
-                        standard = item.standard
-                    };
-                    standards.Add(sticsCity);
-                }
-                List<SticsDist> sticsDists = new();
-
-                //查询所有下面的学校数量
-                foreach (var itemStandrds in standards)
-                {
-                    SticsDist sticsDist = new()
-                    {
-                        provName = itemStandrds.provName,
-                        cityName = itemStandrds.cityName,
-                        distName = itemStandrds.distName,
-                        standard = itemStandrds.standard,
-                    };
-
-                    //查询区级下的学校ID
-                    string sqlTxt = $"select c.id from c where c.areaId='{itemStandrds.areaId}' and c.standard='{itemStandrds.standard}'";
-                    List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlTxt, "Base");
-
-                    sticsDist.schoolCount = schoolIds.Count;
-
-                    int teacherCount = 0;  //教师数量
-                    int studentCount = 0;  //学生数量
-
-                    //查询学校下面的教师人数
-                    foreach (var itemSchool in schoolIds)
-                    {
-                        //查询全部教师人数
-                        string sqlT = $"select value(count(c.id)) from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
-                        teacherCount += await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", sqlT, "Base");
-
-                        //查询全部学生人数
-                        string sqlS = $"select value(count(c.id)) from c";
-                        teacherCount += await CommonFind.GetSqlValueCount(cosmosClient, "Student", sqlS, $"Base-{itemSchool}");
-                    }
-
-                    sticsDist.teacherCount = teacherCount;
-                    sticsDist.studentCount = studentCount;
-
-                    sticsDists.Add(sticsDist);
-                }
-
-                return Ok(new { state = 200, sticsDists });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location}  /homestatis/get-alldiststics   \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 依据城市Code查询学校,教师数量,学生数量
-        /// </summary>
-        /// <param name="jsonElement"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-citystics")]
-        public async Task<IActionResult> GetCityStics(JsonElement jsonElement) 
-        {
-            try
-            {
-                if(!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode))  return BadRequest();
-                jsonElement.TryGetProperty("site", out JsonElement site);
-                var cosmosClient = _azureCosmos.GetCosmosClient();
-                if ($"{site}".Equals(BIConst.Global))
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-
-                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") }))
-                {
-                    areaStandard.Add(item.standard);
-                }
-                int citySchoolCount = 0;
-                int teachCount = 0;
-                int stuCount = 0;
-
-                foreach (var tempSatndard in areaStandard)
-                {
-                    string sqlSchool = $"select c.id from c where c.standard='{tempSatndard}'";
-                    List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSchool, "Base");
-                    citySchoolCount += schoolIds.Count;
-                    //查询学校下面的教师人数
-                    foreach (var itemSchool in schoolIds)
-                    {
-                        //查询全部教师人数
-                        string sqlT = $"select value(count(c.id)) from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
-                        teachCount += await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", sqlT,  "Base");
-
-                        //查询全部学生人数
-                        string sqlS = $"select value(count(c.id)) from c";
-                        stuCount += await CommonFind.GetSqlValueCount(cosmosClient, "Student", sqlS, $"Base-{itemSchool}");
-                    }
-                }
-
-                return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teachCount, tudentCount = stuCount });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI, {_option.Location}  /homestatis/get-citystics  \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
         /// <summary>
         /// 统计所有省份下的数据   //已对接
         /// </summary>
@@ -685,56 +436,6 @@ namespace TEAMModelBI.Controllers.BIHome
             }
         }
 
-        /// <summary>
-        /// 查询BI权限开放人数
-        /// </summary>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-sticsbipower")]
-        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.Global))
-                {
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-                    table = _azureStorage.GetCloudTableClient(BIConst.Global).GetTableReference("SchoolSetting");
-                }
-
-                List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
-
-                List<PowerStics> powerStics = new(); 
-                foreach (var temp in authorityBIList)
-                {
-                    PowerStics tempPowerStics = new();
-                    tempPowerStics.powerName = temp.Discription;
-
-                    //查询学校权限
-                    string sqlTxt = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.permissions, '{temp.RowKey}', true) AND c.pk = 'Teacher' AND c.status = 'join'";
-                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
-                    {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                        {
-                            tempPowerStics.powerCount += 1;
-                        }
-                    }
-                    powerStics.Add(tempPowerStics);
-                }
-
-                return Ok(new { state = 200, powerStics });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-sticsbipower  \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
         /// <summary>
         /// 统计学校和教师空间类型   //已对接
         /// </summary>
@@ -999,102 +700,6 @@ namespace TEAMModelBI.Controllers.BIHome
             }
         }
 
-        /// <summary>
-        /// 统计教师的空间类型
-        /// </summary>
-        /// <returns></returns>
-        [HttpPost("get-teachetypestics")]
-        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.Global))
-                {
-                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-                    redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.Global);
-                }
-
-                //查询教师的大小和教师集合信息
-                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())
-                    {
-                        teacheSize += obj.GetProperty("size").GetInt64();
-                        teacherId.Add(obj.GetProperty("id").GetString());
-                    }
-                }
-
-                //查询教师已使用空间大小
-                foreach (var itemTeach in teacherId)
-                {
-                    RedisValue tempValue = redisClinet.HashGet($"Blob:Record", itemTeach);
-                    if (!tempValue.IsNullOrEmpty)
-                    {
-                        sizeT += Convert.ToInt64(tempValue);
-                        //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
-                        //long tempSize = 0;
-                        //if (record.TryGetInt64(out tempSize))
-                        //{
-                        //    sizeT += tempSize;
-                        //}
-                    }
-
-                    SortedSetEntry[] tempSorted = await redisClinet.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, teacheSize, sizeT, typeStics });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"BI,{_option.Location}   /homestatis/get-datatypestics   \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-                return BadRequest();
-            }
-        }
-
-        /// <summary>
-        /// 存放的类型
-        /// </summary>
-        public record AllDataType
-        {
-            public long vote { get; set; }/// 投票josn
-            public long thum { get; set; }//视频和封面缩略图
-            public long avatar { get; set; }//学生头像
-            public long test { get; set; }//
-            public long survey { get; set; }//问卷调查 josn
-            public long image { get; set; }// PNG
-            public long other { get; set; }//其他
-            public long doc { get; set; }//文档
-            public long homework { get; set; }//作业  json
-            public long item { get; set; }// 题库 json
-            public long paper { get; set; }//试卷  json
-            public long train { get; set; }// 研修
-            public long res { get; set; }//  教程 htx
-            public long exam { get; set; }//评测  json
-            public long syllabus { get; set; }// 课纲 json
-            public long video { get; set; }// 视频
-            public long yxpt { get; set; }//研修平台
-            public long jyzx { get; set; }// 教研中心
-            public long records { get; set; } //HiTeach上传的数据
-        }
-
         /// <summary>
         /// 省的数据标准
         /// </summary>
@@ -1152,12 +757,6 @@ namespace TEAMModelBI.Controllers.BIHome
             public string standard { get; set; }
         }
 
-        public record PowerStics 
-        {
-            public string powerName { get; set; }
-            public int powerCount { get; set; }        
-        }
-
         /// <summary>
         /// 市的学校数据,及以下数据
         /// </summary>
@@ -1312,76 +911,5 @@ namespace TEAMModelBI.Controllers.BIHome
             /// </summary>
             public string standard { get; set; }
         }
-
-        /// <summary>
-        /// 区域
-        /// </summary>
-        public record SticsCity
-        {
-            /// <summary>
-            /// 区域Id
-            /// </summary>
-            public string areaId { get; set; }
-            /// <summary>
-            /// 省份
-            /// </summary>
-            public string provName { get; set; }
-
-            /// <summary>
-            /// 市名称
-            /// </summary>
-            public string cityName { get; set; }
-
-            /// <summary>
-            /// 区域名称
-            /// </summary>
-            public string distName { get; set; }
-
-            /// <summary>
-            /// 区域标准
-            /// </summary>
-            public string standard { get; set; }
-        }
-
-        /// <summary>
-        /// 返回统计数据
-        /// </summary>
-        public record SticsDist 
-        {
-            /// <summary>
-            /// 省份
-            /// </summary>
-            public string provName { get; set; }
-
-            /// <summary>
-            /// 市名
-            /// </summary>
-            public string cityName { get; set; }
-
-            /// <summary>
-            /// 区域标准名称
-            /// </summary>
-            public string distName { get; set; }
-
-            /// <summary>
-            /// 区域标准
-            /// </summary>
-            public string standard { get; set; }
-
-            /// <summary>
-            /// 学校数量
-            /// </summary>
-            public int schoolCount { get; set; }
-
-            /// <summary>
-            /// 教师人数
-            /// </summary>
-            public int teacherCount { get; set; }
-
-            /// <summary>
-            /// 学生人数
-            /// </summary>
-            public int studentCount { get; set; }
-        }
     }
 }