1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258 |
- using Azure.Cosmos;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Newtonsoft.Json;
- using StackExchange.Redis;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Json;
- using System.Text;
- using System.Text.Json;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK.Models.Cosmos.Common;
- using TEAMModelOS.SDK.Models.Service;
- using HTEXLib.COMM.Helpers;
- using Azure.Storage.Blobs.Models;
- using Azure.Storage.Blobs;
- using System.Security.Cryptography;
- using Azure;
- using Microsoft.Extensions.Options;
- using Microsoft.Extensions.Configuration;
- using TEAMModelOS.Models;
- using System.Text.RegularExpressions;
- using TEAMModelOS.SDK.Services;
- using Azure.Messaging.ServiceBus;
- using TEAMModelOS.SDK.Models.Cosmos.BI;
- using static ICSharpCode.SharpZipLib.Zip.ZipEntryFactory;
- using Azure.Storage.Sas;
- using DocumentFormat.OpenXml.Drawing.Diagrams;
- using TEAMModelOS.SDK.Models.Dtos;
- using DocumentFormat.OpenXml.Bibliography;
- using System.Formats.Asn1;
- using System.Xml.Linq;
- using DocumentFormat.OpenXml.Math;
- using OpenXmlPowerTools;
- using Top.Api;
- using DinkToPdf.Contracts;
- using DocumentFormat.OpenXml.Office2010.Excel;
- using TEAMModelOS.SDK.Models.Cosmos.Student;
- using MathNet.Numerics.RootFinding;
- using DocumentFormat.OpenXml.Wordprocessing;
- using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
- using OfficeOpenXml;
- using Microsoft.AspNetCore.Components.Web;
- using Microsoft.AspNetCore.Cors.Infrastructure;
- using MathNet.Numerics.Distributions;
- using TEAMModelOS.Models.Dto;
- using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
- namespace TEAMModelOS.Controllers
- {
- [Route("fix-data")]
- [ApiController]
- public class FixDataController : ControllerBase
- {
- private readonly IHttpClientFactory _httpClient;
- private readonly IConfiguration _configuration;
- private readonly AzureStorageFactory _azureStorage;
- private readonly AzureRedisFactory _azureRedis;
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private readonly AzureServiceBusFactory _serviceBus;
- private readonly HttpTrigger _httpTrigger;
- private readonly CoreAPIHttpService _coreAPIHttpService;
-
- private readonly IConverter _converter;
- public FixDataController(IConverter converter,IHttpClientFactory httpClient, HttpTrigger httpTrigger, AzureServiceBusFactory serviceBus, AzureCosmosFactory azureCosmos, AzureRedisFactory azureRedis, AzureStorageFactory azureStorage, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService)
- {
- _azureCosmos = azureCosmos;
- _azureRedis = azureRedis;
- _azureStorage = azureStorage;
- _dingDing = dingDing;
- _option = option?.Value;
- _configuration = configuration;
- _serviceBus = serviceBus;
- _httpTrigger = httpTrigger;
- _coreAPIHttpService = coreAPIHttpService;
- _httpClient = httpClient;
-
- _converter = converter;
- }
- [ProducesDefaultResponseType]
- [HttpPost("fix-debate")]
- public async Task<IActionResult> FixElegant(JsonElement json)
- {
- string sqlE = $"select value c from c where c.pk='Debate' ";
- var resultE = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<Debate>(sqlE);
- if (resultE .list.IsNotEmpty()) {
- foreach (var item in resultE.list)
- {
- item.scope="school";
- }
- var group = resultE.list.Where(x => !string.IsNullOrWhiteSpace(x.school)).GroupBy(x => x.school).Select(x => new { key = x.Key, list = x.ToList() });
- foreach (var gp in group) {
- List<Task<ItemResponse<Debate>>> tasks = new List<Task<ItemResponse<Debate>>>();
- try
- {
- foreach (var item in gp.list)
- {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync(item);
- }
- }
- catch (Exception ex) {
- await _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
- }
- }
- }
- return Ok();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("fix-activity")]
- public async Task<IActionResult> FixActivity(JsonElement json) {
- var client = _azureCosmos.GetCosmosClient();
- string stusql = "SELECT * FROM c where c.id in('20221901','20221902','20221903','20221904','20221905','20221906','20221907','20221908','20221909','20221910','20221911','20221912','20221913','20221914','20221915','20221916','20221917','20221918','20221919','20221920','20221921','20221922','20221923','20221924','20221925','20221926','20221927','20221928','20221929','20221930','20221931','20221932','20221933','20221934','20221935','20221936','20221937','20221938','20221939','20221940','20221941','20221942','20221943','20221944','20221945','20221946','20221947','20221948','20221949','20221950','20222002','20222003','20222004','20222005','20222006','20222007','20222008','20222009','20222010','20222011','20222012','20222013','20222014','20222015','20222016','20222017','20222018','20222019','20222020','20222021','20222022','20222023','20222024','20222025','20222026','20222027','20222028','20222029','20222030','20222031','20222032','20222033','20222034','20222035','20222036','20222037','20222038','20222039','20222040','20222041','20222042','20222043','20222044','20222101','20222102','20222103','20222104','20222105','20222106','20222107','20222108','20222109','20222110','20222111','20222112','20222113','20222114','20222115','20222116','20222117','20222118','20222119','20222120','20222121','20222122','20222123','20222124','20222125','20222126','20222127','20222128','20222129','20222130','20222131','20222132','20222133','20222134','20222135','20222136','20222137','20222138','20222139','20222140','20222141','20222142','20222143','20222144','20222145','20222146','20222147','20222201','20222202','20222203','20222204','20222205','20222206','20222207','20222208','20222209','20222210','20222211','20222212','20222213','20222214','20222215','20222216','20222217','20222218','20222219','20222220','20222221','20222222','20222223','20222224','20222226','20222227','20222228','20222229','20222230','20222231','20222232','20222233','20222234','20222235','20222236','20222237','20222238','20222239','20222240','20222241','20222242','20222243','20222244','20222245','20222301','20222302','20222303','20222304','20222305','20222306','20222307','20222308','20222309','20222310','20222311','20222312','20222313','20222314','20222315','20222316','20222317','20222318','20222319','20222320','20222321','20222322','20222323','20222324','20222325','20222326','20222327','20222328','20222329','20222330','20222331','20222332','20222333','20222334','20222335','20222336','20222337','20222338','20222339','20222340','20222341','20222342','20222343','20222344','20222345','20222346','20222347','20222401','20222402','20222403','20222404','20222405','20222406','20222407','20222408','20222409','20222410','20222411','20222412','20222413','20222414','20222415','20222416','20222417','20222418','20222419','20222420','20222421','20222422','20222423','20222424','20222425','20222426','20222427','20222428','20222429','20222430','20222431','20222432','20222433','20222434','20222435','20222436','20222437','20222438','20222439','20222440','20222441','20222442','20222443','20222444','20222445','20222447','20222501','20222502','20222503','20222504','20222505','20222506','20222508','20222509','20222510','20222511','20222512','20222513','20222514','20222515','20222516','20222517','20222518','20222519','20222520','20222521','20222522','20222523','20222525','20222526','20222527','20222528','20222529','20222530','20222531','20222532','20222533','20222534','20222535','20222536','20222537','20222538','20222539','20222540','20222541','20222542','20222543','20222544','20222545','20222546','20222547','20222601','20222602','20222603','20222604','20222605','20222606','20222607','20222608','20222609','20222610','20222611','20222612','20222613','20222614','20222615','20222616','20222617','20222618','20222619','20222620','20222621','20222622','20222623','20222624','20222625','20222626','20222627','20222628','20222629','20222630','20222631','20222632','20222633','20222634','20222635','20222636','20222637','20222639','20222640','20222641','20222642','20222643','20222645','20222646','20222647','20222648','20222649','20222701','20222702','20222703','20222704','20222705','20222706','20222707','20222708','20222709','20222710','20222711','20222712','20222713','20222714','20222715','20222716','20222717','20222718','20222719','20222720','20222721','20222722','20222723','20222724','20222725','20222727','20222728','20222729','20222730','20222731','20222732','20222733','20222734','20222735','20222736','20222737','20222738','20222739','20222740','20222741','20222742','20222743','20222744','20222745','20222746','20222747','20222748','20222749','20222801','20222804','20222805','20222806','20222807','20222808','20222809','20222810','20222811','20222812','20222813','20222814','20222815','20222816','20222817','20222819','20222821','20222822','20222823','20222824','20222825','20222826','20222827','20222828','20222829','20222830','20222831','20222834','20222835','20222836','20222837','20222838','20222839','20222840','20222841','20222842','20222843','20222844','20222845','20222846','20222847','20222848','20211901','20211902','20211903','20211904','20211905','20211906','20211908','20211909','20211910','20211911','20211912','20211913','20211914','20211915','20211916','20211917','20211918','20211919','20211920','20211921','20211922','20211923','20211924','20211925','20211926','20211927','20211928','20211929','20211930','20211931','20211932','20211933','20211934','20211935','20211936','20211937','20211938','20211939','20211940','20211941','20211942','20211943','20211944','20211945','20212001','20212002','20212003','20212004','20212005','20212006','20212007','20212008','20212009','20212010','20212011','20212012','20212013','20212014','20212015','20212016','20212017','20212018','20212019','20212020','20212021','20212022','20212023','20212024','20212025','20212026','20212027','20212028','20212029','20212030','20212031','20212032','20212033','20212034','20212035','20212036','20212037','20212038','20212039','20212040','20212041','20212042','20212043','20212044','20212045','20212046','20212047','20212048','20212101','20212102','20212103','20212104','20212105','20212106','20212107','20212108','20212109','20212110','20212111','20212112','20212113','20212114','20212115','20212116','20212117','20212118','20212119','20212120','20212121','20212123','20212124','20212125','20212126','20212127','20212128','20212129','20212130','20212131','20212132','20212133','20212134','20212135','20212136','20212137','20212138','20212139','20212140','20212141','20212142','20212143','20212144','20212145','20212146','20212147','20212148','20212149','20212150','20212151','20212201','20212202','20212203','20212204','20212205','20212206','20212207','20212208','20212209','20212210','20212211','20212212','20212213','20212214','20212215','20212216','20212217','20212218','20212219','20212220','20212221','20212222','20212223','20212224','20212225','20212226','20212227','20212228','20212229','20212230','20212231','20212232','20212233','20212234','20212235','20212236','20212237','20212238','20212239','20212240','20212241','20212242','20212243','20212244','20212245','20212246','20212247','20212248','20212249','20212250','20212301','20212302','20212303','20212304','20212305','20212306','20212307','20212308','20212309','20212310','20212311','20212312','20212313','20212314','20212315','20212317','20212318','20212319','20212320','20212322','20212323','20212324','20212325','20212326','20212327','20212328','20212329','20212330','20212331','20212332','20212333','20212334','20212335','20212336','20212337','20212338','20212339','20212340','20212341','20212342','20212343','20212344','20212345','20212346','20212401','20212402','20212403','20212404','20212405','20212406','20212407','20212408','20212409','20212410','20212411','20212413','20212414','20212415','20212416','20212417','20212418','20212419','20212420','20212421','20212422','20212423','20212424','20212425','20212426','20212427','20212428','20212429','20212430','20212431','20212432','20212433','20212434','20212435','20212436','20212437','20212438','20212439','20212440','20212441','20212442','20212443','20212444','20212445','20212446','20212447','20212501','20212502','20212503','20212504','20212505','20212506','20212507','20212508','20212509','20212510','20212511','20212512','20212513','20212514','20212515','20212516','20212517','20212518','20212519','20212520','20212521','20212522','20212523','20212524','20212525','20212526','20212527','20212528','20212529','20212530','20212531','20212532','20212533','20212534','20212535','20212536','20212537','20212538','20212539','20212540','20212541','20212542','20212543','20212544','20212545','20212548','20212549','20212601','20212602','20212603','20212604','20212605','20212606','20212607','20212608','20212609','20212610','20212611','20212612','20212613','20212614','20212615','20212616','20212617','20212618','20212619','20212620','20212621','20212622','20212623','20212624','20212625','20212626','20212627','20212628','20212629','20212630','20212631','20212632','20212633','20212634','20212635','20212636','20212637','20212638','20212639','20212640','20212641','20212642','20212643','20212644','20212701','20212702','20212703','20212704','20212705','20212706','20212707','20212708','20212709','20212710','20212711','20212712','20212713','20212714','20212715','20212716','20212717','20212718','20212719','20212720','20212721','20212722','20212723','20212724','20212725','20212726','20212727','20212728','20212730','20212731','20212732','20212733','20212734','20212735','20212736','20212737','20212738','20212739','20212740','20212741','20212742','20212743','20212744','20212745','20212746','20212747','20212748','20212749','20212801','20212802','20212803','20212804','20212805','20212806','20212807','20212808','20212809','20212810','20212811','20212812','20212813','20212814','20212815','20212816','20212818','20212819','20212820','20212821','20212822','20212823','20212824','20212825','20212826','20212827','20212828','20212829','20212830','20212831','20212832','20212833','20212834','20212835','20212836','20212837','20212838','20212839','20212840','20212841','20212842','20212843','20212844','20212845','20212846','20212847','20212848','20212849','20212901','20212902','20212903','20212904','20212905','20212906','20212907','20212908','20212909','20212910','20212911','20212912','20212913','20212914','20212915','20212916','20212917','20212918','20212919','20212920','20212921','20212922','20212923','20212924','20212925','20212927','20212928','20212929','20212930','20212931','20212932','20212933','20212934','20212935','20212936','20212937','20212938','20212939','20212940','20212941','20212942','20212943','20212947','20212948','20213001','20213002','20213003','20213004','20213005','20213006','20213007','20213008','20213009','20213010','20213011','20213012','20213013','20213014','20213015','20213016','20213017','20213018','20213019','20213020','20213021','20213022','20213023','20213024','20213025','20213026','20213027','20213028','20213029','20213030','20213031','20213032','20213033','20213034','20213035','20213036','20213037','20213038','20213039','20213040','20213041','20213042','20213043','20213044','20213045','20213046','20213047','20213048','20213049','20213050','20213101','20213102','20213103','20213104','20213105','20213106','20213107','20213108','20213109','20213110','20213111','20213112','20213113','20213114','20213115','20213116','20213117','20213118','20213119','20213120','20213121','20213122','20213123','20213124','20213125','20213126','20213127','20213128','20213129','20213130','20213131','20213132','20213133','20213134','20213135','20213136','20213137','20213138','20213139','20213140','20213142','20213143','20213144','20213145','20213146','20213147','20213148','20213149','20213152','20213201','20213202','20213203','20213204','20213205','20213206','20213207','20213208','20213209','20213210','20213211','20213212','20213213','20213214','20213215','20213216','20213217','20213218','20213219','20213220','20213221','20213222','20213223','20213224','20213225','20213226','20213227','20213228','20213229','20213230','20213231','20213232','20213233','20213234','20213235','20213236','20213237','20213238','20213239','20213240','20213241','20213242','20213243','20213244','20213245','20213246','20213247','20213248','20201901','20201902','20201903','20201904','20201905','20201906','20201907','20201908','20201909','20201910','20201911','20201912','20201913','20201914','20201915','20201916','20201917','20201918','20201919','20201920','20201921','20201922','20201923','20201924','20201925','20201926','20201927','20201928','20201929','20201930','20201931','20201932','20201933','20201934','20201935','20201936','20201937','20201938','20201939','20201940','20201941','20201942','20201943','20201944','20201945','20201946','20201947','20201949','20201951','20202001','20202002','20202003','20202004','20202005','20202006','20202007','20202008','20202010','20202011','20202012','20202013','20202014','20202016','20202017','20202018','20202019','20202020','20202021','20202022','20202023','20202024','20202025','20202026','20202027','20202028','20202029','20202030','20202031','20202032','20202033','20202034','20202035','20202036','20202037','20202038','20202039','20202040','20202041','20202042','20202043','20202044','20202045','20202046','20202047','20202101','20202102','20202104','20202105','20202106','20202107','20202108','20202109','20202110','20202111','20202112','20202113','20202114','20202115','20202116','20202117','20202118','20202119','20202120','20202121','20202122','20202125','20202126','20202127','20202128','20202129','20202130','20202131','20202132','20202133','20202134','20202135','20202136','20202137','20202138','20202139','20202140','20202141','20202142','20202143','20202144','20202145','20202147','20202148','20202201','20202202','20202203','20202204','20202205','20202206','20202207','20202208','20202209','20202210','20202211','20202212','20202213','20202214','20202215','20202216','20202217','20202218','20202219','20202220','20202221','20202222','20202223','20202224','20202225','20202226','20202227','20202228','20202229','20202230','20202231','20202232','20202233','20202234','20202235','20202236','20202237','20202238','20202239','20202240','20202241','20202242','20202243','20202244','20202245','20202246','20202248','20202301','20202302','20202303','20202304','20202305','20202306','20202307','20202308','20202309','20202310','20202312','20202313','20202314','20202315','20202316','20202317','20202318','20202319','20202320','20202321','20202322','20202323','20202324','20202325','20202326','20202327','20202328','20202329','20202330','20202331','20202332','20202333','20202334','20202335','20202337','20202338','20202339','20202340','20202341','20202342','20202343','20202344','20202345','20202346','20202401','20202402','20202403','20202404','20202405','20202406','20202407','20202408','20202409','20202410','20202412','20202413','20202414','20202415','20202416','20202417','20202418','20202419','20202420','20202421','20202422','20202423','20202424','20202425','20202426','20202427','20202428','20202429','20202430','20202431','20202432','20202433','20202434','20202435','20202436','20202437','20202438','20202439','20202440','20202441','20202442','20202443','20202444','20202445','20202446','20202447','20202448','20202449','20202450','20202501','20202502','20202503','20202504','20202506','20202507','20202508','20202509','20202510','20202511','20202512','20202513','20202514','20202515','20202516','20202517','20202518','20202519','20202520','20202521','20202522','20202523','20202524','20202525','20202526','20202527','20202528','20202529','20202530','20202531','20202532','20202533','20202534','20202535','20202536','20202537','20202538','20202539','20202540','20202541','20202542','20202543','20202544','20202545','20202546','20202601','20202602','20202603','20202604','20202605','20202606','20202607','20202608','20202609','20202610','20202611','20202612','20202613','20202614','20202615','20202616','20202617','20202618','20202619','20202620','20202621','20202622','20202623','20202624','20202625','20202626','20202627','20202628','20202629','20202630','20202631','20202633','20202634','20202635','20202636','20202637','20202638','20202639','20202640','20202641','20202642','20202643','20202644','20202645','20202701','20202702','20202703','20202704','20202705','20202706','20202707','20202708','20202709','20202710','20202711','20202712','20202713','20202714','20202715','20202716','20202717','20202718','20202719','20202720','20202721','20202722','20202723','20202724','20202725','20202726','20202727','20202728','20202729','20202730','20202731','20202732','20202733','20202734','20202735','20202736','20202737','20202738','20202739','20202740','20202741','20202742','20202743','20202747','20202801','20202802','20202803','20202804','20202805','20202806','20202807','20202808','20202809','20202810','20202811','20202812','20202813','20202814','20202815','20202816','20202817','20202818','20202819','20202820','20202821','20202822','20202823','20202824','20202825','20202826','20202827','20202828','20202829','20202830','20202831','20202832','20202833','20202834','20202835','20202836','20202837','20202838','20202839','20202840','20202841','20202842','20202843','20202844','20202845','20202846','20202847','20202901','20202902','20202903','20202904','20202905','20202906','20202907','20202908','20202909','20202910','20202911','20202912','20202913','20202914','20202915','20202916','20202917','20202918','20202919','20202920','20202921','20202922','20202923','20202924','20202925','20202926','20202927','20202928','20202929','20202930','20202931','20202932','20202933','20202934','20202935','20202936','20202937','20202938','20202939','20202940','20202941','20202942','20202943','20202944','20203001','20203002','20203003','20203004','20203005','20203006','20203007','20203008','20203009','20203010','20203011','20203012','20203013','20203014','20203015','20203016','20203017','20203018','20203019','20203020','20203021','20203022','20203023','20203024','20203025','20203026','20203027','20203028','20203029','20203030','20203031','20203032','20203033','20203034','20203035','20203036','20203037','20203039','20203040','20203041','20203042','20203043','20203044','20203046','20203101','20203102','20203103','20203104','20203105','20203106','20203107','20203108','20203109','20203110','20203111','20203112','20203113','20203114','20203115','20203116','20203117','20203118','20203119','20203120','20203121','20203122','20203123','20203124','20203125','20203126','20203127','20203128','20203129','20203130','20203131','20203132','20203133','20203134','20203135','20203136','20203137','20203138','20203139','20203140','20203141','20203142','20203143','20203144','20203145','20203146','20203201','20203202','20203203','20203204','20203205','20203207','20203208','20203209','20203210','20203211','20203212','20203213','20203214','20203215','20203216','20203217','20203218','20203220','20203221','20203222','20203223','20203224','20203225','20203226','20203227','20203228','20203229','20203230','20203231','20203232','20203233','20203234','20203235','20203236','20203237','20203238','20203239','20203240','20203241','20203242','20203243','20203244','20203245','20203246','20203247') and c.code='Base-fzpdzz' ";
- string clasql = "SELECT * FROM c where c.no in('20221901','20221902','20221903','20221904','20221905','20221906','20221907','20221908','20221909','20221910','20221911','20221912','20221913','20221914','20221915','20221916','20221917','20221918','20221919','20221920','20221921','20221922','20221923','20221924','20221925','20221926','20221927','20221928','20221929','20221930','20221931','20221932','20221933','20221934','20221935','20221936','20221937','20221938','20221939','20221940','20221941','20221942','20221943','20221944','20221945','20221946','20221947','20221948','20221949','20221950','20222002','20222003','20222004','20222005','20222006','20222007','20222008','20222009','20222010','20222011','20222012','20222013','20222014','20222015','20222016','20222017','20222018','20222019','20222020','20222021','20222022','20222023','20222024','20222025','20222026','20222027','20222028','20222029','20222030','20222031','20222032','20222033','20222034','20222035','20222036','20222037','20222038','20222039','20222040','20222041','20222042','20222043','20222044','20222101','20222102','20222103','20222104','20222105','20222106','20222107','20222108','20222109','20222110','20222111','20222112','20222113','20222114','20222115','20222116','20222117','20222118','20222119','20222120','20222121','20222122','20222123','20222124','20222125','20222126','20222127','20222128','20222129','20222130','20222131','20222132','20222133','20222134','20222135','20222136','20222137','20222138','20222139','20222140','20222141','20222142','20222143','20222144','20222145','20222146','20222147','20222201','20222202','20222203','20222204','20222205','20222206','20222207','20222208','20222209','20222210','20222211','20222212','20222213','20222214','20222215','20222216','20222217','20222218','20222219','20222220','20222221','20222222','20222223','20222224','20222226','20222227','20222228','20222229','20222230','20222231','20222232','20222233','20222234','20222235','20222236','20222237','20222238','20222239','20222240','20222241','20222242','20222243','20222244','20222245','20222301','20222302','20222303','20222304','20222305','20222306','20222307','20222308','20222309','20222310','20222311','20222312','20222313','20222314','20222315','20222316','20222317','20222318','20222319','20222320','20222321','20222322','20222323','20222324','20222325','20222326','20222327','20222328','20222329','20222330','20222331','20222332','20222333','20222334','20222335','20222336','20222337','20222338','20222339','20222340','20222341','20222342','20222343','20222344','20222345','20222346','20222347','20222401','20222402','20222403','20222404','20222405','20222406','20222407','20222408','20222409','20222410','20222411','20222412','20222413','20222414','20222415','20222416','20222417','20222418','20222419','20222420','20222421','20222422','20222423','20222424','20222425','20222426','20222427','20222428','20222429','20222430','20222431','20222432','20222433','20222434','20222435','20222436','20222437','20222438','20222439','20222440','20222441','20222442','20222443','20222444','20222445','20222447','20222501','20222502','20222503','20222504','20222505','20222506','20222508','20222509','20222510','20222511','20222512','20222513','20222514','20222515','20222516','20222517','20222518','20222519','20222520','20222521','20222522','20222523','20222525','20222526','20222527','20222528','20222529','20222530','20222531','20222532','20222533','20222534','20222535','20222536','20222537','20222538','20222539','20222540','20222541','20222542','20222543','20222544','20222545','20222546','20222547','20222601','20222602','20222603','20222604','20222605','20222606','20222607','20222608','20222609','20222610','20222611','20222612','20222613','20222614','20222615','20222616','20222617','20222618','20222619','20222620','20222621','20222622','20222623','20222624','20222625','20222626','20222627','20222628','20222629','20222630','20222631','20222632','20222633','20222634','20222635','20222636','20222637','20222639','20222640','20222641','20222642','20222643','20222645','20222646','20222647','20222648','20222649','20222701','20222702','20222703','20222704','20222705','20222706','20222707','20222708','20222709','20222710','20222711','20222712','20222713','20222714','20222715','20222716','20222717','20222718','20222719','20222720','20222721','20222722','20222723','20222724','20222725','20222727','20222728','20222729','20222730','20222731','20222732','20222733','20222734','20222735','20222736','20222737','20222738','20222739','20222740','20222741','20222742','20222743','20222744','20222745','20222746','20222747','20222748','20222749','20222801','20222804','20222805','20222806','20222807','20222808','20222809','20222810','20222811','20222812','20222813','20222814','20222815','20222816','20222817','20222819','20222821','20222822','20222823','20222824','20222825','20222826','20222827','20222828','20222829','20222830','20222831','20222834','20222835','20222836','20222837','20222838','20222839','20222840','20222841','20222842','20222843','20222844','20222845','20222846','20222847','20222848','20211901','20211902','20211903','20211904','20211905','20211906','20211908','20211909','20211910','20211911','20211912','20211913','20211914','20211915','20211916','20211917','20211918','20211919','20211920','20211921','20211922','20211923','20211924','20211925','20211926','20211927','20211928','20211929','20211930','20211931','20211932','20211933','20211934','20211935','20211936','20211937','20211938','20211939','20211940','20211941','20211942','20211943','20211944','20211945','20212001','20212002','20212003','20212004','20212005','20212006','20212007','20212008','20212009','20212010','20212011','20212012','20212013','20212014','20212015','20212016','20212017','20212018','20212019','20212020','20212021','20212022','20212023','20212024','20212025','20212026','20212027','20212028','20212029','20212030','20212031','20212032','20212033','20212034','20212035','20212036','20212037','20212038','20212039','20212040','20212041','20212042','20212043','20212044','20212045','20212046','20212047','20212048','20212101','20212102','20212103','20212104','20212105','20212106','20212107','20212108','20212109','20212110','20212111','20212112','20212113','20212114','20212115','20212116','20212117','20212118','20212119','20212120','20212121','20212123','20212124','20212125','20212126','20212127','20212128','20212129','20212130','20212131','20212132','20212133','20212134','20212135','20212136','20212137','20212138','20212139','20212140','20212141','20212142','20212143','20212144','20212145','20212146','20212147','20212148','20212149','20212150','20212151','20212201','20212202','20212203','20212204','20212205','20212206','20212207','20212208','20212209','20212210','20212211','20212212','20212213','20212214','20212215','20212216','20212217','20212218','20212219','20212220','20212221','20212222','20212223','20212224','20212225','20212226','20212227','20212228','20212229','20212230','20212231','20212232','20212233','20212234','20212235','20212236','20212237','20212238','20212239','20212240','20212241','20212242','20212243','20212244','20212245','20212246','20212247','20212248','20212249','20212250','20212301','20212302','20212303','20212304','20212305','20212306','20212307','20212308','20212309','20212310','20212311','20212312','20212313','20212314','20212315','20212317','20212318','20212319','20212320','20212322','20212323','20212324','20212325','20212326','20212327','20212328','20212329','20212330','20212331','20212332','20212333','20212334','20212335','20212336','20212337','20212338','20212339','20212340','20212341','20212342','20212343','20212344','20212345','20212346','20212401','20212402','20212403','20212404','20212405','20212406','20212407','20212408','20212409','20212410','20212411','20212413','20212414','20212415','20212416','20212417','20212418','20212419','20212420','20212421','20212422','20212423','20212424','20212425','20212426','20212427','20212428','20212429','20212430','20212431','20212432','20212433','20212434','20212435','20212436','20212437','20212438','20212439','20212440','20212441','20212442','20212443','20212444','20212445','20212446','20212447','20212501','20212502','20212503','20212504','20212505','20212506','20212507','20212508','20212509','20212510','20212511','20212512','20212513','20212514','20212515','20212516','20212517','20212518','20212519','20212520','20212521','20212522','20212523','20212524','20212525','20212526','20212527','20212528','20212529','20212530','20212531','20212532','20212533','20212534','20212535','20212536','20212537','20212538','20212539','20212540','20212541','20212542','20212543','20212544','20212545','20212548','20212549','20212601','20212602','20212603','20212604','20212605','20212606','20212607','20212608','20212609','20212610','20212611','20212612','20212613','20212614','20212615','20212616','20212617','20212618','20212619','20212620','20212621','20212622','20212623','20212624','20212625','20212626','20212627','20212628','20212629','20212630','20212631','20212632','20212633','20212634','20212635','20212636','20212637','20212638','20212639','20212640','20212641','20212642','20212643','20212644','20212701','20212702','20212703','20212704','20212705','20212706','20212707','20212708','20212709','20212710','20212711','20212712','20212713','20212714','20212715','20212716','20212717','20212718','20212719','20212720','20212721','20212722','20212723','20212724','20212725','20212726','20212727','20212728','20212730','20212731','20212732','20212733','20212734','20212735','20212736','20212737','20212738','20212739','20212740','20212741','20212742','20212743','20212744','20212745','20212746','20212747','20212748','20212749','20212801','20212802','20212803','20212804','20212805','20212806','20212807','20212808','20212809','20212810','20212811','20212812','20212813','20212814','20212815','20212816','20212818','20212819','20212820','20212821','20212822','20212823','20212824','20212825','20212826','20212827','20212828','20212829','20212830','20212831','20212832','20212833','20212834','20212835','20212836','20212837','20212838','20212839','20212840','20212841','20212842','20212843','20212844','20212845','20212846','20212847','20212848','20212849','20212901','20212902','20212903','20212904','20212905','20212906','20212907','20212908','20212909','20212910','20212911','20212912','20212913','20212914','20212915','20212916','20212917','20212918','20212919','20212920','20212921','20212922','20212923','20212924','20212925','20212927','20212928','20212929','20212930','20212931','20212932','20212933','20212934','20212935','20212936','20212937','20212938','20212939','20212940','20212941','20212942','20212943','20212947','20212948','20213001','20213002','20213003','20213004','20213005','20213006','20213007','20213008','20213009','20213010','20213011','20213012','20213013','20213014','20213015','20213016','20213017','20213018','20213019','20213020','20213021','20213022','20213023','20213024','20213025','20213026','20213027','20213028','20213029','20213030','20213031','20213032','20213033','20213034','20213035','20213036','20213037','20213038','20213039','20213040','20213041','20213042','20213043','20213044','20213045','20213046','20213047','20213048','20213049','20213050','20213101','20213102','20213103','20213104','20213105','20213106','20213107','20213108','20213109','20213110','20213111','20213112','20213113','20213114','20213115','20213116','20213117','20213118','20213119','20213120','20213121','20213122','20213123','20213124','20213125','20213126','20213127','20213128','20213129','20213130','20213131','20213132','20213133','20213134','20213135','20213136','20213137','20213138','20213139','20213140','20213142','20213143','20213144','20213145','20213146','20213147','20213148','20213149','20213152','20213201','20213202','20213203','20213204','20213205','20213206','20213207','20213208','20213209','20213210','20213211','20213212','20213213','20213214','20213215','20213216','20213217','20213218','20213219','20213220','20213221','20213222','20213223','20213224','20213225','20213226','20213227','20213228','20213229','20213230','20213231','20213232','20213233','20213234','20213235','20213236','20213237','20213238','20213239','20213240','20213241','20213242','20213243','20213244','20213245','20213246','20213247','20213248','20201901','20201902','20201903','20201904','20201905','20201906','20201907','20201908','20201909','20201910','20201911','20201912','20201913','20201914','20201915','20201916','20201917','20201918','20201919','20201920','20201921','20201922','20201923','20201924','20201925','20201926','20201927','20201928','20201929','20201930','20201931','20201932','20201933','20201934','20201935','20201936','20201937','20201938','20201939','20201940','20201941','20201942','20201943','20201944','20201945','20201946','20201947','20201949','20201951','20202001','20202002','20202003','20202004','20202005','20202006','20202007','20202008','20202010','20202011','20202012','20202013','20202014','20202016','20202017','20202018','20202019','20202020','20202021','20202022','20202023','20202024','20202025','20202026','20202027','20202028','20202029','20202030','20202031','20202032','20202033','20202034','20202035','20202036','20202037','20202038','20202039','20202040','20202041','20202042','20202043','20202044','20202045','20202046','20202047','20202101','20202102','20202104','20202105','20202106','20202107','20202108','20202109','20202110','20202111','20202112','20202113','20202114','20202115','20202116','20202117','20202118','20202119','20202120','20202121','20202122','20202125','20202126','20202127','20202128','20202129','20202130','20202131','20202132','20202133','20202134','20202135','20202136','20202137','20202138','20202139','20202140','20202141','20202142','20202143','20202144','20202145','20202147','20202148','20202201','20202202','20202203','20202204','20202205','20202206','20202207','20202208','20202209','20202210','20202211','20202212','20202213','20202214','20202215','20202216','20202217','20202218','20202219','20202220','20202221','20202222','20202223','20202224','20202225','20202226','20202227','20202228','20202229','20202230','20202231','20202232','20202233','20202234','20202235','20202236','20202237','20202238','20202239','20202240','20202241','20202242','20202243','20202244','20202245','20202246','20202248','20202301','20202302','20202303','20202304','20202305','20202306','20202307','20202308','20202309','20202310','20202312','20202313','20202314','20202315','20202316','20202317','20202318','20202319','20202320','20202321','20202322','20202323','20202324','20202325','20202326','20202327','20202328','20202329','20202330','20202331','20202332','20202333','20202334','20202335','20202337','20202338','20202339','20202340','20202341','20202342','20202343','20202344','20202345','20202346','20202401','20202402','20202403','20202404','20202405','20202406','20202407','20202408','20202409','20202410','20202412','20202413','20202414','20202415','20202416','20202417','20202418','20202419','20202420','20202421','20202422','20202423','20202424','20202425','20202426','20202427','20202428','20202429','20202430','20202431','20202432','20202433','20202434','20202435','20202436','20202437','20202438','20202439','20202440','20202441','20202442','20202443','20202444','20202445','20202446','20202447','20202448','20202449','20202450','20202501','20202502','20202503','20202504','20202506','20202507','20202508','20202509','20202510','20202511','20202512','20202513','20202514','20202515','20202516','20202517','20202518','20202519','20202520','20202521','20202522','20202523','20202524','20202525','20202526','20202527','20202528','20202529','20202530','20202531','20202532','20202533','20202534','20202535','20202536','20202537','20202538','20202539','20202540','20202541','20202542','20202543','20202544','20202545','20202546','20202601','20202602','20202603','20202604','20202605','20202606','20202607','20202608','20202609','20202610','20202611','20202612','20202613','20202614','20202615','20202616','20202617','20202618','20202619','20202620','20202621','20202622','20202623','20202624','20202625','20202626','20202627','20202628','20202629','20202630','20202631','20202633','20202634','20202635','20202636','20202637','20202638','20202639','20202640','20202641','20202642','20202643','20202644','20202645','20202701','20202702','20202703','20202704','20202705','20202706','20202707','20202708','20202709','20202710','20202711','20202712','20202713','20202714','20202715','20202716','20202717','20202718','20202719','20202720','20202721','20202722','20202723','20202724','20202725','20202726','20202727','20202728','20202729','20202730','20202731','20202732','20202733','20202734','20202735','20202736','20202737','20202738','20202739','20202740','20202741','20202742','20202743','20202747','20202801','20202802','20202803','20202804','20202805','20202806','20202807','20202808','20202809','20202810','20202811','20202812','20202813','20202814','20202815','20202816','20202817','20202818','20202819','20202820','20202821','20202822','20202823','20202824','20202825','20202826','20202827','20202828','20202829','20202830','20202831','20202832','20202833','20202834','20202835','20202836','20202837','20202838','20202839','20202840','20202841','20202842','20202843','20202844','20202845','20202846','20202847','20202901','20202902','20202903','20202904','20202905','20202906','20202907','20202908','20202909','20202910','20202911','20202912','20202913','20202914','20202915','20202916','20202917','20202918','20202919','20202920','20202921','20202922','20202923','20202924','20202925','20202926','20202927','20202928','20202929','20202930','20202931','20202932','20202933','20202934','20202935','20202936','20202937','20202938','20202939','20202940','20202941','20202942','20202943','20202944','20203001','20203002','20203003','20203004','20203005','20203006','20203007','20203008','20203009','20203010','20203011','20203012','20203013','20203014','20203015','20203016','20203017','20203018','20203019','20203020','20203021','20203022','20203023','20203024','20203025','20203026','20203027','20203028','20203029','20203030','20203031','20203032','20203033','20203034','20203035','20203036','20203037','20203039','20203040','20203041','20203042','20203043','20203044','20203046','20203101','20203102','20203103','20203104','20203105','20203106','20203107','20203108','20203109','20203110','20203111','20203112','20203113','20203114','20203115','20203116','20203117','20203118','20203119','20203120','20203121','20203122','20203123','20203124','20203125','20203126','20203127','20203128','20203129','20203130','20203131','20203132','20203133','20203134','20203135','20203136','20203137','20203138','20203139','20203140','20203141','20203142','20203143','20203144','20203145','20203146','20203201','20203202','20203203','20203204','20203205','20203207','20203208','20203209','20203210','20203211','20203212','20203213','20203214','20203215','20203216','20203217','20203218','20203220','20203221','20203222','20203223','20203224','20203225','20203226','20203227','20203228','20203229','20203230','20203231','20203232','20203233','20203234','20203235','20203236','20203237','20203238','20203239','20203240','20203241','20203242','20203243','20203244','20203245','20203246','20203247') and c.code='Class-fzpdzz' ";
- List<Student> students = new List<Student>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<Student>(queryText: stusql,requestOptions: new QueryRequestOptions { PartitionKey= new PartitionKey("Base-fzpdzz") }))
- {
- students.Add(item);
- }
- await client.GetContainer(Constant.TEAMModelOS, Constant.Student).DeleteItemsStreamAsync(students.Select(z => z.id).ToList(), "Base-fzpdzz");
- List <Class> classes = new List<Class>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<Class>(queryText: clasql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Class-fzpdzz") }))
- {
- classes.Add(item);
- }
- await client.GetContainer(Constant.TEAMModelOS, Constant.School).DeleteItemsStreamAsync(classes.Select(z => z.id).ToList(), "Class-fzpdzz");
- return Ok();
- }
- [ProducesDefaultResponseType]
- [HttpPost("fix-error-activity")]
- public async Task<IActionResult> FixErrorActivity(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string stusql = "select value(c) from c where c.pk = 'ErrorItems' and c.its = []";
- List<ErrorItems> students = new List<ErrorItems>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<ErrorItems>(queryText: stusql))
- {
- students.Add(item);
- }
- List<Task<ItemResponse<ErrorItems>>> tasks = new List<Task<ItemResponse<ErrorItems>>>();
- foreach (ErrorItems error in students) {
- tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).DeleteItemAsync<ErrorItems>(error.id, new PartitionKey(error.code)));
- }
- await tasks.TaskPage(10);
- return Ok();
- }
- [ProducesDefaultResponseType]
- [HttpPost("find-school-activity")]
- public async Task<IActionResult> findSchoolActivity(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string stusql = "select * from c where c.pk = 'Art' and c.pId in ('2f74d38e-80c1-4c55-9dd0-de0d8f6fdf6d','306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2')";
- List<ArtEvaluation> art = new List<ArtEvaluation>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: stusql))
- {
- art.Add(item);
- }
- var artId = art.Select(c => c.id).ToList();
- string artResultSql = $"select * from c where c.pk = 'ArtResult' and c.artId in ({string.Join(",", artId.Select(o => $"'{o}'"))})";
- List<StudentArtResult> artResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<StudentArtResult>(queryText: artResultSql))
- {
- artResults.Add(item);
- }
- string sql = $"select c.id, c.name from c";
- List<(string id,string name)> sc = new();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
- .GetItemQueryStreamIterator(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- using var sc_json = await JsonDocument.ParseAsync(item.ContentStream);
- if (sc_json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- var accounts = sc_json.RootElement.GetProperty("Documents").EnumerateArray();
- while (accounts.MoveNext())
- {
- JsonElement account = accounts.Current;
- sc.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
- }
- }
- }
- int musicCount = 0;
- int examCount = 0;
- //int wCount = 0;
- //List<Dictionary<string, int>> schoolCount = new();
- Dictionary<string, int> optCount = new Dictionary<string, int>();
- Dictionary<string, int> ansCount = new Dictionary<string, int>();
- foreach (StudentArtResult result in artResults) {
- var score = result.results.Where(c => c.quotaId.Equals("quota_21")).Select(z => z.score).ToList();
- bool flag = score.Exists(c => c == -1);
- if (!flag) {
- if (ansCount.ContainsKey(result.school))
- {
- ansCount[result.school] = ansCount[result.school] + 1;
- }
- else
- {
- ansCount[result.school] = 1;
- }
- examCount++;
- }
- foreach (ArtQuotaResult artQuotas in result.results) {
- if (artQuotas.quotaId.Equals("quota_22") && artQuotas.score > 0 && artQuotas.subjectId.Equals("subject_music")) {
- if (optCount.ContainsKey(result.school))
- {
- optCount[result.school] = optCount[result.school] + 1;
- }
- else
- {
- optCount[result.school] = 1;
- }
- musicCount++;
- }
- }
- }
- var stuList = artResults.GroupBy(c => c.school).Select(z => new { z.Key, z.ToList().Count }).Select(p => new {
- code = p.Key,
- name = sc.Where(x => x.id.Equals(p.Key)).FirstOrDefault().name,
- total = p.Count,
- realMusicCount = optCount.TryGetValue(p.Key,out int real) ? real : 0,
- realAnsCount = ansCount.TryGetValue(p.Key, out int ans) ? ans : 0,
- });
- /*var examId = art.SelectMany(c => c.settings).Where(z => z.id.Equals("quota_21")).SelectMany(a => a.task).Where(p => p.type == 1 && !string.IsNullOrEmpty(p.acId)).Select(o => o.acId).ToList();
- string examSQL = $"select * from c where c.pk = 'ExamClassResult' and c.examId in ({string.Join(",", examId.Select(o => $"'{o}'"))})";
- List<ExamClassResult> classResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ExamClassResult>(queryText: examSQL))
- {
- classResults.Add(item);
- }
- HashSet<string> scCode = new();
- foreach (ExamClassResult result in classResults) {
- bool flag = false;
- if (scCode.Contains(result.school)) {
- continue;
- }
- foreach (var item in result.studentScores)
- {
- foreach (var score in item) {
- if (score > 0) {
- flag = true;
- break;
- }
- }
- if (flag) {
- break;
- }
- }
- if (flag) {
- scCode.Add(result.school);
- }
- }*/
- /*var ans = classResults.SelectMany(c => c.ans).ToList();
- foreach (var c in ans) {
- foreach (var b in c) {
- if (b.Count > 0) {
- break;
- }
- }
- }*/
- return Ok(new { stuList, artResults.Count, musicCount , examCount });
- }
- [ProducesDefaultResponseType]
- [HttpPost("find-student-activity")]
- public async Task<IActionResult> findStudentActivity(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string stusql = "select * from c where c.pk = 'Art' and c.pId in ('2f74d38e-80c1-4c55-9dd0-de0d8f6fdf6d','306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2')";
- List<ArtEvaluation> art = new List<ArtEvaluation>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: stusql))
- {
- art.Add(item);
- }
- var artId = art.Select(c => c.id).ToList();
- string artResultSql = $"select * from c where c.pk = 'ArtResult' and c.artId in ({string.Join(",", artId.Select(o => $"'{o}'"))})";
- List<StudentArtResult> artResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<StudentArtResult>(queryText: artResultSql))
- {
- artResults.Add(item);
- }
- string sql = $"select c.id, c.name from c";
- List<(string id, string name)> sc = new();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
- .GetItemQueryStreamIterator(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- using var sc_json = await JsonDocument.ParseAsync(item.ContentStream);
- if (sc_json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- var accounts = sc_json.RootElement.GetProperty("Documents").EnumerateArray();
- while (accounts.MoveNext())
- {
- JsonElement account = accounts.Current;
- sc.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
- }
- }
- }
- //Dictionary<string, int> optCount = new Dictionary<string, int>();
- //Dictionary<string, int> ansCount = new Dictionary<string, int>();
- /* List<(string stuId, List<(string type, double score)> stuType)> stus = new();
- foreach (StudentArtResult result in artResults)
- {
- List<(string type, double score)> stuTtpe = new();
- foreach (ArtQuotaResult artQuotas in result.results)
- {
- if (artQuotas.quotaId.Equals("quota_21")) {
- stuTtpe.Add((artQuotas.subjectId, artQuotas.score > 0 ? 1 : 0));
- }
- if (artQuotas.quotaId.Equals("quota_22") && artQuotas.subjectId.Equals("subject_music")) {
- stuTtpe.Add(("zy", artQuotas.score > 0 ? 1 : 0));
- }
- }
- stus.Add((result.studentId, stuTtpe));
- }*/
- var classList = artResults.SelectMany(c => c.classIds).ToList().Distinct();
- string classSql = $"select c.id, c.name from c where c.pk = 'Class' and c.id in ({string.Join(",", classList.Select(o => $"'{o}'"))})";
- List<(string id, string name)> classInfos = new();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
- .GetItemQueryStreamIterator(queryText: classSql))
- {
- using var sc_json = await JsonDocument.ParseAsync(item.ContentStream);
- if (sc_json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- var accounts = sc_json.RootElement.GetProperty("Documents").EnumerateArray();
- while (accounts.MoveNext())
- {
- JsonElement account = accounts.Current;
- classInfos.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
- }
- }
- }
- var stuList = artResults.Select(p => new {
- id = p.studentId,
- name = p.studentName,
- school = sc.Where(x => x.id.Equals(p.school)).FirstOrDefault().name,
- code = p.school,
- classId = classInfos.Where(x => x.id.Equals(p.classIds[0])).FirstOrDefault().name
- /*info = p.results.Select(c => new
- {
- c.score,
- c.quotaId,
- c.quotaName,
- c.subjectId
- })*/
- });
- return Ok(new { stuList });
- }
- [HttpPost("read-excel-art")]
- //[Authorize(Roles = "IES")]
- //[AuthToken(Roles = "teacher,admin,business")]
- [RequestSizeLimit(102_400_000_00)] //最大10000m左右
- public async Task<IActionResult> ReadExcel([FromForm] IFormFile file)
- {
- ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
- var client = _azureCosmos.GetCosmosClient();
- //string stusql = "select * from c where c.pk = 'Art' and c.pId in ('2f74d38e-80c1-4c55-9dd0-de0d8f6fdf6d','306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2')";
- string stusql = "select * from c where c.pk = 'Art' and c.pId = '306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2'";
- List<ArtEvaluation> art = new List<ArtEvaluation>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: stusql))
- {
- art.Add(item);
- }
- var artId = art.Select(c => c.id).ToList();
- string artResultSql = $"select * from c where c.pk = 'ArtResult' and c.artId in ({string.Join(",", artId.Select(o => $"'{o}'"))})";
- List<StudentArtResult> artResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<StudentArtResult>(queryText: artResultSql))
- {
- artResults.Add(item);
- }
- List<(string code,string sId)> students = new();
- using ExcelPackage package = new(file.OpenReadStream());
- ExcelWorksheets sheet = package.Workbook.Worksheets;
- List<string> baseTitle = new List<string>();
- //科目标题的栏位序列
- int subjectTitelIndex = -1;
- //读取Exam_
- var art_sheet = sheet.Where(z => z.Name.Equals("art_cz")).FirstOrDefault();
- List<(string code, string stuId, double score)> stus = new();
- if (art_sheet != null)
- {
- var rows = art_sheet.Dimension.Rows;
- var columns = art_sheet.Dimension.Columns;
- for (int r = 2; r <= rows; r++)
- {
- var stuId = art_sheet.GetValue(r, 5).ToString();
- var code = art_sheet.GetValue(r, 2).ToString();
- var score = art_sheet.GetValue(r, 7);
- stus.Add((code, stuId, (double)score));
- }
- }
- await foreach (var (school, id) in stuTask(client, artResults, stus))
- {
- students.Add((school, id));
- }
- //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(examImport, new Azure.Cosmos.PartitionKey(examImport.code));
- return Ok(new { code = 200, students });
- }
- [HttpPost("fix-exam-paper")]
- //[Authorize(Roles = "IES")]
- //[AuthToken(Roles = "teacher,admin,business")]
- [RequestSizeLimit(102_400_000_00)] //最大10000m左右
- public async Task<IActionResult> fixExamPaper(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string stusql = "select * from c where c.pk = 'Art' and c.pId in ('2f74d38e-80c1-4c55-9dd0-de0d8f6fdf6d','306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2')";
- //string stusql = "select * from c where c.pk = 'Art' and c.pId = '306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2'";
- List<ArtEvaluation> art = new List<ArtEvaluation>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: stusql))
- {
- art.Add(item);
- }
- var examId = art.SelectMany(c => c.settings).Where(z => z.id.Equals("quota_21")).SelectMany(a => a.task).Where(p => p.type == 1 && !string.IsNullOrEmpty(p.acId)).Select(o => o.acId).ToList();
- string examSQL = $"select * from c where c.pk = 'ExamClassResult' and c.examId in ({string.Join(",", examId.Select(o => $"'{o}'"))})";
- List<ExamClassResult> classResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ExamClassResult>(queryText: examSQL))
- {
- classResults.Add(item);
- }
- string stuSql = $"select * from c where c.pk = 'Activity' and c.id in ({string.Join(",", examId.Select(o => $"'{o}'"))})";
- List<StuActivity> stus = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<StuActivity>(queryText: stuSql))
- {
- stus.Add(item);
- }
- List<(string code, string sId)> students = new();
-
- await foreach (var (school, id) in stuTask(client, stus, classResults))
- {
- students.Add((school, id));
- }
- //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(examImport, new Azure.Cosmos.PartitionKey(examImport.code));
- return Ok(new { code = 200, students });
- }
- private async IAsyncEnumerable<(string school,string id)> stuTask(CosmosClient client,List<StudentArtResult> artResults, List<(string code, string stuId, double score)> stus) {
-
- foreach (StudentArtResult result in artResults)
- {
- string value = "";
- string code = "";
- try {
- bool flag = false;
- foreach (ArtQuotaResult artQuotas in result.results)
- {
- if (artQuotas.quotaId.Equals("quota_22") && artQuotas.subjectId.Equals("subject_painting"))
- {
- if (artQuotas.score < 0)
- {
- artQuotas.score = stus.Where(c => c.code.Equals(result.school) && c.stuId.Equals(result.studentId)).FirstOrDefault().score;
- flag = true;
- break;
- }
- }
- }
- if (flag) {
- await client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(result, result.id, new PartitionKey(result.code));
- }
- } catch (Exception e) {
- code = result.school;
- value = result.studentId;
- }
- yield return (code, value);
- }
- }
- private async IAsyncEnumerable<(string school, string id)> stuTask(CosmosClient client, List<StuActivity> stus, List<ExamClassResult> classResults)
- {
- foreach (ExamClassResult classResult in classResults)
- {
- string value = "";
- string code = "";
- try {
- //int n = 0;
- var activity = stus.Where(c => c.id.Equals(classResult.examId)).ToList();
- //List<(string studentId, string blob)> stuBlob = new();
- foreach (StuActivity stu in activity) {
- List<string> tas = stu.code.Split('-').ToList();
- JsonElement dict = stu.paper;
- dict[0].TryGetProperty("blob", out JsonElement element);
- string blob = element.ToString();
- int index = classResult.studentIds.IndexOf(tas[2]);
- if (index != -1)
- {
- classResult.paper[index] = blob;
- }
- }
- await client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(classResult, classResult.id, new PartitionKey(classResult.code));
- } catch (Exception e) {
- value = classResult.examId;
- code = classResult.school;
- }
- yield return (code, value);
- }
- }
- [ProducesDefaultResponseType]
- [HttpPost("find-xg-activity")]
- public async Task<IActionResult> findXgActivity(JsonElement element)
- {
- var client = _azureCosmos.GetCosmosClient();
- string musicSql = $"select c.id from c join A0 in c.results where A0.quotaId = 'quota_21' \r\n" +
- $"and c.school = 'qyszgh' \r\n" +
- $"and A0.subjectId = 'subject_music' \r\n" +
- $"and c.artId = '92fb6d6e-4b6f-403a-b4ac-71095d58d43b'\r\n" +
- $"and A0.score > 0";
- List<string> musicResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator(queryText: musicSql))
- {
- using var sc_json = await JsonDocument.ParseAsync(item.ContentStream);
- if (sc_json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- var accounts = sc_json.RootElement.GetProperty("Documents").EnumerateArray();
- while (accounts.MoveNext())
- {
- JsonElement account = accounts.Current;
- musicResults.Add(account.GetProperty("id").GetString());
- }
- }
- }
- string paintingSql = $"select c.id from c join A0 in c.results where A0.quotaId = 'quota_21' \r\n" +
- $"and c.school = 'qyszgh' \r\n" +
- $"and A0.subjectId = 'subject_painting' \r\n" +
- $"and c.artId = '92fb6d6e-4b6f-403a-b4ac-71095d58d43b'\r\n" +
- $"and A0.score > 0";
- List<string> painResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator(queryText: paintingSql))
- {
- using var sc_json = await JsonDocument.ParseAsync(item.ContentStream);
- if (sc_json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- var accounts = sc_json.RootElement.GetProperty("Documents").EnumerateArray();
- while (accounts.MoveNext())
- {
- JsonElement account = accounts.Current;
- painResults.Add(account.GetProperty("id").GetString());
- }
- }
- }
- var guiyi = painResults.Except(musicResults);
- return Ok(new { guiyi });
- }
- [ProducesDefaultResponseType]
- [HttpPost("update-time")]
- public async Task<IActionResult> FixTime(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string stusql = "select * from c where c.pk = 'Art' and c.pId in ('2f74d38e-80c1-4c55-9dd0-de0d8f6fdf6d','306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2')";
- List<ArtEvaluation> art = new List<ArtEvaluation>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: stusql))
- {
- art.Add(item);
- }
- var examId = art.SelectMany(c => c.settings).Where(z => z.id.Equals("quota_21")).SelectMany(a => a.task).Where(p => p.type == 1 && !string.IsNullOrEmpty(p.acId)).Select(o => o.acId).ToList();
- string examSQL = $"select * from c where c.pk = 'Exam' and c.id in ({string.Join(",", examId.Select(o => $"'{o}'"))})";
- List<ExamInfo> infos = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ExamInfo>(queryText: examSQL))
- {
- infos.Add(item);
- }
- //List<Task<ItemResponse<ArtEvaluation>>> tasks = new List<Task<ItemResponse<ArtEvaluation>>>();
- /*foreach (ArtEvaluation evaluation in art)
- {
- foreach (var tas in evaluation.settings)
- {
- if (tas.id.Equals("quota_22"))
- {
- foreach (var quot in tas.task)
- {
- if (quot.subject.Equals("subject_music"))
- {
- quot.workEnd = 1704902400000;
- }
- }
- }
- }
- //evaluation.endTime = 1704902400000;
- tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(evaluation, evaluation.id, new PartitionKey(evaluation.code)));
- }
- await tasks.TaskPage(10);*/
- List<Task<ItemResponse<ArtEvaluation>>> tasks = new List<Task<ItemResponse<ArtEvaluation>>>();
- foreach (ArtEvaluation evaluation in art)
- {
- evaluation.endTime = 1709222400000;
- tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(evaluation, evaluation.id, new PartitionKey(evaluation.code)));
- }
- await tasks.TaskPage(10);
- List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
- foreach (ExamInfo info in infos)
- {
- info.endTime = 1709222400000;
- taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(info, info.id, new PartitionKey(info.code)));
- }
- await taskInfo.TaskPage(10);
- return Ok();
- }
- [ProducesDefaultResponseType]
- [HttpPost("find-score")]
- public async Task<IActionResult> FindScore(JsonElement element)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = "SELECT * FROM c where c.pk = 'Art' and (c.startTime = 1678978800000 or c.startTime = 1678982400000) and c.endTime = 1684382400000";
- //string stusql = "SELECT * FROM c '20222021','20222022','20222023','20222024','20222025','20222026','20222027','20222028','20222029','20222030','20222031','20222032','20222033','20222034','20222035','20222036','20222037','20222038','20222039','20222040','20222041','20222042','20222043','20222044','20222101','20222102','20222103','20222104','20222105','20222106','20222107','20222108','20222109','20222110','20222111','20222112','20222113','20222114','20222115','20222116','20222117','20222118','20222119','20222120','20222121','20222122','20222123','20222124','20222125','20222126','20222127','20222128','20222129','20222130','20222131','20222132','20222133','20222134','20222135','20222136','20222137','20222138','20222139','20222140','20222141','20222142','20222143','20222144','20222145','20222146','20222147','20222201','20222202','20222203','20222204','20222205','20222206','20222207','20222208','20222209','20222210','20222211','20222212','20222213','20222214','20222215','20222216','20222217','20222218','20222219','20222220','20222221','20222222','20222223','20222224','20222226','20222227','20222228','20222229','20222230','20222231','20222232','20222233','20222234','20222235','20222236','20222237','20222238','20222239','20222240','20222241','20222242','20222243','20222244','20222245','20222301','20222302','20222303','20222304','20222305','20222306','20222307','20222308','20222309','20222310','20222311','20222312','20222313','20222314','20222315','20222316','20222317','20222318','20222319','20222320','20222321','20222322','20222323','20222324','20222325','20222326','20222327','20222328','20222329','20222330','20222331','20222332','20222333','20222334','20222335','20222336','20222337','20222338','20222339','20222340','20222341','20222342','20222343','20222344','20222345','20222346','20222347','20222401','20222402','20222403','20222404','20222405','20222406','20222407','20222408','20222409','20222410','20222411','20222412','20222413','20222414','20222415','20222416','20222417','20222418','20222419','20222420','20222421','20222422','20222423','20222424','20222425','20222426','20222427','20222428','20222429','20222430','20222431','20222432','20222433','20222434','20222435','20222436','20222437','20222438','20222439','20222440','20222441','20222442','20222443','20222444','20222445','20222447','20222501','20222502','20222503','20222504','20222505','20222506','20222508','20222509','20222510','20222511','20222512','20222513','20222514','20222515','20222516','20222517','20222518','20222519','20222520','20222521','20222522','20222523','20222525','20222526','20222527','20222528','20222529','20222530','20222531','20222532','20222533','20222534','20222535','20222536','20222537','20222538','20222539','20222540','20222541','20222542','20222543','20222544','20222545','20222546','20222547','20222601','20222602','20222603','20222604','20222605','20222606','20222607','20222608','20222609','20222610','20222611','20222612','20222613','20222614','20222615','20222616','20222617','20222618','20222619','20222620','20222621','20222622','20222623','20222624','20222625','20222626','20222627','20222628','20222629','20222630','20222631','20222632','20222633','20222634','20222635','20222636','20222637','20222639','20222640','20222641','20222642','20222643','20222645','20222646','20222647','20222648','20222649','20222701','20222702','20222703','20222704','20222705','20222706','20222707','20222708','20222709','20222710','20222711','20222712','20222713','20222714','20222715','20222716','20222717','20222718','20222719','20222720','20222721','20222722','20222723','20222724','20222725','20222727','20222728','20222729','20222730','20222731','20222732','20222733','20222734','20222735','20222736','20222737','20222738','20222739','20222740','20222741','20222742','20222743','20222744','20222745','20222746','20222747','20222748','20222749','20222801','20222804','20222805','20222806','20222807','20222808','20222809','20222810','20222811','20222812','20222813','20222814','20222815','20222816','20222817','20222819','20222821','20222822','20222823','20222824','20222825','20222826','20222827','20222828','20222829','20222830','20222831','20222834','20222835','20222836','20222837','20222838','20222839','20222840','20222841','20222842','20222843','20222844','20222845','20222846','20222847','20222848','20211901','20211902','20211903','20211904','20211905','20211906','20211908','20211909','20211910','20211911','20211912','20211913','20211914','20211915','20211916','20211917','20211918','20211919','20211920','20211921','20211922','20211923','20211924','20211925','20211926','20211927','20211928','20211929','20211930','20211931','20211932','20211933','20211934','20211935','20211936','20211937','20211938','20211939','20211940','20211941','20211942','20211943','20211944','20211945','20212001','20212002','20212003','20212004','20212005','20212006','20212007','20212008','20212009','20212010','20212011','20212012','20212013','20212014','20212015','20212016','20212017','20212018','20212019','20212020','20212021','20212022','20212023','20212024','20212025','20212026','20212027','20212028','20212029','20212030','20212031','20212032','20212033','20212034','20212035','20212036','20212037','20212038','20212039','20212040','20212041','20212042','20212043','20212044','20212045','20212046','20212047','20212048','20212101','20212102','20212103','20212104','20212105','20212106','20212107','20212108','20212109','20212110','20212111','20212112','20212113','20212114','20212115','20212116','20212117','20212118','20212119','20212120','20212121','20212123','20212124','20212125','20212126','20212127','20212128','20212129','20212130','20212131','20212132','20212133','20212134','20212135','20212136','20212137','20212138','20212139','20212140','20212141','20212142','20212143','20212144','20212145','20212146','20212147','20212148','20212149','20212150','20212151','20212201','20212202','20212203','20212204','20212205','20212206','20212207','20212208','20212209','20212210','20212211','20212212','20212213','20212214','20212215','20212216','20212217','20212218','20212219','20212220','20212221','20212222','20212223','20212224','20212225','20212226','20212227','20212228','20212229','20212230','20212231','20212232','20212233','20212234','20212235','20212236','20212237','20212238','20212239','20212240','20212241','20212242','20212243','20212244','20212245','20212246','20212247','20212248','20212249','20212250','20212301','20212302','20212303','20212304','20212305','20212306','20212307','20212308','20212309','20212310','20212311','20212312','20212313','20212314','20212315','20212317','20212318','20212319','20212320','20212322','20212323','20212324','20212325','20212326','20212327','20212328','20212329','20212330','20212331','20212332','20212333','20212334','20212335','20212336','20212337','20212338','20212339','20212340','20212341','20212342','20212343','20212344','20212345','20212346','20212401','20212402','20212403','20212404','20212405','20212406','20212407','20212408','20212409','20212410','20212411','20212413','20212414','20212415','20212416','20212417','20212418','20212419','20212420','20212421','20212422','20212423','20212424','20212425','20212426','20212427','20212428','20212429','20212430','20212431','20212432','20212433','20212434','20212435','20212436','20212437','20212438','20212439','20212440','20212441','20212442','20212443','20212444','20212445','20212446','20212447','20212501','20212502','20212503','20212504','20212505','20212506','20212507','20212508','20212509','20212510','20212511','20212512','20212513','20212514','20212515','20212516','20212517','20212518','20212519','20212520','20212521','20212522','20212523','20212524','20212525','20212526','20212527','20212528','20212529','20212530','20212531','20212532','20212533','20212534','20212535','20212536','20212537','20212538','20212539','20212540','20212541','20212542','20212543','20212544','20212545','20212548','20212549','20212601','20212602','20212603','20212604','20212605','20212606','20212607','20212608','20212609','20212610','20212611','20212612','20212613','20212614','20212615','20212616','20212617','20212618','20212619','20212620','20212621','20212622','20212623','20212624','20212625','20212626','20212627','20212628','20212629','20212630','20212631','20212632','20212633','20212634','20212635','20212636','20212637','20212638','20212639','20212640','20212641','20212642','20212643','20212644','20212701','20212702','20212703','20212704','20212705','20212706','20212707','20212708','20212709','20212710','20212711','20212712','20212713','20212714','20212715','20212716','20212717','20212718','20212719','20212720','20212721','20212722','20212723','20212724','20212725','20212726','20212727','20212728','20212730','20212731','20212732','20212733','20212734','20212735','20212736','20212737','20212738','20212739','20212740','20212741','20212742','20212743','20212744','20212745','20212746','20212747','20212748','20212749','20212801','20212802','20212803','20212804','20212805','20212806','20212807','20212808','20212809','20212810','20212811','20212812','20212813','20212814','20212815','20212816','20212818','20212819','20212820','20212821','20212822','20212823','20212824','20212825','20212826','20212827','20212828','20212829','20212830','20212831','20212832','20212833','20212834','20212835','20212836','20212837','20212838','20212839','20212840','20212841','20212842','20212843','20212844','20212845','20212846','20212847','20212848','20212849','20212901','20212902','20212903','20212904','20212905','20212906','20212907','20212908','20212909','20212910','20212911','20212912','20212913','20212914','20212915','20212916','20212917','20212918','20212919','20212920','20212921','20212922','20212923','20212924','20212925','20212927','20212928','20212929','20212930','20212931','20212932','20212933','20212934','20212935','20212936','20212937','20212938','20212939','20212940','20212941','20212942','20212943','20212947','20212948','20213001','20213002','20213003','20213004','20213005','20213006','20213007','20213008','20213009','20213010','20213011','20213012','20213013','20213014','20213015','20213016','20213017','20213018','20213019','20213020','20213021','20213022','20213023','20213024','20213025','20213026','20213027','20213028','20213029','20213030','20213031','20213032','20213033','20213034','20213035','20213036','20213037','20213038','20213039','20213040','20213041','20213042','20213043','20213044','20213045','20213046','20213047','20213048','20213049','20213050','20213101','20213102','20213103','20213104','20213105','20213106','20213107','20213108','20213109','20213110','20213111','20213112','20213113','20213114','20213115','20213116','20213117','20213118','20213119','20213120','20213121','20213122','20213123','20213124','20213125','20213126','20213127','20213128','20213129','20213130','20213131','20213132','20213133','20213134','20213135','20213136','20213137','20213138','20213139','20213140','20213142','20213143','20213144','20213145','20213146','20213147','20213148','20213149','20213152','20213201','20213202','20213203','20213204','20213205','20213206','20213207','20213208','20213209','20213210','20213211','20213212','20213213','20213214','20213215','20213216','20213217','20213218','20213219','20213220','20213221','20213222','20213223','20213224','20213225','20213226','20213227','20213228','20213229','20213230','20213231','20213232','20213233','20213234','20213235','20213236','20213237','20213238','20213239','20213240','20213241','20213242','20213243','20213244','20213245','20213246','20213247','20213248','20201901','20201902','20201903','20201904','20201905','20201906','20201907','20201908','20201909','20201910','20201911','20201912','20201913','20201914','20201915','20201916','20201917','20201918','20201919','20201920','20201921','20201922','20201923','20201924','20201925','20201926','20201927','20201928','20201929','20201930','20201931','20201932','20201933','20201934','20201935','20201936','20201937','20201938','20201939','20201940','20201941','20201942','20201943','20201944','20201945','20201946','20201947','20201949','20201951','20202001','20202002','20202003','20202004','20202005','20202006','20202007','20202008','20202010','20202011','20202012','20202013','20202014','20202016','20202017','20202018','20202019','20202020','20202021','20202022','20202023','20202024','20202025','20202026','20202027','20202028','20202029','20202030','20202031','20202032','20202033','20202034','20202035','20202036','20202037','20202038','20202039','20202040','20202041','20202042','20202043','20202044','20202045','20202046','20202047','20202101','20202102','20202104','20202105','20202106','20202107','20202108','20202109','20202110','20202111','20202112','20202113','20202114','20202115','20202116','20202117','20202118','20202119','20202120','20202121','20202122','20202125','20202126','20202127','20202128','20202129','20202130','20202131','20202132','20202133','20202134','20202135','20202136','20202137','20202138','20202139','20202140','20202141','20202142','20202143','20202144','20202145','20202147','20202148','20202201','20202202','20202203','20202204','20202205','20202206','20202207','20202208','20202209','20202210','20202211','20202212','20202213','20202214','20202215','20202216','20202217','20202218','20202219','20202220','20202221','20202222','20202223','20202224','20202225','20202226','20202227','20202228','20202229','20202230','20202231','20202232','20202233','20202234','20202235','20202236','20202237','20202238','20202239','20202240','20202241','20202242','20202243','20202244','20202245','20202246','20202248','20202301','20202302','20202303','20202304','20202305','20202306','20202307','20202308','20202309','20202310','20202312','20202313','20202314','20202315','20202316','20202317','20202318','20202319','20202320','20202321','20202322','20202323','20202324','20202325','20202326','20202327','20202328','20202329','20202330','20202331','20202332','20202333','20202334','20202335','20202337','20202338','20202339','20202340','20202341','20202342','20202343','20202344','20202345','20202346','20202401','20202402','20202403','20202404','20202405','20202406','20202407','20202408','20202409','20202410','20202412','20202413','20202414','20202415','20202416','20202417','20202418','20202419','20202420','20202421','20202422','20202423','20202424','20202425','20202426','20202427','20202428','20202429','20202430','20202431','20202432','20202433','20202434','20202435','20202436','20202437','20202438','20202439','20202440','20202441','20202442','20202443','20202444','20202445','20202446','20202447','20202448','20202449','20202450','20202501','20202502','20202503','20202504','20202506','20202507','20202508','20202509','20202510','20202511','20202512','20202513','20202514','20202515','20202516','20202517','20202518','20202519','20202520','20202521','20202522','20202523','20202524','20202525','20202526','20202527','20202528','20202529','20202530','20202531','20202532','20202533','20202534','20202535','20202536','20202537','20202538','20202539','20202540','20202541','20202542','20202543','20202544','20202545','20202546','20202601','20202602','20202603','20202604','20202605','20202606','20202607','20202608','20202609','20202610','20202611','20202612','20202613','20202614','20202615','20202616','20202617','20202618','20202619','20202620','20202621','20202622','20202623','20202624','20202625','20202626','20202627','20202628','20202629','20202630','20202631','20202633','20202634','20202635','20202636','20202637','20202638','20202639','20202640','20202641','20202642','20202643','20202644','20202645','20202701','20202702','20202703','20202704','20202705','20202706','20202707','20202708','20202709','20202710','20202711','20202712','20202713','20202714','20202715','20202716','20202717','20202718','20202719','20202720','20202721','20202722','20202723','20202724','20202725','20202726','20202727','20202728','20202729','20202730','20202731','20202732','20202733','20202734','20202735','20202736','20202737','20202738','20202739','20202740','20202741','20202742','20202743','20202747','20202801','20202802','20202803','20202804','20202805','20202806','20202807','20202808','20202809','20202810','20202811','20202812','20202813','20202814','20202815','20202816','20202817','20202818','20202819','20202820','20202821','20202822','20202823','20202824','20202825','20202826','20202827','20202828','20202829','20202830','20202831','20202832','20202833','20202834','20202835','20202836','20202837','20202838','20202839','20202840','20202841','20202842','20202843','20202844','20202845','20202846','20202847','20202901','20202902','20202903','20202904','20202905','20202906','20202907','20202908','20202909','20202910','20202911','20202912','20202913','20202914','20202915','20202916','20202917','20202918','20202919','20202920','20202921','20202922','20202923','20202924','20202925','20202926','20202927','20202928','20202929','20202930','20202931','20202932','20202933','20202934','20202935','20202936','20202937','20202938','20202939','20202940','20202941','20202942','20202943','20202944','20203001','20203002','20203003','20203004','20203005','20203006','20203007','20203008','20203009','20203010','20203011','20203012','20203013','20203014','20203015','20203016','20203017','20203018','20203019','20203020','20203021','20203022','20203023','20203024','20203025','20203026','20203027','20203028','20203029','20203030','20203031','20203032','20203033','20203034','20203035','20203036','20203037','20203039','20203040','20203041','20203042','20203043','20203044','20203046','20203101','20203102','20203103','20203104','20203105','20203106','20203107','20203108','20203109','20203110','20203111','20203112','20203113','20203114','20203115','20203116','20203117','20203118','20203119','20203120','20203121','20203122','20203123','20203124','20203125','20203126','20203127','20203128','20203129','20203130','20203131','20203132','20203133','20203134','20203135','20203136','20203137','20203138','20203139','20203140','20203141','20203142','20203143','20203144','20203145','20203146','20203201','20203202','20203203','20203204','20203205','20203207','20203208','20203209','20203210','20203211','20203212','20203213','20203214','20203215','20203216','20203217','20203218','20203220','20203221','20203222','20203223','20203224','20203225','20203226','20203227','20203228','20203229','20203230','20203231','20203232','20203233','20203234','20203235','20203236','20203237','20203238','20203239','20203240','20203241','20203242','20203243','20203244','20203245','20203246','20203247') and c.code='Base-fzpdzz' ";
- //string clasql = "SELECT * FROM c where c.no in('20221901','20221902','20221903','20221904','20221905','20221906','20221907','20221908','20221909','20221910','20221911','20221912','20221913','20221914','20221915','20221916','20221917','20221918','20221919','20221920','20221921','20221922','20221923','20221924','20221925','20221926','20221927','20221928','20221929','20221930','20221931','20221932','20221933','20221934','20221935','20221936','20221937','20221938','20221939','20221940','20221941','20221942','20221943','20221944','20221945','20221946','20221947','20221948','20221949','20221950','20222002','20222003','20222004','20222005','20222006','20222007','20222008','20222009','20222010','20222011','20222012','20222013','20222014','20222015','20222016','20222017','20222018','20222019','20222020','20222021','20222022','20222023','20222024','20222025','20222026','20222027','20222028','20222029','20222030','20222031','20222032','20222033','20222034','20222035','20222036','20222037','20222038','20222039','20222040','20222041','20222042','20222043','20222044','20222101','20222102','20222103','20222104','20222105','20222106','20222107','20222108','20222109','20222110','20222111','20222112','20222113','20222114','20222115','20222116','20222117','20222118','20222119','20222120','20222121','20222122','20222123','20222124','20222125','20222126','20222127','20222128','20222129','20222130','20222131','20222132','20222133','20222134','20222135','20222136','20222137','20222138','20222139','20222140','20222141','20222142','20222143','20222144','20222145','20222146','20222147','20222201','20222202','20222203','20222204','20222205','20222206','20222207','20222208','20222209','20222210','20222211','20222212','20222213','20222214','20222215','20222216','20222217','20222218','20222219','20222220','20222221','20222222','20222223','20222224','20222226','20222227','20222228','20222229','20222230','20222231','20222232','20222233','20222234','20222235','20222236','20222237','20222238','20222239','20222240','20222241','20222242','20222243','20222244','20222245','20222301','20222302','20222303','20222304','20222305','20222306','20222307','20222308','20222309','20222310','20222311','20222312','20222313','20222314','20222315','20222316','20222317','20222318','20222319','20222320','20222321','20222322','20222323','20222324','20222325','20222326','20222327','20222328','20222329','20222330','20222331','20222332','20222333','20222334','20222335','20222336','20222337','20222338','20222339','20222340','20222341','20222342','20222343','20222344','20222345','20222346','20222347','20222401','20222402','20222403','20222404','20222405','20222406','20222407','20222408','20222409','20222410','20222411','20222412','20222413','20222414','20222415','20222416','20222417','20222418','20222419','20222420','20222421','20222422','20222423','20222424','20222425','20222426','20222427','20222428','20222429','20222430','20222431','20222432','20222433','20222434','20222435','20222436','20222437','20222438','20222439','20222440','20222441','20222442','20222443','20222444','20222445','20222447','20222501','20222502','20222503','20222504','20222505','20222506','20222508','20222509','20222510','20222511','20222512','20222513','20222514','20222515','20222516','20222517','20222518','20222519','20222520','20222521','20222522','20222523','20222525','20222526','20222527','20222528','20222529','20222530','20222531','20222532','20222533','20222534','20222535','20222536','20222537','20222538','20222539','20222540','20222541','20222542','20222543','20222544','20222545','20222546','20222547','20222601','20222602','20222603','20222604','20222605','20222606','20222607','20222608','20222609','20222610','20222611','20222612','20222613','20222614','20222615','20222616','20222617','20222618','20222619','20222620','20222621','20222622','20222623','20222624','20222625','20222626','20222627','20222628','20222629','20222630','20222631','20222632','20222633','20222634','20222635','20222636','20222637','20222639','20222640','20222641','20222642','20222643','20222645','20222646','20222647','20222648','20222649','20222701','20222702','20222703','20222704','20222705','20222706','20222707','20222708','20222709','20222710','20222711','20222712','20222713','20222714','20222715','20222716','20222717','20222718','20222719','20222720','20222721','20222722','20222723','20222724','20222725','20222727','20222728','20222729','20222730','20222731','20222732','20222733','20222734','20222735','20222736','20222737','20222738','20222739','20222740','20222741','20222742','20222743','20222744','20222745','20222746','20222747','20222748','20222749','20222801','20222804','20222805','20222806','20222807','20222808','20222809','20222810','20222811','20222812','20222813','20222814','20222815','20222816','20222817','20222819','20222821','20222822','20222823','20222824','20222825','20222826','20222827','20222828','20222829','20222830','20222831','20222834','20222835','20222836','20222837','20222838','20222839','20222840','20222841','20222842','20222843','20222844','20222845','20222846','20222847','20222848','20211901','20211902','20211903','20211904','20211905','20211906','20211908','20211909','20211910','20211911','20211912','20211913','20211914','20211915','20211916','20211917','20211918','20211919','20211920','20211921','20211922','20211923','20211924','20211925','20211926','20211927','20211928','20211929','20211930','20211931','20211932','20211933','20211934','20211935','20211936','20211937','20211938','20211939','20211940','20211941','20211942','20211943','20211944','20211945','20212001','20212002','20212003','20212004','20212005','20212006','20212007','20212008','20212009','20212010','20212011','20212012','20212013','20212014','20212015','20212016','20212017','20212018','20212019','20212020','20212021','20212022','20212023','20212024','20212025','20212026','20212027','20212028','20212029','20212030','20212031','20212032','20212033','20212034','20212035','20212036','20212037','20212038','20212039','20212040','20212041','20212042','20212043','20212044','20212045','20212046','20212047','20212048','20212101','20212102','20212103','20212104','20212105','20212106','20212107','20212108','20212109','20212110','20212111','20212112','20212113','20212114','20212115','20212116','20212117','20212118','20212119','20212120','20212121','20212123','20212124','20212125','20212126','20212127','20212128','20212129','20212130','20212131','20212132','20212133','20212134','20212135','20212136','20212137','20212138','20212139','20212140','20212141','20212142','20212143','20212144','20212145','20212146','20212147','20212148','20212149','20212150','20212151','20212201','20212202','20212203','20212204','20212205','20212206','20212207','20212208','20212209','20212210','20212211','20212212','20212213','20212214','20212215','20212216','20212217','20212218','20212219','20212220','20212221','20212222','20212223','20212224','20212225','20212226','20212227','20212228','20212229','20212230','20212231','20212232','20212233','20212234','20212235','20212236','20212237','20212238','20212239','20212240','20212241','20212242','20212243','20212244','20212245','20212246','20212247','20212248','20212249','20212250','20212301','20212302','20212303','20212304','20212305','20212306','20212307','20212308','20212309','20212310','20212311','20212312','20212313','20212314','20212315','20212317','20212318','20212319','20212320','20212322','20212323','20212324','20212325','20212326','20212327','20212328','20212329','20212330','20212331','20212332','20212333','20212334','20212335','20212336','20212337','20212338','20212339','20212340','20212341','20212342','20212343','20212344','20212345','20212346','20212401','20212402','20212403','20212404','20212405','20212406','20212407','20212408','20212409','20212410','20212411','20212413','20212414','20212415','20212416','20212417','20212418','20212419','20212420','20212421','20212422','20212423','20212424','20212425','20212426','20212427','20212428','20212429','20212430','20212431','20212432','20212433','20212434','20212435','20212436','20212437','20212438','20212439','20212440','20212441','20212442','20212443','20212444','20212445','20212446','20212447','20212501','20212502','20212503','20212504','20212505','20212506','20212507','20212508','20212509','20212510','20212511','20212512','20212513','20212514','20212515','20212516','20212517','20212518','20212519','20212520','20212521','20212522','20212523','20212524','20212525','20212526','20212527','20212528','20212529','20212530','20212531','20212532','20212533','20212534','20212535','20212536','20212537','20212538','20212539','20212540','20212541','20212542','20212543','20212544','20212545','20212548','20212549','20212601','20212602','20212603','20212604','20212605','20212606','20212607','20212608','20212609','20212610','20212611','20212612','20212613','20212614','20212615','20212616','20212617','20212618','20212619','20212620','20212621','20212622','20212623','20212624','20212625','20212626','20212627','20212628','20212629','20212630','20212631','20212632','20212633','20212634','20212635','20212636','20212637','20212638','20212639','20212640','20212641','20212642','20212643','20212644','20212701','20212702','20212703','20212704','20212705','20212706','20212707','20212708','20212709','20212710','20212711','20212712','20212713','20212714','20212715','20212716','20212717','20212718','20212719','20212720','20212721','20212722','20212723','20212724','20212725','20212726','20212727','20212728','20212730','20212731','20212732','20212733','20212734','20212735','20212736','20212737','20212738','20212739','20212740','20212741','20212742','20212743','20212744','20212745','20212746','20212747','20212748','20212749','20212801','20212802','20212803','20212804','20212805','20212806','20212807','20212808','20212809','20212810','20212811','20212812','20212813','20212814','20212815','20212816','20212818','20212819','20212820','20212821','20212822','20212823','20212824','20212825','20212826','20212827','20212828','20212829','20212830','20212831','20212832','20212833','20212834','20212835','20212836','20212837','20212838','20212839','20212840','20212841','20212842','20212843','20212844','20212845','20212846','20212847','20212848','20212849','20212901','20212902','20212903','20212904','20212905','20212906','20212907','20212908','20212909','20212910','20212911','20212912','20212913','20212914','20212915','20212916','20212917','20212918','20212919','20212920','20212921','20212922','20212923','20212924','20212925','20212927','20212928','20212929','20212930','20212931','20212932','20212933','20212934','20212935','20212936','20212937','20212938','20212939','20212940','20212941','20212942','20212943','20212947','20212948','20213001','20213002','20213003','20213004','20213005','20213006','20213007','20213008','20213009','20213010','20213011','20213012','20213013','20213014','20213015','20213016','20213017','20213018','20213019','20213020','20213021','20213022','20213023','20213024','20213025','20213026','20213027','20213028','20213029','20213030','20213031','20213032','20213033','20213034','20213035','20213036','20213037','20213038','20213039','20213040','20213041','20213042','20213043','20213044','20213045','20213046','20213047','20213048','20213049','20213050','20213101','20213102','20213103','20213104','20213105','20213106','20213107','20213108','20213109','20213110','20213111','20213112','20213113','20213114','20213115','20213116','20213117','20213118','20213119','20213120','20213121','20213122','20213123','20213124','20213125','20213126','20213127','20213128','20213129','20213130','20213131','20213132','20213133','20213134','20213135','20213136','20213137','20213138','20213139','20213140','20213142','20213143','20213144','20213145','20213146','20213147','20213148','20213149','20213152','20213201','20213202','20213203','20213204','20213205','20213206','20213207','20213208','20213209','20213210','20213211','20213212','20213213','20213214','20213215','20213216','20213217','20213218','20213219','20213220','20213221','20213222','20213223','20213224','20213225','20213226','20213227','20213228','20213229','20213230','20213231','20213232','20213233','20213234','20213235','20213236','20213237','20213238','20213239','20213240','20213241','20213242','20213243','20213244','20213245','20213246','20213247','20213248','20201901','20201902','20201903','20201904','20201905','20201906','20201907','20201908','20201909','20201910','20201911','20201912','20201913','20201914','20201915','20201916','20201917','20201918','20201919','20201920','20201921','20201922','20201923','20201924','20201925','20201926','20201927','20201928','20201929','20201930','20201931','20201932','20201933','20201934','20201935','20201936','20201937','20201938','20201939','20201940','20201941','20201942','20201943','20201944','20201945','20201946','20201947','20201949','20201951','20202001','20202002','20202003','20202004','20202005','20202006','20202007','20202008','20202010','20202011','20202012','20202013','20202014','20202016','20202017','20202018','20202019','20202020','20202021','20202022','20202023','20202024','20202025','20202026','20202027','20202028','20202029','20202030','20202031','20202032','20202033','20202034','20202035','20202036','20202037','20202038','20202039','20202040','20202041','20202042','20202043','20202044','20202045','20202046','20202047','20202101','20202102','20202104','20202105','20202106','20202107','20202108','20202109','20202110','20202111','20202112','20202113','20202114','20202115','20202116','20202117','20202118','20202119','20202120','20202121','20202122','20202125','20202126','20202127','20202128','20202129','20202130','20202131','20202132','20202133','20202134','20202135','20202136','20202137','20202138','20202139','20202140','20202141','20202142','20202143','20202144','20202145','20202147','20202148','20202201','20202202','20202203','20202204','20202205','20202206','20202207','20202208','20202209','20202210','20202211','20202212','20202213','20202214','20202215','20202216','20202217','20202218','20202219','20202220','20202221','20202222','20202223','20202224','20202225','20202226','20202227','20202228','20202229','20202230','20202231','20202232','20202233','20202234','20202235','20202236','20202237','20202238','20202239','20202240','20202241','20202242','20202243','20202244','20202245','20202246','20202248','20202301','20202302','20202303','20202304','20202305','20202306','20202307','20202308','20202309','20202310','20202312','20202313','20202314','20202315','20202316','20202317','20202318','20202319','20202320','20202321','20202322','20202323','20202324','20202325','20202326','20202327','20202328','20202329','20202330','20202331','20202332','20202333','20202334','20202335','20202337','20202338','20202339','20202340','20202341','20202342','20202343','20202344','20202345','20202346','20202401','20202402','20202403','20202404','20202405','20202406','20202407','20202408','20202409','20202410','20202412','20202413','20202414','20202415','20202416','20202417','20202418','20202419','20202420','20202421','20202422','20202423','20202424','20202425','20202426','20202427','20202428','20202429','20202430','20202431','20202432','20202433','20202434','20202435','20202436','20202437','20202438','20202439','20202440','20202441','20202442','20202443','20202444','20202445','20202446','20202447','20202448','20202449','20202450','20202501','20202502','20202503','20202504','20202506','20202507','20202508','20202509','20202510','20202511','20202512','20202513','20202514','20202515','20202516','20202517','20202518','20202519','20202520','20202521','20202522','20202523','20202524','20202525','20202526','20202527','20202528','20202529','20202530','20202531','20202532','20202533','20202534','20202535','20202536','20202537','20202538','20202539','20202540','20202541','20202542','20202543','20202544','20202545','20202546','20202601','20202602','20202603','20202604','20202605','20202606','20202607','20202608','20202609','20202610','20202611','20202612','20202613','20202614','20202615','20202616','20202617','20202618','20202619','20202620','20202621','20202622','20202623','20202624','20202625','20202626','20202627','20202628','20202629','20202630','20202631','20202633','20202634','20202635','20202636','20202637','20202638','20202639','20202640','20202641','20202642','20202643','20202644','20202645','20202701','20202702','20202703','20202704','20202705','20202706','20202707','20202708','20202709','20202710','20202711','20202712','20202713','20202714','20202715','20202716','20202717','20202718','20202719','20202720','20202721','20202722','20202723','20202724','20202725','20202726','20202727','20202728','20202729','20202730','20202731','20202732','20202733','20202734','20202735','20202736','20202737','20202738','20202739','20202740','20202741','20202742','20202743','20202747','20202801','20202802','20202803','20202804','20202805','20202806','20202807','20202808','20202809','20202810','20202811','20202812','20202813','20202814','20202815','20202816','20202817','20202818','20202819','20202820','20202821','20202822','20202823','20202824','20202825','20202826','20202827','20202828','20202829','20202830','20202831','20202832','20202833','20202834','20202835','20202836','20202837','20202838','20202839','20202840','20202841','20202842','20202843','20202844','20202845','20202846','20202847','20202901','20202902','20202903','20202904','20202905','20202906','20202907','20202908','20202909','20202910','20202911','20202912','20202913','20202914','20202915','20202916','20202917','20202918','20202919','20202920','20202921','20202922','20202923','20202924','20202925','20202926','20202927','20202928','20202929','20202930','20202931','20202932','20202933','20202934','20202935','20202936','20202937','20202938','20202939','20202940','20202941','20202942','20202943','20202944','20203001','20203002','20203003','20203004','20203005','20203006','20203007','20203008','20203009','20203010','20203011','20203012','20203013','20203014','20203015','20203016','20203017','20203018','20203019','20203020','20203021','20203022','20203023','20203024','20203025','20203026','20203027','20203028','20203029','20203030','20203031','20203032','20203033','20203034','20203035','20203036','20203037','20203039','20203040','20203041','20203042','20203043','20203044','20203046','20203101','20203102','20203103','20203104','20203105','20203106','20203107','20203108','20203109','20203110','20203111','20203112','20203113','20203114','20203115','20203116','20203117','20203118','20203119','20203120','20203121','20203122','20203123','20203124','20203125','20203126','20203127','20203128','20203129','20203130','20203131','20203132','20203133','20203134','20203135','20203136','20203137','20203138','20203139','20203140','20203141','20203142','20203143','20203144','20203145','20203146','20203201','20203202','20203203','20203204','20203205','20203207','20203208','20203209','20203210','20203211','20203212','20203213','20203214','20203215','20203216','20203217','20203218','20203220','20203221','20203222','20203223','20203224','20203225','20203226','20203227','20203228','20203229','20203230','20203231','20203232','20203233','20203234','20203235','20203236','20203237','20203238','20203239','20203240','20203241','20203242','20203243','20203244','20203245','20203246','20203247') and c.code='Class-fzpdzz' ";
- List<ArtEvaluation> infos = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: sql))
- {
- infos.Add(item);
- }
- //List<Task<ItemResponse<ExamInfo>>> tasks = new List<Task<ItemResponse<ExamInfo>>>();
- List<string> ids = infos.SelectMany(x => x.settings).SelectMany(c => c.task).Where(z => z.type == 1).Select(n => n.acId).ToList();
- List<ExamClassResult> examClassResults = new List<ExamClassResult>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
- queryText: $"select value(c) from c where c.pk = 'ExamClassResult' and c.examId in ({string.Join(",", ids.Select(o => $"'{o}'"))})"))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- examClassResults.Add(obj.ToObject<ExamClassResult>());
- }
- }
- }
- //List<(string school, string name,string subject, List<(string stuId, List<double> es, double score)> values)> students = new();
- List<(string stuId, string school, string name, string subject, List<double> es, double score)> stuInfo = new();
- foreach (ExamClassResult classResult in examClassResults)
- {
- //List<(string stuId, List<double> es,double score)> stuInfo = new();
- foreach (var stu in classResult.studentIds) {
- stuInfo.Add((stu, classResult.school,classResult.info.name,classResult.subjectId,classResult.studentScores[classResult.studentIds.IndexOf(stu)], classResult.sum[classResult.studentIds.IndexOf(stu)]));
- }
- //students.Add((classResult.school,classResult.info.name,classResult.subjectId, stuInfo));
- }
- var stus = stuInfo.Select(x => new {
- x.stuId,
- x.school,
- x.name,
- x.subject,
- x.es,
- x.score
- //score = x.values.Select(c => new { c.stuId,c.es,c.score})
- });
- return Ok(stus);
- }
- [ProducesDefaultResponseType]
- [HttpPost("find-art-result")]
- public async Task<IActionResult> FindArtResult(JsonElement element)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = "SELECT * FROM c where c.pk = 'Art' and (c.startTime = 1678978800000 or c.startTime = 1678982400000) and c.endTime = 1684382400000";
- //string stusql = "SELECT * FROM c '20222021','20222022','20222023','20222024','20222025','20222026','20222027','20222028','20222029','20222030','20222031','20222032','20222033','20222034','20222035','20222036','20222037','20222038','20222039','20222040','20222041','20222042','20222043','20222044','20222101','20222102','20222103','20222104','20222105','20222106','20222107','20222108','20222109','20222110','20222111','20222112','20222113','20222114','20222115','20222116','20222117','20222118','20222119','20222120','20222121','20222122','20222123','20222124','20222125','20222126','20222127','20222128','20222129','20222130','20222131','20222132','20222133','20222134','20222135','20222136','20222137','20222138','20222139','20222140','20222141','20222142','20222143','20222144','20222145','20222146','20222147','20222201','20222202','20222203','20222204','20222205','20222206','20222207','20222208','20222209','20222210','20222211','20222212','20222213','20222214','20222215','20222216','20222217','20222218','20222219','20222220','20222221','20222222','20222223','20222224','20222226','20222227','20222228','20222229','20222230','20222231','20222232','20222233','20222234','20222235','20222236','20222237','20222238','20222239','20222240','20222241','20222242','20222243','20222244','20222245','20222301','20222302','20222303','20222304','20222305','20222306','20222307','20222308','20222309','20222310','20222311','20222312','20222313','20222314','20222315','20222316','20222317','20222318','20222319','20222320','20222321','20222322','20222323','20222324','20222325','20222326','20222327','20222328','20222329','20222330','20222331','20222332','20222333','20222334','20222335','20222336','20222337','20222338','20222339','20222340','20222341','20222342','20222343','20222344','20222345','20222346','20222347','20222401','20222402','20222403','20222404','20222405','20222406','20222407','20222408','20222409','20222410','20222411','20222412','20222413','20222414','20222415','20222416','20222417','20222418','20222419','20222420','20222421','20222422','20222423','20222424','20222425','20222426','20222427','20222428','20222429','20222430','20222431','20222432','20222433','20222434','20222435','20222436','20222437','20222438','20222439','20222440','20222441','20222442','20222443','20222444','20222445','20222447','20222501','20222502','20222503','20222504','20222505','20222506','20222508','20222509','20222510','20222511','20222512','20222513','20222514','20222515','20222516','20222517','20222518','20222519','20222520','20222521','20222522','20222523','20222525','20222526','20222527','20222528','20222529','20222530','20222531','20222532','20222533','20222534','20222535','20222536','20222537','20222538','20222539','20222540','20222541','20222542','20222543','20222544','20222545','20222546','20222547','20222601','20222602','20222603','20222604','20222605','20222606','20222607','20222608','20222609','20222610','20222611','20222612','20222613','20222614','20222615','20222616','20222617','20222618','20222619','20222620','20222621','20222622','20222623','20222624','20222625','20222626','20222627','20222628','20222629','20222630','20222631','20222632','20222633','20222634','20222635','20222636','20222637','20222639','20222640','20222641','20222642','20222643','20222645','20222646','20222647','20222648','20222649','20222701','20222702','20222703','20222704','20222705','20222706','20222707','20222708','20222709','20222710','20222711','20222712','20222713','20222714','20222715','20222716','20222717','20222718','20222719','20222720','20222721','20222722','20222723','20222724','20222725','20222727','20222728','20222729','20222730','20222731','20222732','20222733','20222734','20222735','20222736','20222737','20222738','20222739','20222740','20222741','20222742','20222743','20222744','20222745','20222746','20222747','20222748','20222749','20222801','20222804','20222805','20222806','20222807','20222808','20222809','20222810','20222811','20222812','20222813','20222814','20222815','20222816','20222817','20222819','20222821','20222822','20222823','20222824','20222825','20222826','20222827','20222828','20222829','20222830','20222831','20222834','20222835','20222836','20222837','20222838','20222839','20222840','20222841','20222842','20222843','20222844','20222845','20222846','20222847','20222848','20211901','20211902','20211903','20211904','20211905','20211906','20211908','20211909','20211910','20211911','20211912','20211913','20211914','20211915','20211916','20211917','20211918','20211919','20211920','20211921','20211922','20211923','20211924','20211925','20211926','20211927','20211928','20211929','20211930','20211931','20211932','20211933','20211934','20211935','20211936','20211937','20211938','20211939','20211940','20211941','20211942','20211943','20211944','20211945','20212001','20212002','20212003','20212004','20212005','20212006','20212007','20212008','20212009','20212010','20212011','20212012','20212013','20212014','20212015','20212016','20212017','20212018','20212019','20212020','20212021','20212022','20212023','20212024','20212025','20212026','20212027','20212028','20212029','20212030','20212031','20212032','20212033','20212034','20212035','20212036','20212037','20212038','20212039','20212040','20212041','20212042','20212043','20212044','20212045','20212046','20212047','20212048','20212101','20212102','20212103','20212104','20212105','20212106','20212107','20212108','20212109','20212110','20212111','20212112','20212113','20212114','20212115','20212116','20212117','20212118','20212119','20212120','20212121','20212123','20212124','20212125','20212126','20212127','20212128','20212129','20212130','20212131','20212132','20212133','20212134','20212135','20212136','20212137','20212138','20212139','20212140','20212141','20212142','20212143','20212144','20212145','20212146','20212147','20212148','20212149','20212150','20212151','20212201','20212202','20212203','20212204','20212205','20212206','20212207','20212208','20212209','20212210','20212211','20212212','20212213','20212214','20212215','20212216','20212217','20212218','20212219','20212220','20212221','20212222','20212223','20212224','20212225','20212226','20212227','20212228','20212229','20212230','20212231','20212232','20212233','20212234','20212235','20212236','20212237','20212238','20212239','20212240','20212241','20212242','20212243','20212244','20212245','20212246','20212247','20212248','20212249','20212250','20212301','20212302','20212303','20212304','20212305','20212306','20212307','20212308','20212309','20212310','20212311','20212312','20212313','20212314','20212315','20212317','20212318','20212319','20212320','20212322','20212323','20212324','20212325','20212326','20212327','20212328','20212329','20212330','20212331','20212332','20212333','20212334','20212335','20212336','20212337','20212338','20212339','20212340','20212341','20212342','20212343','20212344','20212345','20212346','20212401','20212402','20212403','20212404','20212405','20212406','20212407','20212408','20212409','20212410','20212411','20212413','20212414','20212415','20212416','20212417','20212418','20212419','20212420','20212421','20212422','20212423','20212424','20212425','20212426','20212427','20212428','20212429','20212430','20212431','20212432','20212433','20212434','20212435','20212436','20212437','20212438','20212439','20212440','20212441','20212442','20212443','20212444','20212445','20212446','20212447','20212501','20212502','20212503','20212504','20212505','20212506','20212507','20212508','20212509','20212510','20212511','20212512','20212513','20212514','20212515','20212516','20212517','20212518','20212519','20212520','20212521','20212522','20212523','20212524','20212525','20212526','20212527','20212528','20212529','20212530','20212531','20212532','20212533','20212534','20212535','20212536','20212537','20212538','20212539','20212540','20212541','20212542','20212543','20212544','20212545','20212548','20212549','20212601','20212602','20212603','20212604','20212605','20212606','20212607','20212608','20212609','20212610','20212611','20212612','20212613','20212614','20212615','20212616','20212617','20212618','20212619','20212620','20212621','20212622','20212623','20212624','20212625','20212626','20212627','20212628','20212629','20212630','20212631','20212632','20212633','20212634','20212635','20212636','20212637','20212638','20212639','20212640','20212641','20212642','20212643','20212644','20212701','20212702','20212703','20212704','20212705','20212706','20212707','20212708','20212709','20212710','20212711','20212712','20212713','20212714','20212715','20212716','20212717','20212718','20212719','20212720','20212721','20212722','20212723','20212724','20212725','20212726','20212727','20212728','20212730','20212731','20212732','20212733','20212734','20212735','20212736','20212737','20212738','20212739','20212740','20212741','20212742','20212743','20212744','20212745','20212746','20212747','20212748','20212749','20212801','20212802','20212803','20212804','20212805','20212806','20212807','20212808','20212809','20212810','20212811','20212812','20212813','20212814','20212815','20212816','20212818','20212819','20212820','20212821','20212822','20212823','20212824','20212825','20212826','20212827','20212828','20212829','20212830','20212831','20212832','20212833','20212834','20212835','20212836','20212837','20212838','20212839','20212840','20212841','20212842','20212843','20212844','20212845','20212846','20212847','20212848','20212849','20212901','20212902','20212903','20212904','20212905','20212906','20212907','20212908','20212909','20212910','20212911','20212912','20212913','20212914','20212915','20212916','20212917','20212918','20212919','20212920','20212921','20212922','20212923','20212924','20212925','20212927','20212928','20212929','20212930','20212931','20212932','20212933','20212934','20212935','20212936','20212937','20212938','20212939','20212940','20212941','20212942','20212943','20212947','20212948','20213001','20213002','20213003','20213004','20213005','20213006','20213007','20213008','20213009','20213010','20213011','20213012','20213013','20213014','20213015','20213016','20213017','20213018','20213019','20213020','20213021','20213022','20213023','20213024','20213025','20213026','20213027','20213028','20213029','20213030','20213031','20213032','20213033','20213034','20213035','20213036','20213037','20213038','20213039','20213040','20213041','20213042','20213043','20213044','20213045','20213046','20213047','20213048','20213049','20213050','20213101','20213102','20213103','20213104','20213105','20213106','20213107','20213108','20213109','20213110','20213111','20213112','20213113','20213114','20213115','20213116','20213117','20213118','20213119','20213120','20213121','20213122','20213123','20213124','20213125','20213126','20213127','20213128','20213129','20213130','20213131','20213132','20213133','20213134','20213135','20213136','20213137','20213138','20213139','20213140','20213142','20213143','20213144','20213145','20213146','20213147','20213148','20213149','20213152','20213201','20213202','20213203','20213204','20213205','20213206','20213207','20213208','20213209','20213210','20213211','20213212','20213213','20213214','20213215','20213216','20213217','20213218','20213219','20213220','20213221','20213222','20213223','20213224','20213225','20213226','20213227','20213228','20213229','20213230','20213231','20213232','20213233','20213234','20213235','20213236','20213237','20213238','20213239','20213240','20213241','20213242','20213243','20213244','20213245','20213246','20213247','20213248','20201901','20201902','20201903','20201904','20201905','20201906','20201907','20201908','20201909','20201910','20201911','20201912','20201913','20201914','20201915','20201916','20201917','20201918','20201919','20201920','20201921','20201922','20201923','20201924','20201925','20201926','20201927','20201928','20201929','20201930','20201931','20201932','20201933','20201934','20201935','20201936','20201937','20201938','20201939','20201940','20201941','20201942','20201943','20201944','20201945','20201946','20201947','20201949','20201951','20202001','20202002','20202003','20202004','20202005','20202006','20202007','20202008','20202010','20202011','20202012','20202013','20202014','20202016','20202017','20202018','20202019','20202020','20202021','20202022','20202023','20202024','20202025','20202026','20202027','20202028','20202029','20202030','20202031','20202032','20202033','20202034','20202035','20202036','20202037','20202038','20202039','20202040','20202041','20202042','20202043','20202044','20202045','20202046','20202047','20202101','20202102','20202104','20202105','20202106','20202107','20202108','20202109','20202110','20202111','20202112','20202113','20202114','20202115','20202116','20202117','20202118','20202119','20202120','20202121','20202122','20202125','20202126','20202127','20202128','20202129','20202130','20202131','20202132','20202133','20202134','20202135','20202136','20202137','20202138','20202139','20202140','20202141','20202142','20202143','20202144','20202145','20202147','20202148','20202201','20202202','20202203','20202204','20202205','20202206','20202207','20202208','20202209','20202210','20202211','20202212','20202213','20202214','20202215','20202216','20202217','20202218','20202219','20202220','20202221','20202222','20202223','20202224','20202225','20202226','20202227','20202228','20202229','20202230','20202231','20202232','20202233','20202234','20202235','20202236','20202237','20202238','20202239','20202240','20202241','20202242','20202243','20202244','20202245','20202246','20202248','20202301','20202302','20202303','20202304','20202305','20202306','20202307','20202308','20202309','20202310','20202312','20202313','20202314','20202315','20202316','20202317','20202318','20202319','20202320','20202321','20202322','20202323','20202324','20202325','20202326','20202327','20202328','20202329','20202330','20202331','20202332','20202333','20202334','20202335','20202337','20202338','20202339','20202340','20202341','20202342','20202343','20202344','20202345','20202346','20202401','20202402','20202403','20202404','20202405','20202406','20202407','20202408','20202409','20202410','20202412','20202413','20202414','20202415','20202416','20202417','20202418','20202419','20202420','20202421','20202422','20202423','20202424','20202425','20202426','20202427','20202428','20202429','20202430','20202431','20202432','20202433','20202434','20202435','20202436','20202437','20202438','20202439','20202440','20202441','20202442','20202443','20202444','20202445','20202446','20202447','20202448','20202449','20202450','20202501','20202502','20202503','20202504','20202506','20202507','20202508','20202509','20202510','20202511','20202512','20202513','20202514','20202515','20202516','20202517','20202518','20202519','20202520','20202521','20202522','20202523','20202524','20202525','20202526','20202527','20202528','20202529','20202530','20202531','20202532','20202533','20202534','20202535','20202536','20202537','20202538','20202539','20202540','20202541','20202542','20202543','20202544','20202545','20202546','20202601','20202602','20202603','20202604','20202605','20202606','20202607','20202608','20202609','20202610','20202611','20202612','20202613','20202614','20202615','20202616','20202617','20202618','20202619','20202620','20202621','20202622','20202623','20202624','20202625','20202626','20202627','20202628','20202629','20202630','20202631','20202633','20202634','20202635','20202636','20202637','20202638','20202639','20202640','20202641','20202642','20202643','20202644','20202645','20202701','20202702','20202703','20202704','20202705','20202706','20202707','20202708','20202709','20202710','20202711','20202712','20202713','20202714','20202715','20202716','20202717','20202718','20202719','20202720','20202721','20202722','20202723','20202724','20202725','20202726','20202727','20202728','20202729','20202730','20202731','20202732','20202733','20202734','20202735','20202736','20202737','20202738','20202739','20202740','20202741','20202742','20202743','20202747','20202801','20202802','20202803','20202804','20202805','20202806','20202807','20202808','20202809','20202810','20202811','20202812','20202813','20202814','20202815','20202816','20202817','20202818','20202819','20202820','20202821','20202822','20202823','20202824','20202825','20202826','20202827','20202828','20202829','20202830','20202831','20202832','20202833','20202834','20202835','20202836','20202837','20202838','20202839','20202840','20202841','20202842','20202843','20202844','20202845','20202846','20202847','20202901','20202902','20202903','20202904','20202905','20202906','20202907','20202908','20202909','20202910','20202911','20202912','20202913','20202914','20202915','20202916','20202917','20202918','20202919','20202920','20202921','20202922','20202923','20202924','20202925','20202926','20202927','20202928','20202929','20202930','20202931','20202932','20202933','20202934','20202935','20202936','20202937','20202938','20202939','20202940','20202941','20202942','20202943','20202944','20203001','20203002','20203003','20203004','20203005','20203006','20203007','20203008','20203009','20203010','20203011','20203012','20203013','20203014','20203015','20203016','20203017','20203018','20203019','20203020','20203021','20203022','20203023','20203024','20203025','20203026','20203027','20203028','20203029','20203030','20203031','20203032','20203033','20203034','20203035','20203036','20203037','20203039','20203040','20203041','20203042','20203043','20203044','20203046','20203101','20203102','20203103','20203104','20203105','20203106','20203107','20203108','20203109','20203110','20203111','20203112','20203113','20203114','20203115','20203116','20203117','20203118','20203119','20203120','20203121','20203122','20203123','20203124','20203125','20203126','20203127','20203128','20203129','20203130','20203131','20203132','20203133','20203134','20203135','20203136','20203137','20203138','20203139','20203140','20203141','20203142','20203143','20203144','20203145','20203146','20203201','20203202','20203203','20203204','20203205','20203207','20203208','20203209','20203210','20203211','20203212','20203213','20203214','20203215','20203216','20203217','20203218','20203220','20203221','20203222','20203223','20203224','20203225','20203226','20203227','20203228','20203229','20203230','20203231','20203232','20203233','20203234','20203235','20203236','20203237','20203238','20203239','20203240','20203241','20203242','20203243','20203244','20203245','20203246','20203247') and c.code='Base-fzpdzz' ";
- //string clasql = "SELECT * FROM c where c.no in('20221901','20221902','20221903','20221904','20221905','20221906','20221907','20221908','20221909','20221910','20221911','20221912','20221913','20221914','20221915','20221916','20221917','20221918','20221919','20221920','20221921','20221922','20221923','20221924','20221925','20221926','20221927','20221928','20221929','20221930','20221931','20221932','20221933','20221934','20221935','20221936','20221937','20221938','20221939','20221940','20221941','20221942','20221943','20221944','20221945','20221946','20221947','20221948','20221949','20221950','20222002','20222003','20222004','20222005','20222006','20222007','20222008','20222009','20222010','20222011','20222012','20222013','20222014','20222015','20222016','20222017','20222018','20222019','20222020','20222021','20222022','20222023','20222024','20222025','20222026','20222027','20222028','20222029','20222030','20222031','20222032','20222033','20222034','20222035','20222036','20222037','20222038','20222039','20222040','20222041','20222042','20222043','20222044','20222101','20222102','20222103','20222104','20222105','20222106','20222107','20222108','20222109','20222110','20222111','20222112','20222113','20222114','20222115','20222116','20222117','20222118','20222119','20222120','20222121','20222122','20222123','20222124','20222125','20222126','20222127','20222128','20222129','20222130','20222131','20222132','20222133','20222134','20222135','20222136','20222137','20222138','20222139','20222140','20222141','20222142','20222143','20222144','20222145','20222146','20222147','20222201','20222202','20222203','20222204','20222205','20222206','20222207','20222208','20222209','20222210','20222211','20222212','20222213','20222214','20222215','20222216','20222217','20222218','20222219','20222220','20222221','20222222','20222223','20222224','20222226','20222227','20222228','20222229','20222230','20222231','20222232','20222233','20222234','20222235','20222236','20222237','20222238','20222239','20222240','20222241','20222242','20222243','20222244','20222245','20222301','20222302','20222303','20222304','20222305','20222306','20222307','20222308','20222309','20222310','20222311','20222312','20222313','20222314','20222315','20222316','20222317','20222318','20222319','20222320','20222321','20222322','20222323','20222324','20222325','20222326','20222327','20222328','20222329','20222330','20222331','20222332','20222333','20222334','20222335','20222336','20222337','20222338','20222339','20222340','20222341','20222342','20222343','20222344','20222345','20222346','20222347','20222401','20222402','20222403','20222404','20222405','20222406','20222407','20222408','20222409','20222410','20222411','20222412','20222413','20222414','20222415','20222416','20222417','20222418','20222419','20222420','20222421','20222422','20222423','20222424','20222425','20222426','20222427','20222428','20222429','20222430','20222431','20222432','20222433','20222434','20222435','20222436','20222437','20222438','20222439','20222440','20222441','20222442','20222443','20222444','20222445','20222447','20222501','20222502','20222503','20222504','20222505','20222506','20222508','20222509','20222510','20222511','20222512','20222513','20222514','20222515','20222516','20222517','20222518','20222519','20222520','20222521','20222522','20222523','20222525','20222526','20222527','20222528','20222529','20222530','20222531','20222532','20222533','20222534','20222535','20222536','20222537','20222538','20222539','20222540','20222541','20222542','20222543','20222544','20222545','20222546','20222547','20222601','20222602','20222603','20222604','20222605','20222606','20222607','20222608','20222609','20222610','20222611','20222612','20222613','20222614','20222615','20222616','20222617','20222618','20222619','20222620','20222621','20222622','20222623','20222624','20222625','20222626','20222627','20222628','20222629','20222630','20222631','20222632','20222633','20222634','20222635','20222636','20222637','20222639','20222640','20222641','20222642','20222643','20222645','20222646','20222647','20222648','20222649','20222701','20222702','20222703','20222704','20222705','20222706','20222707','20222708','20222709','20222710','20222711','20222712','20222713','20222714','20222715','20222716','20222717','20222718','20222719','20222720','20222721','20222722','20222723','20222724','20222725','20222727','20222728','20222729','20222730','20222731','20222732','20222733','20222734','20222735','20222736','20222737','20222738','20222739','20222740','20222741','20222742','20222743','20222744','20222745','20222746','20222747','20222748','20222749','20222801','20222804','20222805','20222806','20222807','20222808','20222809','20222810','20222811','20222812','20222813','20222814','20222815','20222816','20222817','20222819','20222821','20222822','20222823','20222824','20222825','20222826','20222827','20222828','20222829','20222830','20222831','20222834','20222835','20222836','20222837','20222838','20222839','20222840','20222841','20222842','20222843','20222844','20222845','20222846','20222847','20222848','20211901','20211902','20211903','20211904','20211905','20211906','20211908','20211909','20211910','20211911','20211912','20211913','20211914','20211915','20211916','20211917','20211918','20211919','20211920','20211921','20211922','20211923','20211924','20211925','20211926','20211927','20211928','20211929','20211930','20211931','20211932','20211933','20211934','20211935','20211936','20211937','20211938','20211939','20211940','20211941','20211942','20211943','20211944','20211945','20212001','20212002','20212003','20212004','20212005','20212006','20212007','20212008','20212009','20212010','20212011','20212012','20212013','20212014','20212015','20212016','20212017','20212018','20212019','20212020','20212021','20212022','20212023','20212024','20212025','20212026','20212027','20212028','20212029','20212030','20212031','20212032','20212033','20212034','20212035','20212036','20212037','20212038','20212039','20212040','20212041','20212042','20212043','20212044','20212045','20212046','20212047','20212048','20212101','20212102','20212103','20212104','20212105','20212106','20212107','20212108','20212109','20212110','20212111','20212112','20212113','20212114','20212115','20212116','20212117','20212118','20212119','20212120','20212121','20212123','20212124','20212125','20212126','20212127','20212128','20212129','20212130','20212131','20212132','20212133','20212134','20212135','20212136','20212137','20212138','20212139','20212140','20212141','20212142','20212143','20212144','20212145','20212146','20212147','20212148','20212149','20212150','20212151','20212201','20212202','20212203','20212204','20212205','20212206','20212207','20212208','20212209','20212210','20212211','20212212','20212213','20212214','20212215','20212216','20212217','20212218','20212219','20212220','20212221','20212222','20212223','20212224','20212225','20212226','20212227','20212228','20212229','20212230','20212231','20212232','20212233','20212234','20212235','20212236','20212237','20212238','20212239','20212240','20212241','20212242','20212243','20212244','20212245','20212246','20212247','20212248','20212249','20212250','20212301','20212302','20212303','20212304','20212305','20212306','20212307','20212308','20212309','20212310','20212311','20212312','20212313','20212314','20212315','20212317','20212318','20212319','20212320','20212322','20212323','20212324','20212325','20212326','20212327','20212328','20212329','20212330','20212331','20212332','20212333','20212334','20212335','20212336','20212337','20212338','20212339','20212340','20212341','20212342','20212343','20212344','20212345','20212346','20212401','20212402','20212403','20212404','20212405','20212406','20212407','20212408','20212409','20212410','20212411','20212413','20212414','20212415','20212416','20212417','20212418','20212419','20212420','20212421','20212422','20212423','20212424','20212425','20212426','20212427','20212428','20212429','20212430','20212431','20212432','20212433','20212434','20212435','20212436','20212437','20212438','20212439','20212440','20212441','20212442','20212443','20212444','20212445','20212446','20212447','20212501','20212502','20212503','20212504','20212505','20212506','20212507','20212508','20212509','20212510','20212511','20212512','20212513','20212514','20212515','20212516','20212517','20212518','20212519','20212520','20212521','20212522','20212523','20212524','20212525','20212526','20212527','20212528','20212529','20212530','20212531','20212532','20212533','20212534','20212535','20212536','20212537','20212538','20212539','20212540','20212541','20212542','20212543','20212544','20212545','20212548','20212549','20212601','20212602','20212603','20212604','20212605','20212606','20212607','20212608','20212609','20212610','20212611','20212612','20212613','20212614','20212615','20212616','20212617','20212618','20212619','20212620','20212621','20212622','20212623','20212624','20212625','20212626','20212627','20212628','20212629','20212630','20212631','20212632','20212633','20212634','20212635','20212636','20212637','20212638','20212639','20212640','20212641','20212642','20212643','20212644','20212701','20212702','20212703','20212704','20212705','20212706','20212707','20212708','20212709','20212710','20212711','20212712','20212713','20212714','20212715','20212716','20212717','20212718','20212719','20212720','20212721','20212722','20212723','20212724','20212725','20212726','20212727','20212728','20212730','20212731','20212732','20212733','20212734','20212735','20212736','20212737','20212738','20212739','20212740','20212741','20212742','20212743','20212744','20212745','20212746','20212747','20212748','20212749','20212801','20212802','20212803','20212804','20212805','20212806','20212807','20212808','20212809','20212810','20212811','20212812','20212813','20212814','20212815','20212816','20212818','20212819','20212820','20212821','20212822','20212823','20212824','20212825','20212826','20212827','20212828','20212829','20212830','20212831','20212832','20212833','20212834','20212835','20212836','20212837','20212838','20212839','20212840','20212841','20212842','20212843','20212844','20212845','20212846','20212847','20212848','20212849','20212901','20212902','20212903','20212904','20212905','20212906','20212907','20212908','20212909','20212910','20212911','20212912','20212913','20212914','20212915','20212916','20212917','20212918','20212919','20212920','20212921','20212922','20212923','20212924','20212925','20212927','20212928','20212929','20212930','20212931','20212932','20212933','20212934','20212935','20212936','20212937','20212938','20212939','20212940','20212941','20212942','20212943','20212947','20212948','20213001','20213002','20213003','20213004','20213005','20213006','20213007','20213008','20213009','20213010','20213011','20213012','20213013','20213014','20213015','20213016','20213017','20213018','20213019','20213020','20213021','20213022','20213023','20213024','20213025','20213026','20213027','20213028','20213029','20213030','20213031','20213032','20213033','20213034','20213035','20213036','20213037','20213038','20213039','20213040','20213041','20213042','20213043','20213044','20213045','20213046','20213047','20213048','20213049','20213050','20213101','20213102','20213103','20213104','20213105','20213106','20213107','20213108','20213109','20213110','20213111','20213112','20213113','20213114','20213115','20213116','20213117','20213118','20213119','20213120','20213121','20213122','20213123','20213124','20213125','20213126','20213127','20213128','20213129','20213130','20213131','20213132','20213133','20213134','20213135','20213136','20213137','20213138','20213139','20213140','20213142','20213143','20213144','20213145','20213146','20213147','20213148','20213149','20213152','20213201','20213202','20213203','20213204','20213205','20213206','20213207','20213208','20213209','20213210','20213211','20213212','20213213','20213214','20213215','20213216','20213217','20213218','20213219','20213220','20213221','20213222','20213223','20213224','20213225','20213226','20213227','20213228','20213229','20213230','20213231','20213232','20213233','20213234','20213235','20213236','20213237','20213238','20213239','20213240','20213241','20213242','20213243','20213244','20213245','20213246','20213247','20213248','20201901','20201902','20201903','20201904','20201905','20201906','20201907','20201908','20201909','20201910','20201911','20201912','20201913','20201914','20201915','20201916','20201917','20201918','20201919','20201920','20201921','20201922','20201923','20201924','20201925','20201926','20201927','20201928','20201929','20201930','20201931','20201932','20201933','20201934','20201935','20201936','20201937','20201938','20201939','20201940','20201941','20201942','20201943','20201944','20201945','20201946','20201947','20201949','20201951','20202001','20202002','20202003','20202004','20202005','20202006','20202007','20202008','20202010','20202011','20202012','20202013','20202014','20202016','20202017','20202018','20202019','20202020','20202021','20202022','20202023','20202024','20202025','20202026','20202027','20202028','20202029','20202030','20202031','20202032','20202033','20202034','20202035','20202036','20202037','20202038','20202039','20202040','20202041','20202042','20202043','20202044','20202045','20202046','20202047','20202101','20202102','20202104','20202105','20202106','20202107','20202108','20202109','20202110','20202111','20202112','20202113','20202114','20202115','20202116','20202117','20202118','20202119','20202120','20202121','20202122','20202125','20202126','20202127','20202128','20202129','20202130','20202131','20202132','20202133','20202134','20202135','20202136','20202137','20202138','20202139','20202140','20202141','20202142','20202143','20202144','20202145','20202147','20202148','20202201','20202202','20202203','20202204','20202205','20202206','20202207','20202208','20202209','20202210','20202211','20202212','20202213','20202214','20202215','20202216','20202217','20202218','20202219','20202220','20202221','20202222','20202223','20202224','20202225','20202226','20202227','20202228','20202229','20202230','20202231','20202232','20202233','20202234','20202235','20202236','20202237','20202238','20202239','20202240','20202241','20202242','20202243','20202244','20202245','20202246','20202248','20202301','20202302','20202303','20202304','20202305','20202306','20202307','20202308','20202309','20202310','20202312','20202313','20202314','20202315','20202316','20202317','20202318','20202319','20202320','20202321','20202322','20202323','20202324','20202325','20202326','20202327','20202328','20202329','20202330','20202331','20202332','20202333','20202334','20202335','20202337','20202338','20202339','20202340','20202341','20202342','20202343','20202344','20202345','20202346','20202401','20202402','20202403','20202404','20202405','20202406','20202407','20202408','20202409','20202410','20202412','20202413','20202414','20202415','20202416','20202417','20202418','20202419','20202420','20202421','20202422','20202423','20202424','20202425','20202426','20202427','20202428','20202429','20202430','20202431','20202432','20202433','20202434','20202435','20202436','20202437','20202438','20202439','20202440','20202441','20202442','20202443','20202444','20202445','20202446','20202447','20202448','20202449','20202450','20202501','20202502','20202503','20202504','20202506','20202507','20202508','20202509','20202510','20202511','20202512','20202513','20202514','20202515','20202516','20202517','20202518','20202519','20202520','20202521','20202522','20202523','20202524','20202525','20202526','20202527','20202528','20202529','20202530','20202531','20202532','20202533','20202534','20202535','20202536','20202537','20202538','20202539','20202540','20202541','20202542','20202543','20202544','20202545','20202546','20202601','20202602','20202603','20202604','20202605','20202606','20202607','20202608','20202609','20202610','20202611','20202612','20202613','20202614','20202615','20202616','20202617','20202618','20202619','20202620','20202621','20202622','20202623','20202624','20202625','20202626','20202627','20202628','20202629','20202630','20202631','20202633','20202634','20202635','20202636','20202637','20202638','20202639','20202640','20202641','20202642','20202643','20202644','20202645','20202701','20202702','20202703','20202704','20202705','20202706','20202707','20202708','20202709','20202710','20202711','20202712','20202713','20202714','20202715','20202716','20202717','20202718','20202719','20202720','20202721','20202722','20202723','20202724','20202725','20202726','20202727','20202728','20202729','20202730','20202731','20202732','20202733','20202734','20202735','20202736','20202737','20202738','20202739','20202740','20202741','20202742','20202743','20202747','20202801','20202802','20202803','20202804','20202805','20202806','20202807','20202808','20202809','20202810','20202811','20202812','20202813','20202814','20202815','20202816','20202817','20202818','20202819','20202820','20202821','20202822','20202823','20202824','20202825','20202826','20202827','20202828','20202829','20202830','20202831','20202832','20202833','20202834','20202835','20202836','20202837','20202838','20202839','20202840','20202841','20202842','20202843','20202844','20202845','20202846','20202847','20202901','20202902','20202903','20202904','20202905','20202906','20202907','20202908','20202909','20202910','20202911','20202912','20202913','20202914','20202915','20202916','20202917','20202918','20202919','20202920','20202921','20202922','20202923','20202924','20202925','20202926','20202927','20202928','20202929','20202930','20202931','20202932','20202933','20202934','20202935','20202936','20202937','20202938','20202939','20202940','20202941','20202942','20202943','20202944','20203001','20203002','20203003','20203004','20203005','20203006','20203007','20203008','20203009','20203010','20203011','20203012','20203013','20203014','20203015','20203016','20203017','20203018','20203019','20203020','20203021','20203022','20203023','20203024','20203025','20203026','20203027','20203028','20203029','20203030','20203031','20203032','20203033','20203034','20203035','20203036','20203037','20203039','20203040','20203041','20203042','20203043','20203044','20203046','20203101','20203102','20203103','20203104','20203105','20203106','20203107','20203108','20203109','20203110','20203111','20203112','20203113','20203114','20203115','20203116','20203117','20203118','20203119','20203120','20203121','20203122','20203123','20203124','20203125','20203126','20203127','20203128','20203129','20203130','20203131','20203132','20203133','20203134','20203135','20203136','20203137','20203138','20203139','20203140','20203141','20203142','20203143','20203144','20203145','20203146','20203201','20203202','20203203','20203204','20203205','20203207','20203208','20203209','20203210','20203211','20203212','20203213','20203214','20203215','20203216','20203217','20203218','20203220','20203221','20203222','20203223','20203224','20203225','20203226','20203227','20203228','20203229','20203230','20203231','20203232','20203233','20203234','20203235','20203236','20203237','20203238','20203239','20203240','20203241','20203242','20203243','20203244','20203245','20203246','20203247') and c.code='Class-fzpdzz' ";
- List<ArtEvaluation> infos = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ArtEvaluation>(queryText: sql))
- {
- infos.Add(item);
- }
- //List<Task<ItemResponse<ExamInfo>>> tasks = new List<Task<ItemResponse<ExamInfo>>>();
- List<string> ids = infos.Select(x => x.id).ToList();
- List<StudentArtResult> examClassResults = new List<StudentArtResult>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
- queryText: $"select value(c) from c where c.pk = 'ArtResult' and c.artId in ({string.Join(",", ids.Select(o => $"'{o}'"))})"))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- examClassResults.Add(obj.ToObject<StudentArtResult>());
- }
- }
- }
- List<(string classId,string name)> classes = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
- queryText: $"select value(c) from c where c.pk = 'Class'"))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- obj.TryGetProperty("id", out JsonElement classId);
- obj.TryGetProperty("name", out JsonElement name);
- classes.Add((classId.GetString(),name.GetString()));
- }
- }
- }
- List<(string id,string stuName,string school, string name, double values, List<ArtSubjectScore> scores, List<(string subjectId, string quotaName, double score)> results)> students = new();
- foreach (StudentArtResult classResult in examClassResults)
- {
- List<(string subjectId, string quotaName,double score)> results = new();
- foreach (var rst in classResult.results) {
- results.Add((rst.subjectId, rst.quotaName, rst.score));
- }
- students.Add((classResult.studentId,classResult.studentName,classResult.school, classResult.classIds[0], classResult.totalScore,classResult.subjectScores, results));
- }
- var stus = students.Select(x => new {
- x.id,
- x.stuName,
- x.school,
- x.name,
- className = classes.Where(c => c.classId.Equals(x.name))?.FirstOrDefault().name,
- x.values,
- x.scores.Where(c => c.subjectId.Equals("subject_music")).FirstOrDefault()?.score,
- quotaName = x.results.Where(c => c.subjectId.Equals("subject_music")).Select(z => new {
- z.quotaName,
- z.score
- })
-
- });
- return Ok(stus);
- }
- [ProducesDefaultResponseType]
- [HttpPost("update-score")]
- public async Task<IActionResult> FixScore(JsonElement req)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = "SELECT c.id FROM c join A0 in c.papers where A0.id = 'ea54f54a-faf3-9fac-6609-dad8b75f9fd6' and c.pk = 'Exam' ";
- List<string> ids = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryStreamIterator(queryText: sql))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- obj.TryGetProperty("id", out JsonElement id);
- ids.Add(id.GetString());
- }
- }
- }
- List<ExamClassResult> classResults = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIterator<ExamClassResult>(queryText: $"select * from c where c.examId in ({string.Join(",", ids.Select(o => $"'{o}'"))}) and c.pk = 'ExamClassResult' "))
- {
- classResults.Add(item);
- }
- List<Task<ItemResponse<ExamClassResult>>> tasks = new List<Task<ItemResponse<ExamClassResult>>>();
- foreach (ExamClassResult info in classResults)
- {
- int n = 0;
- foreach (string stu in info.studentIds) {
- if (info.status[n] == 1)
- {
- n++;
- continue;
- }
- info.studentScores[n][2] = 7;
- info.studentScores[n][7] = 7;
- info.studentScores[n][9] = 7;
- info.studentScores[n][13] = 6;
- info.studentScores[n][14] = 6;
- n++;
- }
- tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(info, info.id, new PartitionKey(info.code)));
- }
- await tasks.TaskPage(10);
- return Ok();
- }
- /// <summary>
- /// 修复能力点学习记录中 nodeid taskid为空的数据
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("fix-nodeid-taskid")]
- public async Task<IActionResult> FixNodeIdTaskId(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = $"SELECT distinct value(c) FROM c join b in c.fileRecords join a in b.files where a.taskId =null or a.nodeId=null ";
- List<TeacherFile> teacherFiles = new List<TeacherFile>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherFile>(queryText: sql))
- {
- teacherFiles.Add(item);
- }
- teacherFiles.ForEach(x => {
- x.fileRecords.ForEach(y => {
- y.files.RemoveAll(x => x.taskId == null || x.nodeId == null);
- });
- });
- foreach (var a in teacherFiles)
- {
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(a, a.id, new PartitionKey(a.code));
- }
- return Ok(teacherFiles);
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("check-repeat-name")]
- public async Task<IActionResult> CheckRepeatName(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = $"SELECT distinct value(c) FROM c join b in c.schools where b.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'";
- List<Teacher> teachers = new();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
- {
- teachers.Add(item);
- }
- var group = teachers.SelectMany(x => x.binds).Select(y => y.userid).GroupBy(z => z).Select(m => new { key = m.Key, list = m.ToList() });
- Dictionary<string, dynamic> dict = new Dictionary<string, dynamic>();
- group.ToList().ForEach(x => {
- if (x.list.Count() > 1)
- {
- HashSet<Teacher> teacherR = new();
- teachers.ForEach(z => {
- z.binds.ForEach(y => {
- if (y.userid.Equals(x.key))
- {
- teacherR.Add(z);
- }
- });
- });
- dict.Add(x.key, teacherR.ToList().Select(x => new { x.name, x.id }));
- }
- });
- return Ok(dict);
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("set-admin")]
- public async Task<IActionResult> SetAdmin(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = $"SELECT value(c) FROM c where c.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'";
- Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1528783259", new PartitionKey("Base"));
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
- {
- var sc = teacher.schools.Find(x => x.schoolId.Equals(item.id));
- if (sc != null)
- {
- if (string.IsNullOrEmpty(sc.status) || !sc.status.Equals("join"))
- {
- sc.status = "join";
- }
- try
- {
- SchoolTeacher schoolTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(teacher.id, new PartitionKey($"Teacher-{sc.schoolId}"));
- if (schoolTeacher != null)
- {
- if (schoolTeacher.roles.IsEmpty() || !schoolTeacher.roles.Contains("admin"))
- {
- schoolTeacher.roles = new List<string> { "admin" };
- }
- schoolTeacher.status = "join";
- schoolTeacher.pk = "Teacher";
- schoolTeacher.name = teacher.name;
- schoolTeacher.picture = teacher.picture;
- schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- schoolTeacher.ttl = -1;
- schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty() ? schoolTeacher.permissions : new List<string>();
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher);
- }
- }
- catch (CosmosException ex)
- {
- SchoolTeacher schoolTeacher = new SchoolTeacher
- {
- id = teacher.id,
- code = $"Teacher-{sc.schoolId}",
- roles = new List<string> { "teacher" },
- permissions = new List<string>(),
- pk = "Teacher",
- name = teacher.name,
- picture = teacher.picture,
- status = "join",
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
- ttl = -1
- };
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher);
- }
- }
- else
- {
- teacher.schools.Add(new Teacher.TeacherSchool { schoolId = item.id, name = item.name, areaId = item.areaId, picture = item.picture, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), status = "join" });
- SchoolTeacher schoolTeacher = new SchoolTeacher
- {
- id = teacher.id,
- code = $"Teacher-{item.id}",
- roles = new List<string> { "admin", "teacher" },
- permissions = new List<string>(),
- pk = "Teacher",
- name = teacher.name,
- picture = teacher.picture,
- status = "join",
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
- };
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher);
- }
- }
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(teacher, teacher.id, new PartitionKey("Base"));
- return Ok();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("fix-teacher-statistics")]
- public async Task<IActionResult> FixTeacherStatistics(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
- string sql = $"SELECT distinct value(c) FROM c where c.pk='TeacherTrain' ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherTrain>(queryText: sql))
- {
- teacherTrains.Add(item);
- }
- foreach (var train in teacherTrains)
- {
- train.update.Add(StatisticsService.TeacherAbility);
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(train, train.id, new PartitionKey(train.code));
- }
- return Ok();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("fix-teacher-file")]
- public async Task<IActionResult> FixTeacherFile(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<TeacherFile> teacherFiles = new List<TeacherFile>();
- string sql = $"SELECT distinct value(c) FROM c join b in c.fileRecords where c.pk='TeacherFile' and b.type='video' and b.done=true and b.duration>0 and b.view<TRUNC(b.duration) ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherFile>(queryText: sql))
- {
- teacherFiles.Add(item);
- }
- foreach (var flie in teacherFiles)
- {
- var records = flie.fileRecords.FindAll(x => x.type.Equals("video") && x.duration > 0 && x.view < (int)x.duration);
- records.ForEach(x => { x.view = (int)x.duration; });
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(flie, flie.id, new PartitionKey(flie.code));
- TeacherTrain train = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherTrain>(flie.id, new PartitionKey($"TeacherTrain-{flie.code.Replace("TeacherFile-", "")}"));
- train.update.Add(StatisticsService.TeacherAbility);
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(train, train.id, new PartitionKey(train.code));
- }
- return Ok();
- }
- /// <summary>
- /// 批量导入自动加入学校
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("fix-joinschool")]
- public async Task<IActionResult> GenerateSchoolCodes(JsonElement json)
- {
- JsonElement _teachers = json.GetProperty("teachers");
- string jsons = _teachers.ToJsonString();
- jsons = Regex.Replace(jsons, @"\s", "");
- List<JoinSchool> joins = jsons.ToObject<List<JoinSchool>>();
- string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
-
- var tmdids = joins.Select(x => x.tmdid).ToList();
- var content = new StringContent(tmdids.ToJsonString(), Encoding.UTF8, "application/json");
- HttpResponseMessage responseMessage = await _httpClient.CreateClient().PostAsync(url, content);
- List<Teacher> ids = null;
- if (responseMessage.StatusCode == HttpStatusCode.OK)
- {
- string responseBody = responseMessage.Content.ReadAsStringAsync().Result;
- ids = responseBody.ToObject<List<Teacher>>();
- }
- if (ids.IsNotEmpty())
- {
- var school = joins.Select(x => x.schoolId);
- HashSet<string> scho = new HashSet<string>(school);
- string sql = $"select value(c) from c where c.id in ({string.Join(",", scho.Select(x => $"'{x}'"))})";
- List<School> schools = new List<School>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").
- GetItemQueryIterator<School>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
- {
- schools.Add(item);
- }
- var noexist = tmdids.Except(ids.Select(x => x.id));
- sql = $"select value(c) from c where c.id in ({string.Join(",", ids.Select(x => $"'{x.id}'"))})";
- List<Teacher> teachers = new List<Teacher>();
- List<Teacher> updTeachers = new List<Teacher>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").
- GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
- {
- teachers.Add(item);
- }
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- var nobinds = ids.Select(x => x.id).Except(teachers.Select(t => t.id)).ToList();
- foreach (var tch in teachers)
- {
- var join = joins.Find(x => x.tmdid.Equals(tch.id));
- if (join != null)
- {
- var joinschool = tch.schools.Find(x => x.schoolId.Equals(join.schoolId));
- if (joinschool == null)
- {
- var schoolInfo = schools.Find(x => x.id.Equals(join.schoolId));
- if (schoolInfo != null)
- {
- tch.defaultSchool = join.schoolId;
- tch.schools.Add(new Teacher.TeacherSchool { schoolId = join.schoolId, areaId = schoolInfo.areaId, name = schoolInfo?.name, picture = schoolInfo?.picture, status = "join", time = now });
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(tch, tch.id, new PartitionKey("Base"));
- updTeachers.Add(tch);
- }
- }
- }
- }
- HashSet<Teacher> changeTeacher = new HashSet<Teacher>();
- List<Teacher> addTeachers = new List<Teacher>();
- if (nobinds != null)
- {
- foreach (var tch in nobinds)
- {
- var teacher = ids.Find(x => x.id.Equals(tch));
- var join = joins.Find(x => x.tmdid.Equals(tch));
- var schoolInfo = schools.Find(x => x.id.Equals(join.schoolId));
- if (schoolInfo != null && teacher != null)
- {
- teacher.ttl = -1;
- teacher.pk = "Teacher";
- teacher.code = "Base";
- teacher.size = 2;
- teacher.schools = new List<Teacher.TeacherSchool> { new Teacher.TeacherSchool { schoolId = join.schoolId, areaId = schoolInfo.areaId, name = schoolInfo?.name, picture = schoolInfo?.picture, status = "join", time = now } };
- teacher.defaultSchool = schoolInfo?.id;
- List<string> roles = new List<string> { "teacher" };
- if (!string.IsNullOrEmpty(join.role) && join.role.Equals("admin"))
- {
- roles.Add("admin");
- }
- var container = _azureStorage.GetBlobContainerClient(teacher.id);
- await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
- teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
- addTeachers.Add(teacher);
- }
- }
- }
- foreach (var sch in schools)
- {
- StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
- List<GroupList> yxtrain = new List<GroupList>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryText.ToString(),
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{sch.id}") }))
- {
- yxtrain.Add(item);
- }
- if (yxtrain.IsNotEmpty())
- {
- var schjoins = joins.FindAll(x => x.schoolId.Equals(sch.id));
- schjoins.RemoveAll(x => noexist.Contains(x.tmdid));
- GroupList groupList = yxtrain[0];
- //不在研修名单
- schjoins = schjoins.FindAll(z => !yxtrain.SelectMany(x => x.members).Where(y => y.type == 1).Select(m => m.id).Contains(z.tmdid));
- if (schjoins.IsNotEmpty())
- {
- foreach (var schjoin in schjoins)
- {
- groupList.members.Add(new Member { id = schjoin.tmdid, type = 1 });
- }
- await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
- }
- }
- else
- {
- var schjoins = joins.FindAll(x => x.schoolId.Equals(sch.id));
- schjoins.RemoveAll(x => noexist.Contains(x.tmdid));
- if (schjoins.IsNotEmpty())
- {
- List<Member> members = new List<Member>();
- foreach (var schjoin in schjoins)
- {
- members.Add(new Member { id = schjoin.tmdid, type = 1 });
- }
- GroupList groupList = new GroupList()
- {
- id = Guid.NewGuid().ToString(),
- code = $"GroupList-{sch.id}",
- creatorId = schjoins[0].tmdid,
- type = "yxtrain",
- year = DateTimeOffset.UtcNow.Year,
- expire = 0,
- members = members,
- scope = "school",
- school = sch.id,
- name = "研修名单",
- pk = "GroupList",
- ttl = -1
- };
- await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
- }
- }
- var schtch = joins.FindAll(x => x.schoolId.Equals(sch.id));
- schtch.RemoveAll(x => noexist.Contains(x.tmdid));
- var tchs = teachers.FindAll(x => schtch.Select(x => x.tmdid).Contains(x.id));
- foreach (var joinc in tchs)
- {
- SchoolTeacher schoolTeacher = null;
- var join = joins.Find(x => x.tmdid.Equals(joinc.id));
- joinc.schools.ForEach(x => {
- if (x.schoolId.Equals(sch.id) && x.status.Equals("request"))
- {
- x.status = "join";
- changeTeacher.Add(joinc);
- }
- });
- List<string> roles = new List<string> { "teacher" };
- if (!string.IsNullOrEmpty(join.role) && join.role.Equals("admin"))
- {
- roles.Add("admin");
- }
- try
- {
- schoolTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(joinc.id, new PartitionKey($"Teacher-{join.schoolId}"));
- if (roles.Contains("admin") && !schoolTeacher.roles.Contains("admin"))
- {
- schoolTeacher.roles.Add("admin");
- }
- if (roles.Contains("teacher") && !schoolTeacher.roles.Contains("teacher"))
- {
- schoolTeacher.roles.Add("teacher");
- }
- schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty() ? schoolTeacher.permissions : new List<string>();
- schoolTeacher.status = "join";
- }
- catch (CosmosException)
- {
- schoolTeacher = new SchoolTeacher
- {
- id = joinc.id,
- name = joinc.name,
- picture = joinc.picture,
- code = $"Teacher-{sch.id}",
- pk = "SchoolTeacher",
- ttl = -1,
- size = 0,
- roles = roles,
- status = "join",
- createTime = now,
- permissions = new List<string>()
- };
- }
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
- }
- }
- foreach (var tch in changeTeacher)
- {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tch, tch.id, new PartitionKey("Base"));
- }
- return Ok(new { noexist, update = updTeachers, add = addTeachers });
- }
- return Ok(new { status = 404 });
- }
- public class JoinSchool
- {
- public string name { get; set; }
- public string schoolId { get; set; }
- public string mobile { get; set; }
- public string tmdid { get; set; }
- public string role { get; set; }
- }
- [ProducesDefaultResponseType]
- [HttpPost("fix-md5-duration")]
- public async Task<IActionResult> FixMD5Duration(JsonElement json)
- {
- json.TryGetProperty("standard", out JsonElement standard);
- json.TryGetProperty("abilityIds", out JsonElement _abilityIds);
- if (string.IsNullOrEmpty($"{standard}")
- && (!$"{standard}".Equals("standard1")
- || !$"{standard}".Equals("standard2")
- || !$"{standard}".Equals("standard3")
- || !$"{standard}".Equals("standard4")
- || !$"{standard}".Equals("standard7")))
- {
- return Ok();
- }
- var client = _azureStorage.GetBlobContainerClient($"teammodelos");
- await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/standard1/jyzx/15d96330-54d8-95fd-cf9a-8785836fad03"))
- {
- string hash = Md5Hash.GetbyteToString(item.Properties.ContentHash);
- Console.WriteLine($"{item.Name}-{hash}");
- }
- var CosmosClient = _azureCosmos.GetCosmosClient();
- HashSet<AbilityTask> abilityTasks = new HashSet<AbilityTask>();
- List<string> abilityIds = _abilityIds.ToObject<List<string>>();
- if (abilityIds.IsEmpty())
- {
- return Ok();
- }
- MD5 md5 = new MD5CryptoServiceProvider();
- string sql = $"select value(c) from c where c.abilityId in ({string.Join(",", abilityIds.Select(x => $"'{x}'"))}) ";
- await foreach (var item in CosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
- {
- var nodes = item.children.SelectMany(x => x.rnodes).Where(m => !m.type.Equals("link") && string.IsNullOrEmpty(m.hash));
- if (nodes != null && nodes.Count() > 0)
- {
- foreach (var node in item.children)
- {
- foreach (var r in node.rnodes)
- {
- if (!r.type.Equals("link") && (string.IsNullOrWhiteSpace(r.hash) || r.size == 0))
- {
- abilityTasks.Add(item);
- }
- }
- }
- }
- abilityTasks.Add(item);
- }
- foreach (var item in abilityTasks)
- {
- var nodes = item.children.SelectMany(x => x.rnodes).Where(m => !m.type.Equals("link") && string.IsNullOrEmpty(m.hash));
- if (nodes != null && nodes.Count() > 0)
- {
- foreach (var node in item.children)
- {
- foreach (var r in node.rnodes)
- {
- if (!r.type.Equals("link") && (string.IsNullOrWhiteSpace(r.hash) || r.size == 0))
- {
- BlobDownloadInfo blobDownload = await client.GetBlobClient(r.link).DownloadAsync(range: new HttpRange(0, 4 * 1048576), rangeGetContentHash: true);
- if (blobDownload.Details.ContentHash != null)
- {
- string hash = Md5Hash.GetbyteToString(blobDownload.Details.ContentHash);
- r.hash = hash;
- }
- //byte[] retVal = md5.ComputeHash(blobDownload.Content);
- //string hash = Md5Hash.GetbyteToString(retVal);
- //r.hash = hash;
- //r.size = blobDownload.Content.Length;
- }
- }
- }
- await CosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<AbilityTask>(item, item.id, new PartitionKey(item.code));
- }
- }
- return Ok(abilityTasks);
- }
- /// <summary>
- /// 修复能力点任务的资源节点的文件大小,hash值等。
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("fix-blobitem-md5")]
- public async Task<IActionResult> GetBlobitemMd5(JsonElement jsonMsg)
- {
- List<string> standards = new List<string>() { "standard1", "standard2", "standard3", "standard4" };
- var client = _azureStorage.GetBlobContainerClient($"teammodelos");
- var CosmosClient = _azureCosmos.GetCosmosClient();
- List<BlobFile> itemInfos = new List<BlobFile>();
- List<string> fils = new List<string>();
- foreach (var standard in standards)
- {
- await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{standard}/jyzx/"))
- {
- if (item.Properties.ContentHash.Length < 16)
- {
- fils.Add(item.Name);
- }
- string hash = Md5Hash.GetbyteToString(item.Properties.ContentHash);
- if (string.IsNullOrEmpty(hash))
- {
- fils.Add(item.Name);
- }
- var blobitem = itemInfos.Find(x => x.id.Equals(hash));
- if (blobitem != null)
- {
- blobitem.paths.Add(item.Name);
- }
- else
- {
- long? ContentLength = item.Properties.ContentLength;
- blobitem = new BlobFile() { code = $"BlobFile-{standard}", source = "standard", pk = "BlobFile", ttl = -1, id = hash, size = ContentLength != null ? ContentLength.Value : 0 };
- blobitem.paths.Add(item.Name);
- itemInfos.Add(blobitem);
- }
- }
- }
- List<Rnode> rnode = new List<Rnode>();
- foreach (var standard in standards)
- {
- List<AbilityTask> abilityTasks = new List<AbilityTask>();
- string sql = "select value(c) from c ";
- await foreach (var item in CosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-{standard}") }))
- {
- var nodes = item.children.SelectMany(x => x.rnodes).Where(m => !m.type.Equals("link") && string.IsNullOrEmpty(m.hash));
- if (nodes != null && nodes.Count() > 0)
- {
- foreach (var node in item.children)
- {
- foreach (var r in node.rnodes)
- {
- if (!r.type.Equals("link") && string.IsNullOrEmpty(r.hash))
- {
- string str = r.link.Substring(1);
- BlobFile itemInfo = itemInfos.Find(s => s.paths.Contains(str));
- if (itemInfo != null)
- {
- r.size = itemInfo.size;
- r.hash = itemInfo.id;
- }
- rnode.Add(r);
- }
- }
- node.rnodes.RemoveAll(x => x.hash == null);
- }
- await CosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- abilityTasks.Add(item);
- }
- }
- await _dingDing.SendBotMsg($"fix-blobitem-md5, {fils.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
- return Ok(new { rnode, itemInfos });
- }
- /// <summary>
- /// 修复学生的id
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-student-id")]
- public async Task<IActionResult> FixStudentId(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- var queryslt = $"SELECT value(c) FROM c ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: queryslt))
- {
- //item.id
- }
- return Ok();
- }
- /// <summary>
- /// 修复学生的id
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-school")]
- public async Task<IActionResult> FixSchool(JsonElement data)
- {
- List<string> arr = new List<string> {
- "pjzx",
- "pjsazx",
- "pjsywgyxx",
- "pjbjxx",
- "pjhszcjzx",
- "pjcyhzjnzxx",
- "pjxnxx",
- "pjthxx",
- "pjsazsmxx",
- "pjcyxx",
- "pjsazcjzx",
- "pjwxjnzxx",
- "ptsxxpjfx",
- "pjjysxx",
- "pjxlzjnzxx",
- "pjfxxx",
- "pjdtjnzxx",
- "pjgxzjnzxx",
- "pjcjzjnzxx",
- "pjdxjnzxx",
- "pjwjxx",
- "pjzyzx",
- "pjnjyey",
- "pjbjyey",
- "pjcbyey",
- "pjcxyey",
- "pjcnyey",
- "pjxj5hyey",
- "pjxlyey",
- "pjsazxyey",
- "pjsaxcyey",
- "pjthyey",
- "pjsmyey",
- "pjshyey",
- "pjwxyey",
- "pjjysyey",
- "pjfxyey",
- "pjgxyey",
- "pjcjyey",
- "pjcyhyey",
- "pjbyyey",
- "pjdtyey",
- "pjnjyeydxfy",
- "pjcxyeygmfy",
- "pjcbyeygqfy",
- "pjsaxcyeyzqfy",
- "pjxyheyey",
- "pjxhyey",
- "pjxbeyey",
- "pjhhzyey",
- "pjxxyey",
- "sazxgyey",
- "xlzlxyey",
- "dxzxmyey",
- "dtzxmyey",
- "dtzydyey"
- };
- var client = _azureCosmos.GetCosmosClient();
- foreach (var ar in arr)
- {
- SchoolTeacher teacher = new SchoolTeacher
- {
- id = "1528783259",
- code = $"Teacher-{ar}",
- picture = "https://corestorageservice.blob.core.windows.net/account/avatar/1528783259",
- name = "郭杰",
- job = "管理员",
- roles = new List<string> { "admin", "teacher" },
- status = "join",
- pk = "Teacher",
- ttl = -1,
- createTime = 1631703528741,
- };
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(teacher, partitionKey: new PartitionKey(teacher.code));
- }
- //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- //{
- // if (arr.Contains(item.id)) {
- // string periodid = Guid.NewGuid().ToString();
- // string campuses = Guid.NewGuid().ToString();
- // item.period = new List<Period> { new Period { name = "默认学段", id = periodid, campusId = campuses } };
- // item.campuses = new List<Campus> { new Campus { name = "本部", id = campuses } };
- // item.timeZone.label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐";
- // item.timeZone.value = "+08:00";
- // await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(item, item.id, new PartitionKey(item.code));
- // }
- //}
- return Ok();
- }
- /// <summary>
- /// 修复学生的id
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-teacher")]
- public async Task<IActionResult> FixTeacher(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<Teacher> teachers = new List<Teacher>();
- string sql = $"SELECT value(c) FROM c ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- teachers.Add(item);
- }
- List<School> schools = new List<School>(0);
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schools.Add(item);
- }
- teachers.ForEach(x => {
- x.schools.ForEach(y => {
- School? school = schools.Find(z => z.id.Equals(y.schoolId));
- if (school != null)
- {
- y.name = school.name;
- y.picture = school.picture;
- y.areaId = school.areaId;
- }
- });
- });
- foreach (var item in teachers)
- {
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey($"Base"));
- }
- return Ok();
- }
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-item")]
- public async Task<IActionResult> FixItem(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<School> schools = new List<School>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schools.Add(item);
- }
- Random random = new Random();
- foreach (var school in schools)
- {
- List<ItemInfo> items = new List<ItemInfo>();
- var queryslt = $"SELECT value(c) FROM c where c.pid = null ";
- List<ItemInfo> noPeriodId = new List<ItemInfo>();
- List<ItemInfo> noSubjectId = new List<ItemInfo>();
- List<ItemInfo> noGradeIds = new List<ItemInfo>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{school.id}") }))
- {
- if (string.IsNullOrEmpty(item.periodId))
- {
- noPeriodId.Add(item);
- }
- if (string.IsNullOrEmpty(item.subjectId))
- {
- noSubjectId.Add(item);
- }
- if (!item.gradeIds.IsNotEmpty())
- {
- noGradeIds.Add(item);
- }
- bool errorData = false;
- foreach (var x in item.gradeIds)
- {
- if (string.IsNullOrEmpty(x))
- {
- errorData = true;
- }
- }
- if (errorData)
- {
- List<string> grds = new List<string>();
- item.gradeIds.ForEach(x => {
- if (string.IsNullOrEmpty(x))
- {
- grds.Add($"{random.Next(0, 5)}");
- }
- else
- {
- grds.Add(x);
- }
- });
- item.gradeIds = grds;
- await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<ItemInfo>(item, item.id, new PartitionKey(item.code));
- }
- items.Add(item);
- }
- List<ItemInfo> unMatch = new List<ItemInfo>();
- foreach (var item in items)
- {
- bool match = false;
- school.period.ForEach(x =>
- {
- if (item.periodId.Equals(x.id))
- {
- if (x.subjects.Select(y => y.id).Contains(item.subjectId))
- {
- match = true;
- }
- }
- });
- if (!match)
- {
- unMatch.Add(item);
- }
- }
- if (noGradeIds.IsNotEmpty())
- {
- var ids = noGradeIds.Select(x => x.id);
- await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-{school.id}");
- foreach (var rm in noGradeIds)
- {
- items.Remove(rm);
- }
- }
- if (noPeriodId.IsNotEmpty())
- {
- var ids = noPeriodId.Select(x => x.id);
- await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-{school.id}");
- foreach (var rm in noPeriodId)
- {
- items.Remove(rm);
- }
- }
- if (noSubjectId.IsNotEmpty())
- {
- var ids = noSubjectId.Select(x => x.id);
- await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-{school.id}");
- foreach (var rm in noSubjectId)
- {
- items.Remove(rm);
- }
- }
- if (unMatch.IsNotEmpty())
- {
- var ids = unMatch.Select(x => x.id);
- await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<ItemInfo>(ids.ToList(), $"Item-{school.id}");
- foreach (var rm in unMatch)
- {
- items.Remove(rm);
- }
- }
- List<ItemCond> itemConds = new List<ItemCond>();
- items.GroupBy(x => x.periodId).Select(y => new { key = y.Key, list = y.ToList() }).ToList().ForEach(z =>
- {
- ItemCond cond = new ItemCond() { id = z.key, code = $"ItemCond-{school.id}", pk = "ItemCond", ttl = -1, count = z.list.Count, grades = new List<GradeCount>(), subjects = new List<SubjectItemCount>() };
- z.list.ForEach(y =>
- {
- ItemService.CountItemCond(y, null, cond);
- });
- itemConds.Add(cond);
- });
- itemConds.ForEach(async cond =>
- {
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(cond, new PartitionKey(cond.code));
- });
- }
- return Ok(new { });
- }
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-item-teacher")]
- public async Task<IActionResult> FixItemTeacher(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<Teacher> teachers = new List<Teacher>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: "SELECT value(c) FROM c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- teachers.Add(item);
- }
- Random random = new Random();
- foreach (var teacher in teachers)
- {
- List<ItemInfo> items = new List<ItemInfo>();
- var queryslt = $"SELECT value(c) FROM c where c.pid = null ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{teacher.id}") }))
- {
- items.Add(item);
- }
- List<ItemInfo> unMatch = new List<ItemInfo>();
- ItemCond cond = new ItemCond() { id = teacher.id, code = $"ItemCond", pk = "ItemCond", ttl = -1, count = items.Count };
- items.ForEach(z =>
- {
- ItemService.CountItemCond(z, null, cond);
- });
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<ItemCond>(cond, new PartitionKey(cond.code));
- }
- return Ok(new { });
- }
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-activity-art")]
- public async Task<IActionResult> FixActivityArt(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<StuActivity> activities = new List<StuActivity>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuActivity>(queryText: "SELECT value(c) FROM c where c.pk = 'Activity' and c.type = 'Atr'"))
- {
- activities.Add(item);
- }
- foreach (var activity in activities)
- {
- activity.type = "Art";
- await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(activity, activity.id,new PartitionKey(activity.code));
- }
- return Ok(new { });
- }
- /// <summary>
- /// 修复名单的scope,school,creatorid
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-stulist-scope&school&creatorid")]
- public async Task<IActionResult> FixStulist(JsonElement data)
- {
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- //先处理未关联课程的教师私人名单
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: "select value(c) from c ", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("StuList") }))
- {
- string scdsql = $"SELECT value(A1) FROM c join A1 in c.schedule where A1.stulist='{item.id}'";
- int count = 0;
- await foreach (var schedule in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Schedule>(queryText: scdsql))
- {
- count += 1;
- }
- if (count == 0)
- {
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(item.id, new PartitionKey("StuList"));
- }
- }
- HashSet<string> plistId = new HashSet<string>();
- List<KeyValuePair<string, string>> pkeyValuePairs = new List<KeyValuePair<string, string>>();
- List<StuList> pstuLists = new List<StuList>();
- //List<Course> pcourses = new List<Course>();
- //处理私人名单
- string sql = "select value(c) from c where c.pk='Course' ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: sql))
- {
- if (item.schedule.IsNotEmpty())
- {
- foreach (var scd in item.schedule)
- {
- if (!string.IsNullOrEmpty(scd.stulist))
- {
- plistId.Add(scd.stulist);
- var tmdid = item.code.Replace("Course-", "");
- pkeyValuePairs.Add(new KeyValuePair<string, string>(scd.stulist, tmdid));
- item.creatorId = tmdid;
- item.scope = "private";
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- }
- }
- }
- List<string> pfaildId = new List<string>();
- foreach (var list in plistId)
- {
- try
- {
- StuList stuList = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuList>(list, new PartitionKey("StuList"));
- var a = pkeyValuePairs.Where(x => x.Key == list).FirstOrDefault();
- if (stuList.students.IsNotEmpty())
- {
- stuList.school = stuList.students[0].code.Replace("Base-", "");
- }
- stuList.creatorId = a.Value;
- stuList.scope = "private";
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuList>(stuList, list, new PartitionKey("StuList"));
- }
- catch (CosmosException ex)
- {
- pfaildId.Add(list);
- }
- }
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-stulist-scope&school&creatorid()\n修复失败私人的名单pfaildId:\n {pfaildId.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
- //处理学校的名单
- HashSet<string> slistId = new HashSet<string>();
- List<KeyValuePair<string, string>> skeyValuePairs = new List<KeyValuePair<string, string>>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: sql))
- {
- if (item.schedule.IsNotEmpty())
- {
- foreach (var scd in item.schedule)
- {
- if (!string.IsNullOrEmpty(scd.stulist))
- {
- slistId.Add(scd.stulist);
- var school = item.code.Replace("Course-", "");
- skeyValuePairs.Add(new KeyValuePair<string, string>(scd.stulist, school));
- item.scope = "school";
- item.school = school;
- await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- }
- }
- }
- List<string> sfaildId = new List<string>();
- foreach (var list in skeyValuePairs)
- {
- try
- {
- StuList stuList = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<StuList>(list.Key, new PartitionKey($"StuList-{list.Value}"));
- stuList.scope = "school";
- stuList.school = list.Value;
- await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<StuList>(stuList, list.Key, new PartitionKey(stuList.code));
- }
- catch (CosmosException ex)
- {
- sfaildId.Add(list.Key);
- }
- }
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-stulist-scope&school&creatorid()\n修复失败学校的的名单sfaildId:\n {sfaildId.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
- return Ok(new { });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-stulist-scope&school&creatorid()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 修复blob容器逻辑
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-blob-content")]
- public async Task<IActionResult> FixBlobContent(JsonElement data)
- {
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- await FixDataService.FixBlobContent(client, _dingDing, _azureStorage, data);
- return Ok(new { });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-blob-content()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- public class SchoolIdSid
- {
- public string id { get; set; }
- public string sid { get; set; }
- public string name { get; set; }
- }
- /// <summary>
- /// 修复blob容器逻辑
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-long-schoolid")]
- public async Task<IActionResult> FixLongSchoolId(JsonElement data)
- {
- try
- {
- //{\"id\":\"cdqcsxx\",\"sid\":\"qcsxx\",\"name\":\"青城山学校\"},
- //{\"id\":\"xagxdsbxx\",\"sid\":\"xagxsb\",\"name\":\"西安高新第十八小学\"},{\"id\":\"xajkdbxx\",\"sid\":\"xajkbx\",\"name\":\"西安经开第八小学\"}
- List<JsonElement> elements = new List<JsonElement>();
- // string josn = "[{\"id\":\"pjsywgyxx\",\"sid\":\"psywgy\",\"name\":\"蒲江实验外国语小学\"},{\"id\":\"pjhszcjzx\",\"sid\":\"hscjzx\",\"name\":\"蒲江鹤山镇初级中学\"},{\"id\":\"pjcyhzjnzxx\",\"sid\":\"cyhjnz\",\"name\":\"蒲江朝阳湖镇九年制学校\"},{\"id\":\"pjsazsmxx\",\"sid\":\"psasmx\",\"name\":\"蒲江寿安镇寿民小学\"},{\"id\":\"pjsazcjzx\",\"sid\":\"psacjz\",\"name\":\"蒲江寿安镇初级中学\"},{\"id\":\"pjwxjnzxx\",\"sid\":\"pwxjnx\",\"name\":\"蒲江五星九年制学校\"},{\"id\":\"ptsxxpjfx\",\"sid\":\"pptsfx\",\"name\":\"泡桐树小学蒲江分校(蒲江松华小学)\"},{\"id\":\"pjjysxx\",\"sid\":\"pjjysx\",\"name\":\"蒲江金钥匙学校\"},{\"id\":\"pjxlzjnzxx\",\"sid\":\"xlzjnx\",\"name\":\"蒲江西来镇九年制学校\"},{\"id\":\"pjdtjnzxx\",\"sid\":\"pdtjnx\",\"name\":\"蒲江大塘九年制学校\"},{\"id\":\"pjgxzjnzxx\",\"sid\":\"pgxjnx\",\"name\":\"蒲江甘溪镇九年制学校\"},{\"id\":\"pjcjzjnzxx\",\"sid\":\"pcjjnx\",\"name\":\"蒲江成佳镇九年制学校\"},{\"id\":\"pjdxjnzxx\",\"sid\":\"pdxjnx\",\"name\":\"蒲江大兴九年制学校\"},{\"id\":\"pjnjyey\",\"sid\":\"pnjyey\",\"name\":\"蒲江南街幼儿园\"},{\"id\":\"pjbjyey\",\"sid\":\"pbjyey\",\"name\":\"蒲江北街幼儿园\"},{\"id\":\"pjcbyey\",\"sid\":\"pcbyey\",\"name\":\"蒲江城北幼儿园\"},{\"id\":\"pjcxyey\",\"sid\":\"pcxyey\",\"name\":\"蒲江城西幼儿园\"},{\"id\":\"pjcnyey\",\"sid\":\"pcnyey\",\"name\":\"蒲江城南幼儿园\"},{\"id\":\"pjxj5hyey\",\"sid\":\"xjwhye\",\"name\":\"蒲江熙锦5号幼儿园\"},{\"id\":\"pjxlyey\",\"sid\":\"pxlyey\",\"name\":\"蒲江西来幼儿园\"},{\"id\":\"pjsazxyey\",\"sid\":\"sazxye\",\"name\":\"蒲江寿安中心幼儿园\"},{\"id\":\"pjsaxcyey\",\"sid\":\"saxcye\",\"name\":\"蒲江寿安新城幼儿园\"},{\"id\":\"pjthyey\",\"sid\":\"pthyey\",\"name\":\"蒲江天华幼儿园\"},{\"id\":\"pjsmyey\",\"sid\":\"psmyey\",\"name\":\"蒲江寿民幼儿园\"},{\"id\":\"pjshyey\",\"sid\":\"pshyey\",\"name\":\"蒲江松华幼儿园\"},{\"id\":\"pjwxyey\",\"sid\":\"pwxyey\",\"name\":\"蒲江五星幼儿园\"},{\"id\":\"pjjysyey\",\"sid\":\"pjysye\",\"name\":\"蒲江金钥匙幼儿园\"},{\"id\":\"pjfxyey\",\"sid\":\"pfxyey\",\"name\":\"蒲江复兴幼儿园\"},{\"id\":\"pjgxyey\",\"sid\":\"pgxyey\",\"name\":\"蒲江甘溪幼儿园\"},{\"id\":\"pjcjyey\",\"sid\":\"pcjyey\",\"name\":\"蒲江成佳幼儿园\"},{\"id\":\"pjcyhyey\",\"sid\":\"pcyhye\",\"name\":\"蒲江朝阳湖幼儿园\"},{\"id\":\"pjbyyey\",\"sid\":\"pbyyey\",\"name\":\"蒲江白云幼儿园\"},{\"id\":\"pjdtyey\",\"sid\":\"pdtyey\",\"name\":\"蒲江大塘幼儿园\"},{\"id\":\"pjnjyeydxfy\",\"sid\":\"njyedx\",\"name\":\"蒲江南街幼儿园大兴分园\"},{\"id\":\"pjcxyeygmfy\",\"sid\":\"cxyegm\",\"name\":\"蒲江城西幼儿园光明分园\"},{\"id\":\"pjcbyeygqfy\",\"sid\":\"cbyrgq\",\"name\":\"蒲江城北幼儿园高桥分园\"},{\"id\":\"pjsaxcyeyzqfy\",\"sid\":\"saxyqf\",\"name\":\"蒲江寿安新城幼儿园长秋分园\"},{\"id\":\"pjxyheyey\",\"sid\":\"xyheye\",\"name\":\"星源慧恩幼儿园\"},{\"id\":\"pjxhyey\",\"sid\":\"xhyey\",\"name\":\"仙鹤幼儿园\"},{\"id\":\"pjxbeyey\",\"sid\":\"xbeyey\",\"name\":\"轩贝尔幼儿园\"},{\"id\":\"pjhhzyey\",\"sid\":\"hhzyey\",\"name\":\"好孩子幼儿园\"},{\"id\":\"pjxxyey\",\"sid\":\"xxyey\",\"name\":\"新星幼儿园\"},{\"id\":\"sazxgyey\",\"sid\":\"saxgye\",\"name\":\"寿安镇星光幼儿园\"},{\"id\":\"xlzlxyey\",\"sid\":\"xllxye\",\"name\":\"西来镇李霞幼儿园\"},{\"id\":\"dxzxmyey\",\"sid\":\"dxxmye\",\"name\":\"大兴镇新苗幼儿园\"},{\"id\":\"dtzxmyey\",\"sid\":\"dtxmye\",\"name\":\"大塘镇新苗幼儿园\"},{\"id\":\"dtzydyey\",\"sid\":\"dtydye\",\"name\":\"大塘镇雨朵幼儿园\"},{\"id\":\"jnqzhjyzzjspxb\",\"sid\":\"jnzzjy\",\"name\":\"金牛区智慧教育种子教师培训班\"}]";
- string josn = "[{\"id\":\"xagxdsbxx\",\"sid\":\"xagxsb\",\"name\":\"西安高新第十八小学\"},{\"id\":\"xajkdbxx\",\"sid\":\"xajkbx\",\"name\":\"西安经开第八小学\"}]";
- List<SchoolIdSid> schools = josn.ToObject<List<SchoolIdSid>>();
- var client = _azureCosmos.GetCosmosClient();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: "select value(c) from c ", requestOptions: new QueryRequestOptions() { }))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- List<string> ids = schools.Select(x => x.id).ToList();
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- string s = obj.ToJsonString();
- IdCode idcode = s.ToObject<IdCode>();
- foreach (var id in ids)
- {
- if (idcode.id.Contains(id) || idcode.code.Contains(id))
- {
- await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(idcode.id, new PartitionKey(idcode.code));
- elements.Add(s.ToObject<JsonElement>());
- }
- }
- }
- }
- }
- return Ok(new { elements });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-blob-content()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- public class IdCode
- {
- public string id { get; set; }
- public string code { get; set; }
- }
- public class CSchool
- {
- public string id { get; set; }
- public string name { get; set; }
- public string admin { get; set; }
- public List<string> period { get; set; } = new List<string>();
- public int size { get; set; } = 100;
- }
- /// <summary>
- /// 修复blob容器逻辑
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("create-school")]
- public async Task<IActionResult> CreateSchool(JsonElement data)
- {
- try
- {
- List<CSchool> schools = new List<CSchool>() {
- new CSchool{
- id="sqtszx",
- name="四川师范大学附属青台山中学",
- admin="1530606136",
- period=new List<string>(){ "初中","高中"},
- size=100,
- }
- };
- var client = _azureCosmos.GetCosmosClient();
- foreach (var sc in schools)
- {
- List<Period> periods = new List<Period>();
- string campusId = Guid.NewGuid().ToString();
- sc.period.ForEach(x => {
- periods.Add(new Period { id = Guid.NewGuid().ToString(), name = x, campusId = campusId });
- });
- School school = new School
- {
- id = sc.id,
- name = sc.name,
- size = sc.size,
- code = "Base",
- campuses = new List<Campus> { new Campus { name = sc.name, id = campusId } },
- region = "中国",
- province = "四川",
- city = "成都",
- timeZone = new SDK.Models.TimeZone { label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐", value = "+08:00" },
- type = 2,
- pk = "School",
- ttl = -1,
- schoolCode = sc.id,
- period = periods
- };
- await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(school, new PartitionKey(school.code));
- Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(sc.admin, new PartitionKey("Base"));
- teacher.schools.Add(new Teacher.TeacherSchool { schoolId = sc.id, name = sc.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, sc.admin, new PartitionKey("Base"));
- SchoolTeacher schoolTeacher = new SchoolTeacher
- {
- id = sc.admin,
- code = $"Teacher-{sc.id}",
- roles = new List<string> { "admin", "teacher" },
- job = "管理员",
- name = teacher.name,
- picture = teacher.picture,
- status = "join",
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
- pk = "Teacher",
- ttl = -1,
- };
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
- }
- return Ok(new { });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-blob-content()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 修复blob容器逻辑
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-student-info")]
- public async Task<IActionResult> FixStudentInfo(JsonElement data)
- {
- try
- {
- var client = _azureCosmos.GetCosmosClient();
- var list = await FixDataService.FixStudentInfo(client, _dingDing, _azureStorage, data);
- return Ok(new { list });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-blob-content()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 修正學段ID非英數邏輯
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-periodid")]
- public async Task<IActionResult> FixPeriodid(JsonElement data)
- {
- try
- {
- if (!data.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
- string schoolCode = school_code.GetString();
- var client = _azureCosmos.GetCosmosClient();
- //學校 Base
- List<string> periodList = await FixDataService.FixSchoolPeriodId(client, schoolCode);
- if (periodList.Count > 0)
- {
- string periodId = periodList[0]; //修正的問題校都只有一個學段,以第一個學段ID為其餘資料的學段ID
- Dictionary<string, string> dataDic = new Dictionary<string, string>();
- dataDic["periodId"] = periodId;
- //班級 Class
- List<string> fixClassIdList = await FixDataService.FixClassInfo(client, schoolCode, dataDic);
- //課程 Course
- List<string> fixCourseIdList = await FixDataService.FixCourseInfo(client, schoolCode, dataDic);
- //知識點 Knowledge
- List<string> fixKnowledgeIdList = await FixDataService.FixKnowledgeInfo(client, schoolCode, dataDic);
- //試題 Item
- List<string> fixItemIdList = await FixDataService.FixItemInfo(client, schoolCode, dataDic);
- //試卷 Paper
- List<string> fixPaperIdList = await FixDataService.FixPaperInfo(client, schoolCode, dataDic);
- //課綱 Volume
- List<string> fixVolumeIdList = await FixDataService.FixVolumeInfo(client, schoolCode, dataDic);
- //評測 Exam
- List<string> fixExamIdList = await FixDataService.FixExamInfo(client, schoolCode, dataDic);
- //學生 Student
- List<string> fixStudentIdList = await FixDataService.FixStudentInfo(client, schoolCode, dataDic);
- return Ok(new { schoolCode, fixClassIdList, fixCourseIdList, fixKnowledgeIdList, fixItemIdList, fixPaperIdList, fixVolumeIdList, fixExamIdList, fixStudentIdList });
- }
- else
- {
- string message = "No period is changed";
- return Ok(new { message });
- }
- }
- catch (Exception ex)
- {
- //await _dingDing.SendBotMsg($"TEAMModelFunction,ActivityHttpTrigger,fix-periodid()\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 修复评测publish字段内容
- /// </summary>
- /// <param name="req"></param>
- /// <param name="log"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-exam-publish")]
- public async Task<IActionResult> FixExamPublish(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<string> infos = await FixDataService.FixExamPublish(client, _dingDing, data, _option);
- return Ok(new { infos });
- }
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-exam-class-result")]
- public async Task<IActionResult> FixExamClassResult(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<string> infos = await FixDataService.FixExamClassResult(client, data, _dingDing, _coreAPIHttpService, _option);
- return Ok(new { infos });
- }
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-school-type")]
- public async Task<IActionResult> FixSchoolType(JsonElement data)
- {
- var client = _azureCosmos.GetCosmosClient();
- List<string> infos = await FixDataService.FixSchoolType(client, data, _dingDing, _coreAPIHttpService, _option);
- return Ok(new { infos });
- }
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("fix-lesson-count")]
- public async Task<IActionResult> FixLessonCount(JsonElement data)
- {
- if (!data.TryGetProperty("code", out JsonElement code)) return BadRequest();
- var client = _azureCosmos.GetCosmosClient();
- var queryClass = $"select value(c) from c";
- List<LessonRecord> records = new List<LessonRecord>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{code}") }))
- {
- records.Add(item);
- }
- List<string> infos = new();
- foreach (LessonRecord lesson in records) {
- LessonDis dis = new();
- dis = LessonService.DisLessonCount_2(null, lesson, dis);
- await LessonService.FixLessonCount(client, _dingDing, lesson, null, dis);
- }
- return Ok(new { infos });
- }
- /// <summary>
- /// add admin
- /// </summary>
- /// <param name="req"></param>
- /// <param name="log"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpPost("add-area-school-admin")]
- public async Task<IActionResult> AddAreaSchoolAdmin(JsonElement data)
- {
- List<School> errorSchool = new List<School>();
- var client = _azureCosmos.GetCosmosClient();
- List<string> tmdids = data.GetProperty("tmdids").ToObject<List<string>>();
- data.TryGetProperty("areaId", out JsonElement areaId);
- data.TryGetProperty("schoolIds", out JsonElement schoolIds);
- data.TryGetProperty("addSchool", out JsonElement addSchool);
- data.TryGetProperty("areaAdmin", out JsonElement areaAdmin);
- List<string> ids = new List<string>();
- string idsSql = "";
- if (schoolIds.ValueKind.Equals(JsonValueKind.Array))
- {
- ids = schoolIds.ToObject<List<string>>();
- if (ids.IsNotEmpty())
- {
- idsSql = $" c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))})";
- }
- }
- List<School> schools = new List<School>();
- if (addSchool.ValueKind.Equals(JsonValueKind.Array))
- {
- List<School> codes = new();
- codes = addSchool.ToObject<List<School>>();
- List<School> schoolsNew = new List<School>();
- string _areaId = null;
- if (!string.IsNullOrWhiteSpace($"{areaId}"))
- {
- _areaId = $"{areaId}";
- }
- int scale = 0;
- data.TryGetProperty("scale", out JsonElement _scale);
- if (!string.IsNullOrWhiteSpace($"{_scale}"))
- {
- int.TryParse($"{_scale}", out scale);
- }
- int size = 0;
- data.TryGetProperty("size", out JsonElement _size);
- if (!string.IsNullOrWhiteSpace($"{_size}"))
- {
- int.TryParse($"{_size}", out size);
- }
- codes.ForEach(x => {
- string campusId = Guid.NewGuid().ToString();
- List<Period> periods = new List<Period>();
- periods.Add(new Period
- {
- id = Guid.NewGuid().ToString(),
- name = x.name,
- campusId = campusId,
- semesterCount = 2,
- gradeCount = 1,
- grades = new List<string> { "一年级" },
- subjectCount = 1,
- subjects = new List<Subject> { new Subject { name = "预设学科", id = Guid.NewGuid().ToString() } },
- semesters = new List<Semester>
- {
- new Semester { name = "上学期", start = 1, month = 9, day = 1, id = Guid.NewGuid().ToString() },
- new Semester { name = "下学期", start = 0, month = 3, day = 1, id = Guid.NewGuid().ToString() }
- },
- });
- School school = new School
- {
- id = x.id,
- name = x.name,
- size = size,
- code = "Base",
- campuses = new List<Campus> { new Campus { name = x.name, id = campusId } },
- region = "中国",
- province = x.province,
- city = $"{x.city}",
- timeZone = new SDK.Models.TimeZone { label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐", value = "+08:00" },
- type = 1,
- pk = "School",
- ttl = -1,
- schoolCode = x.id,
- dist = $"{x.dist}",
- period = periods,
- areaId = String.IsNullOrWhiteSpace($"{areaId}") ? null : $"{areaId}",
- standard = $"standard2"
- };
- schoolsNew.Add(school);
- });
- foreach (var sch in schoolsNew) {
- try
- {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(sch, new PartitionKey("Base"));
- schools.Add(sch);
- }
- catch (CosmosException ex) {
- errorSchool.Add(sch);
- }
- }
- }
- string areaIdsql = string.IsNullOrWhiteSpace($"{areaId}") ? "-0000000" : $"{areaId}";
- string sql = $"select distinct value(c) from c where {idsSql}";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(
- queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schools.Add(item);
- }
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- Azure.Response responseArea = await client.GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync($"{areaId}", new PartitionKey("Base-Area"));
- Area area = null;
- if (responseArea.Status == 200)
- {
- area = JsonDocument.Parse(responseArea.ContentStream).RootElement.ToObject<Area>();
- }
- List<Teacher> teachers = new List<Teacher>();
- List<SchoolTeacher> schoolsTeachers = new List<SchoolTeacher>();
- foreach (var tmdid in tmdids)
- {
- Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<Teacher>(tmdid, new PartitionKey("Base"));
- if (areaAdmin.ValueKind.Equals(JsonValueKind.True) && !string.IsNullOrWhiteSpace($"{areaId}") && area != null)
- {
- if (teacher.areas.IsNotEmpty())
- {
- if (!teacher.areas.Select(x => x.areaId).Contains(area.id))
- {
- teacher.areas.Add(new Teacher.TeacherArea { areaId = area.id, name = area.name, status = "join" });
- }
- }
- else
- {
- teacher.areas = new List<Teacher.TeacherArea> { new Teacher.TeacherArea { areaId = area.id, name = area.name, status = "join" } };
- }
- }
- foreach (var school in schools)
- {
- if (!string.IsNullOrWhiteSpace($"{areaId}")) {
- school.areaId = $"{areaId}";
- }
- data.TryGetProperty("scale", out JsonElement _scale);
- if (!string.IsNullOrWhiteSpace($"{_scale}"))
- {
- int scale = 0;
- int.TryParse($"{_scale}", out scale);
- if (scale > 0) {
- school.scale = scale;
- }
- }
- data.TryGetProperty("size", out JsonElement _size);
- if (!string.IsNullOrWhiteSpace($"{_size}"))
- {
- int size = 0;
- int.TryParse($"{_size}", out size);
- if (size > 0)
- {
- school.size = size;
- }
- }
- await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(school, school.id, new PartitionKey("Base"));
- Azure.Response response = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(tmdid, new PartitionKey($"Teacher-{school.id}"));
- if (response.Status == 200)
- {
- SchoolTeacher schoolTeacher = JsonDocument.Parse(response.ContentStream).RootElement.ToObject<SchoolTeacher>();
- if (schoolTeacher.roles == null)
- {
- schoolTeacher.roles = new List<string> { "admin" };
- }
- if (!schoolTeacher.roles.Contains("admin"))
- {
- schoolTeacher.roles.Add("admin");
- }
- schoolTeacher.name = teacher.name;
- schoolTeacher.picture = teacher.picture;
- schoolTeacher.createTime = now;
- schoolTeacher.subjectIds = schoolTeacher.subjectIds == null ? new List<string>() : schoolTeacher.subjectIds;
- schoolTeacher.status = "join";
- schoolTeacher.job = "管理员";
- schoolTeacher.pk = "Teacher";
- await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(schoolTeacher, tmdid, new PartitionKey($"Teacher-{school.id}"));
- schoolsTeachers.Add(schoolTeacher);
- }
- else
- {
- SchoolTeacher schoolTeacher = new SchoolTeacher()
- {
- id = tmdid,
- code = $"Teacher-{school.id}",
- roles = new List<string> { "admin", "teacher" },
- permissions = new List<string>(),
- };
- schoolTeacher.name = teacher.name;
- schoolTeacher.picture = teacher.picture;
- schoolTeacher.createTime = now;
- schoolTeacher.subjectIds = schoolTeacher.subjectIds == null ? new List<string>() : schoolTeacher.subjectIds;
- schoolTeacher.status = "join";
- schoolTeacher.job = "管理员";
- schoolTeacher.pk = "Teacher";
- await client.GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(schoolTeacher, new PartitionKey($"Teacher-{school.id}"));
- schoolsTeachers.Add(schoolTeacher);
- }
- if (teacher.schools.IsNotEmpty())
- {
- if (!teacher.schools.Select(x => x.schoolId).Contains(school.id))
- {
- teacher.schools.Add(new Teacher.TeacherSchool { schoolId = school.id, areaId = school.areaId, picture = school.picture, name = school.name, status = "join", time = now });
- }
- else
- {
- var sch = teacher.schools.Find(x => x.schoolId.Equals(school.id));
- if (sch != null)
- {
- sch.time = now;
- sch.name = school.name;
- sch.areaId = school.areaId;
- sch.picture = school.picture;
- sch.status = "join";
- }
- }
- }
- else
- {
- teacher.schools = new List<Teacher.TeacherSchool> { new Teacher.TeacherSchool { schoolId = school.id, areaId = school.areaId, picture = school.picture, name = school.name, status = "join", time = now } };
- }
- }
- await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(teacher, tmdid, new PartitionKey($"Base"));
- teachers.Add(teacher);
- }
- return Ok(new { teachers, schoolsTeachers, errorSchool });
- }
- /// <summary>
- /// 修复评测publish字段内容
- /// </summary>
- /// <param name="req"></param>
- /// <param name="log"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- //[AuthToken(Roles = "teacher")]
- [HttpGet("fix-group-list")]
- public async Task<IActionResult> FixGroupList()
- {
- List<GroupList> groupLists = new List<GroupList>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<GroupList>
- (queryText: "select value(c) from c ", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("GroupList") }))
- {
- groupLists.Add(item);
- }
- List<GroupList> groupLists_up = new List<GroupList>();
- groupLists.ForEach(async list => {
- var smembers = list.members.Where(x => x.type == 2);
- list.scount = smembers.Count();
- if (smembers.Count() > 0 && smembers.Select(x => x.code).ToHashSet().Count() >= 2)
- {
- //处理移除多个学校的名单,只保留一个学校的。
- if (string.IsNullOrWhiteSpace(list.school))
- {
- HashSet<string> codes = smembers.Select(x => x.code).ToHashSet();
- list.school = codes.First();
- codes.Remove(codes.First());
- list.members.RemoveAll(x => codes.Contains(x.code));
- }
- else
- {
- list.members.RemoveAll(x => !x.code.Equals(list.school));
- }
- groupLists_up.Add(list);
- }
- if (smembers.Count() > 0 && smembers.Select(x => x.code).ToHashSet().Count() == 1)
- {
- if (string.IsNullOrWhiteSpace(list.school))
- {
- HashSet<string> codes = smembers.Select(x => x.code).ToHashSet();
- list.school = codes.First();
- }
- groupLists_up.Add(list);
- }
- });
- foreach (var item in groupLists_up)
- {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- return Ok();
- }
-
- /// 设置省平台相关账号为管理员,直接操作School的 PK=Teacher
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("set-sc-admin-by-tmdid")]
- public async Task<IActionResult> SetScAdminByTmdid(JsonElement request) {
- if (!request.TryGetProperty("userkeys", out JsonElement _userkeys)) { return BadRequest(); }
- List<string> userkeys = _userkeys.ToObject<List<string>>();
- List<string> nokey = new List<string>();
- var content = new StringContent(userkeys.Select(x => x).ToJsonString(), Encoding.UTF8, "application/json");
- string json = await _coreAPIHttpService.GetUserInfos(content);
- List<CoreUser> tmdInfos = json.ToObject<List<CoreUser>>();
- List<string> noreg = new List<string>();
- var notin = userkeys.Except(tmdInfos.Select(x => x.searchKey));
- if (notin.Any())
- {
- noreg.AddRange(notin);
- }
- string sql = $"select value(c) from c where c.pk='Teacher' and c.id in ({string.Join(",", tmdInfos.Select(x => $"'{x.id}'"))})";
- List<SchoolTeacher> schoolTeachers = new List<SchoolTeacher>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<SchoolTeacher>(queryText: sql))
- {
- schoolTeachers.Add(item);
- }
- var noid= tmdInfos.Select(x => x.id).Except(schoolTeachers.Select(z => z.id));
- if (noid.Any()) {
- var a = tmdInfos.FindAll(x => noid.Contains(x.id));
- nokey.AddRange(a.Select(x=>x.searchKey));
- }
- var groups = schoolTeachers.GroupBy(x => x.id).Select(y => new { key = y.Key, list = y.ToList() });
- var countMore1 = groups.Where(x => x.list.Count > 1).SelectMany(x => x.list);
- var countEqual1 = groups.Where(x => x.list.Count == 1).SelectMany(x => x.list);
- countEqual1.ToList().ForEach(x => {
- if (!x.roles.Contains("admin")) {
- x.roles.Add("admin");
- }
- });
- foreach (var item in countEqual1) {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- return Ok(new { countMore1, countEqual1 , nokey,noreg});
- }
- /// <summary>
- /// 学生活动中间表ClassIds去重
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-classIds")]
- public async Task<IActionResult> CorrectActivityClassIds()
- {
- try
- {
- var cosmosClient = _azureCosmos.GetCosmosClient();
- //string sqlTxt = "SELECT select c.id,c.code,c.classIds FROM c where c.pk='Activity' and c.classIds <> []";
- string sqlTxt = "select c.id,c.code,c.classIds from c where c.classIds <> []";
- List<CorrectStu> correctStus = new List<CorrectStu>();
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- obj.TryGetProperty("id", out JsonElement tempTd);
- obj.TryGetProperty("code", out JsonElement code);
- obj.TryGetProperty("classIds", out JsonElement _classIds);
- List<string> templist = _classIds.ToObject<List<string>>();
- //List<string> newList = templist.Distinct().ToList(); //Equals实现去重
- //List<string> newLis1 = templist.Where((x, i) => templist.FindIndex(z => z == x) == i).ToList(); //Lambda表达式去重
- HashSet<string> hashSet = new HashSet<string>(templist);//哈希自动去重
- if (hashSet.Count != templist.Count)
- {
- CorrectStu correctList = new CorrectStu() { id = $"{tempTd}", code = $"{code}", classIds = hashSet.ToList() };
- correctStus.Add(correctList);
- }
- }
- }
- List<Task<ItemResponse<StuActivity>>> tasks = new List<Task<ItemResponse<StuActivity>>>();
- if (correctStus.Count > 0)
- {
- foreach (var correct in correctStus)
- {
- StuActivity stuActivity = await cosmosClient.GetContainer("TEAMModelOS", "Student").ReadItemAsync<StuActivity>(correct.id, new PartitionKey(correct.code));
- if (stuActivity != null)
- {
- stuActivity.classIds = correct.classIds;
- tasks.Add(cosmosClient.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(stuActivity, stuActivity.id, new PartitionKey(stuActivity.code)));
- }
- }
- int pagesize = 1000;
- if (tasks.Count <= pagesize)
- {
- await Task.WhenAll(tasks);
- }
- else
- {
- int pages = (tasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
- for (int i = 0; i < pages; i++)
- {
- var listssb = tasks.Skip((i) * pagesize).Take(pagesize).ToList();
- await Task.WhenAll(listssb);
- }
- }
- return Ok(new { state = 200, msg = "去重成功" });
- }
- else
- {
- return Ok(new { state = 201, msg = "学生活动中间表无重复班级ID" });
- }
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"OS,{_option.Location} /fix-data/fix-classIds \n {ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
- return Ok(new { state = 401 });
- }
- }
- /// <summary>
- /// 所有学校添加国家智慧教育公共服务平台 https://www.smartedu.cn/
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("set-school-smartedu")]
- public async Task<IActionResult> SetSchoolSmartedu(JsonElement json)
- {
- string sql = "select value(c.id) from c join a in c.third join b in a.links where b.url='https://basic.smartedu.cn/'";
- List<string> schoolIdsAdded = new List<string>();
- //已经添加的
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("SchoolSetting") }))
- {
- schoolIdsAdded.Add(item);
- }
- string sqlSchool = "select value(c.id) from c ";
- List<string> schoolIdsAddHas = new List<string>();
- //未添加的=有SchoolSetting的-已经添加的
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(queryText: sqlSchool, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("SchoolSetting") }))
- {
- schoolIdsAddHas.Add(item);
- }
- string linkName = "国家智慧教育公共服务平台";
- string linkUrl = "https://www.smartedu.cn/";
- //没有添加的
- var schoolIdsAddNo = schoolIdsAddHas.Except(schoolIdsAdded);
- //新添加的
- List<string> schoolIdsAddNew = new List<string>();
- if (schoolIdsAddHas.IsNotEmpty()) {
- string sqlAdd = $"select value(c.id) from c where c.id not in ({string.Join(",", schoolIdsAddHas.Select(x => $"'{x}'"))})";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(queryText: sqlAdd, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schoolIdsAddNew.Add(item);
- }
- foreach (var item in schoolIdsAddNew) {
- SchoolSetting setting = new SchoolSetting
- {
- id = item,
- code = "SchoolSetting",
- pk = "SchoolSetting",
- third = new List<Policy> { new Policy { tag = "default", links = new List<Link> { new Link { name = linkName, url = linkUrl } } } }
- };
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(setting, new PartitionKey("SchoolSetting"));
- }
- }
- foreach (var item in schoolIdsAddNo) {
- SchoolSetting setting = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<SchoolSetting>(item, new PartitionKey("SchoolSetting"));
- if (setting.third.IsNotEmpty())
- {
- var defaultTag = setting.third.Find(x => x.tag.Equals("default"));
- if (defaultTag != null)
- {
- if (defaultTag.links.IsNotEmpty())
- {
- defaultTag.links.Add(new Link { name = linkName, url = linkUrl });
- }
- else {
- defaultTag.links = new List<Link> { new Link { name = linkName, url = linkUrl } };
- }
- }
- else {
- setting.third.Add(new Policy { tag = "default", links = new List<Link> { new Link { name = linkName, url = linkUrl } } });
- }
- }
- else {
- setting.third = new List<Policy> { new Policy { tag = "default", links = new List<Link> { new Link { name = linkName, url = linkUrl } } } };
- }
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(setting, setting.id, new PartitionKey("SchoolSetting"));
- }
- return Ok(new { schoolIdsAddNo, schoolIdsAddNew });
- }
- /// <summary>
- /// 给学校空间设置1024T,按区域。
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-school-blobsize")]
- public async Task<IActionResult> FixSchoolBlobSize(JsonElement json) {
- string sql = "select value(c) from c where c.areaId in " +
- "('99a4a33b-e21b-44ac-80a1-b31dc40496e0','f35e0031-a53f-45e5-b307-1cd39446a2cf'," +
- "'2c1b01fe-3641-464f-8499-7be95a489b7c','9ae614ba-0771-4502-a56e-0537bc5207c3'," +
- "'870a5a6b-1ab3-461a-bdeb-baec19780ddb','dd15017a-f361-4346-852e-8eee71d027ad')";
- List<School> schools = new List<School>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
- schools.Add(item);
- }
- schools.ForEach(x => { x.size = 1024; });
- foreach (var item in schools) {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- return Ok(schools);
- }
- /// <summary>
- /// 给学校空间设置1024T,按区域。
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-school-subjects-type")]
- public async Task<IActionResult> FixSchoolSubjectsType(JsonElement json)
- {
- string sql = " SELECT distinct value(c) FROM c join p in c. period join s in p.subjects where s.type=0 ";
- List<School> schools = new List<School>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schools.Add(item);
- }
- schools.ForEach(x => {
- x.period.ForEach(p => {
- p.subjects.ForEach(s => {
- if (s.type == 0)
- {
- s.type = 1;
- }
- });
- });
- });
- foreach (var item in schools)
- {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- return Ok(schools);
- }
- /// <summary>
- /// 重置能力点上传作品的评分状态
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("reset-ability-upload-school")]
- public async Task<IActionResult> ResetAbilityUploadSchool(JsonElement json) {
- var client = _azureCosmos.GetCosmosClient();
- string sql = "SELECT distinct value(c) FROM c join b in c.otherScore where c.id='c57f3650-7f1a-4bc0-bb66-f19e6ac03fd8' and array_length(c.uploads)>0 and array_length(c.otherScore)>0 and b.roleType='school' ";
- List<AbilitySub> abilitySubs = new List<AbilitySub>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<AbilitySub>(queryText: sql))
- {
- abilitySubs.Add(item);
- }
- List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
- foreach (var item in abilitySubs) {
- item.otherScore.RemoveAll(x => x.roleType.Equals("school"));
- // TeacherAbility item.creatorId
- TeacherTrain teacherTrain = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherTrain>(item.creatorId, new PartitionKey($"TeacherTrain-{item.school}"));
- teacherTrain.update.Add("TeacherAbility");
- teacherTrains.Add(teacherTrain);
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(teacherTrain, teacherTrain.id, new PartitionKey(teacherTrain.code));
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
- }
- return Ok(new { teacherTrains, abilitySubs });
- }
- /// <summary>
- /// 学校设置学期
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-school-semester")]
- public async Task<IActionResult> FixSchoolSemester(JsonElement json) {
- var client = _azureCosmos.GetCosmosClient();
- string sql = " SELECT value(c) FROM c ";
- var schools = new List<School>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schools.Add(item);
- }
- HashSet<School> schoolsSet = new HashSet<School>();
- schools.ForEach(x => {
- if (x.period.IsNotEmpty())
- {
- x.period.ForEach(y => {
- if (y.semesters.IsEmpty())
- {
- y.semesters = new List<Semester>
- {
- new Semester { name = "上学期", start = 1, month = 9, day = 1, id = Guid.NewGuid().ToString() },
- new Semester { name = "下学期", start = 0, month = 3, day = 1, id = Guid.NewGuid().ToString() }
- };
- }
- y.semesterCount = y.semesters.Count;
- schoolsSet.Add(x);
- });
- }
- else {
- string campusId = Guid.NewGuid().ToString();
- List<Period> periods = new List<Period>();
- periods.Add(new Period
- {
- id = Guid.NewGuid().ToString(),
- name = x.name,
- campusId = campusId,
- semesterCount = 2,
- semesters = new List<Semester>
- {
- new Semester { name = "上学期", start = 1, month = 9, day = 1, id = Guid.NewGuid().ToString() },
- new Semester { name = "下学期", start = 0, month = 3, day = 1, id = Guid.NewGuid().ToString() }
- },
- });
- x.period = periods;
- schoolsSet.Add(x);
- x.campuses = new List<Campus> { new Campus { id = campusId, name = x.name } };
- }
- });
- int count = schoolsSet.Count();
- foreach (var item in schoolsSet) {
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync<School>(item, item.id, new PartitionKey(item.code));
- }
- return Ok(schoolsSet);
- }
- [HttpPost("fix-teacher-train-nickname")]
- public async Task<IActionResult> FixTeacherPrivateLessonRecord(JsonElement json)
- {
- var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
- List<ScTeacher> scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" } });
- scTeachers = scTeachers.FindAll(x => !string.IsNullOrWhiteSpace(x.tmdid) && !string.IsNullOrWhiteSpace(x.schoolCode));
- var groups = scTeachers.GroupBy(x => x.schoolCode).Select(x => new { key = x.Key, list = x.ToList() });
- foreach (var item in groups) {
- List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
- string sql = $" select value(c) from c where c.id in ({string.Join(",", item.list.Select(x => $"'{x.tmdid}'"))}) ";
- await foreach (var tr in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<TeacherTrain>(queryText: sql,
- requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"TeacherTrain-{item.key}") }))
- {
- teacherTrains.Add(tr);
- }
- List<Task<ItemResponse<TeacherTrain>>> update = new List<Task<ItemResponse<TeacherTrain>>>();
- teacherTrains.ForEach(x => {
- var sc = scTeachers.Find(s => s.tmdid.Equals(x.id));
- if (sc != null) {
- if (string.IsNullOrWhiteSpace(x.nickname))
- {
- x.nickname = sc.TeacherName;
- update.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(x, x.id, new PartitionKey(x.code)));
- }
- else if (!sc.TeacherName.Equals(x.nickname)) {
- x.nickname = sc.TeacherName;
- update.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(x, x.id, new PartitionKey(x.code)));
- }
- }
- });
- await Task.WhenAll(update);
- }
- return Ok();
- }
- /// <summary>
- /// 修复学校课例及blob计算
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("ReloadBlob")]
- public async Task<IActionResult> ReloadBlob(JsonElement json)
- {
- //var client = _azureCosmos.GetCosmosClient();
- //string sql = " SELECT distinct value(c) FROM c where c.pk='LessonRecord' ";
- //List<LessonRecord> lessonRecords = new List<LessonRecord>();
- //await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<LessonRecord>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("LessonRecord-ydzt") }))
- //{
- // lessonRecords.Add(item);
- //}
- //var list = await _azureStorage.GetBlobContainerClient("ydzt").List($"records");
- //HashSet<string> ids = new HashSet<string>();
- //list.ForEach(x => {
- // var a = x.Split("/");
- // if (a.Length >= 2) {
- // ids.Add(a[1]);
- // }
- //});
- List<string> lists = new List<string> { };
- foreach (var l in lists) {
- await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, "ydzt", new List<string> { $"records/{l}" });
- }
- return Ok(new { });
- }
- /// <summary>
- /// 修复学校课例及blob计算
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-school-lesson-record")]
- public async Task<IActionResult> FixSchoolLessonRecord(JsonElement json)
- {
- var client = _azureCosmos.GetCosmosClient();
- string sql = " SELECT distinct value(c) FROM c where c.pk='LessonRecord' ";
- List<LessonRecord> lessonRecords = new List<LessonRecord>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<LessonRecord>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("LessonRecord-ydzt") }))
- {
- lessonRecords.Add(item);
- }
- //await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<LessonRecord>(queryText: sql, requestOptions: new QueryRequestOptions { }))
- //{
- // lessonRecords.Add(item);
- //}
- HashSet<string> courseIds = new HashSet<string>();
- lessonRecords.ForEach(item => {
- if (!string.IsNullOrWhiteSpace(item.courseId)) {
- courseIds.Add(item.courseId);
- }
- });
- List<Course> courses = new List<Course>();
- if (courseIds.Any()) {
- string sqlCourse = $" SELECT distinct value(c) FROM c where c.pk='Course' and c.id in ({string.Join(",", courseIds.Select(x => $"'{x}'"))}) ";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<Course>(queryText: sqlCourse, requestOptions: new QueryRequestOptions { }))
- {
- courses.Add(item);
- }
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<Course>(queryText: sqlCourse, requestOptions: new QueryRequestOptions { }))
- {
- courses.Add(item);
- }
- }
- HashSet<string> schoolIds = new HashSet<string>();
- lessonRecords.ForEach(item => {
- if (!string.IsNullOrWhiteSpace(item.school))
- {
- schoolIds.Add(item.school);
- }
- });
- List<School> schools = new List<School>();
- if (schoolIds.Any()) {
- string sqlSchool = $" SELECT distinct value(c) FROM c where c.id in ({string.Join(",", schoolIds.Select(x => $"'{x}'"))}) ";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(queryText: sqlSchool, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- schools.Add(item);
- }
- }
- var lists = lessonRecords.Where(x => !string.IsNullOrWhiteSpace(x.school)).GroupBy(y => y.school).Select(a => new { key = a.Key, list = a.ToList() });
- Dictionary<string, List<GroupListDto>> dict = new Dictionary<string, List<GroupListDto>>();
- foreach (var item in lists) {
- var gids = item.list.SelectMany(x => x.groupIds).Where(y => !string.IsNullOrWhiteSpace(y));
- HashSet<string> grades = new HashSet<string>();
- List<GroupListDto> groups = await GroupListService.GetGroupListByListids(client, _dingDing, gids.ToList(), item.key);
- List<GroupListDto> groupLists = groups?.FindAll(x => !string.IsNullOrEmpty(x.periodId) && !string.IsNullOrEmpty(x.school));
- dict.Add(item.key, groupLists);
- }
- foreach (var lessonRecord in lessonRecords) {
- LessonRecord old = lessonRecord.ToJsonString().ToObject<LessonRecord>();
- if (string.IsNullOrWhiteSpace(lessonRecord.courseId)) {
- var course = courses.Find(x => x.id.Equals(lessonRecord.courseId));
- if (course != null)
- {
- lessonRecord.periodId = course.period?.id;
- lessonRecord.subjectId = course.subject?.id;
- }
- }
- //处理课堂选用的名单
- if (lessonRecord.groupIds.IsNotEmpty() && !string.IsNullOrWhiteSpace(lessonRecord.school) && !string.IsNullOrWhiteSpace(lessonRecord.periodId))
- {
- HashSet<string> grades = new HashSet<string>();
- List<GroupListDto> groupLists = null;
- dict.TryGetValue(lessonRecord.school, out groupLists);
- if (groupLists.IsNotEmpty())
- {
- var gplist = groupLists.FindAll(x => lessonRecord.groupIds.Contains(x.id));
- School schoolObj = schools.Find(x => x.id.Equals(lessonRecord.school));
- if (schoolObj != null)
- {
- //年级算法
- var period = schoolObj.period.Find(x => x.id.Equals(lessonRecord.periodId));
- int? Count = period?.grades?.Count;
- if (Count.HasValue)
- {
- int Day = DateTimeOffset.UtcNow.Day;
- int Month = DateTimeOffset.UtcNow.Month;
- int Year = DateTimeOffset.UtcNow.Year;
- int start = int.Parse($"{Year}0901");
- var se = period.semesters.Find(x => x.start == 1);
- if (se == null) {
- se = period.semesters.First();
- }
- if (se != null) {
- string sm = se.month >= 10 ? $"{se.month}" : $"0{se.month}";
- string sd = se.day >= 10 ? $"{se.day}" : $"0{se.day}";
- start = int.Parse($"{Year}{sm}{sd}");
- }
- int curr = int.Parse(DateTimeOffset.UtcNow.ToString("yyyyMMdd"));
- //新学年开学时间大于当前时间,计算年级需要减1 20220901-20220408 > 0 则当前20220408是2021年入学的,
- //当前时间大于新学年开学时间,计算年级则不需要 20220901-20221203 < 1 则当前20221203是2022年入学的,
- //20230901-20230101 > 0 则当前20230101是2022年入学的,
- int dis = start - curr;
- foreach (int year in gplist.Select(x => x.year))
- {
- int grade;
- if (dis > 0)
- {
- grade = (Year - year - 1) % Count.Value;
- }
- else
- {
- grade = (Year - year) % Count.Value;
- }
- grades.Add($"{grade}");
- }
- }
- }
- }
- lessonRecord.grade = grades.ToList();
- }
- string scope = lessonRecord.scope;
- string tmdid = lessonRecord.tmdid;
- string lessonId = lessonRecord.id;
- string school = lessonRecord.school;
- string tbname = "";
- string code;
- string blobname = "";
- if ($"{scope}".Equals("school") && !string.IsNullOrEmpty($"{school}"))
- {
- blobname = $"{school}";
- code = $"LessonRecord-{school}";
- tbname = "School";
- }
- else if ($"{scope}".Equals("private"))
- {
- blobname = $"{tmdid}";
- code = $"LessonRecord";
- tbname = "Teacher";
- }
- //如果有更新 则去读取/{_lessonId}/IES/base.json
- try
- {
- BlobDownloadResult baseblobDownload = await _azureStorage.GetBlobContainerClient(blobname).GetBlobClient($"/records/{lessonId}/IES/base.json").DownloadContentAsync();
- LessonBase lessonBase = baseblobDownload.Content.ToObjectFromJson<LessonBase>();
- if (lessonBase != null && lessonBase.summary != null)
- {
- lessonRecord.attendCount = lessonBase.summary.attendCount;
- lessonRecord.clientCount = lessonBase.summary.clientCount;
- lessonRecord.attendRate = lessonBase.summary.attendRate;
- lessonRecord.groupCount = lessonBase.summary.groupCount;
- lessonRecord.collateTaskCount = lessonBase.summary.collateTaskCount;
- lessonRecord.collateCount = lessonBase.summary.collateCount;
- lessonRecord.pushCount = lessonBase.summary.pushCount;
- lessonRecord.totalPoint = lessonBase.summary.totalPoint;
- lessonRecord.examQuizCount = lessonBase.summary.examQuizCount;
- lessonRecord.interactionCount = lessonBase.summary.interactionCount;
- lessonRecord.examPointRate = lessonBase.summary.examPointRate;
- lessonRecord.clientInteractionCount = lessonBase.summary.clientInteractionCount;
- lessonRecord.clientInteractionAverge = lessonBase.summary.clientInteractionAverge;
- lessonRecord.examCount = lessonBase.summary.examCount;
- lessonRecord.totalInteractPoint = lessonBase.summary.totalInteractPoint;
- }
- long? size = await _azureStorage.GetBlobContainerClient(blobname).GetBlobsSize($"records/{lessonId}");
- Bloblog bloblog = new Bloblog
- {
- id = lessonRecord.id,
- code = $"Bloblog-{blobname}",
- name = lessonRecord.name,
- pk = "Bloblog",
- time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
- type = "records",
- url = $"records/{lessonId}",
- subjectId = string.IsNullOrWhiteSpace(lessonRecord.subjectId) ? new List<string>() : new List<string> { lessonRecord.subjectId },
- periodId = string.IsNullOrWhiteSpace(lessonRecord.periodId) ? new List<string>() : new List<string> { lessonRecord.periodId },
- size = size.HasValue ? size.Value : 0,
- };
- await client.GetContainer(Constant.TEAMModelOS, tbname).UpsertItemAsync(bloblog);
- await BlobService.RefreshBlobRoot(new BlobRefreshMessage { progress = "update", root = "records", name = $"{blobname}" }, _serviceBus, _configuration, _azureRedis);
- }
- catch (RequestFailedException ex) when (ex.Status == 404)
- {
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}课程读取base.json,{lessonId}\n{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
- }
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(lessonRecord, lessonId, new PartitionKey(lessonRecord.code));
- LessonDis lessonDis = new LessonDis();
- //计算课堂更新前后的差值
- lessonDis = LessonService.DisLessonCount(old, lessonRecord, lessonDis);
- await LessonService.FixLessonCount(client, _dingDing, lessonRecord, old, lessonDis);
- }
- return Ok(new { lessonRecords });
- }
- /// <summary>
- /// 修复学校课例及blob计算
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("check-scteacher")]
- public async Task<IActionResult> CheckScTeacher(JsonElement request) {
- if (!request.TryGetProperty("accessConfig", out JsonElement accessConfig)) return BadRequest();
- if (!request.TryGetProperty("city", out JsonElement city)) return BadRequest();
- if (!request.TryGetProperty("dist", out JsonElement dist)) return BadRequest();
- if (!request.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
- if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
- var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
- var ScTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
- Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
- //(int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
- (int status, string json) = await ScsStudyApisService.GetTeachersListByProject(_httpClient.CreateClient(), _dingDing, _azureStorage, $"{areaId}", $"{accessConfig}");
- var teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
- var dbIds = ScTeachers.Select(x => x.PXID);
- var scIds = teachers.Select(x => x.PXID);
- var dbMore = dbIds.Except(scIds);
- List<ScTeacher> dbtech = new List<ScTeacher>();
- foreach (var item in dbMore) {
- dbtech.Add(ScTeachers.Find(x => x.PXID == item));
- }
- List<ScTeacher> sctech = new List<ScTeacher>();
- var scMore = scIds.Except(dbIds);
- foreach (var item in scMore)
- {
- sctech.Add(teachers.Find(x => x.PXID == item));
- }
- List<string> tmdids = new List<string>();
- var group = ScTeachers.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).GroupBy(x => x.tmdid).Select(x => new { x.Key, list = x.ToList() });
- group.ToList().ForEach(x =>
- {
- if (x.list.Count > 1) {
- tmdids.Add(x.Key);
- }
- });
- List<string> teacherTrainsIds = new List<string>();
- string insql = $"where c.id in ({string.Join(",", ScTeachers.Select(x => $"'{x.tmdid}'"))})";
- string selsql = $"select value(c.id) from c {insql} and c.pk='TeacherTrain' ";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<string>(queryText: selsql,
- requestOptions: new QueryRequestOptions() { }))
- {
- teacherTrainsIds.Add(item);
- }
- var bindids = ScTeachers.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).Select(x => x.tmdid);
- var noTrains = bindids.Except(teacherTrainsIds);
- return Ok(new { dbtech, sctech, ScCount = teachers.Count, DBCount = ScTeachers.Count, ScTeachers, tmdids, noTrains });
- }
- /// <summary>
- /// 筛查能力点未上传认证材料的
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("un-upload-abilitysub")]
- public async Task<IActionResult> UnUploadAbilitysub(JsonElement json)
- {
- try {
- List<string> schools = json.Deserialize<List<string>>();
- if (!schools.Any()) {
- return BadRequest();
- }
- var client = _azureCosmos.GetCosmosClient();
- //金牛直属。
- //string sql = $"SELECT distinct c.id,s.schoolId as code , c.name as nickname, s.name as name FROM c join s in c.schools where s.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'" +
- // $" and array_length(c.binds)>0 and s.schoolId in ({string.Join(",", schools.Select(s => $"'{s}'"))})";
- string sql = $"SELECT distinct c.id,s.schoolId as code , c.name as nickname, s.name as name FROM c join s in c.schools where s.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'" +
- $" and array_length(c.binds)>0 and c.id in ({string.Join(",", schools.Select(s => $"'{s}'"))})";
- List<IdNameCode> tmdidSchooCode = new List<IdNameCode>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(queryText: sql,
- requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- tmdidSchooCode.Add(item);
- }
- List<Ability> abilities = new List<Ability>();
- string abilitysql = "select value c from c ";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetItemQueryIterator<Ability>(queryText: abilitysql,
- requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Ability-standard4") }))
- {
- abilities.Add(item);
- }
- List<dynamic> dynamics = new List<dynamic>();
- var group = tmdidSchooCode.GroupBy(idcode => idcode.code).ToList();
- List<Task<List<dynamic>>> dynamicsTask = new List<Task<List<dynamic>>>();
- group.ForEach(x => {
- dynamicsTask .Add(GetDynamics(x.ToList(), abilities));
- });
- var aa= await Task.WhenAll(dynamicsTask);
- foreach (var a in aa) {
- if (a.Any()) {
- dynamics.AddRange(a);
- }
- }
- return Ok(new { dynamics });
- } catch (Exception ex) {
- return BadRequest($"{ex.Message}{ex.StackTrace}");
- }
- }
- private async Task<List<dynamic>> GetDynamics(List<IdNameCode> tmdidSchooCode,List<Ability> abilities) {
- List<dynamic> dynamics = new List<dynamic>();
- List<Task<List<dynamic>>> dynamicsTask = new List<Task<List<dynamic>>>();
- tmdidSchooCode.ForEach(idcode => {
- dynamicsTask.Add(GetDynamicsTmd(idcode, abilities));
- });
- var aa = await Task.WhenAll(dynamicsTask);
- foreach (var a in aa)
- {
- if (a.Any())
- {
- dynamics.AddRange(a);
- }
- }
- return dynamics;
- }
- private async Task<List<dynamic>> GetDynamicsTmd(IdNameCode idcode, List<Ability> abilities) {
- List<dynamic> dynamics = new List<dynamic>();
- string subsql = "select value c from c ";
- List<AbilitySub> abilitySubs = new List<AbilitySub>();
- List<UnUpload> unUploads = new List<UnUpload>();
- (string blobPix, string sas) = _azureStorage.GetBlobContainerSAS99Year(idcode.code, Azure.Storage.Sas.BlobContainerSasPermissions.Read);
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<AbilitySub>(queryText: subsql,
- requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilitySub-{idcode.code}-{idcode.id}") }))
- {
- abilitySubs.Add(item);
- }
- //移除通识
- abilitySubs.RemoveAll(ab => ab.id.Equals("2438e72f-4de8-4ccb-8cae-3f1dce89a769"));
- if (abilitySubs.Count > 3)
- {
- //一个都没上传
- if (!abilitySubs.SelectMany(upsl => upsl.uploads).Any())
- {
- try
- {
- var a = abilitySubs.Count - 3;
- abilitySubs = abilitySubs.Take(a).ToList();
- }
- catch { await _dingDing.SendBotMsg($"{idcode.ToJsonString()},{abilitySubs.ToJsonString()}", GroupNames.成都开发測試群組); }
- }
- else
- {
- //检查
- var 上传了的 = abilitySubs.FindAll(x => x.uploads.Count > 0);
- //如果上传大于三个能力点,则清空掉多余的没有上传的
- if (上传了的.Count >= 3)
- {
- abilitySubs.RemoveAll(x => x.uploads.Count == 0);
- }
- //如果上传不足三个的,保证有三个能力点
- else
- {
- if (上传了的.Any())
- {
- int 需要增加的 = 3 - 上传了的.Count;
- var 未上传的 = abilitySubs.FindAll(x => x.uploads.Count == 0);
- List<AbilitySub> newAb = 上传了的;
- var a = 未上传的.Take(需要增加的);
- if (a.Any())
- {
- newAb.AddRange(a);
- }
- abilitySubs = newAb;
- }
- else
- {
- abilitySubs = abilitySubs.Take(3).ToList();
- }
- }
- }
- }
- List<Task<List<UnUpload>>> uploads = new List<Task<List<UnUpload>>>();
- abilitySubs.ForEach(item => {
- uploads.Add(GetSub(item, abilities, blobPix, sas));
-
- });
- var aa = await Task.WhenAll(uploads);
- int index = 0;
- foreach (var a in aa)
- {
- if (a.Any())
- {
- unUploads.AddRange(a);
- }
- else {
- //没有任何问题的。
- index += 1;
- }
- }
- if (index < 3) {
- if (unUploads.Any())
- {
- foreach (var un in unUploads)
- {
- un.stdsUnUpload.ForEach(ii =>
- {
- dynamics.Add(new { idcode.id, idcode.name, idcode.nickname, un.abilityNo, un.abilityName, msg = "认证材料未上传", stdname = ii.stdname });
- });
- un.taskUnUplaod.ForEach(ii =>
- {
- dynamics.Add(new { idcode.id, idcode.name, idcode.nickname, un.abilityNo, un.abilityName, msg = "认证材料任务未上传", stdname = ii.stdname, taskname = ii.taskname });
- });
- un.urlUnExsit.ToList().ForEach(ii =>
- {
- string msg = "";
- if (ii.enough == 0)
- {
- msg = "认证上传数量不达标";
- }
- else
- {
- msg = "认证材料文件因操作原因";
- }
- StringBuilder uploadUrls = new StringBuilder();
- dynamics.Add(new
- {
- idcode.id,
- idcode.name,
- idcode.nickname,
- idcode.code,
- un.abilityNo,
- un.abilityName,
- msg = msg,
- stdname = ii.stdname,
- taskname = ii.taskname,
- errorUrls = string.Join("\n\r\t ", ii.errorUrls),
- enough = ii.enough,
- limit = ii.limit,
- count = ii.count,
- uploadUrls = string.Join("\n\r\t ", ii.uploadUrls),
- });
- });
- }
- }
- }
- return dynamics;
- }
- private async Task<List<UnUpload>> GetSub(AbilitySub item , List<Ability> abilities, string blobPix, string sas) {
- List<UnUpload> unUploads = new List<UnUpload>();
- var ability = abilities.Find(x => x.id.Equals(item.id));
- foreach (var x in ability.stds)
- {
- UnUpload unUpload = new UnUpload { abilityNo = ability.no, abilityName = ability.name };
- var upload = item.uploads.FindAll(u => u.stdid.Equals(x.id));
- if (upload != null)
- {
- AbilityStdTask abilityStdTask = null;
- x.task.ForEach(t => {
- if (upload.Where(u => u.taskid.Equals(t.id)).Any())
- {
- abilityStdTask = t;
- }
- });
- //检查是否正确上传任务的。
- if (abilityStdTask == null)
- {
- //var dict = new Dictionary<string, List<string>>();
- //dict.Add(x.id, new List<string>(x.task.Select(t => t.id)));
- //x.task.ForEach(t => {
- // unUpload.taskUnUplaod.Add(new aburls { stdid = x.id, stdname = x.std, taskid = t.id, taskname = t.stddesc });
- //});
- }
- else
- {
- SubUpload subUpload = upload.Find(ap => ap.taskid.Equals(abilityStdTask.id));
- if (subUpload != null)
- {
- List<string> urlUn = new List<string>();
- foreach (var url in subUpload.urls)
- {
- string blobItem = url.url.Replace($"{blobPix}/", "");
- bool Exist = await _azureStorage.GetBlobContainerClient(item.school).GetBlobClient(blobItem).ExistsAsync();
- // List<string> items = await _azureStorage.GetBlobContainerClient(item.school).ExistsAsync(blobItem);
- if (!Exist)
- {
- urlUn.Add($"{url.url}?{sas}");
- }
- }
- aburls aburls = new aburls
- {
- stdid = x.id,
- stdname = x.std,
- taskid = abilityStdTask.id,
- taskname = abilityStdTask.stddesc,
- errorUrls = urlUn,
- };
- //if (abilityStdTask.limit > subUpload.urls.Count)
- //{
- // aburls.enough = 0;
- // aburls.limit = abilityStdTask.limit;
- // aburls.count = subUpload.urls.Count;
- // aburls.uploadUrls = subUpload.urls.Select(x => $"{x.url}?{sas}").ToList();
- // unUpload.urlUnExsit.Add(aburls);
- //}
- if (urlUn.Any())
- {
- unUpload.urlUnExsit.Add(aburls);
- }
- }
- else
- {
- //var dict = new Dictionary<string, List<string>>();
- //dict.Add(x.id, new List<string>(x.task.Select(t => t.id)));
- //x.task.ForEach(t => {
- // unUpload.taskUnUplaod.Add(new aburls { stdid = x.id, stdname = x.std, taskid = t.id, taskname = t.stddesc });
- //});
- }
- }
- }
- else
- {
- //unUpload.stdsUnUpload.Add(new aburls { stdid = x.id, stdname = x.std });
- }
- if (/*unUpload.stdsUnUpload.Any() || unUpload.taskUnUplaod.Any() ||*/ unUpload.urlUnExsit.Any())
- {
- unUploads.Add(unUpload);
- }
- }
- return unUploads;
- }
- public class UnUpload {
- public string abilityNo { get; set; }
- public string abilityName { get; set; }
- public List<aburls> stdsUnUpload { get; set; } = new List<aburls>();
- public List<aburls> taskUnUplaod { get; set; } = new List<aburls>();
- public HashSet<aburls> urlUnExsit { get; set; } = new HashSet<aburls>();
- }
- public class aburls
- {
- public string stdid { get; set; }
- public string stdname { get; set; }
- public string taskid { get; set; }
- public string taskname { get; set; }
- public int enough { get; set; } = 1;
- public int limit { get; set; }
- public int count { get; set; }
- public List<string> uploadUrls { get; set; } = new List<string>();
- public List<string> errorUrls { get; set; } = new List<string>();
- }
- [HttpPost("gen-school-teacher-pdf")]
- public async Task<IActionResult> GenSchoolTeacherPdf(JsonElement json) {
- var client = _azureCosmos.GetCosmosClient();
- //金牛直属。
- if (!json.TryGetProperty("areaId", out JsonElement areaId)) { BadRequest(); }
- //string sql = $"SELECT distinct c.id,s.schoolId as code , c.name as nickname, s.name as name FROM c join s in c.schools where s.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'" +
- // $" and array_length(c.binds)>0 and s.schoolId in ({string.Join(",", schools.Select(s => $"'{s}'") )})";
- string sql = $"SELECT distinct c.id,s.schoolId as code , c.name as nickname, s.name as name FROM c join s in c.schools where s.areaId='{areaId}'" +
- $" and array_length(c.binds)>0 ";
- List<IdNameCode> tmdidSchooCode = new List<IdNameCode>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(queryText: sql,
- requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- tmdidSchooCode.Add(item);
- }
- if (json.TryGetProperty("schools", out JsonElement schools))
- {
- List<string> pschools = schools.ToObject<List<string>>();
- tmdidSchooCode = tmdidSchooCode.FindAll(z => pschools.Contains(z.code));
- }
- if (json.TryGetProperty("pushTeachers", out JsonElement pushTeachers)) {
- List<string> teachers = pushTeachers.ToObject<List<string>>();
- tmdidSchooCode = tmdidSchooCode.FindAll(z => teachers.Contains(z.id));
- }
- foreach (var g in tmdidSchooCode)
- {
- //var messageBlobPDF = new ServiceBusMessage(new { id = g.ToList().Select(x => x.id).ToHashSet(), school = g.Key, userType = "tmdid", bizType = "OfflineRecord" }.ToJsonString());
- //var GenPdfQueue = _configuration.GetValue<string>("Azure:ServiceBus:GenPdfQueue");
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(GenPdfQueue, messageBlobPDF);
- string msg = new { id = new List<string> { g.id }, school = g.code, userType = "tmdid", bizType = "OfflineRecord" }.ToJsonString();
- JsonElement element = msg.ToObject<JsonElement>();
- // https://dotblogs.com.tw/yc421206/2013/04/25/102300 // C# 原子操作。Interlocked
- // ConcurrentQueue http://t.zoukankan.com/hohoa-p-12622459.html
- switch (true)
- {
- case bool when element.TryGetProperty("bizType", out JsonElement _bizType) && $"{_bizType}".Equals("OfflineRecord"):
- //处理教师线下研修报告的生成。
- await FixDataService.GenOfflineRecordPdf(_azureCosmos,_dingDing,_azureStorage,_coreAPIHttpService,_converter,element, msg);
- break;
-
- }
- }
- return Ok(tmdidSchooCode);
- }
- [HttpPost("restore-teacher-pdf")]
- public async Task<IActionResult> restoreteacherpdf(JsonElement json)
- {
- var client = _azureStorage.GetBlobContainerClient($"teammodelos");
- string sql = $"SELECT distinct c.id,s.schoolId as code , c.name as nickname, s.name as name FROM c join s in c.schools where s.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'" +
- $" and array_length(c.binds)>0 ";
- List<IdNameCode> tmdidSchooCode = new List<IdNameCode>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(queryText: sql,
- requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
- {
- tmdidSchooCode.Add(item);
- }
- var blobclient = _azureStorage.GetBlobContainerClient($"teammodelos");
- List<Task> tasks = new List<Task>();
- tmdidSchooCode.ForEach(idcode =>
- {
- tasks.Add(resot(idcode, blobclient));
- });
- int pagesize = 500;
- if (tasks.Count <= pagesize)
- {
- await Task.WhenAll(tasks);
- }
- else
- {
- int pages = (tasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
- for (int i = 0; i < pages; i++)
- {
- var listssb = tasks.Skip((i) * pagesize).Take(pagesize).ToList();
- await Task.WhenAll(listssb);
- }
- }
- return Ok();
- }
- private async Task resot(IdNameCode idcode, BlobContainerClient blobclient) {
- Azure.Response teacherTrainRes = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(idcode.id, new PartitionKey($"TeacherTrain-{idcode.code}"));
- if (teacherTrainRes.Status == 200)
- {
- TeacherTrain teacherTrain = JsonDocument.Parse(teacherTrainRes.Content).RootElement.Deserialize<TeacherTrain>();
- try
- {
- if (!string.IsNullOrWhiteSpace(teacherTrain.offlineUrl))
- {
- BlobDownloadInfo blobDownload = await blobclient.GetBlobClient(teacherTrain.offlineUrl).DownloadAsync(range: new HttpRange(0, 4 * 1048576), rangeGetContentHash: true);
- if (blobDownload.Details.ContentHash != null)
- {
- string hash = Md5Hash.GetbyteToString(blobDownload.Details.ContentHash);
- teacherTrain.offlineReport = new Attachment
- {
- hash = hash,
- url = teacherTrain.offlineUrl,
- blob = $"{blobclient.Uri}/{teacherTrain.offlineUrl}",
- extension = "pdf",
- name = $"{teacherTrain.nickname}-校本研修汇总报告.pdf",
- type = "doc",
- size = blobDownload.ContentLength
- };
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain, idcode.id, new PartitionKey($"TeacherTrain-{idcode.code}"));
- }
- }
- }
- catch
- {
- }
- }
- }
- /// <summary>
- /// 修复学校课例及blob计算
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-student-irs")]
- public async Task<IActionResult> FixStudentIrs(JsonElement json) {
-
- string sql = "select value(c.id) from c ";
- List<string> ids = new List<string>();
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
- .GetItemQueryIterator<string>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
- ids.Add(item);
- }
- List<Student> studentsData = new List<Student>();
- foreach (var id in ids) {
- if (id.Equals("ydzt")) {
- continue;
- }
- List<Student> students = new List<Student>();
- string sqlstu = "select value(c) from c ";
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student)
- .GetItemQueryIterator<Student>(sqlstu, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{id}") }))
- {
- students.Add(item);
- }
- List<Task<ItemResponse<Student>>> tasks = new List<Task<ItemResponse<Student>>>();
- var groups= students.Where(x => !string.IsNullOrWhiteSpace(x.classId)).GroupBy(y => y.classId).Select(z => new { key = z.Key,list = z.ToList() });
- foreach (var group in groups) {
- var list= DoIrs(group.list);
- if (list != null) {
- list.ForEach(stu => {
- tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}")));
- });
- }
- }
- int pagesize = 1000;
- if (tasks.Count <= pagesize)
- {
- await Task.WhenAll(tasks);
- }
- else
- {
- int pages = (tasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
- for (int i = 0; i < pages; i++)
- {
- var listssb = tasks.Skip((i) * pagesize).Take(pagesize).ToList();
- await Task.WhenAll(listssb);
- }
- }
- studentsData.AddRange(students);
- }
- return Ok(studentsData);
- }
- private List<Student> DoIrs(List<Student> students) {
- List<int> ids = new List<int>(students.Count);
- bool hasAbc=false;
- int index = students.Count;
- if (!students.Select(x => x.irs).Contains("1"))
- {
- foreach (var stu in students)
- {
- if (int.TryParse(stu.id, out int id))
- {
- ids.Add(id);
- }
- else
- {
- hasAbc = true;
- }
- }
- ids = ids.OrderBy(x => x).ToList();
- if (!hasAbc)
- {
- for (int i = 0; i < ids.Count; i++)
- {
- var stu = students.Find(x => x.id.Equals($"{ids[i]}"));
- if (stu != null)
- {
- stu.irs = $"{(i + 1)}";
- stu.no = $"{(i + 1)}";
- }
- }
- }
- return students;
- }
- else { return null; }
-
- }
-
- public record CorrectStu
- {
- public string id { get; set; }
- public string code { get; set; }
- public List<string> classIds { get; set; }
- }
- /// <summary>
- /// 补充学校教室字段学段id接口
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-room-periodid")]
- public async Task<IActionResult> FixRoomPeriodId(JsonElement jsonElement)
- {
- try
- {
- List<string> schoolId = new();
- var cosmosClient = _azureCosmos.GetCosmosClient();
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: "select distinct value(REPLACE(c.code, 'Room-', '')) from c where c.pk='Room'", requestOptions: new QueryRequestOptions() { }))
- {
- schoolId.Add(item);
- }
- List<Task<ItemResponse<Room>>> allRooms = new(); //存储区域数据
- if (schoolId.Count > 0)
- {
- foreach (var scId in schoolId)
- {
- string periodId = null;
- School scBase = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(scId, new PartitionKey("Base"));
- if(scBase.period.Count > 0)
- periodId = scBase.period[0].id;
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Room>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{scId}") }))
- {
- allRooms.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Room>(item, item.id, new PartitionKey($"Room-{scId}")));
- }
- }
- }
- if (allRooms.Count < 256)
- {
- await Task.WhenAll(allRooms);
- }
- else
- {
- int pages = (allRooms.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<Room>>> tempRoom = allRooms.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempRoom);
- }
- }
- return Ok(new { state = 200, allRooms });
- }
- catch (Exception ex)
- {
- return BadRequest(ex.StackTrace);
- }
- }
- /// <summary>
- /// 修复研修平台账号重复的问题
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-training")]
- public async Task<IActionResult> RepairTraining(JsonElement jsonElement)
- {
- try
- {
- if (!jsonElement.TryGetProperty("trainingIds", out JsonElement ids)) return BadRequest();
- List<TrainingId> trainingIds = ids.ToObject<List<TrainingId>>();
- List<string> noCopyFiles = new();
- var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
- var cosmosClient = _azureCosmos.GetCosmosClient();
- foreach (var item in trainingIds)
- {
- List<ScTeacher> scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "tmdid", $"{item.oldId}" } });
- if (scTeachers.Count > 0)
- {
- scTeachers.ForEach(sct => sct.tmdid = item.newId);
- //保存和更新研修信息
- await table.SaveOrUpdateAll(scTeachers);
- }
- string defaultSc = null;
- //教师基础信息
- Teacher teacher = new();
- var resTchBase = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey("Base"));
- if (resTchBase.Status == 200)
- {
- using var json = await JsonDocument.ParseAsync(resTchBase.ContentStream);
- teacher = json.ToObject<Teacher>();
- defaultSc = teacher.defaultSchool;
- if (string.IsNullOrEmpty(teacher.defaultSchool))
- defaultSc = teacher.schools[0].schoolId;
- teacher.id = $"{item.newId}";
- //教师基础信息
- try {
- teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey(teacher.code));
- } catch { }
- }
- //教师研修文件
- TeacherFile teacherFile = new();
- var resTchFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"TeacherFile-{defaultSc}"));
- if (resTchFile.Status == 200)
- {
- using var json = await JsonDocument.ParseAsync(resTchFile.ContentStream);
- teacherFile = json.ToObject<TeacherFile>();
- teacherFile.id = $"{item.newId}";
- //创建新的教师研修文件
- try {
- teacherFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey(teacherFile.code));
- } catch { }
- }
- //研修统计
- TeacherTrain teacherTrain = new();
- var resTchTrain = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"TeacherTrain-{defaultSc}"));
- if (resTchTrain.Status == 200)
- {
- using var json = await JsonDocument.ParseAsync(resTchTrain.ContentStream);
- teacherTrain = json.ToObject<TeacherTrain>();
- teacherTrain.tmdid = $"{item.newId}";
- teacherTrain.id = $"{item.newId}";
- //研修报告外层文件路径
- if (!string.IsNullOrEmpty($"{teacherTrain.offlineUrl}"))
- {
- string oldOffUrl = teacherTrain.offlineUrl;
- teacherTrain.offlineUrl = teacherTrain.offlineUrl.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!oldOffUrl.Equals(teacherTrain.offlineUrl))
- {
- //复制研修报告
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, "teammodelos", teacherTrain.offlineUrl, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(oldOffUrl);
- }
- }
- if (teacherTrain.offlineRecords.Count > 0)
- {
- foreach (var off in teacherTrain.offlineRecords)
- {
- if (!string.IsNullOrEmpty(off.url))
- {
- string oldOffRe = off.url;
- off.url = off.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!oldOffRe.Equals(off.url))
- {
- //线下研修文件
- var tempFileRe = await BatchCopyFileService.SingleCopyFile(_azureStorage, defaultSc, oldOffRe, item.oldId, item.newId);
- if (tempFileRe != 200)
- noCopyFiles.Add(oldOffRe);
- }
- }
- if (off.other != null)
- {
- //作业附件
- foreach (var offOther in off.other)
- {
- //替换文件路径
- string oldOffOther = offOther.url;
- offOther.url = offOther.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- offOther.blob = offOther.blob.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!oldOffOther.Equals(offOther.url))
- {
- //复制作业附件
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, defaultSc, oldOffOther, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(oldOffOther);
- }
- }
- }
- }
- }
- if (teacherTrain.teacherClasses.Count > 0)
- {
- //课堂实录
- foreach (var tchClass in teacherTrain.teacherClasses)
- {
- string tchCla = tchClass.url;
- //替换课堂实录路径地址
- tchClass.url = tchClass.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!tchCla.Equals(tchClass.url))
- {
- //复制课堂实录文件
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, defaultSc, tchCla, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(tchCla);
- }
- }
- }
- //研修报告信息
- if (teacherTrain.offlineReport != null)
- {
- //替换研修报告信息文件路径地址
- string tchTrain = teacherTrain.offlineReport.url;
- teacherTrain.offlineReport.url = teacherTrain.offlineReport.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- teacherTrain.offlineReport.blob = teacherTrain.offlineReport.blob.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!tchTrain.Equals(teacherTrain.offlineReport.url))
- {
- //研修报告信息文件路径
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, "teammodelos", tchTrain, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(tchTrain);
- }
- }
- teacherTrain.id = item.newId;
- //创建新的教师研修统计
- try { teacherTrain = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherTrain>(teacherTrain, new PartitionKey(teacherTrain.code)); } catch { }
- }
- //课堂实录
- ClassVideo classVideo = new();
- var respCalsVideo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"ClassVideo-{defaultSc}"));
- if (respCalsVideo.Status == 200)
- {
- using var json = await JsonDocument.ParseAsync(respCalsVideo.ContentStream);
- classVideo = json.ToObject<ClassVideo>();
- classVideo.creatorId = $"{item.newId}";
- if (classVideo.files.Count > 0)
- {
- foreach (var cv in classVideo.files)
- {
- string tchCla = cv.url;
- cv.url = cv.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!tchCla.Equals(cv.url))
- {
- //复制课堂实录文件
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, defaultSc, tchCla, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(tchCla);
- }
- }
- }
- classVideo.id = $"{item.newId}";
- //创建新的教师课堂实录
- try { classVideo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<ClassVideo>(classVideo, new PartitionKey(classVideo.code)); } catch { }
- }
- //订阅记录和学习记录
- List<Task<ItemResponse<AbilitySub>>> abilitySubs = new();
- await foreach (var abilitySub in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<AbilitySub>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{defaultSc}-{item.oldId}") }))
- {
- abilitySub.creatorId = item.newId;
- if (abilitySub.uploads.Count > 0)
- {
- foreach (var asup in abilitySub.uploads)
- {
- if (asup.urls.Count > 0)
- {
- foreach (var asupurl in asup.urls)
- {
- string asupUr = asupurl.url;
- asupurl.url = asupurl.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- if (!asupUr.Equals(asupurl.url))
- {
- //订阅记录和学习记录文件地址
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, defaultSc, asupUr, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(asupUr);
- }
- }
- }
- }
- }
- if (abilitySub.otherScore.Count > 0)
- {
- foreach (var abother in abilitySub.otherScore)
- {
- if (abother.tmdid.Equals(item.oldId))
- abother.tmdid = item.oldId;
- }
- }
- abilitySub.code = abilitySub.code.Replace($"-{item.oldId}", $"-{item.newId}");
- try { abilitySubs.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<AbilitySub>(abilitySub, new PartitionKey($"AbilitySub-{defaultSc}-{item.newId}"))); } catch { }
- }
- if (abilitySubs.Count < 256)
- await Task.WhenAll(abilitySubs);
- else
- {
- int pages = (abilitySubs.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<AbilitySub>>> tempAbilSub = abilitySubs.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempAbilSub);
- }
- }
- //教师所在学校的基础信息
- SchoolTeacher schoolTeacher = new();
- var resScTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"Teacher-{defaultSc}"));
- if (resScTeacher.Status == 200)
- {
- using var json = await JsonDocument.ParseAsync(resScTeacher.ContentStream);
- schoolTeacher = json.ToObject<SchoolTeacher>();
- schoolTeacher.id = item.newId;
- //创建新的教师在学校的基础信息
- try {
- schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
- } catch {
- }
- }
- //名单信息
- List<Task<ItemResponse<GroupList>>> groupLists = new();
- await foreach (var grups in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{defaultSc}") }))
- {
- bool isReplace = false;
- if (grups.members.Count > 0)
- {
- foreach (var griupm in grups.members)
- {
- if (griupm.id.Equals(item.oldId))
- {
- griupm.id = item.newId;
- isReplace = true;
- }
- }
- }
- if (grups.creatorId.Equals(item.oldId))
- {
- grups.creatorId = item.newId;
- isReplace = true;
- }
- if (isReplace == true)
- groupLists.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<GroupList>(grups, grups.id, new PartitionKey(grups.code)));
- }
- if (groupLists.Count < 256)
- await Task.WhenAll(groupLists);
- else
- {
- int pages = (groupLists.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<GroupList>>> tempGroups = groupLists.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempGroups);
- }
- }
- //教研活动
- List<Task<ItemResponse<Study>>> studys = new();
- await foreach (var study in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Study>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{defaultSc}") }))
- {
- bool isReplace = false;
- if (study.creatorId.Equals(item.oldId))
- {
- study.creatorId = item.newId;
- isReplace = true;
- }
- if (study.teacIds.Contains(item.oldId) == true)
- {
- study.teacIds = study.teacIds.Select(x => x.Replace($"{item.oldId}", $"{item.newId}")).ToList();
- isReplace = true;
- }
- //if (isReplace == true)
- studys.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Study>(study, study.id, new PartitionKey($"Study-{defaultSc}")));
- }
- if (studys.Count < 256)
- await Task.WhenAll(studys);
- else
- {
- int pages = (studys.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<Study>>> tempStudys = studys.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempStudys);
- }
- }
- //教研测验活动记录
- List<Task<ItemResponse<ExamLite>>> examLites = new();
- await foreach (var examl in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamLite>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{defaultSc}") }))
- {
- bool isReplace = false;
- if (examl.teachers.Count > 0)
- {
- foreach (var examTch in examl.teachers)
- {
- if (examTch.id.Equals(item.oldId))
- {
- examTch.id = item.newId;
- isReplace = true;
- }
- }
- }
- //if (isReplace == true)
- examLites.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamLite>(examl, examl.id, new PartitionKey($"ExamLite-{defaultSc}")));
- }
- if (examLites.Count < 256)
- await Task.WhenAll(examLites);
- else
- {
- int pages = (examLites.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<ExamLite>>> tempExam = examLites.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempExam);
- }
- }
- //作业记录
- List<Task<ItemResponse<HomeworkRecord>>> homeworkRecord = new();
- await foreach (var homerec in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<HomeworkRecord>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{item.oldId}") }))
- {
- bool isReplace = false;
- if (homerec.content.Count > 0)
- {
- foreach (var hrCon in homerec.content)
- {
- if (hrCon.url.Contains($"/{item.oldId}/"))
- {
- string hrUrl = hrCon.url;
- hrCon.url = hrCon.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
- hrCon.blob = hrCon.blob.Replace($"/{item.oldId}/", $"/{item.newId}/");
- //作业附件地址
- var tempFileCopy = await BatchCopyFileService.SingleCopyFile(_azureStorage, defaultSc, hrUrl, item.oldId, item.newId);
- if (tempFileCopy != 200)
- noCopyFiles.Add(hrUrl);
- isReplace = true;
- }
- }
- }
- if (isReplace == true)
- {
- homerec.code = homerec.code.Replace($"-{item.oldId}", $"-{item.newId}");
- try { homeworkRecord.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<HomeworkRecord>(homerec, new PartitionKey(homerec.code))); } catch { }
- }
- }
- if (homeworkRecord.Count < 256)
- await Task.WhenAll(homeworkRecord);
- else
- {
- int pages = (homeworkRecord.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<HomeworkRecord>>> tempHomeR = homeworkRecord.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempHomeR);
- }
- }
- //视频点评
- List<Task<ItemResponse<Appraise>>> appraises = new();
- await foreach (var appra in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Appraise>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Appraise-{item.oldId}") }))
- {
- bool isRepCode = false;
- bool isReplace = false;
- if (appra.code.Contains(item.oldId))
- {
- appra.code = appra.code.Replace($"-{item.oldId}", $"-{item.newId}");
- isRepCode = true;
- }
- if (appra.roles.Count > 0)
- {
- foreach (var appRoles in appra.roles)
- {
- if (appRoles.commentTmdid.Equals(item.oldId))
- {
- appRoles.commentTmdid = item.newId;
- isReplace = true;
- }
- }
- }
- if ((isRepCode == true && isReplace == true) || (isRepCode == true && isReplace == false))
- try { appraises.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Appraise>(appra, new PartitionKey(appra.code))); } catch { }
- if (isReplace == true && isRepCode == false)
- appraises.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Appraise>(appra, appra.id, new PartitionKey(appra.code)));
- }
- if (appraises.Count < 256)
- await Task.WhenAll(appraises);
- else
- {
- int pages = (appraises.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<Appraise>>> tempAppra = appraises.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempAppra);
- }
- }
- //话题记录
- List<Task<ItemResponse<Debate>>> debates = new();
- await foreach (var debate in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Debate>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Debate-{defaultSc}") }))
- {
- bool isReplace = false;
- if (debate.tmdid.Equals(item.oldId))
- {
- debate.tmdid = item.newId;
- isReplace = true;
- }
- if (debate.replies.Count > 0)
- {
- foreach (var deRep in debate.replies)
- {
- if (deRep.tmdid.Equals(item.oldId))
- {
- deRep.tmdid = item.newId;
- isReplace = true;
- }
- }
- }
- if (isReplace == true)
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Debate>(debate, debate.id, new PartitionKey(debate.code));
- }
- }
- return Ok(new { state = 200, noCopyFiles });
- }
- catch (Exception ex)
- {
- return Ok(new { state = 500 });
- }
- }
- /// <summary>
- /// 学校id将大写转换小写 并新增学校相关数据信息;修改教师学校的id
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("fix-uppertolower")]
- public async Task<IActionResult> RepairUpperToLower(JsonElement jsonElement)
- {
- string large = "GXJCXX";
- var cosmosClient = _azureCosmos.GetCosmosClient();
- List<string> containe = new() { "School", "Student", "Teacher" };
- List<dynamic> noFail = new();
- foreach (var itemC in containe)
- {
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, itemC).GetItemQueryStreamIterator(queryText: $"select value(c) from c where (contains(c.code,'{large}') or contains(c.id,'{large}'))"))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- string oldId = obj.GetProperty("id").GetString();
- string oldCode = obj.GetProperty("code").GetString();
- var jsonElm = obj.ToJsonString().Replace(large, large.ToLower()).ToObject<JsonElement>();
- jsonElm.TryGetProperty("code", out JsonElement code);
- byte[] bytes = Encoding.UTF8.GetBytes(jsonElm.GetRawText());
- var memoryStream = new MemoryStream(bytes);
- var resp = await cosmosClient.GetContainer(Constant.TEAMModelOS, itemC).CreateItemStreamAsync(memoryStream, new PartitionKey($"{code}"));
- if (resp.Status != 201)
- noFail.Add(new { container = itemC, id = oldId, code = oldCode });
- }
- }
- }
- }
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c join sc in c.schools where sc.schoolId='{large}'",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- var jsonElm = obj.ToJsonString().Replace(large, large.ToLower()).ToObject<JsonElement>();
- jsonElm.TryGetProperty("id", out JsonElement id);
- jsonElm.TryGetProperty("code", out JsonElement code);
- byte[] bytes = Encoding.UTF8.GetBytes(jsonElm.GetRawText());
- var memoryStream = new MemoryStream(bytes);
- var resp = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemStreamAsync(memoryStream, $"{id}", new PartitionKey($"Base"));
- if(resp.Status != 200)
- noFail.Add(new { container = "Teacher", id = id, code = code });
- }
- }
- }
- return Ok(new { state = 200, noFail });
- }
- /// <summary>
- /// 根據錯題庫(ErrorItems)生成各學校學生各科錯題數後記入Redis
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("set-erroritems-count")]
- public async Task<IActionResult> SetErrorItemsCount(JsonElement json)
- {
- var azureCosmosClient = _azureCosmos.GetCosmosClient();
- await ErrorItemsService.cntStuErrorItemsAsync(_azureRedis, azureCosmosClient, _dingDing);
- return Ok(new { state = 200 });
- }
- /// <summary>
- /// 刪除學生智慧錯題中 activityId = null 的資料
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("del-maLearn-no-activityId")]
- public async Task<IActionResult> DelMaLearnNoActivityId()
- {
- List<object> result = new List<object>();
- var cosmosClient = _azureCosmos.GetCosmosClient();
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE CONTAINS(c.code, 'MaLearn') AND c.type = 'answer' AND IS_DEFINED(c.qId) AND ( c.activityId = null OR NOT IS_DEFINED(c.activityId) )", requestOptions: new QueryRequestOptions() { }))
- {
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- string id = obj.GetProperty("id").GetString();
- string code = obj.GetProperty("code").GetString();
- await cosmosClient.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync(id, new PartitionKey($"{code}"));
- result.Add(new { id = id, code = code });
- }
- }
- }
- return Ok(new { state = 200, result = result });
- }
- public record TrainingId
- {
- public string oldId { get; set; }
- public string newId { get; set; }
- }
- }
- }
|