DBUtils4PG_old.py 386 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177
  1. import concurrent.futures
  2. import datetime
  3. import psycopg2
  4. from pypinyin import pinyin, Style
  5. import traceback
  6. import openpyxl
  7. import msoffcrypto
  8. import io
  9. import requests
  10. import json
  11. import time
  12. import hmac
  13. import hashlib
  14. import base64
  15. import urllib.parse
  16. from openpyxl import Workbook
  17. from Functions import utils
  18. from unitls.settings import DBServer, loginDB, flightDB4
  19. host, port, user, password,online_host, online_port, online_user,online_password = DBServer()
  20. databaseloginDB=loginDB()
  21. databaseflightDB4=flightDB4()
  22. zydy_simple={"FLIGHT_ID":"航班编号","flightIds":"航班编号对","ACNO": "机号", "ACTYPE": "机型", "ENG_TYPE": "发动机", "FLIGHT_NO": "保障航班号",
  23. "STA": "计划到达", "ETA": "预计到达","DEP_CH":"进港机场","DEP_CH1":"离港机场","ARR_DEP":"进出港航班号","FLIGHT_DATE":"航班日期",
  24. "TASKTYPE": "航班类型","FLIGHT_STATUS":"航班状态","STD": "预计起飞","ATA": "实际到达","ATD": "实际起飞","TD": "预计起飞",
  25. "BAY1": "预计机位", "BAY_2": "进港机位", "BAY2": "预计机位", "BAY": "离港机位","WXRY": "维修人员", "FXRY": "放行人员",
  26. "TASKSTS": "维修状态","ZY_FLIGHT": "重要航班", "SJ": "随机","BL": "保留", "FLG_VR": "备降返航", "TASKSTS_TIME":"维修状态时间",
  27. "AP": "航前", "TR": "短停", "AF": "航后","TAF": "特航前","":"未显示","短停":"短停","ECSJRY":"二送人员","TASKSTS_ECSJ":"二送状态","FJ":"附加消息","CANCELID":"取消标志"}
  28. zydy = {"FLIGHT_ID":"航班编号","flightIds":"航班编号对","ACNO": "机号", "ACTYPE": "机型", "ENG_TYPE": "发动机", "FLIGHT_NO": "保障航班号",
  29. "STA": "非航前计划到达", "ETA": "非航前预计到达","DEP_CH":"进港机场","DEP_CH1":"离港机场","ARR_DEP":"进出港航班号","FLIGHT_DATE":"航班日期",
  30. "TASKTYPE": "航班类型","FLIGHT_STATUS":"航班状态","STD": "航前预计起飞","ATA": "非航前实际到达","ATD": "航前实际起飞","TD": "非航前预计起飞",
  31. "BAY1": "非航前预计进港机位", "BAY_2": "非航前进港机位", "BAY2": "航前预计离港机位", "BAY": "航前离港机位","WXRY": "维修人员", "FXRY": "放行人员",
  32. "TASKSTS": "维修状态","ZY_FLIGHT": "重要航班", "SJ": "随机","BL": "保留", "FLG_VR": "备降返航", "TASKSTS_TIME":"维修状态时间",
  33. "AP": "航前", "TR": "短停", "AF": "航后","TAF": "特航前","":"未显示","短停":"短停","ECSJRY":"二送人员","TASKSTS_ECSJ":"二送状态","FJ":"附加消息","CANCELID":"取消标志"}
  34. sortLabel=["编号","航班编号","保障时间","航班类型","航班日期","级别"]
  35. logsLabel=["编号","航班编号","警告信息","信息状态","提示信息","产生时间","处理人","处理时间","变更字段","显示对象","提示内容"]
  36. changestsLabel=["航班编号","航班编号对","机号","发动机","机型","保障航班号","进港机场","离港机场","进出港航班号","航班日期","航班状态",
  37. "航班类型","非航前计划到达","航前预计起飞","非航前实际到达","航前实际起飞","非航前预计到达","非航前预计起飞","非航前预计进港机位",
  38. "非航前进港机位","航前预计离港机位","航前离港机位","维修人员","放行人员","维修状态","重要航班","随机","保留","备降返航","维修状态时间"]
  39. workloadLabel=["编号","机号","机位","航班编号","开始时间","结束时间","保障日期","航班类型","人员状态"]
  40. workerinfoLabel=["工号","姓名","部门","岗位","通行证","电话","年限","川航授权","南航授权","试车授权","星级","籍贯"] #待持续更新
  41. authorityLabel=["编号","用户名","密码","权限","使用人"]
  42. taskLabel=["编号","时间","提示内容","详细信息"]
  43. RiskLabel=["风险编号","状态","提示内容","触发条件1","触发条件2","触发条件3","触发条件4","触发条件5"]
  44. workjobkeyLabel=["任务编号","工作包编号","查询开始时间","查询结束时间","开始时间","基地","项目描述","工作步骤","机号","机型","航班类型"]
  45. flightstsLabel=["航班编号","机号","机位","接机到位","放行","销子夹板","随机到位","二送到位","接机已到位提示","已放行提示","销子夹板已提示","随机已到位提示","二送已到位提示","天府飞机"]
  46. flightinfoLabel=["航班编号","航班编号对","机号","发动机","机型","保障航班号","进港机场","离港机场","进出港航班号","航班日期","航班状态",
  47. "航班类型","非航前计划到达","航前预计起飞","非航前实际到达","非航前预计到达","航前实际起飞","非航前预计起飞","非航前预计进港机位",
  48. "非航前进港机位","航前预计离港机位","航前离港机位","维修人员","放行人员","维修状态","重要航班","随机","保留","备降返航","维修状态时间","二送人员","二送状态","附加消息","取消标志"]
  49. trackLabel=["单号","创建时间","类型","清单","紧急程度","创建人","派送地址","接收人","库管开始","库管派发","领料地址",
  50. "金熊猫接收","金熊猫到位","配送到位","签收人","备注信息","一","二","三","四","五","六","七","八"]
  51. enflightifnoLabel=["FLIGHT_ID","flightIds","ACNO","ENG_TYPE","ACTYPE","FLIGHT_NO","DEP_CH","DEP_CH1","ARR_DEP","FLIGHT_DATE","FLIGHT_STATUS",
  52. "TASKTYPE","STA","STD","ATA","ETA","ATD","TD","BAY1","BAY_2","BAY2","BAY","WXRY","FXRY","TASKSTS","ZY_FLIGHT",
  53. "SJ","BL","FLG_VR","TASKSTS_TIME","ECSJRY","TASKSTS_ECSJ","FJ","CANCELID"]
  54. TaskflightinfoLabel=["航班编号","机号","航班日期","航班类型","非航前计划到达","航前预计起飞","非航前实际到达","航前实际起飞","非航前预计到达","预飞预达",
  55. "非航前进港机位","航前离港机位","维修人员","放行人员","维修状态","随机","保留","维修状态时间","工作包","二次送机","进出港航班号","任务编号"]#重要航班和备降返航有待研究
  56. TaskflightinfoLabel2en={"ACNO":"机号","FLIGHTDATE":"航班日期","TASKTYPE":"航班类型","STA":"非航前计划到达","STD":"航前预计起飞","ATA":"非航前实际到达","ATD":"航前实际起飞","ETA":"非航前预计到达","TA_TD":"预飞预达",
  57. "BAY_A":"非航前进港机位","BAY_B":"航前离港机位","WX":"维修人员","FX":"放行人员","TASKSTS":"维修状态","SJ_DEP":"随机","SJ_ARR":"随机",
  58. "BL":"保留","TASKSTS_TIME":"维修状态时间","FJ_TASKIDS":"工作包","ECSJ":"二次送机","FNO":"进出港航班号","TASKID":"任务编号"}
  59. #'''"FLIGHTID1":"航班编号","FLIGHTID2":"航班编号",'''
  60. #displayLabel=["显示类型","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","99","101","102","103","109"]
  61. displayLabel=["ID","A","B"]
  62. peopleScheduleLabel=["编号","航班编号","显示模式","放行","勤务1","勤务2","工1","工2","工3","附加消息"]
  63. CalllistLabel=["航班编号","电话","工号","姓名","航班号","附加消息","拨号次数","创建时间","接通时间"]
  64. rowlistLabel={10:"放行",11:"勤务1",12:"勤务2",13:"工1",14:"工2",15:"工3",-1:"附加消息"}
  65. pglistLabel=["姓名","工号","角色","班次"]
  66. pglistLabel2en={"NAME":"姓名","EMP_NO":"工号","MAINLY_ROLE":"角色","SHIFT":"班次"}
  67. ecsjtaskSTS={"":"空值","0":"空值",'5':'二送任务待确认', '10':'二送任务已确认', '15':'二送到位',"20":"二送离场"}
  68. #headerLabel = utils.headerLabel
  69. #headerLabelKey=utils.headerLabelKey
  70. headerLabel = flightinfoLabel
  71. headerLabelKey=enflightifnoLabel
  72. taskType = utils.taskType
  73. taskSTS = utils.taskSTS
  74. flightSTS = utils.flightSTS
  75. flightSTSDic = utils.flightSTSDic
  76. class flightDB():
  77. def __init__(self, host, port, user, password, database):
  78. self.conn = psycopg2.connect(
  79. host=host,
  80. port=port,
  81. user=user,
  82. password=password,
  83. database=database
  84. )
  85. self.c = self.conn.cursor()
  86. def initTable(self, tableName:str,primarykey:str,primarykeyStr:str,keyDict:dict):
  87. try:
  88. keyStr = ''
  89. num = 1
  90. for key in keyDict:
  91. if num !=len(keyDict):
  92. keyStr += '{} {},\n'.format(key,keyDict[key])
  93. else:
  94. keyStr += '{} {}'.format(key, keyDict[key])
  95. num +=1
  96. curStr ="""
  97. create table if not exists {} (
  98. {} {} ,
  99. {}
  100. )
  101. """.format(tableName, primarykey, primarykeyStr,keyStr)
  102. #print(curStr)
  103. self.c.execute(curStr)
  104. self.conn.commit()
  105. except Exception:
  106. #print(curStr)
  107. print(traceback.format_exc())
  108. dingding_alert(traceback.format_exc())
  109. def insertData(self, tableName:str, data:dict, *args):
  110. try:
  111. #curStr1 = 'insert into {} '.format(tableName)
  112. num = 1
  113. curStr2 = ''
  114. for key in data:
  115. if num != len(data):
  116. curStr2+='{},'.format(key)
  117. else:
  118. curStr2+='{}'.format(key)
  119. num+=1
  120. curStr3 = ''
  121. num = 1
  122. for key in data:
  123. if num != len(data):
  124. curStr3+="'{}',".format(data[key])
  125. else:
  126. curStr3+="'{}'".format(data[key])
  127. num+=1
  128. curStr = """
  129. insert into {} ({})
  130. values ({})
  131. """.format(tableName, curStr2, curStr3)
  132. #print(curStr)
  133. self.c.execute(curStr)
  134. if args==():
  135. self.conn.commit()
  136. except Exception:
  137. print(traceback.format_exc())
  138. #print(curStr)
  139. #dingding_alert(traceback.format_exc())
  140. def lazyInsertData(self,tableName:str, data:dict):
  141. self.insertData(tableName, data, 'lazy')
  142. def lazydeleteTable(self,tablename:str):
  143. curStr = """delete from {}""".format(tablename)
  144. self.c.execute(curStr)
  145. def lazyInsertData2(self,tableName:str, curStr2, curStr3):
  146. curStr = """insert into {} ({})values {}""".format(tableName, curStr2, curStr3)
  147. self.c.execute(curStr)
  148. #print(curStr)
  149. def lazyInsertData3(self,curStr1, curStr2, curStr3):
  150. curStr = """insert into display (ID, A, B)values (%s,'%s','%s')"""%(curStr1, curStr2, curStr3)
  151. self.c.execute(curStr)
  152. #print(curStr)
  153. def FunctionCommit(self):
  154. self.conn.commit()
  155. def FunctionRollback(self):
  156. self.conn.rollback()
  157. def deleteTable(self, tablename:str, *condition:str):
  158. try:
  159. #print(condition)
  160. if condition !=():
  161. curStr = """
  162. delete from {} where {}
  163. """.format(tablename, condition[0])
  164. else:
  165. curStr = """
  166. delete from {}
  167. """.format(tablename)
  168. self.c.execute(curStr)
  169. self.conn.commit()
  170. return "ok"
  171. except Exception:
  172. dingding_alert(traceback.format_exc())
  173. dingding_alert(curStr)
  174. return "fail"
  175. def copyTable(self, oldtablename:str, newTablename:str):
  176. try:
  177. curStr = """
  178. drop table {}
  179. """.format(newTablename)
  180. self.c.execute(curStr)
  181. self.conn.commit()
  182. except Exception:
  183. dingding_alert(traceback.format_exc())
  184. dingding_alert(curStr)
  185. def sortTable(self, tablename:str, tableKey:str, fn):
  186. try:
  187. curStr = """
  188. select * from {} order by {} {}
  189. """.format(tablename, tableKey, fn)
  190. #print(curStr)
  191. self.c.execute(curStr)
  192. return self.c.fetchall()
  193. except Exception:
  194. dingding_alert(traceback.format_exc())
  195. def sort_queryTable(self, findkey:str,tablename:str, condition:str,tableKey:str, fn):
  196. try:
  197. curStr = """
  198. select {} from {} where {} order by {} {}
  199. """.format(findkey,tablename, condition,tableKey, fn)
  200. #print(curStr)
  201. self.c.execute(curStr)
  202. return self.c.fetchall()
  203. except Exception:
  204. dingding_alert(traceback.format_exc())
  205. dingding_alert(curStr)
  206. def sort_queryTable2(self, findkey:str,tablename:str, condition:str,tableKey:str, fn,tableKey1:str, fn1):
  207. try:
  208. curStr = """
  209. select {} from {} where {} order by {} {},{} {}
  210. """.format(findkey,tablename, condition,tableKey, fn,tableKey1, fn1)
  211. #print(curStr)
  212. self.c.execute(curStr)
  213. return self.c.fetchall()
  214. except Exception:
  215. dingding_alert(traceback.format_exc())
  216. dingding_alert(curStr)
  217. def queryTabel(self, tablename:str, key:str, condition:str):
  218. try:
  219. curStr1 = """
  220. SELECT EXISTS (
  221. SELECT * FROM pg_catalog.pg_tables
  222. WHERE tablename = '{}' AND schemaname = 'public'
  223. );
  224. """.format(tablename.lower())
  225. self.c.execute(curStr1)
  226. result = self.c.fetchall()[0][0]
  227. if result:
  228. curStr = """
  229. select {} from {} where {}
  230. """.format(key, tablename, condition)
  231. #print(curStr)
  232. self.c.execute(curStr)
  233. return self.c.fetchall()
  234. else:
  235. return None
  236. except Exception:
  237. print(traceback.format_exc())
  238. #print(curStr)
  239. #dingding_alert(traceback.format_exc())
  240. #dingding_alert(curStr)
  241. self.conn.rollback()
  242. def getAlldata(self, tablename:str):
  243. try:
  244. curStr = """select * from {}""".format(tablename)
  245. self.c.execute(curStr)
  246. return self.c.fetchall()
  247. except Exception:
  248. dingding_alert(traceback.format_exc())
  249. dingding_alert(curStr)
  250. def upDateItem(self, tablename:str, dateDic:dict, condition:str, *args):
  251. try:
  252. setStr = ''
  253. for key in dateDic:
  254. if tablename == 'display':
  255. setStr += '{}={},'.format(key, str(dateDic[key]).replace("'","''"))
  256. else:
  257. setStr += '{}={},'.format(key, dateDic[key])
  258. if tablename == 'display':
  259. setStr = setStr[:-1].replace('"',"'")
  260. else:
  261. setStr = setStr[:-1]
  262. curStr = """
  263. update {} set {} where {}
  264. """.format(tablename, setStr, condition)
  265. #print(curStr)
  266. if setStr !="":
  267. self.c.execute(curStr)
  268. if args == ():
  269. self.conn.commit()
  270. except Exception:
  271. print(traceback.format_exc())
  272. #print(curStr)
  273. dingding_alert(traceback.format_exc())
  274. def lazyUpdateItem(self,tablename:str, dateDic:dict, condition:str):
  275. self.upDateItem(tablename,dateDic,condition,'lazy')
  276. def getSingledata(self,findkey:str,tablename:str):
  277. try:
  278. curStr = """
  279. select {} from {}
  280. """.format(findkey,tablename)
  281. #print(curStr)
  282. self.c.execute(curStr)
  283. return self.c.fetchall()
  284. except Exception:
  285. dingding_alert(traceback.format_exc())
  286. def deleteSingledata(self,tablename:str,findkey:str):
  287. try:
  288. curStr = """
  289. delete from {} where {}
  290. """.format(tablename,findkey)
  291. self.c.execute(curStr)
  292. #print(curStr)
  293. self.conn.commit()
  294. except Exception:
  295. dingding_alert(traceback.format_exc())
  296. def close(self):
  297. try:
  298. self.conn.close()
  299. except Exception:
  300. dingding_alert(traceback.format_exc())
  301. def infoConfirm(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
  302. try:
  303. peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
  304. if displayMode =="A":
  305. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  306. flightid_new=flightid+"-1"+"-A"
  307. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  308. flightid_new = flightid + "-2" + "-A"
  309. elif displayMode =="B":
  310. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  311. flightid_new=flightid+"-1"+"-B"
  312. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  313. flightid_new = flightid + "-2" + "-B"
  314. peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
  315. newdic={}
  316. if len(peopleSchedule_sts) != 0:
  317. for i in range(3,9):
  318. if "√" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
  319. newitem=peopleSchedule_sts[0][i]+"√"
  320. newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
  321. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  322. except Exception:
  323. dingding_alert(traceback.format_exc())
  324. def infoConfirm3(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
  325. try:
  326. peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
  327. if displayMode =="A":
  328. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  329. flightid_new=flightid+"-1"+"-A"
  330. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  331. flightid_new = flightid + "-2" + "-A"
  332. elif displayMode =="B":
  333. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  334. flightid_new=flightid+"-1"+"-B"
  335. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  336. flightid_new = flightid + "-2" + "-B"
  337. peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
  338. newdic={}
  339. if len(peopleSchedule_sts) != 0:
  340. for i in range(3,9):
  341. if "*" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
  342. newitem=peopleSchedule_sts[0][i]+"*"
  343. newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
  344. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  345. except Exception:
  346. dingding_alert(traceback.format_exc())
  347. def infoConfirm2(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
  348. try:
  349. peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
  350. if displayMode =="A":
  351. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  352. flightid_new=flightid+"-1"+"-A"
  353. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  354. flightid_new = flightid + "-2" + "-A"
  355. elif displayMode =="B":
  356. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  357. flightid_new=flightid+"-1"+"-B"
  358. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  359. flightid_new = flightid + "-2" + "-B"
  360. peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
  361. newdic={}
  362. if len(peopleSchedule_sts) != 0:
  363. for i in range(3,9):
  364. if "!" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
  365. newitem="!"+peopleSchedule_sts[0][i]
  366. newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
  367. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  368. except Exception:
  369. dingding_alert(traceback.format_exc())
  370. def dingding_alert(msg):
  371. dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=9c78c711f14ba3345d6dc492dc5ca8118c421516d611b5de46854fb8e158565f"
  372. timestamp = str(round(time.time() * 1000))
  373. secret = 'SEC09f744f81b55c8a18f0d77a3ab60bf4e1ec3f16b85f025e6a4f75ddff00a8fd4'
  374. secret_enc = secret.encode('utf-8')
  375. string_to_sign = '{}\n{}'.format(timestamp, secret)
  376. string_to_sign_enc = string_to_sign.encode('utf-8')
  377. hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
  378. sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
  379. dingding_url = dingding_webhook + '&timestamp=' + timestamp + "&sign=" + sign
  380. header = {
  381. "Content-Type": "application/json"
  382. }
  383. data = {
  384. "at": {
  385. "atMobiles":(123,456),
  386. # "isAtAll": True
  387. },
  388. "text": {
  389. "content": msg
  390. },
  391. "msgtype": "text"
  392. }
  393. res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
  394. def dingding_alert1(phone:list,msg):
  395. dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=9c78c711f14ba3345d6dc492dc5ca8118c421516d611b5de46854fb8e158565f"
  396. timestamp = str(round(time.time() * 1000))
  397. secret = 'SEC09f744f81b55c8a18f0d77a3ab60bf4e1ec3f16b85f025e6a4f75ddff00a8fd4'
  398. secret_enc = secret.encode('utf-8')
  399. string_to_sign = '{}\n{}'.format(timestamp, secret)
  400. string_to_sign_enc = string_to_sign.encode('utf-8')
  401. hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
  402. sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
  403. dingding_url = dingding_webhook + '&timestamp=' + timestamp + "&sign=" + sign
  404. if phone:
  405. header = {
  406. "Content-Type": "application/json"
  407. }
  408. data = {
  409. "at": {
  410. "atMobiles": phone,
  411. },
  412. "text": {
  413. "content": msg
  414. },
  415. "msgtype": "text"
  416. }
  417. else:
  418. header = {
  419. "Content-Type": "application/json"
  420. }
  421. data = {
  422. "at": {
  423. "isAtAll": True
  424. },
  425. "text": {
  426. "content": msg
  427. },
  428. "msgtype": "text"
  429. }
  430. res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
  431. def dingding_alert11(phone:list,msg):
  432. dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=c3be52d9ae7307dd7ceb0b677f569c47de2ff81b20fe30c328c75fbd9ab81383"
  433. timestamp = str(round(time.time() * 1000))
  434. secret = 'SEC14f583c6f735044be3f9f6fdc53edb7cf0b7d56d9b63c4b78bcafa9880814f9e'
  435. secret_enc = secret.encode('utf-8')
  436. string_to_sign = '{}\n{}'.format(timestamp, secret)
  437. string_to_sign_enc = string_to_sign.encode('utf-8')
  438. hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
  439. sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
  440. dingding_url = dingding_webhook + '&timestamp=' + timestamp + "&sign=" + sign
  441. if phone:
  442. header = {
  443. "Content-Type": "application/json"
  444. }
  445. data = {
  446. "at": {
  447. "atMobiles": phone,
  448. },
  449. "text": {
  450. "content": msg
  451. },
  452. "msgtype": "text"
  453. }
  454. else:
  455. header = {
  456. "Content-Type": "application/json"
  457. }
  458. data = {
  459. "at": {
  460. "isAtAll": True
  461. },
  462. "text": {
  463. "content": msg
  464. },
  465. "msgtype": "text"
  466. }
  467. res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
  468. def maintainAuthCheck(fdb:flightDB,name,flighttype):
  469. search=fdb.queryTabel("workerinfo","姓名","姓名 = '{}' and 南航授权 like '%{}%'".format(name,flighttype))
  470. if search ==None or len(search) !=0:
  471. res = {"返回值":"ok"}
  472. else:
  473. res = {"返回值": "fail"}
  474. return res
  475. def checkLoadSingal(wdb:flightDB,worknum,time,time2):
  476. try:
  477. table="workload"+str(worknum)
  478. #peopleLabel = ["序号", "保障日期", "类型", "机号", "机位", "开始时间", "结束时间"]
  479. LoadSingals={}
  480. res = wdb.sort_queryTable2("*", table, "保障日期='%s' or 保障日期='%s'"%(time,time2), "保障日期", "desc", "结束时间", "ASC")
  481. j=0
  482. if len(res) != 0:
  483. for i in res:
  484. LoadSingal = {}
  485. LoadSingal["序号"]=j
  486. LoadSingal["保障日期"] = i[6][0:10]
  487. if i[0][-1]=="1" and (i[7]=="特后前" or i[7]=="短停"):
  488. LoadSingal["类型"] = i[7]+"接机"
  489. elif i[0][-1]=="2" and (i[7]=="特后前" or i[7]=="短停"):
  490. LoadSingal["类型"] = i[7] + "送机"
  491. else:
  492. LoadSingal["类型"] = i[7]
  493. LoadSingal["机号"] = i[1]
  494. LoadSingal["机位"] = i[2]
  495. LoadSingal["开始时间"] = i[4]
  496. LoadSingal["结束时间"] = i[5]
  497. LoadSingals[j]=LoadSingal
  498. j += 1
  499. #print(LoadSingals)
  500. return LoadSingals
  501. except Exception:
  502. dingding_alert(traceback.format_exc())
  503. def changepassword(user,old,new):
  504. try:
  505. loginTabledb =flightDB(host=host,
  506. port=port,
  507. user=user,
  508. password=password,
  509. database=databaseloginDB
  510. )
  511. newdic={"密码":"'%s'"%new}
  512. loginTabledb.upDateItem("loginTable",newdic,"登录名='%s' and 密码='%s'"%(user,old))
  513. loginTabledb.close()
  514. except Exception:
  515. dingding_alert(traceback.format_exc())
  516. def qtPeopleLoad(fdb:flightDB,workLoad:flightDB,bc:str,nowDaystr:str):
  517. try:
  518. qtPeopleLoad={}
  519. aa=[]
  520. selectdaystr = str(nowDaystr)[0:4] + "-" + str(nowDaystr)[4:6] + "-" + str(nowDaystr)[6:] + " 00:00:00"
  521. selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
  522. selectday_2 = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(days=1)
  523. nowDay = datetime.date.today().strftime("%Y%m%d")
  524. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  525. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  526. nowtime = datetime.datetime.now()
  527. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  528. a_str = nowDay_str2 + " 00:00:00"
  529. b_str = nowDay_str2 + " 17:00:00"
  530. a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  531. b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
  532. nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  533. tomorrow_search = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  534. yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  535. if bc == "A":
  536. pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
  537. elif bc == "B" and nowDaystr == nowDay and a < nowtime < b:
  538. pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
  539. elif bc == "B" and nowDaystr == nowDay and b < nowtime:
  540. pglist_str = fdb.queryTabel("pglist{}".format(nowDay), "*", "班次='%s'" % bc)
  541. elif bc == "B" and nowDaystr == nowDay_1:
  542. pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
  543. elif bc == "B" and nowDaystr < nowDay_1:
  544. pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
  545. else:
  546. pglist_str = []
  547. diplaylist = pglist_str
  548. # peopleLabel = ["序号", "姓名", "角色", "总量", "当前", "最后时间"]
  549. rowNum = 0
  550. JS = ""
  551. workload = []
  552. workload_now = ""
  553. lastone=""
  554. for row in diplaylist:
  555. col={}
  556. if len(fdb.queryTabel('workerinfo', "*", "姓名='%s'" % row[0])) != 0:
  557. workload = []
  558. workload_now = []
  559. if bc == "A":
  560. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and 保障日期='%s'" % nowDayStr_search)
  561. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and 保障日期='%s'" % nowDayStr_search))
  562. elif bc == "B" and nowDaystr == nowDay and a < nowtime < b: # 选择今天00900之前的夜班
  563. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search))
  564. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search)))
  565. elif bc == "B" and nowDaystr == nowDay and b < nowtime:
  566. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, tomorrow_search))
  567. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, tomorrow_search)))
  568. elif bc == "B" and nowDaystr == nowDay_1: # 选择今天之前的夜班
  569. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search))
  570. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search)))
  571. elif bc == "B" and nowDaystr < nowDay_1: # 选择今天之前的夜班
  572. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (selectday, selectday_2))
  573. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*", "结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (selectday, selectday_2)))
  574. time = []
  575. lastone = ""
  576. for j in workload:
  577. time.append(j[4])
  578. time.append(j[5])
  579. if len(time) != 0:
  580. lastone = time[0]
  581. for i in range(1, len(time) - 1):
  582. if lastone < time[i]:
  583. lastone = time[i]
  584. lastone = lastone[-8:-3]
  585. if row[2] == "WX":
  586. JS = "维修员"
  587. elif row[2] == "FX":
  588. JS ="放行"
  589. col={"序号":rowNum,"姓名":row[0],"角色":JS,"总量":str(len(workload)),"当前":str(workload_now),"最后时间":lastone,}
  590. aa.append(col)
  591. rowNum += 1
  592. if len(aa) != 0:
  593. #aa.sort(key=lambda x:(x["角色"],x['最后时间'],x['当前'],x['总量']))
  594. aa.sort(key=lambda x: (x["角色"], x['当前'], x['最后时间'], x['总量']))
  595. #print(aa)
  596. rowNum1=0
  597. for i in aa:
  598. i["序号"]=rowNum1
  599. qtPeopleLoad[rowNum1]=i
  600. rowNum1 += 1
  601. #print(qtPeopleLoad)
  602. return qtPeopleLoad
  603. except Exception:
  604. dingding_alert(traceback.format_exc())
  605. def updateDragDropItem(fdb:flightDB,column,text,flightid,displayMode,flighttype,selectedtime):
  606. try:
  607. flightid_new=""
  608. if displayMode =="A":
  609. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  610. flightid_new=flightid+"-1"+"-A"
  611. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  612. flightid_new = flightid + "-2" + "-A"
  613. elif displayMode =="B":
  614. if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
  615. flightid_new=flightid+"-1"+"-B"
  616. elif flighttype =="航前":
  617. flightid_new = flightid + "-2" + "-B"
  618. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  619. flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
  620. newdic = {}
  621. if str(flightid_new) not in str(flightids_in_peopleSchedule) and str(flightid_new) !="":
  622. newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
  623. for i in rowlistLabel.keys():
  624. if i == int(column):
  625. if text != "清空项目12345678987654321":
  626. newdic[rowlistLabel[i]] = text
  627. else:
  628. newdic[rowlistLabel[i]] = ""
  629. else:
  630. newdic[rowlistLabel[i]] = ""
  631. fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
  632. else:
  633. if text != "清空项目12345678987654321":
  634. newdic[rowlistLabel[int(column)]]="'%s'"%text
  635. else:
  636. newdic[rowlistLabel[int(column)]]="''"
  637. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  638. except Exception:
  639. dingding_alert(traceback.format_exc())
  640. def updateEidteItem(fdb:flightDB,text,flightid,displayMode,flighttype,selectedtime):
  641. try:
  642. if displayMode =="A":
  643. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  644. flightid_new=flightid+"-1"+"-A"
  645. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  646. flightid_new = flightid + "-2" + "-A"
  647. elif displayMode =="B":
  648. if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
  649. flightid_new=flightid+"-1"+"-B"
  650. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  651. flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
  652. newdic = {}
  653. if str(flightid_new) not in str(flightids_in_peopleSchedule):
  654. newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
  655. for i in rowlistLabel.keys():
  656. if i == -1:
  657. if text !="清空项目12345678987654321":
  658. newdic[rowlistLabel[i]]=text
  659. else:
  660. newdic[rowlistLabel[i]] = ""
  661. else:
  662. newdic[rowlistLabel[i]] = ""
  663. fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
  664. else:
  665. if text != "清空项目12345678987654321":
  666. newdic[rowlistLabel[int(-1)]]="'%s'"%text
  667. else:
  668. newdic[rowlistLabel[int(-1)]]="''"
  669. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  670. except Exception:
  671. dingding_alert(traceback.format_exc())
  672. def checkPglist(fdb:flightDB,name,selectedtime,bc):
  673. try:
  674. list=["1","2","3","4","5","6","7","8","9","10","11","12"]
  675. if name != "清空项目12345678987654321" and str(name) not in list:
  676. time2=datetime.datetime.strptime(selectedtime,"%Y%m%d")
  677. time1=str((time2 - datetime.timedelta(days=1)).strftime("%Y%m%d"))
  678. check=fdb.queryTabel("pglist{}".format(selectedtime), "工号", "班次='%s' and 姓名='%s'" % (bc,name))
  679. check2 = fdb.queryTabel("pglist{}".format(time1), "工号", "班次='%s' and 姓名='%s'" % (bc, name))
  680. if len(check) == 0 and len(check2) == 0:
  681. res="NO"
  682. else:
  683. res="YES"
  684. elif str(name) in list:
  685. res = "YES"
  686. else:
  687. res = "YES"
  688. return res
  689. except Exception:
  690. dingding_alert(traceback.format_exc())
  691. def mapDispaly(fdb:flightDB,selectedtime):
  692. try:
  693. mapDispalydata = {}
  694. nowDayStr = selectedtime
  695. sorttable = fdb.queryTabel("sortFlight{}".format(nowDayStr),"*","CAST(级别 AS integer)='1' or CAST(级别 AS integer)='3'")
  696. #{机位:[机号,机型,发动机,航班类型,航班号,ta,td,进港机场,出港机场,状态,放行,维修人员,二送人员,保留,工作包,TASKID,flightid,color,备注]}
  697. for row in sorttable:
  698. # print(row)
  699. otheroneSts = []
  700. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  701. if flightinfodata[11] == "短停":
  702. iddd=row[1]+"-1"
  703. iddddd = row[1] + "-2"
  704. jfjSts= fdb.queryTabel("sortFlight{}".format(nowDayStr),"级别","编号='%s'"%iddd)[0][0]
  705. sfjSts = fdb.queryTabel("sortFlight{}".format(nowDayStr), "级别", "编号='%s'" % iddddd)[0][0]
  706. # print(otheroneSts)
  707. if (flightinfodata[11] =="航前" and flightinfodata[21] !="") or (flightinfodata[11] !="航前" and flightinfodata[19] !=""):
  708. TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  709. if flightinfodata[11] == "航前" and flightinfodata[21] != "":
  710. bay=flightinfodata[21]
  711. color="#99CCCC"
  712. elif flightinfodata[11] == "航后" and flightinfodata[19] != "" and row[5]=="3":
  713. bay = flightinfodata[19]
  714. color = "#0095d9"
  715. elif flightinfodata[11] == "停场" and flightinfodata[19] != "" and row[5]=="3":
  716. bay = flightinfodata[19]
  717. color = "#0095d9"
  718. elif flightinfodata[11] == "航后" and flightinfodata[19] != "" and row[5]=="1":
  719. bay = "Y"+flightinfodata[19]
  720. color = "#f6ad49"
  721. elif flightinfodata[11] == "特后前" and flightinfodata[19] != "" and flightinfodata[14] == "":
  722. bay = "Y"+flightinfodata[19]
  723. color = "#f6ad49"
  724. elif flightinfodata[11] == "特后前" and flightinfodata[19] != "" and flightinfodata[14] != "":
  725. bay = flightinfodata[19]
  726. color = "#4c6cb3"
  727. elif flightinfodata[11] == "短停" and flightinfodata[19] != "" and jfjSts=="1":
  728. bay = "Y"+flightinfodata[19]
  729. color = "#f6ad49"
  730. elif flightinfodata[11] == "短停" and flightinfodata[19] != "" and jfjSts=="4" and sfjSts=="1":
  731. bay = flightinfodata[19]
  732. color = "#69b076"
  733. acno=flightinfodata[2]
  734. airpalneType=flightinfodata[4]
  735. EngType=flightinfodata[3]
  736. flightType = flightinfodata[11]
  737. flightNos = flightinfodata[8]
  738. DEP_CH=flightinfodata[6] #进港机场
  739. DEP_CH1=flightinfodata[7] #出港机场
  740. flightsts = flightinfodata[10]
  741. wx=flightinfodata[22]
  742. fx = flightinfodata[23]
  743. es = flightinfodata[30]
  744. flightid=flightinfodata[0]
  745. message=flightinfodata[32]
  746. e = "" #保留
  747. F = ""#工作包
  748. g = "" #taskid
  749. ta = ""
  750. td=""
  751. if len(TaskFlightinfo) != 0:
  752. if TaskFlightinfo[0][16] != "":
  753. e = "有保留"
  754. if TaskFlightinfo[0][18] != "":
  755. F = "有工作包"
  756. if TaskFlightinfo[0][21] != "":
  757. g = TaskFlightinfo[0][21]
  758. if "-" not in TaskFlightinfo[0][9].split('</br>')[0]:
  759. ta = TaskFlightinfo[0][9].split('</br>')[0]
  760. if "-" not in TaskFlightinfo[0][9].split('</br>')[1]:
  761. td = TaskFlightinfo[0][9].split('</br>')[1]
  762. if "CZ" in str(flightNos) or "OQ" in str(flightNos):
  763. nanhang="1"
  764. elif "3U" not in str(flightNos) or "CSC" not in str(flightNos):
  765. nanhang = "0"
  766. else:
  767. nanhang = "3"
  768. mapDispalydata[bay] = {"机号":acno,
  769. "机型":airpalneType,
  770. "发动机":EngType,
  771. "航班类型":flightType,
  772. "航班号":flightNos,
  773. "到达":ta,
  774. "起飞":td,
  775. "进港机场":DEP_CH,
  776. "出港机场":DEP_CH1,
  777. "状态":flightsts,
  778. "放行":fx,
  779. "维修人员":wx,
  780. "二送人员":es,
  781. "保留":e,
  782. "工作包":F,
  783. "TASKID":g,
  784. "flightid":flightid,
  785. "color":color,
  786. "备注":message,
  787. "南航":nanhang
  788. }
  789. return mapDispalydata
  790. except Exception:
  791. dingding_alert(traceback.format_exc())
  792. def postgresql_local(local:flightDB,host_online, port_online, user_online, password_online, database_online):
  793. print(datetime.datetime.now(), "[同步中心]开始同步数据库")
  794. today = datetime.datetime.now().strftime('%Y%m%d')
  795. yesterday=(datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y%m%d')
  796. tomorrow=(datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y%m%d')
  797. online=flightDB(host_online, port_online, user_online, password_online, database_online)
  798. table_colmuns={"flightinfo%s"%today:flightinfoLabel,"flightinfo%s"%yesterday:flightinfoLabel,"flightinfo%s"%tomorrow:flightinfoLabel,
  799. "peopleschedule%s"%today:peopleScheduleLabel,"peopleschedule%s"%yesterday:peopleScheduleLabel,"peopleschedule%s"%tomorrow:peopleScheduleLabel,
  800. "sortflight%s"%today:sortLabel,"sortflight%s"%yesterday:sortLabel,"sortflight%s"%tomorrow:sortLabel,
  801. "display":displayLabel}
  802. dbtables=["flightinfo%s"%today,"flightinfo%s"%yesterday,"flightinfo%s"%tomorrow,
  803. "peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,
  804. "sortflight%s"%today,"sortflight%s"%yesterday,"sortflight%s"%tomorrow,"display"]
  805. try:
  806. tablesok=""
  807. tablenum=0
  808. for dbtable in dbtables:
  809. try:
  810. Dic = {}
  811. primaryKey2 = 'text'
  812. for key in list(table_colmuns[dbtable])[1:]:
  813. Dic[key] = 'text'
  814. online.initTable(dbtable, table_colmuns[dbtable][0], primaryKey2, Dic)
  815. all_source_data=local.getAlldata(dbtable)
  816. if len(all_source_data)!=0:
  817. online.lazydeleteTable(dbtable)
  818. if dbtable=="display":
  819. dispaly_res=online.getSingledata("A", 'display')
  820. if dispaly_res == None or len(dispaly_res) == 0:
  821. online.insertData('display', {'ID': 1, 'A': '{}', 'B': '{}'})
  822. online.insertData('display', {'ID': 2, 'A': '{}', 'B': '{}'})
  823. online.insertData('display', {'ID': 3, 'A': '{}', 'B': '{}'})
  824. for row in all_source_data:
  825. newdic = {"A": '"{}"'.format(row[1]),"B": '"{}"'.format(row[2])}
  826. online.lazyUpdateItem(dbtable, newdic, "ID = '%s'"%row[0])
  827. #online.FunctionCommit()
  828. else:
  829. for row in all_source_data:
  830. online.lazyInsertData2(dbtable,', '.join(table_colmuns[dbtable]),row)
  831. online.FunctionCommit()
  832. tablesok=tablesok+dbtable+"/"
  833. tablenum+=1
  834. except :
  835. print(traceback.format_exc())
  836. continue
  837. print(datetime.datetime.now(), "[同步中心]完成数据库同步(%s[%s])"%(tablesok,tablenum))
  838. return "ok"
  839. except Exception:
  840. print(traceback.format_exc())
  841. return "fail"
  842. def bakupdata(fdb:flightDB):
  843. try:
  844. #print("5分钟间隔自动备份")
  845. nowDay = str(datetime.date.today().strftime("%Y%m%d"))
  846. nowDay_1 = str((datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d"))
  847. aaa={nowDay:"今天",nowDay_1:"昨天"}
  848. tableWidgetDispalydatas={}
  849. wb = Workbook()
  850. for selectedtime in [nowDay,nowDay_1]:
  851. wb.create_sheet(title="%s"%selectedtime, index=0)
  852. ws = wb.active
  853. ws.title = "%s"%selectedtime
  854. ws= wb["%s"%selectedtime]
  855. ws.cell(1, 1).value = "序号"
  856. ws.cell(1, 2).value = "类型"
  857. ws.cell(1, 3).value = "航班号"
  858. ws.cell(1, 4).value = "机型"
  859. ws.cell(1, 5).value = "发动机"
  860. ws.cell(1, 6).value = "机号"
  861. ws.cell(1, 7).value = "计达"
  862. ws.cell(1, 8).value = "预达"
  863. ws.cell(1, 9).value = "计飞"
  864. ws.cell(1, 10).value = "机位"
  865. ws.cell(1, 11).value = "放行"
  866. ws.cell(1, 12).value = "工1"
  867. ws.cell(1, 13).value = "工2"
  868. ws.cell(1, 14).value = "工3"
  869. ws.cell(1, 15).value = "工4"
  870. ws.cell(1, 16).value = "工5"
  871. ws.cell(1, 17).value = "送1"
  872. ws.cell(1, 18).value = "送2"
  873. ws.cell(1, 19).value = "备注"
  874. ws.cell(1, 20).value = "接机到位"
  875. ws.cell(1, 21).value = "二送到位"
  876. ws.cell(1, 22).value = "放行情况"
  877. ws.cell(1, 23).value = "销子夹板"
  878. tableWidgetDispalydata = {}
  879. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight2")
  880. nowDayStr = selectedtime
  881. '''
  882. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  883. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  884. "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "返航备降", "25": "维修人员",
  885. "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
  886. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  887. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  888. "18": "放行","19": "销夹", "17": "二送","20":"附加消息","21": "送机1", "22": "送机2"}
  889. '''
  890. rowNum = 0
  891. for row in sorttable:
  892. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  893. flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "","", "", "","", "", "","", "", "","", "", ""]
  894. jjdw = "√" if flightstsdata[3] != "" else ""
  895. FX = "√" if flightstsdata[4] != "" else ""
  896. XJ = "√" if flightstsdata[5] != "" else ""
  897. ESDW = "√" if flightstsdata[7] != "" else ""
  898. flighttype=flightinfodata[11] if "3U" not in str(flightinfodata[8]) and "CSC" not in str(flightinfodata[8]) else "外"+str(flightinfodata[11])
  899. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  900. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  901. a = flightinfodata[15][-8:-3]
  902. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  903. a = flightinfodata[12][-8:-3]
  904. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  905. a = ""
  906. elif flightinfodata[16] != "":
  907. a = ""
  908. a = str(a).split(":")[0] + str(a).split(":")[1] if a != "" else ""
  909. b = str(flightinfodata[15][-8:-3]).split(":")[0] + str(flightinfodata[15][-8:-3]).split(":")[1] if flightinfodata[15] != "" else ""
  910. c = flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  911. c = str(c).split(":")[0]+ str(c).split(":")[1] if c != "" else ""
  912. fx = ""
  913. g1 = ""
  914. g2 = ""
  915. g3 = ""
  916. g4 = ""
  917. g5 = ""
  918. fj1 = ""
  919. s1 = ""
  920. s2 = ""
  921. fj2 = ""
  922. fj =""
  923. peopleSchedules = fdb.queryTabel('peopleSchedule{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])) if \
  924. len(fdb.queryTabel('peopleSchedule{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else [("000", "", "", "", "", "", "", "", "", "")]
  925. #print(peopleSchedules)
  926. for i in peopleSchedules:
  927. if i[0][-3] =="1":
  928. fx=i[3]
  929. g1=i[4]
  930. g2 = i[5]
  931. g3 = i[6]
  932. g4 = i[7]
  933. g5 = i[8]
  934. fj1= i[9]
  935. elif i[0][-3] =="2":
  936. s1 = i[7]
  937. s2 = i[8]
  938. fj2 = i[9]
  939. fj=fj1+fj2
  940. if flightinfodata[11] == "航后":
  941. ws.cell(rowNum+2, 1).value = rowNum+1
  942. ws.cell(rowNum+2, 2).value = flighttype
  943. ws.cell(rowNum+2, 3).value = flightinfodata[8]
  944. ws.cell(rowNum+2, 4).value = flightinfodata[4]
  945. ws.cell(rowNum+2, 5).value = flightinfodata[3]
  946. ws.cell(rowNum+2, 6).value = flightinfodata[2]
  947. ws.cell(rowNum+2, 7).value = a
  948. ws.cell(rowNum+2, 8).value = b
  949. ws.cell(rowNum+2, 9).value = ""
  950. ws.cell(rowNum+2, 10).value = flightinfodata[19]
  951. ws.cell(rowNum+2, 11).value = fx
  952. ws.cell(rowNum+2, 12).value =g1
  953. ws.cell(rowNum+2, 13).value = g2
  954. ws.cell(rowNum+2, 14).value = g3
  955. ws.cell(rowNum+2, 15).value = g4
  956. ws.cell(rowNum+2, 16).value = g5
  957. ws.cell(rowNum+2, 17).value = s1
  958. ws.cell(rowNum+2, 18).value = s2
  959. ws.cell(rowNum+2, 19).value = fj
  960. ws.cell(rowNum+2, 20).value = jjdw
  961. ws.cell(rowNum+2, 21).value = ""
  962. ws.cell(rowNum+2, 22).value = ""
  963. ws.cell(rowNum+2, 23).value = ""
  964. rowNum += 1
  965. elif flightinfodata[11] == "停场":
  966. ws.cell(rowNum + 2, 1).value = rowNum+1
  967. ws.cell(rowNum + 2, 2).value = flighttype
  968. ws.cell(rowNum + 2, 3).value = ""
  969. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  970. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  971. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  972. ws.cell(rowNum + 2, 7).value = ""
  973. ws.cell(rowNum + 2, 8).value = ""
  974. ws.cell(rowNum + 2, 9).value = ""
  975. ws.cell(rowNum + 2, 10).value = flightinfodata[19]
  976. ws.cell(rowNum + 2, 11).value = fx
  977. ws.cell(rowNum + 2, 12).value = g1
  978. ws.cell(rowNum + 2, 13).value = g2
  979. ws.cell(rowNum + 2, 14).value = g3
  980. ws.cell(rowNum + 2, 15).value = g4
  981. ws.cell(rowNum + 2, 16).value = g5
  982. ws.cell(rowNum + 2, 17).value = s1
  983. ws.cell(rowNum + 2, 18).value = s2
  984. ws.cell(rowNum + 2, 19).value = fj
  985. ws.cell(rowNum + 2, 20).value = ""
  986. ws.cell(rowNum + 2, 21).value = ""
  987. ws.cell(rowNum + 2, 22).value = ""
  988. ws.cell(rowNum + 2, 23).value = ""
  989. rowNum += 1
  990. elif flightinfodata[11] == "航前":
  991. ws.cell(rowNum + 2, 1).value = rowNum+1
  992. ws.cell(rowNum + 2, 2).value = flighttype
  993. ws.cell(rowNum + 2, 3).value = flightinfodata[8]
  994. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  995. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  996. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  997. ws.cell(rowNum + 2, 7).value = ""
  998. ws.cell(rowNum + 2, 8).value = ""
  999. ws.cell(rowNum + 2, 9).value = c
  1000. ws.cell(rowNum + 2, 10).value = flightinfodata[21]
  1001. ws.cell(rowNum + 2, 11).value = fx
  1002. ws.cell(rowNum + 2, 12).value = g1
  1003. ws.cell(rowNum + 2, 13).value = g2
  1004. ws.cell(rowNum + 2, 14).value = g3
  1005. ws.cell(rowNum + 2, 15).value = g4
  1006. ws.cell(rowNum + 2, 16).value = g5
  1007. ws.cell(rowNum + 2, 17).value = s1
  1008. ws.cell(rowNum + 2, 18).value = s2
  1009. ws.cell(rowNum + 2, 19).value = fj
  1010. ws.cell(rowNum + 2, 20).value = jjdw
  1011. ws.cell(rowNum + 2, 21).value = ""
  1012. ws.cell(rowNum + 2, 22).value = FX
  1013. ws.cell(rowNum + 2, 23).value = XJ
  1014. rowNum += 1
  1015. elif row[3] == "短停接":
  1016. ws.cell(rowNum + 2, 1).value = rowNum+1
  1017. ws.cell(rowNum + 2, 2).value = flighttype
  1018. ws.cell(rowNum + 2, 3).value = flightinfodata[8]
  1019. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  1020. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  1021. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  1022. ws.cell(rowNum + 2, 7).value = a
  1023. ws.cell(rowNum + 2, 8).value = b
  1024. ws.cell(rowNum + 2, 9).value = c
  1025. ws.cell(rowNum + 2, 10).value = flightinfodata[19]
  1026. ws.cell(rowNum + 2, 11).value = fx
  1027. ws.cell(rowNum + 2, 12).value = g1
  1028. ws.cell(rowNum + 2, 13).value = g2
  1029. ws.cell(rowNum + 2, 14).value = g3
  1030. ws.cell(rowNum + 2, 15).value = g4
  1031. ws.cell(rowNum + 2, 16).value = g5
  1032. ws.cell(rowNum + 2, 17).value = s1
  1033. ws.cell(rowNum + 2, 18).value = s2
  1034. ws.cell(rowNum + 2, 19).value = fj
  1035. ws.cell(rowNum + 2, 20).value = jjdw
  1036. ws.cell(rowNum + 2, 21).value = ESDW
  1037. ws.cell(rowNum + 2, 22).value = FX
  1038. ws.cell(rowNum + 2, 23).value = ""
  1039. rowNum += 1
  1040. elif row[3] == "特后前接":
  1041. ws.cell(rowNum + 2, 1).value = rowNum+1
  1042. ws.cell(rowNum + 2, 2).value = flighttype
  1043. ws.cell(rowNum + 2, 3).value = flightinfodata[8]
  1044. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  1045. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  1046. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  1047. ws.cell(rowNum + 2, 7).value = a
  1048. ws.cell(rowNum + 2, 8).value = b
  1049. ws.cell(rowNum + 2, 9).value = c
  1050. ws.cell(rowNum + 2, 10).value = flightinfodata[19]
  1051. ws.cell(rowNum + 2, 11).value = fx
  1052. ws.cell(rowNum + 2, 12).value = g1
  1053. ws.cell(rowNum + 2, 13).value = g2
  1054. ws.cell(rowNum + 2, 14).value = g3
  1055. ws.cell(rowNum + 2, 15).value = g4
  1056. ws.cell(rowNum + 2, 16).value = g5
  1057. ws.cell(rowNum + 2, 17).value = s1
  1058. ws.cell(rowNum + 2, 18).value = s2
  1059. ws.cell(rowNum + 2, 19).value = fj
  1060. ws.cell(rowNum + 2, 20).value = jjdw
  1061. ws.cell(rowNum + 2, 20).value = jjdw
  1062. ws.cell(rowNum + 2, 21).value = ESDW
  1063. ws.cell(rowNum + 2, 22).value = FX
  1064. ws.cell(rowNum + 2, 23).value = ""
  1065. rowNum += 1
  1066. wb.save('D:/flightinfo/bakup/航班运行备份数据(勿动).xlsx')
  1067. #wb.save('航班运行备份数据.xlsx')
  1068. res="ok"
  1069. return res
  1070. except Exception:
  1071. dingding_alert(traceback.format_exc())
  1072. def tableWidgetDispalyRead(fdb:flightDB,date):
  1073. if date == "1":
  1074. tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '1'")[0][0] if len(
  1075. fdb.queryTabel("display", "A", "ID = '1'")) != 0 else {}
  1076. if date == "2":
  1077. tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '2'")[0][0] if len(
  1078. fdb.queryTabel("display", "A", "ID = '2'")) != 0 else {}
  1079. if date == "3":
  1080. tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '3'")[0][0] if len(
  1081. fdb.queryTabel("display", "A", "ID = '3'")) != 0 else {}
  1082. if "\'" in tableWidgetDispalydata1:
  1083. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("\'", '"')
  1084. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("'", '"')
  1085. tableWidgetDispalydata1 = eval(tableWidgetDispalydata1)
  1086. return tableWidgetDispalydata1
  1087. def tableWidgetDispalyRead2(fdb:flightDB,date):
  1088. if date == "1":
  1089. tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '1'")[0][0] if len(
  1090. fdb.queryTabel("display", "B", "ID = '1'")) != 0 else {}
  1091. if date == "2":
  1092. tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '2'")[0][0] if len(
  1093. fdb.queryTabel("display", "B", "ID = '2'")) != 0 else {}
  1094. if date == "3":
  1095. tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '3'")[0][0] if len(
  1096. fdb.queryTabel("display", "B", "ID = '3'")) != 0 else {}
  1097. if "\'" in tableWidgetDispalydata1:
  1098. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("\'", '"')
  1099. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("'", '"')
  1100. tableWidgetDispalydata1 = eval(tableWidgetDispalydata1)
  1101. return tableWidgetDispalydata1
  1102. def TuplefindInList(lists: list, args):
  1103. for l in lists:
  1104. if args in l:
  1105. return l
  1106. return None
  1107. def functionDisaplay(row,rowNum,TaskFlightinfoAlldata, workjobDataAll,flightInfoDataAll, flightStsDataAll,
  1108. peopleScheduleDataAll, waringMessageID):
  1109. #print("kaishi")
  1110. TaskFlightinfo = TuplefindInList(TaskFlightinfoAlldata,row[1])
  1111. #print(TaskFlightinfo)
  1112. # print(row)
  1113. e = ""
  1114. F = ""
  1115. g = ""
  1116. if TaskFlightinfo != None and TaskFlightinfo[16] != "":
  1117. e = "保留"
  1118. if TaskFlightinfo != None :
  1119. takinfo = TuplefindInList(workjobDataAll, TaskFlightinfo[21])
  1120. JWA = TaskFlightinfo[10]
  1121. JWB = TaskFlightinfo[11]
  1122. if JWA =="" and JWB !="":
  1123. JWA=JWB
  1124. elif JWB =="" and JWA !="":
  1125. JWB=JWA
  1126. if TaskFlightinfo[18] != "":
  1127. #takinfo = fdb.queryTabel('workjob', '*', "任务编号= '%s'" % TaskFlightinfo[0][21])
  1128. F = "工作包无法正常获取请通过AMRO人工查询"
  1129. if takinfo != None and takinfo[4] != "":
  1130. F = takinfo[4] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[6] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[7]
  1131. elif takinfo != None:
  1132. F = "工作包暂未获取请点击右键工作包查询后即可随意查看"
  1133. else:
  1134. JWA =""
  1135. JWB =""
  1136. if TaskFlightinfo != None and TaskFlightinfo[21] != "":
  1137. g = TaskFlightinfo[21]
  1138. #print("tttt:{}".format(g))
  1139. wx_people = ""
  1140. fx_people = ""
  1141. ecsj_people = ""
  1142. ta_td = ""
  1143. type31 = ""
  1144. if TaskFlightinfo != None:
  1145. wx_people = TaskFlightinfo[12]
  1146. fx_people = TaskFlightinfo[13]
  1147. ecsj_people = TaskFlightinfo[19]
  1148. ta_td = TaskFlightinfo[9]
  1149. type31 = TaskFlightinfo[3]
  1150. # print(row[1])
  1151. # print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
  1152. flightinfodata = TuplefindInList(flightInfoDataAll,row[1])
  1153. #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  1154. flightstsdata = TuplefindInList(flightStsDataAll, row[1]) if TuplefindInList(flightStsDataAll, row[1]) != None \
  1155. else ["", "","", "", "", "","", "", "", "","", "", "", ""]
  1156. # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  1157. # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  1158. # "", "", "", "",
  1159. # "", "", "", "",
  1160. # "", "", "", ""]
  1161. jjdw = "√" if flightstsdata[3] != "" else ""
  1162. FX = "√" if flightstsdata[4] != "" else ""
  1163. XJ = "√" if flightstsdata[5] != "" else ""
  1164. ESDW = "√" if flightstsdata[7] != "" else ""
  1165. if flightinfodata[11] == "航后":
  1166. postion = str(flightinfodata[6]) + "-天府"
  1167. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  1168. postion = str(flightinfodata[6]) + "-天府-" + str(flightinfodata[7])
  1169. else:
  1170. postion = "天府-" + str(flightinfodata[7])
  1171. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  1172. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  1173. a = flightinfodata[15][-8:-3]
  1174. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1175. a = flightinfodata[12][-8:-3]
  1176. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1177. a = ""
  1178. elif flightinfodata[16] != "":
  1179. a = ""
  1180. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  1181. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  1182. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  1183. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  1184. waringMessageIDs = waringMessageID
  1185. if str(row[1]) in str(waringMessageIDs["通用警告"]):
  1186. color_code = QColorList[6]
  1187. color_code1 = QColorList[1]
  1188. color_code2 = QColorList[1]
  1189. color_code3 = QColorList[1]
  1190. elif row[3] == "短停接" and (
  1191. str(row[1]) in str(waringMessageIDs["到位警告"]) or str(row[1]) in str(waringMessageIDs["ETA"]) or str(
  1192. row[1]) in str(waringMessageIDs["BAY_2"])):
  1193. color_code = QColorList[6]
  1194. color_code1 = QColorList[1]
  1195. color_code2 = QColorList[1]
  1196. color_code3 = QColorList[1]
  1197. elif row[3] == "短停送" and (
  1198. str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
  1199. color_code = QColorList[6]
  1200. color_code1 = QColorList[1]
  1201. color_code2 = QColorList[1]
  1202. color_code3 = QColorList[1]
  1203. elif row[5] == "4":
  1204. color_code = QColorList[5]
  1205. color_code1 = QColorList[1]
  1206. color_code2 = QColorList[1]
  1207. color_code3 = QColorList[1]
  1208. elif row[5] == "3":
  1209. color_code = QColorList[3]
  1210. color_code1 = QColorList[0]
  1211. color_code2 = QColorList[0]
  1212. color_code3 = QColorList[0]
  1213. elif row[5] == "2":
  1214. color_code = QColorList[2]
  1215. color_code1 = QColorList[0]
  1216. color_code2 = QColorList[0]
  1217. color_code3 = QColorList[0]
  1218. elif row[5] == "1":
  1219. if (rowNum + 2) % 2 == 0:
  1220. color_code = QColorList[4]
  1221. else:
  1222. color_code = QColorList[1]
  1223. color_code1 = QColorList[0]
  1224. color_code2 = QColorList[6]
  1225. color_code3 = QColorList[7]
  1226. findid = row[0] + "-A"
  1227. #print(peopleScheduleDataAll)
  1228. peopleSchedule = TuplefindInList(peopleScheduleDataAll,findid)
  1229. #peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
  1230. #print(peopleSchedule)
  1231. if peopleSchedule != None:
  1232. fx = peopleSchedule[3]
  1233. qw1 = peopleSchedule[4]
  1234. qw2 = peopleSchedule[5]
  1235. g1 = peopleSchedule[6]
  1236. g2 = peopleSchedule[7]
  1237. g3 = peopleSchedule[8]
  1238. if flightinfodata[28] != "" and flightinfodata[28][0] == "R" and "返航航班" not in str(peopleSchedule[9]):
  1239. fj = "返航航班;" + str(peopleSchedule[9])
  1240. elif flightinfodata[28] != "" and flightinfodata[28] == "V" and "备降航班" not in str(peopleSchedule[9]):
  1241. fj = "备降航班;" + str(peopleSchedule[9])
  1242. else:
  1243. fj = str(peopleSchedule[9])
  1244. else:
  1245. fx = ""
  1246. qw1 = ""
  1247. qw2 = ""
  1248. g1 = ""
  1249. g2 = ""
  1250. g3 = ""
  1251. if flightinfodata[28] != "" and flightinfodata[28][0] == "R":
  1252. fj = "返航航班;"
  1253. elif flightinfodata[28] != "" and flightinfodata[28][0] == "V":
  1254. fj = "备降航班;"
  1255. else:
  1256. fj = ""
  1257. if "随机离港" in str(fj):
  1258. SJDW = "√" if flightstsdata[6] != "" else ""
  1259. else:
  1260. SJDW ="--"
  1261. if flightinfodata[11] == "航后":
  1262. item_dic = {"0": rowNum,
  1263. "1": flightinfodata[2],
  1264. "2": flightinfodata[4],
  1265. "3": flightinfodata[3],
  1266. "4": flightinfodata[8],
  1267. "5": a,
  1268. "6": b,
  1269. "7": "--",
  1270. "8": JWA,
  1271. "9": row[3],
  1272. "10": fx,
  1273. "11": qw1,
  1274. "12": qw2,
  1275. "13": g1,
  1276. "14": g2,
  1277. "15": g3,
  1278. "16": jjdw,
  1279. "17": "--",
  1280. "18": "--",
  1281. "19": d,
  1282. "20": "--",
  1283. "21": e,
  1284. "22": F,
  1285. "23": postion,
  1286. "24": wx_people, # flightinfodata[22],
  1287. "25": fx_people, # flightinfodata[23],
  1288. "26": row[1],
  1289. "27": g,
  1290. "28": ta_td,
  1291. "29": type31,
  1292. "30": fj,
  1293. "99": color_code,
  1294. "101": color_code1,
  1295. "102": color_code2,
  1296. "103": color_code3,
  1297. "109": row[5]
  1298. }
  1299. elif flightinfodata[11] == "停场":
  1300. item_dic = {"0": rowNum,
  1301. "1": flightinfodata[2],
  1302. "2": flightinfodata[4],
  1303. "3": flightinfodata[3],
  1304. "4": "--",
  1305. "5": a,
  1306. "6": "--",
  1307. "7": "--",
  1308. "8": flightinfodata[19],
  1309. "9": row[3],
  1310. "10": fx,
  1311. "11": qw1,
  1312. "12": qw2,
  1313. "13": g1,
  1314. "14": g2,
  1315. "15": g3,
  1316. "16": "--",
  1317. "17": "--",
  1318. "18": "--",
  1319. "19": "--",
  1320. "20": "--",
  1321. "21": "--",
  1322. "22": "--",
  1323. "23": "--",
  1324. "24": "--", # flightinfodata[22],
  1325. "25": "--", # flightinfodata[23],
  1326. "26": row[1],
  1327. "27": "TSK",
  1328. "28": "--",
  1329. "29": "--",
  1330. "30": fj,
  1331. "99": color_code,
  1332. "101": color_code1,
  1333. "102": color_code2,
  1334. "103": color_code3,
  1335. "109": row[5]
  1336. }
  1337. elif flightinfodata[11] == "航前":
  1338. item_dic = {"0": rowNum,
  1339. "1": flightinfodata[2],
  1340. "2": flightinfodata[4],
  1341. "3": flightinfodata[3],
  1342. "4": flightinfodata[8],
  1343. "5": "",
  1344. "6": "",
  1345. "7": c,
  1346. "8": JWB,
  1347. "9": row[3],
  1348. "10": fx,
  1349. "11": qw1,
  1350. "12": qw2,
  1351. "13": g1,
  1352. "14": g2,
  1353. "15": g3,
  1354. "16": jjdw,
  1355. "17": FX,
  1356. "18": XJ,
  1357. "19": d,
  1358. "20": SJDW,
  1359. "21": e,
  1360. "22": F,
  1361. "23": postion,
  1362. "24": wx_people, # flightinfodata[22],
  1363. "25": fx_people, # flightinfodata[23],
  1364. "26": row[1],
  1365. "27": g,
  1366. "28": ta_td,
  1367. "29": type31,
  1368. "30": fj,
  1369. "99": color_code,
  1370. "101": color_code1,
  1371. "102": color_code2,
  1372. "103": color_code3,
  1373. "109": row[5]
  1374. }
  1375. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前") and (row[3] == "短停接" or row[3] == "特后前接"):
  1376. item_dic = {"0": rowNum,
  1377. "1": flightinfodata[2],
  1378. "2": flightinfodata[4],
  1379. "3": flightinfodata[3],
  1380. "4": flightinfodata[8],
  1381. "5": a,
  1382. "6": b,
  1383. "7": c,
  1384. "8": JWA,
  1385. "9": row[3],
  1386. "10": fx,
  1387. "11": qw1,
  1388. "12": qw2,
  1389. "13": g1,
  1390. "14": g2,
  1391. "15": g3,
  1392. "16": jjdw,
  1393. "17": FX,
  1394. "18": "--",
  1395. "19": d,
  1396. "20": SJDW,
  1397. "21": e,
  1398. "22": F,
  1399. "23": postion,
  1400. "24": wx_people, # flightinfodata[22],
  1401. "25": fx_people, # flightinfodata[23],
  1402. "26": row[1],
  1403. "27": g,
  1404. "28": ta_td,
  1405. "29": type31,
  1406. "30": fj,
  1407. "99": color_code,
  1408. "101": color_code1,
  1409. "102": color_code2,
  1410. "103": color_code3,
  1411. "109": row[5]
  1412. }
  1413. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前") and (row[3] == "短停送" or row[3] == "特后前送"):
  1414. item_dic = {"0": rowNum,
  1415. "1": flightinfodata[2],
  1416. "2": flightinfodata[4],
  1417. "3": flightinfodata[3],
  1418. "4": flightinfodata[8],
  1419. "5": a,
  1420. "6": b,
  1421. "7": c,
  1422. "8": JWA,
  1423. "9": row[3],
  1424. "10": fx,
  1425. "11": qw1,
  1426. "12": qw2,
  1427. "13": g1,
  1428. "14": g2,
  1429. "15": g3,
  1430. "16": ESDW,
  1431. "17": FX,
  1432. "18": "--",
  1433. "19": d,
  1434. "20": SJDW,
  1435. "21": e,
  1436. "22": F,
  1437. "23": postion,
  1438. "24": ecsj_people, # flightinfodata[22],
  1439. "25": fx_people, # flightinfodata[23],
  1440. "26": row[1],
  1441. "27": g,
  1442. "28": ta_td,
  1443. "29": type31,
  1444. "30": fj,
  1445. "99": color_code,
  1446. "101": color_code1,
  1447. "102": color_code2,
  1448. "103": color_code3,
  1449. "109": row[5]
  1450. }
  1451. else:
  1452. item_dic = {"0": rowNum,
  1453. "1": flightinfodata[2],
  1454. "2": flightinfodata[4],
  1455. "3": flightinfodata[3],
  1456. "4": flightinfodata[8],
  1457. "5": a,
  1458. "6": b,
  1459. "7": c,
  1460. "8": JWA,
  1461. "9": row[3],
  1462. "10": fx,
  1463. "11": qw1,
  1464. "12": qw2,
  1465. "13": g1,
  1466. "14": g2,
  1467. "15": g3,
  1468. "16": jjdw,
  1469. "17": FX,
  1470. "18": "--",
  1471. "19": d,
  1472. "20": SJDW,
  1473. "21": e,
  1474. "22": F,
  1475. "23": postion,
  1476. "24": wx_people, # flightinfodata[22],
  1477. "25": fx_people, # flightinfodata[23],
  1478. "26": row[1],
  1479. "27": g,
  1480. "28": ta_td,
  1481. "29": type31,
  1482. "30": fj,
  1483. "99": color_code,
  1484. "101": color_code1,
  1485. "102": color_code2,
  1486. "103": color_code3,
  1487. "109": row[5]
  1488. }
  1489. #tableWidgetDispalydata[rowNum] = item_dic
  1490. #rowNum += 1
  1491. # print(rowNum)
  1492. # print(item_dic)
  1493. # print({rowNum:item_dic})
  1494. return {rowNum:item_dic}
  1495. #########################################
  1496. # 测试导出
  1497. def tableWidgetDispalyAlllogs(fdb: flightDB):
  1498. index2 = {0: "编号", 1: "航班编号", 2: "警告信息", 3: "信息状态", 4: "提示信息", 5: "产生时间", 6: "处理人", 7: "处理时间", 8: "变更字段",9: "显示对象", 10: "提示内容"}
  1499. data = fdb.getAlldata("logs")
  1500. res = {}
  1501. if data != None and len(data) != 0:
  1502. for i in data:
  1503. aa = {}
  1504. for j in index2.keys():
  1505. aa["%s"%j]=i[j]
  1506. res[i[0]]=aa
  1507. return res
  1508. def tableWidgetDispalyCalllogs(fdb: flightDB):
  1509. index2 = {0: "航班编号", 1: "电话", 2: "航班号", 3: "创建时间", 4: "姓名", 5: "接通时间", 6: "附加信息", 7: "工号", 8: "拨号次数"}
  1510. data = fdb.getAlldata("Calllist")
  1511. res = {}
  1512. if data != None and len(data) != 0:
  1513. ii = 0
  1514. for i in data:
  1515. aa = {}
  1516. for j in index2.keys():
  1517. aa["%s"%j]=i[j]
  1518. res[ii]=aa
  1519. ii+=1
  1520. return res
  1521. ########################################
  1522. def tableWidgetDispaly(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  1523. try:
  1524. #t1 = datetime.datetime.now()
  1525. tableWidgetDispalydata = {}
  1526. nowDayStr = selectedtime
  1527. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
  1528. #t2 = datetime.datetime.now()
  1529. #print(f'【航班刷新】【数据库1】:{t2 - t1}')
  1530. TaskFlightinfoAlldata = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
  1531. #t3 = datetime.datetime.now()
  1532. #print(f'【航班刷新】【数据库2】:{t3 - t2}')
  1533. flightInfoDataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
  1534. #t4 = datetime.datetime.now()
  1535. #print(f'【航班刷新】【数据库3】:{t4 - t3}')
  1536. flightStsDataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
  1537. #t5 = datetime.datetime.now()
  1538. #print(f'【航班刷新】【数据库4】:{t5 - t4}')
  1539. peopleScheduleDataAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
  1540. #t6 = datetime.datetime.now()
  1541. #print(f'【航班刷新】【数据库5】:{t6 - t5}')
  1542. workjobDataAll = fdb.getAlldata('workjob')
  1543. #t7 = datetime.datetime.now()
  1544. #print(f'【航班刷新】【数据库6】:{t7 - t6}')
  1545. #print(f'【航班刷新】【数据库ALL】:{t7 - t1}')
  1546. waringMessageIDs = waringMessageID(fdb)
  1547. executor = concurrent.futures.ThreadPoolExecutor()
  1548. all_task = []
  1549. for i in range(len(sorttable)):
  1550. all_task.append(executor.submit(functionDisaplay, sorttable[i],i, TaskFlightinfoAlldata,workjobDataAll,flightInfoDataAll, flightStsDataAll,peopleScheduleDataAll,waringMessageIDs))
  1551. for future in concurrent.futures.as_completed(all_task):
  1552. data = future.result()
  1553. tableWidgetDispalydata.update(data)
  1554. #t8 = datetime.datetime.now()
  1555. #print(f'【航班刷新】【处理数据】:{t8 - t7}')
  1556. newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
  1557. if date == "1":
  1558. fdb.upDateItem("display", newdic, "ID = '1'")
  1559. elif date == "2":
  1560. fdb.upDateItem("display", newdic, "ID = '2'")
  1561. elif date == "3":
  1562. fdb.upDateItem("display", newdic, "ID = '3'")
  1563. #t9 = datetime.datetime.now()
  1564. #print(f'【航班刷新】【保存数据】:{t9 - t8}')
  1565. #print(f'【航班刷新】【总时间】:{t9 - t1}')
  1566. return tableWidgetDispalydata
  1567. except Exception:
  1568. #dingding_alert(traceback.format_exc())
  1569. print(traceback.format_exc())
  1570. def functionDisplay2(row, rowNum, TaskFlightinfoAll,flightinfodataAll,flightstsdataAll,waringMessageIDs,peopleScheduleAll):
  1571. TaskFlightinfo = TuplefindInList(TaskFlightinfoAll,row[1])
  1572. #TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  1573. e = ""
  1574. F = ""
  1575. g = ""
  1576. if TaskFlightinfo != None:
  1577. JWA = TaskFlightinfo[10]
  1578. JWB = TaskFlightinfo[11]
  1579. if JWB!="" and JWA =="":
  1580. JWA=JWB
  1581. if JWA!="" and JWB =="":
  1582. JWB=JWA
  1583. if TaskFlightinfo[16] != "":
  1584. e = "保留"
  1585. if TaskFlightinfo[18] != "":
  1586. F = "工作包"
  1587. if TaskFlightinfo[21] != "":
  1588. g = TaskFlightinfo[21]
  1589. else:
  1590. JWA = ""
  1591. JWB = ""
  1592. wx_people = ""
  1593. fx_people = ""
  1594. ecsj_people = ""
  1595. ta_td = ""
  1596. type31 = ""
  1597. # print(TaskFlightinfo)
  1598. if TaskFlightinfo != None:
  1599. wx_people = TaskFlightinfo[12]
  1600. fx_people = TaskFlightinfo[13]
  1601. ecsj_people = TaskFlightinfo[19]
  1602. ta_td = TaskFlightinfo[9]
  1603. type31 = TaskFlightinfo[3]
  1604. #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  1605. # print(flightinfodataAll)
  1606. # print(row[0])
  1607. flightinfodata = TuplefindInList(flightinfodataAll, row[1])
  1608. # print(flightinfodata)
  1609. # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  1610. # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  1611. # "", "", "", "",
  1612. # "", "", "", "",
  1613. # "", "", "", ""]
  1614. flightstsdata = TuplefindInList(flightstsdataAll,row[0])if TuplefindInList(flightstsdataAll,row[0])!=None \
  1615. else ["", "","", "", "", "","", "", "", "","", "", "", ""]
  1616. jjdw = "√" if flightstsdata[3] != "" else ""
  1617. FX = "√" if flightstsdata[4] != "" else ""
  1618. XJ = "√" if flightstsdata[5] != "" else ""
  1619. ESDW = "√" if flightstsdata[7] != "" else ""
  1620. SJDW = "√" if flightstsdata[6] != "" else ""
  1621. if flightinfodata[11] == "航后":
  1622. postion = str(flightinfodata[6]) + "-天府"
  1623. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  1624. postion = str(flightinfodata[6]) + "-天府-" + str(flightinfodata[7])
  1625. else:
  1626. postion = "天府-" + str(flightinfodata[7])
  1627. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  1628. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  1629. a = flightinfodata[15][-8:-3]
  1630. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1631. a = flightinfodata[12][-8:-3]
  1632. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1633. a = ""
  1634. elif flightinfodata[16] != "":
  1635. a = ""
  1636. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  1637. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  1638. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  1639. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  1640. # waringMessageIDs = waringMessageID(fdb)
  1641. if str(row[1]) in str(waringMessageIDs["全部警告"]):
  1642. color_code = QColorList[6]
  1643. color_code1 = QColorList[1]
  1644. color_code2 = QColorList[1]
  1645. color_code3 = QColorList[1]
  1646. elif row[5] == "4":
  1647. color_code = QColorList[5]
  1648. color_code1 = QColorList[1]
  1649. color_code2 = QColorList[1]
  1650. color_code3 = QColorList[1]
  1651. elif row[5] == "3":
  1652. color_code = QColorList[3]
  1653. color_code1 = QColorList[0]
  1654. color_code2 = QColorList[0]
  1655. color_code3 = QColorList[0]
  1656. elif row[5] == "2":
  1657. color_code = QColorList[2]
  1658. color_code1 = QColorList[0]
  1659. color_code2 = QColorList[0]
  1660. color_code3 = QColorList[0]
  1661. elif row[5] == "1":
  1662. if (rowNum + 2) % 2 == 0:
  1663. color_code = QColorList[4]
  1664. else:
  1665. color_code = QColorList[1]
  1666. color_code1 = QColorList[0]
  1667. color_code2 = QColorList[6]
  1668. color_code3 = QColorList[7]
  1669. findid = row[0] + "-B"
  1670. #peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
  1671. peopleSchedule = TuplefindInList(peopleScheduleAll, findid)
  1672. if peopleSchedule != None:
  1673. fx = peopleSchedule[3]
  1674. qw1 = peopleSchedule[4]
  1675. qw2 = peopleSchedule[5]
  1676. g1 = peopleSchedule[6]
  1677. g2 = peopleSchedule[7]
  1678. g3 = peopleSchedule[8]
  1679. fj = peopleSchedule[9]
  1680. else:
  1681. fx = ""
  1682. qw1 = ""
  1683. qw2 = ""
  1684. g1 = ""
  1685. g2 = ""
  1686. g3 = ""
  1687. fj = ""
  1688. if flightinfodata[11] == "航后":
  1689. item_dic = {"0": rowNum,
  1690. "1": flightinfodata[2],
  1691. "2": flightinfodata[4],
  1692. "3": flightinfodata[3],
  1693. "4": flightinfodata[8],
  1694. "5": a,
  1695. "6": b,
  1696. "7": "--",
  1697. "8": JWA,
  1698. "9": flightinfodata[11],
  1699. "10": fx,
  1700. "11": qw1,
  1701. "12": qw2,
  1702. "13": g1,
  1703. "14": g2,
  1704. "15": g3,
  1705. "16": jjdw,
  1706. "17": "--",
  1707. "18": "--",
  1708. "19": "--",
  1709. "20": d,
  1710. "21": "--",
  1711. "22": e,
  1712. "23": F,
  1713. "24": postion,
  1714. "25": wx_people, # flightinfodata[22],
  1715. "26": "",
  1716. "27": fx_people, # flightinfodata[23],
  1717. "28": row[1],
  1718. "29": g,
  1719. "30": ta_td,
  1720. "31": type31,
  1721. "32": fj,
  1722. "99": color_code,
  1723. "101": color_code1,
  1724. "102": color_code2,
  1725. "103": color_code3,
  1726. "109": row[5]
  1727. }
  1728. # tableWidgetDispalydata[rowNum] = item_dic
  1729. # rowNum += 1
  1730. return {rowNum: item_dic}
  1731. elif flightinfodata[11] == "停场":
  1732. item_dic = {"0": rowNum,
  1733. "1": flightinfodata[2],
  1734. "2": flightinfodata[4],
  1735. "3": flightinfodata[3],
  1736. "4": "--",
  1737. "5": a,
  1738. "6": "--",
  1739. "7": "--",
  1740. "8": JWA,
  1741. "9": flightinfodata[11],
  1742. "10": fx,
  1743. "11": qw1,
  1744. "12": qw2,
  1745. "13": g1,
  1746. "14": g2,
  1747. "15": g3,
  1748. "16": "--",
  1749. "17": "--",
  1750. "18": "--",
  1751. "19": "--",
  1752. "20": "--",
  1753. "21": "--",
  1754. "22": "--",
  1755. "23": "--",
  1756. "24": "--", # flightinfodata[22],
  1757. "25": "--", # flightinfodata[23],
  1758. "26": "--",
  1759. "27": "--",
  1760. "28": row[1],
  1761. "29": "TSK",
  1762. "30": "--",
  1763. "31": "--",
  1764. "32": fj,
  1765. "99": color_code,
  1766. "101": color_code1,
  1767. "102": color_code2,
  1768. "103": color_code3,
  1769. "109": row[5]
  1770. }
  1771. # tableWidgetDispalydata[rowNum] = item_dic
  1772. # rowNum += 1
  1773. return {rowNum: item_dic}
  1774. elif flightinfodata[11] == "航前":
  1775. item_dic = {"0": rowNum,
  1776. "1": flightinfodata[2],
  1777. "2": flightinfodata[4],
  1778. "3": flightinfodata[3],
  1779. "4": flightinfodata[8],
  1780. "5": "",
  1781. "6": "",
  1782. "7": c,
  1783. "8": JWB,
  1784. "9": flightinfodata[11],
  1785. "10": fx,
  1786. "11": qw1,
  1787. "12": qw2,
  1788. "13": g1,
  1789. "14": g2,
  1790. "15": g3,
  1791. "16": jjdw,
  1792. "18": FX,
  1793. "19": XJ,
  1794. "17": "--",
  1795. "20": d,
  1796. "21": SJDW,
  1797. "22": e,
  1798. "23": F,
  1799. "24": postion,
  1800. "25": wx_people, # flightinfodata[22],
  1801. "26": "",
  1802. "27": fx_people, # flightinfodata[23],
  1803. "28": row[1],
  1804. "29": g,
  1805. "30": ta_td,
  1806. "31": type31,
  1807. "32": fj,
  1808. "99": color_code,
  1809. "101": color_code1,
  1810. "102": color_code2,
  1811. "103": color_code3,
  1812. "109": row[5]
  1813. }
  1814. # tableWidgetDispalydata[rowNum] = item_dic
  1815. # rowNum += 1
  1816. return {rowNum: item_dic}
  1817. elif row[3] == "短停接":
  1818. item_dic = {"0": rowNum,
  1819. "1": flightinfodata[2],
  1820. "2": flightinfodata[4],
  1821. "3": flightinfodata[3],
  1822. "4": flightinfodata[8],
  1823. "5": a,
  1824. "6": b,
  1825. "7": c,
  1826. "8": JWA,
  1827. "9": flightinfodata[11],
  1828. "10": fx,
  1829. "11": qw1,
  1830. "12": qw2,
  1831. "13": g1,
  1832. "14": g2,
  1833. "15": g3,
  1834. "16": jjdw,
  1835. "18": FX,
  1836. "19": "--",
  1837. "17": ESDW,
  1838. "20": d,
  1839. "21": SJDW,
  1840. "22": e,
  1841. "23": F,
  1842. "24": postion,
  1843. "25": wx_people, # flightinfodata[22],
  1844. "26": ecsj_people,
  1845. "27": fx_people, # flightinfodata[23],
  1846. "28": row[1],
  1847. "29": g,
  1848. "30": ta_td,
  1849. "31": type31,
  1850. "32": fj,
  1851. "99": color_code,
  1852. "101": color_code1,
  1853. "102": color_code2,
  1854. "103": color_code3,
  1855. "109": row[5]
  1856. }
  1857. # tableWidgetDispalydata[rowNum] = item_dic
  1858. # rowNum += 1
  1859. return {rowNum: item_dic}
  1860. elif row[3] == "特后前接":
  1861. item_dic = {"0": rowNum,
  1862. "1": flightinfodata[2],
  1863. "2": flightinfodata[4],
  1864. "3": flightinfodata[3],
  1865. "4": flightinfodata[8],
  1866. "5": a,
  1867. "6": b,
  1868. "7": c,
  1869. "8": JWA,
  1870. "9": flightinfodata[11],
  1871. "10": fx,
  1872. "11": qw1,
  1873. "12": qw2,
  1874. "13": g1,
  1875. "14": g2,
  1876. "15": g3,
  1877. "16": jjdw,
  1878. "18": FX,
  1879. "19": "--",
  1880. "17": "--",
  1881. "20": d,
  1882. "21": SJDW,
  1883. "22": e,
  1884. "23": F,
  1885. "24": postion,
  1886. "25": wx_people, # flightinfodata[22],
  1887. "26": "",
  1888. "27": fx_people, # flightinfodata[23],
  1889. "28": row[1],
  1890. "29": g,
  1891. "30": ta_td,
  1892. "31": type31,
  1893. "32": fj,
  1894. "99": color_code,
  1895. "101": color_code1,
  1896. "102": color_code2,
  1897. "103": color_code3,
  1898. "109": row[5]
  1899. }
  1900. #tableWidgetDispalydata[rowNum] = item_dic
  1901. #rowNum += 1
  1902. return {rowNum:item_dic}
  1903. def tableWidgetDispaly2(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  1904. try:
  1905. tableWidgetDispalydata = {}
  1906. sorttable = getSortFlightdata(fdb,selectedtime,"sortFlight2")
  1907. nowDayStr = selectedtime
  1908. TaskFlightinfoAll = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
  1909. flightinfodataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
  1910. flightstsdataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
  1911. waringMessageIDs = waringMessageID(fdb)
  1912. peopleScheduleAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
  1913. '''
  1914. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  1915. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  1916. "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "进出港城市", "25": "维修人员",
  1917. "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
  1918. '''
  1919. rowNum = 0
  1920. # functionDisplay2(sorttable[1], 1, TaskFlightinfoAll,
  1921. # flightinfodataAll, flightstsdataAll, waringMessageIDs,
  1922. # peopleScheduleAll)
  1923. executor = concurrent.futures.ThreadPoolExecutor()
  1924. all_task = []
  1925. for i in range(len(sorttable)):
  1926. all_task.append(executor.submit(functionDisplay2, sorttable[i], i, TaskFlightinfoAll,
  1927. flightinfodataAll, flightstsdataAll, waringMessageIDs,
  1928. peopleScheduleAll))
  1929. for future in concurrent.futures.as_completed(all_task):
  1930. data = future.result()
  1931. tableWidgetDispalydata.update(data)
  1932. newdic = {"B": '"{}"'.format(tableWidgetDispalydata)}
  1933. if date == "1":
  1934. fdb.upDateItem("display", newdic, "ID = '1'")
  1935. elif date == "2":
  1936. fdb.upDateItem("display", newdic, "ID = '2'")
  1937. elif date == "3":
  1938. fdb.upDateItem("display", newdic, "ID = '3'")
  1939. return tableWidgetDispalydata
  1940. except Exception:
  1941. #dingding_alert(traceback.format_exc())
  1942. print(traceback.format_exc())
  1943. def tableWidgetDispalyOld(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  1944. try:
  1945. #print("tableWidgetDispaly")
  1946. #print(selectedtime)
  1947. #ts=datetime.datetime.now()
  1948. tableWidgetDispalydata = {}
  1949. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
  1950. nowDayStr = selectedtime
  1951. rowNum = 0
  1952. for row in sorttable:
  1953. # print(row)
  1954. TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  1955. e = ""
  1956. F = ""
  1957. g = ""
  1958. if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][16] != "":
  1959. e = "保留"
  1960. if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][18] != "":
  1961. takinfo = fdb.queryTabel('workjob','*',"任务编号= '%s'"%TaskFlightinfo[0][21])
  1962. F = "工作包无法正常获取请通过AMRO人工查询"
  1963. if len(takinfo) != 0 and takinfo[0][4] !="":
  1964. F=takinfo[0][4]+"\n<+++++++++++++++++++++++++++++++++++++++++>\n"+takinfo[0][6]+"\n<+++++++++++++++++++++++++++++++++++++++++>\n"+takinfo[0][7]
  1965. elif len(takinfo) != 0:
  1966. F="工作包暂未获取请点击右键工作包查询后即可随意查看"
  1967. if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][21] != "":
  1968. g = TaskFlightinfo[0][21]
  1969. wx_people = ""
  1970. fx_people = ""
  1971. ecsj_people = ""
  1972. ta_td = ""
  1973. type31 = ""
  1974. if len(TaskFlightinfo) != 0:
  1975. wx_people = TaskFlightinfo[0][12]
  1976. fx_people = TaskFlightinfo[0][13]
  1977. ecsj_people = TaskFlightinfo[0][19]
  1978. ta_td = TaskFlightinfo[0][9]
  1979. type31 = TaskFlightinfo[0][3]
  1980. #print(row[1])
  1981. #print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
  1982. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  1983. flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  1984. len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  1985. "", "","", "","", "","", "","", "","", ""]
  1986. jjdw="√" if flightstsdata[3] !="" else ""
  1987. FX = "√" if flightstsdata[4] != "" else ""
  1988. XJ = "√" if flightstsdata[5] != "" else ""
  1989. ESDW = "√" if flightstsdata[7] != "" else ""
  1990. SJDW = "√" if flightstsdata[6] != "" else ""
  1991. if flightinfodata[11] == "航后":
  1992. postion=str(flightinfodata[6])+"-天府"
  1993. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  1994. postion = str(flightinfodata[6]) + "-天府-"+str(flightinfodata[7])
  1995. else:
  1996. postion = "天府-" + str(flightinfodata[7])
  1997. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  1998. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  1999. a = flightinfodata[15][-8:-3]
  2000. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  2001. a = flightinfodata[12][-8:-3]
  2002. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  2003. a = ""
  2004. elif flightinfodata[16] != "":
  2005. a = ""
  2006. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  2007. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  2008. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  2009. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  2010. waringMessageIDs=waringMessageID(fdb)
  2011. if str(row[1]) in str(waringMessageIDs["通用警告"]):
  2012. color_code = QColorList[6]
  2013. color_code1 = QColorList[1]
  2014. color_code2 = QColorList[1]
  2015. color_code3 = QColorList[1]
  2016. elif row[3]=="短停接" and (str(row[1]) in str(waringMessageIDs["到位警告"]) or str(row[1]) in str(waringMessageIDs["ETA"]) or str(row[1]) in str(waringMessageIDs["BAY_2"])):
  2017. color_code = QColorList[6]
  2018. color_code1 = QColorList[1]
  2019. color_code2 = QColorList[1]
  2020. color_code3 = QColorList[1]
  2021. elif row[3]=="短停送" and (str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
  2022. color_code = QColorList[6]
  2023. color_code1 = QColorList[1]
  2024. color_code2 = QColorList[1]
  2025. color_code3 = QColorList[1]
  2026. elif row[5] == "4":
  2027. color_code = QColorList[5]
  2028. color_code1 = QColorList[1]
  2029. color_code2 = QColorList[1]
  2030. color_code3 = QColorList[1]
  2031. elif row[5] == "3":
  2032. color_code = QColorList[3]
  2033. color_code1 = QColorList[0]
  2034. color_code2 = QColorList[0]
  2035. color_code3 = QColorList[0]
  2036. elif row[5] == "2":
  2037. color_code = QColorList[2]
  2038. color_code1 = QColorList[0]
  2039. color_code2 = QColorList[0]
  2040. color_code3 = QColorList[0]
  2041. elif row[5] == "1":
  2042. if (rowNum + 2) % 2 == 0:
  2043. color_code = QColorList[4]
  2044. else:
  2045. color_code = QColorList[1]
  2046. color_code1 = QColorList[0]
  2047. color_code2 = QColorList[6]
  2048. color_code3 = QColorList[7]
  2049. findid=row[0]+"-A"
  2050. peopleSchedule=fdb.queryTabel("peopleSchedule{}".format(nowDayStr),"*","编号='%s'"%findid)
  2051. #print(peopleSchedule)
  2052. if len(peopleSchedule) != 0:
  2053. fx=peopleSchedule[0][3]
  2054. qw1 = peopleSchedule[0][4]
  2055. qw2 = peopleSchedule[0][5]
  2056. g1 = peopleSchedule[0][6]
  2057. g2 = peopleSchedule[0][7]
  2058. g3 = peopleSchedule[0][8]
  2059. if flightinfodata[28] !="" and flightinfodata[28][0] =="R" and "返航航班" not in str(peopleSchedule[0][9]):
  2060. fj = "返航航班;"+str(peopleSchedule[0][9])
  2061. elif flightinfodata[28] !="" and flightinfodata[28][0] == "V" and "备降航班" not in str(peopleSchedule[0][9]):
  2062. fj = "备降航班;" + str(peopleSchedule[0][9])
  2063. else:
  2064. fj = str(peopleSchedule[0][9])
  2065. else:
  2066. fx = ""
  2067. qw1 = ""
  2068. qw2 = ""
  2069. g1 = ""
  2070. g2 = ""
  2071. g3 = ""
  2072. if flightinfodata[28] != "" and flightinfodata[28][0] == "R":
  2073. fj = "返航航班;"
  2074. elif flightinfodata[28] != "" and flightinfodata[28][0] == "V":
  2075. fj = "备降航班;"
  2076. else:
  2077. fj = ""
  2078. if flightinfodata[11] == "航后":
  2079. item_dic = {"0": rowNum,
  2080. "1": flightinfodata[2],
  2081. "2": flightinfodata[4],
  2082. "3": flightinfodata[3],
  2083. "4": flightinfodata[8],
  2084. "5": a,
  2085. "6": b,
  2086. "7": "--",
  2087. "8": flightinfodata[19],
  2088. "9": row[3],
  2089. "10": fx,
  2090. "11": qw1,
  2091. "12": qw2,
  2092. "13": g1,
  2093. "14": g2,
  2094. "15": g3,
  2095. "16":jjdw,
  2096. "17": "--",
  2097. "18": "--",
  2098. "19": d,
  2099. "20": "--",
  2100. "21": e,
  2101. "22": F,
  2102. "23": postion,
  2103. "24": wx_people, # flightinfodata[22],
  2104. "25": fx_people, # flightinfodata[23],
  2105. "26": row[1],
  2106. "27": g,
  2107. "28": ta_td,
  2108. "29": type31,
  2109. "30":fj,
  2110. "99":color_code,
  2111. "101": color_code1,
  2112. "102": color_code2,
  2113. "103": color_code3,
  2114. "109":row[5]
  2115. }
  2116. elif flightinfodata[11] == "停场":
  2117. item_dic = {"0": rowNum,
  2118. "1": flightinfodata[2],
  2119. "2": flightinfodata[4],
  2120. "3": flightinfodata[3],
  2121. "4": "--",
  2122. "5": a,
  2123. "6": "--",
  2124. "7": "--",
  2125. "8": flightinfodata[19],
  2126. "9": row[3],
  2127. "10": fx,
  2128. "11": qw1,
  2129. "12": qw2,
  2130. "13": g1,
  2131. "14": g2,
  2132. "15": g3,
  2133. "16":"--",
  2134. "17": "--",
  2135. "18": "--",
  2136. "19": "--",
  2137. "20": "--",
  2138. "21": "--",
  2139. "22": "--",
  2140. "23": "--",
  2141. "24": "--", # flightinfodata[22],
  2142. "25": "--", # flightinfodata[23],
  2143. "26": row[1],
  2144. "27": "TSK",
  2145. "28": "--",
  2146. "29": "--",
  2147. "30":fj,
  2148. "99":color_code,
  2149. "101": color_code1,
  2150. "102": color_code2,
  2151. "103": color_code3,
  2152. "109":row[5]
  2153. }
  2154. elif flightinfodata[11] == "航前":
  2155. item_dic = {"0": rowNum,
  2156. "1": flightinfodata[2],
  2157. "2": flightinfodata[4],
  2158. "3": flightinfodata[3],
  2159. "4": flightinfodata[8],
  2160. "5": "",
  2161. "6": "",
  2162. "7": c,
  2163. "8": flightinfodata[21],
  2164. "9": row[3],
  2165. "10": fx,
  2166. "11": qw1,
  2167. "12": qw2,
  2168. "13": g1,
  2169. "14": g2,
  2170. "15": g3,
  2171. "16":jjdw,
  2172. "17": FX,
  2173. "18": XJ,
  2174. "19": d,
  2175. "20": SJDW,
  2176. "21": e,
  2177. "22": F,
  2178. "23": postion,
  2179. "24": wx_people, # flightinfodata[22],
  2180. "25": fx_people, # flightinfodata[23],
  2181. "26": row[1],
  2182. "27": g,
  2183. "28": ta_td,
  2184. "29": type31,
  2185. "30":fj,
  2186. "99":color_code,
  2187. "101": color_code1,
  2188. "102": color_code2,
  2189. "103": color_code3,
  2190. "109":row[5]
  2191. }
  2192. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前" ) and (row[3] == "短停接" or row[3] == "特后前接"):
  2193. item_dic = {"0": rowNum,
  2194. "1": flightinfodata[2],
  2195. "2": flightinfodata[4],
  2196. "3": flightinfodata[3],
  2197. "4": flightinfodata[8],
  2198. "5": a,
  2199. "6": b,
  2200. "7": c,
  2201. "8": flightinfodata[19],
  2202. "9": row[3],
  2203. "10": fx,
  2204. "11": qw1,
  2205. "12": qw2,
  2206. "13": g1,
  2207. "14": g2,
  2208. "15": g3,
  2209. "16":jjdw,
  2210. "17": FX,
  2211. "18": "--",
  2212. "19": d,
  2213. "20": SJDW,
  2214. "21": e,
  2215. "22": F,
  2216. "23": postion,
  2217. "24": wx_people, # flightinfodata[22],
  2218. "25": fx_people, # flightinfodata[23],
  2219. "26": row[1],
  2220. "27": g,
  2221. "28": ta_td,
  2222. "29": type31,
  2223. "30":fj,
  2224. "99":color_code,
  2225. "101": color_code1,
  2226. "102": color_code2,
  2227. "103": color_code3,
  2228. "109":row[5]
  2229. }
  2230. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前" ) and (row[3] == "短停送" or row[3] == "特后前送"):
  2231. item_dic = {"0": rowNum,
  2232. "1": flightinfodata[2],
  2233. "2": flightinfodata[4],
  2234. "3": flightinfodata[3],
  2235. "4": flightinfodata[8],
  2236. "5": a,
  2237. "6": b,
  2238. "7": c,
  2239. "8": flightinfodata[19],
  2240. "9": row[3],
  2241. "10": fx,
  2242. "11": qw1,
  2243. "12": qw2,
  2244. "13": g1,
  2245. "14": g2,
  2246. "15": g3,
  2247. "16": ESDW,
  2248. "17": FX,
  2249. "18": "--",
  2250. "19": d,
  2251. "20": SJDW,
  2252. "21": e,
  2253. "22": F,
  2254. "23": postion,
  2255. "24": ecsj_people, # flightinfodata[22],
  2256. "25": fx_people, # flightinfodata[23],
  2257. "26": row[1],
  2258. "27": g,
  2259. "28": ta_td,
  2260. "29": type31,
  2261. "30":fj,
  2262. "99":color_code,
  2263. "101": color_code1,
  2264. "102": color_code2,
  2265. "103": color_code3,
  2266. "109":row[5]
  2267. }
  2268. else:
  2269. item_dic = {"0": rowNum,
  2270. "1": flightinfodata[2],
  2271. "2": flightinfodata[4],
  2272. "3": flightinfodata[3],
  2273. "4": flightinfodata[8],
  2274. "5": a,
  2275. "6": b,
  2276. "7": c,
  2277. "8": flightinfodata[19],
  2278. "9": row[3],
  2279. "10": fx,
  2280. "11": qw1,
  2281. "12": qw2,
  2282. "13": g1,
  2283. "14": g2,
  2284. "15": g3,
  2285. "16":jjdw,
  2286. "17": FX,
  2287. "18": "--",
  2288. "19": d,
  2289. "20": SJDW,
  2290. "21": e,
  2291. "22": F,
  2292. "23": postion,
  2293. "24": wx_people, # flightinfodata[22],
  2294. "25": fx_people, # flightinfodata[23],
  2295. "26": row[1],
  2296. "27": g,
  2297. "28": ta_td,
  2298. "29": type31,
  2299. "30":fj,
  2300. "99":color_code,
  2301. "101": color_code1,
  2302. "102": color_code2,
  2303. "103": color_code3,
  2304. "109":row[5]
  2305. }
  2306. tableWidgetDispalydata[rowNum]=item_dic
  2307. rowNum += 1
  2308. #print(tableWidgetDispalydata)
  2309. #print("耗时%s"%(datetime.datetime.now()-ts)) ###需要传参一个昨天今天明天地结果123
  2310. newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
  2311. if date =="1":
  2312. fdb.upDateItem("display", newdic, "ID = '1'")
  2313. elif date =="2":
  2314. fdb.upDateItem("display", newdic, "ID = '2'")
  2315. elif date =="3":
  2316. fdb.upDateItem("display", newdic, "ID = '3'")
  2317. return tableWidgetDispalydata
  2318. except Exception:
  2319. dingding_alert(traceback.format_exc())
  2320. def tableWidgetDispaly2Old(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  2321. try:
  2322. tableWidgetDispalydata = {}
  2323. sorttable = getSortFlightdata(fdb,selectedtime,"sortFlight2")
  2324. nowDayStr = selectedtime
  2325. '''
  2326. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  2327. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  2328. "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "进出港城市", "25": "维修人员",
  2329. "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
  2330. '''
  2331. rowNum = 0
  2332. for row in sorttable:
  2333. # print(row)
  2334. TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  2335. e = ""
  2336. F = ""
  2337. g = ""
  2338. if len(TaskFlightinfo) != 0:
  2339. if TaskFlightinfo[0][16] != "":
  2340. e = "保留"
  2341. if TaskFlightinfo[0][18] != "":
  2342. F = "工作包"
  2343. if TaskFlightinfo[0][21] != "":
  2344. g = TaskFlightinfo[0][21]
  2345. wx_people = ""
  2346. fx_people = ""
  2347. ecsj_people = ""
  2348. ta_td = ""
  2349. type31 = ""
  2350. # print(TaskFlightinfo)
  2351. if len(TaskFlightinfo) != 0:
  2352. wx_people = TaskFlightinfo[0][12]
  2353. fx_people = TaskFlightinfo[0][13]
  2354. ecsj_people = TaskFlightinfo[0][19]
  2355. ta_td = TaskFlightinfo[0][9]
  2356. type31 = TaskFlightinfo[0][3]
  2357. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  2358. flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  2359. len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  2360. "", "","", "","", "","", "","", "","", ""]
  2361. jjdw = "√" if flightstsdata[3] != "" else ""
  2362. FX = "√" if flightstsdata[4] != "" else ""
  2363. XJ = "√" if flightstsdata[5] != "" else ""
  2364. ESDW = "√" if flightstsdata[7] != "" else ""
  2365. SJDW = "√" if flightstsdata[6] != "" else ""
  2366. if flightinfodata[11] == "航后":
  2367. postion=str(flightinfodata[6])+"-天府"
  2368. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  2369. postion = str(flightinfodata[6]) + "-天府-"+str(flightinfodata[7])
  2370. else:
  2371. postion = "天府-" + str(flightinfodata[7])
  2372. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  2373. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  2374. a = flightinfodata[15][-8:-3]
  2375. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  2376. a = flightinfodata[12][-8:-3]
  2377. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  2378. a = ""
  2379. elif flightinfodata[16] != "":
  2380. a = ""
  2381. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  2382. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  2383. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  2384. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  2385. waringMessageIDs = waringMessageID(fdb)
  2386. if str(row[1]) in str(waringMessageIDs["全部警告"]):
  2387. color_code = QColorList[6]
  2388. color_code1 = QColorList[1]
  2389. color_code2 = QColorList[1]
  2390. color_code3 = QColorList[1]
  2391. elif row[5] == "4":
  2392. color_code = QColorList[5]
  2393. color_code1 = QColorList[1]
  2394. color_code2 = QColorList[1]
  2395. color_code3 = QColorList[1]
  2396. elif row[5] == "3":
  2397. color_code = QColorList[3]
  2398. color_code1 = QColorList[0]
  2399. color_code2 = QColorList[0]
  2400. color_code3 = QColorList[0]
  2401. elif row[5] == "2":
  2402. color_code = QColorList[2]
  2403. color_code1 = QColorList[0]
  2404. color_code2 = QColorList[0]
  2405. color_code3 = QColorList[0]
  2406. elif row[5] == "1":
  2407. if (rowNum + 2) % 2 == 0:
  2408. color_code = QColorList[4]
  2409. else:
  2410. color_code = QColorList[1]
  2411. color_code1 = QColorList[0]
  2412. color_code2 = QColorList[6]
  2413. color_code3 = QColorList[7]
  2414. findid = row[0] + "-B"
  2415. peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
  2416. if len(peopleSchedule) != 0:
  2417. fx = peopleSchedule[0][3]
  2418. qw1 = peopleSchedule[0][4]
  2419. qw2 = peopleSchedule[0][5]
  2420. g1 = peopleSchedule[0][6]
  2421. g2 = peopleSchedule[0][7]
  2422. g3 = peopleSchedule[0][8]
  2423. fj = peopleSchedule[0][9]
  2424. else:
  2425. fx = ""
  2426. qw1 = ""
  2427. qw2 = ""
  2428. g1 = ""
  2429. g2 = ""
  2430. g3 = ""
  2431. fj = ""
  2432. if flightinfodata[11] == "航后":
  2433. item_dic = {"0": rowNum,
  2434. "1": flightinfodata[2],
  2435. "2": flightinfodata[4],
  2436. "3": flightinfodata[3],
  2437. "4": flightinfodata[8],
  2438. "5": a,
  2439. "6": b,
  2440. "7": "--",
  2441. "8": flightinfodata[19],
  2442. "9": flightinfodata[11],
  2443. "10": fx,
  2444. "11": qw1,
  2445. "12": qw2,
  2446. "13": g1,
  2447. "14": g2,
  2448. "15": g3,
  2449. "16":jjdw,
  2450. "17": "--",
  2451. "18": "--",
  2452. "19": "--",
  2453. "20": d,
  2454. "21": "--",
  2455. "22": e,
  2456. "23": F,
  2457. "24": postion,
  2458. "25": wx_people, # flightinfodata[22],
  2459. "26": "",
  2460. "27": fx_people, # flightinfodata[23],
  2461. "28": row[1],
  2462. "29": g,
  2463. "30": ta_td,
  2464. "31": type31,
  2465. "32": fj,
  2466. "99":color_code,
  2467. "101": color_code1,
  2468. "102": color_code2,
  2469. "103": color_code3,
  2470. "109":row[5]
  2471. }
  2472. tableWidgetDispalydata[rowNum] = item_dic
  2473. rowNum += 1
  2474. elif flightinfodata[11] == "停场":
  2475. item_dic = {"0": rowNum,
  2476. "1": flightinfodata[2],
  2477. "2": flightinfodata[4],
  2478. "3": flightinfodata[3],
  2479. "4": "--",
  2480. "5": a,
  2481. "6": "--",
  2482. "7": "--",
  2483. "8": flightinfodata[19],
  2484. "9": flightinfodata[11],
  2485. "10": fx,
  2486. "11": qw1,
  2487. "12": qw2,
  2488. "13": g1,
  2489. "14": g2,
  2490. "15": g3,
  2491. "16":"--",
  2492. "17": "--",
  2493. "18": "--",
  2494. "19": "--",
  2495. "20": "--",
  2496. "21": "--",
  2497. "22": "--",
  2498. "23": "--",
  2499. "24": "--", # flightinfodata[22],
  2500. "25": "--", # flightinfodata[23],
  2501. "26": "--",
  2502. "27": "--",
  2503. "28": row[1],
  2504. "29": "TSK",
  2505. "30":"--",
  2506. "31": "--",
  2507. "32": fj,
  2508. "99":color_code,
  2509. "101": color_code1,
  2510. "102": color_code2,
  2511. "103": color_code3,
  2512. "109":row[5]
  2513. }
  2514. tableWidgetDispalydata[rowNum] = item_dic
  2515. rowNum += 1
  2516. elif flightinfodata[11] == "航前":
  2517. item_dic = {"0": rowNum,
  2518. "1": flightinfodata[2],
  2519. "2": flightinfodata[4],
  2520. "3": flightinfodata[3],
  2521. "4": flightinfodata[8],
  2522. "5": "",
  2523. "6": "",
  2524. "7": c,
  2525. "8": flightinfodata[21],
  2526. "9": flightinfodata[11],
  2527. "10": fx,
  2528. "11": qw1,
  2529. "12": qw2,
  2530. "13": g1,
  2531. "14": g2,
  2532. "15": g3,
  2533. "16":jjdw,
  2534. "18": FX,
  2535. "19": XJ,
  2536. "17": "--",
  2537. "20": d,
  2538. "21": SJDW,
  2539. "22": e,
  2540. "23": F,
  2541. "24": postion,
  2542. "25": wx_people, # flightinfodata[22],
  2543. "26": "",
  2544. "27": fx_people, # flightinfodata[23],
  2545. "28": row[1],
  2546. "29": g,
  2547. "30": ta_td,
  2548. "31": type31,
  2549. "32": fj,
  2550. "99":color_code,
  2551. "101": color_code1,
  2552. "102": color_code2,
  2553. "103": color_code3,
  2554. "109":row[5]
  2555. }
  2556. tableWidgetDispalydata[rowNum] = item_dic
  2557. rowNum += 1
  2558. elif row[3] == "短停接":
  2559. item_dic = {"0": rowNum,
  2560. "1": flightinfodata[2],
  2561. "2": flightinfodata[4],
  2562. "3": flightinfodata[3],
  2563. "4": flightinfodata[8],
  2564. "5": a,
  2565. "6": b,
  2566. "7": c,
  2567. "8": flightinfodata[19],
  2568. "9": flightinfodata[11],
  2569. "10": fx,
  2570. "11": qw1,
  2571. "12": qw2,
  2572. "13": g1,
  2573. "14": g2,
  2574. "15": g3,
  2575. "16":jjdw,
  2576. "18": FX,
  2577. "19": "--",
  2578. "17": ESDW,
  2579. "20": d,
  2580. "21": SJDW,
  2581. "22": e,
  2582. "23": F,
  2583. "24": postion,
  2584. "25": wx_people, # flightinfodata[22],
  2585. "26": ecsj_people,
  2586. "27": fx_people, # flightinfodata[23],
  2587. "28": row[1],
  2588. "29": g,
  2589. "30": ta_td,
  2590. "31": type31,
  2591. "32":fj,
  2592. "99":color_code,
  2593. "101": color_code1,
  2594. "102": color_code2,
  2595. "103": color_code3,
  2596. "109":row[5]
  2597. }
  2598. tableWidgetDispalydata[rowNum] = item_dic
  2599. rowNum += 1
  2600. elif row[3] == "特后前接":
  2601. item_dic = {"0": rowNum,
  2602. "1": flightinfodata[2],
  2603. "2": flightinfodata[4],
  2604. "3": flightinfodata[3],
  2605. "4": flightinfodata[8],
  2606. "5": a,
  2607. "6": b,
  2608. "7": c,
  2609. "8": flightinfodata[19],
  2610. "9": flightinfodata[11],
  2611. "10": fx,
  2612. "11": qw1,
  2613. "12": qw2,
  2614. "13": g1,
  2615. "14": g2,
  2616. "15": g3,
  2617. "16":jjdw,
  2618. "18": FX,
  2619. "19": "--",
  2620. "17": "--",
  2621. "20": d,
  2622. "21": SJDW,
  2623. "22": e,
  2624. "23": F,
  2625. "24": postion,
  2626. "25": wx_people, # flightinfodata[22],
  2627. "26": "",
  2628. "27": fx_people, # flightinfodata[23],
  2629. "28": row[1],
  2630. "29": g,
  2631. "30": ta_td,
  2632. "31": type31,
  2633. "32":fj,
  2634. "99":color_code,
  2635. "101": color_code1,
  2636. "102": color_code2,
  2637. "103": color_code3,
  2638. "109":row[5]
  2639. }
  2640. tableWidgetDispalydata[rowNum] = item_dic
  2641. rowNum += 1
  2642. newdic = {"B": '"{}"'.format(tableWidgetDispalydata)}
  2643. if date == "1":
  2644. fdb.upDateItem("display", newdic, "ID = '1'")
  2645. elif date == "2":
  2646. fdb.upDateItem("display", newdic, "ID = '2'")
  2647. elif date == "3":
  2648. fdb.upDateItem("display", newdic, "ID = '3'")
  2649. return tableWidgetDispalydata
  2650. except Exception:
  2651. dingding_alert(traceback.format_exc())
  2652. def tableWidgetDisplayChange(fdb:flightDB,selectedtime):
  2653. try:
  2654. log=fdb.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
  2655. tableWidgetDisplayChangedata={}
  2656. now = datetime.datetime.now()
  2657. rowNum=0
  2658. if len(log) != 0:
  2659. for i in log:
  2660. timedeadline=""
  2661. if i[8] =="人工待办" and i[4] !="" and i[7] =="":
  2662. timedeadline = datetime.datetime.strptime(i[4], "%Y-%m-%d %H:%M")
  2663. #print(timedeadline)
  2664. if timedeadline <= now:
  2665. tableWidgetDisplayChangedata[rowNum]=i
  2666. rowNum +=1
  2667. elif i[8] =="准备组任务" and i[4] !="" and i[7] =="":
  2668. timedeadline = datetime.datetime.strptime(i[4], "%Y-%m-%d %H:%M:%S")
  2669. #print(timedeadline)
  2670. if timedeadline <= now:
  2671. tableWidgetDisplayChangedata[rowNum]=i
  2672. rowNum +=1
  2673. elif i[8] !="人工待办" and i[8] !="人工待办":
  2674. tableWidgetDisplayChangedata[rowNum] = i
  2675. rowNum += 1
  2676. return tableWidgetDisplayChangedata
  2677. except Exception:
  2678. dingding_alert(traceback.format_exc())
  2679. def tableWidgetLOGDispaly(fdb:flightDB,selectedtime):
  2680. try:
  2681. selectdaystr = str(selectedtime)[0:4] + "-" + str(selectedtime)[4:6] + "-" + str(selectedtime)[6:] + " 00:00:00"
  2682. selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
  2683. yesterday = (selectday - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  2684. log_str = fdb.sort_queryTable("编号", 'logs', "提示信息 !='' and 变更字段 !='人工待办' and 产生时间 >'%s'" % yesterday,"产生时间", "desc")
  2685. log_len = 999 if len(log_str) > 1000 else len(log_str)
  2686. tableWidgetLOGDispalydata={}
  2687. for i in range(0,log_len):
  2688. a = fdb.queryTabel('logs', "*", "编号='%s'" % log_str[i][0])[0]
  2689. tableWidgetLOGDispalydata[i]=a[4]
  2690. return tableWidgetLOGDispalydata
  2691. except Exception:
  2692. dingding_alert(traceback.format_exc())
  2693. def deletelogs(fdb:flightDB):
  2694. try:
  2695. now=datetime.datetime.now()
  2696. passtime = (now - datetime.timedelta(days=30)).strftime("%Y-%m-%d %H:%M:%S")
  2697. log_str = fdb.queryTabel('logs',"编号","产生时间 <'%s'" %passtime)
  2698. if len(log_str) != 0:
  2699. for i in log_str:
  2700. fdb.deleteSingledata('logs',"编号='%s'" % i[0])
  2701. except Exception:
  2702. dingding_alert(traceback.format_exc())
  2703. def checkCalllist(fdb:flightDB,time):
  2704. try:
  2705. selectedtime_time = str(time) + " 00:00:00"
  2706. now = datetime.datetime.strptime(selectedtime_time, "%Y%m%d %H:%M:%S")
  2707. tom = (now + datetime.timedelta(days=2)).strftime("%Y-%m-%d %H:%M:%S")
  2708. yesterday = (now - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  2709. calllists=fdb.sort_queryTable2("*","Calllist","创建时间 <'%s' and 创建时间 >'%s'"%(tom,yesterday),"创建时间","desc","接通时间","desc")
  2710. num = 0
  2711. res = {}
  2712. if len(calllists) != 0:
  2713. for i in calllists:
  2714. calllist={}
  2715. calllist["序号"]=num
  2716. calllist["电话"] = i[1]
  2717. calllist["工号"] = i[2]
  2718. calllist["姓名"] = i[3]
  2719. calllist["航班号"] = i[4]
  2720. calllist["拨号次数"] = str(i[6])
  2721. calllist["创建时间"] = i[7]
  2722. calllist["接通时间"] = i[8]
  2723. res[num] = calllist
  2724. num += 1
  2725. return res
  2726. except Exception:
  2727. dingding_alert(traceback.format_exc())
  2728. def getphonelist(fdb:flightDB):
  2729. try:
  2730. phonelists=fdb.getAlldata("workerinfo")
  2731. num = 0
  2732. res={}
  2733. if len(phonelists) != 0:
  2734. for i in phonelists:
  2735. phonelist = {}
  2736. phonelist["序号"]=num
  2737. phonelist["姓名"] = i[1]
  2738. phonelist["部门"] = i[2]
  2739. phonelist["电话"] = i[5]
  2740. phonelist["name"] = i[11]
  2741. res[num]=phonelist
  2742. num+=1
  2743. return res
  2744. except Exception:
  2745. dingding_alert(traceback.format_exc())
  2746. def MM_GJJH_LIST(fdb:flightDB,team,data):
  2747. GJlist1 = {}
  2748. GJlist2 = {}
  2749. if data !=[]:
  2750. now=datetime.datetime.now()
  2751. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  2752. a_str = nowDay_str2 + " 17:00:00"
  2753. time1 = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  2754. if time1 < now :
  2755. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  2756. pglist = fdb.queryTabel("pglist%s"%nowDay,"姓名","班次 = 'A'")
  2757. else:
  2758. nowDay = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  2759. pglist = fdb.queryTabel("pglist%s" % nowDay, "姓名", "班次 = 'B'")
  2760. for row in data:
  2761. phone=fdb.queryTabel("workerinfo","电话","姓名='%s'"%str(row["zlynam"]))
  2762. if len(phone) != 0 and len(phone[0][0]) == 12:
  2763. phonenumber=phone[0][0][1:]
  2764. if str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) in GJlist1.keys():
  2765. maktx=GJlist1[row["zlynam"]]["工具名"]+","+row["maktx"]
  2766. zzbh = GJlist1[row["zlynam"]]["编号"] + "," + row["zzbh"]
  2767. zjcmeng = GJlist1[row["zlynam"]]["数量"] + "," + row["zjcmeng"]
  2768. a={"工具名":maktx,"编号":zzbh,"数量":zjcmeng,"phonenumber":phonenumber}
  2769. GJlist1[row["zlynam"]]=a
  2770. elif str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) not in GJlist1.keys():
  2771. maktx =row["maktx"]
  2772. zzbh = row["zzbh"]
  2773. zjcmeng = row["zjcmeng"]
  2774. a={"工具名":maktx,"编号":zzbh,"数量":zjcmeng,"phonenumber":phonenumber}
  2775. GJlist1[row["zlynam"]] = a
  2776. else:
  2777. if str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) in GJlist2.keys():
  2778. maktx = GJlist2[row["zlynam"]]["工具名"] + "," + row["maktx"]
  2779. zzbh = GJlist2[row["zlynam"]]["编号"] + "," + row["zzbh"]
  2780. zjcmeng = GJlist2[row["zlynam"]]["数量"] + "," + row["zjcmeng"]
  2781. a = {"工具名": maktx, "编号": zzbh, "数量": zjcmeng}
  2782. GJlist2[row["zlynam"]] = a
  2783. elif str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) not in GJlist2.keys():
  2784. maktx = row["maktx"]
  2785. zzbh = row["zzbh"]
  2786. zjcmeng = row["zjcmeng"]
  2787. a = {"工具名": maktx, "编号": zzbh, "数量": zjcmeng}
  2788. GJlist2[row["zlynam"]] = a
  2789. if GJlist1:
  2790. msg = "经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
  2791. times=5
  2792. telphone=list()
  2793. for i in GJlist1:
  2794. msg =msg+"\n"+"【"+str(i)+"】" + "\n[工具名]:" + str(GJlist1[i]["工具名"]) + "\n[数量]:" + str(GJlist1[i]["数量"]) + "\n[编号]:" + str(GJlist1[i]["编号"])
  2795. telphone.append(str(GJlist1[i]["phonenumber"]))
  2796. #telphone.append("17729693827")
  2797. times+=1
  2798. if times % 5 == 0:
  2799. if team == "test":
  2800. dingding_alert1(telphone,msg)
  2801. elif str(team)=="1":
  2802. dingding_alert11(telphone, msg)
  2803. elif str(team)=="2":
  2804. dingding_alert1(telphone, msg)
  2805. elif str(team)=="3":
  2806. dingding_alert1(telphone, msg)
  2807. elif str(team)=="4":
  2808. dingding_alert1(telphone, msg)
  2809. msg = "经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
  2810. telphone = list()
  2811. if msg !="经查询您有以下工具未归还,请注意核实工具归还或交接情况:":
  2812. if team == "test":
  2813. dingding_alert1(telphone, msg)
  2814. elif str(team) == "1":
  2815. #print(telphone, msg)
  2816. #dingding_alert1(telphone, msg)
  2817. dingding_alert11(telphone, msg)
  2818. elif str(team) == "2":
  2819. dingding_alert1(telphone, msg)
  2820. elif str(team) == "3":
  2821. dingding_alert1(telphone, msg)
  2822. elif str(team) == "4":
  2823. dingding_alert1(telphone, msg)
  2824. if GJlist2:
  2825. msg="经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
  2826. a=list()
  2827. for i in GJlist2:
  2828. msg =msg+"\n"+"【"+str(i)+"】" + "\n[工具名]:" + str(GJlist2[i]["工具名"]) + "\n[数量]:" + str(GJlist2[i]["数量"]) + "\n[编号]:" + str(GJlist2[i]["编号"])
  2829. if team == "test":
  2830. dingding_alert1(a, msg)
  2831. elif str(team) == "1":
  2832. #print("联系不上的", msg)
  2833. #dingding_alert1(a, msg)
  2834. dingding_alert11("", msg)
  2835. elif str(team) == "2":
  2836. dingding_alert1(a, msg)
  2837. elif str(team) == "3":
  2838. dingding_alert1(a, msg)
  2839. elif str(team) == "4":
  2840. dingding_alert1(a, msg)
  2841. return
  2842. def taskAtuoCheck(fdb:flightDB,time):
  2843. try:
  2844. now = datetime.datetime.now()
  2845. tomorrow=(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  2846. #print(tomorrow)
  2847. if time =="1":
  2848. print(datetime.datetime.now(),"[数据库操作]准备组任务首次登录检查验证")
  2849. log_str = fdb.queryTabel('logs',"编号","处理时间='' and 变更字段='准备组任务'")
  2850. if len(log_str) == 0:
  2851. getTaskAuto=fdb.getAlldata('taskAuto')
  2852. if len(getTaskAuto) != 0:
  2853. #print(getTaskAuto)
  2854. for i in getTaskAuto:
  2855. #print(i)
  2856. if i[1] !="None":
  2857. time1=str(datetime.date.today())+ " "+i[1]
  2858. time11 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  2859. time2 = str(datetime.date.today()+ datetime.timedelta(days=1)) + " " + i[1]
  2860. time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
  2861. newdic = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2862. "提示信息": "%s" % time11, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务", "显示对象": "",
  2863. "提示内容": i[3]}
  2864. fdb.lazyInsertData("logs", newdic)
  2865. newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2866. "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务", "显示对象": "",
  2867. "提示内容": i[3]}
  2868. fdb.lazyInsertData("logs", newdic2)
  2869. if time =="2":
  2870. print(datetime.datetime.now(),"[数据库操作]准备组任务登录持续验证")
  2871. log_str2 = fdb.queryTabel('logs', "编号", "提示信息 >'%s' and 处理时间='' and 变更字段='准备组任务'" % tomorrow)
  2872. if len(log_str2) == 0:
  2873. getTaskAuto = fdb.getAlldata('taskAuto')
  2874. if len(getTaskAuto) != 0:
  2875. #print(getTaskAuto)
  2876. for i in getTaskAuto:
  2877. #print(i)
  2878. if i[1] != "None":
  2879. time2 = str(datetime.date.today() + datetime.timedelta(days=1)) + " " + i[1]
  2880. time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
  2881. newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2882. "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
  2883. "显示对象": "",
  2884. "提示内容": i[3]}
  2885. fdb.lazyInsertData("logs", newdic2)
  2886. if time =="3":
  2887. print(datetime.datetime.now(),"[数据库操作]更新准备组任务抑制前序任务")
  2888. log_str3 = fdb.queryTabel('logs', "编号", "处理时间='' and 变更字段='准备组任务'")
  2889. #print(log_str3)
  2890. if len(log_str3) != 0:
  2891. for i in log_str3:
  2892. newdic = {"处理人": "'更新准备组任务系统抑制'", "处理时间": "'%s'" % now}
  2893. fdb.lazyUpdateItem('logs', newdic, "编号='%s'" % i[0])
  2894. getTaskAuto = fdb.getAlldata('taskAuto')
  2895. if len(getTaskAuto) != 0:
  2896. #print(getTaskAuto)
  2897. for i in getTaskAuto:
  2898. #print(i)
  2899. if i[1] != "None":
  2900. time1 = str(datetime.date.today()) + " " + i[1]
  2901. time11 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  2902. time2 = str(datetime.date.today() + datetime.timedelta(days=1)) + " " + i[1]
  2903. time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
  2904. newdic = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2905. "提示信息": "%s" % time11, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
  2906. "显示对象": "",
  2907. "提示内容": i[3]}
  2908. fdb.lazyInsertData("logs", newdic)
  2909. newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2910. "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
  2911. "显示对象": "",
  2912. "提示内容": i[3]}
  2913. fdb.lazyInsertData("logs", newdic2)
  2914. fdb.FunctionCommit()
  2915. except Exception:
  2916. fdb.FunctionCommit()
  2917. dingding_alert(traceback.format_exc())
  2918. def selftaxiLogs(database:flightDB,TEXT:str,flightid:str):
  2919. try:
  2920. now = datetime.datetime.now()
  2921. noteid=database.queryTabel("logs","*","航班编号='%s' and 警告信息='%s'"%(flightid,TEXT))
  2922. if len(noteid) == 0:
  2923. newdic = {"航班编号":flightid, "警告信息":TEXT, "信息状态": "",
  2924. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "自滑提示","显示对象":"","提示内容":""}
  2925. database.insertData("logs", newdic)
  2926. except Exception:
  2927. dingding_alert(traceback.format_exc())
  2928. def insertLogs(database:flightDB,TEXT:str,user:str,time):
  2929. try:
  2930. now = datetime.datetime.now()
  2931. newdic = {"航班编号": "人工%s" % user, "警告信息":TEXT, "信息状态": "",
  2932. "提示信息": time,"产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "人工待办","显示对象":"","提示内容":""} #需要确定显示对象,可以考虑传参
  2933. database.insertData("logs", newdic)
  2934. except Exception:
  2935. dingding_alert(traceback.format_exc())
  2936. def insertLogs2(database:flightDB,TEXT:str,user:str,time):
  2937. try:
  2938. now = datetime.datetime.now()
  2939. newdic = {"航班编号": "人工%s" % user, "警告信息":"", "信息状态": "",
  2940. "提示信息": TEXT,"产生时间": "%s" % now, "处理人": user, "处理时间": time, "变更字段": "操作日志","显示对象":"","提示内容":""} #需要确定显示对象,可以考虑传参
  2941. database.insertData("logs", newdic)
  2942. except Exception:
  2943. dingding_alert(traceback.format_exc())
  2944. def manChangests(database:flightDB,flight_id:str,changests_id:str,selectedtime,username):
  2945. try:
  2946. nowDayStr = selectedtime
  2947. now = datetime.datetime.now()
  2948. now11=str(now).split(".")[0]
  2949. code = {"接机到位": "已到位", "放行": "已放行", "随机到位": "已到位", "销子夹板": "已取下", "二送到位": "已到位"}
  2950. code2 = {"接机到位": "接机已到位提示", "放行": "已放行提示", "随机到位": "随机已到位提示", "销子夹板": "销子夹板已提示", "二送到位": "二送已到位提示"}
  2951. flightsts_search=database.queryTabel("flightsts{}".format(nowDayStr),"%s"%changests_id,"航班编号 = '%s'"%flight_id)
  2952. waringsts=database.queryTabel("logs","*","航班编号='%s' and 处理时间 =''"%flight_id)
  2953. if len(flightsts_search) != 0:
  2954. if flightsts_search[0][0] != "":
  2955. newdic={"%s"%changests_id:"''","%s"%code2[changests_id]:"''"}
  2956. database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号='%s'"%flight_id)
  2957. a =database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
  2958. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
  2959. "提示信息": "人工处理:%s取消%s状态!%s" % (a,changests_id,now11),
  2960. "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
  2961. database.insertData('logs', newdic)
  2962. else:
  2963. newdic={"%s"%changests_id:"'%s'"%code[changests_id],"%s"%code2[changests_id]:"'1'"}
  2964. database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号 = '%s'"%flight_id)
  2965. a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(
  2966. database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
  2967. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
  2968. "提示信息": "人工处理:%s确认%s已完成!%s" % (a, changests_id,now11),
  2969. "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
  2970. database.insertData('logs', newdic)
  2971. if len(waringsts) != 0:
  2972. for i in waringsts:
  2973. if changests_id == "接机到位" and i[8]=="到位警告":
  2974. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2975. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2976. elif changests_id == "放行" and i[8]=="放行警告":
  2977. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2978. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2979. elif changests_id == "二送到位" and i[8]=="二送警告":
  2980. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2981. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2982. elif changests_id == "销子夹板" and i[8]=="销夹警告":
  2983. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2984. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2985. elif changests_id == "随机到位" and i[8] == "随机到位警告":
  2986. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2987. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2988. except Exception:
  2989. print(traceback.format_exc())
  2990. dingding_alert(traceback.format_exc())
  2991. def checkFlightAlert(database:flightDB):
  2992. try:
  2993. ########需要建立昨日初始化
  2994. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  2995. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  2996. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  2997. selftaxi=["166","166L","166R","167","167L","167R","168","169","170","171","172","173","174","269","270","271","272","273","274","275","287","288","601","602","603","604","605","606","607","607L","607R"]
  2998. now = datetime.datetime.now()
  2999. now_20=(datetime.datetime.now()+ datetime.timedelta(minutes=120)).strftime("%Y%m%d")
  3000. if now_20 == nowDay:
  3001. day=[nowDay,nowDay_1]
  3002. else:
  3003. day = [nowDay, nowDay_1,nowDay_2]
  3004. for nowDayStr in day:
  3005. flightcheck=database.queryTabel("sortFlight{}".format(nowDayStr),"航班编号","CAST(级别 AS integer) = 1" )
  3006. flightcheck2 = database.queryTabel("sortFlight{}".format(nowDayStr), "航班编号", "CAST(级别 AS integer) != 4")
  3007. if database.getSingledata("航班编号", "flightinfo{}".format(nowDayStr)) !=None and len(database.getSingledata("航班编号", "flightinfo{}".format(nowDayStr))) != 0 and len(flightcheck) !=0:
  3008. for i in flightcheck:
  3009. a = database.queryTabel("flightinfo{}".format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
  3010. b = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
  3011. dd = database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % i[0])[0][0]
  3012. if b =="航前":
  3013. c = database.queryTabel("flightinfo{}".format(nowDayStr), "航前离港机位", "航班编号='%s'" % i[0])[0][0]
  3014. else:
  3015. c = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前进港机位", "航班编号='%s'" % i[0])[0][0]
  3016. #if c in selftaxi:
  3017. if "航前" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and database.queryTabel("flightinfo{}".format(nowDayStr),"航前预计起飞","航班编号='%s'"%i[0])[0][0] != "":
  3018. STD=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  3019. STD_str = dd.split("-")[0] + "/" + STD.split("]")[1]
  3020. STD_90 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
  3021. STD_30 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=30)
  3022. if STD_90 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
  3023. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3024. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  3025. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  3026. database.lazyInsertData('logs', newdic)
  3027. if STD_30 < now and "已放行" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"放行","航班编号='%s'"%i[0])) and \
  3028. "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3029. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
  3030. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
  3031. database.lazyInsertData('logs', newdic)
  3032. if STD_30 < now and "已取下" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"销子夹板","航班编号='%s'"%i[0])) and \
  3033. "销夹警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3034. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s销夹取下情况!"%(a,b,c), "信息状态": "",
  3035. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "销夹警告","显示对象":"","提示内容":""}
  3036. database.lazyInsertData('logs', newdic)
  3037. elif "航后" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and\
  3038. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] != "" and\
  3039. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] != "":
  3040. ETA_15_str = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  3041. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3042. if ETA_15 < now and "已到位" not in database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0]) and \
  3043. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3044. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  3045. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  3046. database.lazyInsertData('logs', newdic)
  3047. elif "短停" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and\
  3048. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!= "" and \
  3049. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0]!= "" :
  3050. ETA_15_str=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3051. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3052. ATA = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])
  3053. if ATA[0][0] != "":
  3054. ATA_time_30 = datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  3055. ATA_time_3H=datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S")+datetime.timedelta(minutes=180)
  3056. else:
  3057. ATA_time_30 = ""
  3058. ATA_time_3H=""
  3059. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  3060. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  3061. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  3062. TD_time_25 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")- datetime.timedelta(minutes=25)
  3063. TD_time_120 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  3064. TD_time=datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")
  3065. if ETA_15 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
  3066. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3067. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  3068. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  3069. database.lazyInsertData('logs', newdic)
  3070. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_25 < now and "已放行" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"放行","航班编号='%s'"%i[0])) and \
  3071. "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3072. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
  3073. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
  3074. database.lazyInsertData('logs', newdic)
  3075. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_25 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"二送到位","航班编号='%s'"%i[0])) and \
  3076. "二送警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3077. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s二送到位情况!"%(a,b,c), "信息状态": "",
  3078. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "二送警告","显示对象":"","提示内容":""}
  3079. database.lazyInsertData('logs', newdic)
  3080. if ATA_time_3H !="" and ATA_time_3H < TD_time and TD_time_120 < now and\
  3081. "长短停到位提示" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" % i[0])):
  3082. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认安排%s%s%s长短停上电人员!" % (a, b, c), "信息状态": "",
  3083. "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "长短停到位提示","显示对象":"","提示内容":""}
  3084. database.lazyInsertData('logs', newdic)
  3085. if ATA_time_3H !="" and ATA_time_3H < TD_time and\
  3086. "长短停值守提示" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" % i[0])):
  3087. newdic = {"航班编号": "%s" % i[0], "警告信息": "请注意安排%s %s长短停值守,如无需则忽略!" % (a,c), "信息状态": "",
  3088. "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "长短停值守提示","显示对象":"","提示内容":""}
  3089. database.lazyInsertData('logs', newdic)
  3090. elif "短停" not in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and \
  3091. "航后" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0]))and \
  3092. "航前" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
  3093. "未显示" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
  3094. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!= "":
  3095. ETA_15_str = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  3096. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3097. ATA = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])
  3098. if ATA[0][0] != "":
  3099. #print(ATA[0][0])
  3100. ATA_time_30 = datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  3101. else:
  3102. ATA_time_30 = ""
  3103. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  3104. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  3105. #print(TD)
  3106. #print(FlightDate)
  3107. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  3108. TD_time_25 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")- datetime.timedelta(minutes=25)
  3109. if ETA_15 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
  3110. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3111. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  3112. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  3113. database.lazyInsertData('logs', newdic)
  3114. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_25 < now and "已放行" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"放行","航班编号='%s'"%i[0])) and \
  3115. "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3116. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
  3117. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
  3118. database.lazyInsertData('logs', newdic)
  3119. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_25 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"二送到位","航班编号='%s'"%i[0])) and \
  3120. "二送警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  3121. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s二送到位情况!"%(a,b,c), "信息状态": "",
  3122. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "二送警告","显示对象":"","提示内容":""}
  3123. database.lazyInsertData('logs', newdic)
  3124. for i in flightcheck2:
  3125. a = database.queryTabel("flightinfo{}".format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
  3126. b = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
  3127. dd = database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % i[0])[0][0]
  3128. if b =="航前":
  3129. c = database.queryTabel("flightinfo{}".format(nowDayStr), "航前离港机位", "航班编号='%s'" % i[0])[0][0]
  3130. else:
  3131. c = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前进港机位", "航班编号='%s'" % i[0])[0][0]
  3132. if "航前" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and database.queryTabel("flightinfo{}".format(nowDayStr),"航前预计起飞","航班编号='%s'"%i[0])[0][0] != "":
  3133. STD=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  3134. STD_str = dd.split("-")[0] + "/" + STD.split("]")[1]
  3135. STD_120 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  3136. STD_60 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
  3137. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  3138. "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and STD_120 < now:
  3139. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
  3140. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  3141. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  3142. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
  3143. database.lazyInsertData('logs', newdic)
  3144. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  3145. "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and STD_60 < now and\
  3146. "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
  3147. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  3148. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
  3149. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  3150. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
  3151. database.lazyInsertData('logs', newdic)
  3152. elif "短停" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])):
  3153. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  3154. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  3155. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  3156. TD_time_120 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  3157. TD_time_60 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
  3158. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  3159. "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and TD_time_120 < now:
  3160. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  3161. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
  3162. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  3163. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
  3164. database.lazyInsertData('logs', newdic)
  3165. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  3166. "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and TD_time_60 < now and\
  3167. "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
  3168. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  3169. sjry = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
  3170. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  3171. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
  3172. database.lazyInsertData('logs', newdic)
  3173. elif "短停" not in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and \
  3174. "航后" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0]))and \
  3175. "航前" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
  3176. "未显示" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and\
  3177. "停场" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])):
  3178. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  3179. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  3180. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  3181. TD_time_120= datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  3182. TD_time_60 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
  3183. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  3184. "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and TD_time_120 < now:
  3185. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  3186. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
  3187. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  3188. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
  3189. database.lazyInsertData('logs', newdic)
  3190. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  3191. "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and TD_time_60 < now and\
  3192. "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
  3193. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  3194. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
  3195. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  3196. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
  3197. database.lazyInsertData('logs', newdic)
  3198. database.FunctionCommit()
  3199. waringIDs=database.queryTabel('logs',"*","变更字段 like '%警告%' and 处理时间 =''")
  3200. flightstsids=database.getSingledata("航班编号",'flightsts{}'.format(nowDayStr))
  3201. for waringID in waringIDs:
  3202. if str(waringID[1]) in str(flightstsids):
  3203. waringIDstsNow=database.queryTabel('flightsts{}'.format(nowDayStr),"*","航班编号 ='%s'"%waringID[1])
  3204. if waringID[8] == "到位警告" and waringIDstsNow[0][3] == "已到位":
  3205. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  3206. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  3207. if waringID[8] == "放行警告" and waringIDstsNow[0][4] == "已放行":
  3208. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  3209. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  3210. if waringID[8] == "二送警告" and waringIDstsNow[0][7] == "已到位":
  3211. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  3212. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  3213. if waringID[8] == "销夹警告" and waringIDstsNow[0][5] == "已取下":
  3214. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  3215. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  3216. if waringID[8] == "随机到位警告" and waringIDstsNow[0][6] == "已到位":
  3217. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  3218. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  3219. database.FunctionCommit()
  3220. except Exception:
  3221. database.FunctionCommit()
  3222. print(traceback.format_exc())
  3223. dingding_alert(traceback.format_exc())
  3224. def createWorkloadtablesFromPg(fdb: flightDB, workLoad: flightDB,selectedtime):
  3225. try:
  3226. workloadDic = {}
  3227. primaryKey2 = 'text UNIQUE NOT NULL'
  3228. pglist=fdb.getAlldata("pglist{}".format(selectedtime))
  3229. if len(pglist) != 0:
  3230. for workloadkey in list(workloadLabel)[1:]:
  3231. workloadDic[workloadkey] = 'text not null'
  3232. for row in pglist:
  3233. workLoad.initTable('workload%s'%str(row[1]),"编号", primaryKey2, workloadDic)
  3234. except Exception:
  3235. dingding_alert(traceback.format_exc())
  3236. def createWorkloadtables(fdb:flightDB, workLoad:flightDB):
  3237. try:
  3238. workloadDic = {}
  3239. primaryKey = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'
  3240. primaryKey2 = 'TEXT UNIQUE NOT NULL'
  3241. #print(len(fdb.getAlldata("workerinfo")))
  3242. if len(fdb.getAlldata("workerinfo")) != 0:
  3243. for workloadkey in list(workloadLabel)[1:]:
  3244. workloadDic[workloadkey]= 'text not null'
  3245. worknumbs=fdb.getSingledata("工号","workerinfo")
  3246. for worknumbskey in worknumbs:
  3247. if str(worknumbskey[0]) != "*":
  3248. workLoad.initTable('workload%s'%str(worknumbskey[0]),"编号",primaryKey2, workloadDic)
  3249. else:
  3250. print(datetime.datetime.now(),"[数据库操作]人员信息为空,无法创建人员工作量数据库!请先上传人员信息")
  3251. #需要QT输出警告弹框信息
  3252. except Exception:
  3253. dingding_alert(traceback.format_exc())
  3254. def get_full_pinyin1(word, style=Style.NORMAL, separator=''):
  3255. pinyin_list = pinyin(word, style=style)
  3256. #使用列表推导式获取每个汉字的第一个拼音(不带声调),并使用 separator 连接
  3257. full_pinyin = separator.join([''.join(syllable[0]) for syllable in pinyin_list])
  3258. return full_pinyin
  3259. def get_full_pinyin2(word, style=Style.NORMAL, separator=''):
  3260. return ''.join([word[0][0] for word in pinyin(word, style=Style.NORMAL)])
  3261. def get_dic(database:flightDB, fileName):
  3262. try:
  3263. fdb = database
  3264. decrypted_workbook = io.BytesIO()
  3265. try:
  3266. with open(fileName, 'rb') as file:
  3267. office_file = msoffcrypto.OfficeFile(file)
  3268. office_file.load_key(password='Scal_0177')
  3269. office_file.decrypt(decrypted_workbook)
  3270. workbook = openpyxl.load_workbook(filename=decrypted_workbook)
  3271. mysheet = workbook.active
  3272. myrows = list(mysheet.values)[1:]
  3273. mytitle = list(mysheet.values)[0]
  3274. for myrow in myrows:
  3275. mydics0 = {}
  3276. mydics1 = {}
  3277. for i in range(0, (len(mytitle))):
  3278. a = get_full_pinyin1(str(myrow[0])) + ":" + get_full_pinyin2(str(myrow[0]))
  3279. mydics0[mytitle[i]] = "%s"%myrow[i]
  3280. mydics0[mytitle[11]] = "%s" % a
  3281. if i != 3 and i != 11:
  3282. mydics1[mytitle[i]] = "'%s'" % myrow[i]
  3283. elif i == 11:
  3284. mydics1[mytitle[11]] = "'%s'" % a
  3285. #a= fdb.getSingledata("工号",'workerinfo')
  3286. if str(mydics0["工号"]) in str(fdb.getSingledata("工号",'workerinfo')):
  3287. fdb.lazyUpdateItem('workerinfo',mydics1,"工号='%s'"%mydics0["工号"])
  3288. else:
  3289. fdb.lazyInsertData('workerinfo',mydics0)
  3290. #print(1)
  3291. fdb.FunctionCommit()
  3292. return 1
  3293. except Exception:
  3294. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查通讯录文件!人员显示功能失效!!')
  3295. print(traceback.format_exc())
  3296. dingding_alert(traceback.format_exc())
  3297. # 需要QT输出警告弹框信息
  3298. fdb.FunctionCommit()
  3299. return 0
  3300. except Exception:
  3301. dingding_alert(traceback.format_exc())
  3302. def manAddFlight(fdb:flightDB,flighttype,acno,eng,actype,flightno,flightdate,bay,eta,etd,user):
  3303. starttime = flightdate + " 00:00:00"
  3304. flightdate1 = datetime.datetime.strptime(starttime, "%Y-%m-%d %H:%M:%S")
  3305. flightdate2 =flightdate.replace("-", "")
  3306. flightids=fdb.getSingledata("航班编号","flightinfo%s"%flightdate2)
  3307. ETD2=str("[计]"+etd[6:16]).replace("-", "/")
  3308. flightid = "MAN" + str(acno) + str(flightno)+str(flightdate2)
  3309. if flightid not in str(flightids):
  3310. if flighttype =="航前":
  3311. newdic={"航班编号":"%s"%flightid, "航班编号对":"", "机号":acno, "发动机":eng, "机型":actype, "保障航班号":flightno, "进港机场":"", "离港机场":"", "进出港航班号":flightno, "航班日期":flightdate1, "航班状态":"",
  3312. "航班类型":flighttype, "非航前计划到达":"", "航前预计起飞":etd, "非航前实际到达":"", "非航前预计到达":"", "航前实际起飞":"", "非航前预计起飞":ETD2, "非航前预计进港机位":"",
  3313. "非航前进港机位":"", "航前预计离港机位":"", "航前离港机位":bay, "维修人员":"", "放行人员":"", "维修状态":"", "重要航班":"", "随机":"", "保留":"", "备降返航":"", "维修状态时间":"", "二送人员":"", "二送状态":"",
  3314. "附加消息":"人工添加", "取消标志":""}
  3315. elif flighttype =="短停" or flighttype =="特后前":
  3316. newdic = {"航班编号": "%s" % flightid, "航班编号对": "", "机号": acno, "发动机": eng, "机型": actype, "保障航班号": flightno,
  3317. "进港机场": "", "离港机场": "", "进出港航班号": flightno, "航班日期": flightdate1, "航班状态": "","航班类型": flighttype, "非航前计划到达": "", "航前预计起飞": "", "非航前实际到达": eta, "非航前预计到达": eta, "航前实际起飞": eta,
  3318. "非航前预计起飞": ETD2, "非航前预计进港机位": "","非航前进港机位": bay, "航前预计离港机位": "", "航前离港机位": "", "维修人员": "", "放行人员": "", "维修状态": "", "重要航班": "",
  3319. "随机": "", "保留": "", "备降返航": "", "维修状态时间": "", "二送人员": "", "二送状态": "","附加消息": "人工添加", "取消标志": ""}
  3320. else:
  3321. newdic = {"航班编号": "%s" % flightid, "航班编号对": "", "机号": acno, "发动机": eng, "机型": actype, "保障航班号": flightno,
  3322. "进港机场": "", "离港机场": "", "进出港航班号": flightno, "航班日期": flightdate1, "航班状态": "", "航班类型": flighttype,
  3323. "非航前计划到达": "", "航前预计起飞": "", "非航前实际到达": "", "非航前预计到达": eta, "航前实际起飞": eta,
  3324. "非航前预计起飞": "", "非航前预计进港机位": "", "非航前进港机位": bay, "航前预计离港机位": "", "航前离港机位": "", "维修人员": "", "放行人员": "",
  3325. "维修状态": "", "重要航班": "",
  3326. "随机": "", "保留": "", "备降返航": "", "维修状态时间": "", "二送人员": "", "二送状态": "", "附加消息": "人工添加", "取消标志": ""}
  3327. fdb.insertData("flightinfo%s"%flightdate2,newdic)
  3328. else:
  3329. if flighttype =="航前":
  3330. newdic={"航班编号":"'%s'"%flightid,"机号":"'%s'"%acno, "非航前预计起飞":"'%s'"%ETD2,"发动机":"'%s'"%eng, "机型":"'%s'"%actype, "保障航班号":"'%s'"%flightno,"进出港航班号":"'%s'"%flightno, "航班日期":"'%s'"%flightdate1,"航班类型":"'%s'"%flighttype, "航前预计起飞":"'%s'"%etd, "航前离港机位":"'%s'"%bay}
  3331. elif flighttype =="短停" or flighttype =="特后前":
  3332. newdic = {"航班编号": "'%s'" % flightid, "机号":"'%s'"% acno, "发动机":"'%s'"% eng, "机型":"'%s'"% actype, "保障航班号":"'%s'"% flightno, "进出港航班号":"'%s'"% flightno, "航班日期":"'%s'"% flightdate1, "航班类型":"'%s'"% flighttype,"非航前预计到达":"'%s'"% eta,"非航前实际到达": "'%s'"% eta, "航前实际起飞": "'%s'"% eta, "非航前预计起飞":"'%s'"% ETD2, "非航前进港机位":"'%s'"% bay}
  3333. else:
  3334. newdic = {"航班编号": "'%s'" % flightid,"机号":"'%s'"% acno, "发动机":"'%s'"% eng, "机型":"'%s'"% actype, "保障航班号":"'%s'"% flightno,"进出港航班号":"'%s'"% flightno, "航班日期":"'%s'"% flightdate1, "航班类型":"'%s'"% flighttype, "非航前预计到达":"'%s'"% eta,"航前实际起飞": "'%s'"% eta, "非航前进港机位":"'%s'"% bay}
  3335. fdb.upDateItem("flightinfo%s"%flightdate2,newdic,"航班编号='%s'"%flightid)
  3336. sortFlighttime(flightDB(host=host,
  3337. port=port,
  3338. user=user,
  3339. password=password,
  3340. database=databaseflightDB4
  3341. ))
  3342. sortFlighttime2(flightDB(host=host,
  3343. port=port,
  3344. user=user,
  3345. password=password,
  3346. database=databaseflightDB4
  3347. ))
  3348. res={"返回值":"ok"}
  3349. return res
  3350. def deleteFlight(fdb:flightDB,flightid,time):
  3351. fdb.deleteTable("flightinfo%s"%time,"航班编号='%s'"%flightid)
  3352. res={"返回值":"ok"}
  3353. sortFlighttime(flightDB(host=host,
  3354. port=port,
  3355. user=user,
  3356. password=password,
  3357. database=databaseflightDB4
  3358. ))
  3359. sortFlighttime2(flightDB(host=host,
  3360. port=port,
  3361. user=user,
  3362. password=password,
  3363. database=databaseflightDB4
  3364. ))
  3365. return res
  3366. def updateStopFlight(database:flightDB, fileName):
  3367. fdb = database
  3368. textInfo={"机号":2,"非航前进港机位":3,"机型":4,"发动机":5}
  3369. try:
  3370. workbook = openpyxl.load_workbook(filename=fileName)
  3371. mysheet = workbook.active
  3372. myrows = list(mysheet.values)[2:]
  3373. #print(myrows)
  3374. #print(myrows[1])
  3375. if myrows[0][1] != "" and myrows[0][2] != "" and myrows[0][1] != None and myrows[0][2] != None:
  3376. #print(myrows[0])
  3377. day=str(myrows[0][1]).split("/")[0]+str(myrows[0][1]).split("/")[1]+str(myrows[0][1]).split("/")[2]
  3378. day1 = str(myrows[0][1]).split("/")[0] +"-"+ str(myrows[0][1]).split("/")[1] +"-"+ str(myrows[0][1]).split("/")[2]
  3379. daytime = day1 + " 00:00:00"
  3380. starttime = day1 + " 09:00:00"
  3381. a = datetime.datetime.strptime(daytime, "%Y-%m-%d %H:%M:%S")
  3382. b = datetime.datetime.strptime(starttime, "%Y-%m-%d %H:%M:%S")
  3383. flightids=fdb.queryTabel("flightinfo%s"%day,"航班编号","航班类型 ='停场'")
  3384. if len(flightids) != 0:
  3385. for i in flightids:
  3386. fdb.deleteSingledata("flightinfo%s"%day,"航班编号='%s'"%i[0])
  3387. for myrow in myrows:
  3388. mydics0 = {}
  3389. if myrow[2] != None and myrow[1] != None and myrow[2] != "" and myrow[1] != "":
  3390. now = str(time.time() * 1000000).split(".")[0]
  3391. #print(now)
  3392. flightid = "MAN" + str(now)+str(myrow[2])
  3393. #print(flightid)
  3394. for i in flightinfoLabel:
  3395. if i in textInfo.keys():
  3396. text=myrow[textInfo[i]] if myrow[textInfo[i]] !=None else ""
  3397. mydics0[i] = "%s"%text
  3398. elif i =="航班编号":
  3399. mydics0[i]="%s"%flightid
  3400. elif i =="航班日期":
  3401. mydics0[i]="%s"%a
  3402. elif i =="非航前实际到达":
  3403. mydics0[i]="%s"%b
  3404. elif i =="附加消息":
  3405. mydics0[i]="人工添加"
  3406. elif i =="航班类型":
  3407. mydics0[i]="停场"
  3408. else:
  3409. mydics0[i]=''
  3410. #print(mydics0)
  3411. fdb.lazyInsertData("flightinfo%s"%day,mydics0)
  3412. fdb.FunctionCommit()
  3413. sortFlighttime(flightDB(host=host,
  3414. port=port,
  3415. user=user,
  3416. password=password,
  3417. database=databaseflightDB4
  3418. ))
  3419. sortFlighttime2(flightDB(host=host,
  3420. port=port,
  3421. user=user,
  3422. password=password,
  3423. database=databaseflightDB4
  3424. ))
  3425. print(datetime.datetime.now(), '[数据库操作]停场航班导入成功!')
  3426. res = {"返回值": "ok"}
  3427. return res
  3428. except Exception:
  3429. print(datetime.datetime.now(),'[数据库操作]停场航班导入失败!!检查模板文件!')
  3430. print(traceback.format_exc())
  3431. # 需要QT输出警告弹框信息
  3432. res = {"返回值": "fail"}
  3433. fdb.FunctionCommit()
  3434. return res
  3435. #新增内容
  3436. def updateRiskdb(database:flightDB, fileName): #创建准备组提示数据库
  3437. fdb = database
  3438. fdb.deleteTable("RiskTable")
  3439. try:
  3440. workbook = openpyxl.load_workbook(filename=fileName)
  3441. mysheet = workbook.active
  3442. myrows = list(mysheet.values)[1:]
  3443. mytitle = list(mysheet.values)[0]
  3444. for myrow in myrows:
  3445. mydics0 = {}
  3446. for i in range(0, (len(mytitle))):
  3447. mydics0[mytitle[i]] = "%s"%myrow[i]
  3448. #print(mydics0)
  3449. fdb.lazyInsertData('RiskTable',mydics0)
  3450. fdb.FunctionCommit()
  3451. return 1
  3452. except Exception:
  3453. dingding_alert(traceback.format_exc())
  3454. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查模板文件!风险提示功能失效!!')
  3455. fdb.FunctionCommit()
  3456. return 0
  3457. def saveRisktable(database:flightDB):
  3458. fdb = database
  3459. res=fdb.getAlldata("RiskTable")
  3460. if res == None:
  3461. res =[]
  3462. return res
  3463. def getRiskData(fdb:flightDB,bay,time):
  3464. res = fdb.queryTabel("RiskTable","提示内容","状态='生效' and 触发条件1 ='%s' and 触发条件2 ='%s' "%(bay,time))
  3465. tips= res[0][0] if res !=None and res !=[] and len(res) !=0 else ""
  3466. return tips
  3467. def updateTaskAuto(database:flightDB, fileName): #创建准备组提示数据库
  3468. fdb = database
  3469. fdb.deleteTable("taskAuto")
  3470. try:
  3471. workbook = openpyxl.load_workbook(filename=fileName)
  3472. mysheet = workbook.active
  3473. myrows = list(mysheet.values)[1:]
  3474. mytitle = list(mysheet.values)[0]
  3475. for myrow in myrows:
  3476. mydics0 = {}
  3477. for i in range(0, (len(mytitle))):
  3478. mydics0[mytitle[i]] = "%s"%myrow[i]
  3479. #print(mydics0)
  3480. fdb.lazyInsertData('taskAuto',mydics0)
  3481. fdb.FunctionCommit()
  3482. return 1
  3483. except Exception:
  3484. dingding_alert(traceback.format_exc())
  3485. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查模板文件!准备组任务提示功能失效!!')
  3486. fdb.FunctionCommit()
  3487. return 0
  3488. def initFlightDatabase(database:flightDB, datatime:str):
  3489. try:
  3490. fdb = database
  3491. zhDic = {}
  3492. sortDic={}
  3493. logsDic = {}
  3494. workerinfoDic = {}
  3495. authorityDic = {}
  3496. flightstsDic = {}
  3497. TaskFlightinfoDic={}
  3498. pglistDic={}
  3499. peopleScheduleDic={}
  3500. taskDic={}
  3501. CalllistDic={}
  3502. workjobDic = {}
  3503. displayDic={}
  3504. riskDic={}
  3505. primaryKey = 'SERIAL PRIMARY KEY'
  3506. primaryKey2 = 'INTEGER PRIMARY KEY NOT NULL'
  3507. primaryKey3 ='TEXT PRIMARY KEY NOT NULL'
  3508. for key1 in list(flightinfoLabel)[1:]:
  3509. zhDic[key1] = 'text not null'
  3510. for sortkey in list(sortLabel)[1:]:
  3511. sortDic[sortkey]= 'text not null'
  3512. for logskey in list(logsLabel)[1:]:
  3513. logsDic[logskey]= 'text not null'
  3514. for workerinfokey in list(workerinfoLabel)[1:]:
  3515. workerinfoDic[workerinfokey]= 'text not null'
  3516. for authoritykey in list(authorityLabel)[1:]:
  3517. authorityDic[authoritykey]= 'text not null'
  3518. for flightstskey in list(flightstsLabel)[1:]:
  3519. flightstsDic[flightstskey]= 'text not null'
  3520. for flightstskey in list(TaskflightinfoLabel)[1:]:
  3521. TaskFlightinfoDic[flightstskey]= 'text not null'
  3522. for pglistkey in list(pglistLabel)[1:]:
  3523. pglistDic[pglistkey] = 'text not null'
  3524. for peopleScheduleKey in list(peopleScheduleLabel)[1:]:
  3525. peopleScheduleDic[peopleScheduleKey] = 'text not null'
  3526. for CalllistKey in list(CalllistLabel)[1:]:
  3527. if CalllistKey == '拨号次数':
  3528. CalllistDic[CalllistKey] = 'int'
  3529. else:
  3530. CalllistDic[CalllistKey] = 'text not null'
  3531. for taskkey in list(taskLabel)[1:]:
  3532. taskDic[taskkey]= 'text not null'
  3533. for workjobkey in list(workjobkeyLabel)[1:]:
  3534. workjobDic[workjobkey]= 'text not null'
  3535. for displaykey in list(displayLabel)[1:]:
  3536. displayDic[displaykey]= 'text not null'
  3537. for riskkey in list(RiskLabel)[1:]:
  3538. riskDic[riskkey]= 'text not null'
  3539. nowDayStr = datatime
  3540. fdb.initTable('pglist{}'.format(nowDayStr),"姓名", primaryKey3,pglistDic)
  3541. fdb.initTable('flightinfo{}'.format(nowDayStr),"航班编号",primaryKey3, zhDic)
  3542. fdb.initTable('sortFlight2{}'.format(nowDayStr), "编号", primaryKey3, sortDic)
  3543. fdb.initTable('sortFlight{}'.format(nowDayStr), "编号",primaryKey3, sortDic)
  3544. fdb.initTable('logs', "编号",primaryKey, logsDic)
  3545. fdb.initTable('taskAuto', "编号", primaryKey3, taskDic)
  3546. fdb.initTable('workerinfo',"工号", primaryKey3, workerinfoDic)
  3547. fdb.initTable('authority',"编号", primaryKey, authorityDic)
  3548. fdb.initTable('flightsts{}'.format(nowDayStr),"航班编号", primaryKey3, flightstsDic)
  3549. fdb.initTable('TaskFlightinfo{}'.format(nowDayStr), "航班编号", primaryKey3, TaskFlightinfoDic)
  3550. fdb.initTable('peopleSchedule{}'.format(nowDayStr), "编号", primaryKey3, peopleScheduleDic)
  3551. fdb.initTable('Calllist', "航班编号", primaryKey3, CalllistDic)
  3552. fdb.initTable('workjob', "任务编号", primaryKey3, workjobDic)
  3553. fdb.initTable('display', "ID", primaryKey3, displayDic)
  3554. fdb.initTable('RiskTable', "风险编号", primaryKey3, riskDic)
  3555. if len(fdb.getSingledata("A",'display')) == 0:
  3556. fdb.insertData('display', {'ID': 1, 'A': '{}','B': '{}'})
  3557. fdb.insertData('display', {'ID': 2, 'A': '{}','B': '{}'})
  3558. fdb.insertData('display', {'ID': 3, 'A': '{}','B': '{}'})
  3559. except Exception:
  3560. print(traceback.format_exc())
  3561. dingding_alert(traceback.format_exc())
  3562. def insertCalllist(fdb,data):
  3563. try:
  3564. #CalllistLabel1 = ["航班编号", "电话", "工号", "姓名", "航班号", "附加消息", "拨号次数", "创建时间", "接通时间"]
  3565. now = datetime.datetime.now()
  3566. data["创建时间"]=now
  3567. data["接通时间"] = ''
  3568. fdb.insertData('Calllist',data)
  3569. #print("test")
  3570. res={"返回值":"ok"}
  3571. return res
  3572. except Exception:
  3573. print(traceback.format_exc())
  3574. dingding_alert(traceback.format_exc())
  3575. def checkTFUairplane(database:flightDB):
  3576. try:
  3577. code = {"接机已到位提示","已放行提示","二送已到位提示"}
  3578. code2 = {"接机已到位提示", "已放行提示"}
  3579. #需要建立昨日初始化
  3580. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3581. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3582. now = datetime.datetime.now()
  3583. now11=str(now).split(".")[0]
  3584. day = [nowDay, nowDay_1]
  3585. for nowDayStr in day:
  3586. AFinsky_arr = []
  3587. AFongroud_arr = []
  3588. TRinsky_arr = []
  3589. TRongroud_arr = []
  3590. THQinsky_arr = []
  3591. THQongroud_arr = []
  3592. APongroud_arr = []
  3593. flightsts_flight_ids_arr=[]
  3594. AFinsky=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='航后' and 非航前预计到达!='' and 非航前实际到达=''and 航前实际起飞!=''")
  3595. AFongroud=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='航后' and 非航前实际到达!=''")
  3596. TRinsky=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='短停' and 非航前预计到达!='' and 非航前实际到达='' and 航前实际起飞!=''")
  3597. TRongroud = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='短停' and 非航前实际到达!='' and (非航前预计起飞 like '%预%' or 非航前预计起飞 like '%计%')")
  3598. THQinsky = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号',"航班类型='特后前' and 非航前预计到达!='' and 非航前实际到达=''and 航前实际起飞!=''")
  3599. THQongroud=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='特后前' and 非航前实际到达!='' and (非航前预计起飞 like '%预%' or 非航前预计起飞 like '%计%')")
  3600. APongroud=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='航前' and 航前实际起飞 =''")
  3601. ##################################
  3602. #缺个未显示的航班筛选
  3603. if len(AFinsky) != 0:
  3604. for i in AFinsky:
  3605. AFinsky_arr.append(i[0])
  3606. if len(AFongroud) != 0:
  3607. for i in AFongroud:
  3608. AFongroud_arr.append(i[0])
  3609. if len(TRinsky) != 0:
  3610. for i in TRinsky:
  3611. TRinsky_arr.append(i[0])
  3612. if len(TRongroud) != 0:
  3613. for i in TRongroud:
  3614. TRongroud_arr.append(i[0])
  3615. if len(THQinsky) != 0:
  3616. for i in THQinsky:
  3617. THQinsky_arr.append(i[0])
  3618. if len(THQongroud) != 0:
  3619. for i in THQongroud:
  3620. THQongroud_arr.append(i[0])
  3621. if len(APongroud) != 0:
  3622. for i in APongroud:
  3623. APongroud_arr.append(i[0])
  3624. flightsts_flight_ids=database.getSingledata('航班编号','flightsts{}'.format(nowDayStr))
  3625. flightinfo_flight_ids=database.getSingledata('航班编号','flightinfo{}'.format(nowDayStr))
  3626. if len(flightsts_flight_ids) != 0:
  3627. for flightstskey in flightsts_flight_ids:
  3628. newdic={"天府飞机":"''"}
  3629. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%flightstskey[0])
  3630. if flightstskey in flightinfo_flight_ids:
  3631. flightsts_flight_ids_arr.append(flightstskey[0])
  3632. else:
  3633. database.deleteSingledata('flightsts{}'.format(nowDayStr),"航班编号='%s'"%flightstskey[0])
  3634. for AFinsky_arr_key in AFinsky_arr:
  3635. if AFinsky_arr_key in flightsts_flight_ids_arr:
  3636. newdic = {"天府飞机":"'空中航后'"}
  3637. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%AFinsky_arr_key)
  3638. else:
  3639. newdic={"航班编号":"%s"%AFinsky_arr_key,"接机到位":"","放行":"","销子夹板":"","随机到位":"","二送到位":"","接机已到位提示":"","已放行提示":"","销子夹板已提示":"","随机已到位提示":"","二送已到位提示":"","天府飞机":'空中航后',"机号":"","机位":""}
  3640. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3641. for AFongroud_arr_key in AFongroud_arr:
  3642. if AFongroud_arr_key in flightsts_flight_ids_arr:
  3643. newdic = {"天府飞机": "'地面航后'"}
  3644. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%AFongroud_arr_key)
  3645. else:
  3646. newdic = {"航班编号": "%s" % AFongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3647. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面航后',"机号":"","机位":""}
  3648. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3649. for TRinsky_arr_key in TRinsky_arr:
  3650. if TRinsky_arr_key in flightsts_flight_ids_arr:
  3651. newdic = {"天府飞机": "'空中短停'"}
  3652. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%TRinsky_arr_key)
  3653. else:
  3654. newdic = {"航班编号": "%s" % TRinsky_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3655. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '空中短停',"机号":"","机位":""}
  3656. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3657. for TRongroud_arr_key in TRongroud_arr:
  3658. if TRongroud_arr_key in flightsts_flight_ids_arr:
  3659. newdic = {"天府飞机": "'地面短停'"}
  3660. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%TRongroud_arr_key)
  3661. else:
  3662. newdic = {"航班编号": "%s" % TRongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3663. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面短停',"机号":"","机位":""}
  3664. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3665. for THQinsky_arr_key in THQinsky_arr:
  3666. if THQinsky_arr_key in flightsts_flight_ids_arr:
  3667. newdic = {"天府飞机": "'空中特后前'"}
  3668. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%THQinsky_arr_key)
  3669. else:
  3670. newdic = {"航班编号": "%s" % THQinsky_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3671. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '空中特后前',"机号":"","机位":""}
  3672. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3673. for THQongroud_arr_key in THQongroud_arr:
  3674. if THQongroud_arr_key in flightsts_flight_ids_arr:
  3675. newdic = {"天府飞机": "'地面特后前'"}
  3676. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%THQongroud_arr_key)
  3677. else:
  3678. newdic = {"航班编号": "%s" % THQongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3679. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面特后前',"机号":"","机位":""}
  3680. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3681. for APongroud_arr_key in APongroud_arr:
  3682. #print(APongroud_arr_key)
  3683. if APongroud_arr_key in flightsts_flight_ids_arr:
  3684. newdic = {"天府飞机":"'地面航前'"}
  3685. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%APongroud_arr_key)
  3686. else:
  3687. newdic = {"航班编号": "%s" % APongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3688. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面航前',"机号":"","机位":""}
  3689. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3690. for flightstskey in flightinfo_flight_ids:
  3691. acno_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "机号", "航班编号='{}'".format(flightstskey[0]))
  3692. if "航前" not in database.queryTabel('flightinfo{}'.format(nowDayStr), "航班类型", "航班编号='{}'".format(flightstskey[0])):
  3693. bay_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "航前离港机位", "航班编号='{}'".format(flightstskey[0]))
  3694. else:
  3695. bay_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "非航前进港机位", "航班编号='{}'".format(flightstskey[0]))
  3696. newdic = {"机位":"'%s'"%bay_str[0], "机号":"'%s'"%acno_str[0]}
  3697. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3698. worksts_str=database.queryTabel('flightinfo{}'.format(nowDayStr), "维修状态", "航班编号='{}'".format(flightstskey[0]))
  3699. worksts_STR = worksts_str[0][0] if len(worksts_str) != 0 else 0
  3700. worksts = int(worksts_STR) if worksts_STR != "" else 0
  3701. a=database.queryTabel('flightsts{}'.format(nowDayStr),"机号","航班编号='%s'" % flightstskey[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr),"机号","航班编号='%s'" % flightstskey[0])) != 0 else "未显示机号"
  3702. if worksts >= 7 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
  3703. newdic={"接机到位":"'已到位'", "放行": "'已放行'"}
  3704. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3705. for i in code2:
  3706. if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"%s"%i,"航班编号='%s'" % flightstskey[0]):
  3707. newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s%s!%s"%(a,i,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3708. database.lazyInsertData('logs', newdic)
  3709. newdic = {"%s"%i: 1}
  3710. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3711. elif worksts >= 4 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
  3712. newdic = {"接机到位": "'已到位'"}
  3713. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3714. if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"接机已到位提示","航班编号='%s'" % flightstskey[0]):
  3715. newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s接机已到位提示!%s"%(a,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3716. database.lazyInsertData('logs', newdic)
  3717. newdic = {"接机已到位提示": 1}
  3718. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'"% flightstskey[0])
  3719. ECSJ_worksts_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "二送状态", "航班编号='{}'".format(flightstskey[0]))
  3720. ECSJ_worksts_STR = ECSJ_worksts_str[0][0] if len(ECSJ_worksts_str) != 0 else 0
  3721. ECSJ_worksts = int(ECSJ_worksts_STR) if ECSJ_worksts_STR != "" else 0
  3722. a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flightstskey[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flightstskey[0])) != 0 else "未显示机号"
  3723. if ECSJ_worksts >= 15 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
  3724. newdic = {"接机到位": "'已到位'", "放行": "'已放行'", "二送到位": "'已到位'"}
  3725. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3726. for i in code:
  3727. if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"%s"%i,"航班编号='%s'" % flightstskey[0]):
  3728. newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s%s!%s"%(a,i,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3729. database.lazyInsertData('logs', newdic)
  3730. newdic = {"%s"%i: 1}
  3731. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3732. database.FunctionCommit()
  3733. except Exception:
  3734. dingding_alert(traceback.format_exc())
  3735. database.FunctionCommit()
  3736. def dingdingDelete_flight(database:flightDB):
  3737. try:
  3738. dmac={}
  3739. # 需要建立昨日初始化
  3740. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3741. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3742. day = [nowDay_1,nowDay]
  3743. for nowDayStr in day:
  3744. tfac_ids=database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","CAST(级别 AS integer)=1")
  3745. if len(tfac_ids) != 0:
  3746. for i in tfac_ids:
  3747. acno=database.queryTabel('flightinfo{}'.format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
  3748. type=database.queryTabel('flightinfo{}'.format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
  3749. if acno in dmac.keys() and type !="航前":
  3750. dmac[acno]=i[0]
  3751. elif acno not in dmac.keys():
  3752. dmac[acno] = i[0]
  3753. try:
  3754. res = requests.post(url="http://124.223.185.200:888/delete_flight/", data=json.dumps(dmac),timeout=5) # 自己服务器
  3755. #flightsts = res.json()
  3756. #print(flightsts)
  3757. except Exception:
  3758. dingding_alert(traceback.format_exc())
  3759. pass
  3760. #QT输出弹窗警告,服务器链接失效
  3761. except Exception:
  3762. dingding_alert(traceback.format_exc())
  3763. def dingdinginfoget(database:flightDB):
  3764. try:
  3765. infos={}
  3766. try:
  3767. resfwq = requests.get(url="http://124.223.185.200:4567/get_deal_info/", timeout=10) # 自己服务器
  3768. if resfwq.json() != "":
  3769. infos = resfwq.json()
  3770. except Exception:
  3771. dingding_alert(traceback.format_exc())
  3772. pass
  3773. #print("infos",infos)
  3774. if infos !={}:
  3775. now = datetime.datetime.now()
  3776. for i in infos.keys():
  3777. info=str(infos[i]["info"].split("信息上报")[0])+str(now.strftime("%Y-%m-%d %H:%M:%S"))+"上报信息,鼠标停留查看详情"
  3778. newdic = {"航班编号": "%s" % i, "警告信息": "%s"%info, "信息状态": "", "提示信息": "",
  3779. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "", "显示对象": "", "提示内容": "%s"%infos[i]["info"]}
  3780. database.lazyInsertData('logs', newdic)
  3781. database.FunctionCommit()
  3782. except Exception:
  3783. dingding_alert(traceback.format_exc())
  3784. database.FunctionCommit()
  3785. def dingdingFlightsts(database:flightDB):
  3786. try:
  3787. flightsts = {}
  3788. sever_code={"JJDW":"接机到位","FX":"放行","SJDW":"随机到位","XJ":"销子夹板","ESDW":"二送到位"}
  3789. sever_code1 = {"JJDW": "已到位", "FX": "已放行", "SJDW": "已到位", "XJ": "已取下", "ESDW": "已到位"}
  3790. code2 = {"JJDW": "接机已到位", "FX": "已放行", "SJDW": "随机已到位", "XJ": "销子夹板已取下", "ESDW": "二送已到位"}
  3791. code3 = {"JJDW": "接机已到位提示", "FX": "已放行提示", "SJDW": "随机已到位提示", "XJ": "销子夹板已提示", "ESDW": "二送已到位提示"}
  3792. try:
  3793. resfwq = requests.get(url="http://124.223.185.200:888/search_status/", timeout=10) # 自己服务器
  3794. if resfwq.json() != "":
  3795. flightsts = resfwq.json()
  3796. #print(flightsts)
  3797. #测试数据
  3798. #flightsts={'30CA':{"JJDW": 1, "FX": 1, "SJDW": 1, "XJ": 1, "ESDW": 1},'300D':{"JJDW": 1, "FX": 1, "SJDW": 1, "XJ": 1, "ESDW": 0}}
  3799. except Exception:
  3800. dingding_alert(traceback.format_exc())
  3801. pass
  3802. # QT输出弹窗警告,服务器链接失效
  3803. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3804. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3805. now = datetime.datetime.now()
  3806. now11=str(now).split(".")[0]
  3807. day = [nowDay_1, nowDay]
  3808. tfac_acs=[]
  3809. for nowDayStr in day:
  3810. dmacs = database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","CAST(级别 AS integer)=1")
  3811. for i in dmacs:
  3812. dmac=database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'"%i[0])
  3813. if str(dmac[0]) not in str(tfac_acs):
  3814. tfac_acs.append(dmac[0])
  3815. if len(tfac_acs) != 0:
  3816. for i in tfac_acs:
  3817. #print(i[0])
  3818. if i[0] in flightsts.keys():
  3819. for j,k in sever_code.items():
  3820. if flightsts[i[0]][j] == 1:
  3821. newdic={"%s"%k:"'%s'"%sever_code1[j]}
  3822. #print(newdic)
  3823. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"机号='%s' and 天府飞机!=''"%i[0])
  3824. newdic={}
  3825. a=database.queryTabel('flightsts{}'.format(nowDayStr), '%s' % code3[j], "机号='%s' and 天府飞机!=''" % i[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr),'%s'%code3[j],"机号='%s' and 天府飞机!=''"%i[0])) != 0 else "0"
  3826. b=database.queryTabel('flightsts{}'.format(nowDayStr), '航班编号', "机号='%s' and 天府飞机!=''" % i[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), '航班编号', "机号='%s' and 天府飞机!=''" % i[0])) != 0 else "未显示机号"
  3827. if a !="1":
  3828. newdic={"%s"%code3[j]:1}
  3829. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "机号='%s' and 天府飞机!=''" % i[0])
  3830. newdic={"航班编号":"%s"%b,"警告信息":"","信息状态":"","提示信息":"钉钉:%s%s!%s"%(i[0],code2[j],now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3831. database.lazyInsertData('logs',newdic)
  3832. database.FunctionCommit()
  3833. #########################################
  3834. #引入钉钉显示
  3835. ########################################
  3836. except Exception:
  3837. dingding_alert(traceback.format_exc())
  3838. database.FunctionCommit()
  3839. def waringMessageID(database:flightDB):
  3840. try:
  3841. waringMessageID1_arr=[]
  3842. waringMessageID2_arr = []
  3843. waringMessageID3_arr = []
  3844. waringMessageID4_arr = []
  3845. waringMessageID5_arr = []
  3846. waringMessageID6_arr = []
  3847. waringMessageID0_arr = []
  3848. waringMessageID_arrs={}
  3849. waringMessageIDs=database.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
  3850. if len(waringMessageIDs) != 0:
  3851. for i in waringMessageIDs:
  3852. waringMessageID0_arr.append(i[1])
  3853. if i[8] == "到位警告":
  3854. waringMessageID1_arr.append(i[1])
  3855. elif i[8] == "二送警告":
  3856. waringMessageID2_arr.append(i[1])
  3857. elif i[8] == "非航前预计到达":
  3858. waringMessageID3_arr.append(i[1])
  3859. elif i[8] == "非航前进港机位":
  3860. waringMessageID4_arr.append(i[1])
  3861. elif i[8] == "非航前预计起飞":
  3862. waringMessageID5_arr.append(i[1])
  3863. else:
  3864. waringMessageID6_arr.append(i[1])
  3865. waringMessageID_arrs["到位警告"]=waringMessageID1_arr
  3866. waringMessageID_arrs["二送警告"] = waringMessageID2_arr
  3867. waringMessageID_arrs["ETA"] = waringMessageID3_arr
  3868. waringMessageID_arrs["BAY_2"] = waringMessageID4_arr
  3869. waringMessageID_arrs["TD"] = waringMessageID5_arr
  3870. waringMessageID_arrs["通用警告"] = waringMessageID6_arr
  3871. waringMessageID_arrs["全部警告"] = waringMessageID0_arr
  3872. return waringMessageID_arrs
  3873. except Exception:
  3874. dingding_alert(traceback.format_exc())
  3875. def sortFlighttime2(database:flightDB):
  3876. try:
  3877. sortLabel = ["编号", "航班编号", "保障时间", "航班类型", "航班日期", "级别"]
  3878. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3879. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3880. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  3881. now = datetime.datetime.now()
  3882. now_20 = (datetime.datetime.now() + datetime.timedelta(minutes=200)).strftime("%Y%m%d")
  3883. initFlightDatabase(database, now_20)
  3884. initFlightDatabase(database, nowDay_1)
  3885. initFlightDatabase(database, nowDay_2)
  3886. initFlightDatabase(database, nowDay)
  3887. if now_20 == nowDay:
  3888. day = [nowDay, nowDay_1]
  3889. else:
  3890. day = [nowDay, nowDay_1, nowDay_2]
  3891. for selectedtime in day:
  3892. sort2NOs_arr=[]
  3893. sort2NOs = database.getSingledata("编号","sortFlight2{}".format(selectedtime))
  3894. sortNOs = database.getSingledata("编号", "sortFlight{}".format(selectedtime))
  3895. if sort2NOs !=None and len(sort2NOs)!=0:
  3896. for i in sort2NOs:
  3897. if str(i) in str(sortNOs):
  3898. sort2NOs_arr.append(i[0])
  3899. else:
  3900. database.deleteSingledata("sortFlight2{}".format(selectedtime),"编号 = '%s'"%i[0])
  3901. sorttable = getSortFlightdata(database, selectedtime,"sortFlight")
  3902. for row in sorttable:
  3903. if row[3] == "短停接" or row[3] == "特后前接":
  3904. if str(row[5]) == "4":
  3905. find_id = row[1] + "-2"
  3906. for row2 in sorttable:
  3907. if row2[0] == find_id and row2[5] == "4":
  3908. jb = row[5]
  3909. elif row2[0] == find_id:
  3910. jb = "1"
  3911. else:
  3912. jb = row[5]
  3913. newdic = {}
  3914. newdic2={}
  3915. for col in range(0,6):
  3916. if col == 0:
  3917. newdic[sortLabel[col]]=row[col]
  3918. elif col != 5:
  3919. newdic[sortLabel[col]]=row[col]
  3920. newdic2[sortLabel[col]]="'%s'"%row[col]
  3921. else:
  3922. newdic[sortLabel[5]]=jb
  3923. newdic2[sortLabel[5]] = "'%s'"%jb
  3924. if str(row[0]) not in str(sort2NOs_arr):
  3925. database.lazyInsertData('sortFlight2{}'.format(selectedtime),newdic)
  3926. else:
  3927. database.lazyUpdateItem('sortFlight2{}'.format(selectedtime),newdic2,"编号 = '%s'"%row[0])
  3928. elif row[3] != "短停送" and row[3] != "特后前送":
  3929. newdic = {}
  3930. newdic2 = {}
  3931. for col in range(0,6):
  3932. if col == 0:
  3933. newdic[sortLabel[col]]=row[col]
  3934. else:
  3935. newdic[sortLabel[col]]=row[col]
  3936. newdic2[sortLabel[col]] = "'%s'"%row[col]
  3937. if str(row[0]) not in str(sort2NOs_arr):
  3938. database.lazyInsertData('sortFlight2{}'.format(selectedtime), newdic)
  3939. else:
  3940. database.lazyUpdateItem('sortFlight2{}'.format(selectedtime), newdic2, "编号 = '%s'" % row[0])
  3941. database.FunctionCommit()
  3942. except Exception:
  3943. dingding_alert(traceback.format_exc())
  3944. def sortFlighttime(database:flightDB):
  3945. try:
  3946. print(datetime.datetime.now(),'[数据库操作]开始排序')
  3947. #yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  3948. #today_search=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  3949. #tomorrow_search=(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  3950. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3951. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3952. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  3953. now = datetime.datetime.now()
  3954. now_20 = (datetime.datetime.now() + datetime.timedelta(minutes=200)).strftime("%Y%m%d")
  3955. initFlightDatabase(database, now_20)
  3956. initFlightDatabase(database, nowDay_1)
  3957. initFlightDatabase(database, nowDay_2)
  3958. initFlightDatabase(database, nowDay)
  3959. if now_20 == nowDay:
  3960. day = [nowDay, nowDay_1]
  3961. else:
  3962. day = [nowDay, nowDay_1, nowDay_2]
  3963. for nowDayStr in day:
  3964. #nowDayStr = datatime
  3965. sort_flight_ids_arr=[]
  3966. sort_flight_ids = database.getSingledata('编号','sortFlight{}'.format(nowDayStr))
  3967. flightinfo_flight_ids = database.getSingledata('航班编号', 'flightinfo{}'.format(nowDayStr))
  3968. if len(sort_flight_ids) != 0:
  3969. for sortkey in sort_flight_ids:
  3970. sort_flight_id=database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","编号='%s'"%sortkey[0])[0]
  3971. if str(sort_flight_id) in str(flightinfo_flight_ids):
  3972. sort_flight_ids_arr.append(sortkey[0])
  3973. else:
  3974. database.deleteSingledata('sortFlight{}'.format(nowDayStr),"编号='%s'"%sortkey[0])
  3975. for i in flightinfo_flight_ids:
  3976. #print(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0]))
  3977. flight_date_str=database.queryTabel("flightinfo{}".format(nowDayStr),"航班日期","航班编号='%s'"%i[0])[0][0]
  3978. if database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] == "航前" and "MAN" not in str(i[0]):
  3979. if database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]!= "":
  3980. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  3981. time_str = flight_date_str.split("-")[0] + "/" + time.split("]")[1]
  3982. sendtime = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
  3983. ii=str(i[0])+str(-2)
  3984. iii = str(i[0]) + str(-1)
  3985. if ii in str(sort_flight_ids_arr):
  3986. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3987. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3988. else:
  3989. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0],"保障时间": "%s" % sendtime, "航班类型": "航前",
  3990. "航班日期": "%s" % flight_date_str, "级别": 1}
  3991. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3992. #print('插入{}'.format(newdic))
  3993. if iii in str(sort_flight_ids_arr):
  3994. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3995. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] !="":
  3996. time=database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0]
  3997. sendtime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3998. ii=str(i[0])+str(-2)
  3999. iii = str(i[0]) + str(-1)
  4000. if ii in str(sort_flight_ids_arr):
  4001. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4002. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4003. else:
  4004. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % sendtime, "航班类型": "航前",
  4005. "航班日期": "%s" % flight_date_str, "级别": 4}
  4006. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4007. if iii in str(sort_flight_ids_arr):
  4008. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4009. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] == "航前" and "MAN" in str(i[0]):
  4010. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  4011. time_str = flight_date_str.split("-")[0] + "/" + time.split("]")[1]
  4012. sendtime = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
  4013. sendtime2 = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M")
  4014. if now < sendtime2:
  4015. ii=str(i[0])+str(-2)
  4016. iii = str(i[0]) + str(-1)
  4017. if ii in str(sort_flight_ids_arr):
  4018. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4019. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4020. else:
  4021. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0],"保障时间": "%s" % sendtime, "航班类型": "航前",
  4022. "航班日期": "%s" % flight_date_str, "级别": 1}
  4023. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4024. #print('插入{}'.format(newdic))
  4025. if iii in str(sort_flight_ids_arr):
  4026. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4027. else:
  4028. ii=str(i[0])+str(-2)
  4029. iii = str(i[0]) + str(-1)
  4030. if ii in str(sort_flight_ids_arr):
  4031. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime2,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4032. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4033. else:
  4034. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % sendtime2, "航班类型": "航前",
  4035. "航班日期": "%s" % flight_date_str, "级别": 4}
  4036. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4037. if iii in str(sort_flight_ids_arr):
  4038. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4039. elif database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "停场":
  4040. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0]
  4041. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4042. ii = str(i[0]) + str(-1)
  4043. iii = str(i[0]) + str(-2)
  4044. if ii in str(sort_flight_ids_arr):
  4045. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'停场'",
  4046. "航班日期": "'%s'" % flight_date_str, "级别": "3"}
  4047. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4048. else:
  4049. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "停场",
  4050. "航班日期": "%s" % flight_date_str, "级别": 3}
  4051. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4052. if iii in str(sort_flight_ids_arr):
  4053. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4054. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="航后" and "MAN" not in str(i[0]):
  4055. if database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  4056. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] !="" and \
  4057. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  4058. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  4059. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4060. ii=str(i[0])+str(-1)
  4061. iii = str(i[0]) + str(-2)
  4062. if ii in str(sort_flight_ids_arr):
  4063. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4064. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4065. else:
  4066. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  4067. "航班日期": "%s" % flight_date_str, "级别": 1}
  4068. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4069. if iii in str(sort_flight_ids_arr):
  4070. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4071. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  4072. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] =="" and \
  4073. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  4074. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  4075. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4076. ii=str(i[0])+str(-1)
  4077. iii = str(i[0]) + str(-2)
  4078. if ii in str(sort_flight_ids_arr):
  4079. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4080. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4081. else:
  4082. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  4083. "航班日期": "%s" % flight_date_str, "级别": 1}
  4084. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4085. if iii in str(sort_flight_ids_arr):
  4086. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4087. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  4088. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and \
  4089. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0] == "" and \
  4090. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]!="" :
  4091. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  4092. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4093. ii=str(i[0])+str(-1)
  4094. iii = str(i[0]) + str(-2)
  4095. if ii in str(sort_flight_ids_arr):
  4096. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  4097. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4098. else:
  4099. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  4100. "航班日期": "%s" % flight_date_str, "级别": 2}
  4101. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4102. if iii in str(sort_flight_ids_arr):
  4103. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4104. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] !="":
  4105. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]
  4106. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4107. ii=str(i[0])+str(-1)
  4108. iii = str(i[0]) + str(-2)
  4109. if ii in str(sort_flight_ids_arr):
  4110. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"3"}
  4111. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4112. else:
  4113. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  4114. "航班日期": "%s" % flight_date_str, "级别": 3}
  4115. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4116. if iii in str(sort_flight_ids_arr):
  4117. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4118. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  4119. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and \
  4120. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!="" :
  4121. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  4122. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4123. ii=str(i[0])+str(-1)
  4124. iii = str(i[0]) + str(-2)
  4125. if ii in str(sort_flight_ids_arr):
  4126. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  4127. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4128. else:
  4129. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  4130. "航班日期": "%s" % flight_date_str, "级别": 2}
  4131. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4132. if iii in str(sort_flight_ids_arr):
  4133. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4134. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="航后" and "MAN" in str(i[0]):
  4135. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  4136. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4137. receivetime2= datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4138. if now < receivetime2:
  4139. ii=str(i[0])+str(-1)
  4140. iii = str(i[0]) + str(-2)
  4141. if ii in str(sort_flight_ids_arr):
  4142. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4143. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4144. else:
  4145. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  4146. "航班日期": "%s" % flight_date_str, "级别": 1}
  4147. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4148. if iii in str(sort_flight_ids_arr):
  4149. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4150. else:
  4151. ii=str(i[0])+str(-1)
  4152. iii = str(i[0]) + str(-2)
  4153. if ii in str(sort_flight_ids_arr):
  4154. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"3"}
  4155. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4156. else:
  4157. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "航后",
  4158. "航班日期": "%s" % flight_date_str, "级别": 3}
  4159. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4160. if iii in str(sort_flight_ids_arr):
  4161. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  4162. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="短停" and "MAN" not in str(i[0]):
  4163. if database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  4164. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] != "" and \
  4165. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  4166. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  4167. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4168. ii=str(i[0])+str(-1)
  4169. if ii in str(sort_flight_ids_arr):
  4170. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4171. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4172. else:
  4173. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  4174. "航班日期": "%s" % flight_date_str, "级别": 1}
  4175. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4176. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  4177. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] == "" and \
  4178. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  4179. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  4180. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4181. ii=str(i[0])+str(-1)
  4182. if ii in str(sort_flight_ids_arr):
  4183. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4184. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4185. else:
  4186. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  4187. "航班日期": "%s" % flight_date_str, "级别": 1}
  4188. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4189. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  4190. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] =="" and \
  4191. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0] == "" and \
  4192. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0] !="":
  4193. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  4194. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4195. ii=str(i[0])+str(-1)
  4196. if ii in str(sort_flight_ids_arr):
  4197. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  4198. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4199. else:
  4200. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  4201. "航班日期": "%s" % flight_date_str, "级别": 2}
  4202. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4203. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  4204. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] =="" and\
  4205. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] !="":
  4206. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  4207. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4208. ii=str(i[0])+str(-1)
  4209. if ii in str(sort_flight_ids_arr):
  4210. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  4211. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4212. else:
  4213. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  4214. "航班日期": "%s" % flight_date_str, "级别": 2}
  4215. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4216. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] !="":
  4217. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]
  4218. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4219. ii=str(i[0])+str(-1)
  4220. if ii in str(sort_flight_ids_arr):
  4221. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4222. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4223. else:
  4224. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  4225. "航班日期": "%s" % flight_date_str, "级别": 4}
  4226. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4227. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="短停" and "MAN" in str(i[0]):
  4228. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  4229. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4230. receivetime2 = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4231. if now < receivetime2:
  4232. ii=str(i[0])+str(-1)
  4233. if ii in str(sort_flight_ids_arr):
  4234. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  4235. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4236. else:
  4237. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  4238. "航班日期": "%s" % flight_date_str, "级别": 1}
  4239. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4240. else:
  4241. ii=str(i[0])+str(-1)
  4242. if ii in str(sort_flight_ids_arr):
  4243. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4244. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4245. else:
  4246. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "短停接",
  4247. "航班日期": "%s" % flight_date_str, "级别": 4}
  4248. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4249. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="特后前" and "MAN" not in str(i[0]):
  4250. if database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] == "" and \
  4251. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  4252. 0] != "" and \
  4253. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  4254. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4255. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4256. ii = str(i[0]) + str(-1)
  4257. if ii in str(sort_flight_ids_arr):
  4258. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4259. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4260. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4261. else:
  4262. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4263. "航班日期": "%s" % flight_date_str, "级别": 1}
  4264. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4265. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
  4266. 0] == "" and \
  4267. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  4268. 0] == "" and \
  4269. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  4270. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][0]
  4271. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4272. ii = str(i[0]) + str(-1)
  4273. if ii in str(sort_flight_ids_arr):
  4274. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4275. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4276. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4277. else:
  4278. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4279. "航班日期": "%s" % flight_date_str, "级别": 1}
  4280. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4281. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
  4282. 0] == "" and \
  4283. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][
  4284. 0] == "" and \
  4285. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  4286. 0] == "" and \
  4287. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][
  4288. 0] != "":
  4289. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][0]
  4290. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4291. ii = str(i[0]) + str(-1)
  4292. if ii in str(sort_flight_ids_arr):
  4293. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4294. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4295. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4296. else:
  4297. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4298. "航班日期": "%s" % flight_date_str, "级别": 2}
  4299. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4300. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
  4301. 0] == "" and \
  4302. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][
  4303. 0] == "" and \
  4304. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  4305. 0] != "":
  4306. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4307. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4308. ii = str(i[0]) + str(-1)
  4309. if ii in str(sort_flight_ids_arr):
  4310. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4311. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4312. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4313. else:
  4314. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4315. "航班日期": "%s" % flight_date_str, "级别": 2}
  4316. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4317. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] != "":
  4318. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0]
  4319. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4320. ii = str(i[0]) + str(-1)
  4321. if ii in str(sort_flight_ids_arr):
  4322. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4323. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
  4324. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4325. else:
  4326. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4327. "航班日期": "%s" % flight_date_str, "级别": 4}
  4328. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4329. elif database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][
  4330. 0] == "特后前" and "MAN" in str(i[0]):
  4331. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4332. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4333. receivetime2 = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4334. if now < receivetime2:
  4335. ii = str(i[0]) + str(-1)
  4336. if ii in str(sort_flight_ids_arr):
  4337. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4338. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4339. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4340. else:
  4341. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4342. "航班日期": "%s" % flight_date_str, "级别": 1}
  4343. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4344. else:
  4345. ii = str(i[0]) + str(-1)
  4346. if ii in str(sort_flight_ids_arr):
  4347. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime2,
  4348. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
  4349. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4350. else:
  4351. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "特后前接",
  4352. "航班日期": "%s" % flight_date_str, "级别": 4}
  4353. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4354. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "短停" and "MAN" not in str(i[0]):
  4355. if "[实]" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])):
  4356. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
  4357. receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4358. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4359. ii=str(i[0])+str(-2)
  4360. if ii in str(sort_flight_ids_arr):
  4361. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4362. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4363. else:
  4364. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
  4365. "航班日期": "%s" % flight_date_str, "级别": 4}
  4366. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4367. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4368. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] !="" and \
  4369. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4370. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4371. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4372. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4373. ii = str(i[0]) + str(-2)
  4374. if ii in str(sort_flight_ids_arr):
  4375. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'短停送'",
  4376. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4377. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4378. else:
  4379. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
  4380. "航班日期": "%s" % flight_date_str, "级别": 1}
  4381. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4382. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4383. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] =="" and \
  4384. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4385. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4386. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4387. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4388. ii = str(i[0]) + str(-2)
  4389. if ii in str(sort_flight_ids_arr):
  4390. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'短停送'",
  4391. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4392. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4393. else:
  4394. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
  4395. "航班日期": "%s" % flight_date_str, "级别": 2}
  4396. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4397. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "短停" and "MAN" in str(i[0]):
  4398. time1 = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4399. receivetime1 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  4400. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
  4401. receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4402. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4403. receivetime2 = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M")
  4404. if now<receivetime1:
  4405. ii = str(i[0]) + str(-2)
  4406. if ii in str(sort_flight_ids_arr):
  4407. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4408. "航班类型": "'短停送'",
  4409. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4410. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4411. else:
  4412. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4413. "航班类型": "短停送",
  4414. "航班日期": "%s" % flight_date_str, "级别": 2}
  4415. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4416. elif receivetime1<now<receivetime2:
  4417. ii = str(i[0]) + str(-2)
  4418. if ii in str(sort_flight_ids_arr):
  4419. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4420. "航班类型": "'短停送'",
  4421. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4422. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4423. else:
  4424. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4425. "航班类型": "短停送",
  4426. "航班日期": "%s" % flight_date_str, "级别": 1}
  4427. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4428. else:
  4429. ii=str(i[0])+str(-2)
  4430. if ii in str(sort_flight_ids_arr):
  4431. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'短停送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4432. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4433. else:
  4434. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "短停送",
  4435. "航班日期": "%s" % flight_date_str, "级别": 4}
  4436. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4437. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "特后前" and "MAN" not in str(i[0]):
  4438. if "[实]" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])):
  4439. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
  4440. receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4441. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4442. ii=str(i[0])+str(-2)
  4443. if ii in str(sort_flight_ids_arr):
  4444. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型": "'特后前送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4445. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4446. else:
  4447. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
  4448. "航班日期": "%s" % flight_date_str, "级别": 4}
  4449. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4450. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4451. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] !="" and \
  4452. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4453. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4454. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4455. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4456. ii = str(i[0]) + str(-2)
  4457. if ii in str(sort_flight_ids_arr):
  4458. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'特后前送'",
  4459. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4460. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4461. else:
  4462. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
  4463. "航班日期": "%s" % flight_date_str, "级别": 1}
  4464. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4465. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4466. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] =="" and \
  4467. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4468. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4469. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4470. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4471. ii = str(i[0]) + str(-2)
  4472. if ii in str(sort_flight_ids_arr):
  4473. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'特后前送'",
  4474. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4475. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4476. else:
  4477. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
  4478. "航班日期": "%s" % flight_date_str, "级别": 2}
  4479. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4480. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][
  4481. 0] == "特后前" and "MAN" in str(i[0]):
  4482. time1 = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4483. receivetime1 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  4484. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4485. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4486. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(
  4487. minutes=25)
  4488. receivetime2 = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M")
  4489. if now < receivetime1:
  4490. ii = str(i[0]) + str(-2)
  4491. if ii in str(sort_flight_ids_arr):
  4492. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4493. "航班类型": "'特后前送'",
  4494. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4495. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4496. else:
  4497. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4498. "航班类型": "特后前送",
  4499. "航班日期": "%s" % flight_date_str, "级别": 2}
  4500. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4501. elif receivetime1 < now < receivetime2:
  4502. ii = str(i[0]) + str(-2)
  4503. if ii in str(sort_flight_ids_arr):
  4504. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4505. "航班类型": "'特后前送'",
  4506. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4507. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4508. else:
  4509. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4510. "航班类型": "特后前送",
  4511. "航班日期": "%s" % flight_date_str, "级别": 1}
  4512. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4513. else:
  4514. ii = str(i[0]) + str(-2)
  4515. if ii in str(sort_flight_ids_arr):
  4516. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime2,
  4517. "航班类型": "'特后前送'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
  4518. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4519. else:
  4520. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "特后前送",
  4521. "航班日期": "%s" % flight_date_str, "级别": 4}
  4522. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4523. database.FunctionCommit()
  4524. except Exception:
  4525. dingding_alert(traceback.format_exc())
  4526. database.FunctionCommit()
  4527. print(datetime.datetime.now(),'[数据库操作]结束排序')
  4528. def checkWorkerlaod(database:flightDB, workload:flightDB,nowDayStr1,nowDay_11):
  4529. try:
  4530. #需要初始化表格
  4531. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  4532. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  4533. day=[nowDay_1,nowDay]
  4534. nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  4535. #nowDayStr_search=datetime.datetime.strptime(str("2023-06-11 00:00:00"),"%Y-%m-%d %H:%M:%S")
  4536. yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  4537. workernames_arr=[]
  4538. workernames1=database.getSingledata('姓名','pglist%s'%nowDayStr1)
  4539. if len(workernames1) != 0:
  4540. for i in workernames1:
  4541. workernames_arr.append(i[0])
  4542. workernames2 = database.getSingledata('姓名', 'pglist%s' % nowDay_11)
  4543. if len(workernames2) != 0:
  4544. for i in workernames2:
  4545. workernames_arr.append(i[0])
  4546. for worker in workernames_arr:
  4547. if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker))!= 0:
  4548. worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
  4549. else:
  4550. worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
  4551. # worker_number = a if len(a) !=0 else ""
  4552. single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
  4553. single_worker_load_ids_arr = []
  4554. if len(single_worker_load_ids) != 0:
  4555. for l in single_worker_load_ids:
  4556. single_worker_load_ids_arr.append(l[0])
  4557. for nowDayStr in day:
  4558. worker_laod_ids=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "维修人员 like '%{}%'".format(worker))
  4559. worker_laod_ids_arr = []
  4560. if len(worker_laod_ids)!= 0:
  4561. for j in worker_laod_ids:
  4562. worker_laod_ids_arr.append(j[0])
  4563. if len(worker_laod_ids_arr) != 0:
  4564. for k in worker_laod_ids_arr:
  4565. TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'"%k)[0][0]
  4566. #TYPE = a[0] if len(a) !=0 else ""
  4567. acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
  4568. #acno = a[0] if len(a) !=0 else ""
  4569. bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
  4570. bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
  4571. #bay = a[0] if len(a) !=0 else ""
  4572. flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
  4573. flight_id_1=str(str(flight_id))+str("-1") #接机保障标志
  4574. flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
  4575. #print(flight_id_1)
  4576. #flight_id = a[0] if len(a) !=0 else ""
  4577. flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
  4578. #flight_date = a[0] if len(a) !=0 else ""
  4579. if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4580. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4581. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4582. endtime=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前实际到达', "航班编号='%s'"%k)[0][0]
  4583. if flight_id_1 in single_worker_load_ids_arr:
  4584. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4585. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4586. else:
  4587. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4588. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4589. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4590. elif TYPE == '航前' and database.queryTabel('flightinfo{}'.format(nowDayStr), '航前预计起飞', "航班编号 ='%s'"%k)[0][0] != "":
  4591. endtime_ap = database.queryTabel('flightinfo{}'.format(nowDayStr),'航前实际起飞', "航班编号='{}'".format(k))[0][0]
  4592. STD_ap=database.queryTabel('flightinfo{}'.format(nowDayStr),'航前预计起飞', "航班编号='{}'".format(k))[0]
  4593. #STD_time_str =flight_date[0].split("-")[0] + "/" + STD_ap[0].split("]")[1]
  4594. #print(STD_ap)
  4595. starttime_ap = datetime.datetime.strptime(STD_ap[0], "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=90)
  4596. if flight_id_1 in single_worker_load_ids_arr:
  4597. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay1, "开始时间": "'%s'"%starttime_ap, "结束时间": "'%s'"%endtime_ap, "航班类型": "'%s'"%TYPE}
  4598. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='%s'"%flight_id_1)
  4599. else:
  4600. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s"%bay1, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime_ap,
  4601. "结束时间": "%s" % endtime_ap, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4602. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4603. elif TYPE == '航后' and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4604. eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
  4605. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4606. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) == "8":
  4607. endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4608. else:
  4609. endtime=""
  4610. if flight_id_1 in single_worker_load_ids_arr:
  4611. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime,
  4612. "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4613. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_1))
  4614. else:
  4615. newdic = {"编号": "%s" % flight_id_1, "机号": "%s" % acno, "机位": "%s" % bay,
  4616. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4617. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE, "人员状态": ""}
  4618. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4619. elif TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4620. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4621. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4622. if "[实]" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]):
  4623. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4624. endtime_str1 =flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4625. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4626. else:
  4627. endtime = ""
  4628. if flight_id_1 in single_worker_load_ids_arr:
  4629. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4630. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4631. else:
  4632. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4633. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4634. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4635. if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)) != 0:
  4636. worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
  4637. else:
  4638. worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
  4639. single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
  4640. single_worker_load_ids_arr = []
  4641. if len(single_worker_load_ids) != 0:
  4642. for l in single_worker_load_ids:
  4643. single_worker_load_ids_arr.append(l[0])
  4644. FX_laod_ids = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "放行人员 like '%{}%'".format(worker))
  4645. FX_laod_ids_arr = []
  4646. if len(FX_laod_ids) != 0:
  4647. for j in FX_laod_ids:
  4648. FX_laod_ids_arr.append(j[0])
  4649. if len(FX_laod_ids_arr) != 0:
  4650. for k in FX_laod_ids_arr:
  4651. TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'"%k)[0][0]
  4652. #TYPE = a[0] if len(a) !=0 else ""
  4653. acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
  4654. #acno = a[0] if len(a) !=0 else ""
  4655. bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
  4656. bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
  4657. #bay = a[0] if len(a) !=0 else ""
  4658. flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
  4659. flight_id_1=str(str(flight_id))+str("-1") #接机保障标志
  4660. flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
  4661. #print(flight_id_1)
  4662. #flight_id = a[0] if len(a) !=0 else ""
  4663. flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
  4664. #flight_date = a[0] if len(a) !=0 else ""
  4665. if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4666. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4667. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4668. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "7":
  4669. endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4670. else:
  4671. endtime = ""
  4672. if flight_id_1 in single_worker_load_ids_arr:
  4673. if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'"%flight_id_1)[0][0] =="":
  4674. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4675. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4676. else:
  4677. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4678. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4679. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4680. elif TYPE == '航前' and database.queryTabel('flightinfo{}'.format(nowDayStr), '航前预计起飞', "航班编号 ='%s'"%k)[0][0] != "":
  4681. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "7":
  4682. endtime_ap = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4683. else:
  4684. endtime_ap = ""
  4685. STD_ap=database.queryTabel('flightinfo{}'.format(nowDayStr),'航前预计起飞', "航班编号='{}'".format(k))[0]
  4686. #STD_time_str =flight_date[0].split("-")[0] + "/" + STD_ap[0].split("]")[1]
  4687. #print(STD_ap)
  4688. starttime_ap = datetime.datetime.strptime(STD_ap[0], "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=90)
  4689. if flight_id_1 in single_worker_load_ids_arr:
  4690. if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'" % flight_id_1)[0][0] == "":
  4691. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay1, "开始时间": "'%s'"%starttime_ap, "结束时间": "'%s'"%endtime_ap, "航班类型": "'%s'"%TYPE}
  4692. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='%s'"%flight_id_1)
  4693. else:
  4694. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s"%bay1, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime_ap,
  4695. "结束时间": "%s" % endtime_ap, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4696. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4697. elif TYPE == '航后' and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4698. eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
  4699. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4700. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "8":
  4701. endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4702. else:
  4703. endtime=""
  4704. if flight_id_1 in single_worker_load_ids_arr:
  4705. if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'" % flight_id_1)[0][0] == "":
  4706. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime,
  4707. "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4708. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_1))
  4709. else:
  4710. newdic = {"编号": "%s" % flight_id_1, "机号": "%s" % acno, "机位": "%s" % bay,
  4711. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4712. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE, "人员状态": ""}
  4713. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4714. elif TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4715. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4716. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4717. if "[实]" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]):
  4718. #print(flight_date)
  4719. #print(endtime_str)
  4720. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4721. #print(flight_date.split("-")[0])
  4722. #print(endtime_str.split("]")[1])
  4723. endtime_str1 =flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4724. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4725. else:
  4726. endtime = ""
  4727. if flight_id_1 in single_worker_load_ids_arr:
  4728. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4729. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4730. else:
  4731. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4732. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4733. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4734. if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)) != 0:
  4735. worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
  4736. else:
  4737. worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
  4738. single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
  4739. single_worker_load_ids_arr = []
  4740. if len(single_worker_load_ids) != 0:
  4741. for l in single_worker_load_ids:
  4742. single_worker_load_ids_arr.append(l[0])
  4743. ECCJ_laod_ids = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "二送人员 like '%{}%'".format(worker))
  4744. ECSJ_laod_ids_arr = []
  4745. if len(ECCJ_laod_ids) != 0:
  4746. for j in ECCJ_laod_ids:
  4747. ECSJ_laod_ids_arr.append(j[0])
  4748. if len(ECSJ_laod_ids_arr) != 0:
  4749. for k in ECSJ_laod_ids_arr:
  4750. TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'" % k)[0][0]
  4751. # TYPE = a[0] if len(a) !=0 else ""
  4752. acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
  4753. # acno = a[0] if len(a) !=0 else ""
  4754. bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
  4755. bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
  4756. # bay = a[0] if len(a) !=0 else ""
  4757. flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
  4758. flight_id_1 = str(str(flight_id)) + str("-1") # 接机保障标志
  4759. flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
  4760. # print(flight_id_1)
  4761. # flight_id = a[0] if len(a) !=0 else ""
  4762. flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
  4763. # flight_date = a[0] if len(a) !=0 else ""
  4764. if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0] != "":
  4765. if "实" not in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4766. starttime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4767. starttime_str1 = flight_date.split("-")[0] + "/" + starttime_str.split("]")[1]
  4768. starttime = datetime.datetime.strptime(starttime_str1, "%Y/%m/%d %H:%M")-datetime.timedelta(minutes=25)
  4769. if flight_id_2 in single_worker_load_ids_arr:
  4770. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime, "航班类型": "'%s'" % TYPE}
  4771. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4772. else:
  4773. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4774. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4775. "结束时间": "" , "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4776. "人员状态": ""}
  4777. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4778. if "实" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4779. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4780. endtime_str1 = flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4781. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4782. starttime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4783. if flight_id_2 in single_worker_load_ids_arr:
  4784. if workload.queryTabel('workload%s' % worker_number, "开始时间", "编号='{}'".format(flight_id_2))[0][0] != "":
  4785. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4786. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4787. else:
  4788. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay,"开始时间": "'%s'" % starttime, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4789. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4790. else:
  4791. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4792. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4793. "结束时间": "%s"%endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4794. "人员状态": ""}
  4795. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4796. if TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0] != "":
  4797. if "实" not in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4798. starttime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4799. starttime_str1 = flight_date.split("-")[0] + "/" + starttime_str.split("]")[1]
  4800. starttime = datetime.datetime.strptime(starttime_str1, "%Y/%m/%d %H:%M")-datetime.timedelta(minutes=25)
  4801. if flight_id_2 in single_worker_load_ids_arr:
  4802. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime, "航班类型": "'%s'" % TYPE}
  4803. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4804. else:
  4805. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4806. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4807. "结束时间": "" , "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4808. "人员状态": ""}
  4809. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4810. if "实" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4811. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4812. endtime_str1 = flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4813. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4814. starttime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4815. if flight_id_2 in single_worker_load_ids_arr:
  4816. if workload.queryTabel('workload%s' % worker_number, "开始时间", "编号='{}'".format(flight_id_2))[0][0] != "":
  4817. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4818. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4819. else:
  4820. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay,"开始时间": "'%s'" % starttime, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4821. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4822. else:
  4823. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4824. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4825. "结束时间": "%s"%endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4826. "人员状态": ""}
  4827. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4828. single_worker_load_twoday_ids = workload.queryTabel('workload%s' % worker_number, '编号',"保障日期='{}'or 保障日期='{}'".format(nowDayStr_search,yesterday_search))
  4829. single_worker_load_twoday_ids_arr = []
  4830. if len(single_worker_load_twoday_ids) != 0:
  4831. for ll in single_worker_load_twoday_ids:
  4832. single_worker_load_twoday_ids_arr.append(ll[0])
  4833. worker_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号',"维修人员 like '%{}%'".format(worker))
  4834. worker_laod_ids_twoday_arr = [] # 两天的量
  4835. if len(worker_laod_ids) != 0:
  4836. for j in worker_laod_ids:
  4837. worker_laod_ids_twoday_arr.append(j[0])
  4838. worker_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"维修人员 like '%{}%'".format(worker))
  4839. if len(worker_laod_ids_yesterday) != 0:
  4840. for m in worker_laod_ids_yesterday:
  4841. worker_laod_ids_twoday_arr.append(m[0])
  4842. FX_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号', "放行人员 like '%{}%'".format(worker))
  4843. if len(FX_laod_ids) != 0:
  4844. for j in FX_laod_ids:
  4845. worker_laod_ids_twoday_arr.append(j[0])
  4846. FX_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"放行人员 like '%{}%'".format(worker))
  4847. if len(FX_laod_ids_yesterday) != 0:
  4848. for m in FX_laod_ids_yesterday:
  4849. worker_laod_ids_twoday_arr.append(m[0])
  4850. ECSJ_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号', "二送人员 like '%{}%'".format(worker))
  4851. if len(ECSJ_laod_ids) != 0:
  4852. for j in ECSJ_laod_ids:
  4853. worker_laod_ids_twoday_arr.append(j[0])
  4854. #暂无昨日table,待完善后启用两日查询
  4855. ECCJ_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"二送人员 like '%{}%'".format(worker))
  4856. if len(ECCJ_laod_ids_yesterday) != 0:
  4857. for m in ECCJ_laod_ids_yesterday:
  4858. worker_laod_ids_twoday_arr.append(m[0])
  4859. for kk in single_worker_load_twoday_ids_arr:
  4860. if str(str(kk)[:-2]) not in str(worker_laod_ids_twoday_arr):
  4861. workload.deleteSingledata('workload%s' % worker_number, "编号='{}'".format(kk))
  4862. workload.FunctionCommit()
  4863. except Exception:
  4864. dingding_alert(traceback.format_exc())
  4865. def initAuthority(database:flightDB):
  4866. try:
  4867. fdb = database
  4868. primaryKey = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'
  4869. labelKey = ['登录名', '密码', '权限', '使用人']
  4870. dic = {}
  4871. for key in labelKey:
  4872. dic[key] = 'text not null'
  4873. fdb.initTable('loginTable', 'ID', primaryKey, dic)
  4874. except Exception:
  4875. dingding_alert(traceback.format_exc())
  4876. def insertDataToAuthority(database:flightDB):
  4877. try:
  4878. dataDic = {}
  4879. dataDic['登录名'] = 'admin'
  4880. dataDic['密码'] = 'admin123'
  4881. dataDic['权限'] = '0'
  4882. dataDic['使用人'] = '开发'
  4883. rest = database.queryTabel('loginTable', '*', "登录名='admin'")
  4884. #print(rest)
  4885. if len(rest) == 0:
  4886. database.insertData('loginTable', dataDic)
  4887. except Exception:
  4888. dingding_alert(traceback.format_exc())
  4889. def insertDataToTable(database:flightDB, datatime:str, jsonData, jsonData2):
  4890. try:
  4891. #print(datetime.datetime.now(), "开始写入Flightinfo数据库")
  4892. flightst_code={"4":"接机已到位提示","7":"已放行提示","11":"二送已到位提示"}
  4893. bglist = ["ACNO", "FLIGHT_NO", "ETA", "BAY_2", "TASKTYPE", "TD", "BL", "SJ", "ZY_FLIGHT","FLG_VR", "STD"] # 需要播报的变更列表,应该与显示的相结合
  4894. AFbglist=["ACNO", "FLIGHT_NO", "ETA", "BAY_2", "BL", "SJ", "ZY_FLIGHT"]
  4895. APbglist=["ACNO", "FLIGHT_NO", "SJ", "STD"] #去掉了BAY BL ZY_FLIGHT
  4896. TRbglist = ["ACNO", "FLIGHT_NO", "ETA", "BAY_2", "TD", "BL", "SJ", "ZY_FLIGHT"]
  4897. notelist = ["STA", "ATA", "BAY1", "BAY2","TASKSTS_TIME"]
  4898. nowDayStr = datatime
  4899. now = datetime.datetime.now()
  4900. insertdatestr=datatime + " 00:00:00"
  4901. insertdate=datetime.datetime.strptime(insertdatestr, "%Y%m%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
  4902. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  4903. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  4904. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  4905. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  4906. a_str = nowDay_str2 + " 20:30:00"
  4907. b_str = nowDay_str2 + " 22:00:00"
  4908. c_str = nowDay_str2 + " 09:00:00"
  4909. time1 = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  4910. time2 = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
  4911. time3 = datetime.datetime.strptime(c_str, "%Y-%m-%d %H:%M:%S")
  4912. if now < time3:
  4913. days=[nowDay,nowDay_1]
  4914. elif time3 < now < time1:
  4915. days=[nowDay]
  4916. else:
  4917. days=[nowDay,nowDay_2]
  4918. #print("测试监测",nowDayStr,days)
  4919. if nowDayStr in days:
  4920. #print("测试插入",nowDayStr)
  4921. if str(nowDay) !=str(nowDayStr) and time1 < now < time2:
  4922. LOGsdeactive = 1
  4923. else:
  4924. LOGsdeactive= 0
  4925. zh2en = {}
  4926. en2zh = {}
  4927. for key in range(len(headerLabel)):
  4928. zh2en[headerLabel[key]] = headerLabelKey[key]
  4929. for key in range(len(headerLabelKey)):
  4930. en2zh[headerLabelKey[key]] = headerLabel[key]
  4931. flightinfo_flight_ids_arr=[]
  4932. flightinfo_flight_ids = database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"附加消息='AMRO'")
  4933. if len(flightinfo_flight_ids) != 0:
  4934. for i in flightinfo_flight_ids:
  4935. flightinfo_flight_ids_arr.append(i[0])
  4936. flight_id_now = []
  4937. for i in [jsonData,jsonData2]:
  4938. if jsonData !="" and jsonData2 !="" and jsonData2 !=None and jsonData !=None and jsonData != {} and jsonData2 != {} and len(jsonData)!=0 and len(jsonData2)!=0:
  4939. for row in i:
  4940. flight_id_now.append(row["FLIGHT_ID"])
  4941. newDic2 = {}
  4942. now11=str(now).split(".")[0]
  4943. flightdate=str(row["FLIGHT_DATE"]).split(" ")[0][5:10]
  4944. if str(row["FLIGHT_ID"]) not in str(flightinfo_flight_ids_arr) and str(insertdate)==row["FLIGHT_DATE"]:
  4945. for col in row:
  4946. if col in headerLabelKey:
  4947. if col == 'TASKTYPE':
  4948. if row["TASKTYPE"] !="" :
  4949. newDic2[en2zh[col]] = taskType[row[col]]
  4950. elif row["TASKTYPE"] =="" and "FLG_VR" not in row.keys():
  4951. #newDic2[en2zh[col]] = "未显示"
  4952. if row["ARR_DEP"] !="" :
  4953. if row["ARR_DEP"][-1] =="-":
  4954. newDic2[en2zh[col]] = "航后"
  4955. if LOGsdeactive == 0:
  4956. newDic3 = {"警告信息": "[%s]机号%s航班号%s,航班类型显示为空白,智能判断类型为航后,请核对FOC!!" % (flightdate,row["ACNO"],row["ARR_DEP"]),
  4957. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,"处理人": "","处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  4958. database.lazyInsertData('logs', newDic3)
  4959. elif row["ARR_DEP"][0] =="-":
  4960. newDic2[en2zh[col]] = "航前"
  4961. if LOGsdeactive == 0:
  4962. newDic3 = {"警告信息": "[%s]机号%s航班号%s,航班类型显示为空白,智能判断类型为航前,请核对FOC!!" % (flightdate,row["ACNO"], row["ARR_DEP"]),
  4963. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  4964. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  4965. database.lazyInsertData('logs', newDic3)
  4966. else:
  4967. newDic2[en2zh[col]] = "短停"
  4968. if LOGsdeactive == 0:
  4969. newDic3 = {"警告信息": "[%s]机号%s航班号%s,航班类型显示为空白,智能判断类型为短停,请注意判断是否为特后前或保障正常航后航前,请核对FOC!!" % (flightdate,row["ACNO"], row["ARR_DEP"]),
  4970. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  4971. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  4972. database.lazyInsertData('logs', newDic3)
  4973. elif row["TASKTYPE"] =="" and "FLG_VR" in row.keys():
  4974. newDic2[en2zh[col]] = "短停"
  4975. newDic3 = {"警告信息": "[%s]机号%s航班号%s为备降返航航班,航班类型显示为空白,智能判断类型为短停,请关注后续航班是否取消,请核对FOC!!" % (flightdate, row["ACNO"], row["ARR_DEP"]),"航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "",
  4976. "产生时间": "%s" % now, "处理人": "", "处理时间": "","变更字段": "%s" % zydy[col], "显示对象": "", "提示内容": ""}
  4977. try:
  4978. database.lazyInsertData('logs', newDic3)
  4979. except Exception:
  4980. dingding_alert(traceback.format_exc())
  4981. pass
  4982. elif row["ARR_DEP"] =="":
  4983. newDic2[en2zh[col]] = "未显示"
  4984. else:
  4985. newDic2[en2zh[col]] = row[col]
  4986. #database.FunctionCommit()
  4987. for key in headerLabel:
  4988. if key not in newDic2.keys():
  4989. # print(key)
  4990. newDic2[key] = ''
  4991. newDic2['航班编号'] = str(row['FLIGHT_ID'])
  4992. newDic2['取消标志'] = "0"
  4993. newDic2['附加消息'] = "AMRO"
  4994. database.lazyInsertData('flightinfo{}'.format(nowDayStr), newDic2)
  4995. if len(flightinfo_flight_ids_arr) != 0 and "FLG_VR" not in row.keys():
  4996. if row["TASKTYPE"] != "":
  4997. a = taskType[row["TASKTYPE"]]
  4998. else:
  4999. # newDic2[en2zh[col]] = "未显示"
  5000. if row["ARR_DEP"] != "" and row["ARR_DEP"][-1] == "-":
  5001. a = "航后"
  5002. elif row["ARR_DEP"] != "" and row["ARR_DEP"][0] == "-":
  5003. a = "航前"
  5004. elif row["ARR_DEP"] == "":
  5005. a = "未显示"
  5006. if LOGsdeactive == 0:
  5007. newDic3={"警告信息":"有新增航班,[%s]机号:%s航班号:%s航班类型:%s,请注意核对FOC!!!"%(flightdate,row["ACNO"],row["FLIGHT_NO"],a),"航班编号":"%s"%row["FLIGHT_ID"],"信息状态":"","提示信息":"","产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"全部新增","显示对象":"","提示内容":""}
  5008. database.lazyInsertData('logs',newDic3)
  5009. elif len(flightinfo_flight_ids_arr) != 0 and "FLG_VR" in row.keys() and row["FLG_VR"] != "" :
  5010. if row['FLG_VR'][0] == "V":
  5011. newDic3 = {"警告信息": "有备降航班,[%s]机号为%s航班号%s,请核对FOC!" % (flightdate,row["ACNO"],row["FLIGHT_NO"]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "",
  5012. "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "备降返航","显示对象":"","提示内容":""}
  5013. database.lazyInsertData('logs', newDic3)
  5014. if row['FLG_VR'][0] == "R":
  5015. newDic3 = {"警告信息": "有返航航班,[%s]机号为%s航班号%s,请核对FOC!" % (flightdate,row["ACNO"],row["FLIGHT_NO"]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "",
  5016. "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "备降返航","显示对象":"","提示内容":""}
  5017. database.lazyInsertData('logs', newDic3)
  5018. elif str(row["FLIGHT_ID"]) in str(flightinfo_flight_ids_arr) and str(row["FLIGHT_ID"]) !="":
  5019. newdic = {"取消标志": "'0'"}
  5020. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" %row["FLIGHT_ID"])
  5021. acno=database.queryTabel("flightinfo{}".format(nowDayStr), "%s" % zydy["ACNO"],"航班编号='%s'" % row["FLIGHT_ID"])[0][0]
  5022. if row["ACNO"] == acno:
  5023. for col in headerLabelKey:
  5024. #flightinfo_str=database.queryTabel("flightinf o{}".format(nowDayStr),"%s"%zydy[col],"航班编号='%s'"%row["FLIGHT_ID"])[0][0]
  5025. #newflightinfo_str = taskType[row[col]]
  5026. #newflightinfo_str1 = taskSTS[row[col]]
  5027. #c= database.queryTabel("flightinfo{}".format(nowDayStr), "%s" % zydy[col], "航班编号='%s'" % row["FLIGHT_ID"])[0][0]
  5028. b= database.queryTabel("flightinfo{}".format(nowDayStr),"%s"%zydy[col],"航班编号='%s'"%row["FLIGHT_ID"])[0][0]
  5029. bb = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % row["FLIGHT_ID"])[0][0]
  5030. if row["TASKTYPE"] != "":
  5031. a = taskType[row["TASKTYPE"]]
  5032. else:
  5033. # newDic2[en2zh[col]] = "未显示"
  5034. if row["ARR_DEP"] != "" and "FLG_VR" not in row.keys():
  5035. if row["ARR_DEP"][-1] == "-":
  5036. a = "航后"
  5037. elif row["ARR_DEP"][0] == "-":
  5038. a = "航前"
  5039. else:
  5040. a = "短停"
  5041. elif row["ARR_DEP"] != "" and "FLG_VR" in row.keys():
  5042. a = "短停"
  5043. elif row["ARR_DEP"] == "":
  5044. a = "未显示"
  5045. if col == 'TASKTYPE' and a != b:
  5046. if LOGsdeactive == 0:
  5047. newDic3 = {"警告信息": "[%s]机号:%s航班类型由%s变更为%s,请注意核对FOC!!!" % (flightdate,row["ACNO"],b, a),
  5048. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now, "处理人": "",
  5049. "处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5050. database.lazyInsertData('logs', newDic3)
  5051. newdic={"航班类型":"'%s'"%a}
  5052. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic,"航班编号='%s'"%row["FLIGHT_ID"])
  5053. elif col == 'TASKSTS' and row[col] != b:
  5054. if LOGsdeactive == 0:
  5055. newDic3 = {"警告信息": "","航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "[%s]机号:%s维修状态由%s变更为%s!%s" % (flightdate,row["ACNO"],taskSTS[b], taskSTS[row["TASKSTS"]],now11), "产生时间": "%s" % now, "处理人": "",
  5056. "处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5057. database.lazyInsertData('logs', newDic3)
  5058. if row[col] in flightst_code.keys():
  5059. newdic={"%s"%flightst_code[row[col]]:"1"}
  5060. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%row["FLIGHT_ID"])
  5061. newdic = {"维修状态": "'%s'" % row[col]}
  5062. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5063. elif col == 'TASKSTS_ECSJ' and row[col] != b:
  5064. if LOGsdeactive == 0:
  5065. newDic3 = {"警告信息": "","航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "[%s]机号:%s二送状态由%s变更为%s!%s" % (flightdate,row["ACNO"],ecsjtaskSTS[b], ecsjtaskSTS[row["TASKSTS_ECSJ"]],now11), "产生时间": "%s" % now, "处理人": "",
  5066. "处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5067. database.lazyInsertData('logs', newDic3)
  5068. newdic = {"二送状态": "'%s'" % row[col]}
  5069. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5070. elif 'FLG_VR' in row.keys() and col == 'FLG_VR' and row['FLG_VR'] != "":
  5071. if row['FLG_VR'][0] == "R":
  5072. mesg = "有返航航班,[%s]机号为%s航班号%s,返航航班预达时间不准,请核对FOC,可人工创建航班监控节点!" % (flightdate, row["ACNO"], row["FLIGHT_NO"])
  5073. if len(database.queryTabel('logs',"*","警告信息= '%s' and 航班编号 ='%s'"%(mesg, row["FLIGHT_ID"])))==0:
  5074. newDic3 = {"警告信息":mesg, "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "","产生时间": "%s" % now, "处理人": "","处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  5075. database.lazyInsertData('logs', newDic3)
  5076. if row[col] != b:
  5077. newdic = {"备降返航": "'%s'" % row[col]}
  5078. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic,"航班编号='%s'" % row["FLIGHT_ID"])
  5079. elif row['FLG_VR'][0] == "V":
  5080. mesg = "有备降航班,[%s]机号为%s航班号%s,备降航班预达时间不准,请核对FOC,可人工创建航班监控节点!" % (flightdate, row["ACNO"], row["FLIGHT_NO"])
  5081. if len(database.queryTabel('logs', "*", "警告信息= '%s' and 航班编号 ='%s'" % (mesg, row["FLIGHT_ID"]))) == 0:
  5082. newDic3 = {"警告信息": mesg, "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "","变更字段": "%s" % zydy[col], "显示对象": "", "提示内容": ""}
  5083. database.lazyInsertData('logs', newDic3)
  5084. if row[col] != b:
  5085. newdic = {"备降返航": "'%s'" % row[col]}
  5086. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic,"航班编号='%s'" % row["FLIGHT_ID"])
  5087. elif "ETA" in row.keys() and col == 'ETA' and row[col] != b and a != "航前":
  5088. if b=="" and LOGsdeactive == 0 and "ATD" in row.keys() and row["ATD"] != "" :
  5089. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
  5090. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5091. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  5092. database.lazyInsertData('logs', newDic3)
  5093. elif b!="" and LOGsdeactive == 0 and "ATD" in row.keys() and row["ATD"] != "" :
  5094. #eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
  5095. ETA_P10 = datetime.datetime.strptime(b, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=10)
  5096. ETA_N10 = datetime.datetime.strptime(b, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=10)
  5097. ETAnew=datetime.datetime.strptime(str(row[col]), "%Y-%m-%d %H:%M:%S")
  5098. if ETAnew < ETA_N10 or ETAnew > ETA_P10 and ETAnew > now:
  5099. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
  5100. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5101. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  5102. database.lazyInsertData('logs', newDic3)
  5103. newdic = {"非航前预计到达": "'%s'" % row[col]}
  5104. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5105. elif "ATD" in row.keys() and col == "ATD" and database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] !="航前" and row[col] != b and "新航班播报" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" %row["FLIGHT_ID"])):
  5106. FJtask = ""
  5107. BLstr = ""
  5108. if row["FLIGHT_ID"] in str(database.getSingledata("航班编号",'TaskFlightinfo{}'.format(nowDayStr))):
  5109. if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"工作包","航班编号='%s'"%row["FLIGHT_ID"])[0][0]!="":
  5110. FJtask=",有工作包"
  5111. if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"保留","航班编号='%s'"%row["FLIGHT_ID"])[0][0]!="":
  5112. BLstr=",有保留"
  5113. bay_str=row["BAY_2"] if "BAY_2" in row.keys() else ""
  5114. newDic3 = {"警告信息": "[%s]新航班:%s%s%s %s%s%s!" % (flightdate,row["ACNO"],(database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0]),bay_str, row["ETA"][-8:-3],BLstr,FJtask), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "",
  5115. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "新航班播报","显示对象":"","提示内容":""}
  5116. database.lazyInsertData('logs', newDic3)
  5117. newdic = {"航前实际起飞": "'%s'" % row[col]}
  5118. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5119. now_1= (datetime.datetime.now()- datetime.timedelta(minutes=0.5)).strftime("%Y-%m-%d %H:%M:%S")
  5120. waringsts = database.queryTabel('logs', "编号","航班编号 ='%s' and 变更字段='非航前预计到达' and 产生时间>'%s'" %(row["FLIGHT_ID"],now_1))
  5121. if len(waringsts) != 0:
  5122. newdic = {"处理人": "'系统抑制'", "处理时间": "'%s'" % now}
  5123. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringsts[0][0])
  5124. elif "TD" in row.keys() and col == 'TD' and row[col] != b:
  5125. if row[col] !="":
  5126. FlightDate=str(row["FLIGHT_DATE"])
  5127. TD_time_str = FlightDate.split("-")[0] + "/" + row[col].split("]")[1]
  5128. TD_time = datetime.datetime.strptime(TD_time_str,"%Y/%m/%d %H:%M")
  5129. else:
  5130. TD_time=now+ datetime.timedelta(minutes=5)
  5131. if LOGsdeactive == 0 and "ATD" in row.keys() and row["ATD"] != "" and bb != "航后" and bb != "航前" and "实" not in str(row["TD"]) and TD_time > now:
  5132. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
  5133. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5134. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  5135. database.lazyInsertData('logs', newDic3)
  5136. elif LOGsdeactive == 0 and "ATD" in row.keys() and row["ATD"] == "" and bb != "航后" and bb == "航前" and "实" not in str(row["TD"]) and TD_time > now:
  5137. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
  5138. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5139. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  5140. database.lazyInsertData('logs', newDic3)
  5141. newdic = {"非航前预计起飞": "'%s'" % row[col]}
  5142. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5143. elif col !="TASKTYPE" and col !="TASKSTS" and col !="FLIGHT_ID" and col !="FLG_VR" and col in row.keys() and row[col] != b:
  5144. if database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] == "航前" and col in APbglist:
  5145. if LOGsdeactive == 0:
  5146. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col],b, row[col]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now,
  5147. "处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5148. database.lazyInsertData('logs', newDic3)
  5149. elif database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] == "航后" and col in AFbglist:
  5150. if LOGsdeactive == 0:
  5151. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col],b, row[col]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now,
  5152. "处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5153. database.lazyInsertData('logs', newDic3)
  5154. elif (database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] =="短停" or database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] =="特后前" )and col in TRbglist:
  5155. if LOGsdeactive == 0:
  5156. if col == "TD" and "[实]" not in str(row[col]):
  5157. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col],b, row[col]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now,
  5158. "处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5159. database.lazyInsertData('logs', newDic3)
  5160. elif col != "TD":
  5161. newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),"航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5162. "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
  5163. database.lazyInsertData('logs', newDic3)
  5164. else: #限制提示信息输出位置
  5165. if LOGsdeactive == 0:
  5166. if col not in ["WXRY","FXRY","ECSJRY","TASKSTS_TIME"]:
  5167. newDic3 = {"警告信息": "", "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "[%s]机号:%s%s由%s变更为%s!%s" % (flightdate,row["ACNO"],zydy_simple[col],b,row[col],now11), "产生时间": "%s" % now,"处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
  5168. database.lazyInsertData('logs', newDic3)
  5169. newdic = {"%s"% zydy[col]: "'%s'" %row[col]}
  5170. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5171. else:
  5172. if LOGsdeactive == 0:
  5173. newDic3 = {"警告信息": "[%s]%s航班机号由%s变更为%s,请注意核对FOC!!!" % (flightdate,row["FLIGHT_NO"], acno, row["ACNO"]),
  5174. "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5175. "处理人": "","处理时间": "", "变更字段": "机号","显示对象":"","提示内容":""}
  5176. database.lazyInsertData('logs', newDic3)
  5177. newdic = {"机号": "'%s'" % row["ACNO"]}
  5178. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
  5179. database.FunctionCommit()
  5180. else:
  5181. print(datetime.datetime.now(),"[数据库操作]flightinfo航班数据为空")
  5182. pass
  5183. if jsonData !="" and jsonData2 !="" and jsonData2 !=None and jsonData !=None and jsonData != {} and jsonData2 != {} and len(flight_id_now) != 0 and len(jsonData)!=0 and len(jsonData2)!=0:
  5184. flightinfo_flight_ids = database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"附加消息='AMRO'")
  5185. if len(flightinfo_flight_ids) != 0:
  5186. for iii in flightinfo_flight_ids:
  5187. if str(iii[0]) not in flight_id_now:
  5188. cancelid=database.queryTabel( 'flightinfo{}'.format(nowDayStr),'取消标志',"航班编号='%s'"%iii[0])[0][0]
  5189. newcancelid=int(cancelid)+1
  5190. if int(newcancelid) <4:
  5191. newdic={"取消标志":"'%s'"%newcancelid}
  5192. database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" %iii[0])
  5193. else:
  5194. c=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % str(iii[0]) )[0][0][5:10]
  5195. a= database.queryTabel("flightinfo{}".format(nowDayStr), "机号","航班编号='%s'" % str(iii[0]) )[0][0]
  5196. b=database.queryTabel("flightinfo{}".format(nowDayStr), "保障航班号","航班编号='%s'" % str(iii[0]) )[0][0]
  5197. newDic3 = {"警告信息": "[%s]%s,%s航班已取消,注意核对FOC!!!"% (c,a,b),"航班编号": "%s" % str(iii[0]) , "信息状态": "", "提示信息": "", "产生时间": "%s" % now,"处理人": "", "处理时间": "", "变更字段": "全部取消","显示对象":"","提示内容":""}
  5198. database.lazyInsertData('logs', newDic3)
  5199. database.deleteSingledata("flightinfo{}".format(nowDayStr), "航班编号='%s'" % str(iii[0]) )
  5200. #print("全部取消警告",int(time.time()),c,a,b)
  5201. database.FunctionCommit()
  5202. except Exception:
  5203. database.FunctionCommit()
  5204. dingding_alert(traceback.format_exc())
  5205. def insertTaskDataToTable(database: flightDB, datatime: str, jsonData1,jsonData2):
  5206. try:
  5207. #print(datetime.datetime.now(),"开始写入Task任务数据库")
  5208. flightsts_code = {"4": "接机已到位提示", "7": "已放行提示", "11": "二送已到位提示"}
  5209. nowDayStr = datatime
  5210. now = datetime.datetime.now()
  5211. selectdaystr = str(datatime)[0:4] + "-" + str(datatime)[4:6] + "-" + str(datatime)[6:] + " 00:00:00"
  5212. nowDayStr_search = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
  5213. '''
  5214. Taskflightinfo_flight_ids_arr = []
  5215. Taskflightinfo_flight_ids = database.getSingledata('航班编号', 'TaskFlightinfo{}'.format(nowDayStr))
  5216. if len(Taskflightinfo_flight_ids) != 0:
  5217. for i in Taskflightinfo_flight_ids:
  5218. Taskflightinfo_flight_ids_arr.append(i[0])
  5219. '''
  5220. for jsonData in [jsonData1,jsonData2]:
  5221. #print(len(jsonData))
  5222. if jsonData !="" and len(jsonData) !=0:
  5223. for row in jsonData:
  5224. flightdate = str(row["FLIGHTDATE"]).split(" ")[0][5:10]
  5225. if row["FLIGHTDATE"] == str(nowDayStr_search):
  5226. newDic2 = {}
  5227. if row["TASKTYPE"]=="AP":
  5228. a=row["FLIGHTID2"]
  5229. elif row["TASKTYPE"]=="AF":
  5230. a = row["FLIGHTID1"]
  5231. elif row["TASKTYPE"] == "TR":
  5232. a = row["FLIGHTID1"]
  5233. elif row["TASKTYPE"] == "TAF":
  5234. a = row["FLIGHTID1"]
  5235. else:
  5236. if"FNO" in row.keys() and row["FNO"] != "":
  5237. if row["FNO"][-1] == "-" and row["FNO"][0] != "-" :
  5238. a = row["FLIGHTID2"]
  5239. else:
  5240. a = row["FLIGHTID1"]
  5241. else:
  5242. if "FLIGHTID2" in row.keys() and "FLIGHTID1" not in row.keys():
  5243. a = row["FLIGHTID2"]
  5244. else:
  5245. a = row["FLIGHTID1"]
  5246. if str(a) !="" and str(a) not in str(database.getSingledata('航班编号', 'TaskFlightinfo{}'.format(nowDayStr))):#and str(a) not in str(Taskflightinfo_flight_ids_arr)
  5247. for col in row:
  5248. if col in TaskflightinfoLabel2en.keys():
  5249. if col == 'TASKTYPE':
  5250. if row[col] != "":
  5251. newDic2[TaskflightinfoLabel2en[col]] = row[col]
  5252. else:
  5253. # newDic2[en2zh[col]] = "未显示"
  5254. if row["FNO"] != "" and row["FNO"][0] == "-":
  5255. newDic2[TaskflightinfoLabel2en[col]] = "AF"
  5256. elif row["FNO"] != "" and row["FNO"][-1] == "-":
  5257. newDic2[TaskflightinfoLabel2en[col]] = "AP"
  5258. elif row["FNO"] != "":
  5259. newDic2[TaskflightinfoLabel2en[col]] = "TR"
  5260. elif row["ARR_DEP"] == "":
  5261. newDic2[TaskflightinfoLabel2en[col]] = ""
  5262. elif col == 'FJ_TASKIDS':
  5263. if "'" in str(row[col]):
  5264. b=""
  5265. for i in range(0,len(row[col])-1):
  5266. b=b+str(row[col][i])+","
  5267. newDic2[TaskflightinfoLabel2en[col]] = b
  5268. else:
  5269. newDic2[TaskflightinfoLabel2en[col]] = ""
  5270. else:
  5271. newDic2[TaskflightinfoLabel2en[col]] = row[col]
  5272. for key in TaskflightinfoLabel:
  5273. if key not in newDic2.keys():
  5274. # print(key)
  5275. newDic2[key] = ''
  5276. newDic2['航班编号'] = str(a)
  5277. database.lazyInsertData('TaskFlightinfo{}'.format(nowDayStr), newDic2)
  5278. else:
  5279. sjry = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "随机", "航班编号='%s'" % str(a))[0][0]
  5280. #print(sjry)
  5281. for col in row:
  5282. if col in TaskflightinfoLabel2en.keys():
  5283. if col == 'TASKTYPE':
  5284. if row[col] != "":
  5285. aa = "'%s'" %row[col]
  5286. else:
  5287. # newDic2[en2zh[col]] = "未显示"
  5288. if row["FNO"] != "" and row["FNO"][0] == "-":
  5289. aa = "AF"
  5290. elif row["FNO"] != "" and row["FNO"][-1] == "-":
  5291. aa = "AP"
  5292. elif row["FNO"] != "":
  5293. aa = "TR"
  5294. elif row["ARR_DEP"] == "":
  5295. aa = ""
  5296. if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%str(a))[0][0] != aa:
  5297. newDic2={"航班类型":"%s"%aa}
  5298. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5299. elif col == 'FJ_TASKIDS':
  5300. #print(str(row[col]))
  5301. if "'" in str(row[col]):
  5302. c=""
  5303. for i in range(0,len(row[col])):
  5304. c=c+str(row[col][i])+","
  5305. else:
  5306. c = ""
  5307. #print("#################")
  5308. #print(c)
  5309. #print(database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "工作包", "航班编号='%s'" % str(a))[0][0])
  5310. #print(database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"工作包","航班编号='%s'"%str(a))[0][0].count(","))
  5311. #print("#################")
  5312. workjob=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"工作包","航班编号='%s'"%str(a))[0][0]
  5313. if workjob.count(",") >1:
  5314. for i in range(0,workjob.count(",")):
  5315. #print("***********************")
  5316. #print(c)
  5317. #print(workjob)
  5318. #print(workjob.count(","))
  5319. #print(i)
  5320. #print(str(workjob.split(",")[i]))
  5321. #print("**********************")
  5322. if str(workjob.split(",")[i]) not in str(c):
  5323. newDic2 = {"工作包": "'%s'" % c}
  5324. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
  5325. elif workjob.count(",") <= 1 and str(workjob) != str(c):
  5326. newDic2 = {"工作包": "'%s'" % c}
  5327. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5328. elif col == 'TASKTYPE':
  5329. if (row[col]=="TR" or row[col]=="TAF")and row["BAY_A"] != row["BAY_B"] :
  5330. mesg="[%s]%s %s航班进港机位为%s,出港机位为%s,短停进出港机位不一致,请注意核对AMRO机位信息,按需修改,注意核对工作人员派送机位信息!!!" % (flightdate,row["ACNO"], row["FNO"],row["BAY_A"], row["BAY_B"])
  5331. newDic3 = {"警告信息": "[%s]%s进港机位为%s,出港机位为%s,请注意核对AMRO机位信息,按需修改,注意核对工作人员派送机位信息!!!" % (flightdate,row["ACNO"],row["BAY_A"], row["BAY_B"]),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "",
  5332. "产生时间": "%s" % now,"处理人": "", "处理时间": "", "变更字段": "机位不一致警告", "显示对象": "", "提示内容": ""}
  5333. if mesg not in str(database.queryTabel('logs', "警告信息", "航班编号='%s'" % str(a))):
  5334. database.lazyInsertData('logs', newDic3)
  5335. if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "%s"%TaskflightinfoLabel2en[col], "航班编号='%s'" % str(a))[0][0] != row[col]:
  5336. newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %row[col]}
  5337. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5338. elif col == 'BAY_A':
  5339. aaaa=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "%s"%TaskflightinfoLabel2en[col], "航班编号='%s'" % str(a))[0][0]
  5340. if aaaa != row[col]:
  5341. if row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "AF" or row["TASKTYPE"] == "TAF":
  5342. newDic3 = {"警告信息": "[%s]任务派工模块:%s机位由%s变更为%s" % (
  5343. flightdate, row["ACNO"], aaaa, row[col]),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "",
  5344. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "进港机位变更", "显示对象": "","提示内容": ""}
  5345. database.lazyInsertData('logs', newDic3)
  5346. newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %row[col]}
  5347. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5348. if (row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and "BAY_B" not in row.keys():
  5349. newDic2 = {"航前离港机位": "'%s'" % row[col]}
  5350. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
  5351. elif col == 'BAY_B':
  5352. aaaa = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"%s" % TaskflightinfoLabel2en[col],"航班编号='%s'" % str(a))[0][0]
  5353. if aaaa != row[col]:
  5354. if row["TASKTYPE"] == "AP" or ((row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and("BAY_A" not in row.keys() or row["BAY_A"] != row["BAY_B"])):
  5355. newDic3 = {"警告信息": "[%s]任务派工模块:%s机位由%s变更为%s" % (flightdate, row["ACNO"], aaaa, row[col]),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "",
  5356. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "出港机位变更", "显示对象": "","提示内容": ""}
  5357. database.lazyInsertData('logs', newDic3)
  5358. newDic2 = {"%s"%TaskflightinfoLabel2en[col]: "'%s'" % row[col]}
  5359. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
  5360. if (row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and ( row["BAY_A"] != row["BAY_B"]):
  5361. newDic2 = {"非航前进港机位": "'%s'" % row[col]}
  5362. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
  5363. if (row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and ("BAY_A" not in row.keys()):
  5364. newDic2 = {"非航前进港机位": "'%s'" % row[col]}
  5365. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
  5366. elif col=="SJ_DEP" and "SJ_ARR" not in row.keys():
  5367. if row["SJ_DEP"] !="":
  5368. SJ="随机"+row["SJ_DEP"].replace("已安排","").replace("已登机","")+";"
  5369. else:
  5370. SJ=""
  5371. new_a = str(a) + "-2" + "-A"
  5372. fj = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息", "编号='%s'" % str(new_a))
  5373. if sjry != SJ:
  5374. newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %SJ}
  5375. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5376. if len(fj)!=0 and ((sjry!="" and sjry not in str(fj) and SJ not in str(fj) and SJ !="") or sjry == ""):
  5377. new_fj=SJ + fj[0][0]
  5378. newDic2 = {"附加消息": "'%s'" % new_fj}
  5379. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5380. newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
  5381. database.lazyInsertData('logs', newDic3)
  5382. elif len(fj)!=0 and sjry in str(fj) and SJ != sjry:
  5383. new_fj=fj[0][0].replace("%s"%sjry,"%s"%SJ)
  5384. newDic2 = {"附加消息": "'%s'" % new_fj}
  5385. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5386. newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
  5387. database.lazyInsertData('logs', newDic3)
  5388. if len(fj)==0:
  5389. newDic2 = {"编号":new_a,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" % SJ}
  5390. database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
  5391. elif SJ not in str(fj):
  5392. new_fj=SJ+ fj[0][0]
  5393. newDic2 = {"附加消息": "'%s'" %new_fj}
  5394. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5395. elif col=="SJ_ARR" and "SJ_DEP" not in row.keys():
  5396. if row["SJ_ARR"] !="":
  5397. SJ="随机"+row["SJ_ARR"].replace("已安排","").replace("已登机","")+";"
  5398. else:
  5399. SJ=""
  5400. new_a = str(a) + "-1" + "-A"
  5401. fj = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息","编号='%s'" % str(new_a))
  5402. if sjry != SJ:
  5403. newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %SJ}
  5404. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5405. if len(fj)!=0 and ((sjry!="" and sjry not in str(fj) and SJ not in str(fj) and SJ !="") or sjry == ""):
  5406. new_fj=SJ + fj[0][0]
  5407. newDic2 = {"附加消息": "'%s'" % new_fj}
  5408. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5409. newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
  5410. database.lazyInsertData('logs', newDic3)
  5411. elif len(fj)!=0 and sjry in str(fj) and SJ != sjry:
  5412. new_fj=fj[0][0].replace("%s"%sjry,"%s"%SJ)
  5413. newDic2 = {"附加消息": "'%s'" % new_fj}
  5414. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5415. newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry,SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
  5416. database.lazyInsertData('logs', newDic3)
  5417. if len(fj)==0:
  5418. newDic2 = {"编号":new_a,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" % SJ}
  5419. database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
  5420. elif SJ not in str(fj):
  5421. new_fj=SJ+ fj[0][0]
  5422. newDic2 = {"附加消息": "'%s'" % new_fj}
  5423. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5424. elif (col=="SJ_DEP" and "SJ_ARR" in row.keys()) or (col=="SJ_ARR" and "SJ_DEP" in row.keys()) :
  5425. if row["SJ_DEP"] !="" and row["SJ_ARR"] =="":
  5426. SJ_DEP="随机"+row["SJ_DEP"].replace("已安排","").replace("已登机","")+";"
  5427. SJ_ARR=""
  5428. SJ = str(SJ_DEP)
  5429. elif row["SJ_DEP"] =="" and row["SJ_ARR"] !="":
  5430. SJ_ARR = "随机" + row["SJ_ARR"].replace("已安排","").replace("已登机","") + ";"
  5431. SJ_DEP = ""
  5432. SJ = str(SJ_ARR)
  5433. else:
  5434. SJ_ARR = "随机" + row["SJ_ARR"].replace("已安排","").replace("已登机","") + ";"
  5435. SJ_DEP = "随机" + row["SJ_DEP"].replace("已安排","").replace("已登机","") + ";"
  5436. SJ=str(SJ_ARR)+"-"+str(SJ_DEP)
  5437. new_a = str(a) + "-1" + "-A"
  5438. new_b = str(a) + "-2" + "-A"
  5439. fj = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息","编号='%s'" % str(new_a))
  5440. fj2 = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息","编号='%s'" % str(new_b))
  5441. if "-" in sjry:
  5442. sjry_ARR=sjry.split("-")[0]
  5443. sjry_DEP = sjry.split("-")[1]
  5444. elif "离港" in sjry and "进港" not in sjry:
  5445. sjry_ARR = ""
  5446. sjry_DEP = sjry
  5447. elif "进港" in sjry and "离港" not in sjry:
  5448. sjry_ARR = sjry
  5449. sjry_DEP = ""
  5450. if sjry != SJ:
  5451. newDic2={"随机":"'%s'" %SJ}
  5452. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5453. newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
  5454. database.lazyInsertData('logs', newDic3)
  5455. #if len(fj) != 0 and ((sjry != "" and sjry not in str(fj) and SJ not in str(fj) and SJ != "") or sjry == ""):
  5456. if len(fj)!=0 and ((sjry_ARR !="" and str(sjry_ARR) not in str(fj) and str(SJ_ARR) not in str(fj) and sjry_ARR !=SJ_ARR)or(sjry_ARR =="" and str(SJ_ARR) not in str(fj) and sjry_ARR !=SJ_ARR)):
  5457. new_fj=SJ_ARR+fj[0][0]
  5458. newDic2 = {"附加消息": "'%s'" % new_fj}
  5459. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5460. elif len(fj)!=0 and sjry_ARR !="" and str(sjry_ARR) in str(fj) and sjry_ARR != SJ_ARR:
  5461. new_fj=fj[0][0].replace("%s"%(sjry_ARR),"%s"%(SJ_ARR))
  5462. newDic2 = {"附加消息": "'%s'" % new_fj}
  5463. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5464. if len(fj2)!=0 and ((sjry_DEP !="" and str(sjry_DEP) not in str(fj2) and str(SJ_DEP) not in str(fj2) and sjry_DEP !=SJ_DEP)or(sjry_DEP =="" and str(SJ_DEP) not in str(fj2) and sjry_DEP !=SJ_DEP)):
  5465. new_fj2 = SJ_DEP+fj2[0][0]
  5466. newDic2 = {"附加消息": "'%s'" % new_fj2}
  5467. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_b))
  5468. elif len(fj2)!=0 and sjry_DEP !="" and sjry_DEP in str(fj2) and sjry_DEP !=SJ_DEP:
  5469. new_fj2=fj2[0][0].replace("%s"%(sjry_DEP),"%s"%(SJ_DEP))
  5470. newDic2 = {"附加消息": "'%s'" % new_fj2}
  5471. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_b))
  5472. if len(fj)==0:
  5473. newDic2 = {"编号":new_a,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" %SJ_ARR}
  5474. database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
  5475. elif len(fj2)==0:
  5476. newDic2 = {"编号":new_b,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" %SJ_DEP}
  5477. database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
  5478. elif str(SJ_ARR) not in str(fj) or str(str(SJ_DEP)) not in str(fj2):
  5479. new_fj=SJ_ARR+fj[0][0]
  5480. newDic2 = {"附加消息": "'%s'" % new_fj}
  5481. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
  5482. new_fj2 = SJ_DEP + fj2[0][0]
  5483. newDic2 = {"附加消息": "'%s'" % new_fj2}
  5484. database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_b))
  5485. else:
  5486. if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "%s"%TaskflightinfoLabel2en[col], "航班编号='%s'" % str(a))[0][0] != row[col]:
  5487. newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %row[col]}
  5488. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
  5489. if "已安排" in row[col]:
  5490. print("有刺客")
  5491. if "SJ_DEP" not in row.keys() and "SJ_ARR" not in row.keys() and sjry !="" :
  5492. newDic2 = {"随机" : "''" }
  5493. database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
  5494. newDic3 = {
  5495. "警告信息": "[%s]任务派工模块:%s %s取消,请核对FOC" % (flightdate, row["ACNO"], sjry),
  5496. "航班编号": "%s" % str(a), "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
  5497. "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "", "提示内容": ""}
  5498. database.lazyInsertData('logs', newDic3)
  5499. database.FunctionCommit()
  5500. starttime=(nowDayStr_search - datetime.timedelta(days=7)).strftime("%Y-%m-%d %H:%M:%S")
  5501. endtime = (nowDayStr_search + datetime.timedelta(days=7)).strftime("%Y-%m-%d %H:%M:%S")
  5502. tasknuminworjoblist=database.getSingledata("任务编号",'workjob')
  5503. tasknums=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),'*', "工作包 !=''")
  5504. if len(tasknums) != 0:
  5505. for i in tasknums:
  5506. if i[21] not in str(tasknuminworjoblist) and len(database.queryTabel('flightinfo{}'.format(nowDayStr), '机型', "航班编号 ='%s'"%i[0])) != 0:
  5507. flighttype = database.queryTabel('flightinfo{}'.format(nowDayStr), '机型', "航班编号 ='%s'"%i[0])[0][0]
  5508. workjoblist=i[18][:-1]
  5509. #print(workjoblist)
  5510. newdic3={"任务编号":"%s"%i[21],"工作包编号":"%s"%workjoblist,"查询开始时间":"%s"%starttime,"查询结束时间":"%s"%endtime,"开始时间":"","基地":"","项目描述":"","工作步骤":"","机号":"%s"%i[1],"机型":"%s"%flighttype,"航班类型":"%s"%zydy_simple[i[3]]}
  5511. database.lazyInsertData('workjob', newdic3)
  5512. #返回一个数值去查询
  5513. if i[21] in str(tasknuminworjoblist):
  5514. if i[18][:-1] != database.queryTabel('workjob','工作包编号', "任务编号 ='%s'"%i[21])[0][0]:
  5515. newdic = {"工作包编号": "'%s'" % i[18][:-1],"开始时间":"''","基地":"''","项目描述":"''","工作步骤":"''"}
  5516. database.lazyUpdateItem('workjob', newdic, "任务编号='%s'" % i[21])
  5517. database.FunctionCommit()
  5518. except Exception:
  5519. database.FunctionCommit()
  5520. print(traceback.format_exc())
  5521. dingding_alert(traceback.format_exc())
  5522. def insertWorkjob(database:flightDB,workjobdata,taskid):
  5523. try:
  5524. A=["MDTITLE_C","WORKSTEP","BASE_CODE","PLANSTD"]
  5525. num=1
  5526. MDTITLE_C=""
  5527. WORKSTEP=""
  5528. PLANSTD=""
  5529. BASE_CODE_now=""
  5530. if len(workjobdata) != 0:
  5531. for row in workjobdata:
  5532. MDTITLE_C_now=row["MDTITLE_C"] if "MDTITLE_C" in row.keys() else ""
  5533. WORKSTEP_now = row["WORKSTEP"] if "WORKSTEP" in row.keys() else ""
  5534. BASE_CODE_now = row["BASE_CODE"] if "BASE_CODE" in row.keys() else ""
  5535. PLANSTD_now = row["PLANSTD"] if "PLANSTD" in row.keys() else ""
  5536. if MDTITLE_C !="":
  5537. MDTITLE_C=MDTITLE_C+"\n------------------------------------------------\n"+"工作包%s内容:"%num+"\n"+MDTITLE_C_now
  5538. WORKSTEP=WORKSTEP+"\n------------------------------------------------\n"+"工作包%s步骤:"%num+"\n"+WORKSTEP_now
  5539. PLANSTD=PLANSTD+"\n------------------------------------------------\n"+"工作包%s计划开始时间:"%num+"\n"+PLANSTD_now
  5540. else:
  5541. MDTITLE_C ="工作包%s内容:" % num + "\n" + MDTITLE_C_now
  5542. WORKSTEP ="工作包%s步骤:" % num + "\n" + WORKSTEP_now
  5543. PLANSTD ="工作包%s计划开始时间:" % num + "\n" + PLANSTD_now
  5544. num+=1
  5545. newdic={"基地":"'%s'"%BASE_CODE_now,"开始时间":"'%s'"%PLANSTD,"项目描述":"'%s'"%MDTITLE_C.replace("\"","*").replace("#","*").replace("\\",";").replace("\'","*").replace("/","、"),"工作步骤":"'%s'"%WORKSTEP.replace("\'","*").replace("\\",";").replace("/","、").replace("\"","*").replace("#","*")}
  5546. database.lazyUpdateItem('workjob', newdic, "任务编号='%s'" %taskid)
  5547. res={"返回值":"ok"}
  5548. database.FunctionCommit()
  5549. return res
  5550. except Exception:
  5551. dingding_alert(traceback.format_exc())
  5552. res = {"返回值": "fail"}
  5553. database.FunctionCommit()
  5554. return res
  5555. def getWorkjobInfo(database:flightDB,taskid):
  5556. try:
  5557. res={}
  5558. infos=database.queryTabel('workjob','*',"任务编号 ='%s'"%taskid)
  5559. if len(infos) != 0:
  5560. res["taskids"]=infos[0][1]
  5561. res["acno"] = infos[0][8]
  5562. res["taskType"] = infos[0][10]
  5563. res["actype"] = infos[0][9]
  5564. res["startDate"] = infos[0][2]
  5565. res["endDate"] = infos[0][3]
  5566. return res
  5567. except Exception:
  5568. dingding_alert(traceback.format_exc())
  5569. def update_Pglist(database:flightDB,datatime: str,bc:str,jsonData):
  5570. try:
  5571. nowDayStr = datatime
  5572. newdic={}
  5573. database.deleteSingledata("pglist{}".format(nowDayStr), "班次='%s'" % bc)
  5574. names=[]
  5575. for row in jsonData:
  5576. if "SHIFT" in row.keys() and row["SHIFT"]==bc and row["NAME"] not in names:
  5577. for col in row:
  5578. if col in pglistLabel2en.keys():
  5579. newdic[pglistLabel2en[col]]=row[col]
  5580. database.lazyInsertData("pglist{}".format(nowDayStr),newdic)
  5581. names = row["NAME"]
  5582. database.FunctionCommit()
  5583. except Exception:
  5584. database.FunctionCommit()
  5585. dingding_alert(traceback.format_exc())
  5586. def judge_bc():
  5587. try:
  5588. nowDay = datetime.date.today().strftime("%Y%m%d")
  5589. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  5590. #nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  5591. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  5592. a_str = nowDay_str2 + " 09:00:00"
  5593. b_str = nowDay_str2 + " 20:30:00"
  5594. a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  5595. b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
  5596. nowtime = datetime.datetime.now()
  5597. if a < nowtime < b:
  5598. date=nowDay
  5599. bc="A"
  5600. elif b < nowtime:
  5601. date = nowDay
  5602. bc = "B"
  5603. elif nowtime < a:
  5604. date = nowDay_1
  5605. bc = "B"
  5606. dic={"date":"%s"%date,"bc":"%s"%bc}
  5607. return dic
  5608. except Exception:
  5609. dingding_alert(traceback.format_exc())
  5610. def get_empNos_phoone(database:flightDB,name):
  5611. try:
  5612. infos={}
  5613. info=database.queryTabel('workerinfo',"*","姓名='%s'"%name)
  5614. if len(info) != 0:
  5615. infos={"工号":'%s'%info[0][0],"电话":"%s"%info[0][5]}
  5616. return infos
  5617. except Exception:
  5618. dingding_alert(traceback.format_exc())
  5619. def callon(fdb:flightDB,phonenum):
  5620. try:
  5621. now = datetime.datetime.now()
  5622. now1=datetime.datetime.now()- datetime.timedelta(seconds=5)
  5623. if phonenum !="" and phonenum !=None:
  5624. calllist = fdb.sort_queryTable2("航班编号", "Calllist", "电话 ='%s' and 接通时间 =''"%phonenum, "拨号次数", "ASC", "创建时间", "ASC")
  5625. if len(calllist) != 0:
  5626. lasttime = fdb.sort_queryTable("接通时间", "Calllist", "接通时间 !='' and 接通时间 not like '%人工%'", "接通时间", "desc")
  5627. #print("lasttime", lasttime[0][0])
  5628. if len(lasttime) == 0 or(len(lasttime) != 0 and now1 > datetime.datetime.strptime(lasttime[0][0][:19],"%Y-%m-%d %H:%M:%S")):
  5629. newdic = {"接通时间": "'%s'" % now}
  5630. fdb.upDateItem("Calllist", newdic, "航班编号='%s'" % calllist[0][0])
  5631. except Exception:
  5632. dingding_alert(traceback.format_exc())
  5633. def calltry(fdb:flightDB,ip,token):
  5634. try:
  5635. #print("calltry")
  5636. #print(ip,token)
  5637. calllist=fdb.sort_queryTable2("*","Calllist","接通时间 ='' and 拨号次数<4","拨号次数","ASC","创建时间","ASC")
  5638. if len(calllist) != 0:
  5639. phone_num=calllist[0][1]
  5640. calltime=int((fdb.queryTabel("Calllist","拨号次数","航班编号='%s'"%calllist[0][0]))[0][0])+1
  5641. newdic={"拨号次数":"%s"%calltime}
  5642. fdb.upDateItem("Calllist",newdic,"航班编号='%s'"%calllist[0][0])
  5643. try:
  5644. data = {"PHB_AutoDialNumber": phone_num,
  5645. "ReturnPage": "/contacts.htm",
  5646. "AutoDialSubmit": "submit",
  5647. "PHB_AutoDialLine": "1"
  5648. }
  5649. header = {
  5650. "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
  5651. "Connection": "keep-alive",
  5652. "Cookie": token
  5653. }
  5654. requests.post(url="http://%s/contacts.htm" % ip, data=data, headers=header)
  5655. except Exception:
  5656. dingding_alert(traceback.format_exc())
  5657. print(datetime.datetime.now(),"[数据中心]拨号失败")
  5658. except Exception:
  5659. print(traceback.format_exc())
  5660. dingding_alert(traceback.format_exc())
  5661. def calledChecked(fdb: flightDB):
  5662. try:
  5663. now=datetime.datetime.now()
  5664. now_5 = now - datetime.timedelta(minutes=8)
  5665. callist = fdb.queryTabel("Calllist", "*", "接通时间 ='' and (创建时间<'%s' or CAST(拨号次数 AS integer)>3)"%now_5)
  5666. if len(callist) != 0:
  5667. for i in callist:
  5668. if len(fdb.queryTabel("logs", "航班编号", "航班编号 ='%s' and 处理时间=''"%i[0])) == 0:
  5669. newdic = {"航班编号": "%s" %i[0], "警告信息": "%s %s超过自动联系超过8min或连续拨号超过3次无响应,请人工处理!!"%(i[4],i[3]), "信息状态": "", "提示信息": "",
  5670. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "无法联系", "显示对象": "", "提示内容": ""}
  5671. fdb.lazyInsertData('logs', newdic)
  5672. newdic1={"接通时间":"'%s推送人工处理'"%now}
  5673. fdb.lazyUpdateItem("Calllist",newdic1,"航班编号='%s'"%i[0])
  5674. fdb.FunctionCommit()
  5675. except Exception:
  5676. fdb.FunctionCommit()
  5677. dingding_alert(traceback.format_exc())
  5678. def get_empNos(database:flightDB,dict:dict):
  5679. try:
  5680. date=judge_bc()["date"]
  5681. date_str=judge_bc()["date"][0:4]+"-"+judge_bc()["date"][4:6]+"-"+judge_bc()["date"][6:]
  5682. bc = judge_bc()["bc"]
  5683. faillist=[]
  5684. WXempNos = ""
  5685. ESempNos = ""
  5686. FXempNos = ""
  5687. WX = ""
  5688. ES = ""
  5689. FX = ""
  5690. wxkey = ["工1", "工2", "工3/送1", "工4/送2"]
  5691. eskey = [ "工3/送1", "工4/送2"]
  5692. for i in wxkey:
  5693. if dict[i] != "":
  5694. aa = []
  5695. if bc == "A":
  5696. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
  5697. elif bc == "B":
  5698. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
  5699. if len(aa) != 0 and WXempNos == "":
  5700. if aa[0][0] !="":
  5701. WXempNos = str(aa[0][0])
  5702. else:
  5703. faillist.append(dict[i])
  5704. elif len(aa) != 0 and WXempNos != "":
  5705. if aa[0][0] != "":
  5706. WXempNos =WXempNos+","+str(aa[0][0])
  5707. else:
  5708. faillist.append(dict[i])
  5709. elif len(aa) == 0:
  5710. faillist.append(dict[i])
  5711. if dict[i] != "" and WX == "":
  5712. WX=dict[i]
  5713. elif dict[i] != "" and WX != "":
  5714. WX=WX+","+dict[i]
  5715. for i in eskey:
  5716. if dict[i] != "":
  5717. aa = []
  5718. if bc == "A":
  5719. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
  5720. elif bc == "B":
  5721. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
  5722. if len(aa) != 0 and ESempNos == "":
  5723. if aa[0][0] !="":
  5724. ESempNos = str(aa[0][0])
  5725. else:
  5726. faillist.append(dict[i])
  5727. elif len(aa) != 0 and ESempNos != "":
  5728. if aa[0][0] != "":
  5729. ESempNos =ESempNos+","+str(aa[0][0])
  5730. else:
  5731. faillist.append(dict[i])
  5732. elif len(aa) == 0:
  5733. faillist.append(dict[i])
  5734. if dict[i] != "" and ES == "":
  5735. ES=dict[i]
  5736. elif dict[i] != "" and ES != "":
  5737. ES=ES+","+dict[i]
  5738. if dict["放行"] != "":
  5739. aa = []
  5740. if bc == "A":
  5741. aa=database.queryTabel("pglist{}".format(date),"工号","班次='A' and 姓名='%s'"%dict["放行"])
  5742. elif bc == "B":
  5743. aa=database.queryTabel("pglist{}".format(date),"工号","班次='B' and 姓名='%s'"%dict["放行"])
  5744. if len(aa) != 0 and FXempNos == "":
  5745. if aa[0][0] != "":
  5746. FXempNos = str(aa[0][0])
  5747. else:
  5748. faillist.append(dict["放行"])
  5749. elif len(aa) != 0 and FXempNos != "":
  5750. if aa[0][0] != "":
  5751. FXempNos = FXempNos + "," + str(aa[0][0])
  5752. else:
  5753. faillist.append(dict["放行"])
  5754. elif len(aa) == 0:
  5755. faillist.append(dict["放行"])
  5756. FX=dict["放行"]
  5757. if WXempNos =="" and FXempNos=="" and ESempNos=="":
  5758. dict1={"code":"fail","WXempNos":"","FXempNos":"","ESempNos":"","faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
  5759. elif faillist=="":
  5760. dict1 = {"code": "ok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
  5761. elif faillist !="":
  5762. dict1 = {"code": "justok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
  5763. return dict1
  5764. except Exception:
  5765. dingding_alert(traceback.format_exc())
  5766. def dealLogs(database:flightDB,name:str,number:str):
  5767. try:
  5768. now=datetime.datetime.now()
  5769. nowDay = datetime.datetime.now()
  5770. nowDayStr = nowDay.strftime("%Y%m%d")
  5771. id=number
  5772. newdic={"处理人":"'%s'"%name,"处理时间":"'%s'"%now}
  5773. database.upDateItem('logs',newdic,"编号='%s'"%id)
  5774. except Exception:
  5775. dingding_alert(traceback.format_exc())
  5776. def mandealAllLogs(database:flightDB,name:str,mode):
  5777. try:
  5778. if mode =="norm":
  5779. now=datetime.datetime.now()
  5780. clear=database.queryTabel('logs',"编号","警告信息 !='' and 处理时间 ='' and 变更字段 !='人工待办' and 变更字段 !='准备组任务' ")
  5781. newdic = {"处理人": "'%s'" % name, "处理时间": "'%s'" % now,"信息状态":"'人工一键处理'"}
  5782. if len(clear) != 0:
  5783. for i in clear:
  5784. database.lazyUpdateItem('logs',newdic,"编号='%s'"%i[0])
  5785. elif mode == "super":
  5786. now = datetime.datetime.now()
  5787. clear = database.queryTabel('logs', "编号", "警告信息 !='' and 处理时间 ='' and 变更字段 !='人工待办'")
  5788. newdic = {"处理人": "'%s'" % name, "处理时间": "'%s'" % now, "信息状态": "'人工一键处理'"}
  5789. if len(clear) != 0:
  5790. for i in clear:
  5791. database.lazyUpdateItem('logs', newdic, "编号='%s'" % i[0])
  5792. database.FunctionCommit()
  5793. except Exception:
  5794. dingding_alert(traceback.format_exc())
  5795. database.FunctionCommit()
  5796. def getFlightData(database:flightDB,*args):
  5797. try:
  5798. nowDay = datetime.datetime.now()
  5799. nowDayStr = nowDay.strftime("%Y%m%d")
  5800. if args!=():
  5801. flightData = database.getAlldata('flightinfo{}'.format(args[0]))
  5802. else:
  5803. flightData = database.getAlldata('flightinfo{}'.format(nowDayStr))
  5804. return flightData
  5805. except Exception:
  5806. dingding_alert(traceback.format_exc())
  5807. def getSortFlightdata(fdb:flightDB, datatime:str,tablename:str):
  5808. try:
  5809. nowDayStr = datatime
  5810. sortData = fdb.sortTable('{}{}'.format(tablename,nowDayStr), '级别,保障时间','asc')
  5811. return sortData
  5812. except Exception:
  5813. dingding_alert(traceback.format_exc())
  5814. if __name__ == '__main__':
  5815. fdb = flightDB(host=host,
  5816. port=port,
  5817. user=user,
  5818. password=password,
  5819. database=databaseflightDB4
  5820. )
  5821. loginDB = flightDB(host=host,
  5822. port=port,
  5823. user=user,
  5824. password=password,
  5825. database=databaseflightDB4
  5826. )