HomeStatisController.cs 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  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. //
  265. string sqlTxt = $"select c.id from c where c.standard='{itemStandrds.standard}'";
  266. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlTxt, "Base");
  267. //List<string> schoolIds = new List<string>();
  268. //int schoolCount = 0;
  269. //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") }))
  270. //{
  271. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  272. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  273. // {
  274. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  275. // while (accounts.MoveNext())
  276. // {
  277. // JsonElement account = accounts.Current;
  278. // schoolIds.Add(account.GetProperty("id").GetString());
  279. // schoolCount += 1;
  280. // }
  281. // }
  282. //}
  283. sticsDist.schoolCount = schoolIds.Count;
  284. int teacherCount = 0; //教师数量
  285. int studentCount = 0; //学生数量
  286. List<string> teacherIds = new List<string>();
  287. List<string> studentIds = new List<string>();
  288. //查询学校下面的教师人数
  289. foreach (var itemSchool in schoolIds)
  290. {
  291. //查询全部教师人数
  292. string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  293. teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher","Base");
  294. //string sqlTeacherTxt = $"select distinct value(c) from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  295. //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: sqlTeacherTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  296. //{
  297. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  298. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  299. // {
  300. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  301. // while (accounts.MoveNext())
  302. // {
  303. // //JsonElement account = accounts.Current;
  304. // //teacherIds.Add(account.GetProperty("id").GetString());
  305. // teacherCount += 1;
  306. // }
  307. // }
  308. //}
  309. //查询全部学生人数
  310. string sqlS = $"select count(c.id) as totals from c";
  311. teacherCount += await CommonFind.FindTotals(cosmosClient, sqlS, "Student", $"Base-{itemSchool}");
  312. //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}") }))
  313. //{
  314. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  315. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  316. // {
  317. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  318. // while (accounts.MoveNext())
  319. // {
  320. // //JsonElement account = accounts.Current;
  321. // //studentIds.Add(account.GetProperty("id").GetString());
  322. // studentCount += 1;
  323. // }
  324. // }
  325. //}
  326. }
  327. sticsDist.teacherCount = teacherCount;
  328. sticsDist.studentCount = studentCount;
  329. sticsDists.Add(sticsDist);
  330. }
  331. return Ok(new { state = 200, sticsDists });
  332. }
  333. catch (Exception ex)
  334. {
  335. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-alldiststics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  336. return BadRequest();
  337. }
  338. }
  339. /// <summary>
  340. /// 依据城市Code查询学校,教师数量,学生数量
  341. /// </summary>
  342. /// <param name="jsonElement"></param>
  343. /// <returns></returns>
  344. [ProducesDefaultResponseType]
  345. [HttpPost("get-citystics")]
  346. public async Task<IActionResult> GetCityStics(JsonElement jsonElement)
  347. {
  348. try
  349. {
  350. if(!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
  351. var cosmosClient = _azureCosmos.GetCosmosClient();
  352. List<string> areaStandard = new List<string>();
  353. //查询省份区域
  354. 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") }))
  355. {
  356. areaStandard.Add(item.standard);
  357. }
  358. int citySchoolCount = 0;
  359. int teachCount = 0;
  360. int stuCount = 0;
  361. foreach (var tempSatndard in areaStandard)
  362. {
  363. string sqlSchool = $"select c.id from c where c.standard='{tempSatndard}'";
  364. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSchool, "Base");
  365. citySchoolCount += schoolIds.Count;
  366. //查询学校下面的教师人数
  367. foreach (var itemSchool in schoolIds)
  368. {
  369. //查询全部教师人数
  370. string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  371. teachCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
  372. //查询全部学生人数
  373. string sqlS = $"select count(c.id) as totals from c";
  374. stuCount += await CommonFind.FindTotals(cosmosClient, sqlS, "Student", $"Base-{itemSchool}");
  375. }
  376. }
  377. return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teachCount, tudentCount = stuCount });
  378. //List<string> teacherIds = new List<string>();
  379. //List<string> studentIds = new List<string>();
  380. //foreach (var tempSatndard in areaStandard)
  381. //{
  382. // List<string> schoolIds = new List<string>();
  383. // 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") }))
  384. // {
  385. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  386. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  387. // {
  388. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  389. // while (accounts.MoveNext())
  390. // {
  391. // JsonElement account = accounts.Current;
  392. // schoolIds.Add(account.GetProperty("id").GetString());
  393. // citySchoolCount += 1;
  394. // }
  395. // }
  396. // }
  397. // //查询学校下面的教师人数
  398. // foreach (var itemSchool in schoolIds)
  399. // {
  400. // //查询全部教师人数
  401. // 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") }))
  402. // {
  403. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  404. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  405. // {
  406. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  407. // while (accounts.MoveNext())
  408. // {
  409. // JsonElement account = accounts.Current;
  410. // teacherIds.Add(account.GetProperty("id").GetString());
  411. // }
  412. // }
  413. // }
  414. // //查询全部学生人数
  415. // 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}") }))
  416. // {
  417. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  418. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  419. // {
  420. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  421. // while (accounts.MoveNext())
  422. // {
  423. // JsonElement account = accounts.Current;
  424. // studentIds.Add(account.GetProperty("id").GetString());
  425. // }
  426. // }
  427. // }
  428. // }
  429. //}
  430. //return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teacherIds.Count, tudentCount = studentIds.Count });
  431. }
  432. catch (Exception ex)
  433. {
  434. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-citystics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  435. return BadRequest();
  436. }
  437. }
  438. /// <summary>
  439. /// 统计所有省份下的数据
  440. /// </summary>
  441. /// <returns></returns>
  442. [ProducesDefaultResponseType]
  443. [HttpPost("get-provincestics")]
  444. public async Task<IActionResult> GetProvinceStics()
  445. {
  446. try
  447. {
  448. var cosmosClient = _azureCosmos.GetCosmosClient();
  449. List<ProvinceStandard> standards = new List<ProvinceStandard>();
  450. 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") }))
  451. {
  452. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  453. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  454. {
  455. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  456. while (accounts.MoveNext())
  457. {
  458. JsonElement account = accounts.Current;
  459. ProvinceStandard provinceStandard = new ProvinceStandard
  460. {
  461. provCode = account.GetProperty("provCode").GetString(),
  462. provName = account.GetProperty("provName").GetString(),
  463. standard = account.GetProperty("standard").GetString()
  464. };
  465. standards.Add(provinceStandard);
  466. }
  467. }
  468. }
  469. List<ProvinceStics> provinceStics = new List<ProvinceStics>();
  470. foreach (var itemStandard in standards)
  471. {
  472. ProvinceStics tempProvinceStics = new ProvinceStics();
  473. //ProvinceStics tempCode = new ProvinceStics();
  474. var tempCode = provinceStics.Find(x => x.provCode == itemStandard.provCode);
  475. if (tempCode != null)
  476. {
  477. string sqlSc = $"select c.id from c where c.standard='{itemStandard.standard}'";
  478. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSc, "Base");
  479. tempCode.schoolCount += schoolIds.Count;
  480. //List<string> schoolIds = new List<string>();
  481. //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") }))
  482. //{
  483. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  484. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  485. // {
  486. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  487. // while (accounts.MoveNext())
  488. // {
  489. // JsonElement account = accounts.Current;
  490. // schoolIds.Add(account.GetProperty("id").GetString());
  491. // tempCode.schoolCount += 1;
  492. // }
  493. // }
  494. //}
  495. if (schoolIds.Count > 0)
  496. {
  497. foreach (var itemSchool in schoolIds)
  498. {
  499. //查询学校教师人数
  500. string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  501. tempCode.teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
  502. //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") }))
  503. //{
  504. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  505. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  506. // {
  507. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  508. // while (accounts.MoveNext())
  509. // {
  510. // JsonElement account = accounts.Current;
  511. // tempCode.teacherCount += 1;
  512. // }
  513. // }
  514. //}
  515. //查询学校学生人数
  516. string sqlStu = $"select count(c.id) as totals from c";
  517. tempCode.studentCount += await CommonFind.FindTotals(cosmosClient, sqlStu, "Student", $"Base-{itemSchool}");
  518. //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}") }))
  519. //{
  520. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  521. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  522. // {
  523. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  524. // while (accounts.MoveNext())
  525. // {
  526. // JsonElement account = accounts.Current;
  527. // tempCode.studentCount += 1;
  528. // }
  529. // }
  530. //}
  531. }
  532. }
  533. var tempModel = provinceStics.Where(x => x.provCode == tempCode.provCode).FirstOrDefault();
  534. if (tempModel != null)
  535. {
  536. tempModel.schoolCount = tempCode.schoolCount;
  537. tempModel.teacherCount = tempCode.teacherCount;
  538. tempModel.studentCount = tempCode.studentCount;
  539. tempModel.standardCount +=1;
  540. }
  541. }
  542. else
  543. {
  544. tempProvinceStics.provCode = itemStandard.provCode;
  545. tempProvinceStics.provName = itemStandard.provName;
  546. tempProvinceStics.standardCount += 1;
  547. string sqlSc = $"select c.id from c where c.standard='{itemStandard.standard}'";
  548. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSc, "Base");
  549. tempProvinceStics.schoolCount += schoolIds.Count;
  550. //List<string> schoolIds = new List<string>();
  551. //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") }))
  552. //{
  553. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  554. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  555. // {
  556. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  557. // while (accounts.MoveNext())
  558. // {
  559. // JsonElement account = accounts.Current;
  560. // schoolIds.Add(account.GetProperty("id").GetString());
  561. // tempProvinceStics.schoolCount += 1;
  562. // }
  563. // }
  564. //}
  565. if (schoolIds.Count > 0)
  566. {
  567. foreach (var itemSchool in schoolIds)
  568. {
  569. //查询学校教师人数
  570. string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  571. tempProvinceStics.teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
  572. //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") }))
  573. //{
  574. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  575. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  576. // {
  577. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  578. // while (accounts.MoveNext())
  579. // {
  580. // JsonElement account = accounts.Current;
  581. // tempProvinceStics.teacherCount += 1;
  582. // }
  583. // }
  584. //}
  585. //查询学校学生人数
  586. string sqlStu = "select count(c.id) as totals from c";
  587. tempProvinceStics.studentCount += await CommonFind.FindTotals(cosmosClient, sqlStu, "Student", $"Base-{itemSchool}");
  588. //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}") }))
  589. //{
  590. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  591. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  592. // {
  593. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  594. // while (accounts.MoveNext())
  595. // {
  596. // JsonElement account = accounts.Current;
  597. // tempProvinceStics.studentCount += 1;
  598. // }
  599. // }
  600. //}
  601. }
  602. }
  603. provinceStics.Add(tempProvinceStics);
  604. }
  605. }
  606. return Ok(new { state = 200, provinceStics });
  607. }
  608. catch (Exception ex)
  609. {
  610. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-provincestics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  611. return BadRequest();
  612. }
  613. }
  614. /// <summary>
  615. /// 查询所有市级下的学校数量
  616. /// </summary>
  617. /// <returns></returns>
  618. [ProducesDefaultResponseType]
  619. [HttpPost("get-cityschool")]
  620. public async Task<IActionResult> GetCitySchool()
  621. {
  622. try
  623. {
  624. var cosmosClient = _azureCosmos.GetCosmosClient();
  625. List<CityStandard> standards = new List<CityStandard>();
  626. //查询省份区域
  627. 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") }))
  628. {
  629. CityStandard Citystics = new CityStandard
  630. {
  631. cityCode = item.cityCode,
  632. cityName = item.cityName,
  633. standard = item.standard
  634. };
  635. standards.Add(Citystics);
  636. }
  637. List<CitySchool> citySchools = new List<CitySchool>(); //返回数量
  638. foreach (var itemStandrd in standards)
  639. {
  640. CitySchool citySchool = new CitySchool();
  641. var tempCode = citySchools.Find(x => x.cityCode == itemStandrd.cityCode);
  642. if (tempCode != null)
  643. {
  644. string sqlTxt = $"select count(c.id) totals from c where c.standard='{itemStandrd.standard}'";
  645. tempCode.schoolCount += await CommonFind.FindTotals(cosmosClient, sqlTxt, "School", "Base");
  646. //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") }))
  647. //{
  648. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  649. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  650. // {
  651. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  652. // while (accounts.MoveNext())
  653. // {
  654. // JsonElement account = accounts.Current;
  655. // tempCode.schoolCount += 1;
  656. // }
  657. // }
  658. //}
  659. var tempModel = citySchools.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
  660. if (tempModel != null)
  661. {
  662. tempModel.schoolCount = tempCode.schoolCount;
  663. }
  664. }
  665. else
  666. {
  667. citySchool.cityCode = itemStandrd.cityCode;
  668. citySchool.cityName = itemStandrd.cityName;
  669. string sqlTxt = $"select count(c.id) totals from c where c.standard='{itemStandrd.standard}'";
  670. citySchool.schoolCount += await CommonFind.FindTotals(cosmosClient, sqlTxt, "School", "Base");
  671. //List<string> schoolIds = new List<string>();
  672. //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") }))
  673. //{
  674. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  675. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  676. // {
  677. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  678. // while (accounts.MoveNext())
  679. // {
  680. // JsonElement account = accounts.Current;
  681. // schoolIds.Add(account.GetProperty("id").GetString());
  682. // citySchool.schoolCount += 1;
  683. // }
  684. // }
  685. //}
  686. citySchools.Add(citySchool);
  687. }
  688. }
  689. return Ok(new { state = 200, citySchools });
  690. }
  691. catch (Exception ex)
  692. {
  693. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-cityschool \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  694. return BadRequest();
  695. }
  696. }
  697. /// <summary>
  698. /// 依据市级ID查询区域(区、县、郡)的学校、教师、学生数量
  699. /// </summary>
  700. /// <param name="jsonElement"></param>
  701. /// <returns></returns>
  702. [ProducesDefaultResponseType]
  703. [HttpPost("get-districtstics")]
  704. public async Task<IActionResult> GetDistrictStics(JsonElement jsonElement)
  705. {
  706. try
  707. {
  708. if (!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
  709. var cosmosClient = _azureCosmos.GetCosmosClient();
  710. List<DistrictStandard> districtStandards = new List<DistrictStandard>();
  711. //查询省份区域
  712. 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") }))
  713. {
  714. DistrictStandard districtStandard = new DistrictStandard
  715. {
  716. cityName = item.cityName,
  717. distName = item.name,
  718. standard = item.standard
  719. };
  720. districtStandards.Add(districtStandard);
  721. }
  722. List<DistrictStics> districtSticss = new List<DistrictStics>(); //返回数据
  723. foreach (var itemStandrd in districtStandards)
  724. {
  725. DistrictStics districtStics = new DistrictStics();
  726. districtStics.cityName = itemStandrd.cityName;
  727. districtStics.distName = itemStandrd.distName;
  728. string sqlTxt = $"select c.id from c where c.standard='{itemStandrd.standard}'";
  729. List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient,sqlTxt, "Base");
  730. districtStics.schoolCount += schoolIds.Count;
  731. //List<string> schoolIds = new List<string>();
  732. ////查询区域学校数量
  733. //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") }))
  734. //{
  735. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  736. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  737. // {
  738. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  739. // while (accounts.MoveNext())
  740. // {
  741. // JsonElement account = accounts.Current;
  742. // schoolIds.Add(account.GetProperty("id").GetString());
  743. // districtStics.schoolCount += 1;
  744. // }
  745. // }
  746. //}
  747. if (schoolIds.Count > 0)
  748. {
  749. foreach (var itemSchool in schoolIds)
  750. {
  751. //查询学校教师人数
  752. string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
  753. districtStics.teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
  754. //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") }))
  755. //{
  756. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  757. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  758. // {
  759. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  760. // while (accounts.MoveNext())
  761. // {
  762. // JsonElement account = accounts.Current;
  763. // districtStics.teacherCount += 1;
  764. // }
  765. // }
  766. //}
  767. //查询学校学生人数
  768. string sqlS = $"select count(c.id) as totals from c ";
  769. districtStics.studentCount += await CommonFind.FindTotals(cosmosClient, sqlS, "Student", $"Base-{itemSchool}");
  770. //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}") }))
  771. //{
  772. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  773. // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  774. // {
  775. // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  776. // while (accounts.MoveNext())
  777. // {
  778. // JsonElement account = accounts.Current;
  779. // districtStics.studentCount += 1;
  780. // }
  781. // }
  782. //}
  783. }
  784. }
  785. districtSticss.Add(districtStics);
  786. }
  787. return Ok(new { state = 200, districtSticss });
  788. }
  789. catch (Exception ex)
  790. {
  791. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-districtstics \n {ex.Message} {ex.StackTrace} ", GroupNames.成都开发測試群組);
  792. return BadRequest();
  793. }
  794. }
  795. /// <summary>
  796. /// 查询市的学校数据,以及市级下的区中的学校,教师、学生数量
  797. /// </summary>
  798. /// <param name="jsonElement"></param>
  799. /// <returns></returns>
  800. [ProducesDefaultResponseType]
  801. [HttpPost("get-cityallstics")]
  802. public async Task<IActionResult> GetCityAllStics(JsonElement jsonElement)
  803. {
  804. try
  805. {
  806. var cosmosClient = _azureCosmos.GetCosmosClient();
  807. List<AllCityStics> tempAllCityStics = new List<AllCityStics>();
  808. //查询省份区域
  809. 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") }))
  810. {
  811. AllCityStics Citystics = new AllCityStics
  812. {
  813. cityCode = item.cityCode,
  814. cityName = item.cityName,
  815. distName = item.name,
  816. standard = item.standard
  817. };
  818. tempAllCityStics.Add(Citystics);
  819. }
  820. List<SticsCitys> sticsCitys = new List<SticsCitys>();
  821. foreach(var itemStandrd in tempAllCityStics)
  822. {
  823. SticsCitys citySchool = new SticsCitys();
  824. var tempCode = sticsCitys.Find(x => (x.cityCode) == (itemStandrd.cityCode));
  825. if (tempCode != null)
  826. {
  827. List<string> schoolIds = new List<string>();
  828. 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") }))
  829. {
  830. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  831. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  832. {
  833. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  834. while (accounts.MoveNext())
  835. {
  836. JsonElement account = accounts.Current;
  837. schoolIds.Add(account.GetProperty("id").GetString());
  838. tempCode.schoolCount += 1;
  839. }
  840. }
  841. }
  842. var tempModel = sticsCitys.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
  843. if (tempModel != null)
  844. {
  845. tempModel.schoolCount = tempCode.schoolCount;
  846. }
  847. DistrictStics districtStics = new DistrictStics();
  848. districtStics.cityName = itemStandrd.cityName;
  849. districtStics.distName = itemStandrd.distName;
  850. districtStics.schoolCount = schoolIds.Count;
  851. if (schoolIds.Count > 0)
  852. {
  853. foreach (var itemSchool in schoolIds)
  854. {
  855. //查询学校教师人数
  856. 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") }))
  857. {
  858. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  859. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  860. {
  861. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  862. while (accounts.MoveNext())
  863. {
  864. JsonElement account = accounts.Current;
  865. districtStics.teacherCount += 1;
  866. }
  867. }
  868. }
  869. //查询学校学生人数
  870. 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}") }))
  871. {
  872. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  873. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  874. {
  875. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  876. while (accounts.MoveNext())
  877. {
  878. JsonElement account = accounts.Current;
  879. districtStics.studentCount += 1;
  880. }
  881. }
  882. }
  883. }
  884. }
  885. var tempDistrict = sticsCitys.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
  886. if (tempDistrict != null)
  887. {
  888. tempDistrict.districtSticss.Add(districtStics);
  889. }
  890. }
  891. else
  892. {
  893. citySchool.cityCode = itemStandrd.cityCode;
  894. citySchool.cityName = itemStandrd.cityName;
  895. List<string> schoolIds = new List<string>();
  896. 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") }))
  897. {
  898. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  899. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  900. {
  901. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  902. while (accounts.MoveNext())
  903. {
  904. JsonElement account = accounts.Current;
  905. schoolIds.Add(account.GetProperty("id").GetString());
  906. citySchool.schoolCount += 1;
  907. }
  908. }
  909. }
  910. List<DistrictStics> tempDistrictStics = new List<DistrictStics>();
  911. if (schoolIds.Count > 0)
  912. {
  913. DistrictStics districtStics = new DistrictStics();
  914. districtStics.cityName = itemStandrd.cityName;
  915. districtStics.distName= itemStandrd.distName;
  916. districtStics.schoolCount = schoolIds.Count;
  917. foreach (var itemSchool in schoolIds)
  918. {
  919. //查询学校教师人数
  920. 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") }))
  921. {
  922. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  923. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  924. {
  925. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  926. while (accounts.MoveNext())
  927. {
  928. JsonElement account = accounts.Current;
  929. districtStics.teacherCount += 1;
  930. }
  931. }
  932. }
  933. //查询学校学生人数
  934. 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}") }))
  935. {
  936. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  937. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  938. {
  939. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  940. while (accounts.MoveNext())
  941. {
  942. JsonElement account = accounts.Current;
  943. districtStics.studentCount += 1;
  944. }
  945. }
  946. }
  947. }
  948. tempDistrictStics.Add(districtStics);
  949. }
  950. citySchool.districtSticss = tempDistrictStics;
  951. sticsCitys.Add(citySchool);
  952. }
  953. }
  954. return Ok(new { state = 200, sticsCitys });
  955. }
  956. catch (Exception ex)
  957. {
  958. await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-cityallstics \n {ex.Message} {ex.StackTrace}", GroupNames.成都开发測試群組);
  959. return BadRequest();
  960. }
  961. }
  962. /// <summary>
  963. /// 查询BI权限开放人数
  964. /// </summary>
  965. /// <returns></returns>
  966. [ProducesDefaultResponseType]
  967. [HttpPost("get-sticsbipower")]
  968. public async Task<IActionResult> GetSticsBIPower()
  969. {
  970. try
  971. {
  972. Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
  973. List<Authority> authorityBIList = await _azureStorage.FindListByDict<Authority>(dic);
  974. var cosmosClient = _azureCosmos.GetCosmosClient();
  975. List<PowerStics> powerStics = new List<PowerStics>();
  976. foreach (var temp in authorityBIList)
  977. {
  978. PowerStics tempPowerStics = new PowerStics();
  979. tempPowerStics.powerName = temp.Discription;
  980. //查询学校权限
  981. 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'";
  982. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
  983. {
  984. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  985. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  986. {
  987. tempPowerStics.powerCount += 1;
  988. }
  989. }
  990. powerStics.Add(tempPowerStics);
  991. }
  992. return Ok(new { state = 200, powerStics });
  993. }
  994. catch (Exception ex)
  995. {
  996. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-sticsbipower {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  997. return BadRequest();
  998. }
  999. }
  1000. /// <summary>
  1001. /// 统计学校和教师空间类型
  1002. /// </summary>
  1003. /// <returns></returns>
  1004. [HttpPost("get-datatypestics")]
  1005. public async Task<IActionResult> GetDataTypeStics()
  1006. {
  1007. try
  1008. {
  1009. long totalSize = 0; //总空间
  1010. long useSize = 0; //已使用空间
  1011. long teach = 0; //学校已经分配给所有教师的空间大小GB。
  1012. Dictionary<string, long> typeStics = new Dictionary<string, long>(); //所有类型
  1013. Dictionary<string, double?> typeStics1 = new Dictionary<string, double?>(); //所有类型
  1014. List<string> schoolId = new List<string>();
  1015. var cosmosClient = _azureCosmos.GetCosmosClient();
  1016. //查询学校空间和学校Id
  1017. 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")}))
  1018. {
  1019. var json = await JsonDocument.ParseAsync(item.ContentStream);
  1020. foreach (var tempItem in json.RootElement.GetProperty("Documents").EnumerateArray())
  1021. {
  1022. totalSize += tempItem.GetProperty("size").GetInt64();
  1023. schoolId.Add(tempItem.GetProperty("id").GetString());
  1024. }
  1025. }
  1026. //查询学校已使用空间大小
  1027. foreach (var itemId in schoolId)
  1028. {
  1029. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
  1030. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
  1031. {
  1032. var json = await JsonDocument.ParseAsync(item.ContentStream);
  1033. foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
  1034. {
  1035. if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
  1036. {
  1037. teach += _size.GetInt32();
  1038. break;
  1039. }
  1040. }
  1041. }
  1042. Dictionary<string, double?> schoolStics = new Dictionary<string, double?>(); //学校空间
  1043. long blobsize = 0;
  1044. RedisValue value = default;
  1045. value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
  1046. if (value != default && !value.IsNullOrEmpty)
  1047. {
  1048. JsonElement record = value.ToString().ToObject<JsonElement>();
  1049. if (record.TryGetInt64(out blobsize))
  1050. {
  1051. }
  1052. }
  1053. else
  1054. {
  1055. var client = _azureStorage.GetBlobContainerClient(itemId);
  1056. var size = await client.GetBlobsCatalogSize();
  1057. await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
  1058. foreach (var key in size.Item2.Keys)
  1059. {
  1060. await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
  1061. await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1062. }
  1063. useSize += (long)size.Item1;
  1064. schoolStics = size.Item2;
  1065. 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);
  1066. continue;
  1067. }
  1068. SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
  1069. if (Scores != null)
  1070. {
  1071. foreach (var score in Scores)
  1072. {
  1073. double val = score.Score;
  1074. string key = score.Element.ToString();
  1075. schoolStics.Add(key, val);
  1076. }
  1077. useSize += blobsize;
  1078. 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);
  1079. continue;
  1080. //return Ok(new { size = blobsize, catalog = catalog, teach });
  1081. }
  1082. else
  1083. {
  1084. var client = _azureStorage.GetBlobContainerClient(itemId);
  1085. var size = await client.GetBlobsCatalogSize();
  1086. await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
  1087. foreach (var key in size.Item2.Keys)
  1088. {
  1089. await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
  1090. await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1091. }
  1092. useSize += (long)size.Item1;
  1093. schoolStics = size.Item2;
  1094. 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);
  1095. continue;
  1096. }
  1097. ////RedisValue value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
  1098. //if (!value.IsNullOrEmpty)
  1099. //{
  1100. // useSize += Convert.ToInt64(value);
  1101. // //JsonElement record = value.ToString().ToObject<JsonElement>();
  1102. // //long tempSize = 0;
  1103. // //if (record.TryGetInt64(out tempSize))
  1104. // //{
  1105. // // sizeS += tempSize;
  1106. // //}
  1107. //}
  1108. //else
  1109. //{
  1110. // var client = _azureStorage.GetBlobContainerClient(itemId);
  1111. // var size = await client.GetBlobsCatalogSize();
  1112. // var temp = await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
  1113. // foreach (var itemKey in size.Item2.Keys)
  1114. // {
  1115. // var temp1 = await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", itemKey);
  1116. // var temp2 = await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", itemKey, size.Item2[itemKey].HasValue ? size.Item2[itemKey].Value : 0);
  1117. // useSize += Convert.ToInt64(temp2);
  1118. // }
  1119. //}
  1120. //SortedSetEntry[] sortedSetEntries = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemId}");
  1121. //if (sortedSetEntries != null)
  1122. //{
  1123. // foreach (var tempSorted in sortedSetEntries)
  1124. // {
  1125. // if (typeStics.TryGetValue($"{tempSorted.Element}", out long val))
  1126. // typeStics[$"{tempSorted.Element}"] = Convert.ToInt64(tempSorted.Score) != 0 ? val + Convert.ToInt64(tempSorted.Score) : 0;
  1127. // else
  1128. // typeStics.Add($"{tempSorted.Element}", Convert.ToInt64(tempSorted.Score));
  1129. // }
  1130. //}
  1131. }
  1132. ////教师数据
  1133. //List<string> teacherId = new List<string>(); //教师Id集合
  1134. ////查询教师的大小和教师集合信息
  1135. //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") }))
  1136. //{
  1137. // using var json = await JsonDocument.ParseAsync(item.ContentStream);
  1138. // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  1139. // {
  1140. // totalSize += obj.GetProperty("size").GetInt64();
  1141. // teacherId.Add(obj.GetProperty("id").GetString());
  1142. // }
  1143. //}
  1144. ////查询教师已使用空间大小
  1145. //foreach (var itemTeach in teacherId)
  1146. //{
  1147. // Dictionary<string, double?> teachStics = new Dictionary<string, double?>(); //学校空间
  1148. // long blobsize = 0;
  1149. // RedisValue value = default;
  1150. // value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
  1151. // if (value != default && !value.IsNullOrEmpty)
  1152. // {
  1153. // JsonElement record = value.ToString().ToObject<JsonElement>();
  1154. // if (record.TryGetInt64(out blobsize))
  1155. // {
  1156. // }
  1157. // }
  1158. // else
  1159. // {
  1160. // var client = _azureStorage.GetBlobContainerClient(itemTeach);
  1161. // var size = await client.GetBlobsCatalogSize();
  1162. // await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemTeach, size.Item1);
  1163. // foreach (var key in size.Item2.Keys)
  1164. // {
  1165. // await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemTeach}", key);
  1166. // await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemTeach}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1167. // }
  1168. // useSize += (long)size.Item1;
  1169. // teachStics = size.Item2;
  1170. // 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);
  1171. // continue;
  1172. // }
  1173. // SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemTeach}");
  1174. // if (Scores != null)
  1175. // {
  1176. // foreach (var score in Scores)
  1177. // {
  1178. // double val = score.Score;
  1179. // string key = score.Element.ToString();
  1180. // teachStics.Add(key, val);
  1181. // }
  1182. // useSize += blobsize;
  1183. // 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);
  1184. // continue;
  1185. // }
  1186. // else
  1187. // {
  1188. // var client = _azureStorage.GetBlobContainerClient(itemTeach);
  1189. // var size = await client.GetBlobsCatalogSize();
  1190. // await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemTeach, size.Item1);
  1191. // foreach (var key in size.Item2.Keys)
  1192. // {
  1193. // await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemTeach}", key);
  1194. // await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemTeach}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
  1195. // }
  1196. // useSize += (long)size.Item1;
  1197. // teachStics = size.Item2;
  1198. // 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);
  1199. // continue;
  1200. // }
  1201. // //RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
  1202. // //if (!tempValue.IsNullOrEmpty)
  1203. // //{
  1204. // // useSize += Convert.ToInt64(tempValue);
  1205. // // //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
  1206. // // //long tempSize = 0;
  1207. // // //if (record.TryGetInt64(out tempSize))
  1208. // // //{
  1209. // // // sizeT += tempSize;
  1210. // // //}
  1211. // //}
  1212. // //SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
  1213. // //if (tempSorted != null)
  1214. // //{
  1215. // // foreach (var itemSorted in tempSorted)
  1216. // // {
  1217. // // if (typeStics.TryGetValue($"{itemSorted.Element}", out long val))
  1218. // // typeStics[$"{itemSorted.Element}"] = Convert.ToInt64(itemSorted.Score) != 0 ? val + Convert.ToInt64(itemSorted.Score) : 0;
  1219. // // else
  1220. // // typeStics.Add($"{itemSorted.Element}", Convert.ToInt64(itemSorted.Score));
  1221. // // }
  1222. // //}
  1223. //}
  1224. return Ok(new { state = 200, totalSize, teach, useSize, stics = typeStics1.ToList() });
  1225. }
  1226. catch (Exception ex)
  1227. {
  1228. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-datatypestics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  1229. return BadRequest();
  1230. }
  1231. }
  1232. /// <summary>
  1233. /// 统计教师的空间类型
  1234. /// </summary>
  1235. /// <returns></returns>
  1236. [HttpPost("get-teachetypestics")]
  1237. public async Task<IActionResult> GetTeachDataTypeStics()
  1238. {
  1239. try
  1240. {
  1241. long teacheSize = 0; //教师空间
  1242. long sizeT = 0; //教师空间
  1243. List<string> teacherId = new List<string>(); //教师Id集合
  1244. Dictionary<string, long> typeStics = new Dictionary<string, long>(); //所有类型
  1245. var cosmosClient = _azureCosmos.GetCosmosClient();
  1246. //查询教师的大小和教师集合信息
  1247. 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") }))
  1248. {
  1249. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  1250. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  1251. {
  1252. teacheSize += obj.GetProperty("size").GetInt64();
  1253. teacherId.Add(obj.GetProperty("id").GetString());
  1254. }
  1255. }
  1256. //查询教师已使用空间大小
  1257. foreach (var itemTeach in teacherId)
  1258. {
  1259. RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
  1260. if (!tempValue.IsNullOrEmpty)
  1261. {
  1262. sizeT += Convert.ToInt64(tempValue);
  1263. //JsonElement record = tempValue.ToString().ToObject<JsonElement>();
  1264. //long tempSize = 0;
  1265. //if (record.TryGetInt64(out tempSize))
  1266. //{
  1267. // sizeT += tempSize;
  1268. //}
  1269. }
  1270. SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
  1271. if (tempSorted != null)
  1272. {
  1273. foreach (var itemSorted in tempSorted)
  1274. {
  1275. if (typeStics.TryGetValue($"{itemSorted.Element}", out long val))
  1276. typeStics[$"{itemSorted.Element}"] = Convert.ToInt64(itemSorted.Score) != 0 ? val + Convert.ToInt64(itemSorted.Score) : 0;
  1277. else
  1278. typeStics.Add($"{itemSorted.Element}", Convert.ToInt64(itemSorted.Score));
  1279. }
  1280. }
  1281. }
  1282. return Ok(new { state = 200, teacheSize, sizeT, typeStics });
  1283. }
  1284. catch (Exception ex)
  1285. {
  1286. await _dingDing.SendBotMsg($"BI,{_option.Location} /homestatis/get-datatypestics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
  1287. return BadRequest();
  1288. }
  1289. }
  1290. /// <summary>
  1291. /// 存放的类型
  1292. /// </summary>
  1293. public record AllDataType
  1294. {
  1295. public long vote { get; set; }/// 投票josn
  1296. public long thum { get; set; }//视频和封面缩略图
  1297. public long avatar { get; set; }//学生头像
  1298. public long test { get; set; }//
  1299. public long survey { get; set; }//问卷调查 josn
  1300. public long image { get; set; }// PNG
  1301. public long other { get; set; }//其他
  1302. public long doc { get; set; }//文档
  1303. public long homework { get; set; }//作业 json
  1304. public long item { get; set; }// 题库 json
  1305. public long paper { get; set; }//试卷 json
  1306. public long train { get; set; }// 研修
  1307. public long res { get; set; }// 教程 htx
  1308. public long exam { get; set; }//评测 json
  1309. public long syllabus { get; set; }// 课纲 json
  1310. public long video { get; set; }// 视频
  1311. public long yxpt { get; set; }//研修平台
  1312. public long jyzx { get; set; }// 教研中心
  1313. public long records { get; set; } //HiTeach上传的数据
  1314. }
  1315. /// <summary>
  1316. /// 省的数据标准
  1317. /// </summary>
  1318. public record ProvinceStics
  1319. {
  1320. /// <summary>
  1321. /// 省份ID
  1322. /// </summary>
  1323. public string provCode { get; set; }
  1324. /// <summary>
  1325. /// 省份名称
  1326. /// </summary>
  1327. public string provName { get; set; }
  1328. /// <summary>
  1329. /// 省份下的方案数量
  1330. /// </summary>
  1331. public int standardCount { get; set; }
  1332. /// <summary>
  1333. /// 省份下的学校
  1334. /// </summary>
  1335. public int schoolCount { get; set; }
  1336. /// <summary>
  1337. /// 省份下的教师数量
  1338. /// </summary>
  1339. public int teacherCount { get; set; }
  1340. /// <summary>
  1341. /// 省份下的学生数量
  1342. /// </summary>
  1343. public int studentCount { get; set; }
  1344. }
  1345. /// <summary>
  1346. /// 省以下的区域标准
  1347. /// </summary>
  1348. public record ProvinceStandard
  1349. {
  1350. /// <summary>
  1351. /// 城市Code
  1352. /// </summary>
  1353. public string provCode { get; set; }
  1354. /// <summary>
  1355. /// 城市名称
  1356. /// </summary>
  1357. public string provName { get; set; }
  1358. /// <summary>
  1359. /// 区域标准
  1360. /// </summary>
  1361. public string standard { get; set; }
  1362. }
  1363. public record PowerStics
  1364. {
  1365. public string powerName { get; set; }
  1366. public int powerCount { get; set; }
  1367. }
  1368. /// <summary>
  1369. /// 市的学校数据,及以下数据
  1370. /// </summary>
  1371. public record SticsCitys
  1372. {
  1373. /// <summary>
  1374. /// 市级Code
  1375. /// </summary>
  1376. public string cityCode { get; set; }
  1377. /// <summary>
  1378. /// 市级名称
  1379. /// </summary>
  1380. public string cityName { get; set; }
  1381. /// <summary>
  1382. /// 学校数量
  1383. /// </summary>
  1384. public int schoolCount { get; set; }
  1385. /// <summary>
  1386. /// 市级下的区域,学校、
  1387. /// </summary>
  1388. public List<DistrictStics> districtSticss { get; set; }
  1389. }
  1390. /// <summary>
  1391. /// 所有区域标准
  1392. /// </summary>
  1393. public record AllCityStics
  1394. {
  1395. /// <summary>
  1396. /// 城市Code
  1397. /// </summary>
  1398. public string cityCode { get; set; }
  1399. /// <summary>
  1400. /// 城市名称
  1401. /// </summary>
  1402. public string cityName { get; set; }
  1403. /// <summary>
  1404. /// 区名称
  1405. /// </summary>
  1406. public string distName { get; set; }
  1407. /// <summary>
  1408. /// 区域标准
  1409. /// </summary>
  1410. public string standard { get; set; }
  1411. }
  1412. /// <summary>
  1413. /// 统计区域数量
  1414. /// </summary>
  1415. public record DistrictStics
  1416. {
  1417. /// <summary>
  1418. /// 市级名称
  1419. /// </summary>
  1420. public string cityName { get; set; }
  1421. /// <summary>
  1422. /// 地区名称
  1423. /// </summary>
  1424. public string distName { get; set; }
  1425. /// <summary>
  1426. /// 学校数量
  1427. /// </summary>
  1428. public int schoolCount { get; set; }
  1429. /// <summary>
  1430. /// 教师数量
  1431. /// </summary>
  1432. public int teacherCount { get; set; }
  1433. /// <summary>
  1434. /// 学生数量
  1435. /// </summary>
  1436. public int studentCount { get; set; }
  1437. }
  1438. /// <summary>
  1439. /// 区域标准
  1440. /// </summary>
  1441. public record DistrictStandard()
  1442. {
  1443. /// <summary>
  1444. /// 市名称
  1445. /// </summary>
  1446. public string cityName { get; set; }
  1447. /// <summary>
  1448. /// 区域名称
  1449. /// </summary>
  1450. public string distName { get; set; }
  1451. /// <summary>
  1452. /// 区域标准
  1453. /// </summary>
  1454. public string standard { get; set; }
  1455. }
  1456. /// <summary>
  1457. /// 市级学校数量
  1458. /// </summary>
  1459. public record CitySchool
  1460. {
  1461. /// <summary>
  1462. /// 市级ID
  1463. /// </summary>
  1464. public string cityCode { get; set; }
  1465. /// <summary>
  1466. /// 市级名称
  1467. /// </summary>
  1468. public string cityName { get; set; }
  1469. /// <summary>
  1470. /// 市级学校数量
  1471. /// </summary>
  1472. public int schoolCount { get; set;}
  1473. }
  1474. /// <summary>
  1475. /// 市级信息标准
  1476. /// </summary>
  1477. public record CityStandard
  1478. {
  1479. /// <summary>
  1480. /// 城市Code
  1481. /// </summary>
  1482. public string cityCode { get; set; }
  1483. /// <summary>
  1484. /// 城市名称
  1485. /// </summary>
  1486. public string cityName { get; set; }
  1487. /// <summary>
  1488. /// 区域标准
  1489. /// </summary>
  1490. public string standard { get; set; }
  1491. }
  1492. /// <summary>
  1493. /// 区域
  1494. /// </summary>
  1495. public record SticsCity
  1496. {
  1497. /// <summary>
  1498. /// 省份
  1499. /// </summary>
  1500. public string provName { get; set; }
  1501. /// <summary>
  1502. /// 市名称
  1503. /// </summary>
  1504. public string cityName { get; set; }
  1505. /// <summary>
  1506. /// 区域名称
  1507. /// </summary>
  1508. public string distName { get; set; }
  1509. /// <summary>
  1510. /// 区域标准
  1511. /// </summary>
  1512. public string standard { get; set; }
  1513. }
  1514. /// <summary>
  1515. /// 返回统计数据
  1516. /// </summary>
  1517. public record SticsDist
  1518. {
  1519. /// <summary>
  1520. /// 省份
  1521. /// </summary>
  1522. public string provName { get; set; }
  1523. /// <summary>
  1524. /// 市名
  1525. /// </summary>
  1526. public string cityName { get; set; }
  1527. /// <summary>
  1528. /// 区域标准名称
  1529. /// </summary>
  1530. public string distName { get; set; }
  1531. /// <summary>
  1532. /// 区域标准
  1533. /// </summary>
  1534. public string standard { get; set; }
  1535. /// <summary>
  1536. /// 学校数量
  1537. /// </summary>
  1538. public int schoolCount { get; set; }
  1539. /// <summary>
  1540. /// 教师人数
  1541. /// </summary>
  1542. public int teacherCount { get; set; }
  1543. /// <summary>
  1544. /// 学生人数
  1545. /// </summary>
  1546. public int studentCount { get; set; }
  1547. }
  1548. }
  1549. }