HomeStatisController.cs 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using System.Text.Json;
  8. using TEAMModelOS.SDK.DI;
  9. using Azure.Cosmos;
  10. using Microsoft.Extensions.Options;
  11. using TEAMModelOS.SDK.Models;
  12. using TEAMModelOS.Models;
  13. using System.Text;
  14. using StackExchange.Redis;
  15. using TEAMModelOS.SDK.Extension;
  16. using TEAMModelBI.Models;
  17. namespace TEAMModelBI.Controllers.BIHome
  18. {
  19. [Route("homestatis")]
  20. [ApiController]
  21. public class HomeStatisController : ControllerBase
  22. {
  23. private readonly AzureCosmosFactory _azureCosmos;
  24. private readonly AzureStorageFactory _azureStorage;
  25. private readonly DingDing _dingDing;
  26. private readonly Option _option;
  27. private readonly AzureRedisFactory _azureRedis;
  28. public HomeStatisController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option)
  29. {
  30. _azureCosmos = azureCosmos;
  31. _dingDing = dingDing;
  32. _option = option?.Value;
  33. _azureStorage = azureStorage;
  34. _azureRedis = azureRedis;
  35. }
  36. /// <summary>
  37. /// 获取全部教师数量、学生数量、已创校数量、全部学校总空间大小
  38. /// </summary>
  39. /// <param name="jsonElement"></param>
  40. /// <returns></returns>
  41. [ProducesDefaultResponseType]
  42. [HttpPost("get-allnumber")]
  43. public async Task<IActionResult> GetAllNumber()
  44. {
  45. try
  46. {
  47. var client = _azureCosmos.GetCosmosClient();;
  48. //查询全部教师人数
  49. long teacherCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.code='Base'", new List<string>() { "Teacher" });
  50. //查询全部教师人数
  51. long studentCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.pk='Base'", new List<string>() { "Student" });
  52. //查询已创建多少学校
  53. long schoolCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.code='Base'", new List<string>() { "School" });
  54. //空间
  55. long schoolSize = await CommonFind.FindTotals(client, "select sum(c.size) as totals from c where c.code='Base'", new List<string>() { "School" });
  56. return Ok(new { state = 200, teacherCount, studentCount, schoolCount, schoolSize });
  57. ////依据学校查询教师人数
  58. //List<string> teacherCount_list = new();
  59. ////依据学校查询学生信息
  60. //List<string> studentCount_List = new();
  61. ////学校数
  62. //List<string> schoolCount_List = new();
  63. ////学校空间大小
  64. //long schoolsize = 0
  65. ////查询全部教师人数
  66. //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  67. //{
  68. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  69. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  70. // {
  71. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  72. // while (accounts.MoveNext())
  73. // {
  74. // JsonElement account = accounts.Current;
  75. // teacherCount_list.Add(account.GetProperty("id").GetString());
  76. // }
  77. // }
  78. //}
  79. ////查询全部学生人数
  80. //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.pk='Base'"))
  81. //{
  82. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  83. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  84. // {
  85. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  86. // while (accounts.MoveNext())
  87. // {
  88. // JsonElement account = accounts.Current;
  89. // studentCount_List.Add(account.GetProperty("id").GetString());
  90. // }
  91. // }
  92. //}
  93. ////查询已创建多少学校
  94. //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  95. //{
  96. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  97. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  98. // {
  99. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  100. // while (accounts.MoveNext())
  101. // {
  102. // JsonElement account = accounts.Current;
  103. // schoolCount_List.Add(account.GetProperty("id").GetString());
  104. // schoolsize += account.GetProperty("size").GetInt64();
  105. // }
  106. // }
  107. //}
  108. ////查询教师的大小和教师集合信息
  109. //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select sum(c.size) as size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  110. //{
  111. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  112. // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  113. // {
  114. // schoolsize += obj.GetProperty("size").GetInt64();
  115. // }
  116. //}
  117. //return Ok(new { state = 200, teacherCount = teacherCount_list.Count, studentCount = studentCount_List.Count, schoolCount = schoolCount_List.Count, schoolSize = schoolsize });
  118. }
  119. catch (Exception ex)
  120. {
  121. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-numberpeople \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  122. return BadRequest();
  123. }
  124. }
  125. /// <summary>
  126. /// 获取其它类型的统计:问卷调查、评量检测、投票活动
  127. /// </summary>
  128. /// <param name="jsonElement"></param>
  129. /// <returns></returns>
  130. [ProducesDefaultResponseType]
  131. [HttpPost("get-othertypes")]
  132. public async Task<IActionResult> GetOtherTypes(JsonElement jsonElement)
  133. {
  134. try
  135. {
  136. if (!jsonElement.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
  137. int surveyJoinCount = 0; //调查参加数量
  138. int surveyDoneCount = 0; //调查完成数量
  139. int surveyAreaJoinCount = 0; //调查区域参加数量
  140. int surveyAreaDoneCount = 0; //调查区域完成数量
  141. int examJoinCount = 0; //评量检测参加数量
  142. int examDoneCount = 0; //评量检测完成数量
  143. int examAreaJoinCount = 0; //评量检测区域参加数量
  144. int examAreaDoneCount = 0; //评量检测区域完成数量
  145. int voteJoinCount = 0; //投票参加数量
  146. int voteDoneCount = 0; //投票完成数量
  147. int voteAreaJoinCount = 0; //投票区域参加数量
  148. int voteAreaDoneCount = 0; //投票区域完成数量
  149. //问卷调查
  150. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
  151. .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Survey' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
  152. {
  153. if (!string.IsNullOrEmpty(item.owner))
  154. {
  155. if (item.owner.Equals("school"))
  156. {
  157. surveyJoinCount += 1;
  158. if (item.taskStatus > 0)
  159. {
  160. surveyDoneCount += 1;
  161. }
  162. }
  163. else if (item.owner.Equals("area"))
  164. {
  165. surveyAreaJoinCount += 1;
  166. if (item.taskStatus > 0)
  167. {
  168. surveyAreaDoneCount += 1;
  169. }
  170. }
  171. }
  172. }
  173. //评量检测
  174. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
  175. .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'ExamLite' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
  176. {
  177. if (!string.IsNullOrEmpty(item.owner))
  178. {
  179. if (item.owner.Equals("school"))
  180. {
  181. examJoinCount += 1;
  182. if (item.taskStatus > 0)
  183. {
  184. examDoneCount += 1;
  185. }
  186. }
  187. else if (item.owner.Equals("area"))
  188. {
  189. examAreaJoinCount += 1;
  190. if (item.taskStatus > 0)
  191. {
  192. examAreaDoneCount += 1;
  193. }
  194. }
  195. }
  196. }
  197. //投票活动
  198. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
  199. .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Vote' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
  200. {
  201. if (!string.IsNullOrEmpty(item.owner))
  202. {
  203. if (item.owner.Equals("school"))
  204. {
  205. voteJoinCount += 1;
  206. if (item.taskStatus > 0)
  207. {
  208. voteDoneCount += 1;
  209. }
  210. }
  211. else if (item.owner.Equals("area"))
  212. {
  213. voteAreaJoinCount += 1;
  214. if (item.taskStatus > 0)
  215. {
  216. voteAreaDoneCount += 1;
  217. }
  218. }
  219. }
  220. }
  221. return Ok(new { state = 200, surveyJoinCount, surveyDoneCount, surveyAreaJoinCount, surveyAreaDoneCount, examJoinCount, examDoneCount, examAreaJoinCount, examAreaDoneCount, voteJoinCount, voteDoneCount, voteAreaJoinCount, voteAreaDoneCount });
  222. }
  223. catch (Exception ex)
  224. {
  225. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-othertypes \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  226. return BadRequest();
  227. }
  228. }
  229. /// <summary>
  230. /// 查询所有区级信息统计数据
  231. /// </summary>
  232. /// <param name="jsonElement"></param>
  233. /// <returns></returns>
  234. [ProducesDefaultResponseType]
  235. [HttpPost("get-alldiststics")]
  236. public async Task<IActionResult> GetAllDistStics()
  237. {
  238. try
  239. {
  240. var cosmosClient = _azureCosmos.GetCosmosClient();
  241. List<SticsCity> standards = new List<SticsCity>();
  242. StringBuilder stringBuder = new StringBuilder("select c.name,c.provName,c.cityName,c.standard from c");
  243. //查询省份区域
  244. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: stringBuder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  245. {
  246. SticsCity sticsCity = new SticsCity
  247. {
  248. provName = item.provName,
  249. cityName = item.cityName,
  250. distName = item.name,
  251. standard = item.standard
  252. };
  253. standards.Add(sticsCity);
  254. }
  255. List<SticsDist> sticsDists = new List<SticsDist>();
  256. //查询所有下面的学校数量
  257. foreach (var itemStandrds in standards)
  258. {
  259. SticsDist sticsDist = new SticsDist();
  260. sticsDist.provName = itemStandrds.provName;
  261. sticsDist.cityName = itemStandrds.cityName;
  262. sticsDist.distName = itemStandrds.distName;
  263. sticsDist.standard = itemStandrds.standard;
  264. List<string> schoolIds = new List<string>();
  265. int schoolCount = 0;
  266. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrds.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  267. {
  268. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  269. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  270. {
  271. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  272. while (accounts.MoveNext())
  273. {
  274. JsonElement account = accounts.Current;
  275. schoolIds.Add(account.GetProperty("id").GetString());
  276. schoolCount += 1;
  277. }
  278. }
  279. }
  280. sticsDist.schoolCount = schoolCount;
  281. int teacherCount = 0; //教师数量
  282. int studentCount = 0; //学生数量
  283. List<string> teacherIds = new List<string>();
  284. List<string> studentIds = new List<string>();
  285. //查询学校下面的教师人数
  286. foreach (var itemSchool in schoolIds)
  287. {
  288. string sqlTeacherTxt = $"select distinct value(c) from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  289. //查询全部教师人数
  290. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: sqlTeacherTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  291. {
  292. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  293. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  294. {
  295. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  296. while (accounts.MoveNext())
  297. {
  298. //JsonElement account = accounts.Current;
  299. //teacherIds.Add(account.GetProperty("id").GetString());
  300. teacherCount += 1;
  301. }
  302. }
  303. }
  304. //查询全部学生人数
  305. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  306. {
  307. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  308. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  309. {
  310. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  311. while (accounts.MoveNext())
  312. {
  313. //JsonElement account = accounts.Current;
  314. //studentIds.Add(account.GetProperty("id").GetString());
  315. studentCount += 1;
  316. }
  317. }
  318. }
  319. }
  320. sticsDist.teacherCount = teacherCount;
  321. sticsDist.studentCount = studentCount;
  322. sticsDists.Add(sticsDist);
  323. }
  324. return Ok(new { state = 200, sticsDists });
  325. }
  326. catch (Exception ex)
  327. {
  328. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-alldiststics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  329. return BadRequest();
  330. }
  331. }
  332. /// <summary>
  333. /// 依据城市Code查询学校,教师数量,学生数量
  334. /// </summary>
  335. /// <param name="jsonElement"></param>
  336. /// <returns></returns>
  337. [ProducesDefaultResponseType]
  338. [HttpPost("get-citystics")]
  339. public async Task<IActionResult> GetCityStics(JsonElement jsonElement)
  340. {
  341. try
  342. {
  343. if(!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
  344. var cosmosClient = _azureCosmos.GetCosmosClient();
  345. List<string> areaStandard = new List<string>();
  346. //查询省份区域
  347. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  348. {
  349. areaStandard.Add(item.standard);
  350. }
  351. int citySchoolCount = 0;
  352. List<string> teacherIds = new List<string>();
  353. List<string> studentIds = new List<string>();
  354. foreach (var tempSatndard in areaStandard)
  355. {
  356. List<string> schoolIds = new List<string>();
  357. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{tempSatndard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  358. {
  359. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  360. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  361. {
  362. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  363. while (accounts.MoveNext())
  364. {
  365. JsonElement account = accounts.Current;
  366. schoolIds.Add(account.GetProperty("id").GetString());
  367. citySchoolCount += 1;
  368. }
  369. }
  370. }
  371. //查询学校下面的教师人数
  372. foreach (var itemSchool in schoolIds)
  373. {
  374. //查询全部教师人数
  375. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  376. {
  377. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  378. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  379. {
  380. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  381. while (accounts.MoveNext())
  382. {
  383. JsonElement account = accounts.Current;
  384. teacherIds.Add(account.GetProperty("id").GetString());
  385. }
  386. }
  387. }
  388. //查询全部学生人数
  389. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  390. {
  391. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  392. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  393. {
  394. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  395. while (accounts.MoveNext())
  396. {
  397. JsonElement account = accounts.Current;
  398. studentIds.Add(account.GetProperty("id").GetString());
  399. }
  400. }
  401. }
  402. }
  403. }
  404. return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teacherIds.Count, tudentCount = studentIds.Count });
  405. }
  406. catch (Exception ex)
  407. {
  408. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-citystics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  409. return BadRequest();
  410. }
  411. }
  412. /// <summary>
  413. /// 统计所有省份下的数据
  414. /// </summary>
  415. /// <returns></returns>
  416. [ProducesDefaultResponseType]
  417. [HttpPost("get-provincestics")]
  418. public async Task<IActionResult> GetProvinceStics()
  419. {
  420. try
  421. {
  422. var cosmosClient = _azureCosmos.GetCosmosClient();
  423. List<ProvinceStandard> standards = new List<ProvinceStandard>();
  424. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
  425. {
  426. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  427. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  428. {
  429. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  430. while (accounts.MoveNext())
  431. {
  432. JsonElement account = accounts.Current;
  433. ProvinceStandard provinceStandard = new ProvinceStandard
  434. {
  435. provCode = account.GetProperty("provCode").GetString(),
  436. provName = account.GetProperty("provName").GetString(),
  437. standard = account.GetProperty("standard").GetString()
  438. };
  439. standards.Add(provinceStandard);
  440. }
  441. }
  442. }
  443. List<ProvinceStics> provinceStics = new List<ProvinceStics>();
  444. foreach (var itemStandard in standards)
  445. {
  446. ProvinceStics tempProvinceStics = new ProvinceStics();
  447. var tempCode = provinceStics.Find(x => x.provCode == itemStandard.provCode);
  448. if (tempCode != null)
  449. {
  450. List<string> schoolIds = new List<string>();
  451. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandard.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  452. {
  453. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  454. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  455. {
  456. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  457. while (accounts.MoveNext())
  458. {
  459. JsonElement account = accounts.Current;
  460. schoolIds.Add(account.GetProperty("id").GetString());
  461. tempCode.schoolCount += 1;
  462. }
  463. }
  464. }
  465. if (schoolIds.Count > 0)
  466. {
  467. foreach (var itemSchool in schoolIds)
  468. {
  469. //查询学校教师人数
  470. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  471. {
  472. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  473. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  474. {
  475. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  476. while (accounts.MoveNext())
  477. {
  478. JsonElement account = accounts.Current;
  479. tempCode.teacherCount += 1;
  480. }
  481. }
  482. }
  483. //查询学校学生人数
  484. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  485. {
  486. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  487. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  488. {
  489. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  490. while (accounts.MoveNext())
  491. {
  492. JsonElement account = accounts.Current;
  493. tempCode.studentCount += 1;
  494. }
  495. }
  496. }
  497. }
  498. }
  499. var tempModel = provinceStics.Where(x => x.provCode == tempCode.provCode).FirstOrDefault();
  500. if (tempModel != null)
  501. {
  502. tempModel.schoolCount = tempCode.schoolCount;
  503. tempModel.teacherCount = tempCode.teacherCount;
  504. tempModel.studentCount = tempCode.studentCount;
  505. tempModel.standardCount +=1;
  506. }
  507. }
  508. else
  509. {
  510. tempProvinceStics.provCode = itemStandard.provCode;
  511. tempProvinceStics.provName = itemStandard.provName;
  512. tempProvinceStics.standardCount += 1;
  513. List<string> schoolIds = new List<string>();
  514. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandard.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  515. {
  516. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  517. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  518. {
  519. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  520. while (accounts.MoveNext())
  521. {
  522. JsonElement account = accounts.Current;
  523. schoolIds.Add(account.GetProperty("id").GetString());
  524. tempProvinceStics.schoolCount += 1;
  525. }
  526. }
  527. }
  528. if (schoolIds.Count > 0)
  529. {
  530. foreach (var itemSchool in schoolIds)
  531. {
  532. //查询学校教师人数
  533. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  534. {
  535. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  536. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  537. {
  538. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  539. while (accounts.MoveNext())
  540. {
  541. JsonElement account = accounts.Current;
  542. tempProvinceStics.teacherCount += 1;
  543. }
  544. }
  545. }
  546. //查询学校学生人数
  547. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  548. {
  549. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  550. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  551. {
  552. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  553. while (accounts.MoveNext())
  554. {
  555. JsonElement account = accounts.Current;
  556. tempProvinceStics.studentCount += 1;
  557. }
  558. }
  559. }
  560. }
  561. }
  562. provinceStics.Add(tempProvinceStics);
  563. }
  564. }
  565. return Ok(new { state = 200, provinceStics });
  566. }
  567. catch (Exception ex)
  568. {
  569. await _dingDing.SendBotMsg($"BI, {_option.Location} // \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  570. return BadRequest();
  571. }
  572. }
  573. /// <summary>
  574. /// 查询所有市级下的学校数量
  575. /// </summary>
  576. /// <returns></returns>
  577. [ProducesDefaultResponseType]
  578. [HttpPost("get-cityschool")]
  579. public async Task<IActionResult> GetCitySchool()
  580. {
  581. try
  582. {
  583. var cosmosClient = _azureCosmos.GetCosmosClient();
  584. List<CityStandard> standards = new List<CityStandard>();
  585. //查询省份区域
  586. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  587. {
  588. CityStandard Citystics = new CityStandard
  589. {
  590. cityCode = item.cityCode,
  591. cityName = item.cityName,
  592. standard = item.standard
  593. };
  594. standards.Add(Citystics);
  595. }
  596. List<CitySchool> citySchools = new List<CitySchool>(); //返回数量
  597. foreach (var itemStandrd in standards)
  598. {
  599. CitySchool citySchool = new CitySchool();
  600. var tempCode = citySchools.Find(x => x.cityCode == itemStandrd.cityCode);
  601. if (tempCode != null)
  602. {
  603. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  604. {
  605. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  606. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  607. {
  608. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  609. while (accounts.MoveNext())
  610. {
  611. JsonElement account = accounts.Current;
  612. tempCode.schoolCount += 1;
  613. }
  614. }
  615. }
  616. var tempModel = citySchools.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
  617. if (tempModel != null)
  618. {
  619. tempModel.schoolCount = tempCode.schoolCount;
  620. }
  621. }
  622. else
  623. {
  624. citySchool.cityCode = itemStandrd.cityCode;
  625. citySchool.cityName = itemStandrd.cityName;
  626. List<string> schoolIds = new List<string>();
  627. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  628. {
  629. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  630. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  631. {
  632. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  633. while (accounts.MoveNext())
  634. {
  635. JsonElement account = accounts.Current;
  636. schoolIds.Add(account.GetProperty("id").GetString());
  637. citySchool.schoolCount += 1;
  638. }
  639. }
  640. }
  641. citySchools.Add(citySchool);
  642. }
  643. }
  644. return Ok(new { state = 200, citySchools });
  645. }
  646. catch (Exception ex)
  647. {
  648. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-cityschool \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  649. return BadRequest();
  650. }
  651. }
  652. /// <summary>
  653. /// 依据市级ID查询区域(区、县、郡)的学校、教师、学生数量
  654. /// </summary>
  655. /// <param name="jsonElement"></param>
  656. /// <returns></returns>
  657. [ProducesDefaultResponseType]
  658. [HttpPost("get-districtstics")]
  659. public async Task<IActionResult> GetDistrictStics(JsonElement jsonElement)
  660. {
  661. try
  662. {
  663. if (!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
  664. var cosmosClient = _azureCosmos.GetCosmosClient();
  665. List<DistrictStandard> districtStandards = new List<DistrictStandard>();
  666. //查询省份区域
  667. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  668. {
  669. DistrictStandard districtStandard = new DistrictStandard
  670. {
  671. cityName = item.cityName,
  672. distName = item.name,
  673. standard = item.standard
  674. };
  675. districtStandards.Add(districtStandard);
  676. }
  677. List<DistrictStics> districtSticss = new List<DistrictStics>(); //返回数据
  678. foreach (var itemStandrd in districtStandards)
  679. {
  680. DistrictStics districtStics = new DistrictStics();
  681. districtStics.cityName = itemStandrd.cityName;
  682. districtStics.distName = itemStandrd.distName;
  683. List<string> schoolIds = new List<string>();
  684. //查询区域学校数量
  685. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  686. {
  687. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  688. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  689. {
  690. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  691. while (accounts.MoveNext())
  692. {
  693. JsonElement account = accounts.Current;
  694. schoolIds.Add(account.GetProperty("id").GetString());
  695. districtStics.schoolCount += 1;
  696. }
  697. }
  698. }
  699. if (schoolIds.Count > 0)
  700. {
  701. foreach (var itemSchool in schoolIds)
  702. {
  703. //查询学校教师人数
  704. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  705. {
  706. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  707. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  708. {
  709. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  710. while (accounts.MoveNext())
  711. {
  712. JsonElement account = accounts.Current;
  713. districtStics.teacherCount += 1;
  714. }
  715. }
  716. }
  717. //查询学校学生人数
  718. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  719. {
  720. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  721. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  722. {
  723. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  724. while (accounts.MoveNext())
  725. {
  726. JsonElement account = accounts.Current;
  727. districtStics.studentCount += 1;
  728. }
  729. }
  730. }
  731. }
  732. }
  733. districtSticss.Add(districtStics);
  734. }
  735. return Ok(new { state = 200, districtSticss });
  736. }
  737. catch (Exception ex)
  738. {
  739. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-districtstics \n {ex.Message} {ex.StackTrace} ", GroupNames.成都开发測試群組);
  740. return BadRequest();
  741. }
  742. }
  743. /// <summary>
  744. /// 查询市的学校数据,以及市级下的区中的学校,教师、学生数量
  745. /// </summary>
  746. /// <param name="jsonElement"></param>
  747. /// <returns></returns>
  748. [ProducesDefaultResponseType]
  749. [HttpPost("get-cityallstics")]
  750. public async Task<IActionResult> GetCityAllStics(JsonElement jsonElement)
  751. {
  752. try
  753. {
  754. var cosmosClient = _azureCosmos.GetCosmosClient();
  755. List<AllCityStics> tempAllCityStics = new List<AllCityStics>();
  756. //查询省份区域
  757. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  758. {
  759. AllCityStics Citystics = new AllCityStics
  760. {
  761. cityCode = item.cityCode,
  762. cityName = item.cityName,
  763. distName = item.name,
  764. standard = item.standard
  765. };
  766. tempAllCityStics.Add(Citystics);
  767. }
  768. List<SticsCitys> sticsCitys = new List<SticsCitys>();
  769. foreach(var itemStandrd in tempAllCityStics)
  770. {
  771. SticsCitys citySchool = new SticsCitys();
  772. var tempCode = sticsCitys.Find(x => (x.cityCode) == (itemStandrd.cityCode));
  773. if (tempCode != null)
  774. {
  775. List<string> schoolIds = new List<string>();
  776. try
  777. {
  778. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  779. {
  780. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  781. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  782. {
  783. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  784. while (accounts.MoveNext())
  785. {
  786. JsonElement account = accounts.Current;
  787. schoolIds.Add(account.GetProperty("id").GetString());
  788. tempCode.schoolCount += 1;
  789. }
  790. }
  791. }
  792. }
  793. catch
  794. {
  795. }
  796. var tempModel = sticsCitys.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
  797. if (tempModel != null)
  798. {
  799. tempModel.schoolCount = tempCode.schoolCount;
  800. }
  801. DistrictStics districtStics = new DistrictStics();
  802. districtStics.cityName = itemStandrd.cityName;
  803. districtStics.distName = itemStandrd.distName;
  804. districtStics.schoolCount = schoolIds.Count;
  805. if (schoolIds.Count > 0)
  806. {
  807. foreach (var itemSchool in schoolIds)
  808. {
  809. //查询学校教师人数
  810. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  811. {
  812. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  813. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  814. {
  815. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  816. while (accounts.MoveNext())
  817. {
  818. JsonElement account = accounts.Current;
  819. districtStics.teacherCount += 1;
  820. }
  821. }
  822. }
  823. //查询学校学生人数
  824. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  825. {
  826. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  827. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  828. {
  829. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  830. while (accounts.MoveNext())
  831. {
  832. JsonElement account = accounts.Current;
  833. districtStics.studentCount += 1;
  834. }
  835. }
  836. }
  837. }
  838. }
  839. var tempDistrict = sticsCitys.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
  840. if (tempDistrict != null)
  841. {
  842. tempDistrict.districtSticss.Add(districtStics);
  843. }
  844. }
  845. else
  846. {
  847. citySchool.cityCode = itemStandrd.cityCode;
  848. citySchool.cityName = itemStandrd.cityName;
  849. List<string> schoolIds = new List<string>();
  850. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  851. {
  852. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  853. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  854. {
  855. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  856. while (accounts.MoveNext())
  857. {
  858. JsonElement account = accounts.Current;
  859. schoolIds.Add(account.GetProperty("id").GetString());
  860. citySchool.schoolCount += 1;
  861. }
  862. }
  863. }
  864. List<DistrictStics> tempDistrictStics = new List<DistrictStics>();
  865. if (schoolIds.Count > 0)
  866. {
  867. DistrictStics districtStics = new DistrictStics();
  868. districtStics.cityName = itemStandrd.cityName;
  869. districtStics.distName= itemStandrd.distName;
  870. districtStics.schoolCount = schoolIds.Count;
  871. foreach (var itemSchool in schoolIds)
  872. {
  873. //查询学校教师人数
  874. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  875. {
  876. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  877. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  878. {
  879. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  880. while (accounts.MoveNext())
  881. {
  882. JsonElement account = accounts.Current;
  883. districtStics.teacherCount += 1;
  884. }
  885. }
  886. }
  887. //查询学校学生人数
  888. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
  889. {
  890. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  891. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  892. {
  893. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  894. while (accounts.MoveNext())
  895. {
  896. JsonElement account = accounts.Current;
  897. districtStics.studentCount += 1;
  898. }
  899. }
  900. }
  901. }
  902. tempDistrictStics.Add(districtStics);
  903. }
  904. citySchool.districtSticss = tempDistrictStics;
  905. sticsCitys.Add(citySchool);
  906. }
  907. }
  908. return Ok(new { state = 200, sticsCitys });
  909. }
  910. catch (Exception ex)
  911. {
  912. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-cityallstics \n {ex.Message} {ex.StackTrace}", GroupNames.成都开发測試群組);
  913. return BadRequest();
  914. }
  915. }
  916. /// <summary>
  917. /// 查询BI权限开放人数
  918. /// </summary>
  919. /// <returns></returns>
  920. [ProducesDefaultResponseType]
  921. [HttpPost("get-sticsbipower")]
  922. public async Task<IActionResult> GetSticsBIPower()
  923. {
  924. try
  925. {
  926. Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
  927. List<Authority> authorityBIList = await _azureStorage.FindListByDict<Authority>(dic);
  928. var cosmosClient = _azureCosmos.GetCosmosClient();
  929. List<PowerStics> powerStics = new List<PowerStics>();
  930. foreach (var temp in authorityBIList)
  931. {
  932. PowerStics tempPowerStics = new PowerStics();
  933. tempPowerStics.powerName = temp.Discription;
  934. //查询学校权限
  935. string sqlTxt = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.permissions, '{temp.RowKey}', true) AND c.pk = 'Teacher' AND c.status = 'join'";
  936. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
  937. {
  938. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  939. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  940. {
  941. tempPowerStics.powerCount += 1;
  942. }
  943. }
  944. powerStics.Add(tempPowerStics);
  945. }
  946. return Ok(new { state = 200, powerStics });
  947. }
  948. catch (Exception ex)
  949. {
  950. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-sticsbipower {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  951. return BadRequest();
  952. }
  953. }
  954. /// <summary>
  955. /// 统计学校和教师空间类型
  956. /// </summary>
  957. /// <returns></returns>
  958. [HttpPost("get-datatypestics")]
  959. public async Task<IActionResult> GetDataTypeStics()
  960. {
  961. try
  962. {
  963. long totalSize = 0; //总空间
  964. long useSize = 0; //已使用空间
  965. long teach = 0; //学校已经分配给所有教师的空间大小GB。
  966. Dictionary<string, long> typeStics = new Dictionary<string, long>(); //所有类型
  967. Dictionary<string, double?> typeStics1 = new Dictionary<string, double?>(); //所有类型
  968. List<string> schoolId = new List<string>();
  969. var cosmosClient = _azureCosmos.GetCosmosClient();
  970. //查询学校空间和学校Id
  971. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryStreamIterator(queryText:$"select c.id,c.size from c",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
  972. {
  973. var json = await JsonDocument.ParseAsync(item.ContentStream);
  974. foreach (var tempItem in json.RootElement.GetProperty("Documents").EnumerateArray())
  975. {
  976. totalSize += tempItem.GetProperty("size").GetInt64();
  977. schoolId.Add(tempItem.GetProperty("id").GetString());
  978. }
  979. }
  980. //查询学校已使用空间大小
  981. foreach (var itemId in schoolId)
  982. {
  983. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
  984. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
  985. {
  986. var json = await JsonDocument.ParseAsync(item.ContentStream);
  987. foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
  988. {
  989. if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
  990. {
  991. teach += _size.GetInt32();
  992. break;
  993. }
  994. }
  995. }
  996. Dictionary<string, double?> schoolStics = new Dictionary<string, double?>(); //学校空间
  997. long blobsize = 0;
  998. RedisValue value = default;
  999. value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
  1000. if (value != default && !value.IsNullOrEmpty)
  1001. {
  1002. JsonElement record = value.ToString().ToObject<JsonElement>();
  1003. if (record.TryGetInt64(out blobsize))
  1004. {
  1005. }
  1006. }
  1007. else
  1008. {
  1009. var client = _azureStorage.GetBlobContainerClient(itemId);
  1010. var size = await client.GetBlobsCatalogSize();
  1011. await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
  1012. foreach (var key in size.Item2.Keys)
  1013. {
  1014. await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
  1015. await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1016. }
  1017. useSize += (long)size.Item1;
  1018. schoolStics = size.Item2;
  1019. typeStics1 = (from e in typeStics1.Concat(schoolStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
  1020. continue;
  1021. }
  1022. SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
  1023. if (Scores != null)
  1024. {
  1025. foreach (var score in Scores)
  1026. {
  1027. double val = score.Score;
  1028. string key = score.Element.ToString();
  1029. schoolStics.Add(key, val);
  1030. }
  1031. useSize += blobsize;
  1032. typeStics1 = (from e in typeStics1.Concat(schoolStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
  1033. continue;
  1034. //return Ok(new { size = blobsize, catalog = catalog, teach });
  1035. }
  1036. else
  1037. {
  1038. var client = _azureStorage.GetBlobContainerClient(itemId);
  1039. var size = await client.GetBlobsCatalogSize();
  1040. await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
  1041. foreach (var key in size.Item2.Keys)
  1042. {
  1043. await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
  1044. await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1045. }
  1046. useSize += (long)size.Item1;
  1047. schoolStics = size.Item2;
  1048. typeStics1 = (from e in typeStics1.Concat(schoolStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
  1049. continue;
  1050. }
  1051. ////RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
  1052. //if (!value.IsNullOrEmpty)
  1053. //{
  1054. // useSize += Convert.ToInt64(value);
  1055. // //JsonElement record = value.ToString().ToObject<JsonElement>();
  1056. // //long tempSize = 0;
  1057. // //if (record.TryGetInt64(out tempSize))
  1058. // //{
  1059. // // sizeS += tempSize;
  1060. // //}
  1061. //}
  1062. //else
  1063. //{
  1064. // var client = _azureStorage.GetBlobContainerClient(itemId);
  1065. // var size = await client.GetBlobsCatalogSize();
  1066. // var temp = await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
  1067. // foreach (var itemKey in size.Item2.Keys)
  1068. // {
  1069. // var temp1 = await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", itemKey);
  1070. // var temp2 = await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", itemKey, size.Item2[itemKey].HasValue ? size.Item2[itemKey].Value : 0);
  1071. // useSize += Convert.ToInt64(temp2);
  1072. // }
  1073. //}
  1074. //SortedSetEntry[] sortedSetEntries = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemId}");
  1075. //if (sortedSetEntries != null)
  1076. //{
  1077. // foreach (var tempSorted in sortedSetEntries)
  1078. // {
  1079. // if (typeStics.TryGetValue($"{tempSorted.Element}", out long val))
  1080. // typeStics[$"{tempSorted.Element}"] = Convert.ToInt64(tempSorted.Score) != 0 ? val + Convert.ToInt64(tempSorted.Score) : 0;
  1081. // else
  1082. // typeStics.Add($"{tempSorted.Element}", Convert.ToInt64(tempSorted.Score));
  1083. // }
  1084. //}
  1085. }
  1086. ////教师数据
  1087. //List<string> teacherId = new List<string>(); //教师Id集合
  1088. ////查询教师的大小和教师集合信息
  1089. //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  1090. //{
  1091. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  1092. // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  1093. // {
  1094. // totalSize += obj.GetProperty("size").GetInt64();
  1095. // teacherId.Add(obj.GetProperty("id").GetString());
  1096. // }
  1097. //}
  1098. ////查询教师已使用空间大小
  1099. //foreach (var itemTeach in teacherId)
  1100. //{
  1101. // Dictionary<string, double?> teachStics = new Dictionary<string, double?>(); //学校空间
  1102. // long blobsize = 0;
  1103. // RedisValue value = default;
  1104. // value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
  1105. // if (value != default && !value.IsNullOrEmpty)
  1106. // {
  1107. // JsonElement record = value.ToString().ToObject<JsonElement>();
  1108. // if (record.TryGetInt64(out blobsize))
  1109. // {
  1110. // }
  1111. // }
  1112. // else
  1113. // {
  1114. // var client = _azureStorage.GetBlobContainerClient(itemTeach);
  1115. // var size = await client.GetBlobsCatalogSize();
  1116. // await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemTeach, size.Item1);
  1117. // foreach (var key in size.Item2.Keys)
  1118. // {
  1119. // await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemTeach}", key);
  1120. // await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemTeach}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1121. // }
  1122. // useSize += (long)size.Item1;
  1123. // teachStics = size.Item2;
  1124. // typeStics1 = (from e in typeStics1.Concat(teachStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
  1125. // continue;
  1126. // }
  1127. // SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemTeach}");
  1128. // if (Scores != null)
  1129. // {
  1130. // foreach (var score in Scores)
  1131. // {
  1132. // double val = score.Score;
  1133. // string key = score.Element.ToString();
  1134. // teachStics.Add(key, val);
  1135. // }
  1136. // useSize += blobsize;
  1137. // typeStics1 = (from e in typeStics1.Concat(teachStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
  1138. // continue;
  1139. // }
  1140. // else
  1141. // {
  1142. // var client = _azureStorage.GetBlobContainerClient(itemTeach);
  1143. // var size = await client.GetBlobsCatalogSize();
  1144. // await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemTeach, size.Item1);
  1145. // foreach (var key in size.Item2.Keys)
  1146. // {
  1147. // await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemTeach}", key);
  1148. // await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemTeach}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1149. // }
  1150. // useSize += (long)size.Item1;
  1151. // teachStics = size.Item2;
  1152. // typeStics1 = (from e in typeStics1.Concat(teachStics) group e by e.Key into g select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) }).ToDictionary(item => item.Name, item => item.Count);
  1153. // continue;
  1154. // }
  1155. // //RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
  1156. // //if (!tempValue.IsNullOrEmpty)
  1157. // //{
  1158. // // useSize += Convert.ToInt64(tempValue);
  1159. // // //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
  1160. // // //long tempSize = 0;
  1161. // // //if (record.TryGetInt64(out tempSize))
  1162. // // //{
  1163. // // // sizeT += tempSize;
  1164. // // //}
  1165. // //}
  1166. // //SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
  1167. // //if (tempSorted != null)
  1168. // //{
  1169. // // foreach (var itemSorted in tempSorted)
  1170. // // {
  1171. // // if (typeStics.TryGetValue($"{itemSorted.Element}", out long val))
  1172. // // typeStics[$"{itemSorted.Element}"] = Convert.ToInt64(itemSorted.Score) != 0 ? val + Convert.ToInt64(itemSorted.Score) : 0;
  1173. // // else
  1174. // // typeStics.Add($"{itemSorted.Element}", Convert.ToInt64(itemSorted.Score));
  1175. // // }
  1176. // //}
  1177. //}
  1178. return Ok(new { state = 200, totalSize, teach, useSize, stics = typeStics1.ToList() });
  1179. }
  1180. catch (Exception ex)
  1181. {
  1182. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-datatypestics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  1183. return BadRequest();
  1184. }
  1185. }
  1186. /// <summary>
  1187. /// 统计教师的空间类型
  1188. /// </summary>
  1189. /// <returns></returns>
  1190. [HttpPost("get-teachetypestics")]
  1191. public async Task<IActionResult> GetTeachDataTypeStics()
  1192. {
  1193. try
  1194. {
  1195. long teacheSize = 0; //教师空间
  1196. long sizeT = 0; //教师空间
  1197. List<string> teacherId = new List<string>(); //教师Id集合
  1198. Dictionary<string, long> typeStics = new Dictionary<string, long>(); //所有类型
  1199. var cosmosClient = _azureCosmos.GetCosmosClient();
  1200. //查询教师的大小和教师集合信息
  1201. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  1202. {
  1203. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  1204. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  1205. {
  1206. teacheSize += obj.GetProperty("size").GetInt64();
  1207. teacherId.Add(obj.GetProperty("id").GetString());
  1208. }
  1209. }
  1210. //查询教师已使用空间大小
  1211. foreach (var itemTeach in teacherId)
  1212. {
  1213. RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
  1214. if (!tempValue.IsNullOrEmpty)
  1215. {
  1216. sizeT += Convert.ToInt64(tempValue);
  1217. //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
  1218. //long tempSize = 0;
  1219. //if (record.TryGetInt64(out tempSize))
  1220. //{
  1221. // sizeT += tempSize;
  1222. //}
  1223. }
  1224. SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
  1225. if (tempSorted != null)
  1226. {
  1227. foreach (var itemSorted in tempSorted)
  1228. {
  1229. if (typeStics.TryGetValue($"{itemSorted.Element}", out long val))
  1230. typeStics[$"{itemSorted.Element}"] = Convert.ToInt64(itemSorted.Score) != 0 ? val + Convert.ToInt64(itemSorted.Score) : 0;
  1231. else
  1232. typeStics.Add($"{itemSorted.Element}", Convert.ToInt64(itemSorted.Score));
  1233. }
  1234. }
  1235. }
  1236. return Ok(new { state = 200, teacheSize, sizeT, typeStics });
  1237. }
  1238. catch (Exception ex)
  1239. {
  1240. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-datatypestics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  1241. return BadRequest();
  1242. }
  1243. }
  1244. /// <summary>
  1245. /// 存放的类型
  1246. /// </summary>
  1247. public record AllDataType
  1248. {
  1249. public long vote { get; set; }/// 投票josn
  1250. public long thum { get; set; }//视频和封面缩略图
  1251. public long avatar { get; set; }//学生头像
  1252. public long test { get; set; }//
  1253. public long survey { get; set; }//问卷调查 josn
  1254. public long image { get; set; }// PNG
  1255. public long other { get; set; }//其他
  1256. public long doc { get; set; }//文档
  1257. public long homework { get; set; }//作业 json
  1258. public long item { get; set; }// 题库 json
  1259. public long paper { get; set; }//试卷 json
  1260. public long train { get; set; }// 研修
  1261. public long res { get; set; }// 教程 htx
  1262. public long exam { get; set; }//评测 json
  1263. public long syllabus { get; set; }// 课纲 json
  1264. public long video { get; set; }// 视频
  1265. public long yxpt { get; set; }//研修平台
  1266. public long jyzx { get; set; }// 教研中心
  1267. public long records { get; set; } //HiTeach上传的数据
  1268. }
  1269. /// <summary>
  1270. /// 省的数据标准
  1271. /// </summary>
  1272. public record ProvinceStics
  1273. {
  1274. /// <summary>
  1275. /// 省份ID
  1276. /// </summary>
  1277. public string provCode { get; set; }
  1278. /// <summary>
  1279. /// 省份名称
  1280. /// </summary>
  1281. public string provName { get; set; }
  1282. /// <summary>
  1283. /// 省份下的方案数量
  1284. /// </summary>
  1285. public int standardCount { get; set; }
  1286. /// <summary>
  1287. /// 省份下的学校
  1288. /// </summary>
  1289. public int schoolCount { get; set; }
  1290. /// <summary>
  1291. /// 省份下的教师数量
  1292. /// </summary>
  1293. public int teacherCount { get; set; }
  1294. /// <summary>
  1295. /// 省份下的学生数量
  1296. /// </summary>
  1297. public int studentCount { get; set; }
  1298. }
  1299. /// <summary>
  1300. /// 省以下的区域标准
  1301. /// </summary>
  1302. public record ProvinceStandard
  1303. {
  1304. /// <summary>
  1305. /// 城市Code
  1306. /// </summary>
  1307. public string provCode { get; set; }
  1308. /// <summary>
  1309. /// 城市名称
  1310. /// </summary>
  1311. public string provName { get; set; }
  1312. /// <summary>
  1313. /// 区域标准
  1314. /// </summary>
  1315. public string standard { get; set; }
  1316. }
  1317. public record PowerStics
  1318. {
  1319. public string powerName { get; set; }
  1320. public int powerCount { get; set; }
  1321. }
  1322. /// <summary>
  1323. /// 市的学校数据,及以下数据
  1324. /// </summary>
  1325. public record SticsCitys
  1326. {
  1327. /// <summary>
  1328. /// 市级Code
  1329. /// </summary>
  1330. public string cityCode { get; set; }
  1331. /// <summary>
  1332. /// 市级名称
  1333. /// </summary>
  1334. public string cityName { get; set; }
  1335. /// <summary>
  1336. /// 学校数量
  1337. /// </summary>
  1338. public int schoolCount { get; set; }
  1339. /// <summary>
  1340. /// 市级下的区域,学校、
  1341. /// </summary>
  1342. public List<DistrictStics> districtSticss { get; set; }
  1343. }
  1344. /// <summary>
  1345. /// 所有区域标准
  1346. /// </summary>
  1347. public record AllCityStics
  1348. {
  1349. /// <summary>
  1350. /// 城市Code
  1351. /// </summary>
  1352. public string cityCode { get; set; }
  1353. /// <summary>
  1354. /// 城市名称
  1355. /// </summary>
  1356. public string cityName { get; set; }
  1357. /// <summary>
  1358. /// 区名称
  1359. /// </summary>
  1360. public string distName { get; set; }
  1361. /// <summary>
  1362. /// 区域标准
  1363. /// </summary>
  1364. public string standard { get; set; }
  1365. }
  1366. /// <summary>
  1367. /// 统计区域数量
  1368. /// </summary>
  1369. public record DistrictStics
  1370. {
  1371. /// <summary>
  1372. /// 市级名称
  1373. /// </summary>
  1374. public string cityName { get; set; }
  1375. /// <summary>
  1376. /// 地区名称
  1377. /// </summary>
  1378. public string distName { get; set; }
  1379. /// <summary>
  1380. /// 学校数量
  1381. /// </summary>
  1382. public int schoolCount { get; set; }
  1383. /// <summary>
  1384. /// 教师数量
  1385. /// </summary>
  1386. public int teacherCount { get; set; }
  1387. /// <summary>
  1388. /// 学生数量
  1389. /// </summary>
  1390. public int studentCount { get; set; }
  1391. }
  1392. /// <summary>
  1393. /// 区域标准
  1394. /// </summary>
  1395. public record DistrictStandard()
  1396. {
  1397. /// <summary>
  1398. /// 市名称
  1399. /// </summary>
  1400. public string cityName { get; set; }
  1401. /// <summary>
  1402. /// 区域名称
  1403. /// </summary>
  1404. public string distName { get; set; }
  1405. /// <summary>
  1406. /// 区域标准
  1407. /// </summary>
  1408. public string standard { get; set; }
  1409. }
  1410. /// <summary>
  1411. /// 市级学校数量
  1412. /// </summary>
  1413. public record CitySchool
  1414. {
  1415. /// <summary>
  1416. /// 市级ID
  1417. /// </summary>
  1418. public string cityCode { get; set; }
  1419. /// <summary>
  1420. /// 市级名称
  1421. /// </summary>
  1422. public string cityName { get; set; }
  1423. /// <summary>
  1424. /// 市级学校数量
  1425. /// </summary>
  1426. public int schoolCount { get; set;}
  1427. }
  1428. /// <summary>
  1429. /// 市级信息标准
  1430. /// </summary>
  1431. public record CityStandard
  1432. {
  1433. /// <summary>
  1434. /// 城市Code
  1435. /// </summary>
  1436. public string cityCode { get; set; }
  1437. /// <summary>
  1438. /// 城市名称
  1439. /// </summary>
  1440. public string cityName { get; set; }
  1441. /// <summary>
  1442. /// 区域标准
  1443. /// </summary>
  1444. public string standard { get; set; }
  1445. }
  1446. /// <summary>
  1447. /// 区域
  1448. /// </summary>
  1449. public record SticsCity
  1450. {
  1451. /// <summary>
  1452. /// 省份
  1453. /// </summary>
  1454. public string provName { get; set; }
  1455. /// <summary>
  1456. /// 市名称
  1457. /// </summary>
  1458. public string cityName { get; set; }
  1459. /// <summary>
  1460. /// 区域名称
  1461. /// </summary>
  1462. public string distName { get; set; }
  1463. /// <summary>
  1464. /// 区域标准
  1465. /// </summary>
  1466. public string standard { get; set; }
  1467. }
  1468. /// <summary>
  1469. /// 返回统计数据
  1470. /// </summary>
  1471. public record SticsDist
  1472. {
  1473. /// <summary>
  1474. /// 省份
  1475. /// </summary>
  1476. public string provName { get; set; }
  1477. /// <summary>
  1478. /// 市名
  1479. /// </summary>
  1480. public string cityName { get; set; }
  1481. /// <summary>
  1482. /// 区域标准名称
  1483. /// </summary>
  1484. public string distName { get; set; }
  1485. /// <summary>
  1486. /// 区域标准
  1487. /// </summary>
  1488. public string standard { get; set; }
  1489. /// <summary>
  1490. /// 学校数量
  1491. /// </summary>
  1492. public int schoolCount { get; set; }
  1493. /// <summary>
  1494. /// 教师人数
  1495. /// </summary>
  1496. public int teacherCount { get; set; }
  1497. /// <summary>
  1498. /// 学生人数
  1499. /// </summary>
  1500. public int studentCount { get; set; }
  1501. }
  1502. }
  1503. }