SystemService.cs 126 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425
  1. using Azure.Storage.Blobs.Models;
  2. using DocumentFormat.OpenXml.Bibliography;
  3. using DocumentFormat.OpenXml.Drawing.Charts;
  4. using DocumentFormat.OpenXml.Office2010.Excel;
  5. using DocumentFormat.OpenXml.Wordprocessing;
  6. using HTEXLib;
  7. using HTEXLib.COMM.Helpers;
  8. using HTEXLib.PPTX.Models;
  9. using Microsoft.Azure.Amqp.Framing;
  10. using Microsoft.Extensions.Logging;
  11. using Newtonsoft.Json.Linq;
  12. using NUnit.Framework.Internal.Execution;
  13. using OpenXmlPowerTools;
  14. using StackExchange.Redis;
  15. using System;
  16. using System.Collections.Concurrent;
  17. using System.Collections.Generic;
  18. using System.Diagnostics.PerformanceData;
  19. using System.IdentityModel.Tokens.Jwt;
  20. using System.Linq;
  21. using System.Net.Http;
  22. using System.Net.Http.Json;
  23. using System.Security.Policy;
  24. using System.Text;
  25. using System.Text.Json;
  26. using System.Text.RegularExpressions;
  27. using System.Threading.Tasks;
  28. using TEAMModelOS.SDK.DI;
  29. using TEAMModelOS.SDK.DI.Mail;
  30. using TEAMModelOS.SDK.Extension;
  31. using TEAMModelOS.SDK.Models.Cosmos.Common;
  32. using TEAMModelOS.SDK.Models.Dtos;
  33. using static Azure.Core.HttpHeader;
  34. using static OpenXmlPowerTools.RevisionProcessor;
  35. using static TEAMModelOS.SDK.CoreAPIHttpService;
  36. using static TEAMModelOS.SDK.Models.Service.SystemService;
  37. namespace TEAMModelOS.SDK.Models.Service
  38. {
  39. public static class SystemService
  40. {
  41. #region
  42. static string cn_wb = @"
  43. IES晚间报告:<br>{tmdname}您好,以下是您的今日个人IES教学汇总报告,截至{sendTime}时,您已发布{examCount}次评测任务,{homeworkCount}次作业任务,并使用HiTeach教师端开设了{lessonCount}节课堂教学活动。
  44. <br>&nbsp;&nbsp;&nbsp;以下是报告的具体详细信息。
  45. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{cn_examTitle}<br>{cn_examList}
  46. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{cn_lessonTitle}<br>{cn_lessonList}
  47. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{cn_groupTitle}<br>{cn_groupList}
  48. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如有布置作业任务,将于次日8点通过早报方式发送。
  49. ";
  50. static string cn_examList = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{examName}】已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。<br>";
  51. static string cn_lessonList = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{lessonName}】课例应出席人数{memberCount},实际出席人数{attendCount},出席率{attendRate}%。<br>";
  52. static string cn_groupListJoin = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{grouplistName}】已有总人数{memberCount}位,有{joinCount}位加入。<br>";
  53. static string cn_groupListLeave = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{grouplistName}】已有总人数{memberCount}位,有{joinCount}位离开。<br>";
  54. static string cn_zb = @"
  55. IES早间报告:<br>{tmdname}您好,以下是您发布过的作业任务汇总报告。
  56. <br>&nbsp;&nbsp;&nbsp;以下是报告的具体详细信息。
  57. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{cn_homeworkTitle}<br>{cn_homeworkList}
  58. ";
  59. static string cn_homeworkList = "【{homeworkName}】已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。<br>";
  60. static string cn_homeworkTitle = "作业任务提交详情:";
  61. static string cn_examTitle = "评测任务提交详情:";
  62. static string cn_lessonTitle = "课堂教学出席详情:";
  63. static string cn_groupTitle = "个人课程名单变化详情:";
  64. #endregion
  65. #region
  66. static string tw_wb = @"
  67. IES晚間報告:<br>{tmdname}您好,以下是您的今日個人IES教學總結報告,截至{sendTime},您已發布{examCount}次測驗任務,{homeworkCount}次作業任務,並使用HiTeach上傳了{lessonCount}節課堂教學活動。
  68. <br>&nbsp;&nbsp;&nbsp;以下是詳細資訊。
  69. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{tw_examTitle}<br>{tw_examList}
  70. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{tw_lessonTitle}<br>{tw_lessonList}
  71. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{tw_groupTitle}<br>{tw_groupList}
  72. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如有佈署作業任務,將於隔天早上8點透過晨間報告方式發送。
  73. ";
  74. static string tw_examList = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{examName}】已經有{submitCount}位學生繳交,仍有{unsubmitCount}位學生未繳交。<br>";
  75. static string tw_lessonList = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{lessonName}】課堂應出席人數{memberCount},實際出席人數{attendCount},出席率{attendRate}%。<br>";
  76. static string tw_groupListJoin = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{grouplistName}】已有總人數{memberCount}位,有{joinCount}位加入。<br>";
  77. static string tw_groupListLeave = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【{grouplistName}】已有總人數{memberCount}位,有{joinCount}位離開。<br>";
  78. static string tw_zb = @"
  79. IES晨間報告:<br>{tmdname}您好,以下是您曾經發佈過的作業任務總結報告。
  80. <br>&nbsp;&nbsp;&nbsp;以下是具體詳細資訊。
  81. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{tw_homeworkTitle}<br>{tw_homeworkList}
  82. ";
  83. static string tw_homeworkList = "【{homeworkName}】已經有{submitCount}位學生繳交,仍有{unsubmitCount}位學生未繳交。<br>";
  84. static string tw_homeworkTitle = "作業任務繳交詳情:";
  85. static string tw_examTitle = "測驗任務完成詳情:";
  86. static string tw_lessonTitle = "課堂教學出席詳情:";
  87. static string tw_groupTitle = "個人課程名單變動詳情:";
  88. #endregion
  89. #region
  90. static string en_wb = @"
  91. IES Evening Report:<br>Hello {tmdname}, here is your personal IES teaching summary report for today. As of {sendTime}, you have published {examCount} test tasks, {homeworkCount} homework tasks, and uploaded {lessonCount} HiTeach lesson activity records.
  92. <br>&nbsp;&nbsp;&nbsp;The following are the specific details.
  93. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{en_examTitle}<br>{en_examList}
  94. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{en_lessonTitle}<br>{en_lessonList}
  95. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{en_groupTitle}<br>{en_groupList}
  96. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If there are homework tasks assigned, they will be sent through the morning report at 8 am the next day.
  97. ";
  98. static string en_examList = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ {examName} ] has {submitCount} students submitted, and there are still {unsubmitCount} students who have not submitted.<br>";
  99. static string en_lessonList = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ {lessonName} ] lesson should have {memberCount} attendees, actual attendees {attendCount}, attendance rate {attendRate}%.<br>";
  100. static string en_groupListJoin = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ {grouplistName} ] has a total of {memberCount}, {joinCount} joined.<br>";
  101. static string en_groupListLeave = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ {grouplistName} ] has a total of {memberCount}, {joinCount} left.<br>";
  102. static string en_zb = @"
  103. IES Morning Report:
  104. <br>&nbsp;&nbsp;&nbsp;Hello {tmdname}, here is the summary report of the homework tasks you have posted.
  105. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{en_homeworkTitle}<br>{en_homeworkList}
  106. ";
  107. static string en_homeworkList = "[ {homeworkName} ] has {submitCount} students submitted, and there are still {unsubmitCount} students who have not submitted.<br>";
  108. static string en_homeworkTitle = "Homework Submission Details:";
  109. static string en_examTitle = "Test task submission details:";
  110. static string en_lessonTitle = "Lesson attendance details:";
  111. static string en_groupTitle = "Personal course list change details:";
  112. #endregion
  113. public static async Task<List<CodeValue> > AccumulateDaily(AzureRedisFactory _azureRedis,AzureCosmosFactory _azureCosmos,
  114. CoreAPIHttpService coreAPIHttpService, DingDing dingDing,HttpClient _httpClient, SnowflakeId _snowflakeId,string notifyUrl, MailFactory _mailFactory)
  115. {
  116. DateTimeOffset now = DateTimeOffset.Now;
  117. string day = now.ToString("yyyyMMdd");
  118. string homeworkYesterday = now.AddDays(-1).ToString("yyyyMMdd");
  119. HashSet<string> keys = new HashSet<string>();
  120. //当天评测发布的。
  121. //当天的个人评测提交数
  122. Dictionary<string, double?> exam_submit = new();
  123. SortedSetEntry[] exam_goingScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:exam-going:{day}");
  124. // Dictionary<string, double?> exam_going = new();
  125. if (exam_goingScores != null)
  126. {
  127. foreach (var score in exam_goingScores)
  128. {
  129. double val = score.Score;
  130. string key = score.Element.ToString();
  131. // exam_going.Add(key, val);
  132. exam_submit.Add(key, val);
  133. keys.Add(key);
  134. }
  135. }
  136. ///需要再次获取 没有任何人提交的作业和评测任务。
  137. SortedSetEntry[] exam_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:private:exam-submit:{day}");
  138. if (exam_submitScores != null)
  139. {
  140. foreach (var score in exam_submitScores)
  141. {
  142. double val = score.Score;
  143. string key = score.Element.ToString();
  144. exam_submit.TryAdd(key, val);
  145. keys.Add(key);
  146. }
  147. }
  148. //今天发布的作业
  149. SortedSetEntry[] homework_goingScores_today = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-going:{day}");
  150. Dictionary<string, double?> homework_submit_today = new();
  151. //Dictionary<string, double?> homework_going = new();
  152. if (homework_goingScores_today != null)
  153. {
  154. foreach (var score in homework_goingScores_today)
  155. {
  156. double val = score.Score;
  157. string key = score.Element.ToString();
  158. //homework_going.Add(key, val);
  159. homework_submit_today.TryAdd(key, val);
  160. }
  161. }
  162. //昨天发布的作业
  163. SortedSetEntry[] homework_goingScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-going:{homeworkYesterday}");
  164. Dictionary<string, double?> homework_submit = new();
  165. //Dictionary<string, double?> homework_going = new();
  166. if (homework_goingScores != null)
  167. {
  168. foreach (var score in homework_goingScores)
  169. {
  170. double val = score.Score;
  171. string key = score.Element.ToString();
  172. //homework_going.Add(key, val);
  173. homework_submit.TryAdd(key, val);
  174. keys.Add(key);
  175. }
  176. }
  177. //昨天的个人作业提交数
  178. SortedSetEntry[] homework_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-submit:{homeworkYesterday}");
  179. if (homework_submitScores != null)
  180. {
  181. foreach (var score in homework_submitScores)
  182. {
  183. double val = score.Score;
  184. string key = score.Element.ToString();
  185. homework_submit.TryAdd(key, val);
  186. keys.Add(key);
  187. }
  188. }
  189. //当天的个人名单加入人数
  190. Dictionary<string, double?> grouplist = new();
  191. SortedSetEntry[] grouplistScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:grouplist:{day}");
  192. if (grouplistScores != null)
  193. {
  194. foreach (var score in grouplistScores)
  195. {
  196. double val = score.Score;
  197. string key = score.Element.ToString();
  198. grouplist.TryAdd(key, val);
  199. keys.Add(key);
  200. }
  201. }
  202. //当天教师的开课数量Accumulate:Daily:teacher:lesson-create:20240527
  203. Dictionary<string, double?> lessoncreate = new();
  204. SortedSetEntry[] llessoncreateScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:lesson-create:{day}");
  205. if (llessoncreateScores != null)
  206. {
  207. foreach (var score in llessoncreateScores)
  208. {
  209. double val = score.Score;
  210. string key = score.Element.ToString();
  211. lessoncreate.TryAdd(key, val);
  212. keys.Add(key);
  213. }
  214. }
  215. List<string> ids = new List<string>();
  216. keys.ToList().ForEach(x => {
  217. ids.Add(x.Split("::")[0]);
  218. });
  219. List<CoreUser> coreUsers = new List<CoreUser>();
  220. List<Teacher> teachers= new List<Teacher>();
  221. if (ids.IsNotEmpty())
  222. {
  223. string sql = $"select value c from c where c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))})";
  224. var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<Teacher>(sql, "Base");
  225. if (result.list.IsNotEmpty())
  226. {
  227. teachers.AddRange(result.list);
  228. }
  229. var content = new StringContent(ids.Distinct().ToJsonString(), Encoding.UTF8, "application/json");
  230. try
  231. {
  232. string json = await coreAPIHttpService.GetUserInfos(content);
  233. if (!string.IsNullOrWhiteSpace(json))
  234. {
  235. coreUsers = json.ToObject<List<CoreUser>>();
  236. }
  237. }
  238. catch (Exception ex)
  239. {
  240. await dingDing.SendBotMsg($"{coreAPIHttpService.options.location}用户转换失败:{coreAPIHttpService.options.coreUrl}", GroupNames.醍摩豆服務運維群組);
  241. }
  242. }
  243. List<CodeValue> notifys = new List<CodeValue>();
  244. foreach (var teacher in teachers)
  245. {
  246. StringBuilder notify = new StringBuilder();
  247. #if DEBUG
  248. int sendTime_pm = now.Hour;
  249. int sendTime_am = now.Hour;
  250. #else
  251. int sendTime_pm = 20;
  252. int sendTime_am =8;
  253. #endif
  254. string lang = teacher.lang;
  255. var tzt = now.GetGMTTime((int)teacher.timezone);
  256. if (string.IsNullOrWhiteSpace(teacher.lang))
  257. {
  258. if (coreAPIHttpService.options.location.Contains("China", StringComparison.OrdinalIgnoreCase))
  259. {
  260. lang= "zh-cn";
  261. }
  262. if (coreAPIHttpService.options.location.Contains("Global",StringComparison.OrdinalIgnoreCase))
  263. {
  264. lang= "en-us";
  265. }
  266. }
  267. int examCount = 0,homeworkCount=0,lessonCount=0;
  268. StringBuilder examSB= new StringBuilder();
  269. foreach (var exam in exam_submit)
  270. {
  271. string[] ks = exam.Key.Split("::");
  272. string tid = ks[0];
  273. string examId = ks[1];
  274. string examName = ks[3];
  275. if (tid.Equals(teacher.id)) {
  276. if (tzt.Hour==sendTime_pm)
  277. {
  278. string sql = $"select c.status from c where c.examId='{examId}' and c.pk='ExamClassResult'";
  279. var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<ExamClassResult>(sql, $"ExamClassResult-{tid}");
  280. if (result.list.IsNotEmpty()) {
  281. var unsubmit = result.list.SelectMany(x => x.status).Where(x => x==1);
  282. var submit = result.list.SelectMany(x => x.status).Where(x => x==0);
  283. examCount++;
  284. switch (lang)
  285. {
  286. case "zh-cn":
  287. examSB.Append(cn_examList.Replace("{examName}", examName).Replace("{submitCount}", $"{submit.Count()}").Replace("{unsubmitCount}", $"{unsubmit.Count()}"));
  288. break;
  289. case "zh-tw":
  290. examSB.Append(tw_examList.Replace("{examName}", examName).Replace("{submitCount}", $"{submit.Count()}").Replace("{unsubmitCount}", $"{unsubmit.Count()}"));
  291. break;
  292. case "en-us":
  293. examSB.Append(en_examList.Replace("{examName}", examName).Replace("{submitCount}", $"{submit.Count()}").Replace("{unsubmitCount}", $"{unsubmit.Count()}"));
  294. break;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. StringBuilder homeworkSB = new StringBuilder();
  301. foreach (var homeworksm in homework_submit_today)
  302. {
  303. string[] ks = homeworksm.Key.Split("::");
  304. string tid = ks[0];
  305. string homeworkId = ks[1];
  306. string homeworkName = ks[3];
  307. if (tid.Equals(teacher.id))
  308. {
  309. if (tzt.Hour==sendTime_pm)
  310. {
  311. homeworkCount++;
  312. }
  313. }
  314. }
  315. foreach (var homeworksm in homework_submit)
  316. {
  317. string[] ks = homeworksm.Key.Split("::");
  318. string tid = ks[0];
  319. string homeworkId = ks[1];
  320. string homeworkName = ks[3];
  321. if (tid.Equals(teacher.id))
  322. {
  323. if (tzt.Hour==sendTime_am)
  324. {
  325. Azure .Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(homeworkId, new Azure.Cosmos.PartitionKey($"Homework-{tid}"));
  326. if (response.Status==200) {
  327. Homework homework= JsonDocument.Parse(response.Content).RootElement.ToObject<Homework>();
  328. List<string > classes= new List<string>();
  329. classes.AddRange(homework.stuLists);
  330. classes.AddRange(homework.classes);
  331. List<HomeworkUser> homeworkUsers= await HomeworkService.AnswerRecordAll(_azureCosmos.GetCosmosClient(), coreAPIHttpService, dingDing, homework, tid, "Student", classes, "student");
  332. // homeworkCount++;
  333. switch (lang)
  334. {
  335. case "zh-cn":
  336. homeworkSB.Append(cn_homeworkList.Replace("{homeworkName}", homework.name).Replace("{submitCount}", $"{homeworkUsers.Where(x => x.submit).Count()}").Replace("{unsubmitCount}", $"{homeworkUsers.Where(x => !x.submit).Count()}"));
  337. break;
  338. case "zh-tw":
  339. homeworkSB.Append(tw_homeworkList.Replace("{homeworkName}", homework.name).Replace("{submitCount}", $"{homeworkUsers.Where(x => x.submit).Count()}").Replace("{unsubmitCount}", $"{homeworkUsers.Where(x => !x.submit).Count()}"));
  340. break;
  341. case "en-us":
  342. homeworkSB.Append(en_homeworkList.Replace("{homeworkName}", homework.name).Replace("{submitCount}", $"{homeworkUsers.Where(x => x.submit).Count()}").Replace("{unsubmitCount}", $"{homeworkUsers.Where(x => !x.submit).Count()}"));
  343. break;
  344. }
  345. }
  346. }
  347. }
  348. }
  349. StringBuilder lessonSB = new StringBuilder();
  350. foreach (var lesson in lessoncreate)
  351. {
  352. string[] ks = lesson.Key.Split("::");
  353. string tid = ks[0];
  354. if (tid.Equals(teacher.id))
  355. {
  356. if (tzt.Hour==sendTime_pm)
  357. {
  358. long stime = now.AddHours(-20).ToUnixTimeMilliseconds();
  359. string sql = $"select value c from c where c.tmdid='{teacher.id}' and c.pk='LessonRecord' and c.startTime> {stime} ";
  360. List<LessonRecord>lessons = new List<LessonRecord>();
  361. var schoolResult= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<LessonRecord>(sql);
  362. var teahcerResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<LessonRecord>(sql, "LessonRecord");
  363. lessons.AddRange(schoolResult.list);
  364. lessons.AddRange(teahcerResult.list);
  365. foreach(var lessonRecord in lessons)
  366. {
  367. lessonCount++;
  368. switch (lang)
  369. {
  370. case "zh-cn":
  371. lessonSB.Append(cn_lessonList.Replace("{lessonName}", lessonRecord.name).Replace("{memberCount}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")).Replace("{attendRate}", $"{lessonRecord.attendRate}");
  372. break;
  373. case "zh-tw":
  374. lessonSB.Append(tw_lessonList.Replace("{lessonName}", lessonRecord.name).Replace("{memberCount}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")).Replace("{attendRate}", $"{lessonRecord.attendRate}");
  375. break;
  376. case "en-us":
  377. lessonSB.Append(en_lessonList.Replace("{lessonName}", lessonRecord.name).Replace("{memberCount}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")).Replace("{attendRate}", $"{lessonRecord.attendRate}");
  378. break;
  379. }
  380. }
  381. }
  382. }
  383. }
  384. StringBuilder grouplistSB = new StringBuilder();
  385. List<string> grouplistIds=new List<string>();
  386. foreach (var group in grouplist)
  387. {
  388. string[] ks = group.Key.Split("::");
  389. grouplistIds.Add(ks[1]);
  390. }
  391. List<GroupListDto> groupListDtos= await GroupListService.GetGroupListByListids(_azureCosmos.GetCosmosClient(), dingDing, grouplistIds, null);
  392. foreach (var group in grouplist)
  393. {
  394. string[] ks = group.Key.Split("::");
  395. string tid = ks[0];
  396. string grouplistId = ks[1];
  397. string grouplistName = ks[3];
  398. var gpdto= groupListDtos.Find(x => x.id.Equals(grouplistId));
  399. if (gpdto!= null)
  400. {
  401. if (tid.Equals(teacher.id))
  402. {
  403. if (tzt.Hour==sendTime_pm)
  404. {
  405. switch (lang)
  406. {
  407. case "zh-cn":
  408. if (group.Value>=0)
  409. {
  410. grouplistSB.Append(cn_groupListJoin.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
  411. }
  412. else
  413. {
  414. grouplistSB.Append(cn_groupListLeave.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
  415. }
  416. break;
  417. case "zh-tw":
  418. if (group.Value>=0)
  419. {
  420. grouplistSB.Append(tw_groupListJoin.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
  421. }
  422. else
  423. {
  424. grouplistSB.Append(tw_groupListLeave.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
  425. }
  426. break;
  427. case "en-us":
  428. if (group.Value>=0)
  429. {
  430. grouplistSB.Append(en_groupListJoin.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
  431. }
  432. else
  433. {
  434. grouplistSB.Append(en_groupListLeave.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
  435. }
  436. break;
  437. }
  438. }
  439. }
  440. }
  441. }
  442. if (tzt.Hour==sendTime_pm && (examCount>0 || lessonCount>0 || homeworkCount>0 || (grouplist.Count>0 && !string.IsNullOrWhiteSpace(grouplistSB.ToString()))))
  443. {
  444. string template=string.Empty;
  445. string title=string.Empty;
  446. switch (lang)
  447. {
  448. case "zh-cn":
  449. title="IES晚间报告";
  450. template=cn_wb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_pm}")
  451. .Replace("{examCount}", $"{examCount}").Replace("{homeworkCount}", $"{homeworkCount}").Replace("{lessonCount}", $"{lessonCount}")
  452. .Replace("{cn_examList}", examSB.ToString()).Replace("{cn_lessonList}", lessonSB.ToString()).Replace("{cn_groupList}", grouplistSB.ToString());
  453. if (examCount>0)
  454. {
  455. template= template.Replace("{cn_examTitle}", cn_examTitle);
  456. }
  457. else {
  458. template= template.Replace("{cn_examTitle}", "");
  459. }
  460. if (homeworkCount>0)
  461. {
  462. template= template.Replace("{cn_homeworkTitle}", cn_homeworkTitle);
  463. }
  464. else
  465. {
  466. template= template.Replace("{cn_homeworkTitle}", "");
  467. }
  468. if (lessonCount>0)
  469. {
  470. template= template.Replace("{cn_lessonTitle}", cn_lessonTitle);
  471. }
  472. else
  473. {
  474. template= template.Replace("{cn_lessonTitle}", "");
  475. }
  476. if (grouplist.Count>0 && !string.IsNullOrWhiteSpace(grouplistSB.ToString()))
  477. {
  478. template=template.Replace("{cn_groupTitle}", cn_groupTitle);
  479. }
  480. else
  481. {
  482. template= template.Replace("{cn_groupTitle}", "");
  483. }
  484. break;
  485. case "zh-tw":
  486. title="IES晚間報告";
  487. template=tw_wb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_pm}")
  488. .Replace("{examCount}", $"{examCount}").Replace("{homeworkCount}", $"{homeworkCount}").Replace("{lessonCount}", $"{lessonCount}")
  489. .Replace("{tw_examList}", examSB.ToString()).Replace("{tw_lessonList}", lessonSB.ToString()).Replace("{tw_groupList}", grouplistSB.ToString());
  490. if (examCount>0)
  491. {
  492. template= template.Replace("{tw_examTitle}", tw_examTitle);
  493. }
  494. else
  495. {
  496. template= template.Replace("{tw_examTitle}", "");
  497. }
  498. if (homeworkCount>0)
  499. {
  500. template= template.Replace("{tw_homeworkTitle}", tw_homeworkTitle);
  501. }
  502. else
  503. {
  504. template= template.Replace("{tw_homeworkTitle}", "");
  505. }
  506. if (lessonCount>0)
  507. {
  508. template= template.Replace("{tw_lessonTitle}", tw_lessonTitle);
  509. }
  510. else
  511. {
  512. template= template.Replace("{tw_lessonTitle}", "");
  513. }
  514. if (grouplist.Count>0)
  515. {
  516. template=template.Replace("{tw_groupTitle}", tw_groupTitle);
  517. }
  518. else
  519. {
  520. template= template.Replace("{tw_groupTitle}", "");
  521. }
  522. break;
  523. case "en-us":
  524. title ="IES Evening Report";
  525. template=en_wb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_pm}")
  526. .Replace("{examCount}", $"{examCount}").Replace("{homeworkCount}", $"{homeworkCount}").Replace("{lessonCount}", $"{lessonCount}")
  527. .Replace("{en_examList}", examSB.ToString()).Replace("{en_lessonList}", lessonSB.ToString()).Replace("{en_groupList}", grouplistSB.ToString());
  528. if (examCount>0)
  529. {
  530. template= template.Replace("{en_examTitle}", en_examTitle);
  531. }
  532. else
  533. {
  534. template= template.Replace("{en_examTitle}", "");
  535. }
  536. if (homeworkCount>0)
  537. {
  538. template= template.Replace("{en_homeworkTitle}", en_homeworkTitle);
  539. }
  540. else
  541. {
  542. template= template.Replace("{en_homeworkTitle}", "");
  543. }
  544. if (lessonCount>0)
  545. {
  546. template= template.Replace("{en_lessonTitle}", en_lessonTitle);
  547. }
  548. else
  549. {
  550. template= template.Replace("{en_lessonTitle}", "");
  551. }
  552. if (grouplist.Count>0)
  553. {
  554. template=template.Replace("{en_groupTitle}", en_groupTitle);
  555. }
  556. else
  557. {
  558. template= template.Replace("{en_groupTitle}", "");
  559. }
  560. break;
  561. }
  562. #if DEBUG
  563. string eventId = $"Evening_Report-{_snowflakeId.NextId()}";
  564. NotifyData notifyData = new NotifyData
  565. {
  566. hubName = "hita5",
  567. sender = "IES",
  568. tags = new List<string>() { $"{teacher.id}_{Constant.NotifyType_IES5_Course}" },
  569. title = title,
  570. eventId =eventId,
  571. eventName =title,
  572. data = "{\"value\":{}}",
  573. body=template,
  574. };
  575. HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync($"{notifyUrl}/service/PushNotify", notifyData);
  576. var coreUser = coreUsers.Find(x => x.id.Equals(teacher.id) && !string.IsNullOrWhiteSpace(x.mail));
  577. if (coreUser!=null)
  578. {
  579. var token = _mailFactory.GetSmtpClient().SendEmail(_azureCosmos, dingDing, eventId, title, template, coreUser.mail, teacher.id, teacher.name);
  580. }
  581. #endif
  582. notify.Append(template);
  583. }
  584. if (tzt.Hour==sendTime_am && !string.IsNullOrWhiteSpace(homeworkSB.ToString()))
  585. {
  586. string template = string.Empty;
  587. string title = string.Empty;
  588. switch (lang)
  589. {
  590. case "zh-cn":
  591. title ="IES早间报告";
  592. template= cn_zb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_am}")
  593. .Replace("{cn_homeworkList}", homeworkSB.ToString());
  594. template=template.Replace("{cn_homeworkTitle}", cn_homeworkTitle);
  595. break;
  596. case "zh-tw":
  597. title ="IES晨間報告";
  598. template= tw_zb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_am}")
  599. .Replace("{tw_homeworkList}", homeworkSB.ToString());
  600. template=template.Replace("{tw_homeworkTitle}", tw_homeworkTitle);
  601. break;
  602. case "en-us":
  603. title ="IES Morning Report";
  604. template=en_zb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_am}")
  605. .Replace("{en_homeworkList}", homeworkSB.ToString());
  606. template=template.Replace("{en_homeworkTitle}", en_homeworkTitle);
  607. break;
  608. }
  609. #if DEBUG
  610. string eventId = $"Morning_Report-{_snowflakeId.NextId()}";
  611. NotifyData notifyData = new NotifyData
  612. {
  613. hubName = "hita5",
  614. sender = "IES",
  615. tags = new List<string>() { $"{teacher.id}_{Constant.NotifyType_IES5_Course}" },
  616. title = title,
  617. eventId = eventId,
  618. eventName =title,
  619. data = "{\"value\":{}}",
  620. body=template,
  621. };
  622. HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync($"{notifyUrl}/service/PushNotify", notifyData);
  623. var coreUser = coreUsers.Find(x => x.id.Equals(teacher.id) && !string.IsNullOrWhiteSpace(x.mail));
  624. if (coreUser!=null)
  625. {
  626. var token = _mailFactory.GetSmtpClient().SendEmail(_azureCosmos, dingDing, eventId, title, template, coreUser.mail, teacher.id, teacher.name);
  627. }
  628. #endif
  629. notify.Append(template);
  630. }
  631. notifys.Add(new CodeValue { code=teacher.id, value= notify.ToString() });
  632. }
  633. return notifys;
  634. }
  635. public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, DingDing dingDing, Accumulate accumulate)
  636. {
  637. if (!string.IsNullOrWhiteSpace(accumulate.key) && !string.IsNullOrWhiteSpace(accumulate.target) &&
  638. !string.IsNullOrWhiteSpace(accumulate.id) && !string.IsNullOrWhiteSpace(accumulate.name) &&
  639. !string.IsNullOrWhiteSpace(accumulate.scope) && !string.IsNullOrWhiteSpace(accumulate.client))
  640. {
  641. await RecordAccumulateData(azureRedis, accumulate.key, accumulate.target, accumulate.id, accumulate.name, accumulate.scope, accumulate.client, accumulate.count);
  642. }
  643. else
  644. {
  645. await dingDing.SendBotMsg($"IES累计数据变更统计参数异常,{accumulate.ToJsonString()}", GroupNames.成都开发測試群組);
  646. }
  647. }
  648. /// <summary>
  649. /// 记录累计数据
  650. /// </summary>
  651. public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, string key, string target, string id, string name, string scope, string client, int count)
  652. {
  653. if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(target) &&
  654. !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(name) &&
  655. !string.IsNullOrWhiteSpace(scope)&& !string.IsNullOrWhiteSpace(client))
  656. {
  657. //处理UTC时差
  658. var nowTime = DateTimeOffset.UtcNow.GetGMTTime();
  659. int difference = (DayOfWeek.Sunday - nowTime.DayOfWeek + 7) % 7; //1-7的结果0-6
  660. var day = nowTime.ToString("yyyyMMdd");
  661. string redisKey = $"Accumulate:Daily:{scope}:{key}:{day}";
  662. string member = $"{target}::{id}::{client}::{name}";
  663. await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, count);
  664. await azureRedis.GetRedisClient(8).KeyExpireAsync(redisKey, new TimeSpan((difference+1)*24, 10, 0));
  665. //if (key.Equals("lesson") || key.StartsWith("login_"))
  666. //{
  667. // redisKey = $"Accumulate:Daily:ies:{key}:{day}";
  668. // if (scope.Equals("school"))
  669. // {
  670. // member = $"ies::{id}::{name}";
  671. // }
  672. // else {
  673. // member = $"ies::ies::{name}";
  674. // }
  675. // await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, 1);
  676. //}
  677. }
  678. }
  679. static double GetUserDuration(List<long> times )
  680. {
  681. if (times.IsNotEmpty())
  682. {
  683. if (times.Count>=2)
  684. {
  685. double totalDuration = 0;
  686. // DateTime lastTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsonData[0]["time"]).UtcDateTime;
  687. long ltime = times[0];
  688. for (int i = 1; i < times.Count; i++)
  689. {
  690. long ctime = times[i];
  691. //DateTime currentTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsonData[i]["time"]).UtcDateTime;
  692. long timeDifference = ctime - ltime;
  693. ///如果一小时内连续操作,则按真实时间累计
  694. if (timeDifference < 3600000)
  695. {
  696. totalDuration += timeDifference;
  697. }
  698. else
  699. { ///如果一小时内没有连续操作,则按象征性加10秒,以确保数据有效性。 如果因为一小时没有操作,则表示没有新的接口再次请求,当即就已经退出系统。否则后续仍然会有接口进入,并且带有时间戳
  700. totalDuration += 10000;
  701. }
  702. ltime = ctime;
  703. }
  704. return totalDuration;
  705. }
  706. else { return 10000; }
  707. }
  708. else {
  709. return 0;
  710. }
  711. }
  712. public static List<SchoolStick> CountSchoolStickiness(IEnumerable<IGrouping<string,ApiVisit>> schoolApiVisits, IEnumerable<ApiVisit> apiVisits)
  713. {
  714. List<SchoolStick> schoolStickiness = new List<SchoolStick>();
  715. foreach (var chinaSchoolKey in schoolApiVisits)
  716. {
  717. SchoolStick stickiness = new SchoolStick()
  718. {
  719. id = chinaSchoolKey.Key
  720. };
  721. var teachers = chinaSchoolKey.ToList().Where(x => !string.IsNullOrWhiteSpace(x.userId) && !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("teacher")).GroupBy(x => x.userId);
  722. double hitaTime = 0, hiteachTime = 0, ies5TchTime = 0, otherTchTime = 0, ies5StuTime = 0, otherStuTime = 0;
  723. int hitaTch= 0, hiteachTch = 0, ies5Tch = 0, otherTch = 0, ies5Stu = 0, otherStu = 0;
  724. double hitaCount = 0, hiteachCount = 0, ies5TchCount = 0, otherTchCount = 0, ies5StuCount = 0, otherStuCount = 0;
  725. double lessonCount= chinaSchoolKey.ToList().Where(x => x.path.Contains("hiteach/create-lesson")).Count() ;
  726. int teacherCount= teachers.Count() ;
  727. foreach (var user in teachers)
  728. {
  729. TchStick tchStick = new TchStick()
  730. {
  731. id = user.Key,
  732. school= chinaSchoolKey.Key
  733. };
  734. //HiTA
  735. var teacherHitaVisit = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.userId) && x.userId.Equals(user.Key) && x.client.Equals("hita"));
  736. var teacherHitaVisitCount = teacherHitaVisit.Count();
  737. if (teacherHitaVisitCount>0)
  738. { hitaTch+=1; }
  739. var teacherHitaVisitTime = GetUserDuration(teacherHitaVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
  740. hitaCount+=teacherHitaVisitCount;
  741. hitaTime+=teacherHitaVisitTime;
  742. tchStick.hita.count.value=teacherHitaVisitCount;
  743. tchStick.hita.duration.value=teacherHitaVisitTime;
  744. //Other
  745. var teacherOtherVisit = user.Where(x => !x.client.Equals("hita")&&!x.client.Equals("hiteach")&&!x.client.Equals("ies5"));
  746. var teacherOtherVisitCount= teacherOtherVisit.Count();
  747. var teacherOtherVisitTime= GetUserDuration(teacherOtherVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
  748. if (teacherOtherVisitCount>0)
  749. { otherTch+=1; }
  750. otherTchCount+=teacherOtherVisitCount;
  751. otherTchTime+=teacherOtherVisitTime;
  752. tchStick.otherTch.count.value=teacherOtherVisitCount;
  753. tchStick.otherTch.duration.value=teacherOtherVisitTime;
  754. //HiTeach
  755. //教师访问hiteach 不带学校信息的
  756. var teacherHiteachVisit = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.userId) && x.userId.Equals(user.Key) && x.client.Equals("hiteach") && string.IsNullOrWhiteSpace(x.school));
  757. //教师访问hiteach 包含学校信息的
  758. var teacherHiteachSchoolVisit = user.Where(x => x.client.Equals("hiteach"));
  759. //教师所有的Hiteach访问
  760. List<ApiVisit> teacherHiteachAllVisit = new List<ApiVisit>();
  761. teacherHiteachAllVisit.AddRange(teacherHiteachVisit);
  762. teacherHiteachAllVisit.AddRange(teacherHiteachSchoolVisit);
  763. var teacherHiteachAllVisitCount = teacherHiteachAllVisit.Count();
  764. if (teacherHiteachAllVisitCount>0)
  765. { hiteachTch+=1; }
  766. var teacherHiteachAllVisitTime = GetUserDuration(teacherHiteachAllVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
  767. hiteachCount+=teacherHiteachAllVisitCount;
  768. hiteachTime+=teacherHiteachAllVisitTime;
  769. tchStick.hiteach.count.value=teacherHiteachAllVisitCount;
  770. tchStick.hiteach.duration.value=teacherHiteachAllVisitTime;
  771. //IES5
  772. var teacherIes5Visit = user.Where(x => x.client.Equals("ies5"));
  773. var teacherIes5VisitCount= teacherIes5Visit.Count();
  774. if (teacherIes5VisitCount>0)
  775. { ies5Tch+=1; }
  776. var teacherIes5VisitTime = GetUserDuration(teacherIes5Visit.OrderBy(x => x.time).Select(x => x.time).ToList());
  777. ies5TchCount+=teacherIes5VisitCount;
  778. ies5TchTime+=teacherIes5VisitTime;
  779. tchStick.ies5Tch.count.value=teacherIes5VisitCount;
  780. tchStick.ies5Tch.duration.value=teacherIes5VisitTime;
  781. double lessonCountTch = chinaSchoolKey.ToList().Where(x => x.path.Contains("hiteach/create-lesson") && x.userId.Equals(user.Key)).Count();
  782. tchStick.lesson.value=lessonCountTch;
  783. tchStick.tmd.count.value=tchStick.hita.count.value+tchStick.hiteach.count.value+tchStick.ies5Tch.count.value+tchStick.otherTch.count.value;
  784. tchStick.tmd.duration.value=tchStick.hita.duration.value+tchStick.hiteach.duration.value+tchStick.ies5Tch.duration.value+tchStick.otherTch.duration.value;
  785. tchStick.hita.userCount=1;
  786. tchStick.hiteach.userCount=1;
  787. tchStick.ies5Tch.userCount=1;
  788. tchStick.otherTch.userCount=1;
  789. tchStick.tmd.userCount=1;
  790. if (tchStick.hita.count.value>0 && tchStick.hita.duration.value>0)
  791. {
  792. tchStick.hita.stick.value= (tchStick.hita.duration.value/1000/tchStick.hita.count.value);
  793. }
  794. if (tchStick.ies5Tch.count.value>0 && tchStick.ies5Tch.duration.value>0)
  795. {
  796. tchStick.ies5Tch.stick.value= (tchStick.ies5Tch.duration.value/1000/tchStick.ies5Tch.count.value);
  797. }
  798. if (tchStick.otherTch.count.value>0 && tchStick.otherTch.duration.value>0)
  799. {
  800. tchStick.otherTch.stick.value= (tchStick.otherTch.duration.value/1000/tchStick.otherTch.count.value);
  801. }
  802. if (tchStick.hiteach.count.value>0 && tchStick.hiteach.duration.value>0)
  803. {
  804. tchStick.hiteach.stick.value= (tchStick.hiteach.duration.value/1000/tchStick.hiteach.count.value)+tchStick.lesson.value;
  805. }
  806. if (tchStick.tmd.count.value>0 && tchStick.tmd.duration.value>0)
  807. {
  808. tchStick.tmd.stick.value= (tchStick.tmd.duration.value/1000/tchStick.tmd.count.value)+ tchStick.lesson.value;
  809. }
  810. stickiness.tchSticks.Add(tchStick);
  811. }
  812. var student = chinaSchoolKey.ToList().Where(x => !string.IsNullOrWhiteSpace(x.userId) && !string.IsNullOrWhiteSpace(x.scope) && (x.scope.Equals("student")||x.scope.Equals("tmduser"))).GroupBy(x => x.userId);
  813. var studentCount = student.Count();
  814. foreach (var user in student)
  815. {
  816. StuStick stuStick = new StuStick
  817. {
  818. id=user.Key,
  819. school=chinaSchoolKey.Key
  820. };
  821. var studentOtherVisit = user.Where(x => !x.client.Equals("ies5"));
  822. var studentOtherVisitCount = studentOtherVisit.Count();
  823. if (studentOtherVisitCount>0)
  824. { otherStu+=1; }
  825. double studentOtherVisitTime = GetUserDuration(studentOtherVisit.OrderBy(x => x.time).Select(x => x.time).ToList()) ;
  826. var studentIes5Visit = user.Where(x => x.client.Equals("ies5"));
  827. var studentIes5VisitCount = studentIes5Visit.Count();
  828. if (studentIes5VisitCount>0)
  829. { ies5Stu+=1; }
  830. double studentIes5VisitTime = GetUserDuration(studentIes5Visit.OrderBy(x => x.time).Select(x => x.time).ToList());
  831. ies5StuCount+=studentIes5VisitCount;
  832. ies5StuTime+=studentIes5VisitTime;
  833. otherStuCount+=studentOtherVisitCount;
  834. otherStuTime+=studentOtherVisitTime;
  835. stuStick.ies5Stu.count.value=studentIes5VisitCount;
  836. stuStick.ies5Stu.duration.value=studentIes5VisitTime;
  837. stuStick.otherStu.count.value=studentOtherVisitCount;
  838. stuStick.otherStu.duration.value=studentOtherVisitTime;
  839. stuStick.tmd.count.value= stuStick.ies5Stu.count.value+stuStick.otherStu.count.value;
  840. stuStick.tmd.duration.value= stuStick.ies5Stu.duration.value+stuStick.otherStu.duration.value;
  841. stuStick.ies5Stu.userCount=1;
  842. stuStick.otherStu.userCount=1;
  843. stuStick.tmd.userCount=1;
  844. if (stuStick.ies5Stu.count.value>0 && stuStick.ies5Stu.duration.value>0)
  845. {
  846. stuStick.ies5Stu.stick.value= (stuStick.ies5Stu.duration.value/1000/stuStick.ies5Stu.count.value);
  847. }
  848. if (stuStick.otherStu.count.value>0 && stuStick.otherStu.duration.value>0)
  849. {
  850. stuStick.otherStu.stick.value=(stuStick.otherStu.duration.value/1000/stuStick.otherStu.count.value);
  851. }
  852. if (stuStick.tmd.count.value>0 && stuStick.tmd.duration.value>0)
  853. {
  854. stuStick.tmd.stick.value=(stuStick.tmd.duration.value/1000/stuStick.tmd.count.value);
  855. }
  856. stickiness.stuSticks.Add(stuStick);
  857. }
  858. stickiness.hita.duration.value=hitaTime;
  859. stickiness.hiteach.duration.value=hiteachTime;
  860. stickiness.otherTch.duration.value=otherTchTime;
  861. stickiness.ies5Tch.duration.value=ies5TchTime;
  862. stickiness.tmd.duration.value=hitaTime+hiteachTime+otherTchTime+ies5TchTime+otherStuTime+ies5StuTime;
  863. stickiness.hita.userCount=hitaTch;
  864. stickiness.hiteach.userCount=hiteachTch;
  865. stickiness.ies5Tch.userCount=ies5Tch;
  866. stickiness.otherTch.userCount=otherTch;
  867. stickiness.ies5Stu.userCount=ies5Stu;
  868. stickiness.otherStu.userCount=otherStu;
  869. stickiness.hita.count.value=hitaCount;
  870. stickiness.hiteach.count.value=hiteachCount;
  871. stickiness.ies5Tch.count.value=ies5TchCount;
  872. stickiness.otherTch.count.value=otherTchCount;
  873. stickiness.ies5Stu.count.value=ies5StuCount;
  874. stickiness.otherStu.count.value=otherStuCount;
  875. stickiness.tmd.count.value=hitaCount+hiteachCount+ies5TchCount+otherTchCount+ies5StuCount+otherStuCount;
  876. stickiness.lesson.value=lessonCount;
  877. stickiness.tmd.userCount=teacherCount+studentCount;
  878. if(stickiness.hita.count.value>0 && stickiness.hita.duration.value>0)
  879. {
  880. stickiness.hita.stick.value=(stickiness.hita.userCount* stickiness.hita.count.value)/(stickiness.hita.duration.value/1000/stickiness.hita.count.value);
  881. }
  882. if (stickiness.ies5Stu.count.value>0 && stickiness.ies5Stu.duration.value>0)
  883. {
  884. stickiness.ies5Stu.stick.value=(stickiness.ies5Stu.userCount* stickiness.ies5Stu.count.value)/(stickiness.ies5Stu.duration.value/1000/stickiness.ies5Stu.count.value);
  885. }
  886. if (stickiness.ies5Tch.count.value>0 && stickiness.ies5Tch.duration.value>0)
  887. {
  888. stickiness.ies5Tch.stick.value=(stickiness.ies5Tch.userCount* stickiness.ies5Tch.count.value)/(stickiness.ies5Tch.duration.value/1000/stickiness.ies5Tch.count.value);
  889. }
  890. if (stickiness.otherStu.count.value>0 && stickiness.otherStu.duration.value>0)
  891. {
  892. stickiness.otherStu.stick.value=(stickiness.otherStu.userCount* stickiness.otherStu.count.value)/(stickiness.otherStu.duration.value/1000/stickiness.otherStu.count.value);
  893. }
  894. if (stickiness.otherTch.count.value>0 && stickiness.otherTch.duration.value>0)
  895. {
  896. stickiness.otherTch.stick.value=(stickiness.otherTch.userCount* stickiness.otherTch.count.value)/(stickiness.otherTch.duration.value/1000/stickiness.otherTch.count.value);
  897. }
  898. if (stickiness.hiteach.count.value>0 && stickiness.hiteach.duration.value>0)
  899. {
  900. stickiness.hiteach.stick.value=(stickiness.hiteach.userCount* stickiness.hiteach.count.value)/(stickiness.hiteach.duration.value/1000/stickiness.hiteach.count.value)+stickiness.lesson.value;
  901. }
  902. if (stickiness.tmd.count.value>0 && stickiness.tmd.duration.value>0)
  903. {
  904. stickiness.tmd.stick.value=(stickiness.tmd.userCount* stickiness.tmd.count.value)/(stickiness.tmd.duration.value/1000/stickiness.tmd.count.value)+ stickiness.lesson.value;
  905. }
  906. stickiness.tchSticks= OrderByTchStick(stickiness.tchSticks);
  907. stickiness.stuSticks= OrderByStuStick(stickiness.stuSticks);
  908. schoolStickiness.Add(stickiness);
  909. }
  910. return OrderBySchoolStick(schoolStickiness);
  911. }
  912. private static List<StuStick> OrderByStuStick(List<StuStick> stuStickiness)
  913. {
  914. // 假设visit已经填充了数据
  915. #region
  916. var rank_tmd_count = stuStickiness.Select(x => x.tmd.count.value).Distinct().OrderByDescending(v => v).ToList();
  917. var rank_ies5Stu_count = stuStickiness.Select(x => x.ies5Stu.count.value).Distinct().OrderByDescending(v => v).ToList();
  918. var rank_otherStu_count = stuStickiness.Select(x => x.otherStu.count.value).Distinct().OrderByDescending(v => v).ToList();
  919. #endregion
  920. #region
  921. var rank_tmd_duration = stuStickiness.Select(x => x.tmd.duration.value).Distinct().OrderByDescending(v => v).ToList();
  922. var rank_ies5Stu_duration = stuStickiness.Select(x => x.ies5Stu.duration.value).Distinct().OrderByDescending(v => v).ToList();
  923. var rank_otherStu_duration = stuStickiness.Select(x => x.otherStu.duration.value).Distinct().OrderByDescending(v => v).ToList();
  924. #endregion
  925. #region
  926. var rank_tmd_stick = stuStickiness.Select(x => x.tmd.stick.value).Distinct().OrderByDescending(v => v).ToList();
  927. var rank_ies5Stu_stick = stuStickiness.Select(x => x.ies5Stu.stick.value).Distinct().OrderByDescending(v => v).ToList();
  928. var rank_otherStu_stick = stuStickiness.Select(x => x.otherStu.stick.value).Distinct().OrderByDescending(v => v).ToList();
  929. #endregion
  930. stuStickiness.ForEach(x =>
  931. {
  932. #region
  933. if (x.tmd.count.value>0)
  934. {
  935. int index_tmd_count = rank_tmd_count.FindIndex(i => i==x.tmd.count.value);
  936. if (index_tmd_count!=-1)
  937. {
  938. x.tmd.count.rank = index_tmd_count + 1;
  939. }
  940. }
  941. if (x.ies5Stu.count.value>0)
  942. {
  943. int index_ies5Stu_count = rank_ies5Stu_count.FindIndex(i => i==x.ies5Stu.count.value);
  944. if (index_ies5Stu_count!=-1)
  945. {
  946. x.ies5Stu.count.rank = index_ies5Stu_count + 1;
  947. }
  948. }
  949. if (x.otherStu.count.value>0)
  950. {
  951. int index_otherStu_count = rank_otherStu_count.FindIndex(i => i==x.otherStu.count.value);
  952. if (index_otherStu_count!=-1)
  953. {
  954. x.otherStu.count.rank = index_otherStu_count + 1;
  955. }
  956. }
  957. #endregion
  958. #region
  959. if (x.tmd.duration.value> 0) {
  960. int index_tmd_duration = rank_tmd_duration.FindIndex(i => i==x.tmd.duration.value);
  961. if (index_tmd_duration!=-1)
  962. {
  963. x.tmd.duration.rank = index_tmd_duration + 1;
  964. }
  965. }
  966. if (x.ies5Stu.duration.value>0) {
  967. int index_ies5Stu_duration = rank_ies5Stu_duration.FindIndex(i => i==x.ies5Stu.duration.value);
  968. if (index_ies5Stu_duration!=-1)
  969. {
  970. x.ies5Stu.duration.rank = index_ies5Stu_duration + 1;
  971. }
  972. }
  973. if (x.otherStu.duration.value>0) {
  974. int index_otherStu_duration = rank_otherStu_duration.FindIndex(i => i==x.otherStu.duration.value);
  975. if (index_otherStu_duration!=-1)
  976. {
  977. x.otherStu.duration.rank = index_otherStu_duration + 1;
  978. }
  979. }
  980. #endregion
  981. #region
  982. if (x.tmd.stick.value>0)
  983. {
  984. int index_tmd_stick = rank_tmd_stick.FindIndex(i => i==x.tmd.stick.value);
  985. if (index_tmd_stick!=-1)
  986. {
  987. x.tmd.stick.rank = index_tmd_stick + 1;
  988. }
  989. }
  990. if (x.ies5Stu.stick.value>0)
  991. {
  992. int index_ies5Stu_stick = rank_ies5Stu_stick.FindIndex(i => i==x.ies5Stu.stick.value);
  993. if (index_ies5Stu_stick!=-1)
  994. {
  995. x.ies5Stu.stick.rank = index_ies5Stu_stick + 1;
  996. }
  997. }
  998. if (x.otherStu.stick.value>0)
  999. {
  1000. int index_otherStu_stick = rank_otherStu_stick.FindIndex(i => i==x.otherStu.stick.value);
  1001. if (index_otherStu_stick!=-1)
  1002. {
  1003. x.otherStu.stick.rank = index_otherStu_stick + 1;
  1004. }
  1005. }
  1006. #endregion
  1007. });
  1008. return stuStickiness;
  1009. }
  1010. private static List<TchStick> OrderByTchStick(List<TchStick> tchStickiness)
  1011. {
  1012. // 假设visit已经填充了数据
  1013. #region
  1014. var rank_tmd_count = tchStickiness.Select(x => x.tmd.count.value).Distinct().OrderByDescending(v => v).ToList();
  1015. var rank_hita_count = tchStickiness.Select(x => x.hita.count.value).Distinct().OrderByDescending(v => v).ToList();
  1016. var rank_hiteach_count = tchStickiness.Select(x => x.hiteach.count.value).Distinct().OrderByDescending(v => v).ToList();
  1017. var rank_ies5Tch_count = tchStickiness.Select(x => x.ies5Tch.count.value).Distinct().OrderByDescending(v => v).ToList();
  1018. var rank_otherTch_count = tchStickiness.Select(x => x.otherTch.count.value).Distinct().OrderByDescending(v => v).ToList();
  1019. var rank_lesson_count = tchStickiness.Select(x => x.lesson.value).Distinct().OrderByDescending(v => v).ToList();
  1020. #endregion
  1021. #region
  1022. var rank_tmd_duration = tchStickiness.Select(x => x.tmd.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1023. var rank_hita_duration = tchStickiness.Select(x => x.hita.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1024. var rank_hiteach_duration = tchStickiness.Select(x => x.hiteach.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1025. var rank_ies5Tch_duration = tchStickiness.Select(x => x.ies5Tch.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1026. var rank_otherTch_duration = tchStickiness.Select(x => x.otherTch.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1027. #endregion
  1028. #region
  1029. var rank_tmd_stick = tchStickiness.Select(x => x.tmd.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1030. var rank_hita_stick = tchStickiness.Select(x => x.hita.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1031. var rank_hiteach_stick = tchStickiness.Select(x => x.hiteach.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1032. var rank_ies5Tch_stick = tchStickiness.Select(x => x.ies5Tch.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1033. var rank_otherTch_stick = tchStickiness.Select(x => x.otherTch.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1034. #endregion
  1035. tchStickiness.ForEach(x => {
  1036. #region
  1037. int index_tmd_count = rank_tmd_count.FindIndex(i => i==x.tmd.count.value);
  1038. if (index_tmd_count!=-1)
  1039. {
  1040. x.tmd.count.rank = index_tmd_count + 1;
  1041. }
  1042. int index_hita_count = rank_hita_count.FindIndex(i => i==x.hita.count.value);
  1043. if (index_hita_count!=-1)
  1044. {
  1045. x.hita.count.rank = index_hita_count + 1;
  1046. }
  1047. int index_hiteach_count = rank_hiteach_count.FindIndex(i => i==x.hiteach.count.value);
  1048. if (index_hiteach_count!=-1)
  1049. {
  1050. x.hiteach.count.rank = index_hiteach_count + 1;
  1051. }
  1052. int index_ies5Tch_count = rank_ies5Tch_count.FindIndex(i => i==x.ies5Tch.count.value);
  1053. if (index_ies5Tch_count!=-1)
  1054. {
  1055. x.ies5Tch.count.rank = index_ies5Tch_count + 1;
  1056. }
  1057. int index_otherTch_count = rank_otherTch_count.FindIndex(i => i==x.otherTch.count.value);
  1058. if (index_otherTch_count!=-1)
  1059. {
  1060. x.otherTch.count.rank = index_otherTch_count + 1;
  1061. }
  1062. int index_lesson_count = rank_lesson_count.FindIndex(i => i==x.lesson.value);
  1063. if (index_lesson_count!=-1)
  1064. {
  1065. x.lesson.rank = index_lesson_count + 1;
  1066. }
  1067. #endregion
  1068. #region
  1069. int index_tmd_duration = rank_tmd_duration.FindIndex(i => i==x.tmd.duration.value);
  1070. if (index_tmd_duration!=-1)
  1071. {
  1072. x.tmd.duration.rank = index_tmd_duration + 1;
  1073. }
  1074. int index_hita_duration = rank_hita_duration.FindIndex(i => i==x.hita.duration.value);
  1075. if (index_hita_duration!=-1)
  1076. {
  1077. x.hita.duration.rank = index_hita_duration + 1;
  1078. }
  1079. int index_hiteach_duration = rank_hiteach_duration.FindIndex(i => i==x.hiteach.duration.value);
  1080. if (index_hiteach_duration!=-1)
  1081. {
  1082. x.hiteach.duration.rank = index_hiteach_duration + 1;
  1083. }
  1084. int index_ies5Tch_duration = rank_ies5Tch_duration.FindIndex(i => i==x.ies5Tch.duration.value);
  1085. if (index_ies5Tch_duration!=-1)
  1086. {
  1087. x.ies5Tch.duration.rank = index_ies5Tch_duration + 1;
  1088. }
  1089. int index_otherTch_duration = rank_otherTch_duration.FindIndex(i => i==x.otherTch.duration.value);
  1090. if (index_otherTch_duration!=-1)
  1091. {
  1092. x.otherTch.duration.rank = index_otherTch_duration + 1;
  1093. }
  1094. #endregion
  1095. #region
  1096. int index_tmd_stick = rank_tmd_stick.FindIndex(i => i==x.tmd.stick.value);
  1097. if (index_tmd_stick!=-1)
  1098. {
  1099. x.tmd.stick.rank = index_tmd_stick + 1;
  1100. }
  1101. int index_hita_stick = rank_hita_stick.FindIndex(i => i==x.hita.stick.value);
  1102. if (index_hita_stick!=-1)
  1103. {
  1104. x.hita.stick.rank = index_hita_stick + 1;
  1105. }
  1106. int index_hiteach_stick = rank_hiteach_stick.FindIndex(i => i==x.hiteach.stick.value);
  1107. if (index_hiteach_stick!=-1)
  1108. {
  1109. x.hiteach.stick.rank = index_hiteach_stick + 1;
  1110. }
  1111. int index_ies5Tch_stick = rank_ies5Tch_stick.FindIndex(i => i==x.ies5Tch.stick.value);
  1112. if (index_ies5Tch_stick!=-1)
  1113. {
  1114. x.ies5Tch.stick.rank = index_ies5Tch_stick + 1;
  1115. }
  1116. int index_otherTch_stick = rank_otherTch_stick.FindIndex(i => i==x.otherTch.stick.value);
  1117. if (index_otherTch_stick!=-1)
  1118. {
  1119. x.otherTch.stick.rank = index_otherTch_stick + 1;
  1120. }
  1121. #endregion
  1122. });
  1123. return tchStickiness;
  1124. }
  1125. private static List<SchoolStick> OrderBySchoolStick(List<SchoolStick> schoolStickiness)
  1126. {
  1127. // 假设visit已经填充了数据
  1128. #region
  1129. var rank_tmd_count = schoolStickiness.Select(x => x.tmd.count.value).Distinct().OrderByDescending(v => v).ToList();
  1130. var rank_hita_count = schoolStickiness.Select(x => x.hita.count.value).Distinct().OrderByDescending(v => v).ToList();
  1131. var rank_hiteach_count = schoolStickiness.Select(x => x.hiteach.count.value).Distinct().OrderByDescending(v => v).ToList();
  1132. var rank_ies5Tch_count = schoolStickiness.Select(x => x.ies5Tch.count.value).Distinct().OrderByDescending(v => v).ToList();
  1133. var rank_otherTch_count = schoolStickiness.Select(x => x.otherTch.count.value).Distinct().OrderByDescending(v => v).ToList();
  1134. var rank_ies5Stu_count = schoolStickiness.Select(x => x.ies5Stu.count.value).Distinct().OrderByDescending(v => v).ToList();
  1135. var rank_otherStu_count = schoolStickiness.Select(x => x.otherStu.count.value).Distinct().OrderByDescending(v => v).ToList();
  1136. var rank_lesson_count = schoolStickiness.Select(x => x.lesson.value).Distinct().OrderByDescending(v => v).ToList();
  1137. #endregion
  1138. #region
  1139. var rank_tmd_duration = schoolStickiness.Select(x => x.tmd.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1140. var rank_hita_duration = schoolStickiness.Select(x => x.hita.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1141. var rank_hiteach_duration = schoolStickiness.Select(x => x.hiteach.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1142. var rank_ies5Tch_duration = schoolStickiness.Select(x => x.ies5Tch.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1143. var rank_otherTch_duration = schoolStickiness.Select(x => x.otherTch.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1144. var rank_ies5Stu_duration = schoolStickiness.Select(x => x.ies5Stu.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1145. var rank_otherStu_duration = schoolStickiness.Select(x => x.otherStu.duration.value).Distinct().OrderByDescending(v => v).ToList();
  1146. #endregion
  1147. #region
  1148. var rank_tmd_stick = schoolStickiness.Select(x => x.tmd.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1149. var rank_hita_stick = schoolStickiness.Select(x => x.hita.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1150. var rank_hiteach_stick = schoolStickiness.Select(x => x.hiteach.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1151. var rank_ies5Tch_stick = schoolStickiness.Select(x => x.ies5Tch.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1152. var rank_otherTch_stick = schoolStickiness.Select(x => x.otherTch.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1153. var rank_ies5Stu_stick = schoolStickiness.Select(x => x.ies5Stu.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1154. var rank_otherStu_stick = schoolStickiness.Select(x => x.otherStu.stick.value).Distinct().OrderByDescending(v => v).ToList();
  1155. #endregion
  1156. schoolStickiness.ForEach(x => {
  1157. #region
  1158. if (x.tmd.count.value>0)
  1159. {
  1160. int index_tmd_count = rank_tmd_count.FindIndex(i => i==x.tmd.count.value);
  1161. if (index_tmd_count!=-1)
  1162. {
  1163. x.tmd.count.rank = index_tmd_count + 1;
  1164. }
  1165. }
  1166. if (x.hita.count.value>0)
  1167. {
  1168. int index_hita_count = rank_hita_count.FindIndex(i => i==x.hita.count.value);
  1169. if (index_hita_count!=-1)
  1170. {
  1171. x.hita.count.rank = index_hita_count + 1;
  1172. }
  1173. }
  1174. if (x.hiteach.count.value>0)
  1175. {
  1176. int index_hiteach_count = rank_hiteach_count.FindIndex(i => i==x.hiteach.count.value);
  1177. if (index_hiteach_count!=-1)
  1178. {
  1179. x.hiteach.count.rank = index_hiteach_count + 1;
  1180. }
  1181. }
  1182. if (x.ies5Tch.count.value>0)
  1183. {
  1184. int index_ies5Tch_count = rank_ies5Tch_count.FindIndex(i => i==x.ies5Tch.count.value);
  1185. if (index_ies5Tch_count!=-1)
  1186. {
  1187. x.ies5Tch.count.rank = index_ies5Tch_count + 1;
  1188. }
  1189. }
  1190. if (x.otherTch.count.value>0)
  1191. {
  1192. int index_otherTch_count = rank_otherTch_count.FindIndex(i => i==x.otherTch.count.value);
  1193. if (index_otherTch_count!=-1)
  1194. {
  1195. x.otherTch.count.rank = index_otherTch_count + 1;
  1196. }
  1197. }
  1198. if (x.ies5Stu.count.value>0)
  1199. {
  1200. int index_ies5Stu_count = rank_ies5Stu_count.FindIndex(i => i==x.ies5Stu.count.value);
  1201. if (index_ies5Stu_count!=-1)
  1202. {
  1203. x.ies5Stu.count.rank = index_ies5Stu_count + 1;
  1204. }
  1205. }
  1206. if (x.otherStu.count.value>0)
  1207. {
  1208. int index_otherStu_count = rank_otherStu_count.FindIndex(i => i==x.otherStu.count.value);
  1209. if (index_otherStu_count!=-1)
  1210. {
  1211. x.otherStu.count.rank = index_otherStu_count + 1;
  1212. }
  1213. }
  1214. if (x.lesson.value>0)
  1215. {
  1216. int index_lesson_count = rank_lesson_count.FindIndex(i => i==x.lesson.value);
  1217. if (index_lesson_count!=-1)
  1218. {
  1219. x.lesson.rank = index_lesson_count + 1;
  1220. }
  1221. }
  1222. #endregion
  1223. #region
  1224. if (x.tmd.duration.value>0)
  1225. {
  1226. int index_tmd_duration = rank_tmd_duration.FindIndex(i => i==x.tmd.duration.value);
  1227. if (index_tmd_duration!=-1)
  1228. {
  1229. x.tmd.duration.rank = index_tmd_duration + 1;
  1230. }
  1231. }
  1232. if (x.hita.duration.value>0)
  1233. {
  1234. int index_hita_duration = rank_hita_duration.FindIndex(i => i==x.hita.duration.value);
  1235. if (index_hita_duration!=-1)
  1236. {
  1237. x.hita.duration.rank = index_hita_duration + 1;
  1238. }
  1239. }
  1240. if (x.hiteach.duration.value>0)
  1241. {
  1242. int index_hiteach_duration = rank_hiteach_duration.FindIndex(i => i==x.hiteach.duration.value);
  1243. if (index_hiteach_duration!=-1)
  1244. {
  1245. x.hiteach.duration.rank = index_hiteach_duration + 1;
  1246. }
  1247. }
  1248. if (x.ies5Tch.duration.value>0) {
  1249. int index_ies5Tch_duration = rank_ies5Tch_duration.FindIndex(i => i==x.ies5Tch.duration.value);
  1250. if (index_ies5Tch_duration!=-1)
  1251. {
  1252. x.ies5Tch.duration.rank = index_ies5Tch_duration + 1;
  1253. }
  1254. }
  1255. if (x.otherTch.duration.value>0)
  1256. {
  1257. int index_otherTch_duration = rank_otherTch_duration.FindIndex(i => i==x.otherTch.duration.value);
  1258. if (index_otherTch_duration!=-1)
  1259. {
  1260. x.otherTch.duration.rank = index_otherTch_duration + 1;
  1261. }
  1262. }
  1263. if (x.ies5Stu.duration.value>0)
  1264. {
  1265. int index_ies5Stu_duration = rank_ies5Stu_duration.FindIndex(i => i==x.ies5Stu.duration.value);
  1266. if (index_ies5Stu_duration!=-1)
  1267. {
  1268. x.ies5Stu.duration.rank = index_ies5Stu_duration + 1;
  1269. }
  1270. }
  1271. if (x.otherStu.duration.value>0)
  1272. {
  1273. int index_otherStu_duration = rank_otherStu_duration.FindIndex(i => i==x.otherStu.duration.value);
  1274. if (index_otherStu_duration!=-1)
  1275. {
  1276. x.otherStu.duration.rank = index_otherStu_duration + 1;
  1277. }
  1278. }
  1279. #endregion
  1280. #region
  1281. if (x.tmd.stick.value>0)
  1282. {
  1283. int index_tmd_stick = rank_tmd_stick.FindIndex(i => i==x.tmd.stick.value);
  1284. if (index_tmd_stick!=-1)
  1285. {
  1286. x.tmd.stick.rank = index_tmd_stick + 1;
  1287. }
  1288. }
  1289. if (x.hita.stick.value>0)
  1290. {
  1291. int index_hita_stick = rank_hita_stick.FindIndex(i => i==x.hita.stick.value);
  1292. if (index_hita_stick!=-1)
  1293. {
  1294. x.hita.stick.rank = index_hita_stick + 1;
  1295. }
  1296. }
  1297. if (x.hiteach.stick.value>0)
  1298. {
  1299. int index_hiteach_stick = rank_hiteach_stick.FindIndex(i => i==x.hiteach.stick.value);
  1300. if (index_hiteach_stick!=-1)
  1301. {
  1302. x.hiteach.stick.rank = index_hiteach_stick + 1;
  1303. }
  1304. }
  1305. if (x.ies5Tch.stick.value>0)
  1306. {
  1307. int index_ies5Tch_stick = rank_ies5Tch_stick.FindIndex(i => i==x.ies5Tch.stick.value);
  1308. if (index_ies5Tch_stick!=-1)
  1309. {
  1310. x.ies5Tch.stick.rank = index_ies5Tch_stick + 1;
  1311. }
  1312. }
  1313. if (x.otherTch.stick.value>0)
  1314. {
  1315. int index_otherTch_stick = rank_otherTch_stick.FindIndex(i => i==x.otherTch.stick.value);
  1316. if (index_otherTch_stick!=-1)
  1317. {
  1318. x.otherTch.stick.rank = index_otherTch_stick + 1;
  1319. }
  1320. }
  1321. if (x.ies5Stu.stick.value>0)
  1322. {
  1323. int index_ies5Stu_stick = rank_ies5Stu_stick.FindIndex(i => i==x.ies5Stu.stick.value);
  1324. if (index_ies5Stu_stick!=-1)
  1325. {
  1326. x.ies5Stu.stick.rank = index_ies5Stu_stick + 1;
  1327. }
  1328. }
  1329. if (x.otherStu.stick.value>0)
  1330. {
  1331. int index_otherStu_stick = rank_otherStu_stick.FindIndex(i => i==x.otherStu.stick.value);
  1332. if (index_otherStu_stick!=-1)
  1333. {
  1334. x.otherStu.stick.rank = index_otherStu_stick + 1;
  1335. }
  1336. }
  1337. #endregion
  1338. });
  1339. return schoolStickiness;
  1340. }
  1341. /// <summary>
  1342. /// 结算访问日志
  1343. /// </summary>
  1344. public static async Task<(List<SchoolStick> chinaSchoolStickiness, List<SchoolStick> globalSchoolStickiness)> VisitSettle(List<string> times ,AzureStorageFactory _azureStorage,AzureRedisFactory _azureRedis, Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator, IPSearcher _ipSearcher) {
  1345. List<SchoolStick> chinaSchoolStickiness = new List<SchoolStick>();
  1346. List<SchoolStick> globalSchoolStickiness = new List<SchoolStick>();
  1347. foreach (var timeDate in times)
  1348. {
  1349. List<ApiVisit> apiVisits = new List<ApiVisit>();
  1350. if (DateTimeOffset.TryParse(timeDate, out DateTimeOffset date))
  1351. {
  1352. BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/index.log").DownloadContentAsync();
  1353. var content = result.Content.ToString();
  1354. content= content.Substring(0, content.Length-2);
  1355. if (content.EndsWith("}"))
  1356. {
  1357. content=$"[{content}]";
  1358. }
  1359. else
  1360. {
  1361. content=$"[{content}}}]";
  1362. }
  1363. apiVisits.AddRange(content.ToObject<List<ApiVisit>>());
  1364. var dateNow = DateTimeOffset.Now.GetGMTTime(8);
  1365. if ($"{dateNow:yyyy-MM-dd}".Equals($"{date:yyyy-MM-dd}"))
  1366. { //当前小时一致的
  1367. BlobDownloadResult resultHour = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/{date:HH}.log").DownloadContentAsync();
  1368. var contentHour = resultHour.Content.ToString();
  1369. contentHour= contentHour.Substring(0, contentHour.Length-2);
  1370. if (contentHour.EndsWith("}"))
  1371. {
  1372. contentHour=$"[{contentHour}]";
  1373. }
  1374. else
  1375. {
  1376. contentHour=$"[{contentHour}}}]";
  1377. }
  1378. var httpLog = contentHour.ToObject<List<HttpLog>>();
  1379. (ConcurrentBag<ApiVisit> visits, ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo) = await SystemService.ConvertHttpLog(httpLog, _azureRedis, _ipSearcher, _longitudeLatitudeTranslator, dateNow, false);
  1380. apiVisits.AddRange(visits);
  1381. }
  1382. }
  1383. //大陆学校
  1384. var chinaApiVisits = apiVisits.Where(x => x.hostName.Equals("大陆站"));
  1385. var chinaSchoolVisits = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.school) && x.hostName.Equals("大陆站")).GroupBy(x => x.school);
  1386. List<SchoolStick> chinaStickiness = CountSchoolStickiness(chinaSchoolVisits, chinaApiVisits);
  1387. chinaSchoolStickiness.AddRange(chinaStickiness);
  1388. //国际学校
  1389. var globalApiVisits = apiVisits.Where(x => x.hostName.Equals("国际站"));
  1390. var globalSchoolVisits = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.school) && x.hostName.Equals("国际站")).GroupBy(x => x.school);
  1391. List<SchoolStick> globalStickiness = CountSchoolStickiness(globalSchoolVisits, globalApiVisits);
  1392. globalSchoolStickiness.AddRange(globalStickiness);
  1393. }
  1394. return (chinaSchoolStickiness, globalSchoolStickiness);
  1395. }
  1396. public static async Task<(ConcurrentBag<ApiVisit> visits, ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo)>
  1397. ConvertHttpLog(List<HttpLog> logs, AzureRedisFactory _azureRedis, IPSearcher _ipSearcher, Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator, DateTimeOffset gmt8Time, bool test = false)
  1398. {
  1399. ConcurrentBag<ApiVisit> visits = new ConcurrentBag<ApiVisit>();
  1400. ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo = new ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
  1401. object lockObj = new object();
  1402. await Parallel.ForEachAsync(logs, async (log, _) =>
  1403. {
  1404. if (!log.path.Contains("."))
  1405. {
  1406. string uuid = Guid.NewGuid().ToString();
  1407. List<string> schoolMatch = new List<string>();
  1408. List<string> useridMatch = new List<string>();
  1409. var vist = new ApiVisit()
  1410. {
  1411. id=uuid,
  1412. ip=log.ip,
  1413. tid=log.tid,
  1414. time= log.time,
  1415. userId= log.id,
  1416. school= log.school,
  1417. tname= log.name,
  1418. path = log.path,
  1419. client=log.p.Equals("os", StringComparison.OrdinalIgnoreCase) ? "ies5" : log.p,
  1420. scope=log.scope,
  1421. host= log.host,
  1422. hostName=log.hostName,
  1423. l=log.l,
  1424. year = $"{gmt8Time:yyyy}",
  1425. month = $"{gmt8Time:MM}",
  1426. day = $"{gmt8Time:dd}",
  1427. hour =$"{gmt8Time:HH}"
  1428. };
  1429. if (test)
  1430. {
  1431. var time = DateTimeOffset.FromUnixTimeMilliseconds(log.time);
  1432. //本地调试时间
  1433. if (vist.ip.Equals("0.0.0.1"))
  1434. {
  1435. time= time.AddHours(8);
  1436. }
  1437. vist.year = $"{time:yyyy}";
  1438. vist.month = $"{time:MM}";
  1439. vist.day = $"{time:dd}";
  1440. vist.hour =$"{time:HH}";
  1441. }
  1442. if (string.IsNullOrWhiteSpace(vist.userId))
  1443. {
  1444. //var jsonPathContext = new JsonPathContext();
  1445. //jsonPathContext.ValueSystem= new JsonTextValueSystem();
  1446. string path = "$..['id_token','idToken','idtoken','tmdid','id','teacherId','teacher','tid','tId','userid','userId','code','studentId','student','studentid']";
  1447. if (!log.param.ValueKind.Equals(JsonValueKind.Null)) {
  1448. JObject jsonObject = JObject.Parse(log.param.GetRawText());
  1449. //var nodes_path = jsonPathContext.SelectNodes(log.param, path);
  1450. var nodes_path = jsonObject.SelectTokens(path);
  1451. foreach (var node in nodes_path)
  1452. {
  1453. // 只获取是字符串的
  1454. if (node.Type.Equals(JTokenType.String))
  1455. {
  1456. switch (true)
  1457. {
  1458. case bool when node.Path.Contains("id_token")||node.Path.Contains("idToken")||node.Path.Contains("idtoken"):
  1459. {
  1460. try
  1461. {
  1462. var jwt = new JwtSecurityToken($"{node}");
  1463. string id = jwt.Payload.Sub;
  1464. var name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
  1465. if (!string.IsNullOrWhiteSpace(id) && long.TryParse(id, out long _id))
  1466. {
  1467. vist.userId=id;
  1468. vist.scope="teacher";
  1469. vist.tname=name;
  1470. useridMatch.Add(id);
  1471. }
  1472. }
  1473. catch (Exception ex) { }
  1474. break;
  1475. }
  1476. case bool when node.Path.Contains("tmdid")||node.Path.Contains("id")||node.Path.Contains("teacherId")
  1477. ||node.Path.Contains("teacher")||node.Path.Contains("tid")||node.Path.Contains("tId")||node.Path.Contains("userid")
  1478. ||node.Path.Contains("userId"):
  1479. {
  1480. if (!string.IsNullOrWhiteSpace($"{node}") && long.TryParse($"{node}", out long _id))
  1481. {
  1482. vist.userId=$"{node}";
  1483. vist.scope="teacher";
  1484. useridMatch.Add($"{node}");
  1485. }
  1486. break;
  1487. }
  1488. case bool when node.Path.Contains("studentId")||node.Path.Contains("student")||node.Path.Contains("studentid"):
  1489. {
  1490. if (!string.IsNullOrWhiteSpace($"{node}") && long.TryParse($"{node}", out long _id))
  1491. {
  1492. vist.userId=$"{node}";
  1493. vist.scope="student";
  1494. useridMatch.Add($"{node}");
  1495. }
  1496. break;
  1497. }
  1498. case bool when node.Path.Contains("code"):
  1499. {
  1500. if (!string.IsNullOrWhiteSpace($"{node}"))
  1501. {
  1502. if (long.TryParse($"{node}", out long _id))
  1503. {
  1504. vist.userId=$"{node}";
  1505. useridMatch.Add($"{node}");
  1506. }
  1507. else
  1508. {
  1509. string[] codes = $"{node}".Split("-");
  1510. foreach (var _code in codes)
  1511. {
  1512. if (long.TryParse(_code, out long _codeid))
  1513. {
  1514. vist.userId=$"{node}";
  1515. useridMatch.Add($"{_code}");
  1516. break;
  1517. }
  1518. }
  1519. }
  1520. }
  1521. break;
  1522. }
  1523. }
  1524. }
  1525. }
  1526. if (log.path.Contains("process-notify", StringComparison.OrdinalIgnoreCase))
  1527. {
  1528. string s = log.param.ToJsonString().Replace("\\", "");
  1529. Regex regextmdid = new Regex("\"tmdid\":\"(\\d+)\"");
  1530. Match matchtmdid = regextmdid.Match(s);
  1531. if (matchtmdid.Success)
  1532. {
  1533. var t = matchtmdid.Groups[1].Value;
  1534. if (!string.IsNullOrWhiteSpace(t))
  1535. {
  1536. vist.userId=t;
  1537. vist.scope="teacher";
  1538. useridMatch.Add(t);
  1539. }
  1540. }
  1541. Regex regexname = new Regex("\"tmdname\":\"(.+?)\"");
  1542. Match matchname = regexname.Match(s);
  1543. if (matchname.Success)
  1544. {
  1545. var t = matchname.Groups[1].Value;
  1546. if (!string.IsNullOrWhiteSpace(t))
  1547. {
  1548. vist.tname=t;
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. else
  1555. {
  1556. if (string.IsNullOrWhiteSpace($"{vist.scope}"))
  1557. {
  1558. vist.scope="teacher";
  1559. uuidInfo.Add((uuid, log, new List<string>() { vist.userId }, new List<string>()));
  1560. }
  1561. }
  1562. if (string.IsNullOrWhiteSpace(vist.school) || vist.school.Equals("true") || vist.school.Equals("false"))
  1563. {
  1564. vist.school="";
  1565. string path = "$..['school','id','schoolId','schoolid','schoolCode','school_code','schoolcode','code']";
  1566. if (!log.param.ValueKind.Equals(JsonValueKind.Null)) {
  1567. JObject jsonObject = JObject.Parse(log.param.GetRawText());
  1568. var nodes_path = jsonObject.SelectTokens(path);
  1569. foreach (var node in nodes_path)
  1570. {
  1571. // 只获取是字符串的
  1572. if (node.Type.Equals(JTokenType.String))
  1573. {
  1574. switch (true)
  1575. {
  1576. case bool when node.Path.Contains("school")||node.Path.Contains("id")||node.Path.Contains("schoolId")
  1577. ||node.Path.Contains("schoolid")||node.Path.Contains("schoolCode")||node.Path.Contains("school_code")||node.Path.Contains("schoolcode"):
  1578. {
  1579. if (!$"{node}".Contains("-")&& $"{node}".Length<=8 && $"{node}".Length>=1)
  1580. {
  1581. vist.school=$"{node}";
  1582. schoolMatch.Add($"{node}");
  1583. }
  1584. break;
  1585. }
  1586. case bool when node.Path.Contains("code"):
  1587. {
  1588. if (!$"{node}".Contains("-")&& $"{node}".Length<=8&& $"{node}".Length>=1)
  1589. {
  1590. vist.school=$"{node}";
  1591. schoolMatch.Add($"{node}");
  1592. }
  1593. else
  1594. {
  1595. string[] codes = $"{node}".Split("-");
  1596. foreach (var _code in codes)
  1597. {
  1598. if ($"{_code}".Length<=8 && $"{_code}".Length>=1)
  1599. {
  1600. vist.school=$"{_code}";
  1601. schoolMatch.Add($"{_code}");
  1602. break;
  1603. }
  1604. }
  1605. }
  1606. break;
  1607. }
  1608. }
  1609. }
  1610. }
  1611. if (log.path.Contains("process-notify", StringComparison.OrdinalIgnoreCase))
  1612. {
  1613. string s = log.param.ToJsonString().Replace("\\", "");
  1614. Regex regexname = new Regex("\"schoolId\":\"(.+?)\"");
  1615. Match matchname = regexname.Match(s);
  1616. if (matchname.Success)
  1617. {
  1618. var t = matchname.Groups[1].Value;
  1619. if (!string.IsNullOrWhiteSpace(t))
  1620. {
  1621. vist.school=t;
  1622. }
  1623. }
  1624. }
  1625. }
  1626. }
  1627. //处理 client
  1628. {
  1629. if (!string.IsNullOrWhiteSpace(log.client))
  1630. {
  1631. if (log.client.Equals("IES", StringComparison.OrdinalIgnoreCase))
  1632. {
  1633. vist.client="ies5";
  1634. }
  1635. if (log.client.Equals("AClassONE", StringComparison.OrdinalIgnoreCase))
  1636. {
  1637. vist.client="aclassone";
  1638. }
  1639. if (log.client.Equals("BB", StringComparison.OrdinalIgnoreCase))
  1640. {
  1641. vist.client="habb";
  1642. }
  1643. if (log.client.Equals("HiTool", StringComparison.OrdinalIgnoreCase) ||log.client.Equals("HiTools", StringComparison.OrdinalIgnoreCase))
  1644. {
  1645. vist.client="hiscan";
  1646. }
  1647. if (log.client.Equals("HiTA", StringComparison.OrdinalIgnoreCase))
  1648. {
  1649. vist.client="hita";
  1650. vist.scope="teacher";
  1651. }
  1652. if (log.client.Equals("HiTeachCC", StringComparison.OrdinalIgnoreCase))
  1653. {
  1654. vist.client="hiteachcc";
  1655. }
  1656. if (log.client.Equals("HiTeach", StringComparison.OrdinalIgnoreCase))
  1657. {
  1658. vist.scope="teacher";
  1659. vist.client="hiteach";
  1660. }
  1661. if (log.client.Equals("Open", StringComparison.OrdinalIgnoreCase))
  1662. {
  1663. vist.client="open";
  1664. }
  1665. }
  1666. }
  1667. //补全站点
  1668. {
  1669. if (
  1670. (log.host.Equals("wwww.teammodel.net")||log.host.Equals("ies5-rc.teammodel.net")))
  1671. {
  1672. vist.hostName="国际站";
  1673. vist.host="www.teammodel.net";
  1674. vist.client="ies5";
  1675. vist.l="Global";
  1676. }
  1677. else if (
  1678. log.host.Equals("teammodelos-yx.chinacloudsites.cn")||log.host.Equals("teammodelos.chinacloudsites.cn")
  1679. ||log.host.Equals("yx.teammodel.cn")||log.host.Equals("teammodelos-rc.chinacloudsites.cn")||log.host.Equals("rc.teammodel.cn")|| log.host.Equals("www.teammodel.cn"))
  1680. {
  1681. vist.hostName="大陆站";
  1682. vist.host="www.teammodel.cn";
  1683. vist.client="ies5"; vist.l="China";
  1684. }
  1685. else if ((log.host.Contains("localhost") && log.p.Equals("os"))|| log.host.Equals("teammodelos-test.chinacloudsites.cn") ||log.host.Equals("test.teammodel.cn"))
  1686. {
  1687. vist.hostName="测试站";
  1688. vist.host="test.teammodel.cn";
  1689. vist.client="ies5";
  1690. vist.l="China";
  1691. }
  1692. else if (
  1693. (log.host.Equals("scyx.teammodel.cn") ||log.host.Equals("jinniu.teammodel.cn")))
  1694. {
  1695. vist.hostName="研修2.0";
  1696. vist.host="scyx.teammodel.cn";
  1697. vist.client="ability"; vist.l="China";
  1698. }
  1699. else if (
  1700. log.host.Equals("open.teammodel.cn")||log.host.Equals("open-test.teammodel.cn") ||log.host.Equals("zhiyin-test.teammodel.cn"))
  1701. {
  1702. vist.hostName="开放平台";
  1703. vist.host="open.teammodel.cn";
  1704. vist.client="open";
  1705. vist.l="China";
  1706. }
  1707. else if ((log.host.Equals("bi-rc.teammodel.net") || log.host.Equals("bi.teammodel.net")))
  1708. {
  1709. vist.hostName="国际站";
  1710. vist.host="bi.teammodel.net";
  1711. vist.client="bi";
  1712. vist.scope="admin";
  1713. vist.l="Global";
  1714. }
  1715. else if (log.host.Equals("teammodelbi.chinacloudsites.cn") ||log.host.Equals("bi.teammodel.cn"))
  1716. {
  1717. vist.hostName="大陆站";
  1718. vist.host="bi.teammodel.cn";
  1719. vist.client="bi";
  1720. vist.scope="admin";
  1721. vist.l="China";
  1722. }
  1723. else if (log.host.Equals("bitest.teammodel.cn")||log.host.Equals("teammodelbi-test.chinacloudsites.cn")||(log.host.Contains("localhost") && (log.p.Equals("bi"))))
  1724. {
  1725. vist.hostName="测试站";
  1726. vist.host="testbi.teammodel.cn";
  1727. vist.client="bi";
  1728. vist.scope="admin";
  1729. vist.l="China";
  1730. }
  1731. else if (
  1732. log.host.Equals("teamcontest.chinacloudsites.cn")||log.host.Equals("contest.chinacloudsites.cn")||log.host.Equals("contest-test.chinacloudsites.cn"))
  1733. {
  1734. vist.hostName="大陆站";
  1735. vist.host="contest.teammodel.cn";
  1736. vist.client="contest"; vist.l="China";
  1737. }
  1738. else if (
  1739. log.host.Equals("hiteachcc.chinacloudsites.cn"))
  1740. {
  1741. vist.hostName="正式站";
  1742. vist.host="hiteachcc.teammodel.cn";
  1743. vist.client="hiteachcc";
  1744. vist.l="China";
  1745. }
  1746. else if (log.host.Equals("appraisal.chinacloudsites.cn"))
  1747. {
  1748. vist.hostName="大陆站";
  1749. vist.host="appraisal.teammodel.cn";
  1750. vist.client="appraisal";
  1751. vist.l="China";
  1752. }
  1753. else if ((log.host.Contains("localhost") && log.p.Equals("appraisal"))||log.host.Equals("appraisal-test.teammodel.cn") ||log.host.Equals("appraisal-test.chinacloudsites.cn"))
  1754. {
  1755. vist.hostName="测试站";
  1756. vist.host="appraisal-test.teammodel.cn";
  1757. vist.client="appraisal";
  1758. vist.l="China";
  1759. }
  1760. else
  1761. {
  1762. if (!string.IsNullOrWhiteSpace(log.p))
  1763. {
  1764. vist.client=log.p.Equals("os", StringComparison.OrdinalIgnoreCase) ? "ies5" : log.p;
  1765. }
  1766. else
  1767. {
  1768. vist.client="other";
  1769. }
  1770. if (log.host.EndsWith(".cn"))
  1771. {
  1772. vist.hostName="大陆站";
  1773. vist.l="China";
  1774. }
  1775. else if (log.host.EndsWith(".net"))
  1776. {
  1777. vist.hostName="国际站";
  1778. vist.l="Global";
  1779. }
  1780. else
  1781. {
  1782. vist.hostName="其他";
  1783. vist.l="其他";
  1784. }
  1785. }
  1786. }
  1787. //补全产品端
  1788. {
  1789. //研修2.0
  1790. if (log.path.Contains("research") || log.path.Contains("study") || log.path.Contains("standard-file"))
  1791. {
  1792. vist.client="ability";
  1793. }
  1794. if (log.path.Contains("teacher"))
  1795. {
  1796. vist.scope="teacher";
  1797. }
  1798. if (log.path.Contains("tmduser"))
  1799. {
  1800. vist.scope=Constant.ScopeTmdUser;
  1801. }
  1802. if (log.path.Contains("student/login"))
  1803. {
  1804. vist.scope=Constant.ScopeStudent;
  1805. }
  1806. if (log.path.StartsWith("/activity"))
  1807. {
  1808. vist.client="contest";
  1809. }
  1810. //小程序
  1811. if (log.path.Contains("aclassone"))
  1812. {
  1813. vist.client="aclassone";
  1814. }
  1815. // /// <summary>
  1816. /// ExamInfo qamode 書面問答類型 0:書面問答 1:紙本測驗 2:艺术评测
  1817. /// </summary>
  1818. //艺术评测
  1819. if (log.path.Contains("art") ||log.path.Contains("aclassone/find-children-activity") ||log.path.Contains("aclassone/find-teacher-activity") ||log.path.Contains("aclassone/find-summary-activity") ||log.path.Contains("aclassone/upload-all") ||log.path.Contains("aclassone/delete"))
  1820. {
  1821. vist.client="art";
  1822. }
  1823. if (log.path.Contains("common/exam/upsert-record"))
  1824. {
  1825. JObject jobject = JObject.Parse(log.param.GetRawText());
  1826. var jtokens = jobject.SelectTokens("$..artId");
  1827. if (jtokens!=null && jtokens.Count()>0)
  1828. {
  1829. vist.client="art";
  1830. vist.scope=Constant.ScopeStudent;
  1831. }
  1832. }
  1833. if (log.path.Contains("habb"))
  1834. {
  1835. vist.client="habb";
  1836. }
  1837. //阅卷客户端
  1838. if (log.path.Contains("hiscan"))
  1839. {
  1840. vist.client="hiscan";
  1841. }
  1842. if (log.path.Contains("hita"))
  1843. {
  1844. vist.client="hita";
  1845. }
  1846. if (log.path.Contains("hiteachcc"))
  1847. {
  1848. vist.client="hiteachcc";
  1849. }
  1850. if (log.path.Contains("sokrate"))
  1851. {
  1852. vist.client="sokrate";
  1853. }
  1854. if (log.path.Contains("sokrate") || log.path.Contains("score"))
  1855. {
  1856. vist.client="sokrate";
  1857. }
  1858. if (log.path.Contains("hiteach"))
  1859. {
  1860. vist.client="hiteach";
  1861. }
  1862. ///IES开放平台
  1863. if (log.path.Contains("business") || log.path.Contains("biz") || log.path.Contains("openapi-config") || log.path.Contains("open-api"))
  1864. {
  1865. vist.client="open";
  1866. }
  1867. //从token的role 能否获取 开放平台
  1868. //单点登录及第三方接口
  1869. if (log.path.Contains("lepei") || log.path.Contains("sc/") || log.path.Contains("/sso") || log.path.Contains("sc-init")|| log.path.Contains("moofen") || log.path.Contains("data-push") || log.path.Contains("xkw")|| log.path.Contains("tianbo")
  1870. || log.path.Contains("oauth/check-bind")|| log.path.Contains("dingding") || log.path.Contains("wechat")
  1871. )
  1872. {
  1873. vist.client="sso-third";
  1874. }
  1875. }
  1876. //处理IP转地区
  1877. var region = await _ipSearcher.SearchIpAsync(vist.ip);
  1878. if (string.IsNullOrWhiteSpace(region))
  1879. {
  1880. region="未知IP·未知IP·未知IP";
  1881. }
  1882. if (!string.IsNullOrWhiteSpace(region))
  1883. {
  1884. region= region.Replace("省·", "·").Replace("市·", "·").Replace("特别行政区·", "·").Replace("藏族羌族自治州·", "·");
  1885. var regions = region.Split("·");
  1886. if (regions.Length==4)
  1887. {
  1888. vist.area= regions[0];
  1889. vist.province = regions[1];
  1890. vist.city = regions[2];
  1891. }
  1892. if (regions.Length==3)
  1893. {
  1894. vist.area= regions[0];
  1895. vist.province = regions[1];
  1896. }
  1897. if (regions.Length==2)
  1898. {
  1899. vist.area= regions[0];
  1900. vist.province = regions[1];
  1901. }
  1902. if (regions.Length==1)
  1903. {
  1904. vist.area= regions[0];
  1905. }
  1906. }
  1907. //处理地区转经纬度
  1908. {
  1909. IEnumerable<JToken> tokens = default;
  1910. if (!string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
  1911. {
  1912. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i && @.city=~ /.*{vist.city}/i)]");
  1913. if (!(tokens.Any() && tokens.Count()>0))
  1914. {
  1915. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i && @.city=~ /.*{vist.province}/i)]");
  1916. if (!(tokens.Any() && tokens.Count()>0))
  1917. {
  1918. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i || @.city=~ /.*{vist.city}/i)]");
  1919. }
  1920. if (!(tokens.Any() && tokens.Count()>0))
  1921. {
  1922. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i||@.city=~ /.*{vist.province}/i)]");
  1923. }
  1924. }
  1925. }
  1926. else if (string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
  1927. {
  1928. if (vist.area.Equals("中国"))
  1929. {
  1930. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i)]");
  1931. if (!(tokens.Any() && tokens.Count()>0))
  1932. {
  1933. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i)]");
  1934. }
  1935. }
  1936. else
  1937. {
  1938. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i || @.province=~ /.*{vist.province}/i)]");
  1939. }
  1940. }
  1941. else if (!string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
  1942. {
  1943. if (vist.area.Equals("中国"))
  1944. {
  1945. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i)]");
  1946. if (!(tokens.Any() && tokens.Count()>0))
  1947. {
  1948. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i)]");
  1949. }
  1950. }
  1951. else
  1952. {
  1953. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.city}/i || @.city=~ /.*{vist.province}/i)]");
  1954. }
  1955. }
  1956. else if (string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
  1957. {
  1958. tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.country=~ /.*{vist.area}/i && @.m=='1')]");
  1959. }
  1960. if (tokens!=null && tokens.Any())
  1961. {
  1962. List<RegionLngLat> regionLngLats = new List<RegionLngLat>();
  1963. foreach (JToken token in tokens)
  1964. {
  1965. regionLngLats.Add(token.ToString().ToObject<RegionLngLat>());
  1966. }
  1967. var points = regionLngLats.FindAll(x => string.IsNullOrWhiteSpace(x.area));
  1968. if (!points.IsNotEmpty())
  1969. {
  1970. points= regionLngLats.FindAll(x => !string.IsNullOrWhiteSpace(x.m) && x.m.Equals("1"));
  1971. }
  1972. if (string.IsNullOrWhiteSpace(vist.city))
  1973. {
  1974. vist.city=points?.FirstOrDefault()?.city;
  1975. if (!string.IsNullOrWhiteSpace(vist.city) && vist.city.EndsWith("市"))
  1976. {
  1977. vist.city=vist.city.Replace("市", "");
  1978. }
  1979. }
  1980. vist.lat=points?.FirstOrDefault()?.lat;
  1981. vist.lng=points?.FirstOrDefault()?.lng;
  1982. }
  1983. else
  1984. {
  1985. if (vist.area.Equals("内网IP"))
  1986. {
  1987. if (vist.host.Contains(".cn") || vist.host.Contains("localhost"))
  1988. {
  1989. vist.lat="30.655821878416408";
  1990. vist.lng="104.08153351042463";
  1991. vist.area="中国";
  1992. vist.province="四川";
  1993. vist.city="成都";
  1994. }
  1995. else
  1996. {
  1997. vist.lat="25.044332";
  1998. vist.lng="121.509062";
  1999. vist.area="中国";
  2000. vist.province="台湾";
  2001. vist.city="台湾";
  2002. }
  2003. }
  2004. else
  2005. {
  2006. vist.lat="30.655821878416408";
  2007. vist.lng="104.08153351042463";
  2008. vist.area="中国";
  2009. vist.province="四川";
  2010. vist.city="成都";
  2011. }
  2012. }
  2013. }
  2014. uuidInfo.Add((uuid, log, useridMatch, schoolMatch));
  2015. visits.Add(vist);
  2016. }
  2017. }
  2018. );
  2019. List<(string tmd, bool exists, string scope)> tmdexists = new List<(string tmd, bool exists, string scope)>();
  2020. List<(string sch, bool exists)> schexists = new List<(string sch, bool exists)>();
  2021. var tmds = uuidInfo.SelectMany(x => x.tmdid).ToHashSet();
  2022. if (tmds.Any())
  2023. {
  2024. foreach (var tmd in tmds)
  2025. {
  2026. var exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Blob:Catalog:{tmd}");
  2027. if (exists)
  2028. {
  2029. tmdexists.Add((tmd, exists, "teacher"));
  2030. }
  2031. else
  2032. {
  2033. exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Login:School:hbcn:student:{tmd}");
  2034. tmdexists.Add((tmd, exists, "student"));
  2035. }
  2036. }
  2037. }
  2038. var schs = uuidInfo.SelectMany(x => x.school).ToHashSet();
  2039. if (schs.Any())
  2040. {
  2041. foreach (var sch in schs)
  2042. {
  2043. var exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Blob:Catalog:{sch}");
  2044. schexists.Add((sch, exists));
  2045. }
  2046. }
  2047. foreach (var item in uuidInfo)
  2048. {
  2049. foreach (var tmd in item.tmdid)
  2050. {
  2051. var tmdext = tmdexists.Find(x => x.tmd.Equals(tmd));
  2052. if (tmdext.tmd!= null && tmdext.exists)
  2053. {
  2054. var vist = visits.Where(x => x.id.Equals(item.uuid));
  2055. foreach (var vi in vist)
  2056. {
  2057. vi.userId=tmd;
  2058. if (string.IsNullOrWhiteSpace(vi.scope))
  2059. {
  2060. vi.scope=tmdext.scope;
  2061. }
  2062. }
  2063. break;
  2064. }
  2065. }
  2066. foreach (var sch in item.school)
  2067. {
  2068. var schext = schexists.Find(x => x.sch.Equals(sch));
  2069. if (schext.sch!= null && schext.exists)
  2070. {
  2071. var vist = visits.Where(x => x.id.Equals(item.uuid));
  2072. foreach (var vi in vist)
  2073. {
  2074. vi.school=sch;
  2075. }
  2076. break;
  2077. }
  2078. }
  2079. }
  2080. return (visits, uuidInfo);
  2081. }
  2082. public class ApiVisit
  2083. {
  2084. public string id { get; set; }
  2085. public string path { get; set; }
  2086. /// <summary>
  2087. /// 细分
  2088. /// ies5 ,hiteach,hita,cc,bi,contest,open,aclassone,sokrates,ability,art
  2089. /// 产品端
  2090. /// </summary>
  2091. public string client { get; set; }
  2092. /// <summary>
  2093. /// 具体功能
  2094. /// </summary>
  2095. // public string func { get; set; }
  2096. public string userId { get; set; }
  2097. public string scope { get; set; }
  2098. public string tname { get; set; }
  2099. public string school { get; set; }
  2100. public string ip { get; set; }
  2101. //public string region { get; set; }
  2102. public string area { get; set; }
  2103. public string province { get; set; }
  2104. public string city { get; set; } = "";
  2105. public long time { get; set; }
  2106. /// <summary>
  2107. ///
  2108. /// </summary>
  2109. public string host { get; set; }
  2110. public string hostName { get; set; } = "其他";
  2111. /// <summary>
  2112. /// tokenid
  2113. /// </summary>
  2114. public string tid { get; set; }
  2115. public string year { get; set; }
  2116. public string month { get; set; }
  2117. public string day { get; set; }
  2118. public string hour { get; set; }
  2119. //public RegionLngLat point { get; set; }
  2120. public string lat { get; set; }
  2121. public string lng { get; set; }
  2122. public string l { get; set; }
  2123. }
  2124. public class HttpLog
  2125. {
  2126. public string ip { get; set; }
  2127. public long time { get; set; }
  2128. public string host { get; set; }
  2129. public string hostName = "其他";
  2130. public string tid { get; set; }
  2131. public string path { get; set; }
  2132. public string client { get; set; }
  2133. public JsonElement param { get; set; }
  2134. public string id { get; set; }
  2135. public string name { get; set; }
  2136. public string school { get; set; }
  2137. public string p { get; set; }
  2138. // public string ua { get; set; }
  2139. // public string referer { get; set; }
  2140. public string scope { get; set; }
  2141. public string year { get; set; }
  2142. public string month { get; set; }
  2143. public string day { get; set; }
  2144. public string hour { get; set; }
  2145. public string l { get; set; }
  2146. }
  2147. public record RegionLngLat
  2148. {
  2149. public string country { get; set; }
  2150. public string province { get; set; }
  2151. public string city { get; set; }
  2152. public string lat { get; set; }
  2153. public string lng { get; set; }
  2154. public string area { get; set; }
  2155. public string m { get; set; } = "0";
  2156. }
  2157. public class CountData
  2158. {
  2159. public string pk { get; set; } = "";
  2160. public string sk { get; set; } = "";
  2161. public string sp { get; set; } = "";
  2162. public int count { get; set; }
  2163. }
  2164. public class SchoolStick
  2165. {
  2166. /// <summary>
  2167. /// 名字
  2168. /// </summary>
  2169. public string name { get; set; }
  2170. public string picture { get; set; }
  2171. /// <summary>
  2172. /// 编码
  2173. /// </summary>
  2174. public string id { get; set; }
  2175. public string last { get; set; }
  2176. #region tmd
  2177. public ClientStick tmd { get; set; } = new ClientStick();
  2178. #endregion
  2179. #region hiteach
  2180. public ClientStick hiteach { get; set; } = new ClientStick();
  2181. public Indicator lesson { get; set; } = new Indicator();
  2182. #endregion
  2183. #region hita
  2184. public ClientStick hita { get; set; } = new ClientStick();
  2185. #endregion
  2186. #region ies5Teacher
  2187. public ClientStick ies5Tch { get; set; } = new ClientStick();
  2188. #endregion
  2189. #region otherTeacher
  2190. public ClientStick otherTch { get; set; } = new ClientStick();
  2191. #endregion
  2192. #region ies5Student
  2193. public ClientStick ies5Stu { get; set; } = new ClientStick();
  2194. #endregion
  2195. #region otherStudent
  2196. public ClientStick otherStu { get; set; } = new ClientStick();
  2197. #endregion
  2198. public List<TchStick> tchSticks { get; set; } = new List<TchStick>();
  2199. public List<StuStick> stuSticks { get; set; } = new List<StuStick>();
  2200. }
  2201. public class TchStick {
  2202. public string school { get; set; }
  2203. /// <summary>
  2204. /// 名字
  2205. /// </summary>
  2206. public string name { get; set; }
  2207. public string picture { get; set; }
  2208. /// <summary>
  2209. /// 编码
  2210. /// </summary>
  2211. public string id { get; set; }
  2212. public string last { get; set; }
  2213. #region tmd
  2214. public ClientStick tmd { get; set; } = new ClientStick();
  2215. #endregion
  2216. #region hiteach
  2217. public ClientStick hiteach { get; set; } = new ClientStick();
  2218. public Indicator lesson { get; set; } = new Indicator();
  2219. #endregion
  2220. #region hita
  2221. public ClientStick hita { get; set; } = new ClientStick();
  2222. #endregion
  2223. #region ies5Teacher
  2224. public ClientStick ies5Tch { get; set; } = new ClientStick();
  2225. #endregion
  2226. #region otherTeacher
  2227. public ClientStick otherTch { get; set; } = new ClientStick();
  2228. #endregion
  2229. }
  2230. public class StuStick
  2231. {
  2232. public string school { get; set; }
  2233. /// <summary>
  2234. /// 名字
  2235. /// </summary>
  2236. public string name { get; set; }
  2237. public string picture { get; set; }
  2238. /// <summary>
  2239. /// 编码
  2240. /// </summary>
  2241. public string id { get; set; }
  2242. public string last { get; set; }
  2243. #region tmd
  2244. public ClientStick tmd { get; set; } = new ClientStick();
  2245. #endregion
  2246. #region ies5Student
  2247. public ClientStick ies5Stu { get; set; } = new ClientStick();
  2248. #endregion
  2249. #region otherStudent
  2250. public ClientStick otherStu { get; set; } = new ClientStick();
  2251. #endregion
  2252. }
  2253. public class ClientStick
  2254. {
  2255. public int userCount { get; set; }
  2256. public Indicator stick { get; set; } = new Indicator();
  2257. public Indicator duration { get; set; } = new Indicator();
  2258. public Indicator count { get; set; } = new Indicator();
  2259. }
  2260. public class Indicator
  2261. {
  2262. /// <summary>
  2263. /// 值
  2264. /// </summary>
  2265. public double value { get; set; } = 0;
  2266. /// <summary>
  2267. /// 值的增减浮动
  2268. /// </summary>
  2269. public double range { get; set; } = 0;
  2270. /// <summary>
  2271. /// 排名
  2272. /// </summary>
  2273. public double rank { get; set; } = 0;
  2274. /// <summary>
  2275. /// 排名的上升下降
  2276. /// </summary>
  2277. public double updown { get; set; } = 0;
  2278. }
  2279. }
  2280. }