123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177 |
- import concurrent.futures
- import datetime
- import psycopg2
- from pypinyin import pinyin, Style
- import traceback
- import openpyxl
- import msoffcrypto
- import io
- import requests
- import json
- import time
- import hmac
- import hashlib
- import base64
- import urllib.parse
- from openpyxl import Workbook
- from Functions import utils
- from unitls.settings import DBServer, loginDB, flightDB4
- host, port, user, password,online_host, online_port, online_user,online_password = DBServer()
- databaseloginDB=loginDB()
- databaseflightDB4=flightDB4()
- zydy_simple={"FLIGHT_ID":"航班编号","flightIds":"航班编号对","ACNO": "机号", "ACTYPE": "机型", "ENG_TYPE": "发动机", "FLIGHT_NO": "保障航班号",
- "STA": "计划到达", "ETA": "预计到达","DEP_CH":"进港机场","DEP_CH1":"离港机场","ARR_DEP":"进出港航班号","FLIGHT_DATE":"航班日期",
- "TASKTYPE": "航班类型","FLIGHT_STATUS":"航班状态","STD": "预计起飞","ATA": "实际到达","ATD": "实际起飞","TD": "预计起飞",
- "BAY1": "预计机位", "BAY_2": "进港机位", "BAY2": "预计机位", "BAY": "离港机位","WXRY": "维修人员", "FXRY": "放行人员",
- "TASKSTS": "维修状态","ZY_FLIGHT": "重要航班", "SJ": "随机","BL": "保留", "FLG_VR": "备降返航", "TASKSTS_TIME":"维修状态时间",
- "AP": "航前", "TR": "短停", "AF": "航后","TAF": "特航前","":"未显示","短停":"短停","ECSJRY":"二送人员","TASKSTS_ECSJ":"二送状态","FJ":"附加消息","CANCELID":"取消标志"}
- zydy = {"FLIGHT_ID":"航班编号","flightIds":"航班编号对","ACNO": "机号", "ACTYPE": "机型", "ENG_TYPE": "发动机", "FLIGHT_NO": "保障航班号",
- "STA": "非航前计划到达", "ETA": "非航前预计到达","DEP_CH":"进港机场","DEP_CH1":"离港机场","ARR_DEP":"进出港航班号","FLIGHT_DATE":"航班日期",
- "TASKTYPE": "航班类型","FLIGHT_STATUS":"航班状态","STD": "航前预计起飞","ATA": "非航前实际到达","ATD": "航前实际起飞","TD": "非航前预计起飞",
- "BAY1": "非航前预计进港机位", "BAY_2": "非航前进港机位", "BAY2": "航前预计离港机位", "BAY": "航前离港机位","WXRY": "维修人员", "FXRY": "放行人员",
- "TASKSTS": "维修状态","ZY_FLIGHT": "重要航班", "SJ": "随机","BL": "保留", "FLG_VR": "备降返航", "TASKSTS_TIME":"维修状态时间",
- "AP": "航前", "TR": "短停", "AF": "航后","TAF": "特航前","":"未显示","短停":"短停","ECSJRY":"二送人员","TASKSTS_ECSJ":"二送状态","FJ":"附加消息","CANCELID":"取消标志"}
- sortLabel=["编号","航班编号","保障时间","航班类型","航班日期","级别"]
- logsLabel=["编号","航班编号","警告信息","信息状态","提示信息","产生时间","处理人","处理时间","变更字段","显示对象","提示内容"]
- changestsLabel=["航班编号","航班编号对","机号","发动机","机型","保障航班号","进港机场","离港机场","进出港航班号","航班日期","航班状态",
- "航班类型","非航前计划到达","航前预计起飞","非航前实际到达","航前实际起飞","非航前预计到达","非航前预计起飞","非航前预计进港机位",
- "非航前进港机位","航前预计离港机位","航前离港机位","维修人员","放行人员","维修状态","重要航班","随机","保留","备降返航","维修状态时间"]
- workloadLabel=["编号","机号","机位","航班编号","开始时间","结束时间","保障日期","航班类型","人员状态"]
- workerinfoLabel=["工号","姓名","部门","岗位","通行证","电话","年限","川航授权","南航授权","试车授权","星级","籍贯"] #待持续更新
- authorityLabel=["编号","用户名","密码","权限","使用人"]
- taskLabel=["编号","时间","提示内容","详细信息"]
- RiskLabel=["风险编号","状态","提示内容","触发条件1","触发条件2","触发条件3","触发条件4","触发条件5"]
- workjobkeyLabel=["任务编号","工作包编号","查询开始时间","查询结束时间","开始时间","基地","项目描述","工作步骤","机号","机型","航班类型"]
- flightstsLabel=["航班编号","机号","机位","接机到位","放行","销子夹板","随机到位","二送到位","接机已到位提示","已放行提示","销子夹板已提示","随机已到位提示","二送已到位提示","天府飞机"]
- flightinfoLabel=["航班编号","航班编号对","机号","发动机","机型","保障航班号","进港机场","离港机场","进出港航班号","航班日期","航班状态",
- "航班类型","非航前计划到达","航前预计起飞","非航前实际到达","非航前预计到达","航前实际起飞","非航前预计起飞","非航前预计进港机位",
- "非航前进港机位","航前预计离港机位","航前离港机位","维修人员","放行人员","维修状态","重要航班","随机","保留","备降返航","维修状态时间","二送人员","二送状态","附加消息","取消标志"]
- trackLabel=["单号","创建时间","类型","清单","紧急程度","创建人","派送地址","接收人","库管开始","库管派发","领料地址",
- "金熊猫接收","金熊猫到位","配送到位","签收人","备注信息","一","二","三","四","五","六","七","八"]
- enflightifnoLabel=["FLIGHT_ID","flightIds","ACNO","ENG_TYPE","ACTYPE","FLIGHT_NO","DEP_CH","DEP_CH1","ARR_DEP","FLIGHT_DATE","FLIGHT_STATUS",
- "TASKTYPE","STA","STD","ATA","ETA","ATD","TD","BAY1","BAY_2","BAY2","BAY","WXRY","FXRY","TASKSTS","ZY_FLIGHT",
- "SJ","BL","FLG_VR","TASKSTS_TIME","ECSJRY","TASKSTS_ECSJ","FJ","CANCELID"]
- TaskflightinfoLabel=["航班编号","机号","航班日期","航班类型","非航前计划到达","航前预计起飞","非航前实际到达","航前实际起飞","非航前预计到达","预飞预达",
- "非航前进港机位","航前离港机位","维修人员","放行人员","维修状态","随机","保留","维修状态时间","工作包","二次送机","进出港航班号","任务编号"]#重要航班和备降返航有待研究
- TaskflightinfoLabel2en={"ACNO":"机号","FLIGHTDATE":"航班日期","TASKTYPE":"航班类型","STA":"非航前计划到达","STD":"航前预计起飞","ATA":"非航前实际到达","ATD":"航前实际起飞","ETA":"非航前预计到达","TA_TD":"预飞预达",
- "BAY_A":"非航前进港机位","BAY_B":"航前离港机位","WX":"维修人员","FX":"放行人员","TASKSTS":"维修状态","SJ_DEP":"随机","SJ_ARR":"随机",
- "BL":"保留","TASKSTS_TIME":"维修状态时间","FJ_TASKIDS":"工作包","ECSJ":"二次送机","FNO":"进出港航班号","TASKID":"任务编号"}
- #'''"FLIGHTID1":"航班编号","FLIGHTID2":"航班编号",'''
- #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"]
- displayLabel=["ID","A","B"]
- peopleScheduleLabel=["编号","航班编号","显示模式","放行","勤务1","勤务2","工1","工2","工3","附加消息"]
- CalllistLabel=["航班编号","电话","工号","姓名","航班号","附加消息","拨号次数","创建时间","接通时间"]
- rowlistLabel={10:"放行",11:"勤务1",12:"勤务2",13:"工1",14:"工2",15:"工3",-1:"附加消息"}
- pglistLabel=["姓名","工号","角色","班次"]
- pglistLabel2en={"NAME":"姓名","EMP_NO":"工号","MAINLY_ROLE":"角色","SHIFT":"班次"}
- ecsjtaskSTS={"":"空值","0":"空值",'5':'二送任务待确认', '10':'二送任务已确认', '15':'二送到位',"20":"二送离场"}
- #headerLabel = utils.headerLabel
- #headerLabelKey=utils.headerLabelKey
- headerLabel = flightinfoLabel
- headerLabelKey=enflightifnoLabel
- taskType = utils.taskType
- taskSTS = utils.taskSTS
- flightSTS = utils.flightSTS
- flightSTSDic = utils.flightSTSDic
- class flightDB():
- def __init__(self, host, port, user, password, database):
- self.conn = psycopg2.connect(
- host=host,
- port=port,
- user=user,
- password=password,
- database=database
- )
- self.c = self.conn.cursor()
- def initTable(self, tableName:str,primarykey:str,primarykeyStr:str,keyDict:dict):
- try:
- keyStr = ''
- num = 1
- for key in keyDict:
- if num !=len(keyDict):
- keyStr += '{} {},\n'.format(key,keyDict[key])
- else:
- keyStr += '{} {}'.format(key, keyDict[key])
- num +=1
- curStr ="""
- create table if not exists {} (
- {} {} ,
- {}
- )
- """.format(tableName, primarykey, primarykeyStr,keyStr)
- #print(curStr)
- self.c.execute(curStr)
- self.conn.commit()
- except Exception:
- #print(curStr)
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def insertData(self, tableName:str, data:dict, *args):
- try:
- #curStr1 = 'insert into {} '.format(tableName)
- num = 1
- curStr2 = ''
- for key in data:
- if num != len(data):
- curStr2+='{},'.format(key)
- else:
- curStr2+='{}'.format(key)
- num+=1
- curStr3 = ''
- num = 1
- for key in data:
- if num != len(data):
- curStr3+="'{}',".format(data[key])
- else:
- curStr3+="'{}'".format(data[key])
- num+=1
- curStr = """
- insert into {} ({})
- values ({})
- """.format(tableName, curStr2, curStr3)
- #print(curStr)
- self.c.execute(curStr)
- if args==():
- self.conn.commit()
- except Exception:
- print(traceback.format_exc())
- #print(curStr)
- #dingding_alert(traceback.format_exc())
- def lazyInsertData(self,tableName:str, data:dict):
- self.insertData(tableName, data, 'lazy')
- def lazydeleteTable(self,tablename:str):
- curStr = """delete from {}""".format(tablename)
- self.c.execute(curStr)
- def lazyInsertData2(self,tableName:str, curStr2, curStr3):
- curStr = """insert into {} ({})values {}""".format(tableName, curStr2, curStr3)
- self.c.execute(curStr)
- #print(curStr)
- def lazyInsertData3(self,curStr1, curStr2, curStr3):
- curStr = """insert into display (ID, A, B)values (%s,'%s','%s')"""%(curStr1, curStr2, curStr3)
- self.c.execute(curStr)
- #print(curStr)
- def FunctionCommit(self):
- self.conn.commit()
- def FunctionRollback(self):
- self.conn.rollback()
- def deleteTable(self, tablename:str, *condition:str):
- try:
- #print(condition)
- if condition !=():
- curStr = """
- delete from {} where {}
- """.format(tablename, condition[0])
- else:
- curStr = """
- delete from {}
- """.format(tablename)
- self.c.execute(curStr)
- self.conn.commit()
- return "ok"
- except Exception:
- dingding_alert(traceback.format_exc())
- dingding_alert(curStr)
- return "fail"
- def copyTable(self, oldtablename:str, newTablename:str):
- try:
- curStr = """
- drop table {}
- """.format(newTablename)
- self.c.execute(curStr)
- self.conn.commit()
- except Exception:
- dingding_alert(traceback.format_exc())
- dingding_alert(curStr)
- def sortTable(self, tablename:str, tableKey:str, fn):
- try:
- curStr = """
- select * from {} order by {} {}
- """.format(tablename, tableKey, fn)
- #print(curStr)
- self.c.execute(curStr)
- return self.c.fetchall()
- except Exception:
- dingding_alert(traceback.format_exc())
- def sort_queryTable(self, findkey:str,tablename:str, condition:str,tableKey:str, fn):
- try:
- curStr = """
- select {} from {} where {} order by {} {}
- """.format(findkey,tablename, condition,tableKey, fn)
- #print(curStr)
- self.c.execute(curStr)
- return self.c.fetchall()
- except Exception:
- dingding_alert(traceback.format_exc())
- dingding_alert(curStr)
- def sort_queryTable2(self, findkey:str,tablename:str, condition:str,tableKey:str, fn,tableKey1:str, fn1):
- try:
- curStr = """
- select {} from {} where {} order by {} {},{} {}
- """.format(findkey,tablename, condition,tableKey, fn,tableKey1, fn1)
- #print(curStr)
- self.c.execute(curStr)
- return self.c.fetchall()
- except Exception:
- dingding_alert(traceback.format_exc())
- dingding_alert(curStr)
- def queryTabel(self, tablename:str, key:str, condition:str):
- try:
- curStr1 = """
- SELECT EXISTS (
- SELECT * FROM pg_catalog.pg_tables
- WHERE tablename = '{}' AND schemaname = 'public'
- );
- """.format(tablename.lower())
- self.c.execute(curStr1)
- result = self.c.fetchall()[0][0]
- if result:
- curStr = """
- select {} from {} where {}
- """.format(key, tablename, condition)
- #print(curStr)
- self.c.execute(curStr)
- return self.c.fetchall()
- else:
- return None
- except Exception:
- print(traceback.format_exc())
- #print(curStr)
- #dingding_alert(traceback.format_exc())
- #dingding_alert(curStr)
- self.conn.rollback()
- def getAlldata(self, tablename:str):
- try:
- curStr = """select * from {}""".format(tablename)
- self.c.execute(curStr)
- return self.c.fetchall()
- except Exception:
- dingding_alert(traceback.format_exc())
- dingding_alert(curStr)
- def upDateItem(self, tablename:str, dateDic:dict, condition:str, *args):
- try:
- setStr = ''
- for key in dateDic:
- if tablename == 'display':
- setStr += '{}={},'.format(key, str(dateDic[key]).replace("'","''"))
- else:
- setStr += '{}={},'.format(key, dateDic[key])
- if tablename == 'display':
- setStr = setStr[:-1].replace('"',"'")
- else:
- setStr = setStr[:-1]
- curStr = """
- update {} set {} where {}
- """.format(tablename, setStr, condition)
- #print(curStr)
- if setStr !="":
- self.c.execute(curStr)
- if args == ():
- self.conn.commit()
- except Exception:
- print(traceback.format_exc())
- #print(curStr)
- dingding_alert(traceback.format_exc())
- def lazyUpdateItem(self,tablename:str, dateDic:dict, condition:str):
- self.upDateItem(tablename,dateDic,condition,'lazy')
- def getSingledata(self,findkey:str,tablename:str):
- try:
- curStr = """
- select {} from {}
- """.format(findkey,tablename)
- #print(curStr)
- self.c.execute(curStr)
- return self.c.fetchall()
- except Exception:
- dingding_alert(traceback.format_exc())
- def deleteSingledata(self,tablename:str,findkey:str):
- try:
- curStr = """
- delete from {} where {}
- """.format(tablename,findkey)
- self.c.execute(curStr)
- #print(curStr)
- self.conn.commit()
- except Exception:
- dingding_alert(traceback.format_exc())
- def close(self):
- try:
- self.conn.close()
- except Exception:
- dingding_alert(traceback.format_exc())
- def infoConfirm(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
- try:
- peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
- if displayMode =="A":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-A"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-A"
- elif displayMode =="B":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-B"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-B"
- peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
- newdic={}
- if len(peopleSchedule_sts) != 0:
- for i in range(3,9):
- if "√" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
- newitem=peopleSchedule_sts[0][i]+"√"
- newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
- fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
- except Exception:
- dingding_alert(traceback.format_exc())
- def infoConfirm3(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
- try:
- peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
- if displayMode =="A":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-A"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-A"
- elif displayMode =="B":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-B"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-B"
- peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
- newdic={}
- if len(peopleSchedule_sts) != 0:
- for i in range(3,9):
- if "*" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
- newitem=peopleSchedule_sts[0][i]+"*"
- newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
- fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
- except Exception:
- dingding_alert(traceback.format_exc())
- def infoConfirm2(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
- try:
- peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
- if displayMode =="A":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-A"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-A"
- elif displayMode =="B":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-B"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-B"
- peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
- newdic={}
- if len(peopleSchedule_sts) != 0:
- for i in range(3,9):
- if "!" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
- newitem="!"+peopleSchedule_sts[0][i]
- newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
- fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
- except Exception:
- dingding_alert(traceback.format_exc())
- def dingding_alert(msg):
- dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=9c78c711f14ba3345d6dc492dc5ca8118c421516d611b5de46854fb8e158565f"
- timestamp = str(round(time.time() * 1000))
- secret = 'SEC09f744f81b55c8a18f0d77a3ab60bf4e1ec3f16b85f025e6a4f75ddff00a8fd4'
- secret_enc = secret.encode('utf-8')
- string_to_sign = '{}\n{}'.format(timestamp, secret)
- string_to_sign_enc = string_to_sign.encode('utf-8')
- hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
- sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
- dingding_url = dingding_webhook + '×tamp=' + timestamp + "&sign=" + sign
- header = {
- "Content-Type": "application/json"
- }
- data = {
- "at": {
- "atMobiles":(123,456),
- # "isAtAll": True
- },
- "text": {
- "content": msg
- },
- "msgtype": "text"
- }
- res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
- def dingding_alert1(phone:list,msg):
- dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=9c78c711f14ba3345d6dc492dc5ca8118c421516d611b5de46854fb8e158565f"
- timestamp = str(round(time.time() * 1000))
- secret = 'SEC09f744f81b55c8a18f0d77a3ab60bf4e1ec3f16b85f025e6a4f75ddff00a8fd4'
- secret_enc = secret.encode('utf-8')
- string_to_sign = '{}\n{}'.format(timestamp, secret)
- string_to_sign_enc = string_to_sign.encode('utf-8')
- hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
- sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
- dingding_url = dingding_webhook + '×tamp=' + timestamp + "&sign=" + sign
- if phone:
- header = {
- "Content-Type": "application/json"
- }
- data = {
- "at": {
- "atMobiles": phone,
- },
- "text": {
- "content": msg
- },
- "msgtype": "text"
- }
- else:
- header = {
- "Content-Type": "application/json"
- }
- data = {
- "at": {
- "isAtAll": True
- },
- "text": {
- "content": msg
- },
- "msgtype": "text"
- }
- res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
- def dingding_alert11(phone:list,msg):
- dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=c3be52d9ae7307dd7ceb0b677f569c47de2ff81b20fe30c328c75fbd9ab81383"
- timestamp = str(round(time.time() * 1000))
- secret = 'SEC14f583c6f735044be3f9f6fdc53edb7cf0b7d56d9b63c4b78bcafa9880814f9e'
- secret_enc = secret.encode('utf-8')
- string_to_sign = '{}\n{}'.format(timestamp, secret)
- string_to_sign_enc = string_to_sign.encode('utf-8')
- hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
- sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
- dingding_url = dingding_webhook + '×tamp=' + timestamp + "&sign=" + sign
- if phone:
- header = {
- "Content-Type": "application/json"
- }
- data = {
- "at": {
- "atMobiles": phone,
- },
- "text": {
- "content": msg
- },
- "msgtype": "text"
- }
- else:
- header = {
- "Content-Type": "application/json"
- }
- data = {
- "at": {
- "isAtAll": True
- },
- "text": {
- "content": msg
- },
- "msgtype": "text"
- }
- res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
- def maintainAuthCheck(fdb:flightDB,name,flighttype):
- search=fdb.queryTabel("workerinfo","姓名","姓名 = '{}' and 南航授权 like '%{}%'".format(name,flighttype))
- if search ==None or len(search) !=0:
- res = {"返回值":"ok"}
- else:
- res = {"返回值": "fail"}
- return res
- def checkLoadSingal(wdb:flightDB,worknum,time,time2):
- try:
- table="workload"+str(worknum)
- #peopleLabel = ["序号", "保障日期", "类型", "机号", "机位", "开始时间", "结束时间"]
- LoadSingals={}
- res = wdb.sort_queryTable2("*", table, "保障日期='%s' or 保障日期='%s'"%(time,time2), "保障日期", "desc", "结束时间", "ASC")
- j=0
- if len(res) != 0:
- for i in res:
- LoadSingal = {}
- LoadSingal["序号"]=j
- LoadSingal["保障日期"] = i[6][0:10]
- if i[0][-1]=="1" and (i[7]=="特后前" or i[7]=="短停"):
- LoadSingal["类型"] = i[7]+"接机"
- elif i[0][-1]=="2" and (i[7]=="特后前" or i[7]=="短停"):
- LoadSingal["类型"] = i[7] + "送机"
- else:
- LoadSingal["类型"] = i[7]
- LoadSingal["机号"] = i[1]
- LoadSingal["机位"] = i[2]
- LoadSingal["开始时间"] = i[4]
- LoadSingal["结束时间"] = i[5]
- LoadSingals[j]=LoadSingal
- j += 1
- #print(LoadSingals)
- return LoadSingals
- except Exception:
- dingding_alert(traceback.format_exc())
- def changepassword(user,old,new):
- try:
- loginTabledb =flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseloginDB
- )
- newdic={"密码":"'%s'"%new}
- loginTabledb.upDateItem("loginTable",newdic,"登录名='%s' and 密码='%s'"%(user,old))
- loginTabledb.close()
- except Exception:
- dingding_alert(traceback.format_exc())
- def qtPeopleLoad(fdb:flightDB,workLoad:flightDB,bc:str,nowDaystr:str):
- try:
- qtPeopleLoad={}
- aa=[]
- selectdaystr = str(nowDaystr)[0:4] + "-" + str(nowDaystr)[4:6] + "-" + str(nowDaystr)[6:] + " 00:00:00"
- selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
- selectday_2 = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(days=1)
- nowDay = datetime.date.today().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowtime = datetime.datetime.now()
- nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
- a_str = nowDay_str2 + " 00:00:00"
- b_str = nowDay_str2 + " 17:00:00"
- a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
- b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
- nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
- tomorrow_search = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- if bc == "A":
- pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
- elif bc == "B" and nowDaystr == nowDay and a < nowtime < b:
- pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
- elif bc == "B" and nowDaystr == nowDay and b < nowtime:
- pglist_str = fdb.queryTabel("pglist{}".format(nowDay), "*", "班次='%s'" % bc)
- elif bc == "B" and nowDaystr == nowDay_1:
- pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
- elif bc == "B" and nowDaystr < nowDay_1:
- pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
- else:
- pglist_str = []
- diplaylist = pglist_str
- # peopleLabel = ["序号", "姓名", "角色", "总量", "当前", "最后时间"]
- rowNum = 0
- JS = ""
- workload = []
- workload_now = ""
- lastone=""
- for row in diplaylist:
- col={}
- if len(fdb.queryTabel('workerinfo', "*", "姓名='%s'" % row[0])) != 0:
- workload = []
- workload_now = []
- if bc == "A":
- workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and 保障日期='%s'" % nowDayStr_search)
- workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and 保障日期='%s'" % nowDayStr_search))
- elif bc == "B" and nowDaystr == nowDay and a < nowtime < b: # 选择今天00900之前的夜班
- workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search))
- workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search)))
- elif bc == "B" and nowDaystr == nowDay and b < nowtime:
- workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, tomorrow_search))
- workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, tomorrow_search)))
- elif bc == "B" and nowDaystr == nowDay_1: # 选择今天之前的夜班
- workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search))
- workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search)))
- elif bc == "B" and nowDaystr < nowDay_1: # 选择今天之前的夜班
- workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (selectday, selectday_2))
- workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*", "结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (selectday, selectday_2)))
- time = []
- lastone = ""
- for j in workload:
- time.append(j[4])
- time.append(j[5])
- if len(time) != 0:
- lastone = time[0]
- for i in range(1, len(time) - 1):
- if lastone < time[i]:
- lastone = time[i]
- lastone = lastone[-8:-3]
- if row[2] == "WX":
- JS = "维修员"
- elif row[2] == "FX":
- JS ="放行"
- col={"序号":rowNum,"姓名":row[0],"角色":JS,"总量":str(len(workload)),"当前":str(workload_now),"最后时间":lastone,}
- aa.append(col)
- rowNum += 1
- if len(aa) != 0:
- #aa.sort(key=lambda x:(x["角色"],x['最后时间'],x['当前'],x['总量']))
- aa.sort(key=lambda x: (x["角色"], x['当前'], x['最后时间'], x['总量']))
- #print(aa)
- rowNum1=0
- for i in aa:
- i["序号"]=rowNum1
- qtPeopleLoad[rowNum1]=i
- rowNum1 += 1
- #print(qtPeopleLoad)
- return qtPeopleLoad
- except Exception:
- dingding_alert(traceback.format_exc())
- def updateDragDropItem(fdb:flightDB,column,text,flightid,displayMode,flighttype,selectedtime):
- try:
- flightid_new=""
- if displayMode =="A":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-A"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-A"
- elif displayMode =="B":
- if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-B"
- elif flighttype =="航前":
- flightid_new = flightid + "-2" + "-B"
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
- newdic = {}
- if str(flightid_new) not in str(flightids_in_peopleSchedule) and str(flightid_new) !="":
- newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
- for i in rowlistLabel.keys():
- if i == int(column):
- if text != "清空项目12345678987654321":
- newdic[rowlistLabel[i]] = text
- else:
- newdic[rowlistLabel[i]] = ""
- else:
- newdic[rowlistLabel[i]] = ""
- fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
- else:
- if text != "清空项目12345678987654321":
- newdic[rowlistLabel[int(column)]]="'%s'"%text
- else:
- newdic[rowlistLabel[int(column)]]="''"
- fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
- except Exception:
- dingding_alert(traceback.format_exc())
- def updateEidteItem(fdb:flightDB,text,flightid,displayMode,flighttype,selectedtime):
- try:
- if displayMode =="A":
- if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-A"
- elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
- flightid_new = flightid + "-2" + "-A"
- elif displayMode =="B":
- if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
- flightid_new=flightid+"-1"+"-B"
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
- newdic = {}
- if str(flightid_new) not in str(flightids_in_peopleSchedule):
- newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
- for i in rowlistLabel.keys():
- if i == -1:
- if text !="清空项目12345678987654321":
- newdic[rowlistLabel[i]]=text
- else:
- newdic[rowlistLabel[i]] = ""
- else:
- newdic[rowlistLabel[i]] = ""
- fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
- else:
- if text != "清空项目12345678987654321":
- newdic[rowlistLabel[int(-1)]]="'%s'"%text
- else:
- newdic[rowlistLabel[int(-1)]]="''"
- fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
- except Exception:
- dingding_alert(traceback.format_exc())
- def checkPglist(fdb:flightDB,name,selectedtime,bc):
- try:
- list=["1","2","3","4","5","6","7","8","9","10","11","12"]
- if name != "清空项目12345678987654321" and str(name) not in list:
- time2=datetime.datetime.strptime(selectedtime,"%Y%m%d")
- time1=str((time2 - datetime.timedelta(days=1)).strftime("%Y%m%d"))
- check=fdb.queryTabel("pglist{}".format(selectedtime), "工号", "班次='%s' and 姓名='%s'" % (bc,name))
- check2 = fdb.queryTabel("pglist{}".format(time1), "工号", "班次='%s' and 姓名='%s'" % (bc, name))
- if len(check) == 0 and len(check2) == 0:
- res="NO"
- else:
- res="YES"
- elif str(name) in list:
- res = "YES"
- else:
- res = "YES"
- return res
- except Exception:
- dingding_alert(traceback.format_exc())
- def mapDispaly(fdb:flightDB,selectedtime):
- try:
- mapDispalydata = {}
- nowDayStr = selectedtime
- sorttable = fdb.queryTabel("sortFlight{}".format(nowDayStr),"*","CAST(级别 AS integer)='1' or CAST(级别 AS integer)='3'")
- #{机位:[机号,机型,发动机,航班类型,航班号,ta,td,进港机场,出港机场,状态,放行,维修人员,二送人员,保留,工作包,TASKID,flightid,color,备注]}
- for row in sorttable:
- # print(row)
- otheroneSts = []
- flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
- if flightinfodata[11] == "短停":
- iddd=row[1]+"-1"
- iddddd = row[1] + "-2"
- jfjSts= fdb.queryTabel("sortFlight{}".format(nowDayStr),"级别","编号='%s'"%iddd)[0][0]
- sfjSts = fdb.queryTabel("sortFlight{}".format(nowDayStr), "级别", "编号='%s'" % iddddd)[0][0]
- # print(otheroneSts)
- if (flightinfodata[11] =="航前" and flightinfodata[21] !="") or (flightinfodata[11] !="航前" and flightinfodata[19] !=""):
- TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
- if flightinfodata[11] == "航前" and flightinfodata[21] != "":
- bay=flightinfodata[21]
- color="#99CCCC"
- elif flightinfodata[11] == "航后" and flightinfodata[19] != "" and row[5]=="3":
- bay = flightinfodata[19]
- color = "#0095d9"
- elif flightinfodata[11] == "停场" and flightinfodata[19] != "" and row[5]=="3":
- bay = flightinfodata[19]
- color = "#0095d9"
- elif flightinfodata[11] == "航后" and flightinfodata[19] != "" and row[5]=="1":
- bay = "Y"+flightinfodata[19]
- color = "#f6ad49"
- elif flightinfodata[11] == "特后前" and flightinfodata[19] != "" and flightinfodata[14] == "":
- bay = "Y"+flightinfodata[19]
- color = "#f6ad49"
- elif flightinfodata[11] == "特后前" and flightinfodata[19] != "" and flightinfodata[14] != "":
- bay = flightinfodata[19]
- color = "#4c6cb3"
- elif flightinfodata[11] == "短停" and flightinfodata[19] != "" and jfjSts=="1":
- bay = "Y"+flightinfodata[19]
- color = "#f6ad49"
- elif flightinfodata[11] == "短停" and flightinfodata[19] != "" and jfjSts=="4" and sfjSts=="1":
- bay = flightinfodata[19]
- color = "#69b076"
- acno=flightinfodata[2]
- airpalneType=flightinfodata[4]
- EngType=flightinfodata[3]
- flightType = flightinfodata[11]
- flightNos = flightinfodata[8]
- DEP_CH=flightinfodata[6] #进港机场
- DEP_CH1=flightinfodata[7] #出港机场
- flightsts = flightinfodata[10]
- wx=flightinfodata[22]
- fx = flightinfodata[23]
- es = flightinfodata[30]
- flightid=flightinfodata[0]
- message=flightinfodata[32]
- e = "" #保留
- F = ""#工作包
- g = "" #taskid
- ta = ""
- td=""
- if len(TaskFlightinfo) != 0:
- if TaskFlightinfo[0][16] != "":
- e = "有保留"
- if TaskFlightinfo[0][18] != "":
- F = "有工作包"
- if TaskFlightinfo[0][21] != "":
- g = TaskFlightinfo[0][21]
- if "-" not in TaskFlightinfo[0][9].split('</br>')[0]:
- ta = TaskFlightinfo[0][9].split('</br>')[0]
- if "-" not in TaskFlightinfo[0][9].split('</br>')[1]:
- td = TaskFlightinfo[0][9].split('</br>')[1]
- if "CZ" in str(flightNos) or "OQ" in str(flightNos):
- nanhang="1"
- elif "3U" not in str(flightNos) or "CSC" not in str(flightNos):
- nanhang = "0"
- else:
- nanhang = "3"
- mapDispalydata[bay] = {"机号":acno,
- "机型":airpalneType,
- "发动机":EngType,
- "航班类型":flightType,
- "航班号":flightNos,
- "到达":ta,
- "起飞":td,
- "进港机场":DEP_CH,
- "出港机场":DEP_CH1,
- "状态":flightsts,
- "放行":fx,
- "维修人员":wx,
- "二送人员":es,
- "保留":e,
- "工作包":F,
- "TASKID":g,
- "flightid":flightid,
- "color":color,
- "备注":message,
- "南航":nanhang
- }
- return mapDispalydata
- except Exception:
- dingding_alert(traceback.format_exc())
- def postgresql_local(local:flightDB,host_online, port_online, user_online, password_online, database_online):
- print(datetime.datetime.now(), "[同步中心]开始同步数据库")
- today = datetime.datetime.now().strftime('%Y%m%d')
- yesterday=(datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y%m%d')
- tomorrow=(datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y%m%d')
- online=flightDB(host_online, port_online, user_online, password_online, database_online)
- table_colmuns={"flightinfo%s"%today:flightinfoLabel,"flightinfo%s"%yesterday:flightinfoLabel,"flightinfo%s"%tomorrow:flightinfoLabel,
- "peopleschedule%s"%today:peopleScheduleLabel,"peopleschedule%s"%yesterday:peopleScheduleLabel,"peopleschedule%s"%tomorrow:peopleScheduleLabel,
- "sortflight%s"%today:sortLabel,"sortflight%s"%yesterday:sortLabel,"sortflight%s"%tomorrow:sortLabel,
- "display":displayLabel}
- dbtables=["flightinfo%s"%today,"flightinfo%s"%yesterday,"flightinfo%s"%tomorrow,
- "peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,
- "sortflight%s"%today,"sortflight%s"%yesterday,"sortflight%s"%tomorrow,"display"]
- try:
- tablesok=""
- tablenum=0
- for dbtable in dbtables:
- try:
- Dic = {}
- primaryKey2 = 'text'
- for key in list(table_colmuns[dbtable])[1:]:
- Dic[key] = 'text'
- online.initTable(dbtable, table_colmuns[dbtable][0], primaryKey2, Dic)
- all_source_data=local.getAlldata(dbtable)
- if len(all_source_data)!=0:
- online.lazydeleteTable(dbtable)
- if dbtable=="display":
- dispaly_res=online.getSingledata("A", 'display')
- if dispaly_res == None or len(dispaly_res) == 0:
- online.insertData('display', {'ID': 1, 'A': '{}', 'B': '{}'})
- online.insertData('display', {'ID': 2, 'A': '{}', 'B': '{}'})
- online.insertData('display', {'ID': 3, 'A': '{}', 'B': '{}'})
- for row in all_source_data:
- newdic = {"A": '"{}"'.format(row[1]),"B": '"{}"'.format(row[2])}
- online.lazyUpdateItem(dbtable, newdic, "ID = '%s'"%row[0])
- #online.FunctionCommit()
- else:
- for row in all_source_data:
- online.lazyInsertData2(dbtable,', '.join(table_colmuns[dbtable]),row)
- online.FunctionCommit()
- tablesok=tablesok+dbtable+"/"
- tablenum+=1
- except :
- print(traceback.format_exc())
- continue
- print(datetime.datetime.now(), "[同步中心]完成数据库同步(%s[%s])"%(tablesok,tablenum))
- return "ok"
- except Exception:
- print(traceback.format_exc())
- return "fail"
- def bakupdata(fdb:flightDB):
- try:
- #print("5分钟间隔自动备份")
- nowDay = str(datetime.date.today().strftime("%Y%m%d"))
- nowDay_1 = str((datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d"))
- aaa={nowDay:"今天",nowDay_1:"昨天"}
- tableWidgetDispalydatas={}
- wb = Workbook()
- for selectedtime in [nowDay,nowDay_1]:
- wb.create_sheet(title="%s"%selectedtime, index=0)
- ws = wb.active
- ws.title = "%s"%selectedtime
- ws= wb["%s"%selectedtime]
- ws.cell(1, 1).value = "序号"
- ws.cell(1, 2).value = "类型"
- ws.cell(1, 3).value = "航班号"
- ws.cell(1, 4).value = "机型"
- ws.cell(1, 5).value = "发动机"
- ws.cell(1, 6).value = "机号"
- ws.cell(1, 7).value = "计达"
- ws.cell(1, 8).value = "预达"
- ws.cell(1, 9).value = "计飞"
- ws.cell(1, 10).value = "机位"
- ws.cell(1, 11).value = "放行"
- ws.cell(1, 12).value = "工1"
- ws.cell(1, 13).value = "工2"
- ws.cell(1, 14).value = "工3"
- ws.cell(1, 15).value = "工4"
- ws.cell(1, 16).value = "工5"
- ws.cell(1, 17).value = "送1"
- ws.cell(1, 18).value = "送2"
- ws.cell(1, 19).value = "备注"
- ws.cell(1, 20).value = "接机到位"
- ws.cell(1, 21).value = "二送到位"
- ws.cell(1, 22).value = "放行情况"
- ws.cell(1, 23).value = "销子夹板"
- tableWidgetDispalydata = {}
- sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight2")
- nowDayStr = selectedtime
- '''
- col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
- "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
- "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "返航备降", "25": "维修人员",
- "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
-
- col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
- "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
- "18": "放行","19": "销夹", "17": "二送","20":"附加消息","21": "送机1", "22": "送机2"}
- '''
- rowNum = 0
- for row in sorttable:
- flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
- flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "","", "", "","", "", "","", "", "","", "", ""]
- jjdw = "√" if flightstsdata[3] != "" else ""
- FX = "√" if flightstsdata[4] != "" else ""
- XJ = "√" if flightstsdata[5] != "" else ""
- ESDW = "√" if flightstsdata[7] != "" else ""
- flighttype=flightinfodata[11] if "3U" not in str(flightinfodata[8]) and "CSC" not in str(flightinfodata[8]) else "外"+str(flightinfodata[11])
- a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
- if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
- a = flightinfodata[15][-8:-3]
- elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = flightinfodata[12][-8:-3]
- elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = ""
- elif flightinfodata[16] != "":
- a = ""
- a = str(a).split(":")[0] + str(a).split(":")[1] if a != "" else ""
- b = str(flightinfodata[15][-8:-3]).split(":")[0] + str(flightinfodata[15][-8:-3]).split(":")[1] if flightinfodata[15] != "" else ""
- c = flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
- c = str(c).split(":")[0]+ str(c).split(":")[1] if c != "" else ""
- fx = ""
- g1 = ""
- g2 = ""
- g3 = ""
- g4 = ""
- g5 = ""
- fj1 = ""
- s1 = ""
- s2 = ""
- fj2 = ""
- fj =""
- peopleSchedules = fdb.queryTabel('peopleSchedule{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])) if \
- len(fdb.queryTabel('peopleSchedule{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else [("000", "", "", "", "", "", "", "", "", "")]
- #print(peopleSchedules)
- for i in peopleSchedules:
- if i[0][-3] =="1":
- fx=i[3]
- g1=i[4]
- g2 = i[5]
- g3 = i[6]
- g4 = i[7]
- g5 = i[8]
- fj1= i[9]
- elif i[0][-3] =="2":
- s1 = i[7]
- s2 = i[8]
- fj2 = i[9]
- fj=fj1+fj2
- if flightinfodata[11] == "航后":
- ws.cell(rowNum+2, 1).value = rowNum+1
- ws.cell(rowNum+2, 2).value = flighttype
- ws.cell(rowNum+2, 3).value = flightinfodata[8]
- ws.cell(rowNum+2, 4).value = flightinfodata[4]
- ws.cell(rowNum+2, 5).value = flightinfodata[3]
- ws.cell(rowNum+2, 6).value = flightinfodata[2]
- ws.cell(rowNum+2, 7).value = a
- ws.cell(rowNum+2, 8).value = b
- ws.cell(rowNum+2, 9).value = ""
- ws.cell(rowNum+2, 10).value = flightinfodata[19]
- ws.cell(rowNum+2, 11).value = fx
- ws.cell(rowNum+2, 12).value =g1
- ws.cell(rowNum+2, 13).value = g2
- ws.cell(rowNum+2, 14).value = g3
- ws.cell(rowNum+2, 15).value = g4
- ws.cell(rowNum+2, 16).value = g5
- ws.cell(rowNum+2, 17).value = s1
- ws.cell(rowNum+2, 18).value = s2
- ws.cell(rowNum+2, 19).value = fj
- ws.cell(rowNum+2, 20).value = jjdw
- ws.cell(rowNum+2, 21).value = ""
- ws.cell(rowNum+2, 22).value = ""
- ws.cell(rowNum+2, 23).value = ""
- rowNum += 1
- elif flightinfodata[11] == "停场":
- ws.cell(rowNum + 2, 1).value = rowNum+1
- ws.cell(rowNum + 2, 2).value = flighttype
- ws.cell(rowNum + 2, 3).value = ""
- ws.cell(rowNum + 2, 4).value = flightinfodata[4]
- ws.cell(rowNum + 2, 5).value = flightinfodata[3]
- ws.cell(rowNum + 2, 6).value = flightinfodata[2]
- ws.cell(rowNum + 2, 7).value = ""
- ws.cell(rowNum + 2, 8).value = ""
- ws.cell(rowNum + 2, 9).value = ""
- ws.cell(rowNum + 2, 10).value = flightinfodata[19]
- ws.cell(rowNum + 2, 11).value = fx
- ws.cell(rowNum + 2, 12).value = g1
- ws.cell(rowNum + 2, 13).value = g2
- ws.cell(rowNum + 2, 14).value = g3
- ws.cell(rowNum + 2, 15).value = g4
- ws.cell(rowNum + 2, 16).value = g5
- ws.cell(rowNum + 2, 17).value = s1
- ws.cell(rowNum + 2, 18).value = s2
- ws.cell(rowNum + 2, 19).value = fj
- ws.cell(rowNum + 2, 20).value = ""
- ws.cell(rowNum + 2, 21).value = ""
- ws.cell(rowNum + 2, 22).value = ""
- ws.cell(rowNum + 2, 23).value = ""
- rowNum += 1
- elif flightinfodata[11] == "航前":
- ws.cell(rowNum + 2, 1).value = rowNum+1
- ws.cell(rowNum + 2, 2).value = flighttype
- ws.cell(rowNum + 2, 3).value = flightinfodata[8]
- ws.cell(rowNum + 2, 4).value = flightinfodata[4]
- ws.cell(rowNum + 2, 5).value = flightinfodata[3]
- ws.cell(rowNum + 2, 6).value = flightinfodata[2]
- ws.cell(rowNum + 2, 7).value = ""
- ws.cell(rowNum + 2, 8).value = ""
- ws.cell(rowNum + 2, 9).value = c
- ws.cell(rowNum + 2, 10).value = flightinfodata[21]
- ws.cell(rowNum + 2, 11).value = fx
- ws.cell(rowNum + 2, 12).value = g1
- ws.cell(rowNum + 2, 13).value = g2
- ws.cell(rowNum + 2, 14).value = g3
- ws.cell(rowNum + 2, 15).value = g4
- ws.cell(rowNum + 2, 16).value = g5
- ws.cell(rowNum + 2, 17).value = s1
- ws.cell(rowNum + 2, 18).value = s2
- ws.cell(rowNum + 2, 19).value = fj
- ws.cell(rowNum + 2, 20).value = jjdw
- ws.cell(rowNum + 2, 21).value = ""
- ws.cell(rowNum + 2, 22).value = FX
- ws.cell(rowNum + 2, 23).value = XJ
- rowNum += 1
- elif row[3] == "短停接":
- ws.cell(rowNum + 2, 1).value = rowNum+1
- ws.cell(rowNum + 2, 2).value = flighttype
- ws.cell(rowNum + 2, 3).value = flightinfodata[8]
- ws.cell(rowNum + 2, 4).value = flightinfodata[4]
- ws.cell(rowNum + 2, 5).value = flightinfodata[3]
- ws.cell(rowNum + 2, 6).value = flightinfodata[2]
- ws.cell(rowNum + 2, 7).value = a
- ws.cell(rowNum + 2, 8).value = b
- ws.cell(rowNum + 2, 9).value = c
- ws.cell(rowNum + 2, 10).value = flightinfodata[19]
- ws.cell(rowNum + 2, 11).value = fx
- ws.cell(rowNum + 2, 12).value = g1
- ws.cell(rowNum + 2, 13).value = g2
- ws.cell(rowNum + 2, 14).value = g3
- ws.cell(rowNum + 2, 15).value = g4
- ws.cell(rowNum + 2, 16).value = g5
- ws.cell(rowNum + 2, 17).value = s1
- ws.cell(rowNum + 2, 18).value = s2
- ws.cell(rowNum + 2, 19).value = fj
- ws.cell(rowNum + 2, 20).value = jjdw
- ws.cell(rowNum + 2, 21).value = ESDW
- ws.cell(rowNum + 2, 22).value = FX
- ws.cell(rowNum + 2, 23).value = ""
- rowNum += 1
- elif row[3] == "特后前接":
- ws.cell(rowNum + 2, 1).value = rowNum+1
- ws.cell(rowNum + 2, 2).value = flighttype
- ws.cell(rowNum + 2, 3).value = flightinfodata[8]
- ws.cell(rowNum + 2, 4).value = flightinfodata[4]
- ws.cell(rowNum + 2, 5).value = flightinfodata[3]
- ws.cell(rowNum + 2, 6).value = flightinfodata[2]
- ws.cell(rowNum + 2, 7).value = a
- ws.cell(rowNum + 2, 8).value = b
- ws.cell(rowNum + 2, 9).value = c
- ws.cell(rowNum + 2, 10).value = flightinfodata[19]
- ws.cell(rowNum + 2, 11).value = fx
- ws.cell(rowNum + 2, 12).value = g1
- ws.cell(rowNum + 2, 13).value = g2
- ws.cell(rowNum + 2, 14).value = g3
- ws.cell(rowNum + 2, 15).value = g4
- ws.cell(rowNum + 2, 16).value = g5
- ws.cell(rowNum + 2, 17).value = s1
- ws.cell(rowNum + 2, 18).value = s2
- ws.cell(rowNum + 2, 19).value = fj
- ws.cell(rowNum + 2, 20).value = jjdw
- ws.cell(rowNum + 2, 20).value = jjdw
- ws.cell(rowNum + 2, 21).value = ESDW
- ws.cell(rowNum + 2, 22).value = FX
- ws.cell(rowNum + 2, 23).value = ""
- rowNum += 1
- wb.save('D:/flightinfo/bakup/航班运行备份数据(勿动).xlsx')
- #wb.save('航班运行备份数据.xlsx')
- res="ok"
- return res
- except Exception:
- dingding_alert(traceback.format_exc())
- def tableWidgetDispalyRead(fdb:flightDB,date):
- if date == "1":
- tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '1'")[0][0] if len(
- fdb.queryTabel("display", "A", "ID = '1'")) != 0 else {}
- if date == "2":
- tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '2'")[0][0] if len(
- fdb.queryTabel("display", "A", "ID = '2'")) != 0 else {}
- if date == "3":
- tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '3'")[0][0] if len(
- fdb.queryTabel("display", "A", "ID = '3'")) != 0 else {}
- if "\'" in tableWidgetDispalydata1:
- tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("\'", '"')
- tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("'", '"')
- tableWidgetDispalydata1 = eval(tableWidgetDispalydata1)
- return tableWidgetDispalydata1
- def tableWidgetDispalyRead2(fdb:flightDB,date):
- if date == "1":
- tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '1'")[0][0] if len(
- fdb.queryTabel("display", "B", "ID = '1'")) != 0 else {}
- if date == "2":
- tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '2'")[0][0] if len(
- fdb.queryTabel("display", "B", "ID = '2'")) != 0 else {}
- if date == "3":
- tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '3'")[0][0] if len(
- fdb.queryTabel("display", "B", "ID = '3'")) != 0 else {}
- if "\'" in tableWidgetDispalydata1:
- tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("\'", '"')
- tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("'", '"')
- tableWidgetDispalydata1 = eval(tableWidgetDispalydata1)
- return tableWidgetDispalydata1
- def TuplefindInList(lists: list, args):
- for l in lists:
- if args in l:
- return l
- return None
- def functionDisaplay(row,rowNum,TaskFlightinfoAlldata, workjobDataAll,flightInfoDataAll, flightStsDataAll,
- peopleScheduleDataAll, waringMessageID):
- #print("kaishi")
- TaskFlightinfo = TuplefindInList(TaskFlightinfoAlldata,row[1])
- #print(TaskFlightinfo)
- # print(row)
- e = ""
- F = ""
- g = ""
- if TaskFlightinfo != None and TaskFlightinfo[16] != "":
- e = "保留"
- if TaskFlightinfo != None :
- takinfo = TuplefindInList(workjobDataAll, TaskFlightinfo[21])
- JWA = TaskFlightinfo[10]
- JWB = TaskFlightinfo[11]
- if JWA =="" and JWB !="":
- JWA=JWB
- elif JWB =="" and JWA !="":
- JWB=JWA
- if TaskFlightinfo[18] != "":
- #takinfo = fdb.queryTabel('workjob', '*', "任务编号= '%s'" % TaskFlightinfo[0][21])
- F = "工作包无法正常获取请通过AMRO人工查询"
- if takinfo != None and takinfo[4] != "":
- F = takinfo[4] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[6] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[7]
- elif takinfo != None:
- F = "工作包暂未获取请点击右键工作包查询后即可随意查看"
- else:
- JWA =""
- JWB =""
- if TaskFlightinfo != None and TaskFlightinfo[21] != "":
- g = TaskFlightinfo[21]
- #print("tttt:{}".format(g))
- wx_people = ""
- fx_people = ""
- ecsj_people = ""
- ta_td = ""
- type31 = ""
- if TaskFlightinfo != None:
- wx_people = TaskFlightinfo[12]
- fx_people = TaskFlightinfo[13]
- ecsj_people = TaskFlightinfo[19]
- ta_td = TaskFlightinfo[9]
- type31 = TaskFlightinfo[3]
- # print(row[1])
- # print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
- flightinfodata = TuplefindInList(flightInfoDataAll,row[1])
- #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
- flightstsdata = TuplefindInList(flightStsDataAll, row[1]) if TuplefindInList(flightStsDataAll, row[1]) != None \
- else ["", "","", "", "", "","", "", "", "","", "", "", ""]
- # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
- # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
- # "", "", "", "",
- # "", "", "", "",
- # "", "", "", ""]
- jjdw = "√" if flightstsdata[3] != "" else ""
- FX = "√" if flightstsdata[4] != "" else ""
- XJ = "√" if flightstsdata[5] != "" else ""
- ESDW = "√" if flightstsdata[7] != "" else ""
- if flightinfodata[11] == "航后":
- postion = str(flightinfodata[6]) + "-天府"
- elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
- postion = str(flightinfodata[6]) + "-天府-" + str(flightinfodata[7])
- else:
- postion = "天府-" + str(flightinfodata[7])
- a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
- if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
- a = flightinfodata[15][-8:-3]
- elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = flightinfodata[12][-8:-3]
- elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = ""
- elif flightinfodata[16] != "":
- a = ""
- b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
- c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
- d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
- QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
- waringMessageIDs = waringMessageID
- if str(row[1]) in str(waringMessageIDs["通用警告"]):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- 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"])):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[3] == "短停送" and (
- str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "4":
- color_code = QColorList[5]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "3":
- color_code = QColorList[3]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "2":
- color_code = QColorList[2]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "1":
- if (rowNum + 2) % 2 == 0:
- color_code = QColorList[4]
- else:
- color_code = QColorList[1]
- color_code1 = QColorList[0]
- color_code2 = QColorList[6]
- color_code3 = QColorList[7]
- findid = row[0] + "-A"
- #print(peopleScheduleDataAll)
- peopleSchedule = TuplefindInList(peopleScheduleDataAll,findid)
- #peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
- #print(peopleSchedule)
- if peopleSchedule != None:
- fx = peopleSchedule[3]
- qw1 = peopleSchedule[4]
- qw2 = peopleSchedule[5]
- g1 = peopleSchedule[6]
- g2 = peopleSchedule[7]
- g3 = peopleSchedule[8]
- if flightinfodata[28] != "" and flightinfodata[28][0] == "R" and "返航航班" not in str(peopleSchedule[9]):
- fj = "返航航班;" + str(peopleSchedule[9])
- elif flightinfodata[28] != "" and flightinfodata[28] == "V" and "备降航班" not in str(peopleSchedule[9]):
- fj = "备降航班;" + str(peopleSchedule[9])
- else:
- fj = str(peopleSchedule[9])
- else:
- fx = ""
- qw1 = ""
- qw2 = ""
- g1 = ""
- g2 = ""
- g3 = ""
- if flightinfodata[28] != "" and flightinfodata[28][0] == "R":
- fj = "返航航班;"
- elif flightinfodata[28] != "" and flightinfodata[28][0] == "V":
- fj = "备降航班;"
- else:
- fj = ""
- if "随机离港" in str(fj):
- SJDW = "√" if flightstsdata[6] != "" else ""
- else:
- SJDW ="--"
- if flightinfodata[11] == "航后":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": "--",
- "8": JWA,
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "17": "--",
- "18": "--",
- "19": d,
- "20": "--",
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- elif flightinfodata[11] == "停场":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": "--",
- "5": a,
- "6": "--",
- "7": "--",
- "8": flightinfodata[19],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": "--",
- "17": "--",
- "18": "--",
- "19": "--",
- "20": "--",
- "21": "--",
- "22": "--",
- "23": "--",
- "24": "--", # flightinfodata[22],
- "25": "--", # flightinfodata[23],
- "26": row[1],
- "27": "TSK",
- "28": "--",
- "29": "--",
- "30": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- elif flightinfodata[11] == "航前":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": "",
- "6": "",
- "7": c,
- "8": JWB,
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "17": FX,
- "18": XJ,
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前") and (row[3] == "短停接" or row[3] == "特后前接"):
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": JWA,
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "17": FX,
- "18": "--",
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前") and (row[3] == "短停送" or row[3] == "特后前送"):
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": JWA,
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": ESDW,
- "17": FX,
- "18": "--",
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": ecsj_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- else:
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": JWA,
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "17": FX,
- "18": "--",
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- #tableWidgetDispalydata[rowNum] = item_dic
- #rowNum += 1
- # print(rowNum)
- # print(item_dic)
- # print({rowNum:item_dic})
- return {rowNum:item_dic}
- #########################################
- # 测试导出
- def tableWidgetDispalyAlllogs(fdb: flightDB):
- index2 = {0: "编号", 1: "航班编号", 2: "警告信息", 3: "信息状态", 4: "提示信息", 5: "产生时间", 6: "处理人", 7: "处理时间", 8: "变更字段",9: "显示对象", 10: "提示内容"}
- data = fdb.getAlldata("logs")
- res = {}
- if data != None and len(data) != 0:
- for i in data:
- aa = {}
- for j in index2.keys():
- aa["%s"%j]=i[j]
- res[i[0]]=aa
- return res
- def tableWidgetDispalyCalllogs(fdb: flightDB):
- index2 = {0: "航班编号", 1: "电话", 2: "航班号", 3: "创建时间", 4: "姓名", 5: "接通时间", 6: "附加信息", 7: "工号", 8: "拨号次数"}
- data = fdb.getAlldata("Calllist")
- res = {}
- if data != None and len(data) != 0:
- ii = 0
- for i in data:
- aa = {}
- for j in index2.keys():
- aa["%s"%j]=i[j]
- res[ii]=aa
- ii+=1
- return res
- ########################################
- def tableWidgetDispaly(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
- try:
- #t1 = datetime.datetime.now()
- tableWidgetDispalydata = {}
- nowDayStr = selectedtime
- sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
- #t2 = datetime.datetime.now()
- #print(f'【航班刷新】【数据库1】:{t2 - t1}')
- TaskFlightinfoAlldata = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
- #t3 = datetime.datetime.now()
- #print(f'【航班刷新】【数据库2】:{t3 - t2}')
- flightInfoDataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
- #t4 = datetime.datetime.now()
- #print(f'【航班刷新】【数据库3】:{t4 - t3}')
- flightStsDataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
- #t5 = datetime.datetime.now()
- #print(f'【航班刷新】【数据库4】:{t5 - t4}')
- peopleScheduleDataAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
- #t6 = datetime.datetime.now()
- #print(f'【航班刷新】【数据库5】:{t6 - t5}')
- workjobDataAll = fdb.getAlldata('workjob')
- #t7 = datetime.datetime.now()
- #print(f'【航班刷新】【数据库6】:{t7 - t6}')
- #print(f'【航班刷新】【数据库ALL】:{t7 - t1}')
- waringMessageIDs = waringMessageID(fdb)
- executor = concurrent.futures.ThreadPoolExecutor()
- all_task = []
- for i in range(len(sorttable)):
- all_task.append(executor.submit(functionDisaplay, sorttable[i],i, TaskFlightinfoAlldata,workjobDataAll,flightInfoDataAll, flightStsDataAll,peopleScheduleDataAll,waringMessageIDs))
- for future in concurrent.futures.as_completed(all_task):
- data = future.result()
- tableWidgetDispalydata.update(data)
- #t8 = datetime.datetime.now()
- #print(f'【航班刷新】【处理数据】:{t8 - t7}')
- newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
- if date == "1":
- fdb.upDateItem("display", newdic, "ID = '1'")
- elif date == "2":
- fdb.upDateItem("display", newdic, "ID = '2'")
- elif date == "3":
- fdb.upDateItem("display", newdic, "ID = '3'")
- #t9 = datetime.datetime.now()
- #print(f'【航班刷新】【保存数据】:{t9 - t8}')
- #print(f'【航班刷新】【总时间】:{t9 - t1}')
- return tableWidgetDispalydata
- except Exception:
- #dingding_alert(traceback.format_exc())
- print(traceback.format_exc())
- def functionDisplay2(row, rowNum, TaskFlightinfoAll,flightinfodataAll,flightstsdataAll,waringMessageIDs,peopleScheduleAll):
- TaskFlightinfo = TuplefindInList(TaskFlightinfoAll,row[1])
- #TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
- e = ""
- F = ""
- g = ""
- if TaskFlightinfo != None:
- JWA = TaskFlightinfo[10]
- JWB = TaskFlightinfo[11]
- if JWB!="" and JWA =="":
- JWA=JWB
- if JWA!="" and JWB =="":
- JWB=JWA
- if TaskFlightinfo[16] != "":
- e = "保留"
- if TaskFlightinfo[18] != "":
- F = "工作包"
- if TaskFlightinfo[21] != "":
- g = TaskFlightinfo[21]
- else:
- JWA = ""
- JWB = ""
- wx_people = ""
- fx_people = ""
- ecsj_people = ""
- ta_td = ""
- type31 = ""
- # print(TaskFlightinfo)
- if TaskFlightinfo != None:
- wx_people = TaskFlightinfo[12]
- fx_people = TaskFlightinfo[13]
- ecsj_people = TaskFlightinfo[19]
- ta_td = TaskFlightinfo[9]
- type31 = TaskFlightinfo[3]
- #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
- # print(flightinfodataAll)
- # print(row[0])
- flightinfodata = TuplefindInList(flightinfodataAll, row[1])
- # print(flightinfodata)
- # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
- # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
- # "", "", "", "",
- # "", "", "", "",
- # "", "", "", ""]
- flightstsdata = TuplefindInList(flightstsdataAll,row[0])if TuplefindInList(flightstsdataAll,row[0])!=None \
- else ["", "","", "", "", "","", "", "", "","", "", "", ""]
- jjdw = "√" if flightstsdata[3] != "" else ""
- FX = "√" if flightstsdata[4] != "" else ""
- XJ = "√" if flightstsdata[5] != "" else ""
- ESDW = "√" if flightstsdata[7] != "" else ""
- SJDW = "√" if flightstsdata[6] != "" else ""
- if flightinfodata[11] == "航后":
- postion = str(flightinfodata[6]) + "-天府"
- elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
- postion = str(flightinfodata[6]) + "-天府-" + str(flightinfodata[7])
- else:
- postion = "天府-" + str(flightinfodata[7])
- a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
- if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
- a = flightinfodata[15][-8:-3]
- elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = flightinfodata[12][-8:-3]
- elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = ""
- elif flightinfodata[16] != "":
- a = ""
- b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
- c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
- d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
- QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
- # waringMessageIDs = waringMessageID(fdb)
- if str(row[1]) in str(waringMessageIDs["全部警告"]):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "4":
- color_code = QColorList[5]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "3":
- color_code = QColorList[3]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "2":
- color_code = QColorList[2]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "1":
- if (rowNum + 2) % 2 == 0:
- color_code = QColorList[4]
- else:
- color_code = QColorList[1]
- color_code1 = QColorList[0]
- color_code2 = QColorList[6]
- color_code3 = QColorList[7]
- findid = row[0] + "-B"
- #peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
- peopleSchedule = TuplefindInList(peopleScheduleAll, findid)
- if peopleSchedule != None:
- fx = peopleSchedule[3]
- qw1 = peopleSchedule[4]
- qw2 = peopleSchedule[5]
- g1 = peopleSchedule[6]
- g2 = peopleSchedule[7]
- g3 = peopleSchedule[8]
- fj = peopleSchedule[9]
- else:
- fx = ""
- qw1 = ""
- qw2 = ""
- g1 = ""
- g2 = ""
- g3 = ""
- fj = ""
- if flightinfodata[11] == "航后":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": "--",
- "8": JWA,
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "17": "--",
- "18": "--",
- "19": "--",
- "20": d,
- "21": "--",
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": "",
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- # tableWidgetDispalydata[rowNum] = item_dic
- # rowNum += 1
- return {rowNum: item_dic}
- elif flightinfodata[11] == "停场":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": "--",
- "5": a,
- "6": "--",
- "7": "--",
- "8": JWA,
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": "--",
- "17": "--",
- "18": "--",
- "19": "--",
- "20": "--",
- "21": "--",
- "22": "--",
- "23": "--",
- "24": "--", # flightinfodata[22],
- "25": "--", # flightinfodata[23],
- "26": "--",
- "27": "--",
- "28": row[1],
- "29": "TSK",
- "30": "--",
- "31": "--",
- "32": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- # tableWidgetDispalydata[rowNum] = item_dic
- # rowNum += 1
- return {rowNum: item_dic}
- elif flightinfodata[11] == "航前":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": "",
- "6": "",
- "7": c,
- "8": JWB,
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "18": FX,
- "19": XJ,
- "17": "--",
- "20": d,
- "21": SJDW,
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": "",
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- # tableWidgetDispalydata[rowNum] = item_dic
- # rowNum += 1
- return {rowNum: item_dic}
- elif row[3] == "短停接":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": JWA,
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "18": FX,
- "19": "--",
- "17": ESDW,
- "20": d,
- "21": SJDW,
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": ecsj_people,
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- # tableWidgetDispalydata[rowNum] = item_dic
- # rowNum += 1
- return {rowNum: item_dic}
- elif row[3] == "特后前接":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": JWA,
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": jjdw,
- "18": FX,
- "19": "--",
- "17": "--",
- "20": d,
- "21": SJDW,
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": "",
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32": fj,
- "99": color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109": row[5]
- }
- #tableWidgetDispalydata[rowNum] = item_dic
- #rowNum += 1
- return {rowNum:item_dic}
- def tableWidgetDispaly2(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
- try:
- tableWidgetDispalydata = {}
- sorttable = getSortFlightdata(fdb,selectedtime,"sortFlight2")
- nowDayStr = selectedtime
- TaskFlightinfoAll = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
- flightinfodataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
- flightstsdataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
- waringMessageIDs = waringMessageID(fdb)
- peopleScheduleAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
- '''
- col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
- "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
- "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "进出港城市", "25": "维修人员",
- "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
- '''
- rowNum = 0
- # functionDisplay2(sorttable[1], 1, TaskFlightinfoAll,
- # flightinfodataAll, flightstsdataAll, waringMessageIDs,
- # peopleScheduleAll)
- executor = concurrent.futures.ThreadPoolExecutor()
- all_task = []
- for i in range(len(sorttable)):
- all_task.append(executor.submit(functionDisplay2, sorttable[i], i, TaskFlightinfoAll,
- flightinfodataAll, flightstsdataAll, waringMessageIDs,
- peopleScheduleAll))
- for future in concurrent.futures.as_completed(all_task):
- data = future.result()
- tableWidgetDispalydata.update(data)
- newdic = {"B": '"{}"'.format(tableWidgetDispalydata)}
- if date == "1":
- fdb.upDateItem("display", newdic, "ID = '1'")
- elif date == "2":
- fdb.upDateItem("display", newdic, "ID = '2'")
- elif date == "3":
- fdb.upDateItem("display", newdic, "ID = '3'")
- return tableWidgetDispalydata
- except Exception:
- #dingding_alert(traceback.format_exc())
- print(traceback.format_exc())
- def tableWidgetDispalyOld(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
- try:
- #print("tableWidgetDispaly")
- #print(selectedtime)
- #ts=datetime.datetime.now()
- tableWidgetDispalydata = {}
- sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
- nowDayStr = selectedtime
- rowNum = 0
- for row in sorttable:
- # print(row)
- TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
- e = ""
- F = ""
- g = ""
- if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][16] != "":
- e = "保留"
- if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][18] != "":
- takinfo = fdb.queryTabel('workjob','*',"任务编号= '%s'"%TaskFlightinfo[0][21])
- F = "工作包无法正常获取请通过AMRO人工查询"
- if len(takinfo) != 0 and takinfo[0][4] !="":
- F=takinfo[0][4]+"\n<+++++++++++++++++++++++++++++++++++++++++>\n"+takinfo[0][6]+"\n<+++++++++++++++++++++++++++++++++++++++++>\n"+takinfo[0][7]
- elif len(takinfo) != 0:
- F="工作包暂未获取请点击右键工作包查询后即可随意查看"
- if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][21] != "":
- g = TaskFlightinfo[0][21]
- wx_people = ""
- fx_people = ""
- ecsj_people = ""
- ta_td = ""
- type31 = ""
- if len(TaskFlightinfo) != 0:
- wx_people = TaskFlightinfo[0][12]
- fx_people = TaskFlightinfo[0][13]
- ecsj_people = TaskFlightinfo[0][19]
- ta_td = TaskFlightinfo[0][9]
- type31 = TaskFlightinfo[0][3]
- #print(row[1])
- #print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
- flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
- flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
- len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
- "", "","", "","", "","", "","", "","", ""]
- jjdw="√" if flightstsdata[3] !="" else ""
- FX = "√" if flightstsdata[4] != "" else ""
- XJ = "√" if flightstsdata[5] != "" else ""
- ESDW = "√" if flightstsdata[7] != "" else ""
- SJDW = "√" if flightstsdata[6] != "" else ""
- if flightinfodata[11] == "航后":
- postion=str(flightinfodata[6])+"-天府"
- elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
- postion = str(flightinfodata[6]) + "-天府-"+str(flightinfodata[7])
- else:
- postion = "天府-" + str(flightinfodata[7])
- a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
- if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
- a = flightinfodata[15][-8:-3]
- elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = flightinfodata[12][-8:-3]
- elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = ""
- elif flightinfodata[16] != "":
- a = ""
- b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
- c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
- d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
- QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
- waringMessageIDs=waringMessageID(fdb)
- if str(row[1]) in str(waringMessageIDs["通用警告"]):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- 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"])):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[3]=="短停送" and (str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "4":
- color_code = QColorList[5]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "3":
- color_code = QColorList[3]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "2":
- color_code = QColorList[2]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "1":
- if (rowNum + 2) % 2 == 0:
- color_code = QColorList[4]
- else:
- color_code = QColorList[1]
- color_code1 = QColorList[0]
- color_code2 = QColorList[6]
- color_code3 = QColorList[7]
- findid=row[0]+"-A"
- peopleSchedule=fdb.queryTabel("peopleSchedule{}".format(nowDayStr),"*","编号='%s'"%findid)
- #print(peopleSchedule)
- if len(peopleSchedule) != 0:
- fx=peopleSchedule[0][3]
- qw1 = peopleSchedule[0][4]
- qw2 = peopleSchedule[0][5]
- g1 = peopleSchedule[0][6]
- g2 = peopleSchedule[0][7]
- g3 = peopleSchedule[0][8]
- if flightinfodata[28] !="" and flightinfodata[28][0] =="R" and "返航航班" not in str(peopleSchedule[0][9]):
- fj = "返航航班;"+str(peopleSchedule[0][9])
- elif flightinfodata[28] !="" and flightinfodata[28][0] == "V" and "备降航班" not in str(peopleSchedule[0][9]):
- fj = "备降航班;" + str(peopleSchedule[0][9])
- else:
- fj = str(peopleSchedule[0][9])
- else:
- fx = ""
- qw1 = ""
- qw2 = ""
- g1 = ""
- g2 = ""
- g3 = ""
- if flightinfodata[28] != "" and flightinfodata[28][0] == "R":
- fj = "返航航班;"
- elif flightinfodata[28] != "" and flightinfodata[28][0] == "V":
- fj = "备降航班;"
- else:
- fj = ""
- if flightinfodata[11] == "航后":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": "--",
- "8": flightinfodata[19],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "17": "--",
- "18": "--",
- "19": d,
- "20": "--",
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- elif flightinfodata[11] == "停场":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": "--",
- "5": a,
- "6": "--",
- "7": "--",
- "8": flightinfodata[19],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":"--",
- "17": "--",
- "18": "--",
- "19": "--",
- "20": "--",
- "21": "--",
- "22": "--",
- "23": "--",
- "24": "--", # flightinfodata[22],
- "25": "--", # flightinfodata[23],
- "26": row[1],
- "27": "TSK",
- "28": "--",
- "29": "--",
- "30":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- elif flightinfodata[11] == "航前":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": "",
- "6": "",
- "7": c,
- "8": flightinfodata[21],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "17": FX,
- "18": XJ,
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前" ) and (row[3] == "短停接" or row[3] == "特后前接"):
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": flightinfodata[19],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "17": FX,
- "18": "--",
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前" ) and (row[3] == "短停送" or row[3] == "特后前送"):
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": flightinfodata[19],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16": ESDW,
- "17": FX,
- "18": "--",
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": ecsj_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- else:
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": flightinfodata[19],
- "9": row[3],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "17": FX,
- "18": "--",
- "19": d,
- "20": SJDW,
- "21": e,
- "22": F,
- "23": postion,
- "24": wx_people, # flightinfodata[22],
- "25": fx_people, # flightinfodata[23],
- "26": row[1],
- "27": g,
- "28": ta_td,
- "29": type31,
- "30":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- tableWidgetDispalydata[rowNum]=item_dic
- rowNum += 1
- #print(tableWidgetDispalydata)
- #print("耗时%s"%(datetime.datetime.now()-ts)) ###需要传参一个昨天今天明天地结果123
- newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
- if date =="1":
- fdb.upDateItem("display", newdic, "ID = '1'")
- elif date =="2":
- fdb.upDateItem("display", newdic, "ID = '2'")
- elif date =="3":
- fdb.upDateItem("display", newdic, "ID = '3'")
- return tableWidgetDispalydata
- except Exception:
- dingding_alert(traceback.format_exc())
- def tableWidgetDispaly2Old(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
- try:
- tableWidgetDispalydata = {}
- sorttable = getSortFlightdata(fdb,selectedtime,"sortFlight2")
- nowDayStr = selectedtime
- '''
- col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
- "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
- "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "进出港城市", "25": "维修人员",
- "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
- '''
- rowNum = 0
- for row in sorttable:
- # print(row)
- TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
- e = ""
- F = ""
- g = ""
- if len(TaskFlightinfo) != 0:
- if TaskFlightinfo[0][16] != "":
- e = "保留"
- if TaskFlightinfo[0][18] != "":
- F = "工作包"
- if TaskFlightinfo[0][21] != "":
- g = TaskFlightinfo[0][21]
- wx_people = ""
- fx_people = ""
- ecsj_people = ""
- ta_td = ""
- type31 = ""
- # print(TaskFlightinfo)
- if len(TaskFlightinfo) != 0:
- wx_people = TaskFlightinfo[0][12]
- fx_people = TaskFlightinfo[0][13]
- ecsj_people = TaskFlightinfo[0][19]
- ta_td = TaskFlightinfo[0][9]
- type31 = TaskFlightinfo[0][3]
- flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
- flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
- len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
- "", "","", "","", "","", "","", "","", ""]
- jjdw = "√" if flightstsdata[3] != "" else ""
- FX = "√" if flightstsdata[4] != "" else ""
- XJ = "√" if flightstsdata[5] != "" else ""
- ESDW = "√" if flightstsdata[7] != "" else ""
- SJDW = "√" if flightstsdata[6] != "" else ""
- if flightinfodata[11] == "航后":
- postion=str(flightinfodata[6])+"-天府"
- elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
- postion = str(flightinfodata[6]) + "-天府-"+str(flightinfodata[7])
- else:
- postion = "天府-" + str(flightinfodata[7])
- a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
- if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
- a = flightinfodata[15][-8:-3]
- elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = flightinfodata[12][-8:-3]
- elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
- a = ""
- elif flightinfodata[16] != "":
- a = ""
- b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
- c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
- d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
- QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
- waringMessageIDs = waringMessageID(fdb)
- if str(row[1]) in str(waringMessageIDs["全部警告"]):
- color_code = QColorList[6]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "4":
- color_code = QColorList[5]
- color_code1 = QColorList[1]
- color_code2 = QColorList[1]
- color_code3 = QColorList[1]
- elif row[5] == "3":
- color_code = QColorList[3]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "2":
- color_code = QColorList[2]
- color_code1 = QColorList[0]
- color_code2 = QColorList[0]
- color_code3 = QColorList[0]
- elif row[5] == "1":
- if (rowNum + 2) % 2 == 0:
- color_code = QColorList[4]
- else:
- color_code = QColorList[1]
- color_code1 = QColorList[0]
- color_code2 = QColorList[6]
- color_code3 = QColorList[7]
- findid = row[0] + "-B"
- peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
- if len(peopleSchedule) != 0:
- fx = peopleSchedule[0][3]
- qw1 = peopleSchedule[0][4]
- qw2 = peopleSchedule[0][5]
- g1 = peopleSchedule[0][6]
- g2 = peopleSchedule[0][7]
- g3 = peopleSchedule[0][8]
- fj = peopleSchedule[0][9]
- else:
- fx = ""
- qw1 = ""
- qw2 = ""
- g1 = ""
- g2 = ""
- g3 = ""
- fj = ""
- if flightinfodata[11] == "航后":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": "--",
- "8": flightinfodata[19],
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "17": "--",
- "18": "--",
- "19": "--",
- "20": d,
- "21": "--",
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": "",
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32": fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- tableWidgetDispalydata[rowNum] = item_dic
- rowNum += 1
- elif flightinfodata[11] == "停场":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": "--",
- "5": a,
- "6": "--",
- "7": "--",
- "8": flightinfodata[19],
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":"--",
- "17": "--",
- "18": "--",
- "19": "--",
- "20": "--",
- "21": "--",
- "22": "--",
- "23": "--",
- "24": "--", # flightinfodata[22],
- "25": "--", # flightinfodata[23],
- "26": "--",
- "27": "--",
- "28": row[1],
- "29": "TSK",
- "30":"--",
- "31": "--",
- "32": fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- tableWidgetDispalydata[rowNum] = item_dic
- rowNum += 1
- elif flightinfodata[11] == "航前":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": "",
- "6": "",
- "7": c,
- "8": flightinfodata[21],
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "18": FX,
- "19": XJ,
- "17": "--",
- "20": d,
- "21": SJDW,
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": "",
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32": fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- tableWidgetDispalydata[rowNum] = item_dic
- rowNum += 1
- elif row[3] == "短停接":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": flightinfodata[19],
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "18": FX,
- "19": "--",
- "17": ESDW,
- "20": d,
- "21": SJDW,
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": ecsj_people,
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- tableWidgetDispalydata[rowNum] = item_dic
- rowNum += 1
- elif row[3] == "特后前接":
- item_dic = {"0": rowNum,
- "1": flightinfodata[2],
- "2": flightinfodata[4],
- "3": flightinfodata[3],
- "4": flightinfodata[8],
- "5": a,
- "6": b,
- "7": c,
- "8": flightinfodata[19],
- "9": flightinfodata[11],
- "10": fx,
- "11": qw1,
- "12": qw2,
- "13": g1,
- "14": g2,
- "15": g3,
- "16":jjdw,
- "18": FX,
- "19": "--",
- "17": "--",
- "20": d,
- "21": SJDW,
- "22": e,
- "23": F,
- "24": postion,
- "25": wx_people, # flightinfodata[22],
- "26": "",
- "27": fx_people, # flightinfodata[23],
- "28": row[1],
- "29": g,
- "30": ta_td,
- "31": type31,
- "32":fj,
- "99":color_code,
- "101": color_code1,
- "102": color_code2,
- "103": color_code3,
- "109":row[5]
- }
- tableWidgetDispalydata[rowNum] = item_dic
- rowNum += 1
- newdic = {"B": '"{}"'.format(tableWidgetDispalydata)}
- if date == "1":
- fdb.upDateItem("display", newdic, "ID = '1'")
- elif date == "2":
- fdb.upDateItem("display", newdic, "ID = '2'")
- elif date == "3":
- fdb.upDateItem("display", newdic, "ID = '3'")
- return tableWidgetDispalydata
- except Exception:
- dingding_alert(traceback.format_exc())
- def tableWidgetDisplayChange(fdb:flightDB,selectedtime):
- try:
- log=fdb.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
- tableWidgetDisplayChangedata={}
- now = datetime.datetime.now()
- rowNum=0
- if len(log) != 0:
- for i in log:
- timedeadline=""
- if i[8] =="人工待办" and i[4] !="" and i[7] =="":
- timedeadline = datetime.datetime.strptime(i[4], "%Y-%m-%d %H:%M")
- #print(timedeadline)
- if timedeadline <= now:
- tableWidgetDisplayChangedata[rowNum]=i
- rowNum +=1
- elif i[8] =="准备组任务" and i[4] !="" and i[7] =="":
- timedeadline = datetime.datetime.strptime(i[4], "%Y-%m-%d %H:%M:%S")
- #print(timedeadline)
- if timedeadline <= now:
- tableWidgetDisplayChangedata[rowNum]=i
- rowNum +=1
- elif i[8] !="人工待办" and i[8] !="人工待办":
- tableWidgetDisplayChangedata[rowNum] = i
- rowNum += 1
- return tableWidgetDisplayChangedata
- except Exception:
- dingding_alert(traceback.format_exc())
- def tableWidgetLOGDispaly(fdb:flightDB,selectedtime):
- try:
- selectdaystr = str(selectedtime)[0:4] + "-" + str(selectedtime)[4:6] + "-" + str(selectedtime)[6:] + " 00:00:00"
- selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
- yesterday = (selectday - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- log_str = fdb.sort_queryTable("编号", 'logs', "提示信息 !='' and 变更字段 !='人工待办' and 产生时间 >'%s'" % yesterday,"产生时间", "desc")
- log_len = 999 if len(log_str) > 1000 else len(log_str)
- tableWidgetLOGDispalydata={}
- for i in range(0,log_len):
- a = fdb.queryTabel('logs', "*", "编号='%s'" % log_str[i][0])[0]
- tableWidgetLOGDispalydata[i]=a[4]
- return tableWidgetLOGDispalydata
- except Exception:
- dingding_alert(traceback.format_exc())
- def deletelogs(fdb:flightDB):
- try:
- now=datetime.datetime.now()
- passtime = (now - datetime.timedelta(days=30)).strftime("%Y-%m-%d %H:%M:%S")
- log_str = fdb.queryTabel('logs',"编号","产生时间 <'%s'" %passtime)
- if len(log_str) != 0:
- for i in log_str:
- fdb.deleteSingledata('logs',"编号='%s'" % i[0])
- except Exception:
- dingding_alert(traceback.format_exc())
- def checkCalllist(fdb:flightDB,time):
- try:
- selectedtime_time = str(time) + " 00:00:00"
- now = datetime.datetime.strptime(selectedtime_time, "%Y%m%d %H:%M:%S")
- tom = (now + datetime.timedelta(days=2)).strftime("%Y-%m-%d %H:%M:%S")
- yesterday = (now - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- calllists=fdb.sort_queryTable2("*","Calllist","创建时间 <'%s' and 创建时间 >'%s'"%(tom,yesterday),"创建时间","desc","接通时间","desc")
- num = 0
- res = {}
- if len(calllists) != 0:
- for i in calllists:
- calllist={}
- calllist["序号"]=num
- calllist["电话"] = i[1]
- calllist["工号"] = i[2]
- calllist["姓名"] = i[3]
- calllist["航班号"] = i[4]
- calllist["拨号次数"] = str(i[6])
- calllist["创建时间"] = i[7]
- calllist["接通时间"] = i[8]
- res[num] = calllist
- num += 1
- return res
- except Exception:
- dingding_alert(traceback.format_exc())
- def getphonelist(fdb:flightDB):
- try:
- phonelists=fdb.getAlldata("workerinfo")
- num = 0
- res={}
- if len(phonelists) != 0:
- for i in phonelists:
- phonelist = {}
- phonelist["序号"]=num
- phonelist["姓名"] = i[1]
- phonelist["部门"] = i[2]
- phonelist["电话"] = i[5]
- phonelist["name"] = i[11]
- res[num]=phonelist
- num+=1
- return res
- except Exception:
- dingding_alert(traceback.format_exc())
- def MM_GJJH_LIST(fdb:flightDB,team,data):
- GJlist1 = {}
- GJlist2 = {}
- if data !=[]:
- now=datetime.datetime.now()
- nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
- a_str = nowDay_str2 + " 17:00:00"
- time1 = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
- if time1 < now :
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- pglist = fdb.queryTabel("pglist%s"%nowDay,"姓名","班次 = 'A'")
- else:
- nowDay = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- pglist = fdb.queryTabel("pglist%s" % nowDay, "姓名", "班次 = 'B'")
- for row in data:
- phone=fdb.queryTabel("workerinfo","电话","姓名='%s'"%str(row["zlynam"]))
- if len(phone) != 0 and len(phone[0][0]) == 12:
- phonenumber=phone[0][0][1:]
- if str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) in GJlist1.keys():
- maktx=GJlist1[row["zlynam"]]["工具名"]+","+row["maktx"]
- zzbh = GJlist1[row["zlynam"]]["编号"] + "," + row["zzbh"]
- zjcmeng = GJlist1[row["zlynam"]]["数量"] + "," + row["zjcmeng"]
- a={"工具名":maktx,"编号":zzbh,"数量":zjcmeng,"phonenumber":phonenumber}
- GJlist1[row["zlynam"]]=a
- elif str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) not in GJlist1.keys():
- maktx =row["maktx"]
- zzbh = row["zzbh"]
- zjcmeng = row["zjcmeng"]
- a={"工具名":maktx,"编号":zzbh,"数量":zjcmeng,"phonenumber":phonenumber}
- GJlist1[row["zlynam"]] = a
- else:
- if str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) in GJlist2.keys():
- maktx = GJlist2[row["zlynam"]]["工具名"] + "," + row["maktx"]
- zzbh = GJlist2[row["zlynam"]]["编号"] + "," + row["zzbh"]
- zjcmeng = GJlist2[row["zlynam"]]["数量"] + "," + row["zjcmeng"]
- a = {"工具名": maktx, "编号": zzbh, "数量": zjcmeng}
- GJlist2[row["zlynam"]] = a
- elif str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) not in GJlist2.keys():
- maktx = row["maktx"]
- zzbh = row["zzbh"]
- zjcmeng = row["zjcmeng"]
- a = {"工具名": maktx, "编号": zzbh, "数量": zjcmeng}
- GJlist2[row["zlynam"]] = a
- if GJlist1:
- msg = "经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
- times=5
- telphone=list()
- for i in GJlist1:
- msg =msg+"\n"+"【"+str(i)+"】" + "\n[工具名]:" + str(GJlist1[i]["工具名"]) + "\n[数量]:" + str(GJlist1[i]["数量"]) + "\n[编号]:" + str(GJlist1[i]["编号"])
- telphone.append(str(GJlist1[i]["phonenumber"]))
- #telphone.append("17729693827")
- times+=1
- if times % 5 == 0:
- if team == "test":
- dingding_alert1(telphone,msg)
- elif str(team)=="1":
- dingding_alert11(telphone, msg)
- elif str(team)=="2":
- dingding_alert1(telphone, msg)
- elif str(team)=="3":
- dingding_alert1(telphone, msg)
- elif str(team)=="4":
- dingding_alert1(telphone, msg)
- msg = "经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
- telphone = list()
- if msg !="经查询您有以下工具未归还,请注意核实工具归还或交接情况:":
- if team == "test":
- dingding_alert1(telphone, msg)
- elif str(team) == "1":
- #print(telphone, msg)
- #dingding_alert1(telphone, msg)
- dingding_alert11(telphone, msg)
- elif str(team) == "2":
- dingding_alert1(telphone, msg)
- elif str(team) == "3":
- dingding_alert1(telphone, msg)
- elif str(team) == "4":
- dingding_alert1(telphone, msg)
- if GJlist2:
- msg="经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
- a=list()
- for i in GJlist2:
- msg =msg+"\n"+"【"+str(i)+"】" + "\n[工具名]:" + str(GJlist2[i]["工具名"]) + "\n[数量]:" + str(GJlist2[i]["数量"]) + "\n[编号]:" + str(GJlist2[i]["编号"])
- if team == "test":
- dingding_alert1(a, msg)
- elif str(team) == "1":
- #print("联系不上的", msg)
- #dingding_alert1(a, msg)
- dingding_alert11("", msg)
- elif str(team) == "2":
- dingding_alert1(a, msg)
- elif str(team) == "3":
- dingding_alert1(a, msg)
- elif str(team) == "4":
- dingding_alert1(a, msg)
- return
- def taskAtuoCheck(fdb:flightDB,time):
- try:
- now = datetime.datetime.now()
- tomorrow=(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- #print(tomorrow)
- if time =="1":
- print(datetime.datetime.now(),"[数据库操作]准备组任务首次登录检查验证")
- log_str = fdb.queryTabel('logs',"编号","处理时间='' and 变更字段='准备组任务'")
- if len(log_str) == 0:
- getTaskAuto=fdb.getAlldata('taskAuto')
- if len(getTaskAuto) != 0:
- #print(getTaskAuto)
- for i in getTaskAuto:
- #print(i)
- if i[1] !="None":
- time1=str(datetime.date.today())+ " "+i[1]
- time11 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
- time2 = str(datetime.date.today()+ datetime.timedelta(days=1)) + " " + i[1]
- time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
- newdic = {"航班编号": '', "警告信息": i[2], "信息状态": "",
- "提示信息": "%s" % time11, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务", "显示对象": "",
- "提示内容": i[3]}
- fdb.lazyInsertData("logs", newdic)
- newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
- "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务", "显示对象": "",
- "提示内容": i[3]}
- fdb.lazyInsertData("logs", newdic2)
- if time =="2":
- print(datetime.datetime.now(),"[数据库操作]准备组任务登录持续验证")
- log_str2 = fdb.queryTabel('logs', "编号", "提示信息 >'%s' and 处理时间='' and 变更字段='准备组任务'" % tomorrow)
- if len(log_str2) == 0:
- getTaskAuto = fdb.getAlldata('taskAuto')
- if len(getTaskAuto) != 0:
- #print(getTaskAuto)
- for i in getTaskAuto:
- #print(i)
- if i[1] != "None":
- time2 = str(datetime.date.today() + datetime.timedelta(days=1)) + " " + i[1]
- time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
- newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
- "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
- "显示对象": "",
- "提示内容": i[3]}
- fdb.lazyInsertData("logs", newdic2)
- if time =="3":
- print(datetime.datetime.now(),"[数据库操作]更新准备组任务抑制前序任务")
- log_str3 = fdb.queryTabel('logs', "编号", "处理时间='' and 变更字段='准备组任务'")
- #print(log_str3)
- if len(log_str3) != 0:
- for i in log_str3:
- newdic = {"处理人": "'更新准备组任务系统抑制'", "处理时间": "'%s'" % now}
- fdb.lazyUpdateItem('logs', newdic, "编号='%s'" % i[0])
- getTaskAuto = fdb.getAlldata('taskAuto')
- if len(getTaskAuto) != 0:
- #print(getTaskAuto)
- for i in getTaskAuto:
- #print(i)
- if i[1] != "None":
- time1 = str(datetime.date.today()) + " " + i[1]
- time11 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
- time2 = str(datetime.date.today() + datetime.timedelta(days=1)) + " " + i[1]
- time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
- newdic = {"航班编号": '', "警告信息": i[2], "信息状态": "",
- "提示信息": "%s" % time11, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
- "显示对象": "",
- "提示内容": i[3]}
- fdb.lazyInsertData("logs", newdic)
- newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
- "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
- "显示对象": "",
- "提示内容": i[3]}
- fdb.lazyInsertData("logs", newdic2)
- fdb.FunctionCommit()
- except Exception:
- fdb.FunctionCommit()
- dingding_alert(traceback.format_exc())
- def selftaxiLogs(database:flightDB,TEXT:str,flightid:str):
- try:
- now = datetime.datetime.now()
- noteid=database.queryTabel("logs","*","航班编号='%s' and 警告信息='%s'"%(flightid,TEXT))
- if len(noteid) == 0:
- newdic = {"航班编号":flightid, "警告信息":TEXT, "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "自滑提示","显示对象":"","提示内容":""}
- database.insertData("logs", newdic)
- except Exception:
- dingding_alert(traceback.format_exc())
- def insertLogs(database:flightDB,TEXT:str,user:str,time):
- try:
- now = datetime.datetime.now()
- newdic = {"航班编号": "人工%s" % user, "警告信息":TEXT, "信息状态": "",
- "提示信息": time,"产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "人工待办","显示对象":"","提示内容":""} #需要确定显示对象,可以考虑传参
- database.insertData("logs", newdic)
- except Exception:
- dingding_alert(traceback.format_exc())
- def insertLogs2(database:flightDB,TEXT:str,user:str,time):
- try:
- now = datetime.datetime.now()
- newdic = {"航班编号": "人工%s" % user, "警告信息":"", "信息状态": "",
- "提示信息": TEXT,"产生时间": "%s" % now, "处理人": user, "处理时间": time, "变更字段": "操作日志","显示对象":"","提示内容":""} #需要确定显示对象,可以考虑传参
- database.insertData("logs", newdic)
- except Exception:
- dingding_alert(traceback.format_exc())
- def manChangests(database:flightDB,flight_id:str,changests_id:str,selectedtime,username):
- try:
- nowDayStr = selectedtime
- now = datetime.datetime.now()
- now11=str(now).split(".")[0]
- code = {"接机到位": "已到位", "放行": "已放行", "随机到位": "已到位", "销子夹板": "已取下", "二送到位": "已到位"}
- code2 = {"接机到位": "接机已到位提示", "放行": "已放行提示", "随机到位": "随机已到位提示", "销子夹板": "销子夹板已提示", "二送到位": "二送已到位提示"}
- flightsts_search=database.queryTabel("flightsts{}".format(nowDayStr),"%s"%changests_id,"航班编号 = '%s'"%flight_id)
- waringsts=database.queryTabel("logs","*","航班编号='%s' and 处理时间 =''"%flight_id)
- if len(flightsts_search) != 0:
- if flightsts_search[0][0] != "":
- newdic={"%s"%changests_id:"''","%s"%code2[changests_id]:"''"}
- database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号='%s'"%flight_id)
- a =database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
- newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
- "提示信息": "人工处理:%s取消%s状态!%s" % (a,changests_id,now11),
- "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
- database.insertData('logs', newdic)
- else:
- newdic={"%s"%changests_id:"'%s'"%code[changests_id],"%s"%code2[changests_id]:"'1'"}
- database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号 = '%s'"%flight_id)
- a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(
- database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
- newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
- "提示信息": "人工处理:%s确认%s已完成!%s" % (a, changests_id,now11),
- "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
- database.insertData('logs', newdic)
- if len(waringsts) != 0:
- for i in waringsts:
- if changests_id == "接机到位" and i[8]=="到位警告":
- newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
- database.upDateItem('logs', newdic, "编号='%s'" % i[0])
- elif changests_id == "放行" and i[8]=="放行警告":
- newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
- database.upDateItem('logs', newdic, "编号='%s'" % i[0])
- elif changests_id == "二送到位" and i[8]=="二送警告":
- newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
- database.upDateItem('logs', newdic, "编号='%s'" % i[0])
- elif changests_id == "销子夹板" and i[8]=="销夹警告":
- newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
- database.upDateItem('logs', newdic, "编号='%s'" % i[0])
- elif changests_id == "随机到位" and i[8] == "随机到位警告":
- newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
- database.upDateItem('logs', newdic, "编号='%s'" % i[0])
- except Exception:
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def checkFlightAlert(database:flightDB):
- try:
- ########需要建立昨日初始化
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
- 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"]
- now = datetime.datetime.now()
- now_20=(datetime.datetime.now()+ datetime.timedelta(minutes=120)).strftime("%Y%m%d")
- if now_20 == nowDay:
- day=[nowDay,nowDay_1]
- else:
- day = [nowDay, nowDay_1,nowDay_2]
- for nowDayStr in day:
- flightcheck=database.queryTabel("sortFlight{}".format(nowDayStr),"航班编号","CAST(级别 AS integer) = 1" )
- flightcheck2 = database.queryTabel("sortFlight{}".format(nowDayStr), "航班编号", "CAST(级别 AS integer) != 4")
- if database.getSingledata("航班编号", "flightinfo{}".format(nowDayStr)) !=None and len(database.getSingledata("航班编号", "flightinfo{}".format(nowDayStr))) != 0 and len(flightcheck) !=0:
- for i in flightcheck:
- a = database.queryTabel("flightinfo{}".format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
- b = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
- dd = database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % i[0])[0][0]
- if b =="航前":
- c = database.queryTabel("flightinfo{}".format(nowDayStr), "航前离港机位", "航班编号='%s'" % i[0])[0][0]
- else:
- c = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前进港机位", "航班编号='%s'" % i[0])[0][0]
- #if c in selftaxi:
- if "航前" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and database.queryTabel("flightinfo{}".format(nowDayStr),"航前预计起飞","航班编号='%s'"%i[0])[0][0] != "":
- STD=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
- STD_str = dd.split("-")[0] + "/" + STD.split("]")[1]
- STD_90 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
- STD_30 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=30)
- if STD_90 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
- "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if STD_30 < now and "已放行" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"放行","航班编号='%s'"%i[0])) and \
- "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if STD_30 < now and "已取下" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"销子夹板","航班编号='%s'"%i[0])) and \
- "销夹警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s销夹取下情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "销夹警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- elif "航后" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and\
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] != "" and\
- database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] != "":
- ETA_15_str = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- if ETA_15 < now and "已到位" not in database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0]) and \
- "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- elif "短停" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and\
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!= "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0]!= "" :
- ETA_15_str=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ATA = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])
- if ATA[0][0] != "":
- ATA_time_30 = datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
- ATA_time_3H=datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S")+datetime.timedelta(minutes=180)
- else:
- ATA_time_30 = ""
- ATA_time_3H=""
- FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
- TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
- TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
- TD_time_25 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")- datetime.timedelta(minutes=25)
- TD_time_120 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
- TD_time=datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")
- if ETA_15 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
- "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- 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 \
- "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- 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 \
- "二送警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s二送到位情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "二送警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if ATA_time_3H !="" and ATA_time_3H < TD_time and TD_time_120 < now and\
- "长短停到位提示" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认安排%s%s%s长短停上电人员!" % (a, b, c), "信息状态": "",
- "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "长短停到位提示","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if ATA_time_3H !="" and ATA_time_3H < TD_time and\
- "长短停值守提示" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请注意安排%s %s长短停值守,如无需则忽略!" % (a,c), "信息状态": "",
- "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "长短停值守提示","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- elif "短停" not in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and \
- "航后" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0]))and \
- "航前" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
- "未显示" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!= "":
- ETA_15_str = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ATA = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])
- if ATA[0][0] != "":
- #print(ATA[0][0])
- ATA_time_30 = datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
- else:
- ATA_time_30 = ""
- FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
- TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
- #print(TD)
- #print(FlightDate)
- TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
- TD_time_25 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")- datetime.timedelta(minutes=25)
- if ETA_15 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
- "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- 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 \
- "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- 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 \
- "二送警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
- newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s二送到位情况!"%(a,b,c), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "二送警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- for i in flightcheck2:
- a = database.queryTabel("flightinfo{}".format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
- b = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
- dd = database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % i[0])[0][0]
- if b =="航前":
- c = database.queryTabel("flightinfo{}".format(nowDayStr), "航前离港机位", "航班编号='%s'" % i[0])[0][0]
- else:
- c = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前进港机位", "航班编号='%s'" % i[0])[0][0]
- if "航前" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and database.queryTabel("flightinfo{}".format(nowDayStr),"航前预计起飞","航班编号='%s'"%i[0])[0][0] != "":
- STD=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
- STD_str = dd.split("-")[0] + "/" + STD.split("]")[1]
- STD_120 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
- STD_60 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
- if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
- "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and STD_120 < now:
- sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
- flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
- newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
- "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and STD_60 < now and\
- "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
- flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
- sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
- newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- elif "短停" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])):
- FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
- TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
- TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
- TD_time_120 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
- TD_time_60 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
- if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
- "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and TD_time_120 < now:
- flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
- sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
- newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
- "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and TD_time_60 < now and\
- "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
- flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
- sjry = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
- newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- elif "短停" not in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and \
- "航后" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0]))and \
- "航前" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
- "未显示" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and\
- "停场" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])):
- FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
- TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
- TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
- TD_time_120= datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
- TD_time_60 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
- if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
- "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and TD_time_120 < now:
- flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
- sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
- newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
- "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and TD_time_60 < now and\
- "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
- flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
- sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
- newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
- "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- database.FunctionCommit()
- waringIDs=database.queryTabel('logs',"*","变更字段 like '%警告%' and 处理时间 =''")
- flightstsids=database.getSingledata("航班编号",'flightsts{}'.format(nowDayStr))
- for waringID in waringIDs:
- if str(waringID[1]) in str(flightstsids):
- waringIDstsNow=database.queryTabel('flightsts{}'.format(nowDayStr),"*","航班编号 ='%s'"%waringID[1])
- if waringID[8] == "到位警告" and waringIDstsNow[0][3] == "已到位":
- newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
- if waringID[8] == "放行警告" and waringIDstsNow[0][4] == "已放行":
- newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
- if waringID[8] == "二送警告" and waringIDstsNow[0][7] == "已到位":
- newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
- if waringID[8] == "销夹警告" and waringIDstsNow[0][5] == "已取下":
- newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
- if waringID[8] == "随机到位警告" and waringIDstsNow[0][6] == "已到位":
- newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
- database.FunctionCommit()
- except Exception:
- database.FunctionCommit()
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def createWorkloadtablesFromPg(fdb: flightDB, workLoad: flightDB,selectedtime):
- try:
- workloadDic = {}
- primaryKey2 = 'text UNIQUE NOT NULL'
- pglist=fdb.getAlldata("pglist{}".format(selectedtime))
- if len(pglist) != 0:
- for workloadkey in list(workloadLabel)[1:]:
- workloadDic[workloadkey] = 'text not null'
- for row in pglist:
- workLoad.initTable('workload%s'%str(row[1]),"编号", primaryKey2, workloadDic)
- except Exception:
- dingding_alert(traceback.format_exc())
- def createWorkloadtables(fdb:flightDB, workLoad:flightDB):
- try:
- workloadDic = {}
- primaryKey = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'
- primaryKey2 = 'TEXT UNIQUE NOT NULL'
- #print(len(fdb.getAlldata("workerinfo")))
- if len(fdb.getAlldata("workerinfo")) != 0:
- for workloadkey in list(workloadLabel)[1:]:
- workloadDic[workloadkey]= 'text not null'
- worknumbs=fdb.getSingledata("工号","workerinfo")
- for worknumbskey in worknumbs:
- if str(worknumbskey[0]) != "*":
- workLoad.initTable('workload%s'%str(worknumbskey[0]),"编号",primaryKey2, workloadDic)
- else:
- print(datetime.datetime.now(),"[数据库操作]人员信息为空,无法创建人员工作量数据库!请先上传人员信息")
- #需要QT输出警告弹框信息
- except Exception:
- dingding_alert(traceback.format_exc())
- def get_full_pinyin1(word, style=Style.NORMAL, separator=''):
- pinyin_list = pinyin(word, style=style)
- #使用列表推导式获取每个汉字的第一个拼音(不带声调),并使用 separator 连接
- full_pinyin = separator.join([''.join(syllable[0]) for syllable in pinyin_list])
- return full_pinyin
- def get_full_pinyin2(word, style=Style.NORMAL, separator=''):
- return ''.join([word[0][0] for word in pinyin(word, style=Style.NORMAL)])
- def get_dic(database:flightDB, fileName):
- try:
- fdb = database
- decrypted_workbook = io.BytesIO()
- try:
- with open(fileName, 'rb') as file:
- office_file = msoffcrypto.OfficeFile(file)
- office_file.load_key(password='Scal_0177')
- office_file.decrypt(decrypted_workbook)
- workbook = openpyxl.load_workbook(filename=decrypted_workbook)
- mysheet = workbook.active
- myrows = list(mysheet.values)[1:]
- mytitle = list(mysheet.values)[0]
- for myrow in myrows:
- mydics0 = {}
- mydics1 = {}
- for i in range(0, (len(mytitle))):
- a = get_full_pinyin1(str(myrow[0])) + ":" + get_full_pinyin2(str(myrow[0]))
- mydics0[mytitle[i]] = "%s"%myrow[i]
- mydics0[mytitle[11]] = "%s" % a
- if i != 3 and i != 11:
- mydics1[mytitle[i]] = "'%s'" % myrow[i]
- elif i == 11:
- mydics1[mytitle[11]] = "'%s'" % a
- #a= fdb.getSingledata("工号",'workerinfo')
- if str(mydics0["工号"]) in str(fdb.getSingledata("工号",'workerinfo')):
- fdb.lazyUpdateItem('workerinfo',mydics1,"工号='%s'"%mydics0["工号"])
- else:
- fdb.lazyInsertData('workerinfo',mydics0)
- #print(1)
- fdb.FunctionCommit()
- return 1
- except Exception:
- print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查通讯录文件!人员显示功能失效!!')
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- # 需要QT输出警告弹框信息
- fdb.FunctionCommit()
- return 0
- except Exception:
- dingding_alert(traceback.format_exc())
- def manAddFlight(fdb:flightDB,flighttype,acno,eng,actype,flightno,flightdate,bay,eta,etd,user):
- starttime = flightdate + " 00:00:00"
- flightdate1 = datetime.datetime.strptime(starttime, "%Y-%m-%d %H:%M:%S")
- flightdate2 =flightdate.replace("-", "")
- flightids=fdb.getSingledata("航班编号","flightinfo%s"%flightdate2)
- ETD2=str("[计]"+etd[6:16]).replace("-", "/")
- flightid = "MAN" + str(acno) + str(flightno)+str(flightdate2)
- if flightid not in str(flightids):
- if flighttype =="航前":
- newdic={"航班编号":"%s"%flightid, "航班编号对":"", "机号":acno, "发动机":eng, "机型":actype, "保障航班号":flightno, "进港机场":"", "离港机场":"", "进出港航班号":flightno, "航班日期":flightdate1, "航班状态":"",
- "航班类型":flighttype, "非航前计划到达":"", "航前预计起飞":etd, "非航前实际到达":"", "非航前预计到达":"", "航前实际起飞":"", "非航前预计起飞":ETD2, "非航前预计进港机位":"",
- "非航前进港机位":"", "航前预计离港机位":"", "航前离港机位":bay, "维修人员":"", "放行人员":"", "维修状态":"", "重要航班":"", "随机":"", "保留":"", "备降返航":"", "维修状态时间":"", "二送人员":"", "二送状态":"",
- "附加消息":"人工添加", "取消标志":""}
- elif flighttype =="短停" or flighttype =="特后前":
- newdic = {"航班编号": "%s" % flightid, "航班编号对": "", "机号": acno, "发动机": eng, "机型": actype, "保障航班号": flightno,
- "进港机场": "", "离港机场": "", "进出港航班号": flightno, "航班日期": flightdate1, "航班状态": "","航班类型": flighttype, "非航前计划到达": "", "航前预计起飞": "", "非航前实际到达": eta, "非航前预计到达": eta, "航前实际起飞": eta,
- "非航前预计起飞": ETD2, "非航前预计进港机位": "","非航前进港机位": bay, "航前预计离港机位": "", "航前离港机位": "", "维修人员": "", "放行人员": "", "维修状态": "", "重要航班": "",
- "随机": "", "保留": "", "备降返航": "", "维修状态时间": "", "二送人员": "", "二送状态": "","附加消息": "人工添加", "取消标志": ""}
- else:
- newdic = {"航班编号": "%s" % flightid, "航班编号对": "", "机号": acno, "发动机": eng, "机型": actype, "保障航班号": flightno,
- "进港机场": "", "离港机场": "", "进出港航班号": flightno, "航班日期": flightdate1, "航班状态": "", "航班类型": flighttype,
- "非航前计划到达": "", "航前预计起飞": "", "非航前实际到达": "", "非航前预计到达": eta, "航前实际起飞": eta,
- "非航前预计起飞": "", "非航前预计进港机位": "", "非航前进港机位": bay, "航前预计离港机位": "", "航前离港机位": "", "维修人员": "", "放行人员": "",
- "维修状态": "", "重要航班": "",
- "随机": "", "保留": "", "备降返航": "", "维修状态时间": "", "二送人员": "", "二送状态": "", "附加消息": "人工添加", "取消标志": ""}
- fdb.insertData("flightinfo%s"%flightdate2,newdic)
- else:
- if flighttype =="航前":
- newdic={"航班编号":"'%s'"%flightid,"机号":"'%s'"%acno, "非航前预计起飞":"'%s'"%ETD2,"发动机":"'%s'"%eng, "机型":"'%s'"%actype, "保障航班号":"'%s'"%flightno,"进出港航班号":"'%s'"%flightno, "航班日期":"'%s'"%flightdate1,"航班类型":"'%s'"%flighttype, "航前预计起飞":"'%s'"%etd, "航前离港机位":"'%s'"%bay}
- elif flighttype =="短停" or flighttype =="特后前":
- 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}
- else:
- newdic = {"航班编号": "'%s'" % flightid,"机号":"'%s'"% acno, "发动机":"'%s'"% eng, "机型":"'%s'"% actype, "保障航班号":"'%s'"% flightno,"进出港航班号":"'%s'"% flightno, "航班日期":"'%s'"% flightdate1, "航班类型":"'%s'"% flighttype, "非航前预计到达":"'%s'"% eta,"航前实际起飞": "'%s'"% eta, "非航前进港机位":"'%s'"% bay}
- fdb.upDateItem("flightinfo%s"%flightdate2,newdic,"航班编号='%s'"%flightid)
- sortFlighttime(flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- ))
- sortFlighttime2(flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- ))
- res={"返回值":"ok"}
- return res
- def deleteFlight(fdb:flightDB,flightid,time):
- fdb.deleteTable("flightinfo%s"%time,"航班编号='%s'"%flightid)
- res={"返回值":"ok"}
- sortFlighttime(flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- ))
- sortFlighttime2(flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- ))
- return res
- def updateStopFlight(database:flightDB, fileName):
- fdb = database
- textInfo={"机号":2,"非航前进港机位":3,"机型":4,"发动机":5}
- try:
- workbook = openpyxl.load_workbook(filename=fileName)
- mysheet = workbook.active
- myrows = list(mysheet.values)[2:]
- #print(myrows)
- #print(myrows[1])
- if myrows[0][1] != "" and myrows[0][2] != "" and myrows[0][1] != None and myrows[0][2] != None:
- #print(myrows[0])
- day=str(myrows[0][1]).split("/")[0]+str(myrows[0][1]).split("/")[1]+str(myrows[0][1]).split("/")[2]
- day1 = str(myrows[0][1]).split("/")[0] +"-"+ str(myrows[0][1]).split("/")[1] +"-"+ str(myrows[0][1]).split("/")[2]
- daytime = day1 + " 00:00:00"
- starttime = day1 + " 09:00:00"
- a = datetime.datetime.strptime(daytime, "%Y-%m-%d %H:%M:%S")
- b = datetime.datetime.strptime(starttime, "%Y-%m-%d %H:%M:%S")
- flightids=fdb.queryTabel("flightinfo%s"%day,"航班编号","航班类型 ='停场'")
- if len(flightids) != 0:
- for i in flightids:
- fdb.deleteSingledata("flightinfo%s"%day,"航班编号='%s'"%i[0])
- for myrow in myrows:
- mydics0 = {}
- if myrow[2] != None and myrow[1] != None and myrow[2] != "" and myrow[1] != "":
- now = str(time.time() * 1000000).split(".")[0]
- #print(now)
- flightid = "MAN" + str(now)+str(myrow[2])
- #print(flightid)
- for i in flightinfoLabel:
- if i in textInfo.keys():
- text=myrow[textInfo[i]] if myrow[textInfo[i]] !=None else ""
- mydics0[i] = "%s"%text
- elif i =="航班编号":
- mydics0[i]="%s"%flightid
- elif i =="航班日期":
- mydics0[i]="%s"%a
- elif i =="非航前实际到达":
- mydics0[i]="%s"%b
- elif i =="附加消息":
- mydics0[i]="人工添加"
- elif i =="航班类型":
- mydics0[i]="停场"
- else:
- mydics0[i]=''
- #print(mydics0)
- fdb.lazyInsertData("flightinfo%s"%day,mydics0)
- fdb.FunctionCommit()
- sortFlighttime(flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- ))
- sortFlighttime2(flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- ))
- print(datetime.datetime.now(), '[数据库操作]停场航班导入成功!')
- res = {"返回值": "ok"}
- return res
- except Exception:
- print(datetime.datetime.now(),'[数据库操作]停场航班导入失败!!检查模板文件!')
- print(traceback.format_exc())
- # 需要QT输出警告弹框信息
- res = {"返回值": "fail"}
- fdb.FunctionCommit()
- return res
- #新增内容
- def updateRiskdb(database:flightDB, fileName): #创建准备组提示数据库
- fdb = database
- fdb.deleteTable("RiskTable")
- try:
- workbook = openpyxl.load_workbook(filename=fileName)
- mysheet = workbook.active
- myrows = list(mysheet.values)[1:]
- mytitle = list(mysheet.values)[0]
- for myrow in myrows:
- mydics0 = {}
- for i in range(0, (len(mytitle))):
- mydics0[mytitle[i]] = "%s"%myrow[i]
- #print(mydics0)
- fdb.lazyInsertData('RiskTable',mydics0)
- fdb.FunctionCommit()
- return 1
- except Exception:
- dingding_alert(traceback.format_exc())
- print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查模板文件!风险提示功能失效!!')
- fdb.FunctionCommit()
- return 0
- def saveRisktable(database:flightDB):
- fdb = database
- res=fdb.getAlldata("RiskTable")
- if res == None:
- res =[]
- return res
- def getRiskData(fdb:flightDB,bay,time):
- res = fdb.queryTabel("RiskTable","提示内容","状态='生效' and 触发条件1 ='%s' and 触发条件2 ='%s' "%(bay,time))
- tips= res[0][0] if res !=None and res !=[] and len(res) !=0 else ""
- return tips
- def updateTaskAuto(database:flightDB, fileName): #创建准备组提示数据库
- fdb = database
- fdb.deleteTable("taskAuto")
- try:
- workbook = openpyxl.load_workbook(filename=fileName)
- mysheet = workbook.active
- myrows = list(mysheet.values)[1:]
- mytitle = list(mysheet.values)[0]
- for myrow in myrows:
- mydics0 = {}
- for i in range(0, (len(mytitle))):
- mydics0[mytitle[i]] = "%s"%myrow[i]
- #print(mydics0)
- fdb.lazyInsertData('taskAuto',mydics0)
- fdb.FunctionCommit()
- return 1
- except Exception:
- dingding_alert(traceback.format_exc())
- print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查模板文件!准备组任务提示功能失效!!')
- fdb.FunctionCommit()
- return 0
- def initFlightDatabase(database:flightDB, datatime:str):
- try:
- fdb = database
- zhDic = {}
- sortDic={}
- logsDic = {}
- workerinfoDic = {}
- authorityDic = {}
- flightstsDic = {}
- TaskFlightinfoDic={}
- pglistDic={}
- peopleScheduleDic={}
- taskDic={}
- CalllistDic={}
- workjobDic = {}
- displayDic={}
- riskDic={}
- primaryKey = 'SERIAL PRIMARY KEY'
- primaryKey2 = 'INTEGER PRIMARY KEY NOT NULL'
- primaryKey3 ='TEXT PRIMARY KEY NOT NULL'
- for key1 in list(flightinfoLabel)[1:]:
- zhDic[key1] = 'text not null'
- for sortkey in list(sortLabel)[1:]:
- sortDic[sortkey]= 'text not null'
- for logskey in list(logsLabel)[1:]:
- logsDic[logskey]= 'text not null'
- for workerinfokey in list(workerinfoLabel)[1:]:
- workerinfoDic[workerinfokey]= 'text not null'
- for authoritykey in list(authorityLabel)[1:]:
- authorityDic[authoritykey]= 'text not null'
- for flightstskey in list(flightstsLabel)[1:]:
- flightstsDic[flightstskey]= 'text not null'
- for flightstskey in list(TaskflightinfoLabel)[1:]:
- TaskFlightinfoDic[flightstskey]= 'text not null'
- for pglistkey in list(pglistLabel)[1:]:
- pglistDic[pglistkey] = 'text not null'
- for peopleScheduleKey in list(peopleScheduleLabel)[1:]:
- peopleScheduleDic[peopleScheduleKey] = 'text not null'
- for CalllistKey in list(CalllistLabel)[1:]:
- if CalllistKey == '拨号次数':
- CalllistDic[CalllistKey] = 'int'
- else:
- CalllistDic[CalllistKey] = 'text not null'
- for taskkey in list(taskLabel)[1:]:
- taskDic[taskkey]= 'text not null'
- for workjobkey in list(workjobkeyLabel)[1:]:
- workjobDic[workjobkey]= 'text not null'
- for displaykey in list(displayLabel)[1:]:
- displayDic[displaykey]= 'text not null'
- for riskkey in list(RiskLabel)[1:]:
- riskDic[riskkey]= 'text not null'
- nowDayStr = datatime
- fdb.initTable('pglist{}'.format(nowDayStr),"姓名", primaryKey3,pglistDic)
- fdb.initTable('flightinfo{}'.format(nowDayStr),"航班编号",primaryKey3, zhDic)
- fdb.initTable('sortFlight2{}'.format(nowDayStr), "编号", primaryKey3, sortDic)
- fdb.initTable('sortFlight{}'.format(nowDayStr), "编号",primaryKey3, sortDic)
- fdb.initTable('logs', "编号",primaryKey, logsDic)
- fdb.initTable('taskAuto', "编号", primaryKey3, taskDic)
- fdb.initTable('workerinfo',"工号", primaryKey3, workerinfoDic)
- fdb.initTable('authority',"编号", primaryKey, authorityDic)
- fdb.initTable('flightsts{}'.format(nowDayStr),"航班编号", primaryKey3, flightstsDic)
- fdb.initTable('TaskFlightinfo{}'.format(nowDayStr), "航班编号", primaryKey3, TaskFlightinfoDic)
- fdb.initTable('peopleSchedule{}'.format(nowDayStr), "编号", primaryKey3, peopleScheduleDic)
- fdb.initTable('Calllist', "航班编号", primaryKey3, CalllistDic)
- fdb.initTable('workjob', "任务编号", primaryKey3, workjobDic)
- fdb.initTable('display', "ID", primaryKey3, displayDic)
- fdb.initTable('RiskTable', "风险编号", primaryKey3, riskDic)
- if len(fdb.getSingledata("A",'display')) == 0:
- fdb.insertData('display', {'ID': 1, 'A': '{}','B': '{}'})
- fdb.insertData('display', {'ID': 2, 'A': '{}','B': '{}'})
- fdb.insertData('display', {'ID': 3, 'A': '{}','B': '{}'})
- except Exception:
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def insertCalllist(fdb,data):
- try:
- #CalllistLabel1 = ["航班编号", "电话", "工号", "姓名", "航班号", "附加消息", "拨号次数", "创建时间", "接通时间"]
- now = datetime.datetime.now()
- data["创建时间"]=now
- data["接通时间"] = ''
- fdb.insertData('Calllist',data)
- #print("test")
- res={"返回值":"ok"}
- return res
- except Exception:
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def checkTFUairplane(database:flightDB):
- try:
- code = {"接机已到位提示","已放行提示","二送已到位提示"}
- code2 = {"接机已到位提示", "已放行提示"}
- #需要建立昨日初始化
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- now = datetime.datetime.now()
- now11=str(now).split(".")[0]
- day = [nowDay, nowDay_1]
- for nowDayStr in day:
- AFinsky_arr = []
- AFongroud_arr = []
- TRinsky_arr = []
- TRongroud_arr = []
- THQinsky_arr = []
- THQongroud_arr = []
- APongroud_arr = []
- flightsts_flight_ids_arr=[]
- AFinsky=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='航后' and 非航前预计到达!='' and 非航前实际到达=''and 航前实际起飞!=''")
- AFongroud=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='航后' and 非航前实际到达!=''")
- TRinsky=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='短停' and 非航前预计到达!='' and 非航前实际到达='' and 航前实际起飞!=''")
- TRongroud = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='短停' and 非航前实际到达!='' and (非航前预计起飞 like '%预%' or 非航前预计起飞 like '%计%')")
- THQinsky = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号',"航班类型='特后前' and 非航前预计到达!='' and 非航前实际到达=''and 航前实际起飞!=''")
- THQongroud=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='特后前' and 非航前实际到达!='' and (非航前预计起飞 like '%预%' or 非航前预计起飞 like '%计%')")
- APongroud=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='航前' and 航前实际起飞 =''")
- ##################################
- #缺个未显示的航班筛选
- if len(AFinsky) != 0:
- for i in AFinsky:
- AFinsky_arr.append(i[0])
- if len(AFongroud) != 0:
- for i in AFongroud:
- AFongroud_arr.append(i[0])
- if len(TRinsky) != 0:
- for i in TRinsky:
- TRinsky_arr.append(i[0])
- if len(TRongroud) != 0:
- for i in TRongroud:
- TRongroud_arr.append(i[0])
- if len(THQinsky) != 0:
- for i in THQinsky:
- THQinsky_arr.append(i[0])
- if len(THQongroud) != 0:
- for i in THQongroud:
- THQongroud_arr.append(i[0])
- if len(APongroud) != 0:
- for i in APongroud:
- APongroud_arr.append(i[0])
- flightsts_flight_ids=database.getSingledata('航班编号','flightsts{}'.format(nowDayStr))
- flightinfo_flight_ids=database.getSingledata('航班编号','flightinfo{}'.format(nowDayStr))
- if len(flightsts_flight_ids) != 0:
- for flightstskey in flightsts_flight_ids:
- newdic={"天府飞机":"''"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%flightstskey[0])
- if flightstskey in flightinfo_flight_ids:
- flightsts_flight_ids_arr.append(flightstskey[0])
- else:
- database.deleteSingledata('flightsts{}'.format(nowDayStr),"航班编号='%s'"%flightstskey[0])
- for AFinsky_arr_key in AFinsky_arr:
- if AFinsky_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机":"'空中航后'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%AFinsky_arr_key)
- else:
- newdic={"航班编号":"%s"%AFinsky_arr_key,"接机到位":"","放行":"","销子夹板":"","随机到位":"","二送到位":"","接机已到位提示":"","已放行提示":"","销子夹板已提示":"","随机已到位提示":"","二送已到位提示":"","天府飞机":'空中航后',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for AFongroud_arr_key in AFongroud_arr:
- if AFongroud_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机": "'地面航后'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%AFongroud_arr_key)
- else:
- newdic = {"航班编号": "%s" % AFongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
- "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面航后',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for TRinsky_arr_key in TRinsky_arr:
- if TRinsky_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机": "'空中短停'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%TRinsky_arr_key)
- else:
- newdic = {"航班编号": "%s" % TRinsky_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
- "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '空中短停',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for TRongroud_arr_key in TRongroud_arr:
- if TRongroud_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机": "'地面短停'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%TRongroud_arr_key)
- else:
- newdic = {"航班编号": "%s" % TRongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
- "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面短停',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for THQinsky_arr_key in THQinsky_arr:
- if THQinsky_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机": "'空中特后前'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%THQinsky_arr_key)
- else:
- newdic = {"航班编号": "%s" % THQinsky_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
- "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '空中特后前',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for THQongroud_arr_key in THQongroud_arr:
- if THQongroud_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机": "'地面特后前'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%THQongroud_arr_key)
- else:
- newdic = {"航班编号": "%s" % THQongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
- "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面特后前',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for APongroud_arr_key in APongroud_arr:
- #print(APongroud_arr_key)
- if APongroud_arr_key in flightsts_flight_ids_arr:
- newdic = {"天府飞机":"'地面航前'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%APongroud_arr_key)
- else:
- newdic = {"航班编号": "%s" % APongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
- "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面航前',"机号":"","机位":""}
- database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
- for flightstskey in flightinfo_flight_ids:
- acno_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "机号", "航班编号='{}'".format(flightstskey[0]))
- if "航前" not in database.queryTabel('flightinfo{}'.format(nowDayStr), "航班类型", "航班编号='{}'".format(flightstskey[0])):
- bay_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "航前离港机位", "航班编号='{}'".format(flightstskey[0]))
- else:
- bay_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "非航前进港机位", "航班编号='{}'".format(flightstskey[0]))
- newdic = {"机位":"'%s'"%bay_str[0], "机号":"'%s'"%acno_str[0]}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
- worksts_str=database.queryTabel('flightinfo{}'.format(nowDayStr), "维修状态", "航班编号='{}'".format(flightstskey[0]))
- worksts_STR = worksts_str[0][0] if len(worksts_str) != 0 else 0
- worksts = int(worksts_STR) if worksts_STR != "" else 0
- a=database.queryTabel('flightsts{}'.format(nowDayStr),"机号","航班编号='%s'" % flightstskey[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr),"机号","航班编号='%s'" % flightstskey[0])) != 0 else "未显示机号"
- if worksts >= 7 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
- newdic={"接机到位":"'已到位'", "放行": "'已放行'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
- for i in code2:
- if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"%s"%i,"航班编号='%s'" % flightstskey[0]):
- newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s%s!%s"%(a,i,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- newdic = {"%s"%i: 1}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
- elif worksts >= 4 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
- newdic = {"接机到位": "'已到位'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
- if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"接机已到位提示","航班编号='%s'" % flightstskey[0]):
- newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s接机已到位提示!%s"%(a,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- newdic = {"接机已到位提示": 1}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'"% flightstskey[0])
- ECSJ_worksts_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "二送状态", "航班编号='{}'".format(flightstskey[0]))
- ECSJ_worksts_STR = ECSJ_worksts_str[0][0] if len(ECSJ_worksts_str) != 0 else 0
- ECSJ_worksts = int(ECSJ_worksts_STR) if ECSJ_worksts_STR != "" else 0
- a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flightstskey[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flightstskey[0])) != 0 else "未显示机号"
- if ECSJ_worksts >= 15 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
- newdic = {"接机到位": "'已到位'", "放行": "'已放行'", "二送到位": "'已到位'"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
- for i in code:
- if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"%s"%i,"航班编号='%s'" % flightstskey[0]):
- newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s%s!%s"%(a,i,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newdic)
- newdic = {"%s"%i: 1}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
- database.FunctionCommit()
- except Exception:
- dingding_alert(traceback.format_exc())
- database.FunctionCommit()
- def dingdingDelete_flight(database:flightDB):
- try:
- dmac={}
- # 需要建立昨日初始化
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- day = [nowDay_1,nowDay]
- for nowDayStr in day:
- tfac_ids=database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","CAST(级别 AS integer)=1")
- if len(tfac_ids) != 0:
- for i in tfac_ids:
- acno=database.queryTabel('flightinfo{}'.format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
- type=database.queryTabel('flightinfo{}'.format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
- if acno in dmac.keys() and type !="航前":
- dmac[acno]=i[0]
- elif acno not in dmac.keys():
- dmac[acno] = i[0]
- try:
- res = requests.post(url="http://124.223.185.200:888/delete_flight/", data=json.dumps(dmac),timeout=5) # 自己服务器
- #flightsts = res.json()
- #print(flightsts)
- except Exception:
- dingding_alert(traceback.format_exc())
- pass
- #QT输出弹窗警告,服务器链接失效
- except Exception:
- dingding_alert(traceback.format_exc())
- def dingdinginfoget(database:flightDB):
- try:
- infos={}
- try:
- resfwq = requests.get(url="http://124.223.185.200:4567/get_deal_info/", timeout=10) # 自己服务器
- if resfwq.json() != "":
- infos = resfwq.json()
- except Exception:
- dingding_alert(traceback.format_exc())
- pass
- #print("infos",infos)
- if infos !={}:
- now = datetime.datetime.now()
- for i in infos.keys():
- info=str(infos[i]["info"].split("信息上报")[0])+str(now.strftime("%Y-%m-%d %H:%M:%S"))+"上报信息,鼠标停留查看详情"
- newdic = {"航班编号": "%s" % i, "警告信息": "%s"%info, "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "", "显示对象": "", "提示内容": "%s"%infos[i]["info"]}
- database.lazyInsertData('logs', newdic)
- database.FunctionCommit()
- except Exception:
- dingding_alert(traceback.format_exc())
- database.FunctionCommit()
- def dingdingFlightsts(database:flightDB):
- try:
- flightsts = {}
- sever_code={"JJDW":"接机到位","FX":"放行","SJDW":"随机到位","XJ":"销子夹板","ESDW":"二送到位"}
- sever_code1 = {"JJDW": "已到位", "FX": "已放行", "SJDW": "已到位", "XJ": "已取下", "ESDW": "已到位"}
- code2 = {"JJDW": "接机已到位", "FX": "已放行", "SJDW": "随机已到位", "XJ": "销子夹板已取下", "ESDW": "二送已到位"}
- code3 = {"JJDW": "接机已到位提示", "FX": "已放行提示", "SJDW": "随机已到位提示", "XJ": "销子夹板已提示", "ESDW": "二送已到位提示"}
- try:
- resfwq = requests.get(url="http://124.223.185.200:888/search_status/", timeout=10) # 自己服务器
- if resfwq.json() != "":
- flightsts = resfwq.json()
- #print(flightsts)
- #测试数据
- #flightsts={'30CA':{"JJDW": 1, "FX": 1, "SJDW": 1, "XJ": 1, "ESDW": 1},'300D':{"JJDW": 1, "FX": 1, "SJDW": 1, "XJ": 1, "ESDW": 0}}
- except Exception:
- dingding_alert(traceback.format_exc())
- pass
- # QT输出弹窗警告,服务器链接失效
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- now = datetime.datetime.now()
- now11=str(now).split(".")[0]
- day = [nowDay_1, nowDay]
- tfac_acs=[]
- for nowDayStr in day:
- dmacs = database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","CAST(级别 AS integer)=1")
- for i in dmacs:
- dmac=database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'"%i[0])
- if str(dmac[0]) not in str(tfac_acs):
- tfac_acs.append(dmac[0])
- if len(tfac_acs) != 0:
- for i in tfac_acs:
- #print(i[0])
- if i[0] in flightsts.keys():
- for j,k in sever_code.items():
- if flightsts[i[0]][j] == 1:
- newdic={"%s"%k:"'%s'"%sever_code1[j]}
- #print(newdic)
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"机号='%s' and 天府飞机!=''"%i[0])
- newdic={}
- 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"
- 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 "未显示机号"
- if a !="1":
- newdic={"%s"%code3[j]:1}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "机号='%s' and 天府飞机!=''" % i[0])
- newdic={"航班编号":"%s"%b,"警告信息":"","信息状态":"","提示信息":"钉钉:%s%s!%s"%(i[0],code2[j],now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
- database.lazyInsertData('logs',newdic)
- database.FunctionCommit()
- #########################################
- #引入钉钉显示
- ########################################
- except Exception:
- dingding_alert(traceback.format_exc())
- database.FunctionCommit()
- def waringMessageID(database:flightDB):
- try:
- waringMessageID1_arr=[]
- waringMessageID2_arr = []
- waringMessageID3_arr = []
- waringMessageID4_arr = []
- waringMessageID5_arr = []
- waringMessageID6_arr = []
- waringMessageID0_arr = []
- waringMessageID_arrs={}
- waringMessageIDs=database.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
- if len(waringMessageIDs) != 0:
- for i in waringMessageIDs:
- waringMessageID0_arr.append(i[1])
- if i[8] == "到位警告":
- waringMessageID1_arr.append(i[1])
- elif i[8] == "二送警告":
- waringMessageID2_arr.append(i[1])
- elif i[8] == "非航前预计到达":
- waringMessageID3_arr.append(i[1])
- elif i[8] == "非航前进港机位":
- waringMessageID4_arr.append(i[1])
- elif i[8] == "非航前预计起飞":
- waringMessageID5_arr.append(i[1])
- else:
- waringMessageID6_arr.append(i[1])
- waringMessageID_arrs["到位警告"]=waringMessageID1_arr
- waringMessageID_arrs["二送警告"] = waringMessageID2_arr
- waringMessageID_arrs["ETA"] = waringMessageID3_arr
- waringMessageID_arrs["BAY_2"] = waringMessageID4_arr
- waringMessageID_arrs["TD"] = waringMessageID5_arr
- waringMessageID_arrs["通用警告"] = waringMessageID6_arr
- waringMessageID_arrs["全部警告"] = waringMessageID0_arr
- return waringMessageID_arrs
- except Exception:
- dingding_alert(traceback.format_exc())
- def sortFlighttime2(database:flightDB):
- try:
- sortLabel = ["编号", "航班编号", "保障时间", "航班类型", "航班日期", "级别"]
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
- now = datetime.datetime.now()
- now_20 = (datetime.datetime.now() + datetime.timedelta(minutes=200)).strftime("%Y%m%d")
- initFlightDatabase(database, now_20)
- initFlightDatabase(database, nowDay_1)
- initFlightDatabase(database, nowDay_2)
- initFlightDatabase(database, nowDay)
- if now_20 == nowDay:
- day = [nowDay, nowDay_1]
- else:
- day = [nowDay, nowDay_1, nowDay_2]
- for selectedtime in day:
- sort2NOs_arr=[]
- sort2NOs = database.getSingledata("编号","sortFlight2{}".format(selectedtime))
- sortNOs = database.getSingledata("编号", "sortFlight{}".format(selectedtime))
- if sort2NOs !=None and len(sort2NOs)!=0:
- for i in sort2NOs:
- if str(i) in str(sortNOs):
- sort2NOs_arr.append(i[0])
- else:
- database.deleteSingledata("sortFlight2{}".format(selectedtime),"编号 = '%s'"%i[0])
- sorttable = getSortFlightdata(database, selectedtime,"sortFlight")
- for row in sorttable:
- if row[3] == "短停接" or row[3] == "特后前接":
- if str(row[5]) == "4":
- find_id = row[1] + "-2"
- for row2 in sorttable:
- if row2[0] == find_id and row2[5] == "4":
- jb = row[5]
- elif row2[0] == find_id:
- jb = "1"
- else:
- jb = row[5]
- newdic = {}
- newdic2={}
- for col in range(0,6):
- if col == 0:
- newdic[sortLabel[col]]=row[col]
- elif col != 5:
- newdic[sortLabel[col]]=row[col]
- newdic2[sortLabel[col]]="'%s'"%row[col]
- else:
- newdic[sortLabel[5]]=jb
- newdic2[sortLabel[5]] = "'%s'"%jb
- if str(row[0]) not in str(sort2NOs_arr):
- database.lazyInsertData('sortFlight2{}'.format(selectedtime),newdic)
- else:
- database.lazyUpdateItem('sortFlight2{}'.format(selectedtime),newdic2,"编号 = '%s'"%row[0])
- elif row[3] != "短停送" and row[3] != "特后前送":
- newdic = {}
- newdic2 = {}
- for col in range(0,6):
- if col == 0:
- newdic[sortLabel[col]]=row[col]
- else:
- newdic[sortLabel[col]]=row[col]
- newdic2[sortLabel[col]] = "'%s'"%row[col]
- if str(row[0]) not in str(sort2NOs_arr):
- database.lazyInsertData('sortFlight2{}'.format(selectedtime), newdic)
- else:
- database.lazyUpdateItem('sortFlight2{}'.format(selectedtime), newdic2, "编号 = '%s'" % row[0])
- database.FunctionCommit()
- except Exception:
- dingding_alert(traceback.format_exc())
- def sortFlighttime(database:flightDB):
- try:
- print(datetime.datetime.now(),'[数据库操作]开始排序')
- #yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- #today_search=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
- #tomorrow_search=(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
- now = datetime.datetime.now()
- now_20 = (datetime.datetime.now() + datetime.timedelta(minutes=200)).strftime("%Y%m%d")
- initFlightDatabase(database, now_20)
- initFlightDatabase(database, nowDay_1)
- initFlightDatabase(database, nowDay_2)
- initFlightDatabase(database, nowDay)
- if now_20 == nowDay:
- day = [nowDay, nowDay_1]
- else:
- day = [nowDay, nowDay_1, nowDay_2]
- for nowDayStr in day:
- #nowDayStr = datatime
- sort_flight_ids_arr=[]
- sort_flight_ids = database.getSingledata('编号','sortFlight{}'.format(nowDayStr))
- flightinfo_flight_ids = database.getSingledata('航班编号', 'flightinfo{}'.format(nowDayStr))
- if len(sort_flight_ids) != 0:
- for sortkey in sort_flight_ids:
- sort_flight_id=database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","编号='%s'"%sortkey[0])[0]
- if str(sort_flight_id) in str(flightinfo_flight_ids):
- sort_flight_ids_arr.append(sortkey[0])
- else:
- database.deleteSingledata('sortFlight{}'.format(nowDayStr),"编号='%s'"%sortkey[0])
- for i in flightinfo_flight_ids:
- #print(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0]))
- flight_date_str=database.queryTabel("flightinfo{}".format(nowDayStr),"航班日期","航班编号='%s'"%i[0])[0][0]
- if database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] == "航前" and "MAN" not in str(i[0]):
- if database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]!= "":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
- time_str = flight_date_str.split("-")[0] + "/" + time.split("]")[1]
- sendtime = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
- ii=str(i[0])+str(-2)
- iii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0],"保障时间": "%s" % sendtime, "航班类型": "航前",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- #print('插入{}'.format(newdic))
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] !="":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0]
- sendtime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- ii=str(i[0])+str(-2)
- iii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % sendtime, "航班类型": "航前",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] == "航前" and "MAN" in str(i[0]):
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
- time_str = flight_date_str.split("-")[0] + "/" + time.split("]")[1]
- sendtime = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
- sendtime2 = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M")
- if now < sendtime2:
- ii=str(i[0])+str(-2)
- iii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0],"保障时间": "%s" % sendtime, "航班类型": "航前",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- #print('插入{}'.format(newdic))
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- else:
- ii=str(i[0])+str(-2)
- iii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime2,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % sendtime2, "航班类型": "航前",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "停场":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- ii = str(i[0]) + str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'停场'",
- "航班日期": "'%s'" % flight_date_str, "级别": "3"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "停场",
- "航班日期": "%s" % flight_date_str, "级别": 3}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="航后" and "MAN" not in str(i[0]):
- if database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] !="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]!="" :
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] !="":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"3"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 3}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!="" :
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="航后" and "MAN" in str(i[0]):
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- receivetime2= datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- if now < receivetime2:
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- else:
- ii=str(i[0])+str(-1)
- iii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"3"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "航后",
- "航班日期": "%s" % flight_date_str, "级别": 3}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- if iii in str(sort_flight_ids_arr):
- database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="短停" and "MAN" not in str(i[0]):
- if database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] != "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0] !="":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] =="" and\
- database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] !="":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] !="":
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="短停" and "MAN" in str(i[0]):
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- receivetime2 = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- if now < receivetime2:
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- else:
- ii=str(i[0])+str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "短停接",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="特后前" and "MAN" not in str(i[0]):
- if database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
- 0] != "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][
- 0] != "":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][
- 0] == "" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
- 0] != "":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] != "":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][
- 0] == "特后前" and "MAN" in str(i[0]):
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- receivetime2 = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
- if now < receivetime2:
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- else:
- ii = str(i[0]) + str(-1)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime2,
- "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "特后前接",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "短停" and "MAN" not in str(i[0]):
- if "[实]" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])):
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
- receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- ii=str(i[0])+str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] !="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
- receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'短停送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
- receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'短停送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "短停" and "MAN" in str(i[0]):
- time1 = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- receivetime1 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
- receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- receivetime2 = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M")
- if now<receivetime1:
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'短停送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
- "航班类型": "短停送",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif receivetime1<now<receivetime2:
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'短停送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
- "航班类型": "短停送",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- else:
- ii=str(i[0])+str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'短停送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "短停送",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "特后前" and "MAN" not in str(i[0]):
- if "[实]" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])):
- time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
- receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- ii=str(i[0])+str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型": "'特后前送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] !="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
- receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'特后前送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] =="" and \
- database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
- receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'特后前送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
- if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][
- 0] == "特后前" and "MAN" in str(i[0]):
- time1 = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
- receivetime1 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
- time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
- receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
- receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(
- minutes=25)
- receivetime2 = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M")
- if now < receivetime1:
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "2"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
- "航班类型": "特后前送",
- "航班日期": "%s" % flight_date_str, "级别": 2}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- elif receivetime1 < now < receivetime2:
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
- "航班类型": "'特后前送'",
- "航班日期": "'%s'" % flight_date_str, "级别": "1"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
- "航班类型": "特后前送",
- "航班日期": "%s" % flight_date_str, "级别": 1}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- else:
- ii = str(i[0]) + str(-2)
- if ii in str(sort_flight_ids_arr):
- newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime2,
- "航班类型": "'特后前送'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
- database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
- else:
- newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "特后前送",
- "航班日期": "%s" % flight_date_str, "级别": 4}
- database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
- database.FunctionCommit()
- except Exception:
- dingding_alert(traceback.format_exc())
- database.FunctionCommit()
- print(datetime.datetime.now(),'[数据库操作]结束排序')
- def checkWorkerlaod(database:flightDB, workload:flightDB,nowDayStr1,nowDay_11):
- try:
- #需要初始化表格
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- day=[nowDay_1,nowDay]
- nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
- #nowDayStr_search=datetime.datetime.strptime(str("2023-06-11 00:00:00"),"%Y-%m-%d %H:%M:%S")
- yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
- workernames_arr=[]
- workernames1=database.getSingledata('姓名','pglist%s'%nowDayStr1)
- if len(workernames1) != 0:
- for i in workernames1:
- workernames_arr.append(i[0])
- workernames2 = database.getSingledata('姓名', 'pglist%s' % nowDay_11)
- if len(workernames2) != 0:
- for i in workernames2:
- workernames_arr.append(i[0])
- for worker in workernames_arr:
- if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker))!= 0:
- worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
- else:
- worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
- # worker_number = a if len(a) !=0 else ""
- single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
- single_worker_load_ids_arr = []
- if len(single_worker_load_ids) != 0:
- for l in single_worker_load_ids:
- single_worker_load_ids_arr.append(l[0])
- for nowDayStr in day:
- worker_laod_ids=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "维修人员 like '%{}%'".format(worker))
- worker_laod_ids_arr = []
- if len(worker_laod_ids)!= 0:
- for j in worker_laod_ids:
- worker_laod_ids_arr.append(j[0])
- if len(worker_laod_ids_arr) != 0:
- for k in worker_laod_ids_arr:
- TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'"%k)[0][0]
- #TYPE = a[0] if len(a) !=0 else ""
- acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
- #acno = a[0] if len(a) !=0 else ""
- bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
- bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
- #bay = a[0] if len(a) !=0 else ""
- flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
- flight_id_1=str(str(flight_id))+str("-1") #接机保障标志
- flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
- #print(flight_id_1)
- #flight_id = a[0] if len(a) !=0 else ""
- flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
- #flight_date = a[0] if len(a) !=0 else ""
- if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
- eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
- starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- endtime=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前实际到达', "航班编号='%s'"%k)[0][0]
- if flight_id_1 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
- workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
- else:
- newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
- workload.lazyInsertData('workload%s'%worker_number, newdic)
- elif TYPE == '航前' and database.queryTabel('flightinfo{}'.format(nowDayStr), '航前预计起飞', "航班编号 ='%s'"%k)[0][0] != "":
- endtime_ap = database.queryTabel('flightinfo{}'.format(nowDayStr),'航前实际起飞', "航班编号='{}'".format(k))[0][0]
- STD_ap=database.queryTabel('flightinfo{}'.format(nowDayStr),'航前预计起飞', "航班编号='{}'".format(k))[0]
- #STD_time_str =flight_date[0].split("-")[0] + "/" + STD_ap[0].split("]")[1]
- #print(STD_ap)
- starttime_ap = datetime.datetime.strptime(STD_ap[0], "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=90)
- if flight_id_1 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay1, "开始时间": "'%s'"%starttime_ap, "结束时间": "'%s'"%endtime_ap, "航班类型": "'%s'"%TYPE}
- workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='%s'"%flight_id_1)
- else:
- newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s"%bay1, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime_ap,
- "结束时间": "%s" % endtime_ap, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
- workload.lazyInsertData('workload%s'%worker_number, newdic)
- elif TYPE == '航后' and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
- eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
- starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) == "8":
- endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
- else:
- endtime=""
- if flight_id_1 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime,
- "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_1))
- else:
- newdic = {"编号": "%s" % flight_id_1, "机号": "%s" % acno, "机位": "%s" % bay,
- "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE, "人员状态": ""}
- workload.lazyInsertData('workload%s' % worker_number, newdic)
- elif TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
- eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
- starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- if "[实]" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]):
- endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
- endtime_str1 =flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
- endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
- else:
- endtime = ""
- if flight_id_1 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
- workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
- else:
- newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
- workload.lazyInsertData('workload%s'%worker_number, newdic)
- if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)) != 0:
- worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
- else:
- worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
- single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
- single_worker_load_ids_arr = []
- if len(single_worker_load_ids) != 0:
- for l in single_worker_load_ids:
- single_worker_load_ids_arr.append(l[0])
- FX_laod_ids = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "放行人员 like '%{}%'".format(worker))
- FX_laod_ids_arr = []
- if len(FX_laod_ids) != 0:
- for j in FX_laod_ids:
- FX_laod_ids_arr.append(j[0])
- if len(FX_laod_ids_arr) != 0:
- for k in FX_laod_ids_arr:
- TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'"%k)[0][0]
- #TYPE = a[0] if len(a) !=0 else ""
- acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
- #acno = a[0] if len(a) !=0 else ""
- bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
- bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
- #bay = a[0] if len(a) !=0 else ""
- flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
- flight_id_1=str(str(flight_id))+str("-1") #接机保障标志
- flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
- #print(flight_id_1)
- #flight_id = a[0] if len(a) !=0 else ""
- flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
- #flight_date = a[0] if len(a) !=0 else ""
- if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
- eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
- starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "7":
- endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
- else:
- endtime = ""
- if flight_id_1 in single_worker_load_ids_arr:
- if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'"%flight_id_1)[0][0] =="":
- newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
- workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
- else:
- newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
- workload.lazyInsertData('workload%s'%worker_number, newdic)
- elif TYPE == '航前' and database.queryTabel('flightinfo{}'.format(nowDayStr), '航前预计起飞', "航班编号 ='%s'"%k)[0][0] != "":
- if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "7":
- endtime_ap = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
- else:
- endtime_ap = ""
- STD_ap=database.queryTabel('flightinfo{}'.format(nowDayStr),'航前预计起飞', "航班编号='{}'".format(k))[0]
- #STD_time_str =flight_date[0].split("-")[0] + "/" + STD_ap[0].split("]")[1]
- #print(STD_ap)
- starttime_ap = datetime.datetime.strptime(STD_ap[0], "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=90)
- if flight_id_1 in single_worker_load_ids_arr:
- if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'" % flight_id_1)[0][0] == "":
- newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay1, "开始时间": "'%s'"%starttime_ap, "结束时间": "'%s'"%endtime_ap, "航班类型": "'%s'"%TYPE}
- workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='%s'"%flight_id_1)
- else:
- newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s"%bay1, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime_ap,
- "结束时间": "%s" % endtime_ap, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
- workload.lazyInsertData('workload%s'%worker_number, newdic)
- elif TYPE == '航后' and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
- eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
- starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "8":
- endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
- else:
- endtime=""
- if flight_id_1 in single_worker_load_ids_arr:
- if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'" % flight_id_1)[0][0] == "":
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime,
- "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_1))
- else:
- newdic = {"编号": "%s" % flight_id_1, "机号": "%s" % acno, "机位": "%s" % bay,
- "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE, "人员状态": ""}
- workload.lazyInsertData('workload%s' % worker_number, newdic)
- elif TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
- eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
- starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
- if "[实]" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]):
- #print(flight_date)
- #print(endtime_str)
- endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
- #print(flight_date.split("-")[0])
- #print(endtime_str.split("]")[1])
- endtime_str1 =flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
- endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
- else:
- endtime = ""
- if flight_id_1 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
- workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
- else:
- newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
- workload.lazyInsertData('workload%s'%worker_number, newdic)
- if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)) != 0:
- worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
- else:
- worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
- single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
- single_worker_load_ids_arr = []
- if len(single_worker_load_ids) != 0:
- for l in single_worker_load_ids:
- single_worker_load_ids_arr.append(l[0])
- ECCJ_laod_ids = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "二送人员 like '%{}%'".format(worker))
- ECSJ_laod_ids_arr = []
- if len(ECCJ_laod_ids) != 0:
- for j in ECCJ_laod_ids:
- ECSJ_laod_ids_arr.append(j[0])
- if len(ECSJ_laod_ids_arr) != 0:
- for k in ECSJ_laod_ids_arr:
- TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'" % k)[0][0]
- # TYPE = a[0] if len(a) !=0 else ""
- acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
- # acno = a[0] if len(a) !=0 else ""
- bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
- bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
- # bay = a[0] if len(a) !=0 else ""
- flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
- flight_id_1 = str(str(flight_id)) + str("-1") # 接机保障标志
- flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
- # print(flight_id_1)
- # flight_id = a[0] if len(a) !=0 else ""
- flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
- # flight_date = a[0] if len(a) !=0 else ""
- if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0] != "":
- if "实" not in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
- starttime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
- starttime_str1 = flight_date.split("-")[0] + "/" + starttime_str.split("]")[1]
- starttime = datetime.datetime.strptime(starttime_str1, "%Y/%m/%d %H:%M")-datetime.timedelta(minutes=25)
- if flight_id_2 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
- else:
- newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
- "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "" , "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
- "人员状态": ""}
- workload.lazyInsertData('workload%s' % worker_number, newdic)
- if "实" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
- endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
- endtime_str1 = flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
- endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
- starttime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- if flight_id_2 in single_worker_load_ids_arr:
- if workload.queryTabel('workload%s' % worker_number, "开始时间", "编号='{}'".format(flight_id_2))[0][0] != "":
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
- else:
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay,"开始时间": "'%s'" % starttime, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
- else:
- newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
- "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s"%endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
- "人员状态": ""}
- workload.lazyInsertData('workload%s' % worker_number, newdic)
- if TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0] != "":
- if "实" not in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
- starttime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
- starttime_str1 = flight_date.split("-")[0] + "/" + starttime_str.split("]")[1]
- starttime = datetime.datetime.strptime(starttime_str1, "%Y/%m/%d %H:%M")-datetime.timedelta(minutes=25)
- if flight_id_2 in single_worker_load_ids_arr:
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
- else:
- newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
- "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "" , "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
- "人员状态": ""}
- workload.lazyInsertData('workload%s' % worker_number, newdic)
- if "实" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
- endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
- endtime_str1 = flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
- endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
- starttime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
- if flight_id_2 in single_worker_load_ids_arr:
- if workload.queryTabel('workload%s' % worker_number, "开始时间", "编号='{}'".format(flight_id_2))[0][0] != "":
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
- else:
- newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay,"开始时间": "'%s'" % starttime, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
- workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
- else:
- newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
- "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
- "结束时间": "%s"%endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
- "人员状态": ""}
- workload.lazyInsertData('workload%s' % worker_number, newdic)
- single_worker_load_twoday_ids = workload.queryTabel('workload%s' % worker_number, '编号',"保障日期='{}'or 保障日期='{}'".format(nowDayStr_search,yesterday_search))
- single_worker_load_twoday_ids_arr = []
- if len(single_worker_load_twoday_ids) != 0:
- for ll in single_worker_load_twoday_ids:
- single_worker_load_twoday_ids_arr.append(ll[0])
- worker_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号',"维修人员 like '%{}%'".format(worker))
- worker_laod_ids_twoday_arr = [] # 两天的量
- if len(worker_laod_ids) != 0:
- for j in worker_laod_ids:
- worker_laod_ids_twoday_arr.append(j[0])
- worker_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"维修人员 like '%{}%'".format(worker))
- if len(worker_laod_ids_yesterday) != 0:
- for m in worker_laod_ids_yesterday:
- worker_laod_ids_twoday_arr.append(m[0])
- FX_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号', "放行人员 like '%{}%'".format(worker))
- if len(FX_laod_ids) != 0:
- for j in FX_laod_ids:
- worker_laod_ids_twoday_arr.append(j[0])
- FX_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"放行人员 like '%{}%'".format(worker))
- if len(FX_laod_ids_yesterday) != 0:
- for m in FX_laod_ids_yesterday:
- worker_laod_ids_twoday_arr.append(m[0])
- ECSJ_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号', "二送人员 like '%{}%'".format(worker))
- if len(ECSJ_laod_ids) != 0:
- for j in ECSJ_laod_ids:
- worker_laod_ids_twoday_arr.append(j[0])
- #暂无昨日table,待完善后启用两日查询
- ECCJ_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"二送人员 like '%{}%'".format(worker))
- if len(ECCJ_laod_ids_yesterday) != 0:
- for m in ECCJ_laod_ids_yesterday:
- worker_laod_ids_twoday_arr.append(m[0])
- for kk in single_worker_load_twoday_ids_arr:
- if str(str(kk)[:-2]) not in str(worker_laod_ids_twoday_arr):
- workload.deleteSingledata('workload%s' % worker_number, "编号='{}'".format(kk))
- workload.FunctionCommit()
- except Exception:
- dingding_alert(traceback.format_exc())
- def initAuthority(database:flightDB):
- try:
- fdb = database
- primaryKey = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'
- labelKey = ['登录名', '密码', '权限', '使用人']
- dic = {}
- for key in labelKey:
- dic[key] = 'text not null'
- fdb.initTable('loginTable', 'ID', primaryKey, dic)
- except Exception:
- dingding_alert(traceback.format_exc())
- def insertDataToAuthority(database:flightDB):
- try:
- dataDic = {}
- dataDic['登录名'] = 'admin'
- dataDic['密码'] = 'admin123'
- dataDic['权限'] = '0'
- dataDic['使用人'] = '开发'
- rest = database.queryTabel('loginTable', '*', "登录名='admin'")
- #print(rest)
- if len(rest) == 0:
- database.insertData('loginTable', dataDic)
- except Exception:
- dingding_alert(traceback.format_exc())
- def insertDataToTable(database:flightDB, datatime:str, jsonData, jsonData2):
- try:
- #print(datetime.datetime.now(), "开始写入Flightinfo数据库")
- flightst_code={"4":"接机已到位提示","7":"已放行提示","11":"二送已到位提示"}
- bglist = ["ACNO", "FLIGHT_NO", "ETA", "BAY_2", "TASKTYPE", "TD", "BL", "SJ", "ZY_FLIGHT","FLG_VR", "STD"] # 需要播报的变更列表,应该与显示的相结合
- AFbglist=["ACNO", "FLIGHT_NO", "ETA", "BAY_2", "BL", "SJ", "ZY_FLIGHT"]
- APbglist=["ACNO", "FLIGHT_NO", "SJ", "STD"] #去掉了BAY BL ZY_FLIGHT
- TRbglist = ["ACNO", "FLIGHT_NO", "ETA", "BAY_2", "TD", "BL", "SJ", "ZY_FLIGHT"]
- notelist = ["STA", "ATA", "BAY1", "BAY2","TASKSTS_TIME"]
- nowDayStr = datatime
- now = datetime.datetime.now()
- insertdatestr=datatime + " 00:00:00"
- insertdate=datetime.datetime.strptime(insertdatestr, "%Y%m%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
- nowDay = datetime.datetime.now().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
- a_str = nowDay_str2 + " 20:30:00"
- b_str = nowDay_str2 + " 22:00:00"
- c_str = nowDay_str2 + " 09:00:00"
- time1 = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
- time2 = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
- time3 = datetime.datetime.strptime(c_str, "%Y-%m-%d %H:%M:%S")
- if now < time3:
- days=[nowDay,nowDay_1]
- elif time3 < now < time1:
- days=[nowDay]
- else:
- days=[nowDay,nowDay_2]
- #print("测试监测",nowDayStr,days)
- if nowDayStr in days:
- #print("测试插入",nowDayStr)
- if str(nowDay) !=str(nowDayStr) and time1 < now < time2:
- LOGsdeactive = 1
- else:
- LOGsdeactive= 0
- zh2en = {}
- en2zh = {}
- for key in range(len(headerLabel)):
- zh2en[headerLabel[key]] = headerLabelKey[key]
- for key in range(len(headerLabelKey)):
- en2zh[headerLabelKey[key]] = headerLabel[key]
- flightinfo_flight_ids_arr=[]
- flightinfo_flight_ids = database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"附加消息='AMRO'")
- if len(flightinfo_flight_ids) != 0:
- for i in flightinfo_flight_ids:
- flightinfo_flight_ids_arr.append(i[0])
- flight_id_now = []
- for i in [jsonData,jsonData2]:
- if jsonData !="" and jsonData2 !="" and jsonData2 !=None and jsonData !=None and jsonData != {} and jsonData2 != {} and len(jsonData)!=0 and len(jsonData2)!=0:
- for row in i:
- flight_id_now.append(row["FLIGHT_ID"])
- newDic2 = {}
- now11=str(now).split(".")[0]
- flightdate=str(row["FLIGHT_DATE"]).split(" ")[0][5:10]
- if str(row["FLIGHT_ID"]) not in str(flightinfo_flight_ids_arr) and str(insertdate)==row["FLIGHT_DATE"]:
- for col in row:
- if col in headerLabelKey:
- if col == 'TASKTYPE':
- if row["TASKTYPE"] !="" :
- newDic2[en2zh[col]] = taskType[row[col]]
- elif row["TASKTYPE"] =="" and "FLG_VR" not in row.keys():
- #newDic2[en2zh[col]] = "未显示"
- if row["ARR_DEP"] !="" :
- if row["ARR_DEP"][-1] =="-":
- newDic2[en2zh[col]] = "航后"
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]机号%s航班号%s,航班类型显示为空白,智能判断类型为航后,请核对FOC!!" % (flightdate,row["ACNO"],row["ARR_DEP"]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,"处理人": "","处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- elif row["ARR_DEP"][0] =="-":
- newDic2[en2zh[col]] = "航前"
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]机号%s航班号%s,航班类型显示为空白,智能判断类型为航前,请核对FOC!!" % (flightdate,row["ACNO"], row["ARR_DEP"]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- else:
- newDic2[en2zh[col]] = "短停"
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]机号%s航班号%s,航班类型显示为空白,智能判断类型为短停,请注意判断是否为特后前或保障正常航后航前,请核对FOC!!" % (flightdate,row["ACNO"], row["ARR_DEP"]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- elif row["TASKTYPE"] =="" and "FLG_VR" in row.keys():
- newDic2[en2zh[col]] = "短停"
- newDic3 = {"警告信息": "[%s]机号%s航班号%s为备降返航航班,航班类型显示为空白,智能判断类型为短停,请关注后续航班是否取消,请核对FOC!!" % (flightdate, row["ACNO"], row["ARR_DEP"]),"航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now, "处理人": "", "处理时间": "","变更字段": "%s" % zydy[col], "显示对象": "", "提示内容": ""}
- try:
- database.lazyInsertData('logs', newDic3)
- except Exception:
- dingding_alert(traceback.format_exc())
- pass
- elif row["ARR_DEP"] =="":
- newDic2[en2zh[col]] = "未显示"
- else:
- newDic2[en2zh[col]] = row[col]
- #database.FunctionCommit()
- for key in headerLabel:
- if key not in newDic2.keys():
- # print(key)
- newDic2[key] = ''
- newDic2['航班编号'] = str(row['FLIGHT_ID'])
- newDic2['取消标志'] = "0"
- newDic2['附加消息'] = "AMRO"
- database.lazyInsertData('flightinfo{}'.format(nowDayStr), newDic2)
- if len(flightinfo_flight_ids_arr) != 0 and "FLG_VR" not in row.keys():
- if row["TASKTYPE"] != "":
- a = taskType[row["TASKTYPE"]]
- else:
- # newDic2[en2zh[col]] = "未显示"
- if row["ARR_DEP"] != "" and row["ARR_DEP"][-1] == "-":
- a = "航后"
- elif row["ARR_DEP"] != "" and row["ARR_DEP"][0] == "-":
- a = "航前"
- elif row["ARR_DEP"] == "":
- a = "未显示"
- if LOGsdeactive == 0:
- newDic3={"警告信息":"有新增航班,[%s]机号:%s航班号:%s航班类型:%s,请注意核对FOC!!!"%(flightdate,row["ACNO"],row["FLIGHT_NO"],a),"航班编号":"%s"%row["FLIGHT_ID"],"信息状态":"","提示信息":"","产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"全部新增","显示对象":"","提示内容":""}
- database.lazyInsertData('logs',newDic3)
- elif len(flightinfo_flight_ids_arr) != 0 and "FLG_VR" in row.keys() and row["FLG_VR"] != "" :
- if row['FLG_VR'][0] == "V":
- newDic3 = {"警告信息": "有备降航班,[%s]机号为%s航班号%s,请核对FOC!" % (flightdate,row["ACNO"],row["FLIGHT_NO"]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "",
- "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "备降返航","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- if row['FLG_VR'][0] == "R":
- newDic3 = {"警告信息": "有返航航班,[%s]机号为%s航班号%s,请核对FOC!" % (flightdate,row["ACNO"],row["FLIGHT_NO"]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "",
- "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "备降返航","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- elif str(row["FLIGHT_ID"]) in str(flightinfo_flight_ids_arr) and str(row["FLIGHT_ID"]) !="":
- newdic = {"取消标志": "'0'"}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" %row["FLIGHT_ID"])
- acno=database.queryTabel("flightinfo{}".format(nowDayStr), "%s" % zydy["ACNO"],"航班编号='%s'" % row["FLIGHT_ID"])[0][0]
- if row["ACNO"] == acno:
- for col in headerLabelKey:
- #flightinfo_str=database.queryTabel("flightinf o{}".format(nowDayStr),"%s"%zydy[col],"航班编号='%s'"%row["FLIGHT_ID"])[0][0]
- #newflightinfo_str = taskType[row[col]]
- #newflightinfo_str1 = taskSTS[row[col]]
- #c= database.queryTabel("flightinfo{}".format(nowDayStr), "%s" % zydy[col], "航班编号='%s'" % row["FLIGHT_ID"])[0][0]
- b= database.queryTabel("flightinfo{}".format(nowDayStr),"%s"%zydy[col],"航班编号='%s'"%row["FLIGHT_ID"])[0][0]
- bb = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % row["FLIGHT_ID"])[0][0]
- if row["TASKTYPE"] != "":
- a = taskType[row["TASKTYPE"]]
- else:
- # newDic2[en2zh[col]] = "未显示"
- if row["ARR_DEP"] != "" and "FLG_VR" not in row.keys():
- if row["ARR_DEP"][-1] == "-":
- a = "航后"
- elif row["ARR_DEP"][0] == "-":
- a = "航前"
- else:
- a = "短停"
- elif row["ARR_DEP"] != "" and "FLG_VR" in row.keys():
- a = "短停"
- elif row["ARR_DEP"] == "":
- a = "未显示"
- if col == 'TASKTYPE' and a != b:
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]机号:%s航班类型由%s变更为%s,请注意核对FOC!!!" % (flightdate,row["ACNO"],b, a),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now, "处理人": "",
- "处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic={"航班类型":"'%s'"%a}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic,"航班编号='%s'"%row["FLIGHT_ID"])
- elif col == 'TASKSTS' and row[col] != b:
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "","航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "[%s]机号:%s维修状态由%s变更为%s!%s" % (flightdate,row["ACNO"],taskSTS[b], taskSTS[row["TASKSTS"]],now11), "产生时间": "%s" % now, "处理人": "",
- "处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- if row[col] in flightst_code.keys():
- newdic={"%s"%flightst_code[row[col]]:"1"}
- database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%row["FLIGHT_ID"])
- newdic = {"维修状态": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- elif col == 'TASKSTS_ECSJ' and row[col] != b:
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "","航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "[%s]机号:%s二送状态由%s变更为%s!%s" % (flightdate,row["ACNO"],ecsjtaskSTS[b], ecsjtaskSTS[row["TASKSTS_ECSJ"]],now11), "产生时间": "%s" % now, "处理人": "",
- "处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic = {"二送状态": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- elif 'FLG_VR' in row.keys() and col == 'FLG_VR' and row['FLG_VR'] != "":
- if row['FLG_VR'][0] == "R":
- mesg = "有返航航班,[%s]机号为%s航班号%s,返航航班预达时间不准,请核对FOC,可人工创建航班监控节点!" % (flightdate, row["ACNO"], row["FLIGHT_NO"])
- if len(database.queryTabel('logs',"*","警告信息= '%s' and 航班编号 ='%s'"%(mesg, row["FLIGHT_ID"])))==0:
- newDic3 = {"警告信息":mesg, "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "","产生时间": "%s" % now, "处理人": "","处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- if row[col] != b:
- newdic = {"备降返航": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic,"航班编号='%s'" % row["FLIGHT_ID"])
- elif row['FLG_VR'][0] == "V":
- mesg = "有备降航班,[%s]机号为%s航班号%s,备降航班预达时间不准,请核对FOC,可人工创建航班监控节点!" % (flightdate, row["ACNO"], row["FLIGHT_NO"])
- if len(database.queryTabel('logs', "*", "警告信息= '%s' and 航班编号 ='%s'" % (mesg, row["FLIGHT_ID"]))) == 0:
- newDic3 = {"警告信息": mesg, "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "","变更字段": "%s" % zydy[col], "显示对象": "", "提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- if row[col] != b:
- newdic = {"备降返航": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic,"航班编号='%s'" % row["FLIGHT_ID"])
- elif "ETA" in row.keys() and col == 'ETA' and row[col] != b and a != "航前":
- if b=="" and LOGsdeactive == 0 and "ATD" in row.keys() and row["ATD"] != "" :
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- elif b!="" and LOGsdeactive == 0 and "ATD" in row.keys() and row["ATD"] != "" :
- #eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
- ETA_P10 = datetime.datetime.strptime(b, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=10)
- ETA_N10 = datetime.datetime.strptime(b, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=10)
- ETAnew=datetime.datetime.strptime(str(row[col]), "%Y-%m-%d %H:%M:%S")
- if ETAnew < ETA_N10 or ETAnew > ETA_P10 and ETAnew > now:
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic = {"非航前预计到达": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- 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"])):
- FJtask = ""
- BLstr = ""
- if row["FLIGHT_ID"] in str(database.getSingledata("航班编号",'TaskFlightinfo{}'.format(nowDayStr))):
- if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"工作包","航班编号='%s'"%row["FLIGHT_ID"])[0][0]!="":
- FJtask=",有工作包"
- if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"保留","航班编号='%s'"%row["FLIGHT_ID"])[0][0]!="":
- BLstr=",有保留"
- bay_str=row["BAY_2"] if "BAY_2" in row.keys() else ""
- 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"], "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "新航班播报","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic = {"航前实际起飞": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- now_1= (datetime.datetime.now()- datetime.timedelta(minutes=0.5)).strftime("%Y-%m-%d %H:%M:%S")
- waringsts = database.queryTabel('logs', "编号","航班编号 ='%s' and 变更字段='非航前预计到达' and 产生时间>'%s'" %(row["FLIGHT_ID"],now_1))
- if len(waringsts) != 0:
- newdic = {"处理人": "'系统抑制'", "处理时间": "'%s'" % now}
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringsts[0][0])
- elif "TD" in row.keys() and col == 'TD' and row[col] != b:
- if row[col] !="":
- FlightDate=str(row["FLIGHT_DATE"])
- TD_time_str = FlightDate.split("-")[0] + "/" + row[col].split("]")[1]
- TD_time = datetime.datetime.strptime(TD_time_str,"%Y/%m/%d %H:%M")
- else:
- TD_time=now+ datetime.timedelta(minutes=5)
- 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:
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- 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:
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic = {"非航前预计起飞": "'%s'" % row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- elif col !="TASKTYPE" and col !="TASKSTS" and col !="FLIGHT_ID" and col !="FLG_VR" and col in row.keys() and row[col] != b:
- if database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] == "航前" and col in APbglist:
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col],b, row[col]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now,
- "处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- elif database.queryTabel('flightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%row["FLIGHT_ID"])[0][0] == "航后" and col in AFbglist:
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col],b, row[col]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now,
- "处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- 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:
- if LOGsdeactive == 0:
- if col == "TD" and "[实]" not in str(row[col]):
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col],b, row[col]), "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "","提示信息": "", "产生时间": "%s" % now,
- "处理人": "","处理时间": "", "变更字段": "%s"%zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- elif col != "TD":
- newDic3 = {"警告信息": "[%s]机号:%s%s由%s变更为%s!" % (flightdate,row["ACNO"], zydy_simple[col], b, row[col]),"航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "%s" % zydy[col],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- else: #限制提示信息输出位置
- if LOGsdeactive == 0:
- if col not in ["WXRY","FXRY","ECSJRY","TASKSTS_TIME"]:
- 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],"显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic = {"%s"% zydy[col]: "'%s'" %row[col]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- else:
- if LOGsdeactive == 0:
- newDic3 = {"警告信息": "[%s]%s航班机号由%s变更为%s,请注意核对FOC!!!" % (flightdate,row["FLIGHT_NO"], acno, row["ACNO"]),
- "航班编号": "%s" % row["FLIGHT_ID"], "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "","处理时间": "", "变更字段": "机号","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- newdic = {"机号": "'%s'" % row["ACNO"]}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" % row["FLIGHT_ID"])
- database.FunctionCommit()
- else:
- print(datetime.datetime.now(),"[数据库操作]flightinfo航班数据为空")
- pass
- 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:
- flightinfo_flight_ids = database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"附加消息='AMRO'")
- if len(flightinfo_flight_ids) != 0:
- for iii in flightinfo_flight_ids:
- if str(iii[0]) not in flight_id_now:
- cancelid=database.queryTabel( 'flightinfo{}'.format(nowDayStr),'取消标志',"航班编号='%s'"%iii[0])[0][0]
- newcancelid=int(cancelid)+1
- if int(newcancelid) <4:
- newdic={"取消标志":"'%s'"%newcancelid}
- database.lazyUpdateItem('flightinfo{}'.format(nowDayStr), newdic, "航班编号='%s'" %iii[0])
- else:
- c=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % str(iii[0]) )[0][0][5:10]
- a= database.queryTabel("flightinfo{}".format(nowDayStr), "机号","航班编号='%s'" % str(iii[0]) )[0][0]
- b=database.queryTabel("flightinfo{}".format(nowDayStr), "保障航班号","航班编号='%s'" % str(iii[0]) )[0][0]
- newDic3 = {"警告信息": "[%s]%s,%s航班已取消,注意核对FOC!!!"% (c,a,b),"航班编号": "%s" % str(iii[0]) , "信息状态": "", "提示信息": "", "产生时间": "%s" % now,"处理人": "", "处理时间": "", "变更字段": "全部取消","显示对象":"","提示内容":""}
- database.lazyInsertData('logs', newDic3)
- database.deleteSingledata("flightinfo{}".format(nowDayStr), "航班编号='%s'" % str(iii[0]) )
- #print("全部取消警告",int(time.time()),c,a,b)
- database.FunctionCommit()
- except Exception:
- database.FunctionCommit()
- dingding_alert(traceback.format_exc())
- def insertTaskDataToTable(database: flightDB, datatime: str, jsonData1,jsonData2):
- try:
- #print(datetime.datetime.now(),"开始写入Task任务数据库")
- flightsts_code = {"4": "接机已到位提示", "7": "已放行提示", "11": "二送已到位提示"}
- nowDayStr = datatime
- now = datetime.datetime.now()
- selectdaystr = str(datatime)[0:4] + "-" + str(datatime)[4:6] + "-" + str(datatime)[6:] + " 00:00:00"
- nowDayStr_search = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
- '''
- Taskflightinfo_flight_ids_arr = []
- Taskflightinfo_flight_ids = database.getSingledata('航班编号', 'TaskFlightinfo{}'.format(nowDayStr))
- if len(Taskflightinfo_flight_ids) != 0:
- for i in Taskflightinfo_flight_ids:
- Taskflightinfo_flight_ids_arr.append(i[0])
- '''
- for jsonData in [jsonData1,jsonData2]:
- #print(len(jsonData))
- if jsonData !="" and len(jsonData) !=0:
- for row in jsonData:
- flightdate = str(row["FLIGHTDATE"]).split(" ")[0][5:10]
- if row["FLIGHTDATE"] == str(nowDayStr_search):
- newDic2 = {}
- if row["TASKTYPE"]=="AP":
- a=row["FLIGHTID2"]
- elif row["TASKTYPE"]=="AF":
- a = row["FLIGHTID1"]
- elif row["TASKTYPE"] == "TR":
- a = row["FLIGHTID1"]
- elif row["TASKTYPE"] == "TAF":
- a = row["FLIGHTID1"]
- else:
- if"FNO" in row.keys() and row["FNO"] != "":
- if row["FNO"][-1] == "-" and row["FNO"][0] != "-" :
- a = row["FLIGHTID2"]
- else:
- a = row["FLIGHTID1"]
- else:
- if "FLIGHTID2" in row.keys() and "FLIGHTID1" not in row.keys():
- a = row["FLIGHTID2"]
- else:
- a = row["FLIGHTID1"]
- if str(a) !="" and str(a) not in str(database.getSingledata('航班编号', 'TaskFlightinfo{}'.format(nowDayStr))):#and str(a) not in str(Taskflightinfo_flight_ids_arr)
- for col in row:
- if col in TaskflightinfoLabel2en.keys():
- if col == 'TASKTYPE':
- if row[col] != "":
- newDic2[TaskflightinfoLabel2en[col]] = row[col]
- else:
- # newDic2[en2zh[col]] = "未显示"
- if row["FNO"] != "" and row["FNO"][0] == "-":
- newDic2[TaskflightinfoLabel2en[col]] = "AF"
- elif row["FNO"] != "" and row["FNO"][-1] == "-":
- newDic2[TaskflightinfoLabel2en[col]] = "AP"
- elif row["FNO"] != "":
- newDic2[TaskflightinfoLabel2en[col]] = "TR"
- elif row["ARR_DEP"] == "":
- newDic2[TaskflightinfoLabel2en[col]] = ""
- elif col == 'FJ_TASKIDS':
- if "'" in str(row[col]):
- b=""
- for i in range(0,len(row[col])-1):
- b=b+str(row[col][i])+","
- newDic2[TaskflightinfoLabel2en[col]] = b
- else:
- newDic2[TaskflightinfoLabel2en[col]] = ""
- else:
- newDic2[TaskflightinfoLabel2en[col]] = row[col]
- for key in TaskflightinfoLabel:
- if key not in newDic2.keys():
- # print(key)
- newDic2[key] = ''
- newDic2['航班编号'] = str(a)
- database.lazyInsertData('TaskFlightinfo{}'.format(nowDayStr), newDic2)
- else:
- sjry = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "随机", "航班编号='%s'" % str(a))[0][0]
- #print(sjry)
- for col in row:
- if col in TaskflightinfoLabel2en.keys():
- if col == 'TASKTYPE':
- if row[col] != "":
- aa = "'%s'" %row[col]
- else:
- # newDic2[en2zh[col]] = "未显示"
- if row["FNO"] != "" and row["FNO"][0] == "-":
- aa = "AF"
- elif row["FNO"] != "" and row["FNO"][-1] == "-":
- aa = "AP"
- elif row["FNO"] != "":
- aa = "TR"
- elif row["ARR_DEP"] == "":
- aa = ""
- if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"航班类型","航班编号='%s'"%str(a))[0][0] != aa:
- newDic2={"航班类型":"%s"%aa}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- elif col == 'FJ_TASKIDS':
- #print(str(row[col]))
- if "'" in str(row[col]):
- c=""
- for i in range(0,len(row[col])):
- c=c+str(row[col][i])+","
- else:
- c = ""
- #print("#################")
- #print(c)
- #print(database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "工作包", "航班编号='%s'" % str(a))[0][0])
- #print(database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"工作包","航班编号='%s'"%str(a))[0][0].count(","))
- #print("#################")
- workjob=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"工作包","航班编号='%s'"%str(a))[0][0]
- if workjob.count(",") >1:
- for i in range(0,workjob.count(",")):
- #print("***********************")
- #print(c)
- #print(workjob)
- #print(workjob.count(","))
- #print(i)
- #print(str(workjob.split(",")[i]))
- #print("**********************")
- if str(workjob.split(",")[i]) not in str(c):
- newDic2 = {"工作包": "'%s'" % c}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
- elif workjob.count(",") <= 1 and str(workjob) != str(c):
- newDic2 = {"工作包": "'%s'" % c}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- elif col == 'TASKTYPE':
- if (row[col]=="TR" or row[col]=="TAF")and row["BAY_A"] != row["BAY_B"] :
- mesg="[%s]%s %s航班进港机位为%s,出港机位为%s,短停进出港机位不一致,请注意核对AMRO机位信息,按需修改,注意核对工作人员派送机位信息!!!" % (flightdate,row["ACNO"], row["FNO"],row["BAY_A"], row["BAY_B"])
- newDic3 = {"警告信息": "[%s]%s进港机位为%s,出港机位为%s,请注意核对AMRO机位信息,按需修改,注意核对工作人员派送机位信息!!!" % (flightdate,row["ACNO"],row["BAY_A"], row["BAY_B"]),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now,"处理人": "", "处理时间": "", "变更字段": "机位不一致警告", "显示对象": "", "提示内容": ""}
- if mesg not in str(database.queryTabel('logs', "警告信息", "航班编号='%s'" % str(a))):
- database.lazyInsertData('logs', newDic3)
- if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "%s"%TaskflightinfoLabel2en[col], "航班编号='%s'" % str(a))[0][0] != row[col]:
- newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- elif col == 'BAY_A':
- aaaa=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "%s"%TaskflightinfoLabel2en[col], "航班编号='%s'" % str(a))[0][0]
- if aaaa != row[col]:
- if row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "AF" or row["TASKTYPE"] == "TAF":
- newDic3 = {"警告信息": "[%s]任务派工模块:%s机位由%s变更为%s" % (
- flightdate, row["ACNO"], aaaa, row[col]),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "进港机位变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- if (row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and "BAY_B" not in row.keys():
- newDic2 = {"航前离港机位": "'%s'" % row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
- elif col == 'BAY_B':
- aaaa = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"%s" % TaskflightinfoLabel2en[col],"航班编号='%s'" % str(a))[0][0]
- if aaaa != row[col]:
- 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"])):
- newDic3 = {"警告信息": "[%s]任务派工模块:%s机位由%s变更为%s" % (flightdate, row["ACNO"], aaaa, row[col]),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "出港机位变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- newDic2 = {"%s"%TaskflightinfoLabel2en[col]: "'%s'" % row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
- if (row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and ( row["BAY_A"] != row["BAY_B"]):
- newDic2 = {"非航前进港机位": "'%s'" % row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
- if (row["TASKTYPE"] == "TR" or row["TASKTYPE"] == "TAF") and ("BAY_A" not in row.keys()):
- newDic2 = {"非航前进港机位": "'%s'" % row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
- elif col=="SJ_DEP" and "SJ_ARR" not in row.keys():
- if row["SJ_DEP"] !="":
- SJ="随机"+row["SJ_DEP"].replace("已安排","").replace("已登机","")+";"
- else:
- SJ=""
- new_a = str(a) + "-2" + "-A"
- fj = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息", "编号='%s'" % str(new_a))
- if sjry != SJ:
- newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %SJ}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- if len(fj)!=0 and ((sjry!="" and sjry not in str(fj) and SJ not in str(fj) and SJ !="") or sjry == ""):
- new_fj=SJ + fj[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- elif len(fj)!=0 and sjry in str(fj) and SJ != sjry:
- new_fj=fj[0][0].replace("%s"%sjry,"%s"%SJ)
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- if len(fj)==0:
- newDic2 = {"编号":new_a,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" % SJ}
- database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
- elif SJ not in str(fj):
- new_fj=SJ+ fj[0][0]
- newDic2 = {"附加消息": "'%s'" %new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- elif col=="SJ_ARR" and "SJ_DEP" not in row.keys():
- if row["SJ_ARR"] !="":
- SJ="随机"+row["SJ_ARR"].replace("已安排","").replace("已登机","")+";"
- else:
- SJ=""
- new_a = str(a) + "-1" + "-A"
- fj = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息","编号='%s'" % str(new_a))
- if sjry != SJ:
- newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %SJ}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- if len(fj)!=0 and ((sjry!="" and sjry not in str(fj) and SJ not in str(fj) and SJ !="") or sjry == ""):
- new_fj=SJ + fj[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- elif len(fj)!=0 and sjry in str(fj) and SJ != sjry:
- new_fj=fj[0][0].replace("%s"%sjry,"%s"%SJ)
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry,SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- if len(fj)==0:
- newDic2 = {"编号":new_a,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" % SJ}
- database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
- elif SJ not in str(fj):
- new_fj=SJ+ fj[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- elif (col=="SJ_DEP" and "SJ_ARR" in row.keys()) or (col=="SJ_ARR" and "SJ_DEP" in row.keys()) :
- if row["SJ_DEP"] !="" and row["SJ_ARR"] =="":
- SJ_DEP="随机"+row["SJ_DEP"].replace("已安排","").replace("已登机","")+";"
- SJ_ARR=""
- SJ = str(SJ_DEP)
- elif row["SJ_DEP"] =="" and row["SJ_ARR"] !="":
- SJ_ARR = "随机" + row["SJ_ARR"].replace("已安排","").replace("已登机","") + ";"
- SJ_DEP = ""
- SJ = str(SJ_ARR)
- else:
- SJ_ARR = "随机" + row["SJ_ARR"].replace("已安排","").replace("已登机","") + ";"
- SJ_DEP = "随机" + row["SJ_DEP"].replace("已安排","").replace("已登机","") + ";"
- SJ=str(SJ_ARR)+"-"+str(SJ_DEP)
- new_a = str(a) + "-1" + "-A"
- new_b = str(a) + "-2" + "-A"
- fj = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息","编号='%s'" % str(new_a))
- fj2 = database.queryTabel('peopleSchedule{}'.format(nowDayStr), "附加消息","编号='%s'" % str(new_b))
- if "-" in sjry:
- sjry_ARR=sjry.split("-")[0]
- sjry_DEP = sjry.split("-")[1]
- elif "离港" in sjry and "进港" not in sjry:
- sjry_ARR = ""
- sjry_DEP = sjry
- elif "进港" in sjry and "离港" not in sjry:
- sjry_ARR = sjry
- sjry_DEP = ""
- if sjry != SJ:
- newDic2={"随机":"'%s'" %SJ}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- newDic3 = {"警告信息": "[%s]任务派工模块:%s随机由%s变更为%s" % (flightdate, row["ACNO"], sjry, SJ),"航班编号": "%s" % str(a), "信息状态": "", "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "","提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- #if len(fj) != 0 and ((sjry != "" and sjry not in str(fj) and SJ not in str(fj) and SJ != "") or sjry == ""):
- 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)):
- new_fj=SJ_ARR+fj[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- elif len(fj)!=0 and sjry_ARR !="" and str(sjry_ARR) in str(fj) and sjry_ARR != SJ_ARR:
- new_fj=fj[0][0].replace("%s"%(sjry_ARR),"%s"%(SJ_ARR))
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- 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)):
- new_fj2 = SJ_DEP+fj2[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj2}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_b))
- elif len(fj2)!=0 and sjry_DEP !="" and sjry_DEP in str(fj2) and sjry_DEP !=SJ_DEP:
- new_fj2=fj2[0][0].replace("%s"%(sjry_DEP),"%s"%(SJ_DEP))
- newDic2 = {"附加消息": "'%s'" % new_fj2}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_b))
- if len(fj)==0:
- newDic2 = {"编号":new_a,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" %SJ_ARR}
- database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
- elif len(fj2)==0:
- newDic2 = {"编号":new_b,"航班编号":str(a),"显示模式":"A","放行":"","勤务1":"","勤务2":"","工1":"","工2":"","工3":"","附加消息":"%s" %SJ_DEP}
- database.lazyInsertData('peopleSchedule{}'.format(nowDayStr), newDic2)
- elif str(SJ_ARR) not in str(fj) or str(str(SJ_DEP)) not in str(fj2):
- new_fj=SJ_ARR+fj[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_a))
- new_fj2 = SJ_DEP + fj2[0][0]
- newDic2 = {"附加消息": "'%s'" % new_fj2}
- database.lazyUpdateItem('peopleSchedule{}'.format(nowDayStr), newDic2,"编号='%s'" % str(new_b))
- else:
- if database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "%s"%TaskflightinfoLabel2en[col], "航班编号='%s'" % str(a))[0][0] != row[col]:
- newDic2={"%s"%TaskflightinfoLabel2en[col]:"'%s'" %row[col]}
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2, "航班编号='%s'" % str(a))
- if "已安排" in row[col]:
- print("有刺客")
- if "SJ_DEP" not in row.keys() and "SJ_ARR" not in row.keys() and sjry !="" :
- newDic2 = {"随机" : "''" }
- database.lazyUpdateItem('TaskFlightinfo{}'.format(nowDayStr), newDic2,"航班编号='%s'" % str(a))
- newDic3 = {
- "警告信息": "[%s]任务派工模块:%s %s取消,请核对FOC" % (flightdate, row["ACNO"], sjry),
- "航班编号": "%s" % str(a), "信息状态": "", "提示信息": "", "产生时间": "%s" % now,
- "处理人": "", "处理时间": "", "变更字段": "随机人员变更", "显示对象": "", "提示内容": ""}
- database.lazyInsertData('logs', newDic3)
- database.FunctionCommit()
- starttime=(nowDayStr_search - datetime.timedelta(days=7)).strftime("%Y-%m-%d %H:%M:%S")
- endtime = (nowDayStr_search + datetime.timedelta(days=7)).strftime("%Y-%m-%d %H:%M:%S")
- tasknuminworjoblist=database.getSingledata("任务编号",'workjob')
- tasknums=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),'*', "工作包 !=''")
- if len(tasknums) != 0:
- for i in tasknums:
- if i[21] not in str(tasknuminworjoblist) and len(database.queryTabel('flightinfo{}'.format(nowDayStr), '机型', "航班编号 ='%s'"%i[0])) != 0:
- flighttype = database.queryTabel('flightinfo{}'.format(nowDayStr), '机型', "航班编号 ='%s'"%i[0])[0][0]
- workjoblist=i[18][:-1]
- #print(workjoblist)
- newdic3={"任务编号":"%s"%i[21],"工作包编号":"%s"%workjoblist,"查询开始时间":"%s"%starttime,"查询结束时间":"%s"%endtime,"开始时间":"","基地":"","项目描述":"","工作步骤":"","机号":"%s"%i[1],"机型":"%s"%flighttype,"航班类型":"%s"%zydy_simple[i[3]]}
- database.lazyInsertData('workjob', newdic3)
- #返回一个数值去查询
- if i[21] in str(tasknuminworjoblist):
- if i[18][:-1] != database.queryTabel('workjob','工作包编号', "任务编号 ='%s'"%i[21])[0][0]:
- newdic = {"工作包编号": "'%s'" % i[18][:-1],"开始时间":"''","基地":"''","项目描述":"''","工作步骤":"''"}
- database.lazyUpdateItem('workjob', newdic, "任务编号='%s'" % i[21])
- database.FunctionCommit()
- except Exception:
- database.FunctionCommit()
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def insertWorkjob(database:flightDB,workjobdata,taskid):
- try:
- A=["MDTITLE_C","WORKSTEP","BASE_CODE","PLANSTD"]
- num=1
- MDTITLE_C=""
- WORKSTEP=""
- PLANSTD=""
- BASE_CODE_now=""
- if len(workjobdata) != 0:
- for row in workjobdata:
- MDTITLE_C_now=row["MDTITLE_C"] if "MDTITLE_C" in row.keys() else ""
- WORKSTEP_now = row["WORKSTEP"] if "WORKSTEP" in row.keys() else ""
- BASE_CODE_now = row["BASE_CODE"] if "BASE_CODE" in row.keys() else ""
- PLANSTD_now = row["PLANSTD"] if "PLANSTD" in row.keys() else ""
- if MDTITLE_C !="":
- MDTITLE_C=MDTITLE_C+"\n------------------------------------------------\n"+"工作包%s内容:"%num+"\n"+MDTITLE_C_now
- WORKSTEP=WORKSTEP+"\n------------------------------------------------\n"+"工作包%s步骤:"%num+"\n"+WORKSTEP_now
- PLANSTD=PLANSTD+"\n------------------------------------------------\n"+"工作包%s计划开始时间:"%num+"\n"+PLANSTD_now
- else:
- MDTITLE_C ="工作包%s内容:" % num + "\n" + MDTITLE_C_now
- WORKSTEP ="工作包%s步骤:" % num + "\n" + WORKSTEP_now
- PLANSTD ="工作包%s计划开始时间:" % num + "\n" + PLANSTD_now
- num+=1
- newdic={"基地":"'%s'"%BASE_CODE_now,"开始时间":"'%s'"%PLANSTD,"项目描述":"'%s'"%MDTITLE_C.replace("\"","*").replace("#","*").replace("\\",";").replace("\'","*").replace("/","、"),"工作步骤":"'%s'"%WORKSTEP.replace("\'","*").replace("\\",";").replace("/","、").replace("\"","*").replace("#","*")}
- database.lazyUpdateItem('workjob', newdic, "任务编号='%s'" %taskid)
- res={"返回值":"ok"}
- database.FunctionCommit()
- return res
- except Exception:
- dingding_alert(traceback.format_exc())
- res = {"返回值": "fail"}
- database.FunctionCommit()
- return res
- def getWorkjobInfo(database:flightDB,taskid):
- try:
- res={}
- infos=database.queryTabel('workjob','*',"任务编号 ='%s'"%taskid)
- if len(infos) != 0:
- res["taskids"]=infos[0][1]
- res["acno"] = infos[0][8]
- res["taskType"] = infos[0][10]
- res["actype"] = infos[0][9]
- res["startDate"] = infos[0][2]
- res["endDate"] = infos[0][3]
- return res
- except Exception:
- dingding_alert(traceback.format_exc())
- def update_Pglist(database:flightDB,datatime: str,bc:str,jsonData):
- try:
- nowDayStr = datatime
- newdic={}
- database.deleteSingledata("pglist{}".format(nowDayStr), "班次='%s'" % bc)
- names=[]
- for row in jsonData:
- if "SHIFT" in row.keys() and row["SHIFT"]==bc and row["NAME"] not in names:
- for col in row:
- if col in pglistLabel2en.keys():
- newdic[pglistLabel2en[col]]=row[col]
- database.lazyInsertData("pglist{}".format(nowDayStr),newdic)
- names = row["NAME"]
- database.FunctionCommit()
- except Exception:
- database.FunctionCommit()
- dingding_alert(traceback.format_exc())
- def judge_bc():
- try:
- nowDay = datetime.date.today().strftime("%Y%m%d")
- nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
- #nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
- nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
- a_str = nowDay_str2 + " 09:00:00"
- b_str = nowDay_str2 + " 20:30:00"
- a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
- b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
- nowtime = datetime.datetime.now()
- if a < nowtime < b:
- date=nowDay
- bc="A"
- elif b < nowtime:
- date = nowDay
- bc = "B"
- elif nowtime < a:
- date = nowDay_1
- bc = "B"
- dic={"date":"%s"%date,"bc":"%s"%bc}
- return dic
- except Exception:
- dingding_alert(traceback.format_exc())
- def get_empNos_phoone(database:flightDB,name):
- try:
- infos={}
- info=database.queryTabel('workerinfo',"*","姓名='%s'"%name)
- if len(info) != 0:
- infos={"工号":'%s'%info[0][0],"电话":"%s"%info[0][5]}
- return infos
- except Exception:
- dingding_alert(traceback.format_exc())
- def callon(fdb:flightDB,phonenum):
- try:
- now = datetime.datetime.now()
- now1=datetime.datetime.now()- datetime.timedelta(seconds=5)
- if phonenum !="" and phonenum !=None:
- calllist = fdb.sort_queryTable2("航班编号", "Calllist", "电话 ='%s' and 接通时间 =''"%phonenum, "拨号次数", "ASC", "创建时间", "ASC")
- if len(calllist) != 0:
- lasttime = fdb.sort_queryTable("接通时间", "Calllist", "接通时间 !='' and 接通时间 not like '%人工%'", "接通时间", "desc")
- #print("lasttime", lasttime[0][0])
- if len(lasttime) == 0 or(len(lasttime) != 0 and now1 > datetime.datetime.strptime(lasttime[0][0][:19],"%Y-%m-%d %H:%M:%S")):
- newdic = {"接通时间": "'%s'" % now}
- fdb.upDateItem("Calllist", newdic, "航班编号='%s'" % calllist[0][0])
- except Exception:
- dingding_alert(traceback.format_exc())
- def calltry(fdb:flightDB,ip,token):
- try:
- #print("calltry")
- #print(ip,token)
- calllist=fdb.sort_queryTable2("*","Calllist","接通时间 ='' and 拨号次数<4","拨号次数","ASC","创建时间","ASC")
- if len(calllist) != 0:
- phone_num=calllist[0][1]
- calltime=int((fdb.queryTabel("Calllist","拨号次数","航班编号='%s'"%calllist[0][0]))[0][0])+1
- newdic={"拨号次数":"%s"%calltime}
- fdb.upDateItem("Calllist",newdic,"航班编号='%s'"%calllist[0][0])
- try:
- data = {"PHB_AutoDialNumber": phone_num,
- "ReturnPage": "/contacts.htm",
- "AutoDialSubmit": "submit",
- "PHB_AutoDialLine": "1"
- }
- header = {
- "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",
- "Connection": "keep-alive",
- "Cookie": token
- }
- requests.post(url="http://%s/contacts.htm" % ip, data=data, headers=header)
- except Exception:
- dingding_alert(traceback.format_exc())
- print(datetime.datetime.now(),"[数据中心]拨号失败")
- except Exception:
- print(traceback.format_exc())
- dingding_alert(traceback.format_exc())
- def calledChecked(fdb: flightDB):
- try:
- now=datetime.datetime.now()
- now_5 = now - datetime.timedelta(minutes=8)
- callist = fdb.queryTabel("Calllist", "*", "接通时间 ='' and (创建时间<'%s' or CAST(拨号次数 AS integer)>3)"%now_5)
- if len(callist) != 0:
- for i in callist:
- if len(fdb.queryTabel("logs", "航班编号", "航班编号 ='%s' and 处理时间=''"%i[0])) == 0:
- newdic = {"航班编号": "%s" %i[0], "警告信息": "%s %s超过自动联系超过8min或连续拨号超过3次无响应,请人工处理!!"%(i[4],i[3]), "信息状态": "", "提示信息": "",
- "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "无法联系", "显示对象": "", "提示内容": ""}
- fdb.lazyInsertData('logs', newdic)
- newdic1={"接通时间":"'%s推送人工处理'"%now}
- fdb.lazyUpdateItem("Calllist",newdic1,"航班编号='%s'"%i[0])
- fdb.FunctionCommit()
- except Exception:
- fdb.FunctionCommit()
- dingding_alert(traceback.format_exc())
- def get_empNos(database:flightDB,dict:dict):
- try:
- date=judge_bc()["date"]
- date_str=judge_bc()["date"][0:4]+"-"+judge_bc()["date"][4:6]+"-"+judge_bc()["date"][6:]
- bc = judge_bc()["bc"]
- faillist=[]
- WXempNos = ""
- ESempNos = ""
- FXempNos = ""
- WX = ""
- ES = ""
- FX = ""
- wxkey = ["工1", "工2", "工3/送1", "工4/送2"]
- eskey = [ "工3/送1", "工4/送2"]
- for i in wxkey:
- if dict[i] != "":
- aa = []
- if bc == "A":
- aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
- elif bc == "B":
- aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
- if len(aa) != 0 and WXempNos == "":
- if aa[0][0] !="":
- WXempNos = str(aa[0][0])
- else:
- faillist.append(dict[i])
- elif len(aa) != 0 and WXempNos != "":
- if aa[0][0] != "":
- WXempNos =WXempNos+","+str(aa[0][0])
- else:
- faillist.append(dict[i])
- elif len(aa) == 0:
- faillist.append(dict[i])
- if dict[i] != "" and WX == "":
- WX=dict[i]
- elif dict[i] != "" and WX != "":
- WX=WX+","+dict[i]
- for i in eskey:
- if dict[i] != "":
- aa = []
- if bc == "A":
- aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
- elif bc == "B":
- aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
- if len(aa) != 0 and ESempNos == "":
- if aa[0][0] !="":
- ESempNos = str(aa[0][0])
- else:
- faillist.append(dict[i])
- elif len(aa) != 0 and ESempNos != "":
- if aa[0][0] != "":
- ESempNos =ESempNos+","+str(aa[0][0])
- else:
- faillist.append(dict[i])
- elif len(aa) == 0:
- faillist.append(dict[i])
- if dict[i] != "" and ES == "":
- ES=dict[i]
- elif dict[i] != "" and ES != "":
- ES=ES+","+dict[i]
- if dict["放行"] != "":
- aa = []
- if bc == "A":
- aa=database.queryTabel("pglist{}".format(date),"工号","班次='A' and 姓名='%s'"%dict["放行"])
- elif bc == "B":
- aa=database.queryTabel("pglist{}".format(date),"工号","班次='B' and 姓名='%s'"%dict["放行"])
- if len(aa) != 0 and FXempNos == "":
- if aa[0][0] != "":
- FXempNos = str(aa[0][0])
- else:
- faillist.append(dict["放行"])
- elif len(aa) != 0 and FXempNos != "":
- if aa[0][0] != "":
- FXempNos = FXempNos + "," + str(aa[0][0])
- else:
- faillist.append(dict["放行"])
- elif len(aa) == 0:
- faillist.append(dict["放行"])
- FX=dict["放行"]
- if WXempNos =="" and FXempNos=="" and ESempNos=="":
- dict1={"code":"fail","WXempNos":"","FXempNos":"","ESempNos":"","faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
- elif faillist=="":
- dict1 = {"code": "ok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
- elif faillist !="":
- dict1 = {"code": "justok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
- return dict1
- except Exception:
- dingding_alert(traceback.format_exc())
- def dealLogs(database:flightDB,name:str,number:str):
- try:
- now=datetime.datetime.now()
- nowDay = datetime.datetime.now()
- nowDayStr = nowDay.strftime("%Y%m%d")
- id=number
- newdic={"处理人":"'%s'"%name,"处理时间":"'%s'"%now}
- database.upDateItem('logs',newdic,"编号='%s'"%id)
- except Exception:
- dingding_alert(traceback.format_exc())
- def mandealAllLogs(database:flightDB,name:str,mode):
- try:
- if mode =="norm":
- now=datetime.datetime.now()
- clear=database.queryTabel('logs',"编号","警告信息 !='' and 处理时间 ='' and 变更字段 !='人工待办' and 变更字段 !='准备组任务' ")
- newdic = {"处理人": "'%s'" % name, "处理时间": "'%s'" % now,"信息状态":"'人工一键处理'"}
- if len(clear) != 0:
- for i in clear:
- database.lazyUpdateItem('logs',newdic,"编号='%s'"%i[0])
- elif mode == "super":
- now = datetime.datetime.now()
- clear = database.queryTabel('logs', "编号", "警告信息 !='' and 处理时间 ='' and 变更字段 !='人工待办'")
- newdic = {"处理人": "'%s'" % name, "处理时间": "'%s'" % now, "信息状态": "'人工一键处理'"}
- if len(clear) != 0:
- for i in clear:
- database.lazyUpdateItem('logs', newdic, "编号='%s'" % i[0])
- database.FunctionCommit()
- except Exception:
- dingding_alert(traceback.format_exc())
- database.FunctionCommit()
- def getFlightData(database:flightDB,*args):
- try:
- nowDay = datetime.datetime.now()
- nowDayStr = nowDay.strftime("%Y%m%d")
- if args!=():
- flightData = database.getAlldata('flightinfo{}'.format(args[0]))
- else:
- flightData = database.getAlldata('flightinfo{}'.format(nowDayStr))
- return flightData
- except Exception:
- dingding_alert(traceback.format_exc())
- def getSortFlightdata(fdb:flightDB, datatime:str,tablename:str):
- try:
- nowDayStr = datatime
- sortData = fdb.sortTable('{}{}'.format(tablename,nowDayStr), '级别,保障时间','asc')
- return sortData
- except Exception:
- dingding_alert(traceback.format_exc())
- if __name__ == '__main__':
- fdb = flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- )
- loginDB = flightDB(host=host,
- port=port,
- user=user,
- password=password,
- database=databaseflightDB4
- )
|