SchoolController.cs 46 KB

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