SchoolController.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. using Azure.Cosmos;
  2. using DocumentFormat.OpenXml.Bibliography;
  3. using Microsoft.AspNetCore.Http;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.Extensions.Options;
  6. using NUnit.Framework.Constraints;
  7. using Pipelines.Sockets.Unofficial.Arenas;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Diagnostics;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Text.Json;
  14. using System.Threading.Tasks;
  15. using TEAMModelBI.Models;
  16. using TEAMModelBI.Tool;
  17. using TEAMModelBI.Tool.CosmosBank;
  18. using TEAMModelOS.Models;
  19. using TEAMModelOS.SDK.Context.BI;
  20. using TEAMModelOS.SDK.Context.Constant;
  21. using TEAMModelOS.SDK.DI;
  22. using TEAMModelOS.SDK.Extension;
  23. using TEAMModelOS.SDK.Models;
  24. using TEAMModelOS.SDK.Models.Cosmos.BI;
  25. using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
  26. using TEAMModelOS.SDK.Models.Service.BI;
  27. using TEAMModelOS.SDK.Models.Service.BIStatsWay;
  28. namespace TEAMModelBI.Controllers.Census
  29. {
  30. [Route("school")]
  31. [ApiController]
  32. public class SchoolController : ControllerBase
  33. {
  34. private readonly AzureCosmosFactory _azureCosmos;
  35. private readonly AzureStorageFactory _azureStorage;
  36. private readonly DingDing _dingDing;
  37. private readonly Option _option;
  38. private readonly HttpTrigger _httpTrigger;
  39. public SchoolController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, HttpTrigger httpTrigger)
  40. {
  41. _azureCosmos = azureCosmos;
  42. _azureStorage = azureStorage;
  43. _dingDing = dingDing;
  44. _option = option?.Value;
  45. _httpTrigger = httpTrigger;
  46. }
  47. /// <summary>
  48. /// 统计所有分析:基础、课例、活动、资源
  49. /// </summary>
  50. /// <param name="jsonElement"></param>
  51. /// <returns></returns>
  52. [ProducesDefaultResponseType]
  53. [HttpPost("get-all")]
  54. public async Task<IActionResult> GetAll(JsonElement jsonElement)
  55. {
  56. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  57. var cosmosClient = _azureCosmos.GetCosmosClient();
  58. //////分开部署,就不需要,一站多用时,取消注释
  59. //if ($"{site}".Equals(BIConst.Global))
  60. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  61. long schoolCount = 0; //学校数量
  62. int tecCount = 0; //教师数量
  63. int stuCount = 0; //学生数量
  64. long roomCount = 0; //教室数量
  65. long wisdomRoomCount = 0; //智慧教室数量
  66. long allClassCount = 0; //所有班级
  67. long allLessCount = 0; //所有课例
  68. long lastYearLessCount = 0; //去年课例
  69. long yearLessCount = 0;//今年课例
  70. long lastWeekLessCount = 0; //上周课例
  71. long weekLessCount = 0; //本周课例
  72. long lastTermLessCount = 0; //上学期课例
  73. long termLessCount = 0; //本学期课例
  74. long allActivityCount = 0; //所有活动
  75. long lastActivityCount = 0; //去年活动
  76. long activityCount = 0; //今年活动
  77. long lastWeekActivitCount = 0; //上周活动
  78. long weekActivitCount = 0; //本周活动
  79. long lastTermActivitCount = 0; //上学期活动
  80. long TermActivitCount = 0; //本学期学期活动
  81. long rercCount = 0; //所有资源数量
  82. long weekRercCount = 0; //本周资源数量
  83. long lastWeekRercCount = 0; //上周资源数量
  84. long lastTermRercCount = 0; //上学期资源
  85. long termRercCount = 0; //本学期资源
  86. long lastYearRercCount = 0; //去年资源
  87. long yearRercCount = 0; //去年资源
  88. var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
  89. var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year"); //计算今年开始/结束时间
  90. var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek"); //计算上周开始/结束时间
  91. var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week"); //计算本周开始/结束时间
  92. var (lastTermStart, lastTermEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastterm"); //计算上学期开始/结束时间
  93. var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term"); //计算本学期开始/结束时间
  94. schoolCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c", "Base"); //所有学校数量
  95. tecCount = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", "select value(count(c.id)) from c", "Base"); //所有教师数量
  96. stuCount = await CommonFind.GetSqlValueCount(cosmosClient, "Student", "select value(count(c.id)) from c", "Base"); //所有学生数量
  97. allClassCount = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School" }, "select count(c.id) totals from c where c.pk = 'Class'"); //所有班级数量
  98. roomCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c where c.pk = 'Room'"); //所有教室数量
  99. wisdomRoomCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c where c.pk = 'Room' and c.serial != null"); //智慧教室数量
  100. List<string> containers = new() { "School", "Teacher" };
  101. string lessSqlTxt = "select value(count(c.id)) from c where c.pk='LessonRecord' and c.startTime>={0} and c.startTime<={1}";
  102. allLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, $"select count(c.id) as totals from c where c.pk='LessonRecord'");//所有课例
  103. lastYearLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(lessSqlTxt, lastYearStart, lastYearEnd)); //去年课例
  104. yearLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(lessSqlTxt, yearStart, yearEnd)); //今年课例
  105. lastWeekLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(lessSqlTxt, lastWeekStart, lastWeekEnd)); //上周课例
  106. weekLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(lessSqlTxt, weekStart, weekEnd)); //本周课例
  107. lastTermLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(lessSqlTxt, lastTermStart, lastTermEnd)); //上学期课例
  108. termLessCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(lessSqlTxt, termStart, termEnd)); //上学期课例
  109. string typeSqlTxt = "select value(count(c.id)) from c where c.pk='{0}' and c.createTime >={1} and c.createTime<= {2}";
  110. foreach (var type in StaticValue.activityTypes)
  111. {
  112. allActivityCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", $"select value(count(c.id)) from c where c.pk='{type}' ");//所有活动
  113. lastActivityCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(typeSqlTxt, type, lastYearStart, lastYearEnd)); //去年活动
  114. activityCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(typeSqlTxt, type, yearStart, yearEnd)); //今年活动
  115. lastWeekActivitCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(typeSqlTxt, type, lastWeekStart, lastWeekEnd)); //上周活动
  116. weekActivitCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(typeSqlTxt, type, weekStart, weekEnd)); //本周活动
  117. lastTermActivitCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(typeSqlTxt, type, lastTermStart, lastTermEnd)); //上学期活动
  118. TermActivitCount += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(typeSqlTxt, type, termStart, termEnd)); //本学期学期活动
  119. }
  120. string bloblSqlTxt = "select value(count(c.id)) from c where c.pk='Bloblog' and c.time>={0} and c.time<={1}";
  121. rercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, "select value(count(c.id)) from c where c.pk='Bloblog'"); //所有资源
  122. lastWeekRercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(bloblSqlTxt, lastWeekStart, lastWeekEnd)); //上周资源
  123. weekRercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(bloblSqlTxt, weekStart, weekEnd)); //本周资源
  124. lastTermRercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(bloblSqlTxt, lastTermStart, lastTermEnd)); //上学期资源
  125. termRercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(bloblSqlTxt, termStart, termEnd)); //这学期资源
  126. lastYearRercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(bloblSqlTxt, lastYearStart, lastYearEnd)); //去年资源
  127. yearRercCount = await CommonFind.GetSqlValueCount(cosmosClient, containers, string.Format(bloblSqlTxt, yearStart, yearEnd)); //今年资源
  128. return Ok(new { state = 200, schoolCount, tecCount, stuCount, allClassCount, roomCount, wisdomRoomCount, allLessCount, lastYearLessCount, yearLessCount, lastWeekLessCount, weekLessCount, lastTermLessCount, termLessCount, allActivityCount, lastActivityCount, activityCount, lastWeekActivitCount, weekActivitCount, lastTermActivitCount, TermActivitCount, rercCount, lastWeekRercCount, weekRercCount, lastTermRercCount, termRercCount, lastYearRercCount, yearRercCount });
  129. }
  130. /// <summary>
  131. /// 查询顾问相关的学校统计数据
  132. /// </summary>
  133. /// <param name="jsonElement"></param>
  134. /// <returns></returns>
  135. [ProducesDefaultResponseType]
  136. [HttpPost("get-assist")]
  137. public async Task<IActionResult> GetAssistStatis(JsonElement jsonElement)
  138. {
  139. if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
  140. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  141. int tecCount = 0; //教师数量
  142. int stuCount = 0; //学校数量
  143. int classCount = 0; //班级数量
  144. int roomCount = 0; //智慧教师数量
  145. int allLessonCount = 0; //课例数量
  146. int lastWeekLessCount = 0;// 上周课例数
  147. int weekLessCount = 0; //本周课例
  148. int lastTermLessCount = 0;// 上学期课例数
  149. int termLessCount = 0; //本学期课例
  150. int lastYearLessCount = 0; //去年课例
  151. int yearLessCount = 0; //今年课例
  152. int allBloblog = 0; //学校资源
  153. int lastYearBloblog = 0; //去年学校资源
  154. int yearBloblog = 0; //今年学校资源
  155. long allActivity = 0; //学校所有活动
  156. long lastYearActivity = 0; //去年学校所有活动
  157. long yearActivity = 0; //今年学校所有活动
  158. long lastWeekActivity = 0; //上周学校所有活动
  159. long weekActivity = 0; //本周学校所有活动
  160. var cosmosClient = _azureCosmos.GetCosmosClient();
  161. ////分开部署,就不需要,一站多用时,取消注释
  162. //if ($"{site}".Equals(BIConst.Global))
  163. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  164. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
  165. var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek"); //计算上周开始/结束时间
  166. var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week"); //计算本周开始/结束时间
  167. var (lastTermStart, lastTermEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastterm"); //计算上学期开始/结束时间
  168. var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term"); //计算本学期开始/结束时间
  169. var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
  170. var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year"); //计算今年开始/结束时间
  171. string unifySqlTxt = "select value(count(c.id)) from c";
  172. string unifyTimeSql = "select value(count(c.id)) from c where c.startTime>={0} and c.startTime<={1}";
  173. string blobTimeSql = "select value(count(c.id)) from c where c.time>={0} and c.time<={1}";
  174. List<RecSchoolDate> recSchoolDates = new();
  175. foreach (var itemId in schoolIds)
  176. {
  177. School school = new();
  178. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("Base"));
  179. if (response.Status == 200)
  180. {
  181. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  182. school = json.ToObject<School>();
  183. }
  184. tecCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where ARRAY_CONTAINS(c.roles,'teacher',true) and c.status = 'join'", $"Teacher-{itemId}");
  185. stuCount += await CommonFind.GetSqlValueCount(cosmosClient, "Student", unifySqlTxt, $"Base-{itemId}");
  186. classCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", unifySqlTxt, $"Class-{itemId}");
  187. roomCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", unifySqlTxt, $"Room-{itemId}");
  188. //学校所有课例
  189. int tempLessCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", unifySqlTxt, $"LessonRecord-{itemId}");
  190. lastWeekLessCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(unifyTimeSql, lastWeekStart, lastWeekEnd), $"LessonRecord-{itemId}");
  191. weekLessCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(unifyTimeSql, weekStart, weekEnd), $"LessonRecord-{itemId}");
  192. lastTermLessCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(unifyTimeSql, lastTermStart, lastTermEnd), $"LessonRecord-{itemId}");
  193. termLessCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(unifyTimeSql, termStart, termEnd), $"LessonRecord-{itemId}");
  194. lastYearLessCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(unifyTimeSql, lastYearStart, lastYearEnd), $"LessonRecord-{itemId}");
  195. yearLessCount += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(unifyTimeSql, yearStart, yearEnd), $"LessonRecord-{itemId}");
  196. //学校资源
  197. int tempBloblog = await CommonFind.GetSqlValueCount(cosmosClient, "School", unifySqlTxt, $"Bloblog-{itemId}");
  198. lastYearBloblog += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(blobTimeSql, lastYearStart, lastYearEnd), $"Bloblog-{itemId}");
  199. yearBloblog += await CommonFind.GetSqlValueCount(cosmosClient, "School", string.Format(blobTimeSql, yearStart, yearEnd), $"Bloblog-{itemId}");
  200. //学校活动
  201. long tempallActivity = 0;
  202. //统计活动
  203. foreach (var type in StaticValue.activityTypes)
  204. {
  205. string sqlTime = "SELECT value(count(c.id)) FROM c where c.pk = '{0}' and c.school = '{1}' and c.createTime>={2} and c.createTime<={3}";
  206. tempallActivity += await CommonFind.GetSqlValueCount(cosmosClient, "Common", $"SELECT value(count(c.id)) FROM c where c.pk = '{type}' and c.school = '{itemId}'");
  207. lastYearActivity += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(sqlTime, type, itemId, lastYearStart, lastYearEnd));
  208. yearActivity += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(sqlTime, type, itemId, yearStart, yearEnd));
  209. lastWeekActivity += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(sqlTime, type, itemId, lastWeekStart, lastWeekEnd));
  210. weekActivity += await CommonFind.GetSqlValueCount(cosmosClient, "Common", string.Format(sqlTime, type, itemId, weekStart, weekEnd));
  211. }
  212. allLessonCount += tempLessCount;
  213. allActivity += tempallActivity;
  214. allBloblog += tempBloblog;
  215. recSchoolDates.Add(new RecSchoolDate() { id = school.id, name = school.name, dataCount = (tempLessCount + tempallActivity + tempBloblog) });
  216. }
  217. return Ok(new { state = 200, schoolCount = schoolIds.Count, tecCount, stuCount, classCount, roomCount, allLessonCount, lastWeekLessCount, weekLessCount, lastTermLessCount, termLessCount, lastYearLessCount, yearLessCount, allBloblog, lastYearBloblog, yearBloblog, allActivity, lastYearActivity, yearActivity, lastWeekActivity, weekActivity, recSchoolDates });
  218. }
  219. /// <summary>
  220. /// 依据学校Id统计学校分析
  221. /// </summary>
  222. /// <param name="jsonElement"></param>
  223. /// <returns></returns>
  224. [ProducesDefaultResponseType]
  225. [HttpPost("get-idstatis")]
  226. public async Task<IActionResult> GetIdStatis(JsonElement jsonElement)
  227. {
  228. if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();
  229. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  230. int tecCount = 0; //学校教师数量
  231. int stuCount = 0; //学校学生数量
  232. int classCount = 0; //班级数量
  233. int roomCount = 0; //教室教师数量
  234. long allLessCount = 0; //课例总数
  235. int lastWeekLess = 0; //上周的总数
  236. int weekLess = 0; //本周的总数
  237. int lastTermLess = 0; //上学期的总数
  238. int termLess = 0; //本学期的总数
  239. int lessYearLess = 0; //去年的总数
  240. int yearLess = 0; //去年的总数
  241. int allActivity = 0; //学校所有活动
  242. int lastYearActivity = 0; //去年学校所有活动
  243. int yearActivity = 0; //今年学校所有活动
  244. int lastWeekActivity = 0; //上周学校所有活动
  245. int weekActivity = 0; //本周学校所有活动
  246. int allBlob = 0; //所有资源
  247. int lastYearBlob = 0; //去年的资源
  248. int yearBlob = 0; //去年的资源
  249. var cosmosClient = _azureCosmos.GetCosmosClient();
  250. ////分开部署,就不需要,一站多用时,取消注释
  251. //if ($"{site}".Equals(BIConst.Global))
  252. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  253. var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek"); //计算上周开始/结束时间
  254. var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week"); //计算本周开始/结束时间
  255. var (lastTermStart, lastTermEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastterm"); //计算上学期开始/结束时间
  256. var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term"); //计算本学期开始/结束时间
  257. var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
  258. var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year"); //计算今年开始/结束时间
  259. tecCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", "SELECT value(count(c.id)) FROM c WHERE ARRAY_CONTAINS(c.roles, 'teacher', true) AND c.status = 'join'", code: $"Teacher-{schoolId}");
  260. stuCount = await JointlySingleQuery.GetValueInt(cosmosClient, "Student", code: $"Base-{schoolId}");
  261. classCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", code: $"Class-{schoolId}");
  262. roomCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", code: $"Room-{schoolId}");
  263. string unifyTimeSql = "select value(count(c.id)) from c where c.startTime>={0} and c.startTime<={1}";
  264. allLessCount = await LessonStatisWay.GetSchoolIdLessonCount(cosmosClient, $"{schoolId}");
  265. lastWeekLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, lastWeekStart, lastWeekEnd), $"LessonRecord-{schoolId}");
  266. weekLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, weekStart, lastWeekEnd), $"LessonRecord-{schoolId}");
  267. lastTermLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, lastTermStart, lastTermEnd), $"LessonRecord-{schoolId}");
  268. termLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, termStart, termEnd), $"LessonRecord-{schoolId}");
  269. lessYearLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, lastYearStart, lastYearEnd), $"LessonRecord-{schoolId}");
  270. yearLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, yearStart, yearEnd), $"LessonRecord-{schoolId}");
  271. //统计活动
  272. foreach (var type in StaticValue.activityTypes)
  273. {
  274. string sqlTime = "select value(count(c.id)) from c where c.pk = '{0}' and c.school = '{1}' and c.createTime>={2} and c.createTime<={3}";
  275. allActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"select value(count(c.id)) from c where c.pk = '{type}' and c.school = '{schoolId}'");
  276. lastYearActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, lastYearStart, lastYearEnd));
  277. yearActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, yearStart, yearEnd));
  278. lastWeekActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, lastWeekStart, lastWeekEnd));
  279. weekActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, weekStart, weekEnd));
  280. }
  281. //学校资源
  282. string blobTimeSql = "select value(count(c.id)) from c where c.time>={0} and c.time<={1}";
  283. allBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", code: $"Bloblog-{schoolId}");
  284. lastYearBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(blobTimeSql, lastYearStart, lastYearEnd), $"Bloblog-{schoolId}");
  285. yearBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(blobTimeSql, yearStart, yearEnd), $"Bloblog-{schoolId}");
  286. //获取所有的课程记录
  287. List<LessonRecord> records = new();
  288. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
  289. {
  290. records.Add(item);
  291. }
  292. List<(string name, int count)> gradeCount = new();
  293. if (records.Count > 0)
  294. {
  295. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey($"Base"));
  296. School sc = new();
  297. if (response.Status == 200)
  298. {
  299. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  300. sc = json.ToObject<School>();
  301. }
  302. List<string> grades = new();
  303. foreach (var item in records)
  304. {
  305. foreach (string gId in item.grade)
  306. {
  307. if (!grades.Contains(gId))
  308. {
  309. grades.Add(gId);
  310. }
  311. }
  312. }
  313. foreach (var gId in grades)
  314. {
  315. var c = records.Where(r => r.grade.Contains(gId)).Count();
  316. gradeCount.Add((gId, c));
  317. }
  318. }
  319. return Ok(new { state = 200, tecCount, stuCount, classCount, roomCount, allLessCount, lastWeekLess, weekLess, lastTermLess, termLess, lessYearLess, yearLess, allActivity, lastYearActivity, yearActivity, lastWeekActivity, weekActivity, allBlob, lastYearBlob, yearBlob });
  320. }
  321. /// <summary>
  322. /// 未区域学校统计
  323. /// </summary>
  324. /// <param name="jsonElement"></param>
  325. /// <returns></returns>
  326. [ProducesDefaultResponseType]
  327. [HttpPost("get-noarea")]
  328. public async Task<IActionResult> GetNoAreaCnt(JsonElement jsonElement)
  329. {
  330. var cosmosClient = _azureCosmos.GetCosmosClient();
  331. int tLessCnt = 0; //课例
  332. int tActCnt = 0; //活动
  333. List<string> scIds = new(); //学校id集合
  334. string scIdSql = "select value(c.id) from c where c.areaId=null or c.areaId=''";
  335. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  336. {
  337. scIds.Add(item);
  338. }
  339. string comSql = BICommonWay.ManyScSql("c.school", scIds);
  340. string lesSql = $"select value(count(c.id)) from c where c.pk='LessonRecord' and {comSql}";
  341. tLessCnt = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School", "Teacher" }, lesSql);
  342. comSql = BICommonWay.ManyScSql(" and c.school", scIds);
  343. tActCnt = await ActivityWay.GetCnt(cosmosClient, condSql: comSql);
  344. return Ok(new { state = 200, scCnt=scIds.Count(), tLessCnt, tActCnt });
  345. }
  346. /// <summary>
  347. /// 未加区的学校统计
  348. /// </summary>
  349. /// <param name="jsonElement"></param>
  350. /// <returns></returns>
  351. [ProducesDefaultResponseType]
  352. [HttpPost("get-noareasc")]
  353. public async Task<IActionResult> GetNoAareaScCnt(JsonElement jsonElement)
  354. {
  355. var cosmosClient = _azureCosmos.GetCosmosClient();
  356. var tableClient = _azureStorage.GetCloudTableClient();
  357. var table = tableClient.GetTableReference("BIDDUserInfo");
  358. var (dayS, dayE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow);
  359. var (weekS, weekE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
  360. var (monthS, monthE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
  361. var (termS, termE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term");
  362. List<AreaAssist> areaAssists = new(); //顾问信息
  363. int tchCnt = 0; //所有区级老师
  364. int stuCnt = 0; //所有区级学生
  365. int tLessCnt = 0; //课例数量
  366. int tActCnt = 0; //活动数量
  367. HashSet<string> tchIds = new();
  368. List<string> scIds = new(); //学校id集合
  369. string scIdSql = "select value(c.id) from c where c.areaId=null or c.areaId=''";
  370. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  371. {
  372. scIds.Add(item);
  373. }
  374. string scsSql = BICommonWay.ManyScSql("c.school", scIds);
  375. string cntSql = $"select value(count(c.id)) from c where {scsSql}";
  376. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<int>(queryText: cntSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  377. {
  378. tchCnt += item;
  379. }
  380. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<int>(queryText: cntSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  381. {
  382. stuCnt += item;
  383. }
  384. foreach (var scId in scIds)
  385. {
  386. string tchIdSql = $"select value(c.id) from c where array_contains(c.roles,'assist',true) and c.pk='Teacher'";
  387. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: tchIdSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
  388. {
  389. tchIds.Add(item);
  390. }
  391. }
  392. List<string> noIds = new();
  393. foreach (var item in tchIds)
  394. {
  395. List<DingDingUserInfo> ddUsers = await table.QueryWhereString<DingDingUserInfo>($"PartitionKey eq '{_option.Location}' and tmdId eq '{item}'");
  396. if (ddUsers.Count > 0)
  397. {
  398. foreach (var dduser in ddUsers)
  399. {
  400. AreaAssist areaAssist = new()
  401. {
  402. userId = dduser.userId,
  403. unionId = dduser.unionId,
  404. name = dduser.name,
  405. mobile = dduser.mobile,
  406. avatar = dduser.avatar,
  407. tmdId = dduser.tmdId,
  408. tmdName = dduser.tmdName,
  409. tmdMobile = dduser.tmdMobile,
  410. picture = dduser.picture,
  411. roles = dduser.roles,
  412. schoolIds = dduser.schoolIds
  413. };
  414. areaAssists.Add(areaAssist);
  415. }
  416. }
  417. else { noIds.Add(item); }
  418. }
  419. if (scIds.Count > 0)
  420. {
  421. string lesSql = $"select value(count(c.id)) from c where c.pk='LessonRecord' and {scsSql}";
  422. tLessCnt = await CommonFind.GetSqlValueCount(cosmosClient, new List<string>() { "School", "Teacher" }, lesSql);
  423. string actComSql = BICommonWay.ManyScSql(" and c.school", scIds);
  424. tActCnt = await ActivityWay.GetCnt(cosmosClient, condSql: actComSql);
  425. }
  426. return Ok(new { state = RespondCode.Ok, scCnt = scIds.Count, tchCnt, stuCnt, allCnt = tLessCnt + tActCnt, tLessCnt, tActCnt});
  427. }
  428. /// <summary>
  429. /// 学校统计
  430. /// 新的数据结构
  431. /// </summary>
  432. /// <param name="jsonElement"></param>
  433. /// <returns></returns>
  434. [ProducesDefaultResponseType]
  435. [HttpPost("get-scstats")]
  436. public async Task<IActionResult> GetSchoolStats(JsonElement jsonElement)
  437. {
  438. if (!jsonElement.TryGetProperty("scId", out JsonElement scId)) return BadRequest();
  439. var cosmosClient = _azureCosmos.GetCosmosClient();
  440. School school = new();
  441. ScStats scStats = new();
  442. var respSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{scId}", new PartitionKey($"Base"));
  443. if (respSc.Status == 200)
  444. {
  445. using var fileJson = await JsonDocument.ParseAsync(respSc.ContentStream);
  446. school = fileJson.ToObject<School>();
  447. }
  448. else
  449. return Ok(new { state = RespondCode.NotFound, msg = $"未找到id:{scId};相关的学校,请检查" });
  450. try
  451. {
  452. bool isExist = true;
  453. StatsInfo statsInfo = new();
  454. var scDataStats = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{scId}", new PartitionKey("Stats"));
  455. if (scDataStats.Status == 200)
  456. {
  457. using var fileJson = await JsonDocument.ParseAsync(scDataStats.ContentStream);
  458. statsInfo = fileJson.ToObject<StatsInfo>();
  459. }
  460. else
  461. {
  462. scStats.id = school.id;
  463. isExist = false;
  464. }
  465. bool isnew = false;
  466. DateTimeOffset dateTime = DateTimeOffset.UtcNow;
  467. long now = dateTime.ToUnixTimeMilliseconds();
  468. if (!string.IsNullOrEmpty(statsInfo.id))
  469. {
  470. scStats.id= statsInfo.id;
  471. scStats.name = statsInfo.name;
  472. scStats.picture = statsInfo.picture;
  473. scStats.tch = statsInfo.tch;
  474. scStats.dayTch = statsInfo.dayTch;
  475. scStats.weekTch = statsInfo.weekTch;
  476. scStats.monthTch = statsInfo.monthTch;
  477. scStats.stu = statsInfo.stu;
  478. scStats.dayStu = statsInfo.dayStu;
  479. scStats.weekStu = statsInfo.weekStu;
  480. scStats.monthStu = statsInfo.monthStu;
  481. scStats.room = statsInfo.room;
  482. scStats.witRoom = statsInfo.witRoom;
  483. scStats.size = statsInfo.size;
  484. scStats.scCreateTime = statsInfo.scCreateTime;
  485. scStats.upTime = statsInfo.upTime;
  486. scStats.lessStats.open = statsInfo.lesson.open;
  487. scStats.lessStats.less = statsInfo.lesson.less;
  488. scStats.lessStats.lastDay = statsInfo.lesson.lastDay;
  489. scStats.lessStats.day = statsInfo.lesson.day;
  490. scStats.lessStats.lastWeek = statsInfo.lesson.lastWeek;
  491. scStats.lessStats.week = statsInfo.lesson.week;
  492. scStats.lessStats.lastTerm = statsInfo.lesson.lastTerm;
  493. scStats.lessStats.term = statsInfo.lesson.term;
  494. scStats.lessStats.lastDayInter = statsInfo.lesson.lastDayInter;
  495. scStats.lessStats.dayInter = statsInfo.lesson.dayInter;
  496. scStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
  497. scStats.lessStats.monthInter = statsInfo.lesson.monthInter;
  498. scStats.lessStats.lastYearInter = statsInfo.lesson.lastYearInter;
  499. scStats.lessStats.yearInter=statsInfo.lesson.yearInter;
  500. scStats.lessStats.LastYear = TimeHelper.GetYearMonth(statsInfo.lesson.LastYear, dateTime.Year, dateTime.Month);
  501. scStats.lessStats.year = TimeHelper.GetYearMonth(statsInfo.lesson.year, dateTime.Year, dateTime.Month);
  502. scStats.actStats.cnt = statsInfo.activity.cnt;
  503. scStats.actStats.exam = statsInfo.activity.exam;
  504. scStats.actStats.survey = statsInfo.activity.survey;
  505. scStats.actStats.vote = statsInfo.activity.vote;
  506. scStats.actStats.homework = statsInfo.activity.homework;
  507. scStats.actStats.lastDay = statsInfo.activity.lastDay;
  508. scStats.actStats.dayCnt = statsInfo.activity.dayCnt;
  509. scStats.actStats.lastWeek = statsInfo.activity.lastWeek;
  510. scStats.actStats.week = statsInfo.activity.week;
  511. scStats.actStats.lastTerm = statsInfo.activity.lastTerm;
  512. scStats.actStats.term = statsInfo.activity.term;
  513. scStats.actStats.LastYear = TimeHelper.GetYearMonth(statsInfo.activity.LastYear ,dateTime.Year,dateTime.Month);
  514. scStats.actStats.year = TimeHelper.GetYearMonth(statsInfo.activity.year, dateTime.Year, dateTime.Month);
  515. if (statsInfo.study != null)
  516. {
  517. scStats.srStats.learnTime = statsInfo.study.learnTime;
  518. scStats.srStats.online = statsInfo.study.online;
  519. scStats.srStats.offline = statsInfo.study.offline;
  520. scStats.srStats.classRoom = statsInfo.study.classRoom;
  521. scStats.srStats.submit = statsInfo.study.submit;
  522. scStats.srStats.notStarted = statsInfo.study.notStarted;
  523. scStats.srStats.ongoing = statsInfo.study.ongoing;
  524. scStats.srStats.finish = statsInfo.study.finish;
  525. }
  526. }
  527. if(statsInfo.upTime > 0 && !isnew) {
  528. long timedis = 20 * 60 * 1000;//20分钟
  529. if (now - statsInfo.upTime < timedis)
  530. isnew = true;
  531. }
  532. if (statsInfo.upTime == 0 && isnew)
  533. statsInfo.upTime = now;
  534. if (statsInfo.upTime == 0 && isnew)
  535. statsInfo.upTime = DateTimeOffset.UtcNow.Add(new TimeSpan(-1, 0, 0, 0)).ToUnixTimeMilliseconds();
  536. if (!isnew)
  537. {
  538. //Function 处理Function 更新或者新增
  539. //_ = _httpTrigger.RequestHttpTrigger(new { schoolId = $"{school.id}"}, _option.Location, "stats-sc-info");
  540. //异步方法处理 同步更新
  541. statsInfo = await SchoolStatsWay.GetSingleSc(cosmosClient, school.id);
  542. statsInfo.upTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
  543. if (isExist)
  544. statsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<StatsInfo>(statsInfo, statsInfo.id, new PartitionKey("Stats"));
  545. else
  546. statsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<StatsInfo>(statsInfo, new PartitionKey("Stats"));
  547. }
  548. return Ok(new { state = RespondCode.Ok, statsInfo });
  549. }
  550. catch (Exception ex)
  551. {
  552. //await _dingDing.SendBotMsg($"BI,{_option.Location} /school/set-scstats \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  553. return BadRequest();
  554. }
  555. }
  556. /// <summary>
  557. /// 区域统计
  558. /// 新的数据结构
  559. /// </summary>
  560. /// <param name="jsonElement"></param>
  561. /// <returns></returns>
  562. [ProducesDefaultResponseType]
  563. [HttpPost("get-areastats")]
  564. public async Task<IActionResult> GetAreaStats(JsonElement jsonElement)
  565. {
  566. if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
  567. var cosmosClient = _azureCosmos.GetCosmosClient();
  568. Area area = new();
  569. ScStats areaScStats = new();
  570. var respSc = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey($"Base-Area"));
  571. if (respSc.Status == 200)
  572. {
  573. using var fileJson = await JsonDocument.ParseAsync(respSc.ContentStream);
  574. area = fileJson.ToObject<Area>();
  575. }
  576. else
  577. return Ok(new { state = RespondCode.NotFound, msg = $"未找到id:{areaId};相关的学区,请检查!" });
  578. List<string> scIds = new();
  579. //scIds.Contains
  580. string scSql = $"select value(c.id) from c where c.areaId='{areaId}'";
  581. scIds = await CommonFind.FindScIds(cosmosClient, scSql, "Base");
  582. //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: scSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")} ))
  583. //{
  584. // scIds.Add(item);
  585. //}
  586. StringBuilder statsSql = new("select value(c) from c");
  587. if (scIds.Count > 0)
  588. {
  589. statsSql.Append($" where {BICommonWay.ManyScSql("c.id", scIds)}");
  590. }
  591. List<ScStats> scStats = new();
  592. List<StatsInfo> statsInfos = new();
  593. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIterator<StatsInfo>(queryText:statsSql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Stats") }))
  594. {
  595. statsInfos.Add(item);
  596. }
  597. StatsInfo statsInfo = new();
  598. statsInfo = await SchoolStatsWay.GetAreaStats(cosmosClient, _httpTrigger, _option, statsInfos, scIds);
  599. return Ok(new { state = RespondCode.Ok ,area, statsInfo, scIds });
  600. }
  601. /// <summary>
  602. /// 学校信息中间件查询接口
  603. /// </summary>
  604. /// <param name="jsonElement"></param>
  605. /// <returns></returns>
  606. [ProducesDefaultResponseType]
  607. [HttpPost("get-scinfos")]
  608. public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
  609. {
  610. var cosmosClient = _azureCosmos.GetCosmosClient();
  611. List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
  612. List<BIRelation> scInfos = new();
  613. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText:$"select value(c) from c",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
  614. {
  615. scInfos.Add(item);
  616. }
  617. return Ok(new { state = RespondCode.Ok, allCnt = scId.Count, scInfos });
  618. }
  619. /// <summary>
  620. /// 依据Id查询School容器 数据管理工具——查询工具
  621. /// </summary>
  622. /// <param name="jsonElement"></param>
  623. /// <returns></returns>
  624. [ProducesDefaultResponseType]
  625. [HttpPost("get-info")]
  626. public async Task<IActionResult> GetSchool(JsonElement jsonElement)
  627. {
  628. if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
  629. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  630. var cosmosClient = _azureCosmos.GetCosmosClient();
  631. //if ($"{site}".Equals(BIConst.Global))
  632. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  633. List<object> infos = new List<object>();
  634. string sqlTxt = $"select value(c) from c where c.id='{id}'";
  635. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
  636. {
  637. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  638. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  639. {
  640. infos.Add(obj.ToObject<object>());
  641. }
  642. }
  643. return Ok(new { state = 200, infos });
  644. }
  645. public record RecSchoolDate
  646. {
  647. public string id { get; set; }
  648. public string name { get; set; }
  649. public long dataCount { get; set; }
  650. }
  651. /// <summary>
  652. /// 前端显示学校统计数据
  653. /// </summary>
  654. public record ScStats
  655. {
  656. public string id { get; set; }
  657. public string name { get; set; }
  658. public string picture { get; set; }
  659. public int tch { get; set; }
  660. public int dayTch { get; set; }
  661. public int weekTch { get; set; }
  662. public int monthTch { get; set; }
  663. public int stu { get; set; }
  664. public int dayStu { get; set; }
  665. public int weekStu { get; set; }
  666. public int monthStu { get; set; }
  667. public int room { get; set; }
  668. public int witRoom { get; set; }
  669. public int size { get; set; }
  670. public long scCreateTime { get; set; }
  671. public long upTime { get; set; }
  672. public ScLessStats lessStats { get; set; } = new ScLessStats();
  673. public ScActStats actStats { get; set; } = new ScActStats();
  674. public ScSRStats srStats { get; set; } = new ScSRStats();
  675. }
  676. /// <summary>
  677. /// 课例活动数据
  678. /// </summary>
  679. public record ScLessStats
  680. {
  681. public int open { get; set; }
  682. public int less { get; set; }
  683. public int lastDay { get; set; }
  684. public int day { get; set; }
  685. public int lastWeek { get; set; }
  686. public int week { get; set; }
  687. public int lastTerm { get; set; }
  688. public int term { get; set; }
  689. public int lastDayInter { get; set; }
  690. public int dayInter { get; set; }
  691. public int lastMonthInter { get; set; }
  692. public int monthInter { get; set; }
  693. public int lastYearInter { get; set; }
  694. public int yearInter { get; set; }
  695. //public List<YearMonth> yearInter { get; set; } = new List<YearMonth>();//12个月
  696. public List<YearMonth> LastYear { get; set; } = new List<YearMonth>();//12个月
  697. public List<YearMonth> year { get; set; } = new List<YearMonth>(); //12个月
  698. }
  699. /// <summary>
  700. /// 学校活动数据
  701. /// </summary>
  702. public record ScActStats
  703. {
  704. public int cnt { get; set; }
  705. public int exam { get; set; }
  706. public int survey { get; set; }
  707. public int vote { get; set; }
  708. public int homework { get; set; }
  709. public int lastDay { get; set; }
  710. public int dayCnt { get; set; }
  711. public int lastWeek { get; set; }
  712. public int week { get; set; }
  713. public int lastTerm { get; set; }
  714. public int term { get; set; }
  715. public List<YearMonth> LastYear { get; set; } = new List<YearMonth>(); //12个月
  716. public List<YearMonth> year { get; set; } = new List<YearMonth>(); //12个月
  717. }
  718. /// <summary>
  719. /// 研修统计数据
  720. /// </summary>
  721. public record ScSRStats
  722. {
  723. public int learnTime { get; set; }
  724. public int online { get; set; }
  725. public int offline { get; set; }
  726. public int classRoom { get; set; }
  727. public int submit { get; set; }
  728. public int notStarted { get; set; }
  729. public int ongoing { get; set; }
  730. public int finish { get; set; }
  731. }
  732. }
  733. }