Browse Source

重构依据区统id分析数据区级数据分析接口

Li 2 years ago
parent
commit
643b769c22
1 changed files with 314 additions and 140 deletions
  1. 314 140
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs

+ 314 - 140
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -332,186 +332,337 @@ namespace TEAMModelBI.Controllers.Census
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 依据区统计区级相关信息包括活动统计
+        /// 依据区统id分析数据区级数据分析
         /// </summary>
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         /// <returns></returns>
+        [ProducesDefaultResponseType]
         [HttpPost("get-areastics")]
         [HttpPost("get-areastics")]
         public async Task<IActionResult> GetAreaStics(JsonElement jsonElement)
         public async Task<IActionResult> GetAreaStics(JsonElement jsonElement)
         {
         {
             if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
             if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
             jsonElement.TryGetProperty("site", out JsonElement site);
             jsonElement.TryGetProperty("site", out JsonElement site);
-            var (dayStart, dayEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow);
-            var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
-            var (monthStart, monthEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
-            var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term");
+            var (dayS, dayE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow);
+            var (weekS, weekE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
+            var (monthS, monthE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
+            var (termS, termE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term");
 
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
             var cosmosClient = _azureCosmos.GetCosmosClient();
             if ($"{site}".Equals(BIConst.Global))
             if ($"{site}".Equals(BIConst.Global))
                 cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
                 cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
-            List<RecSchool> schools = new();
 
 
+            int scCnt = 0; //学校人数
+            int weekScCnt = 0; //本周学校人数
+            int motnhScCnt = 0; //本月学校人数
 
 
-            StringBuilder scSqlTxt = new("select c.id,c.name,c.picture,c.size,c.scale,c.type from c");
-            if (!string.IsNullOrEmpty($"{areaId}"))
-            {
-                scSqlTxt.Append($" where c.areaId='{areaId}'");
-            }
+            int tchCnt = 0;   //所有区级老师
+            int weekTchCnt = 0;   //所有区级老师
+            int monthTchCnt = 0;   //所有区级老师
 
 
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
-            {
-                schools.Add(item);
-            }
+            int stuCnt = 0;   //所有区级学生
+            int weekStuCnt = 0;   //所有区级学生
+            int monthStuCnt = 0;   //所有区级学生
 
 
-            int countArea = 0;//区级人员
-            int appraiseArea = 0;//区级评审人员
             int areaSize = 0;   //区级空间
             int areaSize = 0;   //区级空间
-            long examAreaCount = 0;   //试卷活动
-            long surveyAreaCount = 0;  //问卷活动
-            long voteAreaCount = 0;   //投票活动
-            long homeworkAreaCount = 0;  //作业活动
-            long weekActivity = 0; //周活动数量
-            long termActivity = 0;   //学期活动
-            int basics = 0; //基础版数
-            int standard = 0; //标准版数
-            int major = 0;   //专业版数
-            int geCount = 0; //普教
-            int heCount = 0; //高教
-            int oeCount = 0; //其他教育
+            int weekSize = 0;   //本周空间
+            int monthSize = 0;   //本月空间
+
             int allLess = 0; //所有课例
             int allLess = 0; //所有课例
-            int dayLess = 0;  //当天课例
             int weekLess = 0;  //周课例
             int weekLess = 0;  //周课例
             int monthLess = 0;  //月课例
             int monthLess = 0;  //月课例
             int termLess = 0;    //学期课例
             int termLess = 0;    //学期课例
-            double teachCount = 0;    //课例教师
-
-            List<SchoolLesson> schoolLessons = new();  //学校课例集合 
-            List<SchoolInfo> schoolInfos = new();
-            List<LessonRecord> records = new();//所有的课程记录
 
 
-            List<string> scIds = schools.Select(x => x.id).ToList();
+            int totalTime = 0;   //累计学时
+            int allActCnt = 0;   //所有活动
+            int weekActivity = 0; //周活动数量
+            int monthActCnt = 0; //月活动数量
+            int termActivity = 0;   //学期活动
 
 
-            int totalTime = 0;
+            int onLineCount = 0;    //线上研修人数
+            int offlineCount = 0;   //线下研修人数
+            int classRoomCount = 0;  //课堂实录人数
+            int submitCount = 0;     //认证材料人数
 
 
-            heCount = schools.Select(s => s.type == 2).Count();
-            geCount = schools.Select(s => s.type == 1).Count();
-            oeCount = schools.Select(s => s.type != 2 && s.type != 1).Count();
-            areaSize = schools.Select(s => s.size).Sum();
+            int fulfilCount = 0;    //已完成
+            int carryOnCount = 0;   //进行中
+            int noCount = 0;      //未开始
+            List<AreaStudy> trains = new();
 
 
-            foreach (var school in schools)
+            AreaSetting setting = null;
+            try
+            {
+                setting = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemAsync<AreaSetting>($"{areaId}", new PartitionKey("AreaSetting"));
+            }
+            catch (CosmosException)
             {
             {
-                int count = 0;
-                int appraise = 0;
-                await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
+                setting = null;
+            }
+            if (setting == null)
+            {
+                setting = new AreaSetting
                 {
                 {
-                    if (info)
-                    {
-                        appraise += 1;
-                        appraiseArea += 1;
-                    }
-                    countArea += 1;
-                    count += 1;
-                }
+                    allTime = 50,
+                    classTime = 5,
+                    submitTime = 15,
+                    onlineTime = 20,
+                    offlineTime = 10,
+                    lessonMinutes = 45,
+                };
+            }
 
 
-                //查询学校的总学时
-                totalTime += await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", "SELECT value(sum(c.totalTime)) FROM c", $"TeacherTrain-{school.id}");
-                //查询学校参训人数
-                int tempCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(array_length(c.members)) from c where c.type='yxtrain'", $"GroupList-{school.id}");
-                //学校学生人数
-                long stuCount = await CommonFind.GetSqlValueCount(cosmosClient, "Student", $"select value(count(c.id)) from c", $"Base-{school.id}");
-
-                //查询是否有服务
-                int serCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(array_length(c.service)) from c where c.id='{school.id}'", "ProductSum");
-                if (serCount > 0)
-                    major += 1;
-                else if (school.size >= 300 && school.scale >= 500)
-                    standard += 1;
-                else basics += 1;
-
-                string sqlTxtSchool = $"select value(c) from c where c.code='LessonRecord-{school}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxtSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
-                {
-                    records.Add(item);
-                }
+            string oftenSql = "select value(count(c.id)) from c";
+            string scSql = $"{oftenSql} where c.areaId='{areaId}'";
+            List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", $"select value(c.id) from c where c.areaId='{areaId}'", "Base");
+            if (scIds.Count > 0)
+            {
+                string weekWhereSql = $"c.createTime >= {weekS} and c.createTime <= {weekE}";
+                string monthWhereSql = $"c.createTime >= {monthS} and c.createTime <= {monthE}";
+
+                //学校查询拼接
+                string comSql = BICommonWay.ManyScSql("c.school", scIds);
+                //学校数据查询
+                scCnt = scIds.Count;
+                weekScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{oftenSql} where {comSql} and {weekWhereSql}", "Base");
+                motnhScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{oftenSql} where {comSql} and {monthWhereSql}", "Base");
+
+                //查教师
+                string tchSpl = BICommonWay.ManyScSql("REPLACE(c.code, 'Teacher-', '')", scIds);
+                string tchSql = $"{oftenSql} where c.pk='Teacher' and {tchSpl}";
+                tchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", tchSql);
+                weekTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{tchSql} and {weekWhereSql}");
+                monthTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{tchSql} and {monthWhereSql}");
+
+                string stuSpl = BICommonWay.ManyScSql("REPLACE(c.code, 'Base-', '')", scIds);
+                //查学生
+                string stuSql = $"{oftenSql} where c.pk='Base' and {stuSpl}";
+                stuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", $"{oftenSql} where c.pk='Base' and {stuSpl}");
+                weekStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", $"{oftenSql} where c.pk='Base' and {stuSpl} and {weekWhereSql}");
+                monthStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", $"{oftenSql} where c.pk='Base' and {stuSpl} and {monthWhereSql}");
+
+                //空间
+                //学校查询拼接
+                string sizeSpl = BICommonWay.ManyScSql("c.id", scIds);
+                string sizeSql = "select value(sum(c.size)) from c";
+                areaSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{sizeSql} where {sizeSpl}","Base");
+                weekSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{sizeSql} where {sizeSpl} and {weekWhereSql}", "Base");
+                monthSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{sizeSql} where {sizeSpl} and {monthWhereSql}", "Base");
 
 
                 //课例
                 //课例
-                int lessCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c", $"LessonRecord-{school.id}");
-                SchoolLesson schoolLesson = new()
-                {
-                    id = school.id,
-                    name = school.name,
-                    picture = school.picture,
-                    count = lessCount
-                };
+                allLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{oftenSql} where c.pk='LessonRecord' and {comSql}");
+                weekLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{oftenSql} where c.pk='LessonRecord' and {comSql} and c.startTime >= {weekS} and c.startTime <= {weekE}");
+                termLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{oftenSql} where c.pk='LessonRecord' and {comSql} and c.startTime >= {termS} and c.startTime <= {termE}");
+                monthLess = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{oftenSql} where c.pk='LessonRecord' and {comSql} and c.startTime >= {monthS} and c.startTime <= {monthE}");
 
 
-                SchoolInfo schoolInfo = new()
-                {
-                    id = school.id,
-                    name = school.name,
-                    picture = school.picture,
-                    teacherCount = count,
-                    studentCount = stuCount,
-                    appraiseCount = appraise,
-                    trainCount = tempCount
-                };
+                //学时
+                totalTime = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"select value(sum(c.totalTime)) from c where c.pk='TeacherTrain' and {comSql}");
 
 
-                ActivityCount tempActivity = new() { id = school.id, name = school.name != null ? school.name : school.id };
-                foreach (var type in StaticValue.activityTypes)
-                {
-                    long totals = await CommonFind.GetSqlValueCount(cosmosClient, "Common", $"select value(COUNT(c.id)) from c where c.pk='{type}' and c.school='{school.id}' ");
+                //活动
+                string actSpl = BICommonWay.ManyScSql(" and c.school", scIds);
+                allActCnt = await ActivityWay.GetCnt(cosmosClient, condSql: actSpl);
+                weekActivity = await ActivityWay.GetCnt(cosmosClient, condSql: $"{actSpl} and {weekWhereSql} ");
+                termActivity = await ActivityWay.GetCnt(cosmosClient, condSql: $"{actSpl} and c.createTime >= {termS} and c.createTime <= {termE}");
+                monthActCnt = await ActivityWay.GetCnt(cosmosClient, condSql: $"{actSpl} and {monthWhereSql} ");
 
 
-                    string weekSql = $"select value(count(c.id)) from c where c.pk='{type}' and c.school='{school.id}' and c.createTime>={weekStart}   and c.createTime<={weekEnd}";
-                    long weekActCount = await CommonFind.GetSqlValueCount(cosmosClient, "Common", weekSql);
-                    weekActivity += weekActCount;
+                string onLineSql = $"{oftenSql} where  c.TeacherTrain and {comSql} and c.onlineTime = 0 or c.onlineTime >= {setting.onlineTime} ";
+                onLineCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", onLineSql);
 
 
-                    string termSql = $"select value(count(c.id)) from c where c.pk='{type}' and c.school='{school.id}' and c.createTime>={termStart}   and c.createTime<={termEnd}";
-                    long termActCount = await CommonFind.GetSqlValueCount(cosmosClient, "Common", termSql);
-                    termActivity += termActCount;
+                //string offLineSql = $"{oftenSql} where  c.TeacherTrain and {comSql} and c.offlineTime = 0 or c.offlineTime >= {setting.offlineTime} ";
+                //offlineCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", offLineSql);
 
 
-                    switch (type)
+                //string ctSql = $"{oftenSql} where  c.TeacherTrain and {comSql} and c.classTime = 0 or c.classTime >= {setting.classTime} ";
+                //classRoomCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", ctSql);
+
+                //string stSql = $"{oftenSql} join s in c.currency where c.TeacherTrain and {comSql} and s.submitTime = 0 or s.submitTime >= {setting.submitTime}";
+                //submitCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", ctSql);
+
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.code,c.onlineTime,c.offlineTime,c.classTime,c.currency from c where c.pk='TeacherTrain' and {comSql}", requestOptions: new QueryRequestOptions() { })) 
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                     {
-                        case "Exam":
-                            examAreaCount += totals;
-                            break;
-                        case "Survey":
-                            surveyAreaCount += totals;
-                            break;
-                        case "Vote":
-                            voteAreaCount += totals;
-                            break;
-                        case "Homework":
-                            homeworkAreaCount += totals;
-                            break;
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {                            
+                            trains.Add(obj.ToObject<AreaStudy>());
+                        }
                     }
                     }
-                    schoolInfo.census.Add(new KeyValuePair<object, long>(type, totals));
                 }
                 }
-                schoolInfos.Add(schoolInfo);
-                schoolLessons.Add(schoolLesson);
-            }
-
-            List<string> tecIds = await CommonFind.FindRolesId(cosmosClient, scIds);
 
 
-            //查询去下面所有学校教师课例
-            foreach (var tecId in tecIds)
-            {
-                string sqlTxt = $"select value(c) from c where c.id='{tecId}'";
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+                trains.ForEach(x =>
                 {
                 {
-                    records.Add(item);
-                }
-            }
+                    //线上研修
+                    if (x.onlineTime == 0) onLineCount++; else if (x.onlineTime >= setting.onlineTime) onLineCount++; else onLineCount++;
 
 
-            //课例统计
-            if (records.Count > 0)
-            {
-                records.ForEach(x => { if (x.startTime >= dayStart && x.startTime <= dayEnd) dayLess += 1; });
-                records.ForEach(x => { if (x.startTime >= weekStart && x.startTime <= weekEnd) weekLess += 1; });
-                records.ForEach(x => { if (x.startTime >= monthStart && x.startTime <= monthEnd) monthLess += 1; });
-                records.ForEach(x => { if (x.startTime >= termStart && x.startTime <= termEnd) termLess += 1; });
-                teachCount = records.Where(r => r.tmdid != null).Where((x, i) => records.FindIndex(z => z.tmdid == x.tmdid) == i).ToList().Count;
+                    //线下研修
+                    if (x.offlineTime == 0) offlineCount++; else if (x.onlineTime >= setting.offlineTime) offlineCount++; else offlineCount++;
+
+                    //课堂实录
+                    if (x.classTime == 0) classRoomCount++; else if (x.classTime >= setting.classTime) classRoomCount++; else classRoomCount++;
+
+                    //认证材料
+                    if (x.currency.submitTime == 0) submitCount++; else if (x.currency.submitTime >= setting.submitTime) submitCount++; else submitCount++;
+
+                    if (x.currency.submitTime == 0 && x.classTime == 0 && x.offlineTime == 0 && x.onlineTime == 0) noCount++;
+                    else if (x.currency.submitTime >= setting.submitTime && x.classTime >= setting.classTime && x.onlineTime >= setting.offlineTime && x.onlineTime >= setting.onlineTime) fulfilCount++;
+                    else carryOnCount++;
+                });
             }
             }
 
 
-            return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, major, standard, basics, oeCount, dayLess, weekLess, monthLess, termLess, teachCount, allLess = records.Count, schools = schoolInfos, schoolLessons });
+            return Ok(new { state = RespondCode.Ok, scCnt, weekScCnt, motnhScCnt, tchCnt, weekTchCnt, monthTchCnt, stuCnt, weekStuCnt, monthStuCnt, areaSize, weekSize, monthSize, allLess, weekLess, monthLess, termLess, totalTime, allActCnt, weekActivity, monthActCnt, termActivity, study = new { onLineCount, offlineCount, classRoomCount, submitCount, fulfilCount, carryOnCount, noCount } });
+
+            //int countArea = 0;//区级人员
+            //int appraiseArea = 0;//区级评审人员
+            //long examAreaCount = 0;   //试卷活动
+            //long surveyAreaCount = 0;  //问卷活动
+            //long voteAreaCount = 0;   //投票活动
+            //long homeworkAreaCount = 0;  //作业活动
+            //int basics = 0; //基础版数
+            //int standard = 0; //标准版数
+            //int major = 0;   //专业版数
+            //int geCount = 0; //普教
+            //int heCount = 0; //高教
+            //int oeCount = 0; //其他教育
+            //int dayLess = 0;  //当天课例
+            //double teachCount = 0;    //课例教师
+
+            //List<RecSchool> schools = new();
+
+            //StringBuilder scSqlTxt = new("select c.id,c.name,c.picture,c.size,c.scale,c.type from c");
+            //if (!string.IsNullOrEmpty($"{areaId}"))
+            //{
+            //    scSqlTxt.Append($" where c.areaId='{areaId}'");
+            //}
+
+            //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: scSqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            //{
+            //    schools.Add(item);
+            //}
+            //List<SchoolLesson> schoolLessons = new();  //学校课例集合 
+            //List<SchoolInfo> schoolInfos = new();
+            //List<LessonRecord> records = new();//所有的课程记录
+
+            ////List<string> scIds = schools.Select(x => x.id).ToList();
+
+            //int totalTime = 0;
+
+            //heCount = schools.Select(s => s.type == 2).Count();
+            //geCount = schools.Select(s => s.type == 1).Count();
+            //oeCount = schools.Select(s => s.type != 2 && s.type != 1).Count();
+            //areaSize = schools.Select(s => s.size).Sum();
+
+            //foreach (var school in schools)
+            //{
+            //    int count = 0;
+            //    int appraise = 0;
+            //    await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
+            //    {
+            //        if (info)
+            //        {
+            //            appraise += 1;
+            //            appraiseArea += 1;
+            //        }
+            //        countArea += 1;
+            //        count += 1;
+            //    }
+
+            //    //查询学校的总学时
+            //    totalTime += await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", "SELECT value(sum(c.totalTime)) FROM c", $"TeacherTrain-{school.id}");
+            //    //查询学校参训人数
+            //    int tempCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(array_length(c.members)) from c where c.type='yxtrain'", $"GroupList-{school.id}");
+            //    //学校学生人数
+            //    long stuCount = await CommonFind.GetSqlValueCount(cosmosClient, "Student", $"select value(count(c.id)) from c", $"Base-{school.id}");
+
+            //    //查询是否有服务
+            //    int serCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(array_length(c.service)) from c where c.id='{school.id}'", "ProductSum");
+            //    if (serCount > 0)
+            //        major += 1;
+            //    else if (school.size >= 300 && school.scale >= 500)
+            //        standard += 1;
+            //    else basics += 1;
+
+            //    string sqlTxtSchool = $"select value(c) from c where c.code='LessonRecord-{school}'";
+            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: sqlTxtSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school}") }))
+            //    {
+            //        records.Add(item);
+            //    }
+
+            //    //课例
+            //    int lessCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c", $"LessonRecord-{school.id}");
+            //    SchoolLesson schoolLesson = new()
+            //    {
+            //        id = school.id,
+            //        name = school.name,
+            //        picture = school.picture,
+            //        count = lessCount
+            //    };
+
+            //    SchoolInfo schoolInfo = new()
+            //    {
+            //        id = school.id,
+            //        name = school.name,
+            //        picture = school.picture,
+            //        teacherCount = count,
+            //        studentCount = stuCount,
+            //        appraiseCount = appraise,
+            //        trainCount = tempCount
+            //    };
+
+            //    ActivityCount tempActivity = new() { id = school.id, name = school.name != null ? school.name : school.id };
+            //    foreach (var type in StaticValue.activityTypes)
+            //    {
+            //        long totals = await CommonFind.GetSqlValueCount(cosmosClient, "Common", $"select value(COUNT(c.id)) from c where c.pk='{type}' and c.school='{school.id}' ");
+
+            //        string weekSql = $"select value(count(c.id)) from c where c.pk='{type}' and c.school='{school.id}' and c.createTime>={weekS}   and c.createTime<={weekE}";
+            //        long weekActCount = await CommonFind.GetSqlValueCount(cosmosClient, "Common", weekSql);
+            //        weekActivity += weekActCount;
+
+            //        string termSql = $"select value(count(c.id)) from c where c.pk='{type}' and c.school='{school.id}' and c.createTime>={termS}   and c.createTime<={termE}";
+            //        long termActCount = await CommonFind.GetSqlValueCount(cosmosClient, "Common", termSql);
+            //        termActivity += termActCount;
+
+            //        switch (type)
+            //        {
+            //            case "Exam":
+            //                examAreaCount += totals;
+            //                break;
+            //            case "Survey":
+            //                surveyAreaCount += totals;
+            //                break;
+            //            case "Vote":
+            //                voteAreaCount += totals;
+            //                break;
+            //            case "Homework":
+            //                homeworkAreaCount += totals;
+            //                break;
+            //        }
+            //        schoolInfo.census.Add(new KeyValuePair<object, long>(type, totals));
+            //    }
+            //    schoolInfos.Add(schoolInfo);
+            //    schoolLessons.Add(schoolLesson);
+            //}
+
+            //List<string> tecIds = await CommonFind.FindRolesId(cosmosClient, scIds);
+
+            ////查询去下面所有学校教师课例
+            //foreach (var tecId in tecIds)
+            //{
+            //    string sqlTxt = $"select value(c) from c where c.id='{tecId}'";
+            //    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<LessonRecord>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord") }))
+            //    {
+            //        records.Add(item);
+            //    }
+            //}
+
+            ////课例统计
+            //if (records.Count > 0)
+            //{
+            //    records.ForEach(x => { if (x.startTime >= dayS && x.startTime <= dayE) dayLess += 1; });
+            //    records.ForEach(x => { if (x.startTime >= weekS && x.startTime <= weekE) weekLess += 1; });
+            //    records.ForEach(x => { if (x.startTime >= monthS && x.startTime <= monthE) monthLess += 1; });
+            //    records.ForEach(x => { if (x.startTime >= termS && x.startTime <= termE) termLess += 1; });
+            //    teachCount = records.Where(r => r.tmdid != null).Where((x, i) => records.FindIndex(z => z.tmdid == x.tmdid) == i).ToList().Count;
+            //}
+
+            //return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, major, standard, basics, oeCount, dayLess, weekLess, monthLess, termLess, teachCount, allLess = records.Count, schools = schoolInfos, schoolLessons });
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -655,7 +806,6 @@ namespace TEAMModelBI.Controllers.Census
             return Ok(new { state = RespondCode.Ok, areaInfos });
             return Ok(new { state = RespondCode.Ok, areaInfos });
         }
         }
 
 
-
         /// <summary>
         /// <summary>
         /// 所有活动分析
         /// 所有活动分析
         /// </summary>
         /// </summary>
@@ -711,8 +861,6 @@ namespace TEAMModelBI.Controllers.Census
             return Ok(new {state = RespondCode.Ok, allLess, weekLess, termLess, monthLessCnt, actAllCnt, actWeekCnt, actTermCnt, actMonthCnt });
             return Ok(new {state = RespondCode.Ok, allLess, weekLess, termLess, monthLessCnt, actAllCnt, actWeekCnt, actTermCnt, actMonthCnt });
         }
         }
 
 
-
-
         /// <summary>
         /// <summary>
         /// 依据活动Id查询活动详情信息  数据管理工具——查询工具
         /// 依据活动Id查询活动详情信息  数据管理工具——查询工具
         /// </summary>
         /// </summary>
@@ -776,6 +924,32 @@ namespace TEAMModelBI.Controllers.Census
         }
         }
 
 
 
 
+        public class AreaStudy 
+        {
+            public string id { get; set; }
+
+            public string code { get; set; }
+
+            /// <summary>
+            /// 线上观看视频的学时
+            /// </summary>
+            public long onlineTime { get; set; }
+
+            /// <summary>
+            /// 线下研修学时
+            /// </summary>
+            public long offlineTime { get; set; }
+            /// <summary>
+            /// 课堂实录学时
+            /// </summary>
+            public long classTime { get; set; }
+            /// <summary>
+            /// 必修的
+            /// </summary>
+            public Currency currency { get; set; } = new Currency();
+
+        }
+
         private class SchoolInfo
         private class SchoolInfo
         {
         {
             public string id { get; set; }
             public string id { get; set; }