123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686 |
- using Azure.Storage.Blobs.Models;
- using Microsoft.Extensions.Configuration;
- using Newtonsoft.Json.Linq;
- using StackExchange.Redis;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.IdentityModel.Tokens.Jwt;
- using System.Linq;
- using System.Net.Http;
- using System.Net.Http.Json;
- using System.Text;
- using System.Text.Json;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK.Models.Dtos;
- using static TEAMModelOS.SDK.CoreAPIHttpService;
- using Microsoft.Azure.Cosmos;
- using System.Collections;
- using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
- using System.Globalization;
- using Microsoft.OData;
- using System.Configuration;
- using System.ServiceModel.Channels;
- using static System.Runtime.InteropServices.JavaScript.JSType;
- using System.Threading;
- using TEAMModelOS.SDK.Models.Cosmos;
- namespace TEAMModelOS.SDK.Models.Service
- {
- public static class SystemService
- {
- #region
- static string cn_wb = @"
- IES晚间报告:{tmdname}您好,以下是您的今日个人IES教学汇总报告,截至{sendTime}时,您已发布{examCount}次评测任务,{homeworkCount}次作业任务,并使用HiTeach教师端开设了{lessonCount}节课堂教学活动。
- 以下是报告的具体详细信息。
- {cn_examTitle}{cn_examList}
- {cn_lessonTitle}{cn_lessonList}
- {cn_groupTitle}{cn_groupList}
- 如有布置作业任务,将于次日8点通过早报方式发送。
- ";
- static string cn_examList = "【{examName}】已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。";
- static string cn_lessonList = "【{lessonName}】课例应出席人数{memberCount},实际出席人数{attendCount},出席率{attendRate}%。";
- static string cn_groupListJoin = "【{grouplistName}】已有总人数{memberCount}位,有{joinCount}位加入。";
- static string cn_groupListLeave = "【{grouplistName}】已有总人数{memberCount}位,有{joinCount}位离开。";
- static string cn_zb = @"
- IES早间报告:{tmdname}您好,以下是您发布过的作业任务汇总报告。
- 以下是报告的具体详细信息。
- {cn_homeworkTitle}{cn_homeworkList}
- ";
- static string cn_homeworkList = "【{homeworkName}】已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。";
- static string cn_homeworkTitle = "作业任务提交详情:";
- static string cn_examTitle = "评测任务提交详情:";
- static string cn_lessonTitle = "课堂教学出席详情:";
- static string cn_groupTitle = "个人课程名单变化详情:";
- static string cn_lessonDetail = @"</br>课例名称:{name},开课时间:{time},时长:{duration}分钟</br>
- 1.本节课名单{count}人,分成{groupCount}组,出席人数:{attendCount}人,缺席:{absentCount}人,出席率{attendRate}%</br>
- 2.学习参与度指数平均:{engagementIndexAverge} </br>
- 分组参与度:{grpEngagement}</br>
- 参与较多者:{highRankEngagement}</br>
- 3.记分:总记分:{totalPoint}分 </br>
- 个人记分较多者:{highRankPerPoint}</br>
- 小组记分较多的:{highRankGrpPoint}</br>
- 4.互动:{interactionCount}题,总互动分:{totalInteractPoint}分</br>
- 5.任务:{pushCount}次,作品总数:{collateTaskCount}件</br>
- 6.测验:{examCount}次,题数:{examQuizCount}题,平均得分率:{examPointRate}% </br>
- 表现较好者:{highRankExam}</br>
- 表现较弱者:{lowRankExam}</br>
- 7.互评:{smartRatingCount}次,合计参与:{clientSmartRatingCount}次</br>
- 8.协作:{coworkTaskCount}次,作品总数:{coworkGroupCount}件,总操作量:{coworkGroupCount}</br>";
- #endregion
- #region
- static string tw_wb = @"
- IES晚間報告:{tmdname}您好,以下是您的今日個人IES教學總結報告,截至{sendTime},您已發布{examCount}次測驗任務,{homeworkCount}次作業任務,並使用HiTeach上傳了{lessonCount}節課堂教學活動。
- 以下是詳細資訊。
- {tw_examTitle}{tw_examList}
- {tw_lessonTitle}{tw_lessonList}
- {tw_groupTitle}{tw_groupList}
- 如有佈署作業任務,將於隔天早上8點透過晨間報告方式發送。
- ";
- static string tw_examList = "【{examName}】已經有{submitCount}位學生繳交,仍有{unsubmitCount}位學生未繳交。";
- static string tw_lessonList = "【{lessonName}】課堂應出席人數{memberCount},實際出席人數{attendCount},出席率{attendRate}%。";
- static string tw_groupListJoin = "【{grouplistName}】已有總人數{memberCount}位,有{joinCount}位加入。";
- static string tw_groupListLeave = "【{grouplistName}】已有總人數{memberCount}位,有{joinCount}位離開。";
- static string tw_zb = @"
- IES晨間報告:{tmdname}您好,以下是您曾經發佈過的作業任務總結報告。
- 以下是具體詳細資訊。
- {tw_homeworkTitle}{tw_homeworkList}
- ";
- static string tw_homeworkList = "【{homeworkName}】已經有{submitCount}位學生繳交,仍有{unsubmitCount}位學生未繳交。";
- static string tw_homeworkTitle = "作業任務繳交詳情:";
- static string tw_examTitle = "測驗任務完成詳情:";
- static string tw_lessonTitle = "課堂教學出席詳情:";
- static string tw_groupTitle = "個人課程名單變動詳情:";
- static string tw_lessonDetail = @"</br>课例名称:{name},開課時間:{time},時長:{duration}分鐘</br>
- 1.本節課名單{count}人,分成{groupCount}組,出席人数:{attendCount}人,缺席:{absentCount}人,出席率{attendRate}%</br>
- 2.學習参與度指數平均:{engagementIndexAverge}</br>
- 分組参舆度:{grpEngagement}</br>
- 参與较多者:{highRankEngagement}</br>
- 3.記分:總記分:{totalPoint}分</br>
- 個人記分较多者:{highRankPerPoint}</br>
- 小組記分较多的:{highRankGrpPoint}</br>
- 4.互動:{interactionCount}题,總互動分:{totalInteractPoint}分</br>
- 5.任務:{pushCount}次,作品總数:{collateTaskCount}件</br>
- 6.測驗:{examCount}次,题數:{examQuizCount}题,平均得分率:{examPointRate}%</br>
- 表現较好者:{highRankExam}</br>
- 表現较弱者:{lowRankExam}</br>
- 7.互评:{smartRatingCount}次,合計参與:{clientSmartRatingCount}次</br>
- 8.協作:{coworkTaskCount}次,作品總數:{coworkGroupCount}件,總操作量:{coworkGroupCount}</br>";
- #endregion
- #region
- static string en_wb = @"
- IES Evening Report: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.
- The following are the specific details.
- {en_examTitle}{en_examList}
- {en_lessonTitle}{en_lessonList}
- {en_groupTitle}{en_groupList}
- If there are homework tasks assigned, they will be sent through the morning report at 8 am the next day.
- ";
- static string en_examList = "[ {examName} ] has {submitCount} students submitted, and there are still {unsubmitCount} students who have not submitted.";
- static string en_lessonList = "[ {lessonName} ] lesson should have {memberCount} attendees, actual attendees {attendCount}, attendance rate {attendRate}%.";
- static string en_groupListJoin = "[ {grouplistName} ] has a total of {memberCount}, {joinCount} joined.";
- static string en_groupListLeave = "[ {grouplistName} ] has a total of {memberCount}, {joinCount} left.";
- static string en_zb = @"
- IES Morning Report:
- Hello {tmdname}, here is the summary report of the homework tasks you have posted.
- {en_homeworkTitle}{en_homeworkList}
- ";
- static string en_homeworkList = "[ {homeworkName} ] has {submitCount} students submitted, and there are still {unsubmitCount} students who have not submitted.";
- static string en_homeworkTitle = "Homework Submission Details:";
- static string en_examTitle = "Test task submission details:";
- static string en_lessonTitle = "Lesson attendance details:";
- static string en_groupTitle = "Personal course list change details:";
- static string en_lessonDetail = @"</br>Lesson Name: {name}, Start time: {time}, Duration: {duration} Minutes</br>
- 1. There are {count} people in this course, divided into {groupCount} groups, attendance: {attendCount} people, absences: 0 people, attendance rate {attendRate}%</br>
- 2. Learning Engagement : {engagementIndexAverge}</br>
- Engagement per group: {grpEngagement}</br>
- More engaged students: {highRankEngagement}</br>
- 3. Total Points: {totalPoint} points</br>
- Persons with more points: {highRankPerPoint}</br>
- Groups with more points: {highRankGrpPoint}</br>
- 4. IRS Interaction: {interactionCount} questions, total IRS interaction score: {totalInteractPoint} points</br>
- 5. Tasks: {pushCount} times, total number of collected works: {collateTaskCount} </br>
- 6. Test/Exam: {examCount} times, number of questions: {examQuizCount} questions, average scoring rate: {examPointRate}%</br>
- Better performers: {highRankExam}</br>
- Weaker performers: {lowRankExam}</br>
- 7. Smart Rating: {smartRatingCount} times, total participation: {clientSmartRatingCount} times</br>
- 8. Collaboration: {coworkTaskCount} times, total number of works: {coworkGroupCount}, total operation: {coworkGroupCount}</br>";
- #endregion
- // #region
- // static string cn_wb = @"
- //IES晚间报告:</br>{tmdname}您好,以下是您的今日个人IES教学汇总报告,截至{sendTime}时,您已发布{examCount}次评测任务,{homeworkCount}次作业任务,并使用HiTeach教师端开设了{lessonCount}节课堂教学活动。
- //</br> 以下是报告的具体详细信息。
- //</br> {cn_examTitle}</br>{cn_examList}
- //</br> {cn_lessonTitle}</br>{cn_lessonList}
- //</br> {cn_groupTitle}</br>{cn_groupList}
- //</br> 如有布置作业任务,将于次日8点通过早报方式发送。
- //";
- // static string cn_examList = " 【{examName}】已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。</br>";
- // static string cn_lessonList = " 【{lessonName}】课例应出席人数{memberCount},实际出席人数{attendCount},出席率{attendRate}%。</br>";
- // static string cn_groupListJoin = " 【{grouplistName}】已有总人数{memberCount}位,有{joinCount}位加入。</br>";
- // static string cn_groupListLeave = " 【{grouplistName}】已有总人数{memberCount}位,有{joinCount}位离开。</br>";
- // static string cn_zb = @"
- //IES早间报告:</br>{tmdname}您好,以下是您发布过的作业任务汇总报告。
- //</br> 以下是报告的具体详细信息。
- //</br> {cn_homeworkTitle}</br>{cn_homeworkList}
- //";
- // static string cn_homeworkList = "【{homeworkName}】已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。</br>";
- // static string cn_homeworkTitle = "作业任务提交详情:";
- // static string cn_examTitle = "评测任务提交详情:";
- // static string cn_lessonTitle = "课堂教学出席详情:";
- // static string cn_groupTitle = "个人课程名单变化详情:";
- // #endregion
- // #region
- // static string tw_wb = @"
- //IES晚間報告:</br>{tmdname}您好,以下是您的今日個人IES教學總結報告,截至{sendTime},您已發布{examCount}次測驗任務,{homeworkCount}次作業任務,並使用HiTeach上傳了{lessonCount}節課堂教學活動。
- //</br> 以下是詳細資訊。
- //</br> {tw_examTitle}</br>{tw_examList}
- //</br> {tw_lessonTitle}</br>{tw_lessonList}
- //</br> {tw_groupTitle}</br>{tw_groupList}
- //</br> 如有佈署作業任務,將於隔天早上8點透過晨間報告方式發送。
- //";
- // static string tw_examList = " 【{examName}】已經有{submitCount}位學生繳交,仍有{unsubmitCount}位學生未繳交。</br>";
- // static string tw_lessonList = " 【{lessonName}】課堂應出席人數{memberCount},實際出席人數{attendCount},出席率{attendRate}%。</br>";
- // static string tw_groupListJoin = " 【{grouplistName}】已有總人數{memberCount}位,有{joinCount}位加入。</br>";
- // static string tw_groupListLeave = " 【{grouplistName}】已有總人數{memberCount}位,有{joinCount}位離開。</br>";
- // static string tw_zb = @"
- //IES晨間報告:</br>{tmdname}您好,以下是您曾經發佈過的作業任務總結報告。
- //</br> 以下是具體詳細資訊。
- //</br> {tw_homeworkTitle}</br>{tw_homeworkList}
- //";
- // static string tw_homeworkList = "【{homeworkName}】已經有{submitCount}位學生繳交,仍有{unsubmitCount}位學生未繳交。</br>";
- // static string tw_homeworkTitle = "作業任務繳交詳情:";
- // static string tw_examTitle = "測驗任務完成詳情:";
- // static string tw_lessonTitle = "課堂教學出席詳情:";
- // static string tw_groupTitle = "個人課程名單變動詳情:";
- // #endregion
- // #region
- // static string en_wb = @"
- //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.
- //</br> The following are the specific details.
- //</br> {en_examTitle}</br>{en_examList}
- //</br> {en_lessonTitle}</br>{en_lessonList}
- //</br> {en_groupTitle}</br>{en_groupList}
- //</br> If there are homework tasks assigned, they will be sent through the morning report at 8 am the next day.
- //";
- // static string en_examList = " [ {examName} ] has {submitCount} students submitted, and there are still {unsubmitCount} students who have not submitted.</br>";
- // static string en_lessonList = " [ {lessonName} ] lesson should have {memberCount} attendees, actual attendees {attendCount}, attendance rate {attendRate}%.</br>";
- // static string en_groupListJoin = " [ {grouplistName} ] has a total of {memberCount}, {joinCount} joined.</br>";
- // static string en_groupListLeave = " [ {grouplistName} ] has a total of {memberCount}, {joinCount} left.</br>";
- // static string en_zb = @"
- //IES Morning Report:
- //</br> Hello {tmdname}, here is the summary report of the homework tasks you have posted.
- //</br> {en_homeworkTitle}</br>{en_homeworkList}
- //";
- // static string en_homeworkList = "[ {homeworkName} ] has {submitCount} students submitted, and there are still {unsubmitCount} students who have not submitted.</br>";
- // static string en_homeworkTitle = "Homework Submission Details:";
- // static string en_examTitle = "Test task submission details:";
- // static string en_lessonTitle = "Lesson attendance details:";
- // static string en_groupTitle = "Personal course list change details:";
- // #endregion
- public static string weeklyReportCN = @"<!DOCTYPE html>
- <html>
- <head>
- <title>HiTeach课堂数据周报</title>
- <meta charset=""UTF-8"">
- <style>
- </style>
- </head>
- <body>
- <div style=""margin: 0 0 20px 10px;"">
- <p style=""font-size: 20px;"">
- <span id=""tmdName"">{tmdName}</span>
- 教师您好,你于{year}第{Week}周({weekTime})创建了{lessonCount}节HiTeach5课堂教学活动,以下是报告总览信息,点击其中一行可查看报告详细信息
- </p>
- <div style=""margin-left: 10px;"">
- <table border=""1"" cellpadding=""10"" cellspacing=""0"" border=""1"" cellpadding=""10"" border=""1"" id=""acourseData"">
- <thead>
- <tr>
- <th>课程名称</th>
- <th>科目</th>
- <th>学校/个人</th>
- <th>名单</th>
- <th>课例数量</th>
- <th>查看详情</th>
- </tr>
- </thead>
- <tbody>
- {tableData}
- </tbody>
- </table>
- </div>
- </div>
- </body>
- </html>";
- public static string weeklyReportTW = @"<!DOCTYPE html>
- <html>
- <head>
- <title>HiTeach課堂數據週報</title>
- <meta charset=""UTF-8"">
- <style>
- </style>
- </head>
- <body>
- <div style=""margin: 0 0 20px 10px;"">
- <p style=""font-size: 20px;"">
- <span id=""tmdName"">{tmdName}</span>
- 老師您好,你於{year}第{Week}週({weekTime})上了{lessonCount}節HiTeach5課堂教學活動,以下是報告彙總資訊,點選其中一行可查看報告詳細內容
- </p>
- <div style=""margin-left: 10px;"">
- <table border=""1"" cellpadding=""10"" cellspacing=""0"" border=""1"" cellpadding=""10"" border=""1"" id=""acourseData"">
- <thead>
- <tr>
- <th>課程名稱</th>
- <th>學科</th>
- <th>學校/個人</th>
- <th>名單</th>
- <th>課堂數量</th>
- <th>詳細內容</th>
- </tr>
- </thead>
- <tbody>
- {tableData}
- </tbody>
- </table>
- </div>
- </div>
- </body>
- </html>";
-
- public static string weeklyReportEN = @"<!DOCTYPE html>
- <html>
- <head>
- <title>HiTeach Weekly Report</title>
- <meta charset=""UTF-8"">
- <style>
- </style>
- </head>
- <body>
- <div style=""margin: 0 0 20px 10px;"">
- <p style=""font-size: 20px;"">
- <span id=""tmdName"">{tmdName}</span>
- Hi, you have {lessonCount} HiTeach5 lesson activities in {Week} of {year} ({weekTime}). The following is the
- summary information. Click on one of the rows to view the report details.
- </p>
- <div style=""margin-left: 10px;"">
- <table border=""1"" cellpadding=""10"" cellspacing=""0"" border=""1"" cellpadding=""10"" border=""1"" id=""acourseData"">
- <thead>
- <tr>
- <th>Course name</th>
- <th>Subject</th>
- <th>School/Individual</th>
- <th>Name List</th>
- <th>Number of Lessons</th>
- <th>Details</th>
- </tr>
- </thead>
- <tbody>
- {tableData}
- </tbody>
- </table>
- </div>
- </div>
- </body>
- </html>";
- /// <summary>
- ///
- /// </summary>
- /// <param name="_azureRedis"></param>
- /// <param name="_azureCosmos"></param>
- /// <param name="coreAPIHttpService"></param>
- /// <param name="dingDing"></param>
- /// <param name="_httpClient"></param>
- /// <param name="_snowflakeId"></param>
- /// <param name="notifyUrl"></param>
- /// <param name="_mailFactory"></param>
- /// <param name="am"></param>
- /// <param name="pm"></param>
- /// <returns></returns>
- public static async Task<List<CodeValue> > AccumulateDaily(IConfiguration _configuration,AzureRedisFactory _azureRedis,AzureCosmosFactory _azureCosmos,AzureStorageFactory _azureStorage,
- CoreAPIHttpService coreAPIHttpService, DingDing dingDing,HttpClient _httpClient, SnowflakeId _snowflakeId,string notifyUrl, int am=0 ,int pm=0)
- {
- DateTimeOffset now = DateTimeOffset.Now;
- string day = now.ToString("yyyyMMdd");
- string homeworkYesterday = now.AddDays(-1).ToString("yyyyMMdd");
- HashSet<string> keys = new HashSet<string>();
- //当天评测发布的。
- //当天的个人评测提交数
- Dictionary<string, double?> exam_submit = new();
- SortedSetEntry[] exam_goingScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:exam-going:{day}");
- // Dictionary<string, double?> exam_going = new();
- if (exam_goingScores != null)
- {
- foreach (var score in exam_goingScores)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- // exam_going.Add(key, val);
- exam_submit.Add(key, val);
- keys.Add(key);
- }
- }
- ///需要再次获取 没有任何人提交的作业和评测任务。
- SortedSetEntry[] exam_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:private:exam-submit:{day}");
- if (exam_submitScores != null)
- {
- foreach (var score in exam_submitScores)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- exam_submit.TryAdd(key, val);
- keys.Add(key);
- }
- }
- //今天发布的作业
- SortedSetEntry[] homework_goingScores_today = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-going:{day}");
- Dictionary<string, double?> homework_submit_today = new();
- //Dictionary<string, double?> homework_going = new();
- if (homework_goingScores_today != null)
- {
- foreach (var score in homework_goingScores_today)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- //homework_going.Add(key, val);
- homework_submit_today.TryAdd(key, val);
- keys.Add(key);
- }
- }
- //昨天发布的作业
- SortedSetEntry[] homework_goingScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-going:{homeworkYesterday}");
- Dictionary<string, double?> homework_submit = new();
- //Dictionary<string, double?> homework_going = new();
- if (homework_goingScores != null)
- {
- foreach (var score in homework_goingScores)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- //homework_going.Add(key, val);
- homework_submit.TryAdd(key, val);
- keys.Add(key);
-
- }
- }
- //昨天的个人作业提交数
- SortedSetEntry[] homework_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-submit:{homeworkYesterday}");
-
- if (homework_submitScores != null)
- {
- foreach (var score in homework_submitScores)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- homework_submit.TryAdd(key, val);
- keys.Add(key);
- }
- }
- //当天的个人名单加入人数
- Dictionary<string, double?> grouplist = new();
- SortedSetEntry[] grouplistScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:grouplist:{day}");
- if (grouplistScores != null)
- {
- foreach (var score in grouplistScores)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- grouplist.TryAdd(key, val);
- keys.Add(key);
- }
- }
- //当天教师的开课数量Accumulate:Daily:teacher:lesson-create:20240527
- Dictionary<string, double?> lessoncreate = new();
- SortedSetEntry[] llessoncreateScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:lesson-create:{day}");
- if (llessoncreateScores != null)
- {
- foreach (var score in llessoncreateScores)
- {
- double val = score.Score;
- string key = score.Element.ToString();
- lessoncreate.TryAdd(key, val);
- keys.Add(key);
- }
- }
- List<string> ids = new List<string>();
- keys.ToList().ForEach(x => {
- ids.Add(x.Split("::")[0]);
- });
- List<CoreUser> coreUsers = new List<CoreUser>();
- List<Teacher> teachers= new List<Teacher>();
- if (ids.IsNotEmpty())
- {
- string sql = $"select value c from c where c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))})";
- var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<Teacher>(sql, "Base");
- if (result.list.IsNotEmpty())
- {
- teachers.AddRange(result.list);
- }
- var content = new StringContent(ids.Distinct().ToJsonString(), Encoding.UTF8, "application/json");
- try
- {
- string json = await coreAPIHttpService.GetUserInfos(content);
- if (!string.IsNullOrWhiteSpace(json))
- {
-
- coreUsers = json.ToObject<List<CoreUser>>();
- }
- }
- catch (Exception ex)
- {
- await dingDing.SendBotMsg($"{coreAPIHttpService.options.location}用户转换失败:{coreAPIHttpService.options.coreUrl}", GroupNames.醍摩豆服務運維群組);
- }
- }
- List<CodeValue> notifys = new List<CodeValue>();
- foreach (var teacher in teachers)
- {
- //if (!(teacher.id.Equals("1535418750")))
- //{
- // continue;
- //}
- //if (!(teacher.id.Equals("1535418750")))
- //{
- // continue;
- //}
- StringBuilder notify = new StringBuilder();
- #if DEBUG
- int sendTime_pm = now.Hour;
- int sendTime_am = now.Hour;
- #else
- int sendTime_pm = 20;
- int sendTime_am =8;
- #endif
- if (am>0) {
- sendTime_am = am;
- }
- if (pm>0)
- {
- sendTime_pm = pm;
- }
- string lang = teacher.lang;
- var tzt = now.GetGMTTime((int)teacher.timezone);
- if (string.IsNullOrWhiteSpace(teacher.lang))
- {
- if (coreAPIHttpService.options.location.Contains("China", StringComparison.OrdinalIgnoreCase))
- {
- lang= "zh-cn";
- }
- if (coreAPIHttpService.options.location.Contains("Global",StringComparison.OrdinalIgnoreCase))
- {
- lang= "en-us";
- }
- }
- int examCount = 0,homeworkCount=0,lessonCount=0;
- StringBuilder examSB= new StringBuilder();
- foreach (var exam in exam_submit)
- {
-
- string[] ks = exam.Key.Split("::");
- string tid = ks[0];
- string examId = ks[1];
- string examName = ks[3];
- if (tid.Equals(teacher.id)) {
- if (tzt.Hour==sendTime_pm)
- {
- string sql = $"select c.status from c where c.examId='{examId}' and c.pk='ExamClassResult'";
- var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<ExamClassResult>(sql, $"ExamClassResult-{tid}");
- if (result.list.IsNotEmpty()) {
- var unsubmit = result.list.SelectMany(x => x.status).Where(x => x==1);
- var submit = result.list.SelectMany(x => x.status).Where(x => x==0);
- examCount++;
- switch (lang)
- {
- case "zh-cn":
- examSB.Append(cn_examList.Replace("{examName}", examName).Replace("{submitCount}", $"{submit.Count()}").Replace("{unsubmitCount}", $"{unsubmit.Count()}"));
- break;
- case "zh-tw":
- examSB.Append(tw_examList.Replace("{examName}", examName).Replace("{submitCount}", $"{submit.Count()}").Replace("{unsubmitCount}", $"{unsubmit.Count()}"));
- break;
- case "en-us":
- examSB.Append(en_examList.Replace("{examName}", examName).Replace("{submitCount}", $"{submit.Count()}").Replace("{unsubmitCount}", $"{unsubmit.Count()}"));
- break;
- }
-
- }
- }
- }
- }
- StringBuilder homeworkSB = new StringBuilder();
- foreach (var homeworksm in homework_submit_today)
- {
- string[] ks = homeworksm.Key.Split("::");
- string tid = ks[0];
- string homeworkId = ks[1];
- string homeworkName = ks[3];
- if (tid.Equals(teacher.id))
- {
- if (tzt.Hour==sendTime_pm)
- {
- homeworkCount++;
- }
- }
- }
-
- foreach (var homeworksm in homework_submit)
- {
-
- string[] ks = homeworksm.Key.Split("::");
- string tid = ks[0];
- string homeworkId = ks[1];
- string homeworkName = ks[3];
- if (tid.Equals(teacher.id))
- {
- if (tzt.Hour==sendTime_am)
- {
- var response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(homeworkId, new PartitionKey($"Homework-{tid}"));
- if (response.StatusCode == System.Net.HttpStatusCode.OK) {
- Homework homework= JsonDocument.Parse(response.Content).RootElement.ToObject<Homework>();
- List<string > classes= new List<string>();
- classes.AddRange(homework.stuLists);
- classes.AddRange(homework.classes);
- List<HomeworkUser> homeworkUsers= await HomeworkService.AnswerRecordAll(_azureCosmos.GetCosmosClient(), coreAPIHttpService, dingDing, homework, tid, "Student", classes, "student");
- // homeworkCount++;
- switch (lang)
- {
- case "zh-cn":
- homeworkSB.Append(cn_homeworkList.Replace("{homeworkName}", homework.name).Replace("{submitCount}", $"{homeworkUsers.Where(x => x.submit).Count()}").Replace("{unsubmitCount}", $"{homeworkUsers.Where(x => !x.submit).Count()}"));
- break;
- case "zh-tw":
- homeworkSB.Append(tw_homeworkList.Replace("{homeworkName}", homework.name).Replace("{submitCount}", $"{homeworkUsers.Where(x => x.submit).Count()}").Replace("{unsubmitCount}", $"{homeworkUsers.Where(x => !x.submit).Count()}"));
- break;
- case "en-us":
- homeworkSB.Append(en_homeworkList.Replace("{homeworkName}", homework.name).Replace("{submitCount}", $"{homeworkUsers.Where(x => x.submit).Count()}").Replace("{unsubmitCount}", $"{homeworkUsers.Where(x => !x.submit).Count()}"));
- break;
- }
- }
- }
- }
- }
- StringBuilder lessonSB = new StringBuilder();
- StringBuilder lessonDetailSB = new StringBuilder();
- foreach (var lesson in lessoncreate)
- {
- string[] ks = lesson.Key.Split("::");
- string tid = ks[0];
- if (tid.Equals(teacher.id))
- {
- if (tzt.Hour==sendTime_pm)
- {
- long stime = now.AddHours(-20).ToUnixTimeMilliseconds();
- string sql = $"select value c from c where c.tmdid='{teacher.id}' and c.pk='LessonRecord' and c.startTime> {stime} ";
- List<LessonRecord>lessons = new List<LessonRecord>();
- var schoolResult= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<LessonRecord>(sql);
- var teahcerResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<LessonRecord>(sql, "LessonRecord");
- lessons.AddRange(schoolResult.list);
- lessons.AddRange(teahcerResult.list);
- foreach (var lessonRecord in lessons)
- {
- LessonBase lessonBase = null;
- try
- {
- string owner = lessonRecord.scope.Equals("school") ? lessonRecord.school : lessonRecord.tmdid;
- BlobDownloadResult baseblobDownload = await _azureStorage.GetBlobContainerClient(owner).GetBlobClient($"/records/{lessonRecord.id}/IES/base.json").DownloadContentAsync();
- string basejson = baseblobDownload.Content.ToString().Replace("\"Uncall\"", "0").Replace("Uncall", "0");
- lessonBase = basejson.ToObject<LessonBase>();
- lessonCount++;
- var grpEngagement = string.Join(",", lessonBase.summary?.grpEngagement.Select((x, index) => $"G{index+1}({x})"));
- var highRankEngagement = string.Join(",", lessonBase.summary?.highRankEngagement?.Select((x, index) => $"{x}"));
- var highRankPerPoint = string.Join(",", lessonBase.summary?.highRankPerPoint?.Select((x, index) => $"{x}"));
- var highRankGrpPoint = string.Join(",", lessonBase.summary?.highRankGrpPoint?.Select((x, index) => $"{x}"));
- var highRankExam = string.Join(",", lessonBase.summary?.highRankExam?.Select((x, index) => $"{x}"));
- var lowRankExam = string.Join(",", lessonBase.summary?.lowRankExam?.Select((x, index) => $"{x}"));
- DateTimeOffset time = DateTimeOffset.FromUnixTimeMilliseconds(lessonRecord.startTime).GetGMTTime((int)teacher.timezone);
- switch (lang)
- {
- case "zh-cn":
- if (lessonBase!=null)
- {
-
- lessonDetailSB.Append(cn_lessonDetail.Replace("{name}", lessonRecord.name).Replace("{groupCount}",$"{lessonBase.group.Count()}").Replace("{time}",time.ToString("yyyy-MM-dd HH:mm:ss"))
- .Replace("{duration}", $"{Math.Round(lessonRecord.duration/60, 2)}").Replace("{count}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")
- .Replace("{absentCount}", $"{lessonRecord.clientCount-lessonRecord.attendCount}").Replace("{attendRate}", $"{lessonRecord.attendRate}").Replace("{engagementIndexAverge}", $"{lessonBase.summary?.engagementIndexAverge}")
- .Replace("{grpEngagement}", grpEngagement).Replace("{highRankEngagement}", highRankEngagement).Replace("{totalPoint}", $"{lessonBase.summary.totalPoint}").Replace("{highRankPerPoint}", highRankPerPoint)
- .Replace("{highRankGrpPoint}", highRankGrpPoint).Replace("{interactionCount}", $"{lessonBase.summary.interactionCount}").Replace("{totalInteractPoint}", $"{lessonBase.summary.totalInteractPoint}")
- .Replace("{pushCount}", $"{lessonBase.summary.pushCount}").Replace("{collateTaskCount}", $"{lessonBase.summary.collateTaskCount}").Replace("{examCount}", $"{lessonBase.summary.examCount}")
- .Replace("{examQuizCount}", $"{lessonBase.summary.examQuizCount}").Replace("{examPointRate}", $"{lessonBase.summary.examPointRate}").Replace("{highRankExam}", $"{highRankExam}")
- .Replace("{lowRankExam}", $"{lowRankExam}").Replace("{smartRatingCount}", $"{lessonBase.summary.smartRatingCount}").Replace("{clientSmartRatingCount}", $"{lessonBase.summary.clientSmartRatingCount}")
- .Replace("{coworkTaskCount}", $"{lessonBase.summary.coworkTaskCount}").Replace("{coworkGroupCount}", $"{lessonBase.summary.coworkGroupCount}").Replace("{coworkGroupCount}", $"{lessonBase.summary.coworkGroupCount}")
- .Replace("{avgcoworkGroupCount}", lessonRecord.attendCount>0 ? $"{lessonBase.summary.coworkGroupCount/lessonRecord.attendCount}" : "0"));
- }
- lessonSB.Append(cn_lessonList.Replace("{lessonName}", lessonRecord.name).Replace("{memberCount}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")).Replace("{attendRate}", $"{lessonRecord.attendRate}");
- break;
- case "zh-tw":
- if (lessonBase!=null)
- {
- lessonDetailSB.Append(tw_lessonDetail.Replace("{name}", lessonRecord.name).Replace("{groupCount}", $"{lessonBase.group.Count()}").Replace("{time}", time.ToString("yyyy-MM-dd HH:mm:ss"))
- .Replace("{duration}", $"{Math.Round(lessonRecord.duration/60, 2)}").Replace("{count}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")
- .Replace("{absentCount}", $"{lessonRecord.clientCount-lessonRecord.attendCount}").Replace("{attendRate}", $"{lessonRecord.attendRate}").Replace("{engagementIndexAverge}", $"{lessonBase.summary?.engagementIndexAverge}")
- .Replace("{grpEngagement}", grpEngagement).Replace("{highRankEngagement}", highRankEngagement).Replace("{totalPoint}", $"{lessonBase.summary.totalPoint}").Replace("{highRankPerPoint}", highRankPerPoint)
- .Replace("{highRankGrpPoint}", highRankGrpPoint).Replace("{interactionCount}", $"{lessonBase.summary.interactionCount}").Replace("{totalInteractPoint}", $"{lessonBase.summary.totalInteractPoint}")
- .Replace("{pushCount}", $"{lessonBase.summary.pushCount}").Replace("{collateTaskCount}", $"{lessonBase.summary.collateTaskCount}").Replace("{examCount}", $"{lessonBase.summary.examCount}")
- .Replace("{examQuizCount}", $"{lessonBase.summary.examQuizCount}").Replace("{examPointRate}", $"{lessonBase.summary.examPointRate}").Replace("{highRankExam}", $"{highRankExam}")
- .Replace("{lowRankExam}", $"{lowRankExam}").Replace("{smartRatingCount}", $"{lessonBase.summary.smartRatingCount}").Replace("{clientSmartRatingCount}", $"{lessonBase.summary.clientSmartRatingCount}")
- .Replace("{coworkTaskCount}", $"{lessonBase.summary.coworkTaskCount}").Replace("{coworkGroupCount}", $"{lessonBase.summary.coworkGroupCount}").Replace("{coworkGroupCount}", $"{lessonBase.summary.coworkGroupCount}")
- .Replace("{avgcoworkGroupCount}", lessonRecord.attendCount>0 ? $"{lessonBase.summary.coworkGroupCount/lessonRecord.attendCount}" : "0"));
- }
- lessonSB.Append(tw_lessonList.Replace("{lessonName}", lessonRecord.name).Replace("{memberCount}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")).Replace("{attendRate}", $"{lessonRecord.attendRate}");
- break;
- case "en-us":
- if (lessonBase!=null)
- {
- lessonDetailSB.Append(en_lessonDetail.Replace("{name}", lessonRecord.name).Replace("{groupCount}", $"{lessonBase.group.Count()}").Replace("{time}", time.ToString("yyyy-MM-dd HH:mm:ss"))
- .Replace("{duration}", $"{Math.Round(lessonRecord.duration/60, 2)}").Replace("{count}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")
- .Replace("{absentCount}", $"{lessonRecord.clientCount-lessonRecord.attendCount}").Replace("{attendRate}", $"{lessonRecord.attendRate}").Replace("{engagementIndexAverge}", $"{lessonBase.summary?.engagementIndexAverge}")
- .Replace("{grpEngagement}", grpEngagement).Replace("{highRankEngagement}", highRankEngagement).Replace("{totalPoint}", $"{lessonBase.summary.totalPoint}").Replace("{highRankPerPoint}", highRankPerPoint)
- .Replace("{highRankGrpPoint}", highRankGrpPoint).Replace("{interactionCount}", $"{lessonBase.summary.interactionCount}").Replace("{totalInteractPoint}", $"{lessonBase.summary.totalInteractPoint}")
- .Replace("{pushCount}", $"{lessonBase.summary.pushCount}").Replace("{collateTaskCount}", $"{lessonBase.summary.collateTaskCount}").Replace("{examCount}", $"{lessonBase.summary.examCount}")
- .Replace("{examQuizCount}", $"{lessonBase.summary.examQuizCount}").Replace("{examPointRate}", $"{lessonBase.summary.examPointRate}").Replace("{highRankExam}", $"{highRankExam}")
- .Replace("{lowRankExam}", $"{lowRankExam}").Replace("{smartRatingCount}", $"{lessonBase.summary.smartRatingCount}").Replace("{clientSmartRatingCount}", $"{lessonBase.summary.clientSmartRatingCount}")
- .Replace("{coworkTaskCount}", $"{lessonBase.summary.coworkTaskCount}").Replace("{coworkGroupCount}", $"{lessonBase.summary.coworkGroupCount}").Replace("{coworkGroupCount}", $"{lessonBase.summary.coworkGroupCount}")
- .Replace("{avgcoworkGroupCount}", lessonRecord.attendCount>0 ? $"{lessonBase.summary.coworkGroupCount/lessonRecord.attendCount}" : "0"));
- }
- lessonSB.Append(en_lessonList.Replace("{lessonName}", lessonRecord.name).Replace("{memberCount}", $"{lessonRecord.clientCount}").Replace("{attendCount}", $"{lessonRecord.attendCount}")).Replace("{attendRate}", $"{lessonRecord.attendRate}");
- break;
- }
- }
- catch (Exception ex)
- {
-
- }
-
- }
- }
- }
- }
- StringBuilder grouplistSB = new StringBuilder();
- List<string> grouplistIds=new List<string>();
- foreach (var group in grouplist)
- {
- string[] ks = group.Key.Split("::");
- grouplistIds.Add(ks[1]);
- }
- List<GroupListDto> groupListDtos= await GroupListService.GetGroupListByListids(_azureCosmos.GetCosmosClient(), dingDing, grouplistIds, null);
- foreach (var group in grouplist)
- {
- string[] ks = group.Key.Split("::");
- string tid = ks[0];
- string grouplistId = ks[1];
- string grouplistName = ks[3];
- var gpdto= groupListDtos.Find(x => x.id.Equals(grouplistId));
- if (gpdto!= null)
- {
- if (tid.Equals(teacher.id))
- {
- if (tzt.Hour==sendTime_pm)
- {
- switch (lang)
- {
- case "zh-cn":
- if (group.Value>=0)
- {
- grouplistSB.Append(cn_groupListJoin.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
- }
- else
- {
- grouplistSB.Append(cn_groupListLeave.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
- }
- break;
- case "zh-tw":
- if (group.Value>=0)
- {
- grouplistSB.Append(tw_groupListJoin.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
- }
- else
- {
- grouplistSB.Append(tw_groupListLeave.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
- }
- break;
- case "en-us":
- if (group.Value>=0)
- {
- grouplistSB.Append(en_groupListJoin.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
- }
- else
- {
- grouplistSB.Append(en_groupListLeave.Replace("{grouplistName}", grouplistName).Replace("{memberCount}", $"{gpdto.tcount+gpdto.scount}").Replace("{joinCount}", $"{group.Value}"));
- }
- break;
- }
- }
- }
- }
- }
- // await dingDing.SendBotMsg($"{teacher.name},{homework_submit_today.ToJsonString()},pm:{pm},am:{am},tztH:{tzt.Hour},sendPm:{sendTime_pm},sendAm:{sendTime_am},examCount:{examCount},lessonCount:{lessonCount},homeworkCount:{homeworkCount}", GroupNames.成都开发測試群組);
- if (tzt.Hour==sendTime_pm && (!string.IsNullOrWhiteSpace(lessonDetailSB.ToString()) || examCount>0 || lessonCount>0 || homeworkCount>0 || (grouplist.Count>0 && !string.IsNullOrWhiteSpace(grouplistSB.ToString()))))
- {
- string template=string.Empty;
- string title=string.Empty;
- switch (lang)
- {
- case "zh-cn":
- title="IES晚间报告";
- template=cn_wb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_pm}")
- .Replace("{examCount}", $"{examCount}").Replace("{homeworkCount}", $"{homeworkCount}").Replace("{lessonCount}", $"{lessonCount}")
- .Replace("{cn_examList}", examSB.ToString()).Replace("{cn_lessonList}", lessonSB.ToString()).Replace("{cn_groupList}", grouplistSB.ToString());
- if (examCount>0)
- {
- template= template.Replace("{cn_examTitle}", cn_examTitle);
- }
- else {
- template= template.Replace("{cn_examTitle}", "");
- }
- if (homeworkCount>0)
- {
- template= template.Replace("{cn_homeworkTitle}", cn_homeworkTitle);
- }
- else
- {
- template= template.Replace("{cn_homeworkTitle}", "");
- }
- if (lessonCount>0)
- {
- template= template.Replace("{cn_lessonTitle}", cn_lessonTitle);
- }
- else
- {
- template= template.Replace("{cn_lessonTitle}", "");
- }
- if (grouplist.Count>0 && !string.IsNullOrWhiteSpace(grouplistSB.ToString()))
- {
- template=template.Replace("{cn_groupTitle}", cn_groupTitle);
- }
- else
- {
- template= template.Replace("{cn_groupTitle}", "");
- }
- break;
- case "zh-tw":
- title="IES晚間報告";
- template=tw_wb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_pm}")
- .Replace("{examCount}", $"{examCount}").Replace("{homeworkCount}", $"{homeworkCount}").Replace("{lessonCount}", $"{lessonCount}")
- .Replace("{tw_examList}", examSB.ToString()).Replace("{tw_lessonList}", lessonSB.ToString()).Replace("{tw_groupList}", grouplistSB.ToString());
- if (examCount>0)
- {
- template= template.Replace("{tw_examTitle}", tw_examTitle);
- }
- else
- {
- template= template.Replace("{tw_examTitle}", "");
- }
- if (homeworkCount>0)
- {
- template= template.Replace("{tw_homeworkTitle}", tw_homeworkTitle);
- }
- else
- {
- template= template.Replace("{tw_homeworkTitle}", "");
- }
- if (lessonCount>0)
- {
- template= template.Replace("{tw_lessonTitle}", tw_lessonTitle);
- }
- else
- {
- template= template.Replace("{tw_lessonTitle}", "");
- }
- if (grouplist.Count>0)
- {
- template=template.Replace("{tw_groupTitle}", tw_groupTitle);
- }
- else
- {
- template= template.Replace("{tw_groupTitle}", "");
- }
- break;
- case "en-us":
- title ="IES Evening Report";
- template=en_wb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_pm}")
- .Replace("{examCount}", $"{examCount}").Replace("{homeworkCount}", $"{homeworkCount}").Replace("{lessonCount}", $"{lessonCount}")
- .Replace("{en_examList}", examSB.ToString()).Replace("{en_lessonList}", lessonSB.ToString()).Replace("{en_groupList}", grouplistSB.ToString());
- if (examCount>0)
- {
- template= template.Replace("{en_examTitle}", en_examTitle);
- }
- else
- {
- template= template.Replace("{en_examTitle}", "");
- }
- if (homeworkCount>0)
- {
- template= template.Replace("{en_homeworkTitle}", en_homeworkTitle);
- }
- else
- {
- template= template.Replace("{en_homeworkTitle}", "");
- }
- if (lessonCount>0)
- {
- template= template.Replace("{en_lessonTitle}", en_lessonTitle);
- }
- else
- {
- template= template.Replace("{en_lessonTitle}", "");
- }
- if (grouplist.Count>0)
- {
- template=template.Replace("{en_groupTitle}", en_groupTitle);
- }
- else
- {
- template= template.Replace("{en_groupTitle}", "");
- }
- break;
- }
- template= template.Replace("\r\n", "");
- string eventId = $"Evening_Report-{_snowflakeId.NextId()}";
- NotifyData notifyData = new NotifyData
- {
- hubName = "hita5",
- sender = "IES",
- tags = new List<string>() { $"{teacher.id}_{Constant.NotifyType_IES5_Course}" },
- title = title,
- eventId =eventId,
- eventName =title,
- data = "{\"value\":{}}",
- body=template,
- };
- HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync($"{notifyUrl}/service/PushNotify", notifyData);
- var coreUser = coreUsers.Find(x => x.id.Equals(teacher.id) && !string.IsNullOrWhiteSpace(x.mail));
- if (coreUser!=null)
- {
- // var token = _mailFactory.GetSmtpClient().SendEmail(_azureCosmos, dingDing, eventId, title, template, coreUser.mail, teacher.id, teacher.name, sender: "TEAMModel");
- //var tid = lang.Equals("zh-cn") ? "d-136eddbd974046f1a721c8f4e210b9bf" : lang.Equals("zh-tw") ? "d-136eddbd974046f1a721c8f4e210b9bf" : "d-95ac2d657d1b4d9dbb7b79defc17f714";
- var tid = string.Empty;
- if (coreAPIHttpService.options.location.Contains("China"))
- {
- tid=lang.Equals("zh-cn") ? "IES5GeneralTemplateSC" : lang.Equals("zh-tw") ? "IES5GeneralTemplateTC" : "IES5GeneralTemplateEN";
- }
- else
- {
- tid=lang.Equals("zh-cn") ? "d-270b4ec690f541a9a4045d7a4032bc3b" : lang.Equals("zh-tw") ? "d-136eddbd974046f1a721c8f4e210b9bf" : "d-95ac2d657d1b4d9dbb7b79defc17f714";
- }
- await coreAPIHttpService.SendMail(new Dictionary<string, object> { { "to", coreUser.mail }, { "tid", tid }, { "vars", new { title = title, notificationcontent = $"{template}</br>{lessonDetailSB.ToString()}" } } }, coreAPIHttpService.options.location, _configuration);
- }
- notify.Append(template);
- }
- if (tzt.Hour==sendTime_am && !string.IsNullOrWhiteSpace(homeworkSB.ToString()))
- {
- string template = string.Empty;
- string title = string.Empty;
- switch (lang)
- {
- case "zh-cn":
- title ="IES早间报告";
- template= cn_zb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_am}")
- .Replace("{cn_homeworkList}", homeworkSB.ToString());
- template=template.Replace("{cn_homeworkTitle}", cn_homeworkTitle);
- break;
- case "zh-tw":
- title ="IES晨間報告";
- template= tw_zb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_am}")
- .Replace("{tw_homeworkList}", homeworkSB.ToString());
- template=template.Replace("{tw_homeworkTitle}", tw_homeworkTitle);
- break;
- case "en-us":
- title ="IES Morning Report";
- template=en_zb.Replace("{tmdname}", teacher.name).Replace("{sendTime}", $"{now.ToString("yyyy-MM-dd")} {sendTime_am}")
- .Replace("{en_homeworkList}", homeworkSB.ToString());
- template=template.Replace("{en_homeworkTitle}", en_homeworkTitle);
- break;
- }
- template= template.Replace("\r\n", "");
- string eventId = $"Morning_Report-{_snowflakeId.NextId()}";
- NotifyData notifyData = new NotifyData
- {
- hubName = "hita5",
- sender = "IES",
- tags = new List<string>() { $"{teacher.id}_{Constant.NotifyType_IES5_Course}" },
- title = title,
- eventId = eventId,
- eventName =title,
- data = "{\"value\":{}}",
- body=template,
- };
- HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync($"{notifyUrl}/service/PushNotify", notifyData);
- var coreUser = coreUsers.Find(x => x.id.Equals(teacher.id) && !string.IsNullOrWhiteSpace(x.mail));
- if (coreUser!=null)
- {
- // var token = _mailFactory.GetSmtpClient().SendEmail(_azureCosmos, dingDing, eventId, title, template, coreUser.mail, teacher.id, teacher.name,sender:"TEAMModel");
- var tid = string.Empty ;
- if (coreAPIHttpService.options.location.Contains("China"))
- {
- tid=lang.Equals("zh-cn") ? "IES5GeneralTemplateSC" : lang.Equals("zh-tw") ? "IES5GeneralTemplateTC" : "IES5GeneralTemplateEN";
- }
- else {
- tid=lang.Equals("zh-cn")? "d-270b4ec690f541a9a4045d7a4032bc3b" : lang.Equals("zh-tw") ? "d-136eddbd974046f1a721c8f4e210b9bf" : "d-95ac2d657d1b4d9dbb7b79defc17f714";
- }
- await coreAPIHttpService.SendMail(new Dictionary<string, object> { { "to", coreUser.mail }, { "tid", tid }, { "vars", new { title = title, notificationcontent = template } } }, coreAPIHttpService.options.location, _configuration);
- }
- notify.Append(template);
- }
- notifys.Add(new CodeValue { code=teacher.id, value= notify.ToString() });
-
- }
- return notifys;
- }
- public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, DingDing dingDing, Accumulate accumulate)
- {
- if (!string.IsNullOrWhiteSpace(accumulate.key) && !string.IsNullOrWhiteSpace(accumulate.target) &&
- !string.IsNullOrWhiteSpace(accumulate.id) && !string.IsNullOrWhiteSpace(accumulate.name) &&
- !string.IsNullOrWhiteSpace(accumulate.scope) && !string.IsNullOrWhiteSpace(accumulate.client))
- {
- await RecordAccumulateData(azureRedis, accumulate.key, accumulate.target, accumulate.id, accumulate.name, accumulate.scope, accumulate.client, accumulate.count);
- }
- else
- {
- await dingDing.SendBotMsg($"IES累计数据变更统计参数异常,{accumulate.ToJsonString()}", GroupNames.成都开发測試群組);
- }
- }
- public static async Task LessonWeekly( AzureRedisFactory _azureRedis, AzureCosmosFactory _azureCosmos, CoreAPIHttpService _coreAPIHttpService, DingDing _dingDing, IConfiguration _configuration)
- {
- var now = DateTimeOffset.Now;
- var nownf = DateTime.Now;
- // 使用当前文化设置的日历
- CultureInfo cultureInfo = CultureInfo.CurrentCulture;
- Calendar calendar = cultureInfo.Calendar;
- //表示如果一年的第一个星期至少有4天在同一年,则该星期被视为第一周,DayOfWeek.Monday和DayOfWeek.Sunday分别表示一周的第一天是星期一或星期日。
- var week = calendar.GetWeekOfYear(nownf, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
- string schoolKey = $"LessonWeekly:school:{now.Year}-{week}";
- string privateKey = $"LessonWeekly:private:{now.Year}-{week}";
- int currentDayOfWeek = (int)now.DayOfWeek;
- // 计算周一的日期
- DateTimeOffset startOfWeek = now.AddDays(1 - currentDayOfWeek);
- // 计算周日的日期
- DateTimeOffset endOfWeek = now.AddDays(7 - currentDayOfWeek);
- // 获取当前年份
- int currentYear = now.Year;
- // 获取当前年份的第一天
- DateTimeOffset firstDayOfYear = new DateTimeOffset(currentYear, 1, 1, 0, 0, 0,new TimeSpan(8,0,0));
- // 获取当前年份的最后一天
- DateTimeOffset lastDayOfYear = new DateTimeOffset(currentYear, 12, 31, 23, 59, 59, new TimeSpan(8, 0, 0));
- var schoolValues = await _azureRedis.GetRedisClient(8).HashGetAllAsync(schoolKey);
- var privateValues = await _azureRedis.GetRedisClient(8).HashGetAllAsync(privateKey);
- List<KeyValuePair<string, List<LessonWeek>>> datas = new List<KeyValuePair<string, List<LessonWeek>>>();
- HashSet<string> schoolId = new HashSet<string>();
- if (schoolValues!=default && schoolValues.Length>0)
- {
- foreach (var value in schoolValues)
- {
- var tmdid = value.Name.ToString().Split(":")[0];
- LessonWeek data = value.Value.ToString().ToObject<LessonWeek>();
- if (!string.IsNullOrWhiteSpace(data.school))
- {
- schoolId.Add(data.school);
- }
- var tmdData = datas.Find(x => x.Key.Equals(tmdid));
- if (tmdData.Key==null)
- {
- tmdData= new KeyValuePair<string, List<LessonWeek>>(tmdid, new List<LessonWeek> { data });
- datas.Add(tmdData);
- }
- else
- {
- tmdData.Value.Add(data);
- }
- }
- }
- if (privateValues!=default && privateValues.Length>0)
- {
- foreach (var value in privateValues)
- {
- var tmdid = value.Name.ToString().Split(":")[0];
- LessonWeek data = value.Value.ToString().ToObject<LessonWeek>();
- var tmdData = datas.Find(x => x.Key.Equals(tmdid));
- if (tmdData.Key==null)
- {
- tmdData= new KeyValuePair<string, List<LessonWeek>>(tmdid, new List<LessonWeek> { data });
- datas.Add(tmdData);
- }
- else
- {
- tmdData.Value.Add(data);
- }
- }
- }
- if (datas.IsNotEmpty())
- {
- List<CoreUser> coreUsers= new List<CoreUser>();
- List<Teacher> teachers = new List<Teacher>();
- string sql = $"select value c from c where c.id in ({string.Join(",", datas.Select(x => $"'{x.Key}'"))})";
- var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<Teacher>(sql, "Base");
- if (result.list.IsNotEmpty())
- {
- teachers.AddRange(result.list);
- }
- var str = teachers.Select(x => $"{x.id}").ToJsonString();
- var content = new StringContent(str, Encoding.UTF8, "application/json");
- try
- {
- string json = await _coreAPIHttpService.GetUserInfos(content);
- if (!string.IsNullOrWhiteSpace(json))
- {
- coreUsers = json.ToObject<List<CoreUser>>();
- }
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location}邮件用户转换失败:{_coreAPIHttpService.options.coreUrl}", GroupNames.醍摩豆服務運維群組);
- }
- List<School> schools = new List<School>();
- if (schoolId.IsNotEmpty())
- {
- var schoolIds= datas.SelectMany(x => x.Value).Where(x => !string.IsNullOrWhiteSpace(x.school)).Select(x => x.school).Distinct();
- string schsql = $"select value c from c where c.id in ({string.Join(",", schoolIds.Select(x => $"'{x}'"))})";
- var schresult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<School>(schsql, "Base");
- if (schresult.list.IsNotEmpty())
- {
- schools.AddRange(schresult.list);
- }
- }
- //个人和学校名单
- List<GroupListDto> groupLists = new List<GroupListDto>();
- //个人和学校课程
- List<CourseBase> courseBases = new List<CourseBase>();
- foreach (var data in datas)
- {
- var teacher = teachers.Find(x => x.id.Equals(data.Key));
-
- if (teacher!=null)
- {
- var coreUser = coreUsers.Find(x => x.id.Equals(teacher.id) && !string.IsNullOrWhiteSpace(x.mail));
- if (coreUser!=null)
- {
- if (!teacher.id.Equals("1535418750"))
- {
- continue;
- }
- string lang = teacher.lang;
- var tzt = now.GetGMTTime((int)teacher.timezone);
- if (string.IsNullOrWhiteSpace(teacher.lang))
- {
- if (_coreAPIHttpService.options.location.Contains("China", StringComparison.OrdinalIgnoreCase))
- {
- lang= "zh-cn";
- }
- if (_coreAPIHttpService.options.location.Contains("Global", StringComparison.OrdinalIgnoreCase))
- {
- lang= "en-us";
- }
- }
- List<LessonRecord> lessonRecords = new List<LessonRecord>();
- #region
- //课例
- //{
- // var pid = data.Value.FindAll(x => !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("private")).Select(x => x.id);
- // var sid = data.Value.FindAll(x => !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("school"))
- // .Select(x => new CodeValue { code=x.school, value=x.id }).GroupBy(x => x.code).Select(x => new { key = x.Key, list = x.ToList() });
- // if (pid!=null && pid.Count()>0)
- // {
- // var pg = pid.ExceptBy(groupLists.Select(x => x.id), y => y);
- // if (pg!=null && pg.Count()>0)
- // {
- // string csql = $"select value c from c where c.id in ({string.Join(",", pg.Select(x => $"'{x}'"))})";
- // var lresult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<LessonRecord>(csql, "LessonRecord");
- // if (lresult.list.IsNotEmpty())
- // {
- // lessonRecords.AddRange(lresult.list);
- // }
- // }
- // }
- // if (sid!=null && sid.Count()>0)
- // {
- // foreach (var item in sid)
- // {
- // var sg = item.list.Select(x => x.value).ToList().ExceptBy(groupLists.Where(x => x.school.Equals(item.key)).Select(x => x.id), y => y);
- // if (sg!=null && sg.Count()>0)
- // {
- // string csql = $"select value c from c where c.id in ({string.Join(",", sg.Select(x => $"'{x}'"))})";
- // var lresult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<LessonRecord>(csql, $"LessonRecord-{item.key}");
- // if (lresult.list.IsNotEmpty())
- // {
- // lessonRecords.AddRange(lresult.list);
- // }
- // }
- // }
- // }
- //}
- //名单
- {
- var pgid = data.Value.FindAll(x => !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("private")).Select(x => x.gid);
- var sgid = data.Value.FindAll(x => !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("school"))
- .Select(x => new CodeValue { code=x.school, value=x.gid }).GroupBy(x => x.code).Select(x => new { key = x.Key, list = x.ToList() });
- if (pgid!=null && pgid.Count()>0)
- {
- var pg = pgid.ExceptBy(groupLists.Select(x => x.id), y => y);
- if (pg!=null && pg.Count()>0)
- {
- var grouplist = await GroupListService.GetGroupListByListids(_azureCosmos.GetCosmosClient(), _dingDing, pg.ToList(), null);
- if (grouplist.IsNotEmpty())
- {
- groupLists.AddRange(grouplist);
- }
- }
- }
- if (sgid!=null && sgid.Count()>0)
- {
- foreach (var item in sgid)
- {
- var sg = item.list.Select(x => x.value).ToList().ExceptBy(groupLists.Where(x => x.school.Equals(item.key)).Select(x => x.id), y => y);
- if (sg!=null && sg.Count()>0)
- {
- var grouplist = await GroupListService.GetGroupListByListids(_azureCosmos.GetCosmosClient(), _dingDing, sg.ToList(), item.key);
- if (grouplist.IsNotEmpty())
- {
- groupLists.AddRange(grouplist);
- }
- }
- }
- }
- }
- //课程
- {
- var pcid = data.Value.FindAll(x => !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("private") && !string.IsNullOrWhiteSpace(x.cid)).Select(x => x.cid);
- var scid = data.Value.FindAll(x => !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("school") && !string.IsNullOrWhiteSpace(x.cid))
- .Select(x => new CodeValue { code=x.school, value=x.cid }).GroupBy(x => x.code).Select(x => new { key = x.Key, list = x.ToList() });
- if (pcid!=null && pcid.Count()>0)
- {
- var pg = pcid.ExceptBy(courseBases.Select(x => x.id), y => y);
- if (pg!=null && pg.Count()>0)
- {
- string csql = $"select value c from c where c.id in ({string.Join(",", pg.Select(x => $"'{x}'"))})";
- var cresult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<CourseBase>(csql, "CourseBase");
- if (cresult.list.IsNotEmpty())
- {
- courseBases.AddRange(cresult.list);
- }
- }
- }
- if (scid!=null && scid.Count()>0)
- {
- foreach (var item in scid)
- {
- var sg = item.list.Select(x => x.value).ToList().ExceptBy(courseBases.Where(x => x.school.Equals(item.key)).Select(x => x.id), y => y);
- if (sg!=null && sg.Count()>0)
- {
- string csql = $"select value c from c where c.id in ({string.Join(",", sg.Select(x => $"'{x}'"))})";
- var cresult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<CourseBase>(csql, $"CourseBase-{item.key}");
- if (cresult.list.IsNotEmpty())
- {
- courseBases.AddRange(cresult.list);
- }
- }
- }
- }
- }
- #endregion
- StringBuilder sb = new StringBuilder();
- var sdata = data.Value.Where(x => x.scope.Equals("school")).GroupBy(x => $"{x.scope}:{x.cid}:{x.gid}:{x.school}:{x.sid}").Select(x => new { key = x.Key, list = x.ToList() });
- var pdata = data.Value.Where(x => x.scope.Equals("private")).GroupBy(x => $"{x.scope}:{x.cid}:{x.gid}:").Select(x => new { key = x.Key, list = x.ToList() }); ;
- foreach (var s in sdata)
- {
- Dictionary<string, string> @params = new();
- string[] ids = s.key.Split(":");
- var course = courseBases.Find(x => x.id.Equals(ids[1]));
- var group = groupLists.Find(x => x.id.Equals(ids[2]));
- School school = null;
- Subject subject = null;
- Period period = null;
- long stime = 0;
- long etime = 0;
- school = schools.Find(x => x.id.Equals(ids[3]));
- if (school !=null)
- {
- period=school.period.FirstOrDefault();
- subject = school.period.SelectMany(x => x.subjects).Where(x => x.id.Equals(ids[4])).FirstOrDefault();
- var semester = SchoolService.GetSemester(period, DateTimeOffset.Now.ToUnixTimeMilliseconds());
- stime = semester.currSemesterDate.ToUnixTimeMilliseconds();
- etime = semester.nextSemester.ToUnixTimeMilliseconds();
- }
- if (stime==0)
- {
- stime= firstDayOfYear.ToUnixTimeMilliseconds();
- }
- if (etime==0)
- {
- etime= lastDayOfYear.ToUnixTimeMilliseconds();
- }
- @params.Add("tmdId", teacher.id);
- @params.Add("school", school.id);
- @params.Add("scope", "school");
- @params.Add("courseId", course.id);
- @params.Add("groupIds", group.id);
- @params.Add("astime", $"{stime}");
- @params.Add("aetime", $"{etime}");
- @params.Add("stime", $"{startOfWeek.ToUnixTimeMilliseconds()}");
- @params.Add("etime", $"{endOfWeek.ToUnixTimeMilliseconds()}");
- @params.Add("srvAdr", _coreAPIHttpService.options.location);
- string page = lang.Equals("zh-cn") ? "reprotCN.html" : lang.Equals("zh-tw") ? "reprotTW.html" : "reprotUS.html";
- string opt = lang.Equals("zh-cn") ? "查看" : lang.Equals("zh-tw") ? "檢視" : "View";
- var host = _coreAPIHttpService.options.location.Contains("China", StringComparison.OrdinalIgnoreCase) ? "https://www.teammodel.cn" : "https://www.teammodel.net";
- string paramStr = string.Join("&", @params.Select(x => $"{x.Key}={x.Value}"));
- string url = $"{host}/{page}?{paramStr}";
- sb.Append($"<tr><td>{course.name}</td><td>{subject.name}</td><td>{school.name}</td><td>{group.name}</td><td>{s.list.Count()}</td><td><a href='{url}'>{opt}</td>");
- }
- foreach (var s in pdata)
- {
- Dictionary<string, string> @params = new();
- string[] ids = s.key.Split(":");
- var course = courseBases.Find(x => x.id.Equals(ids[1]));
- var group = groupLists.Find(x => x.id.Equals(ids[2]));
- long stime = firstDayOfYear.ToUnixTimeMilliseconds();
- long etime = lastDayOfYear.ToUnixTimeMilliseconds();
- @params.Add("tmdId", teacher.id);
- @params.Add("school", "");
- @params.Add("scope", "school");
- @params.Add("courseId", course.id);
- @params.Add("groupIds", group.id);
- @params.Add("astime", $"{stime}");
- @params.Add("aetime", $"{etime}");
- @params.Add("stime", $"{startOfWeek.ToUnixTimeMilliseconds()}");
- @params.Add("etime", $"{endOfWeek.ToUnixTimeMilliseconds()}");
- @params.Add("srvAdr", _coreAPIHttpService.options.location);
- string page = lang.Equals("zh-cn") ? "reprotCN.html" : lang.Equals("zh-tw") ? "reprotTW.html" : "reprotUS.html";
- string opt = lang.Equals("zh-cn") ? "查看" : lang.Equals("zh-tw") ? "檢視" : "View";
- string scopeStr = lang.Equals("zh-cn") ? "个人课程" : lang.Equals("zh-tw") ? "個人課程" : "Personal Course";
- var host = _coreAPIHttpService.options.location.Contains("China", StringComparison.OrdinalIgnoreCase) ? "https://www.teammodel.cn" : "https://www.teammodel.net";
- string paramStr = string.Join("&", @params.Select(x => $"{x.Key}={x.Value}"));
- string url = $"{host}/{page}?{paramStr}";
- sb.Append($"<tr><td>{course.name}</td><td>--</td><td>{scopeStr}</td><td>{group.name}</td><td>{s.list.Count()}</td><td><a href='{url}'>{opt}</td>");
- }
- string html = string.Empty;
- string title = string.Empty;
- switch (lang)
- {
- case "zh-cn":
- title= $"课例周报{startOfWeek.ToString("yyyy/MM/dd")}-{endOfWeek.ToString("MM/dd")}";
- html= weeklyReportCN.Replace("{tmdName}", teacher.name).Replace("{year}", $"{now.Year}").Replace("{Week}", $"{week}").Replace("{weekTime}", $"{startOfWeek.ToString("yyyy/MM/dd")}-{endOfWeek.ToString("MM/dd")}").Replace("{lessonCount}", $"{data.Value.Count()}").Replace("{tableData}", sb.ToString());
- break;
- case "zh-tw":
- title= $"課例周報{startOfWeek.ToString("yyyy/MM/dd")}-{endOfWeek.ToString("MM/dd")}";
- html= weeklyReportTW.Replace("{tmdName}", teacher.name).Replace("{year}", $"{now.Year}").Replace("{Week}", $"{week}").Replace("{weekTime}", $"{startOfWeek.ToString("yyyy/MM/dd")}-{endOfWeek.ToString("MM/dd")}").Replace("{lessonCount}", $"{data.Value.Count()}").Replace("{tableData}", sb.ToString());
- break;
- case "en-us":
- title= $"Lesson record weekly report{startOfWeek.ToString("yyyy/MM/dd")}-{endOfWeek.ToString("MM/dd")}";
- html= weeklyReportEN.Replace("{tmdName}", teacher.name).Replace("{year}", $"{now.Year}").Replace("{Week}", $"{week}").Replace("{weekTime}", $"{startOfWeek.ToString("yyyy/MM/dd")}-{endOfWeek.ToString("MM/dd")}").Replace("{lessonCount}", $"{data.Value.Count()}").Replace("{tableData}", sb.ToString());
- break;
- }
- {
- // var token = _mailFactory.GetSmtpClient().SendEmail(_azureCosmos, dingDing, eventId, title, template, coreUser.mail, teacher.id, teacher.name, sender: "TEAMModel");
- //var tid = lang.Equals("zh-cn") ? "d-136eddbd974046f1a721c8f4e210b9bf" : lang.Equals("zh-tw") ? "d-136eddbd974046f1a721c8f4e210b9bf" : "d-95ac2d657d1b4d9dbb7b79defc17f714";
- var tid = string.Empty;
- if (_coreAPIHttpService.options.location.Contains("China"))
- {
- tid=lang.Equals("zh-cn") ? "IES5GeneralTemplateSC" : lang.Equals("zh-tw") ? "IES5GeneralTemplateTC" : "IES5GeneralTemplateEN";
- }
- else
- {
- tid=lang.Equals("zh-cn") ? "d-270b4ec690f541a9a4045d7a4032bc3b" : lang.Equals("zh-tw") ? "d-136eddbd974046f1a721c8f4e210b9bf" : "d-95ac2d657d1b4d9dbb7b79defc17f714";
- }
- await _coreAPIHttpService.SendMail(new Dictionary<string, object> { { "to", coreUser.mail }, { "tid", tid }, { "vars", new { title = title, notificationcontent = html } } }, _coreAPIHttpService.options.location, _configuration);
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 记录累计数据
- /// </summary>
- public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, string key, string target, string id, string name, string scope, string client, int count)
- {
- if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(target) &&
- !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(name) &&
- !string.IsNullOrWhiteSpace(scope)&& !string.IsNullOrWhiteSpace(client))
- {
- //处理UTC时差
- var nowTime = DateTimeOffset.UtcNow.GetGMTTime();
- int difference = (DayOfWeek.Sunday - nowTime.DayOfWeek + 7) % 7; //1-7的结果0-6
- var day = nowTime.ToString("yyyyMMdd");
- string redisKey = $"Accumulate:Daily:{scope}:{key}:{day}";
- string member = $"{target}::{id}::{client}::{name}";
- await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, count);
- await azureRedis.GetRedisClient(8).KeyExpireAsync(redisKey, new TimeSpan((difference+1)*24, 10, 0));
- //if (key.Equals("lesson") || key.StartsWith("login_"))
- //{
- // redisKey = $"Accumulate:Daily:ies:{key}:{day}";
- // if (scope.Equals("school"))
- // {
- // member = $"ies::{id}::{name}";
- // }
- // else {
- // member = $"ies::ies::{name}";
- // }
- // await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, 1);
- //}
- }
- }
- public const double timeWeight = 0.7;
- public const double countWeight = 0.3;
- static double GetUserDuration(List<long> times)
- {
- if (times.IsNotEmpty())
- {
- if (times.Count>=2)
- {
- double totalDuration = 0;
- // DateTime lastTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsonData[0]["time"]).UtcDateTime;
- long ltime = times[0];
- for (int i = 1; i < times.Count; i++)
- {
- long ctime = times[i];
- //DateTime currentTime = DateTimeOffset.FromUnixTimeMilliseconds((long)jsonData[i]["time"]).UtcDateTime;
- long timeDifference = ctime - ltime;
- ///如果一小时内连续操作,则按真实时间累计
- if (timeDifference < 3600000)
- {
- totalDuration += timeDifference;
- }
- else
- { ///如果一小时内没有连续操作,则按象征性加10秒,以确保数据有效性。 如果因为一小时没有操作,则表示没有新的接口再次请求,当即就已经退出系统。否则后续仍然会有接口进入,并且带有时间戳
- totalDuration += 10000;
- }
- ltime = ctime;
- }
- return totalDuration;
- }
- else { return 10000; }
- }
- else
- {
- return 0;
- }
- }
- public static List<SchoolStick> CountSchoolStickiness(IEnumerable<IGrouping<string, ApiVisit>> schoolApiVisits, IEnumerable<ApiVisit> apiVisits, List<SchoolStick> bygoneStickiness)
- {
- List<SchoolStick> schoolStickiness = new List<SchoolStick>();
- //用于做标准化值的最大最小度量值
- double max_sch_hita_c = 0, max_sch_hiteach_c = 0, max_sch_ies5Tch_c = 0, max_sch_otherTch_c = 0, max_sch_ies5Stu_c = 0, max_sch_otherStu_c = 0;
- double max_sch_hita_d = 0, max_sch_hiteach_d = 0, max_sch_ies5Tch_d = 0, max_sch_otherTch_d = 0, max_sch_ies5Stu_d = 0, max_sch_otherStu_d = 0;
- double min_sch_hita_c = 0, min_sch_hiteach_c = 0, min_sch_ies5Tch_c = 0, min_sch_otherTch_c = 0, min_sch_ies5Stu_c = 0, min_sch_otherStu_c = 0;
- double min_sch_hita_d = 0, min_sch_hiteach_d = 0, min_sch_ies5Tch_d = 0, min_sch_otherTch_d = 0, min_sch_ies5Stu_d = 0, min_sch_otherStu_d = 0;
- double max_tch_hita_c = 0, max_tch_hiteach_c = 0, max_tch_ies5Tch_c = 0, max_tch_otherTch_c = 0;
- double max_tch_hita_d = 0, max_tch_hiteach_d = 0, max_tch_ies5Tch_d = 0, max_tch_otherTch_d = 0;
- double min_tch_hita_c = 0, min_tch_hiteach_c = 0, min_tch_ies5Tch_c = 0, min_tch_otherTch_c = 0;
- double min_tch_hita_d = 0, min_tch_hiteach_d = 0, min_tch_ies5Tch_d = 0, min_tch_otherTch_d = 0;
- foreach (var chinaSchoolKey in schoolApiVisits)
- {
- SchoolStick stickiness = new SchoolStick()
- {
- id = chinaSchoolKey.Key
- };
- var teachers = chinaSchoolKey.ToList().Where(x => !string.IsNullOrWhiteSpace(x.userId) && !string.IsNullOrWhiteSpace(x.scope) && x.scope.Equals("teacher")).GroupBy(x => x.userId);
- double hitaTime = 0, hiteachTime = 0, ies5TchTime = 0, otherTchTime = 0, ies5StuTime = 0, otherStuTime = 0;
- int hitaTch = 0, hiteachTch = 0, ies5Tch = 0, otherTch = 0, ies5Stu = 0, otherStu = 0;
- double hitaCount = 0, hiteachCount = 0, ies5TchCount = 0, otherTchCount = 0, ies5StuCount = 0, otherStuCount = 0;
- double lessonCount = chinaSchoolKey.ToList().Where(x => x.path.Contains("hiteach/create-lesson")).Count();
- int teacherCount = teachers.Count();
- double max_stu_ies5Stu_c = 0, max_stu_otherStu_c = 0;
- double max_stu_ies5Stu_d = 0, max_stu_otherStu_d = 0;
- double min_stu_ies5Stu_c = 0, min_stu_otherStu_c = 0;
- double min_stu_ies5Stu_d = 0, min_stu_otherStu_d = 0;
- foreach (var user in teachers)
- {
- TchStick tchStick = new TchStick()
- {
- id = user.Key,
- school= chinaSchoolKey.Key
- };
- //HiTA
- var teacherHitaVisit = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.userId) && x.userId.Equals(user.Key) && x.client.Equals("hita"));
- var teacherHitaVisitCount = teacherHitaVisit.Count();
- if (teacherHitaVisitCount>0)
- { hitaTch+=1; }
- var teacherHitaVisitTime = GetUserDuration(teacherHitaVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
- hitaCount+=teacherHitaVisitCount;
- hitaTime+=teacherHitaVisitTime;
- tchStick.hita.count.value=teacherHitaVisitCount;
- tchStick.hita.duration.value=teacherHitaVisitTime;
- //Other
- var teacherOtherVisit = user.Where(x => !x.client.Equals("hita")&&!x.client.Equals("hiteach")&&!x.client.Equals("ies5"));
- var teacherOtherVisitCount = teacherOtherVisit.Count();
- var teacherOtherVisitTime = GetUserDuration(teacherOtherVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
- if (teacherOtherVisitCount>0)
- { otherTch+=1; }
- otherTchCount+=teacherOtherVisitCount;
- otherTchTime+=teacherOtherVisitTime;
- tchStick.otherTch.count.value=teacherOtherVisitCount;
- tchStick.otherTch.duration.value=teacherOtherVisitTime;
- //HiTeach
- //教师访问hiteach 不带学校信息的
- var teacherHiteachVisit = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.userId) && x.userId.Equals(user.Key) && x.client.Equals("hiteach") && string.IsNullOrWhiteSpace(x.school));
- //教师访问hiteach 包含学校信息的
- var teacherHiteachSchoolVisit = user.Where(x => x.client.Equals("hiteach"));
- //教师所有的Hiteach访问
- List<ApiVisit> teacherHiteachAllVisit = new List<ApiVisit>();
- teacherHiteachAllVisit.AddRange(teacherHiteachVisit);
- teacherHiteachAllVisit.AddRange(teacherHiteachSchoolVisit);
- var teacherHiteachAllVisitCount = teacherHiteachAllVisit.Count();
- if (teacherHiteachAllVisitCount>0)
- { hiteachTch+=1; }
- var teacherHiteachAllVisitTime = GetUserDuration(teacherHiteachAllVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
- hiteachCount+=teacherHiteachAllVisitCount;
- hiteachTime+=teacherHiteachAllVisitTime;
- tchStick.hiteach.count.value=teacherHiteachAllVisitCount;
- tchStick.hiteach.duration.value=teacherHiteachAllVisitTime;
- //IES5
- var teacherIes5Visit = user.Where(x => x.client.Equals("ies5"));
- var teacherIes5VisitCount = teacherIes5Visit.Count();
- if (teacherIes5VisitCount>0)
- { ies5Tch+=1; }
- var teacherIes5VisitTime = GetUserDuration(teacherIes5Visit.OrderBy(x => x.time).Select(x => x.time).ToList());
- ies5TchCount+=teacherIes5VisitCount;
- ies5TchTime+=teacherIes5VisitTime;
- tchStick.ies5Tch.count.value=teacherIes5VisitCount;
- tchStick.ies5Tch.duration.value=teacherIes5VisitTime;
- double lessonCountTch = chinaSchoolKey.ToList().Where(x => x.path.Contains("hiteach/create-lesson") && x.userId.Equals(user.Key)).Count();
- tchStick.lesson.value=lessonCountTch;
- tchStick.teacher.count.value=tchStick.hita.count.value+tchStick.hiteach.count.value+tchStick.ies5Tch.count.value+tchStick.otherTch.count.value;
- tchStick.teacher.duration.value=tchStick.hita.duration.value+tchStick.hiteach.duration.value+tchStick.ies5Tch.duration.value+tchStick.otherTch.duration.value;
- tchStick.hita.userCount=1;
- tchStick.hiteach.userCount=1;
- tchStick.ies5Tch.userCount=1;
- tchStick.otherTch.userCount=1;
- tchStick.teacher.userCount=1;
- //if (tchStick.hita.count.value>0 && tchStick.hita.duration.value>0)
- //{
- // tchStick.hita.stick.value= (tchStick.hita.duration.value/1000/tchStick.hita.count.value * tchStick.hita.count.value/tchStick.teacher.count.value);
- //}
- //if (tchStick.ies5Tch.count.value>0 && tchStick.ies5Tch.duration.value>0)
- //{
- // tchStick.ies5Tch.stick.value= (tchStick.ies5Tch.duration.value/1000/tchStick.ies5Tch.count.value * tchStick.ies5Tch.count.value/tchStick.teacher.count.value);
- //}
- //if (tchStick.otherTch.count.value>0 && tchStick.otherTch.duration.value>0)
- //{
- // tchStick.otherTch.stick.value= (tchStick.otherTch.duration.value/1000/tchStick.otherTch.count.value);
- //}
- //if (tchStick.hiteach.count.value>0 && tchStick.hiteach.duration.value>0)
- //{
- // tchStick.hiteach.stick.value= (tchStick.hiteach.duration.value/1000/tchStick.hiteach.count.value)+(tchStick.lesson.value*100);
- //}
- //if (tchStick.teacher.count.value>0 && tchStick.teacher.duration.value>0)
- //{
- // tchStick.teacher.stick.value= (tchStick.teacher.duration.value/1000/tchStick.teacher.count.value)+ (tchStick.lesson.value*100);
- //}
- #region
- if (tchStick.hita.count.value>0)
- {
- if (min_tch_hita_c ==0)
- {
- min_tch_hita_c= tchStick.hita.count.value;
- }
- else if (min_tch_hita_c>tchStick.hita.count.value)
- {
- min_tch_hita_c=tchStick.hita.count.value;
- }
- if (tchStick.hita.count.value>max_tch_hita_c)
- {
- max_tch_hita_c= tchStick.hita.count.value;
- }
- }
- if (tchStick.hiteach.count.value>0)
- {
- if (min_tch_hiteach_c ==0)
- {
- min_tch_hiteach_c= tchStick.hiteach.count.value;
- }
- else if (min_tch_hiteach_c>tchStick.hiteach.count.value)
- {
- min_tch_hiteach_c=tchStick.hiteach.count.value;
- }
- if (tchStick.hiteach.count.value>max_tch_hiteach_c)
- {
- max_tch_hiteach_c= tchStick.hiteach.count.value;
- }
- }
- if (tchStick.ies5Tch.count.value>0)
- {
- if (min_tch_ies5Tch_c ==0)
- {
- min_tch_ies5Tch_c= tchStick.ies5Tch.count.value;
- }
- else if (min_tch_ies5Tch_c>tchStick.ies5Tch.count.value)
- {
- min_tch_ies5Tch_c=tchStick.ies5Tch.count.value;
- }
- if (tchStick.ies5Tch.count.value>max_tch_ies5Tch_c)
- {
- max_tch_ies5Tch_c= tchStick.ies5Tch.count.value;
- }
- }
- if (tchStick.otherTch.count.value>0)
- {
- if (min_tch_otherTch_c ==0)
- {
- min_tch_otherTch_c= tchStick.otherTch.count.value;
- }
- else if (min_tch_otherTch_c>tchStick.otherTch.count.value)
- {
- min_tch_otherTch_c=tchStick.otherTch.count.value;
- }
- if (tchStick.otherTch.count.value>max_tch_otherTch_c)
- {
- max_tch_otherTch_c= tchStick.otherTch.count.value;
- }
- }
- if (tchStick.hita.duration.value>0)
- {
- if (min_tch_hita_d ==0)
- {
- min_tch_hita_d= tchStick.hita.duration.value;
- }
- else if (min_tch_hita_d>tchStick.hita.duration.value)
- {
- min_tch_hita_d=tchStick.hita.duration.value;
- }
- if (tchStick.hita.duration.value>max_tch_hita_d)
- {
- max_tch_hita_d= tchStick.hita.duration.value;
- }
- }
- if (tchStick.hiteach.duration.value>0)
- {
- if (min_tch_hiteach_d ==0)
- {
- min_tch_hiteach_d= tchStick.hiteach.duration.value;
- }
- else if (min_tch_hiteach_d>tchStick.hiteach.duration.value)
- {
- min_tch_hiteach_d=tchStick.hiteach.duration.value;
- }
- if (tchStick.hiteach.duration.value>max_tch_hiteach_d)
- {
- max_tch_hiteach_d= tchStick.hiteach.duration.value;
- }
- }
- if (tchStick.ies5Tch.duration.value>0)
- {
- if (min_tch_ies5Tch_d ==0)
- {
- min_tch_ies5Tch_d= tchStick.ies5Tch.duration.value;
- }
- else if (min_tch_ies5Tch_d>tchStick.ies5Tch.duration.value)
- {
- min_tch_ies5Tch_d=tchStick.ies5Tch.duration.value;
- }
- if (tchStick.ies5Tch.duration.value>max_tch_ies5Tch_d)
- {
- max_tch_ies5Tch_d= tchStick.ies5Tch.duration.value;
- }
- }
- if (tchStick.otherTch.duration.value>0)
- {
- if (min_tch_otherTch_d ==0)
- {
- min_tch_otherTch_d= tchStick.otherTch.duration.value;
- }
- else if (min_tch_otherTch_d>tchStick.otherTch.duration.value)
- {
- min_tch_otherTch_d=tchStick.otherTch.duration.value;
- }
- if (tchStick.otherTch.duration.value>max_tch_otherTch_d)
- {
- max_tch_otherTch_d= tchStick.otherTch.duration.value;
- }
- }
- #endregion
- stickiness.tchSticks.Add(tchStick);
- }
- 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);
- var studentCount = student.Count();
- foreach (var user in student)
- {
- StuStick stuStick = new StuStick
- {
- id=user.Key,
- school=chinaSchoolKey.Key
- };
- var studentOtherVisit = user.Where(x => !x.client.Equals("ies5"));
- var studentOtherVisitCount = studentOtherVisit.Count();
- if (studentOtherVisitCount>0)
- { otherStu+=1; }
- double studentOtherVisitTime = GetUserDuration(studentOtherVisit.OrderBy(x => x.time).Select(x => x.time).ToList());
- var studentIes5Visit = user.Where(x => x.client.Equals("ies5"));
- var studentIes5VisitCount = studentIes5Visit.Count();
- if (studentIes5VisitCount>0)
- { ies5Stu+=1; }
- double studentIes5VisitTime = GetUserDuration(studentIes5Visit.OrderBy(x => x.time).Select(x => x.time).ToList());
- ies5StuCount+=studentIes5VisitCount;
- ies5StuTime+=studentIes5VisitTime;
- otherStuCount+=studentOtherVisitCount;
- otherStuTime+=studentOtherVisitTime;
- stuStick.ies5Stu.count.value=studentIes5VisitCount;
- stuStick.ies5Stu.duration.value=studentIes5VisitTime;
- stuStick.otherStu.count.value=studentOtherVisitCount;
- stuStick.otherStu.duration.value=studentOtherVisitTime;
- stuStick.student.count.value= stuStick.ies5Stu.count.value+stuStick.otherStu.count.value;
- stuStick.student.duration.value= stuStick.ies5Stu.duration.value+stuStick.otherStu.duration.value;
- stuStick.ies5Stu.userCount=1;
- stuStick.otherStu.userCount=1;
- stuStick.student.userCount=1;
- //if (stuStick.ies5Stu.count.value>0 && stuStick.ies5Stu.duration.value>0)
- //{
- // stuStick.ies5Stu.stick.value= (stuStick.ies5Stu.duration.value/1000/stuStick.ies5Stu.count.value);
- //}
- //if (stuStick.otherStu.count.value>0 && stuStick.otherStu.duration.value>0)
- //{
- // stuStick.otherStu.stick.value=(stuStick.otherStu.duration.value/1000/stuStick.otherStu.count.value);
- //}
- //if (stuStick.student.count.value>0 && stuStick.student.duration.value>0)
- //{
- // stuStick.student.stick.value=(stuStick.student.duration.value/1000/stuStick.student.count.value);
- //}
- #region
- if (stuStick.otherStu.count.value>0)
- {
- if (min_stu_otherStu_c ==0)
- {
- min_stu_otherStu_c= stuStick.otherStu.count.value;
- }
- else if (min_stu_otherStu_c>stuStick.otherStu.count.value)
- {
- min_stu_otherStu_c=stuStick.otherStu.count.value;
- }
- if (stuStick.otherStu.count.value>max_stu_otherStu_c)
- {
- max_stu_otherStu_c= stuStick.otherStu.count.value;
- }
- }
- if (stuStick.ies5Stu.count.value>0)
- {
- if (min_stu_ies5Stu_c ==0)
- {
- min_stu_ies5Stu_c= stuStick.ies5Stu.count.value;
- }
- else if (min_stu_ies5Stu_c>stuStick.ies5Stu.count.value)
- {
- min_stu_ies5Stu_c=stuStick.ies5Stu.count.value;
- }
- if (stuStick.ies5Stu.count.value>max_stu_ies5Stu_c)
- {
- max_stu_ies5Stu_c= stuStick.ies5Stu.count.value;
- }
- }
- if (stuStick.otherStu.duration.value>0)
- {
- if (min_stu_otherStu_d ==0)
- {
- min_stu_otherStu_d= stuStick.otherStu.duration.value;
- }
- else if (min_stu_otherStu_d>stuStick.otherStu.duration.value)
- {
- min_stu_otherStu_d=stuStick.otherStu.duration.value;
- }
- if (stuStick.otherStu.duration.value>max_stu_otherStu_d)
- {
- max_stu_otherStu_d= stuStick.otherStu.duration.value;
- }
- }
- if (stuStick.ies5Stu.duration.value>0)
- {
- if (min_stu_ies5Stu_d ==0)
- {
- min_stu_ies5Stu_d= stuStick.ies5Stu.duration.value;
- }
- else if (min_stu_ies5Stu_d>stuStick.ies5Stu.duration.value)
- {
- min_stu_ies5Stu_d=stuStick.ies5Stu.duration.value;
- }
- if (stuStick.ies5Stu.duration.value>max_stu_ies5Stu_d)
- {
- max_stu_ies5Stu_d= stuStick.ies5Stu.duration.value;
- }
- }
- #endregion
- stickiness.stuSticks.Add(stuStick);
- }
- //时长
- stickiness.hita.duration.value=hitaTime;
- stickiness.hiteach.duration.value=hiteachTime;
- stickiness.otherTch.duration.value=otherTchTime;
- stickiness.ies5Tch.duration.value=ies5TchTime;
- stickiness.ies5Stu.duration.value=ies5StuTime;
- stickiness.otherStu.duration.value=otherStuTime;
- stickiness.teacher.duration.value=hitaTime+hiteachTime+otherTchTime+ies5TchTime;
- stickiness.student.duration.value=otherStuTime+ies5StuTime;
- //用户数
- stickiness.hita.userCount=hitaTch;
- stickiness.hiteach.userCount=hiteachTch;
- stickiness.ies5Tch.userCount=ies5Tch;
- stickiness.otherTch.userCount=otherTch;
- stickiness.ies5Stu.userCount=ies5Stu;
- stickiness.otherStu.userCount=otherStu;
- stickiness.teacher.userCount=teacherCount;
- stickiness.student.userCount=studentCount;
- //访问数
- stickiness.hita.count.value=hitaCount;
- stickiness.hiteach.count.value=hiteachCount;
- stickiness.ies5Tch.count.value=ies5TchCount;
- stickiness.otherTch.count.value=otherTchCount;
- stickiness.ies5Stu.count.value=ies5StuCount;
- stickiness.otherStu.count.value=otherStuCount;
- stickiness.teacher.count.value=hitaCount+hiteachCount+ies5TchCount+otherTchCount;
- stickiness.student.count.value=ies5StuCount+otherStuCount;
- //开课数
- stickiness.lesson.value=lessonCount;
- //if (stickiness.hita.count.value>0 && stickiness.hita.duration.value>0)
- //{
- // stickiness.hita.stick.value=(stickiness.hita.userCount* stickiness.hita.count.value)/(stickiness.hita.duration.value/1000/stickiness.hita.count.value);
- //}
- //if (stickiness.ies5Stu.count.value>0 && stickiness.ies5Stu.duration.value>0)
- //{
- // stickiness.ies5Stu.stick.value=(stickiness.ies5Stu.userCount* stickiness.ies5Stu.count.value)/(stickiness.ies5Stu.duration.value/1000/stickiness.ies5Stu.count.value);
- //}
- //if (stickiness.ies5Tch.count.value>0 && stickiness.ies5Tch.duration.value>0)
- //{
- // stickiness.ies5Tch.stick.value=(stickiness.ies5Tch.userCount* stickiness.ies5Tch.count.value)/(stickiness.ies5Tch.duration.value/1000/stickiness.ies5Tch.count.value);
- //}
- //if (stickiness.otherStu.count.value>0 && stickiness.otherStu.duration.value>0)
- //{
- // stickiness.otherStu.stick.value=(stickiness.otherStu.userCount* stickiness.otherStu.count.value)/(stickiness.otherStu.duration.value/1000/stickiness.otherStu.count.value);
- //}
- //if (stickiness.otherTch.count.value>0 && stickiness.otherTch.duration.value>0)
- //{
- // stickiness.otherTch.stick.value=(stickiness.otherTch.userCount* stickiness.otherTch.count.value)/(stickiness.otherTch.duration.value/1000/stickiness.otherTch.count.value);
- //}
- //if (stickiness.hiteach.count.value>0 && stickiness.hiteach.duration.value>0)
- //{
- // stickiness.hiteach.stick.value=(stickiness.hiteach.userCount* stickiness.hiteach.count.value)/(stickiness.hiteach.duration.value/1000/stickiness.hiteach.count.value)+stickiness.lesson.value;
- //}
- //if (stickiness.teacher.count.value>0 && stickiness.teacher.duration.value>0)
- //{
- // stickiness.teacher.stick.value=(stickiness.teacher.userCount* stickiness.teacher.count.value)/(stickiness.teacher.duration.value/1000/stickiness.teacher.count.value)+ stickiness.lesson.value;
- //}
- //if (stickiness.student.count.value>0 && stickiness.student.duration.value>0)
- //{
- // stickiness.student.stick.value=(stickiness.student.userCount* stickiness.student.count.value)/(stickiness.student.duration.value/1000/stickiness.student.count.value)+ stickiness.lesson.value;
- //}
- #region
- if (stickiness.hita.count.value>0)
- {
- if (min_sch_hita_c ==0)
- {
- min_sch_hita_c= stickiness.hita.count.value;
- }
- else if (min_sch_hita_c>stickiness.hita.count.value)
- {
- min_sch_hita_c=stickiness.hita.count.value;
- }
- if (stickiness.hita.count.value>max_sch_hita_c)
- {
- max_sch_hita_c= stickiness.hita.count.value;
- }
- }
- if (stickiness.hiteach.count.value>0)
- {
- if (min_sch_hiteach_c ==0)
- {
- min_sch_hiteach_c= stickiness.hiteach.count.value;
- }
- else if (min_sch_hiteach_c>stickiness.hiteach.count.value)
- {
- min_sch_hiteach_c=stickiness.hiteach.count.value;
- }
- if (stickiness.hiteach.count.value>max_sch_hiteach_c)
- {
- max_sch_hiteach_c= stickiness.hiteach.count.value;
- }
- }
- if (stickiness.ies5Tch.count.value>0)
- {
- if (min_sch_ies5Tch_c ==0)
- {
- min_sch_ies5Tch_c= stickiness.ies5Tch.count.value;
- }
- else if (min_sch_ies5Tch_c>stickiness.ies5Tch.count.value)
- {
- min_sch_ies5Tch_c=stickiness.ies5Tch.count.value;
- }
- if (stickiness.ies5Tch.count.value>max_sch_ies5Tch_c)
- {
- max_sch_ies5Tch_c= stickiness.ies5Tch.count.value;
- }
- }
- if (stickiness.otherTch.count.value>0)
- {
- if (min_sch_otherTch_c ==0)
- {
- min_sch_otherTch_c= stickiness.otherTch.count.value;
- }
- else if (min_sch_otherTch_c>stickiness.otherTch.count.value)
- {
- min_sch_otherTch_c=stickiness.otherTch.count.value;
- }
- if (stickiness.otherTch.count.value>max_sch_otherTch_c)
- {
- max_sch_otherTch_c= stickiness.otherTch.count.value;
- }
- }
- if (stickiness.otherStu.count.value>0)
- {
- if (min_sch_otherStu_c ==0)
- {
- min_sch_otherStu_c= stickiness.otherStu.count.value;
- }
- else if (min_sch_otherStu_c>stickiness.otherStu.count.value)
- {
- min_sch_otherStu_c=stickiness.otherStu.count.value;
- }
- if (stickiness.otherStu.count.value>max_sch_otherStu_c)
- {
- max_sch_otherStu_c= stickiness.otherStu.count.value;
- }
- }
- if (stickiness.ies5Stu.count.value>0)
- {
- if (min_sch_ies5Stu_c ==0)
- {
- min_sch_ies5Stu_c= stickiness.ies5Stu.count.value;
- }
- else if (min_sch_ies5Stu_c>stickiness.ies5Stu.count.value)
- {
- min_sch_ies5Stu_c=stickiness.ies5Stu.count.value;
- }
- if (stickiness.ies5Stu.count.value>max_sch_ies5Stu_c)
- {
- max_sch_ies5Stu_c= stickiness.ies5Stu.count.value;
- }
- }
- if (stickiness.hita.duration.value>0)
- {
- if (min_sch_hita_d ==0)
- {
- min_sch_hita_d= stickiness.hita.duration.value;
- }
- else if (min_sch_hita_d>stickiness.hita.duration.value)
- {
- min_sch_hita_d=stickiness.hita.duration.value;
- }
- if (stickiness.hita.duration.value>max_sch_hita_d)
- {
- max_sch_hita_d= stickiness.hita.duration.value;
- }
- }
- if (stickiness.hiteach.duration.value>0)
- {
- if (min_sch_hiteach_d ==0)
- {
- min_sch_hiteach_d= stickiness.hiteach.duration.value;
- }
- else if (min_sch_hiteach_d>stickiness.hiteach.duration.value)
- {
- min_sch_hiteach_d=stickiness.hiteach.duration.value;
- }
- if (stickiness.hiteach.duration.value>max_sch_hiteach_d)
- {
- max_sch_hiteach_d= stickiness.hiteach.duration.value;
- }
- }
- if (stickiness.ies5Tch.duration.value>0)
- {
- if (min_sch_ies5Tch_d ==0)
- {
- min_sch_ies5Tch_d= stickiness.ies5Tch.duration.value;
- }
- else if (min_sch_ies5Tch_d>stickiness.ies5Tch.duration.value)
- {
- min_sch_ies5Tch_d=stickiness.ies5Tch.duration.value;
- }
- if (stickiness.ies5Tch.duration.value>max_sch_ies5Tch_d)
- {
- max_sch_ies5Tch_d= stickiness.ies5Tch.duration.value;
- }
- }
- if (stickiness.otherTch.duration.value>0)
- {
- if (min_sch_otherTch_d ==0)
- {
- min_sch_otherTch_d= stickiness.otherTch.duration.value;
- }
- else if (min_sch_otherTch_d>stickiness.otherTch.duration.value)
- {
- min_sch_otherTch_d=stickiness.otherTch.duration.value;
- }
- if (stickiness.otherTch.duration.value>max_sch_otherTch_d)
- {
- max_sch_otherTch_d= stickiness.otherTch.duration.value;
- }
- }
- if (stickiness.otherStu.duration.value>0)
- {
- if (min_sch_otherStu_d ==0)
- {
- min_sch_otherStu_d= stickiness.otherStu.duration.value;
- }
- else if (min_sch_otherStu_d>stickiness.otherStu.duration.value)
- {
- min_sch_otherStu_d=stickiness.otherStu.duration.value;
- }
- if (stickiness.otherStu.duration.value>max_sch_otherStu_d)
- {
- max_sch_otherStu_d= stickiness.otherStu.duration.value;
- }
- }
- if (stickiness.ies5Stu.duration.value>0)
- {
- if (min_sch_ies5Stu_d ==0)
- {
- min_sch_ies5Stu_d= stickiness.ies5Stu.duration.value;
- }
- else if (min_sch_ies5Stu_d>stickiness.ies5Stu.duration.value)
- {
- min_sch_ies5Stu_d=stickiness.ies5Stu.duration.value;
- }
- if (stickiness.ies5Stu.duration.value>max_sch_ies5Stu_d)
- {
- max_sch_ies5Stu_d= stickiness.ies5Stu.duration.value;
- }
- }
- #endregion
- var bygoneStickinessSchool = bygoneStickiness?.Find(x => x.id.Equals(chinaSchoolKey.Key));
- stickiness.tchSticks= OrderByTchStick(stickiness.tchSticks, bygoneStickinessSchool?.tchSticks);
- stickiness.stuSticks= OrderByStuStick(stickiness.stuSticks, bygoneStickinessSchool?.stuSticks);
- schoolStickiness.Add(stickiness);
- }
- return OrderBySchoolStick(schoolStickiness, bygoneStickiness);
- }
- private static List<StuStick> OrderByStuStick(List<StuStick> currentStickiness, List<StuStick>? bygoneStickiness)
- {
- // 假设visit已经填充了数据
- #region
- var rank_tmd_count = currentStickiness.Select(x => x.student.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Stu_count = currentStickiness.Select(x => x.ies5Stu.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherStu_count = currentStickiness.Select(x => x.otherStu.count.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- #region
- var rank_tmd_duration = currentStickiness.Select(x => x.student.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Stu_duration = currentStickiness.Select(x => x.ies5Stu.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherStu_duration = currentStickiness.Select(x => x.otherStu.duration.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- #region
- var rank_tmd_stick = currentStickiness.Select(x => x.student.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Stu_stick = currentStickiness.Select(x => x.ies5Stu.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherStu_stick = currentStickiness.Select(x => x.otherStu.stick.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- currentStickiness.ForEach(x =>
- {
- #region
- if (x.student.count.value>0)
- {
- int index_tmd_count = rank_tmd_count.FindIndex(i => i==x.student.count.value);
- if (index_tmd_count!=-1)
- {
- x.student.count.rank = index_tmd_count + 1;
- }
- }
- if (x.ies5Stu.count.value>0)
- {
- int index_ies5Stu_count = rank_ies5Stu_count.FindIndex(i => i==x.ies5Stu.count.value);
- if (index_ies5Stu_count!=-1)
- {
- x.ies5Stu.count.rank = index_ies5Stu_count + 1;
- }
- }
- if (x.otherStu.count.value>0)
- {
- int index_otherStu_count = rank_otherStu_count.FindIndex(i => i==x.otherStu.count.value);
- if (index_otherStu_count!=-1)
- {
- x.otherStu.count.rank = index_otherStu_count + 1;
- }
- }
- #endregion
- #region
- if (x.student.duration.value> 0)
- {
- int index_tmd_duration = rank_tmd_duration.FindIndex(i => i==x.student.duration.value);
- if (index_tmd_duration!=-1)
- {
- x.student.duration.rank = index_tmd_duration + 1;
- }
- }
- if (x.ies5Stu.duration.value>0)
- {
- int index_ies5Stu_duration = rank_ies5Stu_duration.FindIndex(i => i==x.ies5Stu.duration.value);
- if (index_ies5Stu_duration!=-1)
- {
- x.ies5Stu.duration.rank = index_ies5Stu_duration + 1;
- }
- }
- if (x.otherStu.duration.value>0)
- {
- int index_otherStu_duration = rank_otherStu_duration.FindIndex(i => i==x.otherStu.duration.value);
- if (index_otherStu_duration!=-1)
- {
- x.otherStu.duration.rank = index_otherStu_duration + 1;
- }
- }
- #endregion
- #region
- if (x.student.stick.value>0)
- {
- int index_tmd_stick = rank_tmd_stick.FindIndex(i => i==x.student.stick.value);
- if (index_tmd_stick!=-1)
- {
- x.student.stick.rank = index_tmd_stick + 1;
- }
- }
- if (x.ies5Stu.stick.value>0)
- {
- int index_ies5Stu_stick = rank_ies5Stu_stick.FindIndex(i => i==x.ies5Stu.stick.value);
- if (index_ies5Stu_stick!=-1)
- {
- x.ies5Stu.stick.rank = index_ies5Stu_stick + 1;
- }
- }
- if (x.otherStu.stick.value>0)
- {
- int index_otherStu_stick = rank_otherStu_stick.FindIndex(i => i==x.otherStu.stick.value);
- if (index_otherStu_stick!=-1)
- {
- x.otherStu.stick.rank = index_otherStu_stick + 1;
- }
- }
- #endregion
- var bygone = bygoneStickiness?.Find(y => y.id.Equals(x.id));
- if (bygone!=null)
- {
- #region tmd
- //人数上升下降
- x.student.userUpdown= x.student.userCount-bygone.student.userCount;
- //访问数量上升下降
- x.student.count.range= x.student.count.value-bygone.student.count.value;
- //访问数量排名上升下降
- x.student.count.updown= -(x.student.count.rank-bygone.student.count.rank);
- //停留时长上升下降
- x.student.duration.range=x.student.duration.value-bygone.student.duration.value;
- //停留时长排名上升下降
- x.student.duration.updown=-(x.student.duration.rank-bygone.student.duration.rank);
- //访问指数上升下降
- x.student.stick.range=x.student.stick.value-bygone.student.stick.value;
- //访问指数排名上升下降
- x.student.stick.updown=-(x.student.stick.rank-bygone.student.stick.rank);
- #endregion
- #region otherStu
- //人数上升下降
- x.otherStu.userUpdown= x.otherStu.userCount-bygone.otherStu.userCount;
- //访问数量上升下降
- x.otherStu.count.range= x.otherStu.count.value-bygone.otherStu.count.value;
- //访问数量排名上升下降
- x.otherStu.count.updown= -(x.otherStu.count.rank-bygone.otherStu.count.rank);
- //停留时长上升下降
- x.otherStu.duration.range=x.otherStu.duration.value-bygone.otherStu.duration.value;
- //停留时长排名上升下降
- x.otherStu.duration.updown=-(x.otherStu.duration.rank - bygone.otherStu.duration.rank);
- //访问指数上升下降
- x.otherStu.stick.range=x.otherStu.stick.value-bygone.otherStu.stick.value;
- //访问指数排名上升下降
- x.otherStu.stick.updown=-(x.otherStu.stick.rank - bygone.otherStu.stick.rank);
- #endregion
- #region ies5Stu
- //人数上升下降
- x.ies5Stu.userUpdown= x.ies5Stu.userCount-bygone.ies5Stu.userCount;
- //访问数量上升下降
- x.ies5Stu.count.range= x.ies5Stu.count.value-bygone.ies5Stu.count.value;
- //访问数量排名上升下降
- x.ies5Stu.count.updown= -(x.ies5Stu.count.rank - bygone.ies5Stu.count.rank);
- //停留时长上升下降
- x.ies5Stu.duration.range=x.ies5Stu.duration.value-bygone.ies5Stu.duration.value;
- //停留时长排名上升下降
- x.ies5Stu.duration.updown=-(x.ies5Stu.duration.rank - bygone.ies5Stu.duration.rank);
- //访问指数上升下降
- x.ies5Stu.stick.range=x.ies5Stu.stick.value-bygone.ies5Stu.stick.value;
- //访问指数排名上升下降
- x.ies5Stu.stick.updown=-(x.ies5Stu.stick.rank - bygone.ies5Stu.stick.rank);
- #endregion
- }
- else
- {
- #region tmd
- //人数上升下降
- x.student.userUpdown= x.student.userCount;
- //访问数量上升下降
- x.student.count.range= x.student.count.value;
- //访问数量排名上升下降
- x.student.count.updown= x.student.count.rank;
- //停留时长上升下降
- x.student.duration.range=x.student.duration.value;
- //停留时长排名上升下降
- x.student.duration.updown=x.student.duration.rank;
- //访问指数上升下降
- x.student.stick.range=x.student.stick.value;
- //访问指数排名上升下降
- x.student.stick.updown=x.student.stick.rank;
- #endregion
- #region otherStu
- //人数上升下降
- x.otherStu.userUpdown= x.otherStu.userCount;
- //访问数量上升下降
- x.otherStu.count.range= x.otherStu.count.value;
- //访问数量排名上升下降
- x.otherStu.count.updown= x.otherStu.count.rank;
- //停留时长上升下降
- x.otherStu.duration.range=x.otherStu.duration.value;
- //停留时长排名上升下降
- x.otherStu.duration.updown=x.otherStu.duration.rank;
- //访问指数上升下降
- x.otherStu.stick.range=x.otherStu.stick.value;
- //访问指数排名上升下降
- x.otherStu.stick.updown=x.otherStu.stick.rank;
- #endregion
- #region ies5Stu
- //人数上升下降
- x.ies5Stu.userUpdown= x.ies5Stu.userCount;
- //访问数量上升下降
- x.ies5Stu.count.range= x.ies5Stu.count.value;
- //访问数量排名上升下降
- x.ies5Stu.count.updown= x.ies5Stu.count.rank;
- //停留时长上升下降
- x.ies5Stu.duration.range=x.ies5Stu.duration.value;
- //停留时长排名上升下降
- x.ies5Stu.duration.updown=x.ies5Stu.duration.rank;
- //访问指数上升下降
- x.ies5Stu.stick.range=x.ies5Stu.stick.value;
- //访问指数排名上升下降
- x.ies5Stu.stick.updown=x.ies5Stu.stick.rank;
- #endregion
- }
- });
- //当前时间没有的
- var disappears = bygoneStickiness?.Where(x => x.student.stick.value!=0).ExceptBy(currentStickiness.Select(x => x.id), y => y.id);
- if (disappears!=null && disappears.Count()>0)
- {
- double rank_tmd_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.student.stick.rank).Max() : 0;
- double rank_tmd_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.student.count.rank).Max() : 0;
- double rank_tmd_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.student.duration.rank).Max() : 0;
- double rank_ies5Stu_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Stu.stick.rank).Max() : 0;
- double rank_ies5Stu_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Stu.count.rank).Max() : 0;
- double rank_ies5Stu_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Stu.duration.rank).Max() : 0;
- double rank_otherStu_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherStu.stick.rank).Max() : 0;
- double rank_otherStu_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherStu.count.rank).Max() : 0;
- double rank_otherStu_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherStu.duration.rank).Max() : 0;
- foreach (var disappear in disappears)
- {
- //下降
- // y 5 t0
- disappear.student.stick.updown= -disappear.student.stick.rank;
- disappear.student.stick.range= -disappear.student.stick.value;
- disappear.student.stick.value=0;
- disappear.student.stick.rank=rank_tmd_stick_Max+1;
- disappear.ies5Stu.stick.updown= -disappear.ies5Stu.stick.rank;
- disappear.ies5Stu.stick.range= -disappear.ies5Stu.stick.value;
- disappear.ies5Stu.stick.value=0;
- disappear.ies5Stu.stick.rank=rank_ies5Stu_stick_Max+1;
- disappear.otherStu.stick.updown= -disappear.otherStu.stick.rank;
- disappear.otherStu.stick.range= -disappear.otherStu.stick.value;
- disappear.otherStu.stick.value=0;
- disappear.otherStu.stick.rank=rank_otherStu_stick_Max+1;
- disappear.student.count.updown= -disappear.student.count.rank;
- disappear.student.count.range= -disappear.student.count.value;
- disappear.student.count.value=0;
- disappear.student.count.rank=rank_tmd_count_Max+1;
- disappear.ies5Stu.count.updown= -disappear.ies5Stu.count.rank;
- disappear.ies5Stu.count.range= -disappear.ies5Stu.count.value;
- disappear.ies5Stu.count.value=0;
- disappear.ies5Stu.count.rank=rank_ies5Stu_count_Max+1;
- disappear.otherStu.count.updown= -disappear.otherStu.count.rank;
- disappear.otherStu.count.range= -disappear.otherStu.count.value;
- disappear.otherStu.count.value=0;
- disappear.otherStu.count.rank=rank_otherStu_count_Max+1;
- disappear.student.duration.updown= -disappear.student.duration.rank;
- disappear.student.duration.range= -disappear.student.duration.value;
- disappear.student.duration.value=0;
- disappear.student.duration.rank=rank_tmd_duration_Max+1;
- disappear.ies5Stu.duration.updown= -disappear.ies5Stu.duration.rank;
- disappear.ies5Stu.duration.range= -disappear.ies5Stu.duration.value;
- disappear.ies5Stu.duration.value=0;
- disappear.ies5Stu.duration.rank=rank_ies5Stu_duration_Max+1;
- disappear.otherStu.duration.updown= -disappear.otherStu.duration.rank;
- disappear.otherStu.duration.range= -disappear.otherStu.duration.value;
- disappear.otherStu.duration.value=0;
- disappear.otherStu.duration.rank=rank_otherStu_duration_Max+1;
- currentStickiness.Add(disappear);
- }
- }
- currentStickiness= currentStickiness.OrderByDescending(x => x.student.stick.value).ToList();
- return currentStickiness;
- }
- private static List<TchStick> OrderByTchStick(List<TchStick> currentStickiness, List<TchStick>? bygoneStickiness)
- {
- // 假设visit已经填充了数据
- #region
- var rank_tmd_count = currentStickiness.Select(x => x.teacher.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hita_count = currentStickiness.Select(x => x.hita.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hiteach_count = currentStickiness.Select(x => x.hiteach.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Tch_count = currentStickiness.Select(x => x.ies5Tch.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherTch_count = currentStickiness.Select(x => x.otherTch.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_lesson_count = currentStickiness.Select(x => x.lesson.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- #region
- var rank_tmd_duration = currentStickiness.Select(x => x.teacher.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hita_duration = currentStickiness.Select(x => x.hita.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hiteach_duration = currentStickiness.Select(x => x.hiteach.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Tch_duration = currentStickiness.Select(x => x.ies5Tch.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherTch_duration = currentStickiness.Select(x => x.otherTch.duration.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- #region
- var rank_tmd_stick = currentStickiness.Select(x => x.teacher.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hita_stick = currentStickiness.Select(x => x.hita.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hiteach_stick = currentStickiness.Select(x => x.hiteach.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Tch_stick = currentStickiness.Select(x => x.ies5Tch.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherTch_stick = currentStickiness.Select(x => x.otherTch.stick.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- currentStickiness.ForEach(x =>
- {
- #region
- int index_tmd_count = rank_tmd_count.FindIndex(i => i==x.teacher.count.value);
- if (index_tmd_count!=-1)
- {
- x.teacher.count.rank = index_tmd_count + 1;
- }
- int index_hita_count = rank_hita_count.FindIndex(i => i==x.hita.count.value);
- if (index_hita_count!=-1)
- {
- x.hita.count.rank = index_hita_count + 1;
- }
- int index_hiteach_count = rank_hiteach_count.FindIndex(i => i==x.hiteach.count.value);
- if (index_hiteach_count!=-1)
- {
- x.hiteach.count.rank = index_hiteach_count + 1;
- }
- int index_ies5Tch_count = rank_ies5Tch_count.FindIndex(i => i==x.ies5Tch.count.value);
- if (index_ies5Tch_count!=-1)
- {
- x.ies5Tch.count.rank = index_ies5Tch_count + 1;
- }
- int index_otherTch_count = rank_otherTch_count.FindIndex(i => i==x.otherTch.count.value);
- if (index_otherTch_count!=-1)
- {
- x.otherTch.count.rank = index_otherTch_count + 1;
- }
- int index_lesson_count = rank_lesson_count.FindIndex(i => i==x.lesson.value);
- if (index_lesson_count!=-1)
- {
- x.lesson.rank = index_lesson_count + 1;
- }
- #endregion
- #region
- int index_tmd_duration = rank_tmd_duration.FindIndex(i => i==x.teacher.duration.value);
- if (index_tmd_duration!=-1)
- {
- x.teacher.duration.rank = index_tmd_duration + 1;
- }
- int index_hita_duration = rank_hita_duration.FindIndex(i => i==x.hita.duration.value);
- if (index_hita_duration!=-1)
- {
- x.hita.duration.rank = index_hita_duration + 1;
- }
- int index_hiteach_duration = rank_hiteach_duration.FindIndex(i => i==x.hiteach.duration.value);
- if (index_hiteach_duration!=-1)
- {
- x.hiteach.duration.rank = index_hiteach_duration + 1;
- }
- int index_ies5Tch_duration = rank_ies5Tch_duration.FindIndex(i => i==x.ies5Tch.duration.value);
- if (index_ies5Tch_duration!=-1)
- {
- x.ies5Tch.duration.rank = index_ies5Tch_duration + 1;
- }
- int index_otherTch_duration = rank_otherTch_duration.FindIndex(i => i==x.otherTch.duration.value);
- if (index_otherTch_duration!=-1)
- {
- x.otherTch.duration.rank = index_otherTch_duration + 1;
- }
- #endregion
- #region
- int index_tmd_stick = rank_tmd_stick.FindIndex(i => i==x.teacher.stick.value);
- if (index_tmd_stick!=-1)
- {
- x.teacher.stick.rank = index_tmd_stick + 1;
- }
- int index_hita_stick = rank_hita_stick.FindIndex(i => i==x.hita.stick.value);
- if (index_hita_stick!=-1)
- {
- x.hita.stick.rank = index_hita_stick + 1;
- }
- int index_hiteach_stick = rank_hiteach_stick.FindIndex(i => i==x.hiteach.stick.value);
- if (index_hiteach_stick!=-1)
- {
- x.hiteach.stick.rank = index_hiteach_stick + 1;
- }
- int index_ies5Tch_stick = rank_ies5Tch_stick.FindIndex(i => i==x.ies5Tch.stick.value);
- if (index_ies5Tch_stick!=-1)
- {
- x.ies5Tch.stick.rank = index_ies5Tch_stick + 1;
- }
- int index_otherTch_stick = rank_otherTch_stick.FindIndex(i => i==x.otherTch.stick.value);
- if (index_otherTch_stick!=-1)
- {
- x.otherTch.stick.rank = index_otherTch_stick + 1;
- }
- #endregion
- var bygone = bygoneStickiness?.Find(y => y.id.Equals(x.id));
- if (bygone!=null)
- {
- #region
- x.lesson.range=x.lesson.value-bygone.lesson.value;
- x.lesson.updown=x.lesson.rank-bygone.lesson.rank;
- #endregion
- #region tmd
- //人数上升下降
- x.teacher.userUpdown= x.teacher.userCount-bygone.teacher.userCount;
- //访问数量上升下降
- x.teacher.count.range= x.teacher.count.value-bygone.teacher.count.value;
- //访问数量排名上升下降
- x.teacher.count.updown= -(x.teacher.count.rank - bygone.teacher.count.rank);
- //停留时长上升下降
- x.teacher.duration.range=x.teacher.duration.value-bygone.teacher.duration.value;
- //停留时长排名上升下降
- x.teacher.duration.updown=-(x.teacher.duration.rank - bygone.teacher.duration.rank);
- //访问指数上升下降
- x.teacher.stick.range=x.teacher.stick.value-bygone.teacher.stick.value;
- //访问指数排名上升下降
- x.teacher.stick.updown=-(x.teacher.stick.rank - bygone.teacher.stick.rank);
- #endregion
- #region hita
- //人数上升下降
- x.hita.userUpdown= x.hita.userCount-bygone.hita.userCount;
- //访问数量上升下降
- x.hita.count.range= x.hita.count.value-bygone.hita.count.value;
- //访问数量排名上升下降
- x.hita.count.updown= -(x.hita.count.rank - bygone.hita.count.rank);
- //停留时长上升下降
- x.hita.duration.range=x.hita.duration.value-bygone.hita.duration.value;
- //停留时长排名上升下降
- x.hita.duration.updown=-(x.hita.duration.rank - bygone.hita.duration.rank);
- //访问指数上升下降
- x.hita.stick.range=x.hita.stick.value-bygone.hita.stick.value;
- //访问指数排名上升下降
- x.hita.stick.updown=-(x.hita.stick.rank - bygone.hita.stick.rank);
- #endregion
- #region hiteach
- //人数上升下降
- x.hiteach.userUpdown= x.hiteach.userCount-bygone.hiteach.userCount;
- //访问数量上升下降
- x.hiteach.count.range= x.hiteach.count.value-bygone.hiteach.count.value;
- //访问数量排名上升下降
- x.hiteach.count.updown= -(x.hiteach.count.rank - bygone.hiteach.count.rank);
- //停留时长上升下降
- x.hiteach.duration.range=x.hiteach.duration.value-bygone.hiteach.duration.value;
- //停留时长排名上升下降
- x.hiteach.duration.updown=-(x.hiteach.duration.rank - bygone.hiteach.duration.rank);
- //访问指数上升下降
- x.hiteach.stick.range=x.hiteach.stick.value-bygone.hiteach.stick.value;
- //访问指数排名上升下降
- x.hiteach.stick.updown=-(x.hiteach.stick.rank - bygone.hiteach.stick.rank);
- #endregion
- #region otherTch
- //人数上升下降
- x.otherTch.userUpdown= x.otherTch.userCount-bygone.otherTch.userCount;
- //访问数量上升下降
- x.otherTch.count.range= x.otherTch.count.value-bygone.otherTch.count.value;
- //访问数量排名上升下降
- x.otherTch.count.updown= -(x.otherTch.count.rank - bygone.otherTch.count.rank);
- //停留时长上升下降
- x.otherTch.duration.range=x.otherTch.duration.value-bygone.otherTch.duration.value;
- //停留时长排名上升下降
- x.otherTch.duration.updown=-(x.otherTch.duration.rank - bygone.otherTch.duration.rank);
- //访问指数上升下降
- x.otherTch.stick.range=x.otherTch.stick.value-bygone.otherTch.stick.value;
- //访问指数排名上升下降
- x.otherTch.stick.updown=-(x.otherTch.stick.rank - bygone.otherTch.stick.rank);
- #endregion
- #region ies5Tch
- //人数上升下降
- x.ies5Tch.userUpdown= x.ies5Tch.userCount-bygone.ies5Tch.userCount;
- //访问数量上升下降
- x.ies5Tch.count.range= x.ies5Tch.count.value-bygone.ies5Tch.count.value;
- //访问数量排名上升下降
- x.ies5Tch.count.updown= -(x.ies5Tch.count.rank - bygone.ies5Tch.count.rank);
- //停留时长上升下降
- x.ies5Tch.duration.range=x.ies5Tch.duration.value-bygone.ies5Tch.duration.value;
- //停留时长排名上升下降
- x.ies5Tch.duration.updown=-(x.ies5Tch.duration.rank - bygone.ies5Tch.duration.rank);
- //访问指数上升下降
- x.ies5Tch.stick.range=x.ies5Tch.stick.value-bygone.ies5Tch.stick.value;
- //访问指数排名上升下降
- x.ies5Tch.stick.updown=-(x.ies5Tch.stick.rank - bygone.ies5Tch.stick.rank);
- #endregion
- }
- else
- {
- #region
- x.lesson.range=x.lesson.value;
- x.lesson.updown=x.lesson.rank;
- #endregion
- #region tmd
- //人数上升下降
- x.teacher.userUpdown= x.teacher.userCount;
- //访问数量上升下降
- x.teacher.count.range= x.teacher.count.value;
- //访问数量排名上升下降
- x.teacher.count.updown= x.teacher.count.rank;
- //停留时长上升下降
- x.teacher.duration.range=x.teacher.duration.value;
- //停留时长排名上升下降
- x.teacher.duration.updown=x.teacher.duration.rank;
- //访问指数上升下降
- x.teacher.stick.range=x.teacher.stick.value;
- //访问指数排名上升下降
- x.teacher.stick.updown=x.teacher.stick.rank;
- #endregion
- #region hita
- //人数上升下降
- x.hita.userUpdown= x.hita.userCount;
- //访问数量上升下降
- x.hita.count.range= x.hita.count.value;
- //访问数量排名上升下降
- x.hita.count.updown= x.hita.count.rank;
- //停留时长上升下降
- x.hita.duration.range=x.hita.duration.value;
- //停留时长排名上升下降
- x.hita.duration.updown=x.hita.duration.rank;
- //访问指数上升下降
- x.hita.stick.range=x.hita.stick.value;
- //访问指数排名上升下降
- x.hita.stick.updown=x.hita.stick.rank;
- #endregion
- #region hiteach
- //人数上升下降
- x.hiteach.userUpdown= x.hiteach.userCount;
- //访问数量上升下降
- x.hiteach.count.range= x.hiteach.count.value;
- //访问数量排名上升下降
- x.hiteach.count.updown= x.hiteach.count.rank;
- //停留时长上升下降
- x.hiteach.duration.range=x.hiteach.duration.value;
- //停留时长排名上升下降
- x.hiteach.duration.updown=x.hiteach.duration.rank;
- //访问指数上升下降
- x.hiteach.stick.range=x.hiteach.stick.value;
- //访问指数排名上升下降
- x.hiteach.stick.updown=x.hiteach.stick.rank;
- #endregion
- #region otherTch
- //人数上升下降
- x.otherTch.userUpdown= x.otherTch.userCount;
- //访问数量上升下降
- x.otherTch.count.range= x.otherTch.count.value;
- //访问数量排名上升下降
- x.otherTch.count.updown= x.otherTch.count.rank;
- //停留时长上升下降
- x.otherTch.duration.range=x.otherTch.duration.value;
- //停留时长排名上升下降
- x.otherTch.duration.updown=x.otherTch.duration.rank;
- //访问指数上升下降
- x.otherTch.stick.range=x.otherTch.stick.value;
- //访问指数排名上升下降
- x.otherTch.stick.updown=x.otherTch.stick.rank;
- #endregion
- #region ies5Tch
- //人数上升下降
- x.ies5Tch.userUpdown= x.ies5Tch.userCount;
- //访问数量上升下降
- x.ies5Tch.count.range= x.ies5Tch.count.value;
- //访问数量排名上升下降
- x.ies5Tch.count.updown= x.ies5Tch.count.rank;
- //停留时长上升下降
- x.ies5Tch.duration.range=x.ies5Tch.duration.value;
- //停留时长排名上升下降
- x.ies5Tch.duration.updown=x.ies5Tch.duration.rank;
- //访问指数上升下降
- x.ies5Tch.stick.range=x.ies5Tch.stick.value;
- //访问指数排名上升下降
- x.ies5Tch.stick.updown=x.ies5Tch.stick.rank;
- #endregion
- }
- });
- //当前时间没有的
- var disappears = bygoneStickiness?.Where(x => x.teacher.stick.value!=0).ExceptBy(currentStickiness.Select(x => x.id), y => y.id);
- if (disappears!=null && disappears.Count()>0)
- {
- double rank_tmd_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.teacher.stick.rank).Max() : 0;
- double rank_tmd_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.teacher.count.rank).Max() : 0;
- double rank_tmd_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.teacher.duration.rank).Max() : 0;
- double rank_hiteach_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hiteach.stick.rank).Max() : 0;
- double rank_hiteach_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hiteach.count.rank).Max() : 0;
- double rank_hiteach_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hiteach.duration.rank).Max() : 0;
- double rank_hita_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hita.stick.rank).Max() : 0;
- double rank_hita_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hita.count.rank).Max() : 0;
- double rank_hita_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hita.duration.rank).Max() : 0;
- double rank_ies5Tch_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Tch.stick.rank).Max() : 0;
- double rank_ies5Tch_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Tch.count.rank).Max() : 0;
- double rank_ies5Tch_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Tch.duration.rank).Max() : 0;
- double rank_otherTch_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherTch.stick.rank).Max() : 0;
- double rank_otherTch_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherTch.count.rank).Max() : 0;
- double rank_otherTch_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherTch.duration.rank).Max() : 0;
- double rank_lesson_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.lesson.rank).Max() : 0;
- foreach (var disappear in disappears)
- {
- disappear.lesson.updown=-disappear.lesson.rank;
- disappear.lesson.range=-disappear.lesson.value;
- disappear.lesson.value=0;
- disappear.lesson.rank=rank_lesson_Max+1;
- //下降
- // y 5 t0
- disappear.teacher.stick.updown= -disappear.teacher.stick.rank;
- disappear.teacher.stick.range= -disappear.teacher.stick.value;
- disappear.teacher.stick.value=0;
- disappear.teacher.stick.rank=rank_tmd_stick_Max+1;
- disappear.hiteach.stick.updown= -disappear.hiteach.stick.rank;
- disappear.hiteach.stick.range= -disappear.hiteach.stick.value;
- disappear.hiteach.stick.value=0;
- disappear.hiteach.stick.rank=rank_hiteach_stick_Max+1;
- disappear.hita.stick.updown= -disappear.hita.stick.rank;
- disappear.hita.stick.range= -disappear.hita.stick.value;
- disappear.hita.stick.value=0;
- disappear.hita.stick.rank=rank_hita_stick_Max+1;
- disappear.ies5Tch.stick.updown= -disappear.ies5Tch.stick.rank;
- disappear.ies5Tch.stick.range= -disappear.ies5Tch.stick.value;
- disappear.ies5Tch.stick.value=0;
- disappear.ies5Tch.stick.rank=rank_ies5Tch_stick_Max+1;
- disappear.otherTch.stick.updown= -disappear.otherTch.stick.rank;
- disappear.otherTch.stick.range= -disappear.otherTch.stick.value;
- disappear.otherTch.stick.value=0;
- disappear.otherTch.stick.rank=rank_otherTch_stick_Max+1;
- disappear.teacher.count.updown= -disappear.teacher.count.rank;
- disappear.teacher.count.range= -disappear.teacher.count.value;
- disappear.teacher.count.value=0;
- disappear.teacher.count.rank=rank_tmd_count_Max+1;
- disappear.hiteach.count.updown= -disappear.hiteach.count.rank;
- disappear.hiteach.count.range= -disappear.hiteach.count.value;
- disappear.hiteach.count.value=0;
- disappear.hiteach.count.rank=rank_hiteach_count_Max+1;
- disappear.hita.count.updown= -disappear.hita.count.rank;
- disappear.hita.count.range= -disappear.hita.count.value;
- disappear.hita.count.value=0;
- disappear.hita.count.rank=rank_hita_count_Max+1;
- disappear.ies5Tch.count.updown= -disappear.ies5Tch.count.rank;
- disappear.ies5Tch.count.range= -disappear.ies5Tch.count.value;
- disappear.ies5Tch.count.value=0;
- disappear.ies5Tch.count.rank=rank_ies5Tch_count_Max+1;
- disappear.otherTch.count.updown= -disappear.otherTch.count.rank;
- disappear.otherTch.count.range= -disappear.otherTch.count.value;
- disappear.otherTch.count.value=0;
- disappear.otherTch.count.rank=rank_otherTch_count_Max+1;
- disappear.teacher.duration.updown= -disappear.teacher.duration.rank;
- disappear.teacher.duration.range= -disappear.teacher.duration.value;
- disappear.teacher.duration.value=0;
- disappear.teacher.duration.rank=rank_tmd_duration_Max+1;
- disappear.hiteach.duration.updown= -disappear.hiteach.duration.rank;
- disappear.hiteach.duration.range= -disappear.hiteach.duration.value;
- disappear.hiteach.duration.value=0;
- disappear.hiteach.duration.rank=rank_hiteach_duration_Max+1;
- disappear.hita.duration.updown= -disappear.hita.duration.rank;
- disappear.hita.duration.range= -disappear.hita.duration.value;
- disappear.hita.duration.value=0;
- disappear.hita.duration.rank=rank_hita_duration_Max+1;
- disappear.ies5Tch.duration.updown= -disappear.ies5Tch.duration.rank;
- disappear.ies5Tch.duration.range= -disappear.ies5Tch.duration.value;
- disappear.ies5Tch.duration.value=0;
- disappear.ies5Tch.duration.rank=rank_ies5Tch_duration_Max+1;
- disappear.otherTch.duration.updown= -disappear.otherTch.duration.rank;
- disappear.otherTch.duration.range= -disappear.otherTch.duration.value;
- disappear.otherTch.duration.value=0;
- disappear.otherTch.duration.rank=rank_otherTch_duration_Max+1;
- currentStickiness.Add(disappear);
- }
- }
- currentStickiness= currentStickiness.OrderByDescending(x => x.teacher.stick.value).ToList();
- return currentStickiness;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="currentStickiness">现在的</param>
- /// <param name="bygoneStickiness">过去的</param>
- /// <returns></returns>
- private static List<SchoolStick> OrderBySchoolStick(List<SchoolStick> currentStickiness, List<SchoolStick>? bygoneStickiness)
- {
- // 假设visit已经填充了数据
- #region
- var rank_teacher_count = currentStickiness.Select(x => x.teacher.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_student_count = currentStickiness.Select(x => x.student.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hita_count = currentStickiness.Select(x => x.hita.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hiteach_count = currentStickiness.Select(x => x.hiteach.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Tch_count = currentStickiness.Select(x => x.ies5Tch.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherTch_count = currentStickiness.Select(x => x.otherTch.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Stu_count = currentStickiness.Select(x => x.ies5Stu.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherStu_count = currentStickiness.Select(x => x.otherStu.count.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_lesson_count = currentStickiness.Select(x => x.lesson.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- #region
- var rank_teacher_duration = currentStickiness.Select(x => x.teacher.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_student_duration = currentStickiness.Select(x => x.student.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hita_duration = currentStickiness.Select(x => x.hita.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hiteach_duration = currentStickiness.Select(x => x.hiteach.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Tch_duration = currentStickiness.Select(x => x.ies5Tch.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherTch_duration = currentStickiness.Select(x => x.otherTch.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Stu_duration = currentStickiness.Select(x => x.ies5Stu.duration.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherStu_duration = currentStickiness.Select(x => x.otherStu.duration.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- #region
- var rank_teacher_stick = currentStickiness.Select(x => x.teacher.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_student_stick = currentStickiness.Select(x => x.student.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hita_stick = currentStickiness.Select(x => x.hita.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_hiteach_stick = currentStickiness.Select(x => x.hiteach.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Tch_stick = currentStickiness.Select(x => x.ies5Tch.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherTch_stick = currentStickiness.Select(x => x.otherTch.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_ies5Stu_stick = currentStickiness.Select(x => x.ies5Stu.stick.value).Distinct().OrderByDescending(v => v).ToList();
- var rank_otherStu_stick = currentStickiness.Select(x => x.otherStu.stick.value).Distinct().OrderByDescending(v => v).ToList();
- #endregion
- currentStickiness.ForEach(x =>
- {
- #region
- if (x.teacher.count.value>0)
- {
- int index_teacher_count = rank_teacher_count.FindIndex(i => i==x.teacher.count.value);
- if (index_teacher_count!=-1)
- {
- x.teacher.count.rank = index_teacher_count + 1;
- }
- }
- if (x.student.count.value>0)
- {
- int index_student_count = rank_student_count.FindIndex(i => i==x.student.count.value);
- if (index_student_count!=-1)
- {
- x.student.count.rank = index_student_count + 1;
- }
- }
- if (x.hita.count.value>0)
- {
- int index_hita_count = rank_hita_count.FindIndex(i => i==x.hita.count.value);
- if (index_hita_count!=-1)
- {
- x.hita.count.rank = index_hita_count + 1;
- }
- }
- if (x.hiteach.count.value>0)
- {
- int index_hiteach_count = rank_hiteach_count.FindIndex(i => i==x.hiteach.count.value);
- if (index_hiteach_count!=-1)
- {
- x.hiteach.count.rank = index_hiteach_count + 1;
- }
- }
- if (x.ies5Tch.count.value>0)
- {
- int index_ies5Tch_count = rank_ies5Tch_count.FindIndex(i => i==x.ies5Tch.count.value);
- if (index_ies5Tch_count!=-1)
- {
- x.ies5Tch.count.rank = index_ies5Tch_count + 1;
- }
- }
- if (x.otherTch.count.value>0)
- {
- int index_otherTch_count = rank_otherTch_count.FindIndex(i => i==x.otherTch.count.value);
- if (index_otherTch_count!=-1)
- {
- x.otherTch.count.rank = index_otherTch_count + 1;
- }
- }
- if (x.ies5Stu.count.value>0)
- {
- int index_ies5Stu_count = rank_ies5Stu_count.FindIndex(i => i==x.ies5Stu.count.value);
- if (index_ies5Stu_count!=-1)
- {
- x.ies5Stu.count.rank = index_ies5Stu_count + 1;
- }
- }
- if (x.otherStu.count.value>0)
- {
- int index_otherStu_count = rank_otherStu_count.FindIndex(i => i==x.otherStu.count.value);
- if (index_otherStu_count!=-1)
- {
- x.otherStu.count.rank = index_otherStu_count + 1;
- }
- }
- if (x.lesson.value>0)
- {
- int index_lesson_count = rank_lesson_count.FindIndex(i => i==x.lesson.value);
- if (index_lesson_count!=-1)
- {
- x.lesson.rank = index_lesson_count + 1;
- }
- }
- #endregion
- #region
- if (x.teacher.duration.value>0)
- {
- int index_teacher_duration = rank_teacher_duration.FindIndex(i => i==x.teacher.duration.value);
- if (index_teacher_duration!=-1)
- {
- x.teacher.duration.rank = index_teacher_duration + 1;
- }
- }
- if (x.student.duration.value>0)
- {
- int index_student_duration = rank_student_duration.FindIndex(i => i==x.student.duration.value);
- if (index_student_duration!=-1)
- {
- x.student.duration.rank = index_student_duration + 1;
- }
- }
- if (x.hita.duration.value>0)
- {
- int index_hita_duration = rank_hita_duration.FindIndex(i => i==x.hita.duration.value);
- if (index_hita_duration!=-1)
- {
- x.hita.duration.rank = index_hita_duration + 1;
- }
- }
- if (x.hiteach.duration.value>0)
- {
- int index_hiteach_duration = rank_hiteach_duration.FindIndex(i => i==x.hiteach.duration.value);
- if (index_hiteach_duration!=-1)
- {
- x.hiteach.duration.rank = index_hiteach_duration + 1;
- }
- }
- if (x.ies5Tch.duration.value>0)
- {
- int index_ies5Tch_duration = rank_ies5Tch_duration.FindIndex(i => i==x.ies5Tch.duration.value);
- if (index_ies5Tch_duration!=-1)
- {
- x.ies5Tch.duration.rank = index_ies5Tch_duration + 1;
- }
- }
- if (x.otherTch.duration.value>0)
- {
- int index_otherTch_duration = rank_otherTch_duration.FindIndex(i => i==x.otherTch.duration.value);
- if (index_otherTch_duration!=-1)
- {
- x.otherTch.duration.rank = index_otherTch_duration + 1;
- }
- }
- if (x.ies5Stu.duration.value>0)
- {
- int index_ies5Stu_duration = rank_ies5Stu_duration.FindIndex(i => i==x.ies5Stu.duration.value);
- if (index_ies5Stu_duration!=-1)
- {
- x.ies5Stu.duration.rank = index_ies5Stu_duration + 1;
- }
- }
- if (x.otherStu.duration.value>0)
- {
- int index_otherStu_duration = rank_otherStu_duration.FindIndex(i => i==x.otherStu.duration.value);
- if (index_otherStu_duration!=-1)
- {
- x.otherStu.duration.rank = index_otherStu_duration + 1;
- }
- }
- #endregion
- #region
- if (x.teacher.stick.value>0)
- {
- int index_teacher_stick = rank_teacher_stick.FindIndex(i => i==x.teacher.stick.value);
- if (index_teacher_stick!=-1)
- {
- x.teacher.stick.rank = index_teacher_stick + 1;
- }
- }
- if (x.student.stick.value>0)
- {
- int index_student_stick = rank_student_stick.FindIndex(i => i==x.student.stick.value);
- if (index_student_stick!=-1)
- {
- x.student.stick.rank = index_student_stick + 1;
- }
- }
- if (x.hita.stick.value>0)
- {
- int index_hita_stick = rank_hita_stick.FindIndex(i => i==x.hita.stick.value);
- if (index_hita_stick!=-1)
- {
- x.hita.stick.rank = index_hita_stick + 1;
- }
- }
- if (x.hiteach.stick.value>0)
- {
- int index_hiteach_stick = rank_hiteach_stick.FindIndex(i => i==x.hiteach.stick.value);
- if (index_hiteach_stick!=-1)
- {
- x.hiteach.stick.rank = index_hiteach_stick + 1;
- }
- }
- if (x.ies5Tch.stick.value>0)
- {
- int index_ies5Tch_stick = rank_ies5Tch_stick.FindIndex(i => i==x.ies5Tch.stick.value);
- if (index_ies5Tch_stick!=-1)
- {
- x.ies5Tch.stick.rank = index_ies5Tch_stick + 1;
- }
- }
- if (x.otherTch.stick.value>0)
- {
- int index_otherTch_stick = rank_otherTch_stick.FindIndex(i => i==x.otherTch.stick.value);
- if (index_otherTch_stick!=-1)
- {
- x.otherTch.stick.rank = index_otherTch_stick + 1;
- }
- }
- if (x.ies5Stu.stick.value>0)
- {
- int index_ies5Stu_stick = rank_ies5Stu_stick.FindIndex(i => i==x.ies5Stu.stick.value);
- if (index_ies5Stu_stick!=-1)
- {
- x.ies5Stu.stick.rank = index_ies5Stu_stick + 1;
- }
- }
- if (x.otherStu.stick.value>0)
- {
- int index_otherStu_stick = rank_otherStu_stick.FindIndex(i => i==x.otherStu.stick.value);
- if (index_otherStu_stick!=-1)
- {
- x.otherStu.stick.rank = index_otherStu_stick + 1;
- }
- }
- #endregion
- var bygone = bygoneStickiness?.Find(y => y.id.Equals(x.id));
- if (bygone!=null)
- {
- #region
- x.lesson.range=x.lesson.value-bygone.lesson.value;
- x.lesson.updown=x.lesson.rank-bygone.lesson.rank;
- #endregion
- #region student
- //人数上升下降
- x.student.userUpdown= x.student.userCount-bygone.student.userCount;
- //访问数量上升下降
- x.student.count.range= x.student.count.value-bygone.student.count.value;
- //访问数量排名上升下降
- x.student.count.updown= -(x.student.count.rank - bygone.student.count.rank);
- //停留时长上升下降
- x.student.duration.range=x.student.duration.value-bygone.student.duration.value;
- //停留时长排名上升下降
- x.student.duration.updown=-(x.student.duration.rank - bygone.student.duration.rank);
- //访问指数上升下降
- x.student.stick.range=x.student.stick.value-bygone.student.stick.value;
- //访问指数排名上升下降
- x.student.stick.updown=-(x.student.stick.rank - bygone.student.stick.rank);
- #endregion
- #region teacher
- //人数上升下降
- x.teacher.userUpdown= x.teacher.userCount-bygone.teacher.userCount;
- //访问数量上升下降
- x.teacher.count.range= x.teacher.count.value-bygone.teacher.count.value;
- //访问数量排名上升下降
- x.teacher.count.updown= -(x.teacher.count.rank - bygone.teacher.count.rank);
- //停留时长上升下降
- x.teacher.duration.range=x.teacher.duration.value-bygone.teacher.duration.value;
- //停留时长排名上升下降
- x.teacher.duration.updown=-(x.teacher.duration.rank - bygone.teacher.duration.rank);
- //访问指数上升下降
- x.teacher.stick.range=x.teacher.stick.value-bygone.teacher.stick.value;
- //访问指数排名上升下降
- x.teacher.stick.updown=-(x.teacher.stick.rank - bygone.teacher.stick.rank);
- #endregion
- #region hita
- //人数上升下降
- x.hita.userUpdown= x.hita.userCount-bygone.hita.userCount;
- //访问数量上升下降
- x.hita.count.range= x.hita.count.value-bygone.hita.count.value;
- //访问数量排名上升下降
- x.hita.count.updown= -(x.hita.count.rank - bygone.hita.count.rank);
- //停留时长上升下降
- x.hita.duration.range=x.hita.duration.value-bygone.hita.duration.value;
- //停留时长排名上升下降
- x.hita.duration.updown=-(x.hita.duration.rank - bygone.hita.duration.rank);
- //访问指数上升下降
- x.hita.stick.range=x.hita.stick.value-bygone.hita.stick.value;
- //访问指数排名上升下降
- x.hita.stick.updown=-(x.hita.stick.rank - bygone.hita.stick.rank);
- #endregion
- #region hiteach
- //人数上升下降
- x.hiteach.userUpdown= x.hiteach.userCount-bygone.hiteach.userCount;
- //访问数量上升下降
- x.hiteach.count.range= x.hiteach.count.value-bygone.hiteach.count.value;
- //访问数量排名上升下降
- x.hiteach.count.updown= -(x.hiteach.count.rank - bygone.hiteach.count.rank);
- //停留时长上升下降
- x.hiteach.duration.range=x.hiteach.duration.value-bygone.hiteach.duration.value;
- //停留时长排名上升下降
- x.hiteach.duration.updown=-(x.hiteach.duration.rank - bygone.hiteach.duration.rank);
- //访问指数上升下降
- x.hiteach.stick.range=x.hiteach.stick.value-bygone.hiteach.stick.value;
- //访问指数排名上升下降
- x.hiteach.stick.updown=-(x.hiteach.stick.rank - bygone.hiteach.stick.rank);
- #endregion
- #region otherTch
- //人数上升下降
- x.otherTch.userUpdown= x.otherTch.userCount-bygone.otherTch.userCount;
- //访问数量上升下降
- x.otherTch.count.range= x.otherTch.count.value-bygone.otherTch.count.value;
- //访问数量排名上升下降
- x.otherTch.count.updown= -(x.otherTch.count.rank - bygone.otherTch.count.rank);
- //停留时长上升下降
- x.otherTch.duration.range=x.otherTch.duration.value-bygone.otherTch.duration.value;
- //停留时长排名上升下降
- x.otherTch.duration.updown=-(x.otherTch.duration.rank - bygone.otherTch.duration.rank);
- //访问指数上升下降
- x.otherTch.stick.range=x.otherTch.stick.value-bygone.otherTch.stick.value;
- //访问指数排名上升下降
- x.otherTch.stick.updown=-(x.otherTch.stick.rank - bygone.otherTch.stick.rank);
- #endregion
- #region otherStu
- //人数上升下降
- x.otherStu.userUpdown= x.otherStu.userCount-bygone.otherStu.userCount;
- //访问数量上升下降
- x.otherStu.count.range= x.otherStu.count.value-bygone.otherStu.count.value;
- //访问数量排名上升下降
- x.otherStu.count.updown= -(x.otherStu.count.rank - bygone.otherStu.count.rank);
- //停留时长上升下降
- x.otherStu.duration.range=x.otherStu.duration.value-bygone.otherStu.duration.value;
- //停留时长排名上升下降
- x.otherStu.duration.updown=-(x.otherStu.duration.rank - bygone.otherStu.duration.rank);
- //访问指数上升下降
- x.otherStu.stick.range=x.otherStu.stick.value-bygone.otherStu.stick.value;
- //访问指数排名上升下降
- x.otherStu.stick.updown=-(x.otherStu.stick.rank - bygone.otherStu.stick.rank);
- #endregion
- #region ies5Stu
- //人数上升下降
- x.ies5Stu.userUpdown= x.ies5Stu.userCount-bygone.ies5Stu.userCount;
- //访问数量上升下降
- x.ies5Stu.count.range= x.ies5Stu.count.value-bygone.ies5Stu.count.value;
- //访问数量排名上升下降
- x.ies5Stu.count.updown= -(x.ies5Stu.count.rank - bygone.ies5Stu.count.rank);
- //停留时长上升下降
- x.ies5Stu.duration.range=x.ies5Stu.duration.value-bygone.ies5Stu.duration.value;
- //停留时长排名上升下降
- x.ies5Stu.duration.updown=-(x.ies5Stu.duration.rank - bygone.ies5Stu.duration.rank);
- //访问指数上升下降
- x.ies5Stu.stick.range=x.ies5Stu.stick.value-bygone.ies5Stu.stick.value;
- //访问指数排名上升下降
- x.ies5Stu.stick.updown=-(x.ies5Stu.stick.rank - bygone.ies5Stu.stick.rank);
- #endregion
- #region ies5Tch
- //人数上升下降
- x.ies5Tch.userUpdown= x.ies5Tch.userCount-bygone.ies5Tch.userCount;
- //访问数量上升下降
- x.ies5Tch.count.range= x.ies5Tch.count.value-bygone.ies5Tch.count.value;
- //访问数量排名上升下降
- x.ies5Tch.count.updown= -(x.ies5Tch.count.rank - bygone.ies5Tch.count.rank);
- //停留时长上升下降
- x.ies5Tch.duration.range=x.ies5Tch.duration.value-bygone.ies5Tch.duration.value;
- //停留时长排名上升下降
- x.ies5Tch.duration.updown=-(x.ies5Tch.duration.rank - bygone.ies5Tch.duration.rank);
- //访问指数上升下降
- x.ies5Tch.stick.range=x.ies5Tch.stick.value-bygone.ies5Tch.stick.value;
- //访问指数排名上升下降
- x.ies5Tch.stick.updown=-(x.ies5Tch.stick.rank - bygone.ies5Tch.stick.rank);
- #endregion
- }
- else
- {
- #region
- x.lesson.range=x.lesson.value;
- x.lesson.updown=x.lesson.rank;
- #endregion
- #region teacher
- //人数上升下降
- x.teacher.userUpdown= x.teacher.userCount;
- //访问数量上升下降
- x.teacher.count.range= x.teacher.count.value;
- //访问数量排名上升下降
- x.teacher.count.updown= x.teacher.count.rank;
- //停留时长上升下降
- x.teacher.duration.range=x.teacher.duration.value;
- //停留时长排名上升下降
- x.teacher.duration.updown=x.teacher.duration.rank;
- //访问指数上升下降
- x.teacher.stick.range=x.teacher.stick.value;
- //访问指数排名上升下降
- x.teacher.stick.updown=x.teacher.stick.rank;
- #endregion
- #region student
- //人数上升下降
- x.student.userUpdown= x.student.userCount;
- //访问数量上升下降
- x.student.count.range= x.student.count.value;
- //访问数量排名上升下降
- x.student.count.updown= x.student.count.rank;
- //停留时长上升下降
- x.student.duration.range=x.student.duration.value;
- //停留时长排名上升下降
- x.student.duration.updown=x.student.duration.rank;
- //访问指数上升下降
- x.student.stick.range=x.student.stick.value;
- //访问指数排名上升下降
- x.student.stick.updown=x.student.stick.rank;
- #endregion
- #region hita
- //人数上升下降
- x.hita.userUpdown= x.hita.userCount;
- //访问数量上升下降
- x.hita.count.range= x.hita.count.value;
- //访问数量排名上升下降
- x.hita.count.updown= x.hita.count.rank;
- //停留时长上升下降
- x.hita.duration.range=x.hita.duration.value;
- //停留时长排名上升下降
- x.hita.duration.updown=x.hita.duration.rank;
- //访问指数上升下降
- x.hita.stick.range=x.hita.stick.value;
- //访问指数排名上升下降
- x.hita.stick.updown=x.hita.stick.rank;
- #endregion
- #region hiteach
- //人数上升下降
- x.hiteach.userUpdown= x.hiteach.userCount;
- //访问数量上升下降
- x.hiteach.count.range= x.hiteach.count.value;
- //访问数量排名上升下降
- x.hiteach.count.updown= x.hiteach.count.rank;
- //停留时长上升下降
- x.hiteach.duration.range=x.hiteach.duration.value;
- //停留时长排名上升下降
- x.hiteach.duration.updown=x.hiteach.duration.rank;
- //访问指数上升下降
- x.hiteach.stick.range=x.hiteach.stick.value;
- //访问指数排名上升下降
- x.hiteach.stick.updown=x.hiteach.stick.rank;
- #endregion
- #region otherTch
- //人数上升下降
- x.otherTch.userUpdown= x.otherTch.userCount;
- //访问数量上升下降
- x.otherTch.count.range= x.otherTch.count.value;
- //访问数量排名上升下降
- x.otherTch.count.updown= x.otherTch.count.rank;
- //停留时长上升下降
- x.otherTch.duration.range=x.otherTch.duration.value;
- //停留时长排名上升下降
- x.otherTch.duration.updown=x.otherTch.duration.rank;
- //访问指数上升下降
- x.otherTch.stick.range=x.otherTch.stick.value;
- //访问指数排名上升下降
- x.otherTch.stick.updown=x.otherTch.stick.rank;
- #endregion
- #region otherStu
- //人数上升下降
- x.otherStu.userUpdown= x.otherStu.userCount;
- //访问数量上升下降
- x.otherStu.count.range= x.otherStu.count.value;
- //访问数量排名上升下降
- x.otherStu.count.updown= x.otherStu.count.rank;
- //停留时长上升下降
- x.otherStu.duration.range=x.otherStu.duration.value;
- //停留时长排名上升下降
- x.otherStu.duration.updown=x.otherStu.duration.rank;
- //访问指数上升下降
- x.otherStu.stick.range=x.otherStu.stick.value;
- //访问指数排名上升下降
- x.otherStu.stick.updown=x.otherStu.stick.rank;
- #endregion
- #region ies5Stu
- //人数上升下降
- x.ies5Stu.userUpdown= x.ies5Stu.userCount;
- //访问数量上升下降
- x.ies5Stu.count.range= x.ies5Stu.count.value;
- //访问数量排名上升下降
- x.ies5Stu.count.updown= x.ies5Stu.count.rank;
- //停留时长上升下降
- x.ies5Stu.duration.range=x.ies5Stu.duration.value;
- //停留时长排名上升下降
- x.ies5Stu.duration.updown=x.ies5Stu.duration.rank;
- //访问指数上升下降
- x.ies5Stu.stick.range=x.ies5Stu.stick.value;
- //访问指数排名上升下降
- x.ies5Stu.stick.updown=x.ies5Stu.stick.rank;
- #endregion
- #region ies5Tch
- //人数上升下降
- x.ies5Tch.userUpdown= x.ies5Tch.userCount;
- //访问数量上升下降
- x.ies5Tch.count.range= x.ies5Tch.count.value;
- //访问数量排名上升下降
- x.ies5Tch.count.updown= x.ies5Tch.count.rank;
- //停留时长上升下降
- x.ies5Tch.duration.range=x.ies5Tch.duration.value;
- //停留时长排名上升下降
- x.ies5Tch.duration.updown=x.ies5Tch.duration.rank;
- //访问指数上升下降
- x.ies5Tch.stick.range=x.ies5Tch.stick.value;
- //访问指数排名上升下降
- x.ies5Tch.stick.updown=x.ies5Tch.stick.rank;
- #endregion
- }
- });
- //当前时间没有的
- var disappears = bygoneStickiness?.Where(x => x.teacher.stick.value!=0).ExceptBy(currentStickiness.Select(x => x.id), y => y.id);
- if (disappears!=null && disappears.Count()>0)
- {
- double rank_student_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.student.stick.rank).Max() : 0;
- double rank_student_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.student.count.rank).Max() : 0;
- double rank_student_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.student.duration.rank).Max() : 0;
- double rank_teacher_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.teacher.stick.rank).Max() : 0;
- double rank_teacher_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.teacher.count.rank).Max() : 0;
- double rank_teacher_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.teacher.duration.rank).Max() : 0;
- double rank_hiteach_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hiteach.stick.rank).Max() : 0;
- double rank_hiteach_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hiteach.count.rank).Max() : 0;
- double rank_hiteach_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hiteach.duration.rank).Max() : 0;
- double rank_hita_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hita.stick.rank).Max() : 0;
- double rank_hita_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hita.count.rank).Max() : 0;
- double rank_hita_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.hita.duration.rank).Max() : 0;
- double rank_ies5Stu_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Stu.stick.rank).Max() : 0;
- double rank_ies5Stu_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Stu.count.rank).Max() : 0;
- double rank_ies5Stu_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Stu.duration.rank).Max() : 0;
- double rank_ies5Tch_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Tch.stick.rank).Max() : 0;
- double rank_ies5Tch_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Tch.count.rank).Max() : 0;
- double rank_ies5Tch_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.ies5Tch.duration.rank).Max() : 0;
- double rank_otherStu_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherStu.stick.rank).Max() : 0;
- double rank_otherStu_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherStu.count.rank).Max() : 0;
- double rank_otherStu_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherStu.duration.rank).Max() : 0;
- double rank_otherTch_stick_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherTch.stick.rank).Max() : 0;
- double rank_otherTch_count_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherTch.count.rank).Max() : 0;
- double rank_otherTch_duration_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.otherTch.duration.rank).Max() : 0;
- double rank_lesson_Max = currentStickiness.Count()>0 ? currentStickiness.Select(x => x.lesson.rank).Max() : 0;
- foreach (var disappear in disappears)
- {
- disappear.lesson.updown=-disappear.lesson.rank;
- disappear.lesson.range=-disappear.lesson.value;
- disappear.lesson.value=0;
- disappear.lesson.rank=rank_lesson_Max+1;
- //下降
- // y 5 t0
- disappear.teacher.stick.updown= -disappear.teacher.stick.rank;
- disappear.teacher.stick.range= -disappear.teacher.stick.value;
- disappear.teacher.stick.value=0;
- disappear.teacher.stick.rank=rank_teacher_stick_Max+1;
- disappear.student.stick.updown= -disappear.student.stick.rank;
- disappear.student.stick.range= -disappear.student.stick.value;
- disappear.student.stick.value=0;
- disappear.student.stick.rank=rank_student_stick_Max+1;
- disappear.hiteach.stick.updown= -disappear.hiteach.stick.rank;
- disappear.hiteach.stick.range= -disappear.hiteach.stick.value;
- disappear.hiteach.stick.value=0;
- disappear.hiteach.stick.rank=rank_hiteach_stick_Max+1;
- disappear.hita.stick.updown= -disappear.hita.stick.rank;
- disappear.hita.stick.range= -disappear.hita.stick.value;
- disappear.hita.stick.value=0;
- disappear.hita.stick.rank=rank_hita_stick_Max+1;
- disappear.ies5Stu.stick.updown= -disappear.ies5Stu.stick.rank;
- disappear.ies5Stu.stick.range= -disappear.ies5Stu.stick.value;
- disappear.ies5Stu.stick.value=0;
- disappear.ies5Stu.stick.rank=rank_ies5Stu_stick_Max+1;
- disappear.ies5Tch.stick.updown= -disappear.ies5Tch.stick.rank;
- disappear.ies5Tch.stick.range= -disappear.ies5Tch.stick.value;
- disappear.ies5Tch.stick.value=0;
- disappear.ies5Tch.stick.rank=rank_ies5Tch_stick_Max+1;
- disappear.otherStu.stick.updown= -disappear.otherStu.stick.rank;
- disappear.otherStu.stick.range= -disappear.otherStu.stick.value;
- disappear.otherStu.stick.value=0;
- disappear.otherStu.stick.rank=rank_otherStu_stick_Max+1;
- disappear.otherTch.stick.updown= -disappear.otherTch.stick.rank;
- disappear.otherTch.stick.range= -disappear.otherTch.stick.value;
- disappear.otherTch.stick.value=0;
- disappear.otherTch.stick.rank=rank_otherTch_stick_Max+1;
- disappear.teacher.count.updown= -disappear.teacher.count.rank;
- disappear.teacher.count.range= -disappear.teacher.count.value;
- disappear.teacher.count.value=0;
- disappear.teacher.count.rank=rank_teacher_count_Max+1;
- disappear.student.count.updown= -disappear.student.count.rank;
- disappear.student.count.range= -disappear.student.count.value;
- disappear.student.count.value=0;
- disappear.student.count.rank=rank_student_count_Max+1;
- disappear.hiteach.count.updown= -disappear.hiteach.count.rank;
- disappear.hiteach.count.range= -disappear.hiteach.count.value;
- disappear.hiteach.count.value=0;
- disappear.hiteach.count.rank=rank_hiteach_count_Max+1;
- disappear.hita.count.updown= -disappear.hita.count.rank;
- disappear.hita.count.range= -disappear.hita.count.value;
- disappear.hita.count.value=0;
- disappear.hita.count.rank=rank_hita_count_Max+1;
- disappear.ies5Stu.count.updown= -disappear.ies5Stu.count.rank;
- disappear.ies5Stu.count.range= -disappear.ies5Stu.count.value;
- disappear.ies5Stu.count.value=0;
- disappear.ies5Stu.count.rank=rank_ies5Stu_count_Max+1;
- disappear.ies5Tch.count.updown= -disappear.ies5Tch.count.rank;
- disappear.ies5Tch.count.range= -disappear.ies5Tch.count.value;
- disappear.ies5Tch.count.value=0;
- disappear.ies5Tch.count.rank=rank_ies5Tch_count_Max+1;
- disappear.otherStu.count.updown= -disappear.otherStu.count.rank;
- disappear.otherStu.count.range= -disappear.otherStu.count.value;
- disappear.otherStu.count.value=0;
- disappear.otherStu.count.rank=rank_otherStu_count_Max+1;
- disappear.otherTch.count.updown= -disappear.otherTch.count.rank;
- disappear.otherTch.count.range= -disappear.otherTch.count.value;
- disappear.otherTch.count.value=0;
- disappear.otherTch.count.rank=rank_otherTch_count_Max+1;
- disappear.teacher.duration.updown= -disappear.teacher.duration.rank;
- disappear.teacher.duration.range= -disappear.teacher.duration.value;
- disappear.teacher.duration.value=0;
- disappear.teacher.duration.rank=rank_teacher_duration_Max+1;
- disappear.student.duration.updown= -disappear.student.duration.rank;
- disappear.student.duration.range= -disappear.student.duration.value;
- disappear.student.duration.value=0;
- disappear.student.duration.rank=rank_student_duration_Max+1;
- disappear.hiteach.duration.updown= -disappear.hiteach.duration.rank;
- disappear.hiteach.duration.range= -disappear.hiteach.duration.value;
- disappear.hiteach.duration.value=0;
- disappear.hiteach.duration.rank=rank_hiteach_duration_Max+1;
- disappear.hita.duration.updown= -disappear.hita.duration.rank;
- disappear.hita.duration.range= -disappear.hita.duration.value;
- disappear.hita.duration.value=0;
- disappear.hita.duration.rank=rank_hita_duration_Max+1;
- disappear.ies5Stu.duration.updown= -disappear.ies5Stu.duration.rank;
- disappear.ies5Stu.duration.range= -disappear.ies5Stu.duration.value;
- disappear.ies5Stu.duration.value=0;
- disappear.ies5Stu.duration.rank=rank_ies5Stu_duration_Max+1;
- disappear.ies5Tch.duration.updown= -disappear.ies5Tch.duration.rank;
- disappear.ies5Tch.duration.range= -disappear.ies5Tch.duration.value;
- disappear.ies5Tch.duration.value=0;
- disappear.ies5Tch.duration.rank=rank_ies5Tch_duration_Max+1;
- disappear.otherStu.duration.updown= -disappear.otherStu.duration.rank;
- disappear.otherStu.duration.range= -disappear.otherStu.duration.value;
- disappear.otherStu.duration.value=0;
- disappear.otherStu.duration.rank=rank_otherStu_duration_Max+1;
- disappear.otherTch.duration.updown= -disappear.otherTch.duration.rank;
- disappear.otherTch.duration.range= -disappear.otherTch.duration.value;
- disappear.otherTch.duration.value=0;
- disappear.otherTch.duration.rank=rank_otherTch_duration_Max+1;
- currentStickiness.Add(disappear);
- }
- }
- currentStickiness = currentStickiness.OrderByDescending(x => x.teacher.stick.value).ToList();
- return currentStickiness;
- }
- /// <summary>
- /// 结算访问日志
- /// </summary>
- public static async Task
- VisitSettle(List<string> times, AzureStorageFactory _azureStorage, AzureRedisFactory _azureRedis, Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator, IPSearcher _ipSearcher, string force)
- {
- foreach (var timeDate in times)
- {
- List<Stick> chinaSticks = new List<Stick>();
- List<Stick> globalSticks = new List<Stick>();
- if (DateTimeOffset.TryParse(timeDate, out DateTimeOffset date))
- {
- var blobClientChina = _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/cday.json");
- var blobClientGlobal = _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/gday.json");
- bool g = true, c = true;
- if (blobClientChina.Exists() && force.Equals("0"))
- {
- c=false;
- BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/cday.json").DownloadContentAsync();
- var contentBygone = result.Content.ToString();
- var chinaStick = contentBygone.ToObject<Stick>();
- chinaSticks.Add(chinaStick);
- }
- if (blobClientGlobal.Exists()&& force.Equals("0"))
- {
- g=false;
- BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/gday.json").DownloadContentAsync();
- var contentBygone = result.Content.ToString();
- var globalStick = contentBygone.ToObject<Stick>();
- globalSticks.Add(globalStick);
- }
- if (g||c)
- {
- BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/index.log").DownloadContentAsync();
- var content = result.Content.ToString();
- content= content.Substring(0, content.Length-2);
- if (content.EndsWith("}"))
- {
- content=$"[{content}]";
- }
- else
- {
- content=$"[{content}}}]";
- }
- List<ApiVisit> apiVisits = new List<ApiVisit>();
- apiVisits.AddRange(content.ToObject<List<ApiVisit>>());
- var dateNow = DateTimeOffset.Now.GetGMTTime(8);
- if ($"{dateNow:yyyy-MM-dd}".Equals($"{date:yyyy-MM-dd}"))
- { //当前小时一致的
- BlobDownloadResult resultHour = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/{date:HH}.log").DownloadContentAsync();
- var contentHour = resultHour.Content.ToString();
- contentHour= contentHour.Substring(0, contentHour.Length-2);
- if (contentHour.EndsWith("}"))
- {
- contentHour=$"[{contentHour}]";
- }
- else
- {
- contentHour=$"[{contentHour}}}]";
- }
- var httpLog = contentHour.ToObject<List<HttpLog>>();
- (ConcurrentBag<ApiVisit> visits, ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo) = await SystemService.ConvertHttpLog(httpLog, _azureRedis, _ipSearcher, _longitudeLatitudeTranslator, dateNow, false);
- apiVisits.AddRange(visits);
- }
- if (c)
- {
- Stick apiVisitsBygone = await GetBygoneSettleData(_azureStorage, date, "China");
- //大陆学校
- var chinaApiVisits = apiVisits.Where(x => x.hostName.Equals("大陆站"));
- var chinaSchoolVisits = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.school) && x.hostName.Equals("大陆站")).GroupBy(x => x.school);
- List<SchoolStick> chinaStickiness = CountSchoolStickiness(chinaSchoolVisits, chinaApiVisits, apiVisitsBygone.schoolSticks);
- Stick stickc = new Stick();
- stickc.schoolSticks=chinaStickiness;
- chinaSticks.Add(stickc);
- if (!$"{dateNow:yyyy-MM-dd}".Equals($"{date:yyyy-MM-dd}"))
- {
- await _azureStorage.GetBlobContainerClient("0-service-log").UploadFileByContainer(stickc.ToJsonString(), "http-log", $"{date:yyyy}/{date:MM}/{date:dd}/cday.json", true);
- }
- }
- if (g)
- {
- Stick apiVisitsBygone = await GetBygoneSettleData(_azureStorage, date, "Global");
- //国际学校
- var globalApiVisits = apiVisits.Where(x => x.hostName.Equals("国际站"));
- var globalSchoolVisits = apiVisits.Where(x => !string.IsNullOrWhiteSpace(x.school) && x.hostName.Equals("国际站")).GroupBy(x => x.school);
- List<SchoolStick> globalStickiness = CountSchoolStickiness(globalSchoolVisits, globalApiVisits, apiVisitsBygone.schoolSticks);
- Stick stickg = new Stick();
- stickg.schoolSticks=globalStickiness;
- globalSticks.Add(stickg);
- //如果是当天的 ,则不能保存
- if (!$"{dateNow:yyyy-MM-dd}".Equals($"{date:yyyy-MM-dd}"))
- {
- await _azureStorage.GetBlobContainerClient("0-service-log").UploadFileByContainer(stickg.ToJsonString(), "http-log", $"{date:yyyy}/{date:MM}/{date:dd}/gday.json", true);
- }
- }
- }
- else
- {
- continue;
- }
- }
- }
- }
- public static async Task<Stick> GetBygoneSettleData(AzureStorageFactory _azureStorage, DateTimeOffset date, string cg)
- {
- //过去一天的数据
- var bygone = date.AddDays(-1);
- Stick apiVisitsBygone = new Stick();
- try
- {
- cg=cg.Contains("China", StringComparison.OrdinalIgnoreCase) ? "cday.json" : "gday.json";
- BlobDownloadResult chinaResultBygone = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{bygone:yyyy}/{bygone:MM}/{bygone:dd}/{cg}").DownloadContentAsync();
- var contentBygone = chinaResultBygone.Content.ToString();
- apiVisitsBygone= contentBygone.ToObject<Stick>();
- }
- catch
- { //可能出现异常,因为文件不存在。第一次初始化,前一天的数据没有 }
- }
- return apiVisitsBygone;
- }
- public static async Task<(ConcurrentBag<ApiVisit> visits, ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo)>
- ConvertHttpLog(List<HttpLog> logs, AzureRedisFactory _azureRedis, IPSearcher _ipSearcher, Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator, DateTimeOffset gmt8Time, bool test = false)
- {
- ConcurrentBag<ApiVisit> visits = new ConcurrentBag<ApiVisit>();
- ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo = new ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
- object lockObj = new object();
- await Parallel.ForEachAsync(logs, async (log, _) =>
- {
- if (!log.path.Contains("."))
- {
- string uuid = Guid.NewGuid().ToString();
- List<string> schoolMatch = new List<string>();
- List<string> useridMatch = new List<string>();
- var vist = new ApiVisit()
- {
- id=uuid,
- ip=log.ip,
- tid=log.tid,
- time= log.time,
- userId= log.id,
- picture=log.picture,
- school= log.school,
- tname= log.name,
- path = log.path,
- client=log.p.Equals("os", StringComparison.OrdinalIgnoreCase) ? "ies5" : log.p,
- scope=log.scope,
- host= log.host,
- hostName=log.hostName,
- l=log.l,
- year = $"{gmt8Time:yyyy}",
- month = $"{gmt8Time:MM}",
- day = $"{gmt8Time:dd}",
- hour =$"{gmt8Time:HH}"
- };
- if (test)
- {
- var time = DateTimeOffset.FromUnixTimeMilliseconds(log.time);
- //本地调试时间
- if (vist.ip.Equals("0.0.0.1"))
- {
- time= time.AddHours(8);
- }
- vist.year = $"{time:yyyy}";
- vist.month = $"{time:MM}";
- vist.day = $"{time:dd}";
- vist.hour =$"{time:HH}";
- }
- if (string.IsNullOrWhiteSpace(vist.userId))
- {
- //var jsonPathContext = new JsonPathContext();
- //jsonPathContext.ValueSystem= new JsonTextValueSystem();
- string path = "$..['id_token','idToken','idtoken','tmdid','id','teacherId','teacher','tid','tId','userid','userId','creatorId','creator','code','studentId','student','studentid']";
- if (!log.param.ValueKind.Equals(JsonValueKind.Null))
- {
- JObject jsonObject = JObject.Parse(log.param.GetRawText());
- //var nodes_path = jsonPathContext.SelectNodes(log.param, path);
- var nodes_path = jsonObject.SelectTokens(path);
- foreach (var node in nodes_path)
- {
- // 只获取是字符串的
- if (node.Type.Equals(JTokenType.String))
- {
- switch (true)
- {
- case bool when node.Path.Contains("id_token")||node.Path.Contains("idToken")||node.Path.Contains("idtoken"):
- {
- try
- {
- var jwt = new JwtSecurityToken($"{node}");
- string id = jwt.Payload.Sub;
- var name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
- var picture = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("picture"))?.Value;
- if (!string.IsNullOrWhiteSpace(id) && long.TryParse(id, out long _id))
- {
- vist.userId=id;
- vist.scope="teacher";
- vist.tname=name;
- vist.picture=picture;
- useridMatch.Add(id);
- }
- }
- catch (Exception ex) { }
- break;
- }
- case bool when node.Path.Contains("tmdid")||node.Path.Contains("id")||node.Path.Contains("teacherId")
- ||node.Path.Contains("teacher")||node.Path.Contains("tid")||node.Path.Contains("tId")||node.Path.Contains("userid")
- ||node.Path.Contains("userId"):
- {
- if (!string.IsNullOrWhiteSpace($"{node}") && long.TryParse($"{node}", out long _id))
- {
- vist.userId=$"{node}";
- vist.scope="teacher";
- useridMatch.Add($"{node}");
- }
- break;
- }
- case bool when node.Path.Contains("studentId")||node.Path.Contains("student")||node.Path.Contains("studentid"):
- {
- if (!string.IsNullOrWhiteSpace($"{node}") && long.TryParse($"{node}", out long _id))
- {
- vist.userId=$"{node}";
- vist.scope="student";
- useridMatch.Add($"{node}");
- }
- break;
- }
- case bool when node.Path.Contains("code"):
- {
- if (!string.IsNullOrWhiteSpace($"{node}"))
- {
- if (long.TryParse($"{node}", out long _id))
- {
- vist.userId=$"{node}";
- useridMatch.Add($"{node}");
- }
- else
- {
- string[] codes = $"{node}".Split("-");
- foreach (var _code in codes)
- {
- if (long.TryParse(_code, out long _codeid))
- {
- vist.userId=$"{node}";
- useridMatch.Add($"{_code}");
- break;
- }
- }
- }
- }
- break;
- }
- }
- }
- }
- if (log.path.Contains("process-notify", StringComparison.OrdinalIgnoreCase))
- {
- string s = log.param.ToJsonString().Replace("\\", "");
- Regex regextmdid = new Regex("\"tmdid\":\"(\\d+)\"");
- Match matchtmdid = regextmdid.Match(s);
- if (matchtmdid.Success)
- {
- var t = matchtmdid.Groups[1].Value;
- if (!string.IsNullOrWhiteSpace(t))
- {
- vist.userId=t;
- vist.scope="teacher";
- useridMatch.Add(t);
- }
- }
- Regex regexname = new Regex("\"tmdname\":\"(.+?)\"");
- Match matchname = regexname.Match(s);
- if (matchname.Success)
- {
- var t = matchname.Groups[1].Value;
- if (!string.IsNullOrWhiteSpace(t))
- {
- vist.tname=t;
- }
- }
- }
- }
- }
- else
- {
- if (string.IsNullOrWhiteSpace($"{vist.scope}"))
- {
- vist.scope="teacher";
- uuidInfo.Add((uuid, log, new List<string>() { vist.userId }, new List<string>()));
- }
- }
- if (string.IsNullOrWhiteSpace(vist.school) || vist.school.Equals("true") || vist.school.Equals("false"))
- {
- vist.school="";
- string path = "$..['school','id','schoolId','schoolid','schoolCode','school_code','schoolcode','code']";
- if (!log.param.ValueKind.Equals(JsonValueKind.Null))
- {
- JObject jsonObject = JObject.Parse(log.param.GetRawText());
- var nodes_path = jsonObject.SelectTokens(path);
- foreach (var node in nodes_path)
- {
- // 只获取是字符串的
- if (node.Type.Equals(JTokenType.String))
- {
- switch (true)
- {
- case bool when node.Path.Contains("school")||node.Path.Contains("id")||node.Path.Contains("schoolId")
- ||node.Path.Contains("schoolid")||node.Path.Contains("schoolCode")||node.Path.Contains("school_code")||node.Path.Contains("schoolcode"):
- {
- if (!$"{node}".Contains("-")&& $"{node}".Length<=8 && $"{node}".Length>=1)
- {
- vist.school=$"{node}";
- schoolMatch.Add($"{node}");
- }
- break;
- }
- case bool when node.Path.Contains("code"):
- {
- if (!$"{node}".Contains("-")&& $"{node}".Length<=8&& $"{node}".Length>=1)
- {
- vist.school=$"{node}";
- schoolMatch.Add($"{node}");
- }
- else
- {
- string[] codes = $"{node}".Split("-");
- foreach (var _code in codes)
- {
- if ($"{_code}".Length<=8 && $"{_code}".Length>=1)
- {
- vist.school=$"{_code}";
- schoolMatch.Add($"{_code}");
- break;
- }
- }
- }
- break;
- }
- }
- }
- }
- if (log.path.Contains("process-notify", StringComparison.OrdinalIgnoreCase))
- {
- string s = log.param.ToJsonString().Replace("\\", "");
- Regex regexname = new Regex("\"schoolId\":\"(.+?)\"");
- Match matchname = regexname.Match(s);
- if (matchname.Success)
- {
- var t = matchname.Groups[1].Value;
- if (!string.IsNullOrWhiteSpace(t))
- {
- vist.school=t;
- }
- }
- }
- }
- }
- //处理 client
- {
- if (!string.IsNullOrWhiteSpace(log.client))
- {
- if (log.client.Equals("IES", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="ies5";
- }
- if (log.client.Equals("AClassONE", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="aclassone";
- }
- if (log.client.Equals("BB", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="habb";
- }
- if (log.client.Equals("HiTool", StringComparison.OrdinalIgnoreCase) ||log.client.Equals("HiTools", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="hiscan";
- }
- if (log.client.Equals("HiTA", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="hita";
- vist.scope="teacher";
- }
- if (log.client.Equals("HiTeachCC", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="hiteachcc";
- }
- if (log.client.Equals("HiTeach", StringComparison.OrdinalIgnoreCase))
- {
- vist.scope="teacher";
- vist.client="hiteach";
- }
- if (log.client.Equals("Open", StringComparison.OrdinalIgnoreCase))
- {
- vist.client="open";
- }
- }
- }
- //补全站点
- {
- if (
- (log.host.Equals("wwww.teammodel.net")||log.host.Equals("ies5-rc.teammodel.net")))
- {
- vist.hostName="国际站";
- vist.host="www.teammodel.net";
- vist.client="ies5";
- vist.l="Global";
- }
- else if (
- log.host.Equals("teammodelos-yx.chinacloudsites.cn")||log.host.Equals("teammodelos.chinacloudsites.cn")
- ||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"))
- {
- vist.hostName="大陆站";
- vist.host="www.teammodel.cn";
- vist.client="ies5"; vist.l="China";
- }
- else if ((log.host.Contains("localhost") && log.p.Equals("os"))|| log.host.Equals("teammodelos-test.chinacloudsites.cn") ||log.host.Equals("test.teammodel.cn"))
- {
- vist.hostName="测试站";
- vist.host="test.teammodel.cn";
- vist.client="ies5";
- vist.l="China";
- }
- else if (
- (log.host.Equals("scyx.teammodel.cn") ||log.host.Equals("jinniu.teammodel.cn")))
- {
- vist.hostName="研修2.0";
- vist.host="scyx.teammodel.cn";
- vist.client="ability"; vist.l="China";
- }
- else if (
- log.host.Equals("open.teammodel.cn")||log.host.Equals("open-test.teammodel.cn") ||log.host.Equals("zhiyin-test.teammodel.cn"))
- {
- vist.hostName="开放平台";
- vist.host="open.teammodel.cn";
- vist.client="open";
- vist.l="China";
- }
- else if ((log.host.Equals("bi-rc.teammodel.net") || log.host.Equals("bi.teammodel.net")))
- {
- vist.hostName="国际站";
- vist.host="bi.teammodel.net";
- vist.client="bi";
- vist.scope="admin";
- vist.l="Global";
- }
- else if (log.host.Equals("teammodelbi.chinacloudsites.cn") ||log.host.Equals("bi.teammodel.cn"))
- {
- vist.hostName="大陆站";
- vist.host="bi.teammodel.cn";
- vist.client="bi";
- vist.scope="admin";
- vist.l="China";
- }
- else if (log.host.Equals("bitest.teammodel.cn")||log.host.Equals("teammodelbi-test.chinacloudsites.cn")||(log.host.Contains("localhost") && (log.p.Equals("bi"))))
- {
- vist.hostName="测试站";
- vist.host="testbi.teammodel.cn";
- vist.client="bi";
- vist.scope="admin";
- vist.l="China";
- }
- else if (
- log.host.Equals("teamcontest.chinacloudsites.cn")||log.host.Equals("contest.chinacloudsites.cn")||log.host.Equals("contest-test.chinacloudsites.cn"))
- {
- vist.hostName="大陆站";
- vist.host="contest.teammodel.cn";
- vist.client="contest"; vist.l="China";
- }
- else if (
- log.host.Equals("hiteachcc.chinacloudsites.cn"))
- {
- vist.hostName="正式站";
- vist.host="hiteachcc.teammodel.cn";
- vist.client="hiteachcc";
- vist.l="China";
- }
- else if (log.host.Equals("appraisal.chinacloudsites.cn"))
- {
- vist.hostName="大陆站";
- vist.host="appraisal.teammodel.cn";
- vist.client="appraisal";
- vist.l="China";
- }
- else if ((log.host.Contains("localhost") && log.p.Equals("appraisal"))||log.host.Equals("appraisal-test.teammodel.cn") ||log.host.Equals("appraisal-test.chinacloudsites.cn"))
- {
- vist.hostName="测试站";
- vist.host="appraisal-test.teammodel.cn";
- vist.client="appraisal";
- vist.l="China";
- }
- else
- {
- if (!string.IsNullOrWhiteSpace(log.p))
- {
- vist.client=log.p.Equals("os", StringComparison.OrdinalIgnoreCase) ? "ies5" : log.p;
- }
- else
- {
- vist.client="other";
- }
- if (log.host.EndsWith(".cn"))
- {
- vist.hostName="大陆站";
- vist.l="China";
- }
- else if (log.host.EndsWith(".net"))
- {
- vist.hostName="国际站";
- vist.l="Global";
- }
- else
- {
- vist.hostName="其他";
- vist.l="其他";
- }
- }
- }
- //补全产品端
- {
- //研修2.0
- if (log.path.Contains("research") || log.path.Contains("study") || log.path.Contains("standard-file"))
- {
- vist.client="ability";
- }
- if (log.path.Contains("teacher"))
- {
- vist.scope="teacher";
- }
- if (log.path.Contains("tmduser"))
- {
- vist.scope="tmduser";
- }
- if (log.path.Contains("student/login"))
- {
- vist.scope="student";
- }
- if (log.path.StartsWith("/activity"))
- {
- vist.client="contest";
- }
- //小程序
- if (log.path.Contains("aclassone"))
- {
- vist.client="aclassone";
- }
- // /// <summary>
- /// ExamInfo qamode 書面問答類型 0:書面問答 1:紙本測驗 2:艺术评测
- /// </summary>
- //艺术评测
- 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"))
- {
- vist.client="art";
- }
- if (log.path.Contains("common/exam/upsert-record"))
- {
- JObject jobject = JObject.Parse(log.param.GetRawText());
- var jtokens = jobject.SelectTokens("$..artId");
- if (jtokens!=null && jtokens.Count()>0)
- {
- vist.client="art";
- vist.scope="student";
- }
- }
- if (log.path.Contains("habb"))
- {
- vist.client="habb";
- }
- //阅卷客户端
- if (log.path.Contains("hiscan"))
- {
- vist.client="hiscan";
- }
- if (log.path.Contains("hita"))
- {
- vist.client="hita";
- }
- if (log.path.Contains("hiteachcc"))
- {
- vist.client="hiteachcc";
- }
- if (log.path.Contains("sokrate"))
- {
- vist.client="sokrate";
- }
- if (log.path.Contains("sokrate") || log.path.Contains("score"))
- {
- vist.client="sokrate";
- }
- if (log.path.Contains("hiteach"))
- {
- vist.client="hiteach";
- }
- ///IES开放平台
- if (log.path.Contains("business") || log.path.Contains("biz") || log.path.Contains("openapi-config") || log.path.Contains("open-api"))
- {
- vist.client="open";
- }
- //从token的role 能否获取 开放平台
- //单点登录及第三方接口
- 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")
- || log.path.Contains("oauth/check-bind")|| log.path.Contains("dingding") || log.path.Contains("wechat")
- )
- {
- vist.client="sso-third";
- }
- }
- //处理IP转地区
- var region = await _ipSearcher.SearchIpAsync(vist.ip);
- if (string.IsNullOrWhiteSpace(region))
- {
- region="未知IP·未知IP·未知IP";
- }
- if (!string.IsNullOrWhiteSpace(region))
- {
- region= region.Replace("省·", "·").Replace("市·", "·").Replace("特别行政区·", "·").Replace("藏族羌族自治州·", "·");
- var regions = region.Split("·");
- if (regions.Length==4)
- {
- vist.area= regions[0];
- vist.province = regions[1];
- vist.city = regions[2];
- }
- if (regions.Length==3)
- {
- vist.area= regions[0];
- vist.province = regions[1];
- }
- if (regions.Length==2)
- {
- vist.area= regions[0];
- vist.province = regions[1];
- }
- if (regions.Length==1)
- {
- vist.area= regions[0];
- }
- }
- //处理地区转经纬度
- {
- IEnumerable<JToken> tokens = default;
- if (!string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i && @.city=~ /.*{vist.city}/i)]");
- if (!(tokens.Any() && tokens.Count()>0))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i && @.city=~ /.*{vist.province}/i)]");
- if (!(tokens.Any() && tokens.Count()>0))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i || @.city=~ /.*{vist.city}/i)]");
- }
- if (!(tokens.Any() && tokens.Count()>0))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i||@.city=~ /.*{vist.province}/i)]");
- }
- }
- }
- else if (string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
- {
- if (vist.area.Equals("中国"))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i)]");
- if (!(tokens.Any() && tokens.Count()>0))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i)]");
- }
- }
- else
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i || @.province=~ /.*{vist.province}/i)]");
- }
- }
- else if (!string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
- {
- if (vist.area.Equals("中国"))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i)]");
- if (!(tokens.Any() && tokens.Count()>0))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i)]");
- }
- }
- else
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.city}/i || @.city=~ /.*{vist.province}/i)]");
- }
- }
- else if (string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
- {
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.country=~ /.*{vist.area}/i && @.m=='1')]");
- }
- if (tokens!=null && tokens.Any())
- {
- List<RegionLngLat> regionLngLats = new List<RegionLngLat>();
- foreach (JToken token in tokens)
- {
- regionLngLats.Add(token.ToString().ToObject<RegionLngLat>());
- }
- var points = regionLngLats.FindAll(x => string.IsNullOrWhiteSpace(x.area));
- if (!points.IsNotEmpty())
- {
- points= regionLngLats.FindAll(x => !string.IsNullOrWhiteSpace(x.m) && x.m.Equals("1"));
- }
- if (string.IsNullOrWhiteSpace(vist.city))
- {
- vist.city=points?.FirstOrDefault()?.city;
- if (!string.IsNullOrWhiteSpace(vist.city) && vist.city.EndsWith("市"))
- {
- vist.city=vist.city.Replace("市", "");
- }
- }
- vist.lat=points?.FirstOrDefault()?.lat;
- vist.lng=points?.FirstOrDefault()?.lng;
- }
- else
- {
- if (vist.area.Equals("内网IP"))
- {
- if (vist.host.Contains(".cn") || vist.host.Contains("localhost"))
- {
- vist.lat="30.655821878416408";
- vist.lng="104.08153351042463";
- vist.area="中国";
- vist.province="四川";
- vist.city="成都";
- }
- else
- {
- vist.lat="25.044332";
- vist.lng="121.509062";
- vist.area="中国";
- vist.province="台湾";
- vist.city="台湾";
- }
- }
- else
- {
- vist.lat="30.655821878416408";
- vist.lng="104.08153351042463";
- vist.area="中国";
- vist.province="四川";
- vist.city="成都";
- }
- }
- }
- uuidInfo.Add((uuid, log, useridMatch, schoolMatch));
- visits.Add(vist);
- }
- }
- );
- List<(string tmd, bool exists, string scope)> tmdexists = new List<(string tmd, bool exists, string scope)>();
- List<(string sch, bool exists)> schexists = new List<(string sch, bool exists)>();
- var tmds = uuidInfo.SelectMany(x => x.tmdid).ToHashSet();
- if (tmds.Any())
- {
- foreach (var tmd in tmds)
- {
- var exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Blob:Catalog:{tmd}");
- if (exists)
- {
- tmdexists.Add((tmd, exists, "teacher"));
- }
- else
- {
- exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Login:School:hbcn:student:{tmd}");
- tmdexists.Add((tmd, exists, "student"));
- }
- }
- }
- var schs = uuidInfo.SelectMany(x => x.school).ToHashSet();
- if (schs.Any())
- {
- foreach (var sch in schs)
- {
- var exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Blob:Catalog:{sch}");
- schexists.Add((sch, exists));
- }
- }
- foreach (var item in uuidInfo)
- {
- foreach (var tmd in item.tmdid)
- {
- var tmdext = tmdexists.Find(x => x.tmd.Equals(tmd));
- if (tmdext.tmd!= null && tmdext.exists)
- {
- var vist = visits.Where(x => x.id.Equals(item.uuid));
- foreach (var vi in vist)
- {
- vi.userId=tmd;
- if (string.IsNullOrWhiteSpace(vi.scope))
- {
- vi.scope=tmdext.scope;
- }
- }
- break;
- }
- }
- foreach (var sch in item.school)
- {
- var schext = schexists.Find(x => x.sch.Equals(sch));
- if (schext.sch!= null && schext.exists)
- {
- var vist = visits.Where(x => x.id.Equals(item.uuid));
- foreach (var vi in vist)
- {
- vi.school=sch;
- }
- break;
- }
- }
- }
- return (visits, uuidInfo);
- }
- public class ApiVisit
- {
- public string id { get; set; }
- public string path { get; set; }
- /// <summary>
- /// 细分
- /// ies5 ,hiteach,hita,cc,bi,contest,open,aclassone,sokrates,ability,art
- /// 产品端
- /// </summary>
- public string client { get; set; }
- /// <summary>
- /// 具体功能
- /// </summary>
- // public string func { get; set; }
- public string userId { get; set; }
- public string picture { get; set; }
- public string scope { get; set; }
- public string tname { get; set; }
- public string school { get; set; }
- public string ip { get; set; }
- //public string region { get; set; }
- public string area { get; set; }
- public string province { get; set; }
- public string city { get; set; } = "";
- public long time { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string host { get; set; }
- public string hostName { get; set; } = "其他";
- /// <summary>
- /// tokenid
- /// </summary>
- public string tid { get; set; }
- public string year { get; set; }
- public string month { get; set; }
- public string day { get; set; }
- public string hour { get; set; }
- //public RegionLngLat point { get; set; }
- public string lat { get; set; }
- public string lng { get; set; }
- public string l { get; set; }
- }
- public class HttpLog
- {
- public string ip { get; set; }
- public long time { get; set; }
- public string host { get; set; }
- public string hostName = "其他";
- public string tid { get; set; }
- public string path { get; set; }
- public string client { get; set; }
- public JsonElement param { get; set; }
- public string id { get; set; }
- public string name { get; set; }
- public string picture { get; set; }
- public string school { get; set; }
- public string p { get; set; }
- // public string ua { get; set; }
- // public string referer { get; set; }
- public string scope { get; set; }
- public string year { get; set; }
- public string month { get; set; }
- public string day { get; set; }
- public string hour { get; set; }
- public string l { get; set; }
- }
- public record RegionLngLat
- {
- public string country { get; set; }
- public string province { get; set; }
- public string city { get; set; }
- public string lat { get; set; }
- public string lng { get; set; }
- public string area { get; set; }
- public string m { get; set; } = "0";
- }
- public class CountData
- {
- public string pk { get; set; } = "";
- public string sk { get; set; } = "";
- public string sp { get; set; } = "";
- public int count { get; set; }
- }
- public class SchoolStick
- {
- /// <summary>
- /// 名字
- /// </summary>
- public string name { get; set; }
- public string picture { get; set; }
- /// <summary>
- /// 编码
- /// </summary>
- public string id { get; set; }
- public string last { get; set; }
- #region teacher
- public ClientStick teacher { get; set; } = new ClientStick();
- #endregion
- #region student
- public ClientStick student { get; set; } = new ClientStick();
- #endregion
- #region hiteach
- public ClientStick hiteach { get; set; } = new ClientStick();
- public Indicator lesson { get; set; } = new Indicator();
- #endregion
- #region hita
- public ClientStick hita { get; set; } = new ClientStick();
- #endregion
- #region ies5Teacher
- public ClientStick ies5Tch { get; set; } = new ClientStick();
- #endregion
- #region otherTeacher
- public ClientStick otherTch { get; set; } = new ClientStick();
- #endregion
- #region ies5Student
- public ClientStick ies5Stu { get; set; } = new ClientStick();
- #endregion
- #region otherStudent
- public ClientStick otherStu { get; set; } = new ClientStick();
- #endregion
- public List<TchStick> tchSticks { get; set; } = new List<TchStick>();
- public List<StuStick> stuSticks { get; set; } = new List<StuStick>();
- }
- public class TchStick
- {
- public string school { get; set; }
- /// <summary>
- /// 名字
- /// </summary>
- public string name { get; set; }
- public string picture { get; set; }
- /// <summary>
- /// 编码
- /// </summary>
- public string id { get; set; }
- public string last { get; set; }
- #region tmd
- public ClientStick teacher { get; set; } = new ClientStick();
- #endregion
- #region hiteach
- public ClientStick hiteach { get; set; } = new ClientStick();
- public Indicator lesson { get; set; } = new Indicator();
- #endregion
- #region hita
- public ClientStick hita { get; set; } = new ClientStick();
- #endregion
- #region ies5Teacher
- public ClientStick ies5Tch { get; set; } = new ClientStick();
- #endregion
- #region otherTeacher
- public ClientStick otherTch { get; set; } = new ClientStick();
- #endregion
- }
- public class StuStick
- {
- public string school { get; set; }
- /// <summary>
- /// 名字
- /// </summary>
- public string name { get; set; }
- public string picture { get; set; }
- /// <summary>
- /// 编码
- /// </summary>
- public string id { get; set; }
- public string last { get; set; }
- #region tmd
- public ClientStick student { get; set; } = new ClientStick();
- #endregion
- #region ies5Student
- public ClientStick ies5Stu { get; set; } = new ClientStick();
- #endregion
- #region otherStudent
- public ClientStick otherStu { get; set; } = new ClientStick();
- #endregion
- }
- public class ClientStick
- {
- public int userCount { get; set; }
- public int userUpdown { get; set; }
- public Indicator stick { get; set; } = new Indicator();
- public Indicator duration { get; set; } = new Indicator();
- public Indicator count { get; set; } = new Indicator();
- }
- public class Indicator
- {
- /// <summary>
- /// 值
- /// </summary>
- public double value { get; set; } = 0;
- /// <summary>
- /// 值的增减浮动
- /// </summary>
- public double range { get; set; } = 0;
- /// <summary>
- /// 排名
- /// </summary>
- public double rank { get; set; } = 0;
- /// <summary>
- /// 排名的上升下降
- /// </summary>
- public double updown { get; set; } = 0;
- }
- public class Stick
- {
- public List<SchoolStick> schoolSticks { get; set; } = new List<SchoolStick>();
- public List<TchStick> tchSticks { get; set; } = new List<TchStick>();
- }
- public class LessonWeek
- {
- /// <summary>
- /// 第几周
- /// </summary>
- public int week { get; set; }
- /// <summary>
- /// 课例id
- /// </summary>
- public string? id { get; set; }
- /// <summary>
- /// 课程id
- /// </summary>
- public string? cid { get; set; }
- /// <summary>
- /// 科目id
- /// </summary>
- public string? sid { get; set; }
- /// <summary>
- /// 学校
- /// </summary>
- public string? school { get; set; }
- /// <summary>
- /// 名单id
- /// </summary>
- public string? gid { get; set; }
- /// <summary>
- /// 学段id
- /// </summary>
- //public string? pid { get; set; }
- public string? scope { get; set; }
- }
- public class Product
- {
- public string Name { get; set; }
- public double VisitDuration { get; set; }
- public double VisitCount { get; set; }
- public double CalculateProductIndex(double timeWeight, double countWeight, double minVisitDuration, double maxVisitDuration, double minVisitCount, double maxVisitCount)
- {
- // 计算访问时长的Min-Max标准化值
- double standardizedVisitDuration = (maxVisitDuration - minVisitDuration)!=0 ? (VisitDuration - minVisitDuration) / (maxVisitDuration - minVisitDuration) : 0;
- // 计算访问次数的Min-Max标准化值
- double standardizedVisitCount = (maxVisitCount - minVisitCount)!=0 ? (VisitCount - minVisitCount) / (maxVisitCount - minVisitCount) : 0;
- // 计算加权综合指数
- double comprehensiveIndex = timeWeight * standardizedVisitDuration + countWeight * standardizedVisitCount;
- return Math.Round(comprehensiveIndex, 4);
- }
- }
- }
- }
|