OnLineController.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. using Azure.Cosmos;
  2. using Azure.Storage.Blobs;
  3. using Azure.Storage.Blobs.Models;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.AspNetCore.Mvc;
  6. using StackExchange.Redis;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data.SqlTypes;
  10. using System.IO;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Text.Json;
  14. using System.Threading.Tasks;
  15. using TEAMModelBI.Tool;
  16. using TEAMModelOS.SDK.Context.BI;
  17. using TEAMModelOS.SDK.Context.Constant;
  18. using TEAMModelOS.SDK.DI;
  19. using TEAMModelOS.SDK.Extension;
  20. using TEAMModelOS.SDK.Models;
  21. using TEAMModelOS.SDK.Models.Cosmos.BI;
  22. using TEAMModelOS.SDK.Models.Service.BI;
  23. using TEAMModelOS.SDK.Models.Table;
  24. namespace TEAMModelBI.Controllers.BIHome
  25. {
  26. [Route("online")]
  27. [ApiController]
  28. public class OnLineController : ControllerBase
  29. {
  30. private readonly AzureCosmosFactory _azureCosmos;
  31. private readonly AzureStorageFactory _azureStorage;
  32. private readonly AzureRedisFactory _azureRedis;
  33. public OnLineController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis)
  34. {
  35. _azureCosmos = azureCosmos;
  36. _azureStorage = azureStorage;
  37. _azureRedis = azureRedis;
  38. }
  39. /// <summary>
  40. /// 总数统计 //已对接
  41. /// </summary>
  42. /// <returns></returns>
  43. [ProducesDefaultResponseType]
  44. [HttpPost("get-count")]
  45. public async Task<IActionResult> GetCount(JsonElement jsonElement)
  46. {
  47. var cosmosClient = _azureCosmos.GetCosmosClient();
  48. var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
  49. var blobClient = _azureStorage.GetBlobContainerClient($"0-public");
  50. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  51. //if ($"{site}".Equals(BIConst.Global))
  52. //{
  53. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  54. // table = _azureStorage.GetCloudTableClient(BIConst.Global).GetTableReference("IESLogin");
  55. // blobClient = _azureStorage.GetBlobContainerClient($"0-public", BIConst.Global);
  56. //}
  57. DateTimeOffset dateTime = DateTimeOffset.UtcNow;
  58. string cDay = dateTime.ToString("yyyyMMdd");
  59. var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
  60. var (daySf, dayEf) = TimeHelper.GetStartOrEnd(dateTime, dateLenth: false); //今天开始时间 10位
  61. var (lastDayS, lastdayE) = TimeHelper.GetStartOrEnd(dateTime.AddDays(-1)); //昨天开始时间
  62. var near7S = dateTime.AddDays(-7).ToUnixTimeMilliseconds(); //前七天的开始时间
  63. var near7E = dateTime.ToUnixTimeMilliseconds(); //当前结束时间
  64. long hour1 = dateTime.AddHours(-1).ToUnixTimeMilliseconds(); //一小时前时间戳
  65. int areaCnt = 0; //学区总数
  66. int scCnt = 0; //学校总数
  67. int tchCnt = 0; //教师总数
  68. int stuCnt = 0; //学生总数
  69. int apiCnt = 0; //当天接口访问总量
  70. int onStuCnt = 0; //学生在线人数
  71. int onTchCnt = 0; //教师在线人数
  72. int todayScCnt = 0; //今日新增学校数
  73. int todayTchCnt = 0; //今日新增教师
  74. int todayStuCnt = 0; //今日新增学生数
  75. long datetime = dateTime.ToUnixTimeMilliseconds();
  76. string currentSql = "select value(count(c.id)) from c";
  77. areaCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Normal", currentSql, "Base-Area");
  78. scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", currentSql, "Base");
  79. tchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", currentSql, "Base");
  80. stuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", "select value(count(c.id)) from c where c.pk='Base'");
  81. string addSql = $"select value(count(c.id)) from c where c.createTime >={daySt} and c.createTime <= {dayEt}";
  82. todayScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", addSql, "Base");
  83. todayTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", addSql, "Base");
  84. todayStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", addSql, "Base");
  85. string onStuSql = $"select value(count(c.id)) from c join t in c.loginInfos where array_length(c.loginInfos) > 0 and t.expire > {hour1} and c.pk='Base'";
  86. onTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", onStuSql);
  87. onStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", onStuSql);
  88. //接口访问量
  89. List<RecCnt> recCnts = new();
  90. await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"visitCnt/{cDay}"))
  91. {
  92. if (blobItem.Name.EndsWith(".json") && !blobItem.Name.EndsWith("/days.json"))
  93. {
  94. BlobClient tempBlobClient = blobClient.GetBlobClient(blobItem.Name);
  95. if (await tempBlobClient.ExistsAsync())
  96. {
  97. using (var meomoryStream = new MemoryStream())
  98. {
  99. var response = blobClient.GetBlobClient($"{blobItem.Name}").DownloadTo(meomoryStream);
  100. RecCnt recCnt = Encoding.UTF8.GetString(meomoryStream.ToArray()).ToString().ToObject<RecCnt>();
  101. recCnts.Add(recCnt);
  102. }
  103. }
  104. }
  105. }
  106. apiCnt = recCnts.Select(x => x.apiCnt.Select(s => s.count).Sum()).Sum();
  107. string yymmss = TimeHelper.GetDateTime(datetime).ToString();
  108. return Ok(new { state = 200, yymmss, datetime, areaCnt, scCnt, tchCnt, stuCnt, todayScCnt, todayTchCnt, todayStuCnt, onStuCnt, onTchCnt, apiCnt });
  109. }
  110. /// <summary>
  111. /// 在线人数趋势图 //已对接
  112. /// </summary>
  113. /// <returns></returns>
  114. [ProducesDefaultResponseType]
  115. [HttpPost("get-trend")]
  116. public async Task<IActionResult> GetTrend(JsonElement jsonElement)
  117. {
  118. var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
  119. var redisClinet = _azureRedis.GetRedisClient(8);
  120. //jsonElement.TryGetProperty("site", out JsonElement site); //分开部署,就不需要,一站多用时,取消注释
  121. //if ($"{site}".Equals(BIConst.Global))
  122. //{
  123. // table = _azureStorage.GetCloudTableClient(BIConst.Global).GetTableReference("IESLogin");
  124. // redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.Global);
  125. //}
  126. DateTimeOffset dateTime = DateTimeOffset.UtcNow;
  127. var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
  128. var (strDaySt, strDayEt) = TimeHelper.GetUnixToDate(daySt, dayEt, "yyyyMMddHH");
  129. var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
  130. //daySt.ToString("yyyyMMddHH");
  131. Dictionary<long, int> allDays = new(); //所有在线人数
  132. Dictionary<long, int> tchDays = new(); //教师在线人数
  133. Dictionary<long, int> stuDays = new(); //学生在线人数
  134. Dictionary<long, int> tmdDays = new(); //醍摩豆账户学生
  135. SortedSetEntry[] tchDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
  136. if (tchDay.Length > 0)
  137. {
  138. foreach (var item in tchDay)
  139. {
  140. int val = ((int)item.Score);
  141. int key = ((int)item.Element);
  142. //var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, key, 0, 0)).Hour;
  143. //var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {key}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
  144. tchDays.Add(key, val);
  145. if (allDays.ContainsKey(key))
  146. allDays[key] = (allDays[key] + val);
  147. else
  148. allDays.Add(key, val);
  149. }
  150. }
  151. else
  152. {
  153. string tableSqlTch = $"PartitionKey eq 'HourLogin' and RowKey ge '{strDaySt}' and RowKey le '{strDayEt}'";
  154. List<HourLogin> hourLoginsTch = await table.QueryWhereString<HourLogin>(tableSqlTch);
  155. if (hourLoginsTch.Count > 0)
  156. {
  157. foreach (var item in hourLoginsTch)
  158. {
  159. await redisClinet.SortedSetIncrementAsync($"Login:IES:teacher:{dateDay}", $"{item.Hour}", item.Teacher);//存一天24小时
  160. tchDays.Add(item.Hour, item.Teacher);
  161. if (allDays.ContainsKey(item.Hour))
  162. allDays[item.Hour] = (allDays[item.Hour] + item.Teacher);
  163. else
  164. allDays.Add(item.Hour, item.Teacher);
  165. }
  166. }
  167. }
  168. SortedSetEntry[] stuDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:student:{dateDay}");
  169. if (stuDay.Length > 0)
  170. {
  171. foreach (var item in stuDay)
  172. {
  173. int val = (int)item.Score;
  174. int key = (int)item.Element;
  175. stuDays.Add(key, val);
  176. if (allDays.ContainsKey(key))
  177. allDays[key] = (allDays[key] + val);
  178. else
  179. allDays.Add(key, val);
  180. }
  181. }
  182. else
  183. {
  184. string tableSqlStu = $"PartitionKey eq 'HourLogin' and RowKey ge '{strDaySt}' and RowKey le '{strDayEt}'";
  185. List<HourLogin> hourLoginsStu = await table.QueryWhereString<HourLogin>(tableSqlStu);
  186. //var hourStuCnt = hourLoginsStu.GroupBy(x => x.Hour).Select(k => new { key = int.Parse(k.Key.ToString().Substring(8, 2)), value = k.Count() }).ToList();
  187. if (hourLoginsStu.Count > 0)
  188. {
  189. foreach (var item in hourLoginsStu)
  190. {
  191. await redisClinet.SortedSetIncrementAsync($"Login:IES:student:{dateDay}", $"{item.Hour}", item.Student);//存一天24小时
  192. stuDays.Add(item.Hour, item.Student);
  193. if (allDays.ContainsKey(item.Hour))
  194. allDays[item.Hour] = (allDays[item.Hour] + item.Student);
  195. else
  196. allDays.Add(item.Hour, item.Student);
  197. }
  198. }
  199. }
  200. SortedSetEntry[] tmdDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:tmduser:{dateDay}");
  201. if (tmdDay.Length > 0)
  202. {
  203. foreach (var item in tmdDay)
  204. {
  205. int val = (int)item.Score;
  206. int key = (int)item.Element;
  207. tmdDays.Add(key, val);
  208. if (allDays.ContainsKey(key))
  209. allDays[key] = (allDays[key] + val);
  210. else
  211. allDays.Add(key, val);
  212. }
  213. }
  214. else
  215. {
  216. string tableSqlTmd = $"PartitionKey eq 'HourLogin' and RowKey ge '{strDaySt}' and RowKey le '{strDayEt}'";
  217. List<HourLogin> hourLoginsTmd = await table.QueryWhereString<HourLogin>(tableSqlTmd);
  218. //var hourTmdCnt = hourLoginsTmd.GroupBy(x => x.Hour).Select(k => new { key = int.Parse(k.Key.ToString().Substring(8, 2)), value = k.Count() }).ToList();
  219. if (hourLoginsTmd.Count > 0)
  220. {
  221. foreach (var item in hourLoginsTmd)
  222. {
  223. await redisClinet.SortedSetIncrementAsync($"Login:IES:tmduser:{dateDay}", $"{item.Hour}", item.TmdUser);//存一天24小时
  224. var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 00, 00)).Hour;
  225. tmdDays.Add(utcTo, item.TmdUser);
  226. if (allDays.ContainsKey(utcTo))
  227. allDays[utcTo] = (allDays[utcTo] + item.TmdUser);
  228. else
  229. allDays.Add(utcTo, item.TmdUser);
  230. }
  231. }
  232. }
  233. return Ok(new { state = 200,allDays = allDays.OrderBy(o=>o.Key).ToList(), tchDays=tchDays.OrderBy(o => o.Key).ToList(), stuDays= stuDays.OrderBy(o => o.Key).ToList(), tmdDays= tmdDays.OrderBy(o => o.Key).ToList() });
  234. }
  235. /// <summary>
  236. /// 课例趋势图 //已对接
  237. /// </summary>
  238. /// <returns></returns>
  239. [ProducesDefaultResponseType]
  240. [HttpPost("get-lessontrend")]
  241. public async Task<IActionResult> GetLessonTrend(JsonElement jsonElement)
  242. {
  243. DateTimeOffset dateTime = DateTimeOffset.UtcNow;
  244. var cosmosClient = _azureCosmos.GetCosmosClient();
  245. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  246. //if ($"{site}".Equals(BIConst.Global))
  247. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  248. int year = dateTime.Year; //当前年
  249. int month = dateTime.Month; //当前月
  250. int day = dateTime.Day; //当天
  251. var lestDate = dateTime.AddDays(-1); //昨天
  252. int hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {dateTime.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH")); //当前小时
  253. var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间 13位
  254. var (lastDayS, lastdayE) = TimeHelper.GetStartOrEnd(lestDate); //昨天开始时间
  255. var (monthDayS, monthDayE) = TimeHelper.GetStartOrEnd(lestDate, "monthDay"); //本月开始/结束时间
  256. var (yearS, yearE) = TimeHelper.GetStartOrEnd(lestDate, "yearMonth"); //本月开始/结束时间
  257. Dictionary<int, int> sdOpenLesn = new(); //今日开课
  258. Dictionary<int, int> sdUpdLesn = new(); //今日上传课例
  259. Dictionary<int, int> ydOpenLesn = new(); //昨日开课
  260. Dictionary<int, int> ydUpdLesn = new(); //昨日上传课例
  261. Dictionary<int, int> mthOpenLesn = new(); //本月开课
  262. Dictionary<int, int> mthUpdLesn = new(); //本月上传课例
  263. Dictionary<int, int> yrOpenLesn = new(); //本年开课
  264. Dictionary<int, int> yrUpdLesn = new(); //本年上传课例
  265. Dictionary<int, int> allOpenLesn = new(); //所有年开课
  266. Dictionary<int, int> allUpdLesn = new(); //所有年上传课例
  267. List<RecLesn> yearLeson = new();
  268. List<RecLesn> allLess = new();
  269. string allSql = "select c.id,c.name,c.code,c.school,c.scope,c.startTime from c where c.pk='LessonRecord'";
  270. //所有的课例
  271. allLess = await CommonFind.GetObject<RecLesn>(cosmosClient, new List<string>() { "School", "Teacher" }, allSql);
  272. if (allLess.Count > 0)
  273. {
  274. for (int i = 0; i < 24; i++)
  275. {
  276. if (hour >= i)
  277. {
  278. DateTimeOffset timeHour = new DateTime(year, month, day, i, 0, 0);
  279. var (hourS, hourE) = TimeHelper.GetStartOrEnd(timeHour, type: "hour");
  280. var openLesn1 = allLess.Where(item => item.startTime >= hourS && item.startTime <= hourE && item.upload == 0).Count();
  281. var openLesn = allLess.Where(item => item.startTime >= hourS && item.startTime <= hourE && item.upload == 0).ToList();
  282. sdOpenLesn.Add(i, openLesn.Count());
  283. var UpdLesn = allLess.Where(item => item.startTime >= hourS && item.startTime <= hourE && item.upload == 1).ToList();
  284. sdUpdLesn.Add(i, UpdLesn.Count());
  285. }
  286. DateTimeOffset yesterday = new DateTime(lestDate.Year, lestDate.Month, lestDate.Day, i, 0, 0);
  287. var (yHourS, yHourE) = TimeHelper.GetStartOrEnd(yesterday, type: "hour");
  288. var yOpenLesn = allLess.Where(item => item.startTime >= yHourS && item.startTime <= yHourE && item.upload == 0).ToList();
  289. ydOpenLesn.Add(i, yOpenLesn.Count);
  290. var yUpdLesn = allLess.Where(item => item.startTime >= yHourS && item.startTime <= yHourE && item.upload == 1).ToList();
  291. ydUpdLesn.Add(i, yUpdLesn.Count);
  292. }
  293. for (int i = 1; i <= day; i++)
  294. {
  295. DateTimeOffset timeDay = new DateTime(year, month, i, 0, 0, 0);
  296. var (dayS, dayE) = TimeHelper.GetStartOrEnd(timeDay); //本月开始/结束时间
  297. var openLesn = allLess.Where(item => item.startTime >= dayS && item.startTime <= dayE && item.upload == 0).ToList();
  298. mthOpenLesn.Add(i, openLesn.Count());
  299. var UpdLesn = allLess.Where(item => item.startTime >= dayS && item.startTime <= dayE && item.upload == 1).ToList();
  300. mthUpdLesn.Add(i, UpdLesn.Count());
  301. }
  302. for (int i = 1; i <= month; i++)
  303. {
  304. DateTimeOffset timeDay = DateTimeOffset.UtcNow;
  305. if (i == 2)
  306. {
  307. int tempDay = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? tempDay = 29 : tempDay = 28;
  308. timeDay = new DateTime(year, i, tempDay, 0, 0, 0);
  309. }
  310. else
  311. {
  312. timeDay = new DateTime(year, i, 1, 0, 0, 0);
  313. }
  314. var (monthS, monthE) = TimeHelper.GetStartOrEnd(timeDay, "month"); //本月开始/结束时间
  315. var openLesn = allLess.Where(item => item.startTime >= monthS && item.startTime <= monthE && item.upload == 0).ToList();
  316. yrOpenLesn.Add(i, openLesn.Count());
  317. var UpdLesn = allLess.Where(item => item.startTime >= monthS && item.startTime <= monthE && item.upload == 1).ToList();
  318. yrUpdLesn.Add(i, UpdLesn.Count());
  319. }
  320. yearLeson = allLess.Select(item => { item.startTime = TimeHelper.GetDateTime(item.startTime).Year; return item; }).ToList();
  321. List<RecLesn> oRecLess = yearLeson.Where(o => o.upload == 0).ToList();
  322. var allo = oRecLess.GroupBy(g => g.startTime).Select(s => new { key = s.Key, value = s.Count() }).ToList();
  323. if (allo.Count > 0)
  324. allo.ForEach(a => { allOpenLesn.Add((int)a.key, a.value); });
  325. List<RecLesn> uRecLesns = yearLeson.Where(o => o.upload == 1).ToList();
  326. var allu = uRecLesns.GroupBy(g => g.startTime).Select(s => new { key = s.Key, value = s.Count() }).ToList();
  327. if (allu.Count > 0)
  328. allu.ForEach(a => { allUpdLesn.Add((int)a.key, a.value); });
  329. }
  330. return Ok(new
  331. {
  332. state = RespondCode.Ok,
  333. hours = new { sdOpenLesn = sdOpenLesn.ToList(), sdUpdLesn = sdUpdLesn.ToList(), ydOpenLesn = ydOpenLesn.ToList(), ydUpdLesn = ydUpdLesn.ToList() },
  334. days = new { sdOpenLesn = mthOpenLesn.ToList(), sdUpdLesn = mthUpdLesn.ToList() },
  335. months = new { sdOpenLesn = yrOpenLesn.ToList(), sdUpdLesn = yrUpdLesn.ToList() },
  336. years = new { sdOpenLesn = allOpenLesn.ToList(), sdUpdLesn = allUpdLesn.ToList() }
  337. }) ;
  338. }
  339. /// <summary>
  340. /// 版本数量占比 //已对接
  341. /// </summary>
  342. /// <returns></returns>
  343. [ProducesDefaultResponseType]
  344. [HttpPost("get-edition")]
  345. public async Task<IActionResult> GetEdition(JsonElement jsonElement)
  346. {
  347. var cosmosClient = _azureCosmos.GetCosmosClient();
  348. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  349. //if ($"{site}".Equals(BIConst.Global))
  350. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  351. int beCnt = 0; //基础班
  352. int seCnt = 0; //标准版
  353. int peCnt = 0; //专业版
  354. int cuCnt = 0; //自訂版
  355. List<RecScEd> scEdCnt = new();
  356. var ScSql = $"select c.id,c.name,c.size,c.scale, c.edition, c.service from c";
  357. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
  358. {
  359. scEdCnt.Add(item);
  360. }
  361. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecScEd>(queryText: ScSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
  362. {
  363. scEdCnt.Add(item);
  364. }
  365. foreach (var item in scEdCnt)
  366. {
  367. bool isHaveScaleVersion = false;
  368. if (item.edition != null)
  369. {
  370. if (!string.IsNullOrWhiteSpace(item.edition.scaleVersion))
  371. {
  372. isHaveScaleVersion = true;
  373. }
  374. }
  375. // ※版本判定:1.學校管理(IPDYZYLC) + 學情分析(YMPCVCIM)=「標準版」
  376. // 2.學校管理(IPDYZYLC) + 學情分析(YMPCVCIM) + 五育看板(YPXSJ6NJ) =「專業版」
  377. bool isIP = item.service.Exists(t => t == "IPDYZYLC");
  378. bool isYM = item.service.Exists(t => t == "YMPCVCIM");
  379. bool isYP = item.service.Exists(t => t == "YPXSJ6NJ");
  380. if (isHaveScaleVersion)
  381. { // 自訂版
  382. cuCnt += 1;
  383. }
  384. else if (isIP && isYM && isYP)
  385. { // 專業版
  386. peCnt += 1;
  387. }
  388. else if (isIP && isYM && !isYP)
  389. { // 標準版
  390. seCnt += 1;
  391. }
  392. else
  393. { // 基礎版
  394. beCnt += 1;
  395. }
  396. }
  397. return Ok(new { state = 200, beCnt, seCnt, peCnt, cuCnt, scEdCnt });
  398. }
  399. /// <summary>
  400. /// 记录学校版本信息
  401. /// </summary>
  402. public record RecScEd
  403. {
  404. public string id { get; set; }
  405. public string name { get; set; }
  406. public int size { get; set; }
  407. public int scale { get; set; }
  408. public List<string> serial { get; set; } = new List<string>();//软体
  409. public List<string> service { get; set; } = new List<string>(); //服务
  410. public List<string> hard { get; set; } = new List<string>(); //硬体
  411. public Edition edition { get; set; }
  412. }
  413. /// <summary>
  414. /// 记录课例
  415. /// </summary>
  416. public record RecLesn
  417. {
  418. public string id { get; set; }
  419. public string name { get; set; }
  420. public string code { get; set; }
  421. public string school { get; set; }
  422. public string scope{get;set;}
  423. public long startTime { get; set; }
  424. public int upload { get; set; }
  425. }
  426. }
  427. }