SystemService.cs 127 KB

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