DBUtils4PG_oldtry.py 310 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161
  1. import concurrent.futures
  2. import datetime
  3. import psycopg2
  4. from pypinyin import pinyin, Style
  5. import traceback
  6. import openpyxl
  7. import msoffcrypto
  8. import io
  9. import requests
  10. import json
  11. import time
  12. import hmac
  13. import hashlib
  14. import base64
  15. import urllib.parse
  16. from openpyxl import Workbook
  17. from Functions import utils
  18. from unitls.settings import DBServer, loginDB, flightDB4
  19. ##
  20. from Functions.DButilsFunction import flightDB,judge_bc,initFlightDatabase
  21. from unitls.StaticDataclass import get_dic
  22. host, port, user, password,online_host, online_port, online_user,online_password = DBServer()
  23. databaseloginDB=loginDB()
  24. databaseflightDB4=flightDB4()
  25. zydy_simple={"FLIGHT_ID":"航班编号","flightIds":"航班编号对","ACNO": "机号", "ACTYPE": "机型", "ENG_TYPE": "发动机", "FLIGHT_NO": "保障航班号",
  26. "STA": "计划到达", "ETA": "预计到达","DEP_CH":"进港机场","DEP_CH1":"离港机场","ARR_DEP":"进出港航班号","FLIGHT_DATE":"航班日期",
  27. "TASKTYPE": "航班类型","FLIGHT_STATUS":"航班状态","STD": "预计起飞","ATA": "实际到达","ATD": "实际起飞","TD": "预计起飞",
  28. "BAY1": "预计机位", "BAY_2": "进港机位", "BAY2": "预计机位", "BAY": "离港机位","WXRY": "维修人员", "FXRY": "放行人员",
  29. "TASKSTS": "维修状态","ZY_FLIGHT": "重要航班", "SJ": "随机","BL": "保留", "FLG_VR": "备降返航", "TASKSTS_TIME":"维修状态时间",
  30. "AP": "航前", "TR": "短停", "AF": "航后","TAF": "特航前","":"未显示","短停":"短停","ECSJRY":"二送人员","TASKSTS_ECSJ":"二送状态","FJ":"附加消息","CANCELID":"取消标志"}
  31. zydy = {"FLIGHT_ID":"航班编号","flightIds":"航班编号对","ACNO": "机号", "ACTYPE": "机型", "ENG_TYPE": "发动机", "FLIGHT_NO": "保障航班号",
  32. "STA": "非航前计划到达", "ETA": "非航前预计到达","DEP_CH":"进港机场","DEP_CH1":"离港机场","ARR_DEP":"进出港航班号","FLIGHT_DATE":"航班日期",
  33. "TASKTYPE": "航班类型","FLIGHT_STATUS":"航班状态","STD": "航前预计起飞","ATA": "非航前实际到达","ATD": "航前实际起飞","TD": "非航前预计起飞",
  34. "BAY1": "非航前预计进港机位", "BAY_2": "非航前进港机位", "BAY2": "航前预计离港机位", "BAY": "航前离港机位","WXRY": "维修人员", "FXRY": "放行人员",
  35. "TASKSTS": "维修状态","ZY_FLIGHT": "重要航班", "SJ": "随机","BL": "保留", "FLG_VR": "备降返航", "TASKSTS_TIME":"维修状态时间",
  36. "AP": "航前", "TR": "短停", "AF": "航后","TAF": "特航前","":"未显示","短停":"短停","ECSJRY":"二送人员","TASKSTS_ECSJ":"二送状态","FJ":"附加消息","CANCELID":"取消标志"}
  37. sortLabel=["编号","航班编号","保障时间","航班类型","航班日期","级别"]
  38. logsLabel=["编号","航班编号","警告信息","信息状态","提示信息","产生时间","处理人","处理时间","变更字段","显示对象","提示内容"]
  39. changestsLabel=["航班编号","航班编号对","机号","发动机","机型","保障航班号","进港机场","离港机场","进出港航班号","航班日期","航班状态",
  40. "航班类型","非航前计划到达","航前预计起飞","非航前实际到达","航前实际起飞","非航前预计到达","非航前预计起飞","非航前预计进港机位",
  41. "非航前进港机位","航前预计离港机位","航前离港机位","维修人员","放行人员","维修状态","重要航班","随机","保留","备降返航","维修状态时间"]
  42. workloadLabel=["编号","机号","机位","航班编号","开始时间","结束时间","保障日期","航班类型","人员状态"]
  43. workerinfoLabel=["工号","姓名","部门","岗位","通行证","电话","年限","川航授权","南航授权","试车授权","星级","籍贯"] #待持续更新
  44. authorityLabel=["编号","用户名","密码","权限","使用人"]
  45. taskLabel=["编号","时间","提示内容","详细信息"]
  46. RiskLabel=["风险编号","状态","提示内容","触发条件1","触发条件2","触发条件3","触发条件4","触发条件5"]
  47. workjobkeyLabel=["任务编号","工作包编号","查询开始时间","查询结束时间","开始时间","基地","项目描述","工作步骤","机号","机型","航班类型"]
  48. flightstsLabel=["航班编号","机号","机位","接机到位","放行","销子夹板","随机到位","二送到位","接机已到位提示","已放行提示","销子夹板已提示","随机已到位提示","二送已到位提示","天府飞机"]
  49. flightinfoLabel=["航班编号","航班编号对","机号","发动机","机型","保障航班号","进港机场","离港机场","进出港航班号","航班日期","航班状态",
  50. "航班类型","非航前计划到达","航前预计起飞","非航前实际到达","非航前预计到达","航前实际起飞","非航前预计起飞","非航前预计进港机位",
  51. "非航前进港机位","航前预计离港机位","航前离港机位","维修人员","放行人员","维修状态","重要航班","随机","保留","备降返航","维修状态时间","二送人员","二送状态","附加消息","取消标志"]
  52. trackLabel=["单号","创建时间","类型","清单","紧急程度","创建人","派送地址","接收人","库管开始","库管派发","领料地址",
  53. "金熊猫接收","金熊猫到位","配送到位","签收人","备注信息","一","二","三","四","五","六","七","八"]
  54. enflightifnoLabel=["FLIGHT_ID","flightIds","ACNO","ENG_TYPE","ACTYPE","FLIGHT_NO","DEP_CH","DEP_CH1","ARR_DEP","FLIGHT_DATE","FLIGHT_STATUS",
  55. "TASKTYPE","STA","STD","ATA","ETA","ATD","TD","BAY1","BAY_2","BAY2","BAY","WXRY","FXRY","TASKSTS","ZY_FLIGHT",
  56. "SJ","BL","FLG_VR","TASKSTS_TIME","ECSJRY","TASKSTS_ECSJ","FJ","CANCELID"]
  57. TaskflightinfoLabel=["航班编号","机号","航班日期","航班类型","非航前计划到达","航前预计起飞","非航前实际到达","航前实际起飞","非航前预计到达","预飞预达",
  58. "非航前进港机位","航前离港机位","维修人员","放行人员","维修状态","随机","保留","维修状态时间","工作包","二次送机","进出港航班号","任务编号"]#重要航班和备降返航有待研究
  59. TaskflightinfoLabel2en={"ACNO":"机号","FLIGHTDATE":"航班日期","TASKTYPE":"航班类型","STA":"非航前计划到达","STD":"航前预计起飞","ATA":"非航前实际到达","ATD":"航前实际起飞","ETA":"非航前预计到达","TA_TD":"预飞预达",
  60. "BAY_A":"非航前进港机位","BAY_B":"航前离港机位","WX":"维修人员","FX":"放行人员","TASKSTS":"维修状态","SJ_DEP":"随机","SJ_ARR":"随机",
  61. "BL":"保留","TASKSTS_TIME":"维修状态时间","FJ_TASKIDS":"工作包","ECSJ":"二次送机","FNO":"进出港航班号","TASKID":"任务编号"}
  62. #'''"FLIGHTID1":"航班编号","FLIGHTID2":"航班编号",'''
  63. #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"]
  64. displayLabel=["ID","A","B"]
  65. peopleScheduleLabel=["编号","航班编号","显示模式","放行","勤务1","勤务2","工1","工2","工3","附加消息"]
  66. CalllistLabel=["航班编号","电话","工号","姓名","航班号","附加消息","拨号次数","创建时间","接通时间"]
  67. rowlistLabel={10:"放行",11:"勤务1",12:"勤务2",13:"工1",14:"工2",15:"工3",-1:"附加消息"}
  68. pglistLabel=["姓名","工号","角色","班次"]
  69. pglistLabel2en={"NAME":"姓名","EMP_NO":"工号","MAINLY_ROLE":"角色","SHIFT":"班次"}
  70. ecsjtaskSTS={"":"空值","0":"空值",'5':'二送任务待确认', '10':'二送任务已确认', '15':'二送到位',"20":"二送离场"}
  71. #headerLabel = utils.headerLabel
  72. #headerLabelKey=utils.headerLabelKey
  73. headerLabel = flightinfoLabel
  74. headerLabelKey=enflightifnoLabel
  75. taskType =get_dic("taskType")
  76. taskSTS = get_dic("taskSTS")
  77. flightSTS = get_dic("flightSTS")
  78. flightSTSDic = get_dic("taskSTS")
  79. def infoConfirm(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
  80. try:
  81. peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
  82. if displayMode =="A":
  83. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  84. flightid_new=flightid+"-1"+"-A"
  85. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  86. flightid_new = flightid + "-2" + "-A"
  87. elif displayMode =="B":
  88. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  89. flightid_new=flightid+"-1"+"-B"
  90. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  91. flightid_new = flightid + "-2" + "-B"
  92. peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
  93. newdic={}
  94. if len(peopleSchedule_sts) != 0:
  95. for i in range(3,9):
  96. if "√" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
  97. newitem=peopleSchedule_sts[0][i]+"√"
  98. newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
  99. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  100. except Exception:
  101. dingding_alert(traceback.format_exc())
  102. def infoConfirm3(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
  103. try:
  104. peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
  105. if displayMode =="A":
  106. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  107. flightid_new=flightid+"-1"+"-A"
  108. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  109. flightid_new = flightid + "-2" + "-A"
  110. elif displayMode =="B":
  111. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  112. flightid_new=flightid+"-1"+"-B"
  113. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  114. flightid_new = flightid + "-2" + "-B"
  115. peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
  116. newdic={}
  117. if len(peopleSchedule_sts) != 0:
  118. for i in range(3,9):
  119. if "*" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
  120. newitem=peopleSchedule_sts[0][i]+"*"
  121. newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
  122. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  123. except Exception:
  124. dingding_alert(traceback.format_exc())
  125. def infoConfirm2(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
  126. try:
  127. peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
  128. if displayMode =="A":
  129. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  130. flightid_new=flightid+"-1"+"-A"
  131. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  132. flightid_new = flightid + "-2" + "-A"
  133. elif displayMode =="B":
  134. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  135. flightid_new=flightid+"-1"+"-B"
  136. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  137. flightid_new = flightid + "-2" + "-B"
  138. peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
  139. newdic={}
  140. if len(peopleSchedule_sts) != 0:
  141. for i in range(3,9):
  142. if "!" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
  143. newitem="!"+peopleSchedule_sts[0][i]
  144. newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
  145. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  146. except Exception:
  147. dingding_alert(traceback.format_exc())
  148. def dingding_alert(msg):
  149. dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=9c78c711f14ba3345d6dc492dc5ca8118c421516d611b5de46854fb8e158565f"
  150. timestamp = str(round(time.time() * 1000))
  151. secret = 'SEC09f744f81b55c8a18f0d77a3ab60bf4e1ec3f16b85f025e6a4f75ddff00a8fd4'
  152. secret_enc = secret.encode('utf-8')
  153. string_to_sign = '{}\n{}'.format(timestamp, secret)
  154. string_to_sign_enc = string_to_sign.encode('utf-8')
  155. hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
  156. sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
  157. dingding_url = dingding_webhook + '&timestamp=' + timestamp + "&sign=" + sign
  158. header = {
  159. "Content-Type": "application/json"
  160. }
  161. data = {
  162. "at": {
  163. "atMobiles":(123,456),
  164. # "isAtAll": True
  165. },
  166. "text": {
  167. "content": msg
  168. },
  169. "msgtype": "text"
  170. }
  171. res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
  172. def dingding_alert1(phone:list,msg):
  173. dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=9c78c711f14ba3345d6dc492dc5ca8118c421516d611b5de46854fb8e158565f"
  174. timestamp = str(round(time.time() * 1000))
  175. secret = 'SEC09f744f81b55c8a18f0d77a3ab60bf4e1ec3f16b85f025e6a4f75ddff00a8fd4'
  176. secret_enc = secret.encode('utf-8')
  177. string_to_sign = '{}\n{}'.format(timestamp, secret)
  178. string_to_sign_enc = string_to_sign.encode('utf-8')
  179. hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
  180. sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
  181. dingding_url = dingding_webhook + '&timestamp=' + timestamp + "&sign=" + sign
  182. if phone:
  183. header = {
  184. "Content-Type": "application/json"
  185. }
  186. data = {
  187. "at": {
  188. "atMobiles": phone,
  189. },
  190. "text": {
  191. "content": msg
  192. },
  193. "msgtype": "text"
  194. }
  195. else:
  196. header = {
  197. "Content-Type": "application/json"
  198. }
  199. data = {
  200. "at": {
  201. "isAtAll": True
  202. },
  203. "text": {
  204. "content": msg
  205. },
  206. "msgtype": "text"
  207. }
  208. res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
  209. def dingding_alert11(phone:list,msg):
  210. dingding_webhook="https://oapi.dingtalk.com/robot/send?access_token=c3be52d9ae7307dd7ceb0b677f569c47de2ff81b20fe30c328c75fbd9ab81383"
  211. timestamp = str(round(time.time() * 1000))
  212. secret = 'SEC14f583c6f735044be3f9f6fdc53edb7cf0b7d56d9b63c4b78bcafa9880814f9e'
  213. secret_enc = secret.encode('utf-8')
  214. string_to_sign = '{}\n{}'.format(timestamp, secret)
  215. string_to_sign_enc = string_to_sign.encode('utf-8')
  216. hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
  217. sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
  218. dingding_url = dingding_webhook + '&timestamp=' + timestamp + "&sign=" + sign
  219. if phone:
  220. header = {
  221. "Content-Type": "application/json"
  222. }
  223. data = {
  224. "at": {
  225. "atMobiles": phone,
  226. },
  227. "text": {
  228. "content": msg
  229. },
  230. "msgtype": "text"
  231. }
  232. else:
  233. header = {
  234. "Content-Type": "application/json"
  235. }
  236. data = {
  237. "at": {
  238. "isAtAll": True
  239. },
  240. "text": {
  241. "content": msg
  242. },
  243. "msgtype": "text"
  244. }
  245. res = requests.post(url=dingding_url, data=json.dumps(data), headers=header)
  246. def maintainAuthCheck(fdb:flightDB,name,flighttype):
  247. search=fdb.queryTabel("workerinfo","姓名","姓名 = '{}' and 南航授权 like '%{}%'".format(name,flighttype))
  248. if search ==None or len(search) !=0:
  249. res = {"返回值":"ok"}
  250. else:
  251. res = {"返回值": "fail"}
  252. return res
  253. def checkLoadSingal(wdb:flightDB,worknum,time,time2):
  254. try:
  255. table="workload"+str(worknum)
  256. #peopleLabel = ["序号", "保障日期", "类型", "机号", "机位", "开始时间", "结束时间"]
  257. LoadSingals={}
  258. res = wdb.sort_queryTable2("*", table, "保障日期='%s' or 保障日期='%s'"%(time,time2), "保障日期", "desc", "结束时间", "ASC")
  259. j=0
  260. if len(res) != 0:
  261. for i in res:
  262. LoadSingal = {}
  263. LoadSingal["序号"]=j
  264. LoadSingal["保障日期"] = i[6][0:10]
  265. if i[0][-1]=="1" and (i[7]=="特后前" or i[7]=="短停"):
  266. LoadSingal["类型"] = i[7]+"接机"
  267. elif i[0][-1]=="2" and (i[7]=="特后前" or i[7]=="短停"):
  268. LoadSingal["类型"] = i[7] + "送机"
  269. else:
  270. LoadSingal["类型"] = i[7]
  271. LoadSingal["机号"] = i[1]
  272. LoadSingal["机位"] = i[2]
  273. LoadSingal["开始时间"] = i[4]
  274. LoadSingal["结束时间"] = i[5]
  275. LoadSingals[j]=LoadSingal
  276. j += 1
  277. #print(LoadSingals)
  278. return LoadSingals
  279. except Exception:
  280. dingding_alert(traceback.format_exc())
  281. def changepassword(user,old,new):
  282. try:
  283. loginTabledb =flightDB(host=host,
  284. port=port,
  285. user=user,
  286. password=password,
  287. database=databaseloginDB
  288. )
  289. newdic={"密码":"'%s'"%new}
  290. loginTabledb.upDateItem("loginTable",newdic,"登录名='%s' and 密码='%s'"%(user,old))
  291. loginTabledb.close()
  292. except Exception:
  293. dingding_alert(traceback.format_exc())
  294. def qtPeopleLoad(fdb:flightDB,workLoad:flightDB,bc:str,nowDaystr:str):
  295. try:
  296. qtPeopleLoad={}
  297. aa=[]
  298. selectdaystr = str(nowDaystr)[0:4] + "-" + str(nowDaystr)[4:6] + "-" + str(nowDaystr)[6:] + " 00:00:00"
  299. selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
  300. selectday_2 = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(days=1)
  301. nowDay = datetime.date.today().strftime("%Y%m%d")
  302. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  303. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  304. nowtime = datetime.datetime.now()
  305. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  306. a_str = nowDay_str2 + " 00:00:00"
  307. b_str = nowDay_str2 + " 17:00:00"
  308. a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  309. b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
  310. nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  311. tomorrow_search = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  312. yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  313. if bc == "A":
  314. pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
  315. elif bc == "B" and nowDaystr == nowDay and a < nowtime < b:
  316. pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
  317. elif bc == "B" and nowDaystr == nowDay and b < nowtime:
  318. pglist_str = fdb.queryTabel("pglist{}".format(nowDay), "*", "班次='%s'" % bc)
  319. elif bc == "B" and nowDaystr == nowDay_1:
  320. pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
  321. elif bc == "B" and nowDaystr < nowDay_1:
  322. pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
  323. else:
  324. pglist_str = []
  325. diplaylist = pglist_str
  326. # peopleLabel = ["序号", "姓名", "角色", "总量", "当前", "最后时间"]
  327. rowNum = 0
  328. JS = ""
  329. workload = []
  330. workload_now = ""
  331. lastone=""
  332. for row in diplaylist:
  333. col={}
  334. if len(fdb.queryTabel('workerinfo', "*", "姓名='%s'" % row[0])) != 0:
  335. workload = []
  336. workload_now = []
  337. if bc == "A":
  338. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and 保障日期='%s'" % nowDayStr_search)
  339. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and 保障日期='%s'" % nowDayStr_search))
  340. elif bc == "B" and nowDaystr == nowDay and a < nowtime < b: # 选择今天00900之前的夜班
  341. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search))
  342. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search)))
  343. elif bc == "B" and nowDaystr == nowDay and b < nowtime:
  344. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, tomorrow_search))
  345. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, tomorrow_search)))
  346. elif bc == "B" and nowDaystr == nowDay_1: # 选择今天之前的夜班
  347. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search))
  348. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*","结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (nowDayStr_search, yesterday_search)))
  349. elif bc == "B" and nowDaystr < nowDay_1: # 选择今天之前的夜班
  350. workload = workLoad.queryTabel('workload{}'.format(row[1]), "*","开始时间!='' and (保障日期='%s' or 保障日期='%s')" % (selectday, selectday_2))
  351. workload_now = len(workload) - len(workLoad.queryTabel('workload{}'.format(row[1]), "*", "结束时间!='' and (保障日期='%s' or 保障日期='%s')" % (selectday, selectday_2)))
  352. time = []
  353. lastone = ""
  354. for j in workload:
  355. time.append(j[4])
  356. time.append(j[5])
  357. if len(time) != 0:
  358. lastone = time[0]
  359. for i in range(1, len(time) - 1):
  360. if lastone < time[i]:
  361. lastone = time[i]
  362. lastone = lastone[-8:-3]
  363. if row[2] == "WX":
  364. JS = "维修员"
  365. elif row[2] == "FX":
  366. JS ="放行"
  367. col={"序号":rowNum,"姓名":row[0],"角色":JS,"总量":str(len(workload)),"当前":str(workload_now),"最后时间":lastone,}
  368. aa.append(col)
  369. rowNum += 1
  370. if len(aa) != 0:
  371. #aa.sort(key=lambda x:(x["角色"],x['最后时间'],x['当前'],x['总量']))
  372. aa.sort(key=lambda x: (x["角色"], x['当前'], x['最后时间'], x['总量']))
  373. #print(aa)
  374. rowNum1=0
  375. for i in aa:
  376. i["序号"]=rowNum1
  377. qtPeopleLoad[rowNum1]=i
  378. rowNum1 += 1
  379. #print(qtPeopleLoad)
  380. return qtPeopleLoad
  381. except Exception:
  382. dingding_alert(traceback.format_exc())
  383. def updateDragDropItem(fdb:flightDB,column,text,flightid,displayMode,flighttype,selectedtime):
  384. try:
  385. flightid_new=""
  386. if displayMode =="A":
  387. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  388. flightid_new=flightid+"-1"+"-A"
  389. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  390. flightid_new = flightid + "-2" + "-A"
  391. elif displayMode =="B":
  392. if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
  393. flightid_new=flightid+"-1"+"-B"
  394. elif flighttype =="航前":
  395. flightid_new = flightid + "-2" + "-B"
  396. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  397. flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
  398. newdic = {}
  399. if str(flightid_new) not in str(flightids_in_peopleSchedule) and str(flightid_new) !="":
  400. newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
  401. for i in rowlistLabel.keys():
  402. if i == int(column):
  403. if text != "清空项目12345678987654321":
  404. newdic[rowlistLabel[i]] = text
  405. else:
  406. newdic[rowlistLabel[i]] = ""
  407. else:
  408. newdic[rowlistLabel[i]] = ""
  409. fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
  410. else:
  411. if text != "清空项目12345678987654321":
  412. newdic[rowlistLabel[int(column)]]="'%s'"%text
  413. else:
  414. newdic[rowlistLabel[int(column)]]="''"
  415. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  416. except Exception:
  417. dingding_alert(traceback.format_exc())
  418. def updateEidteItem(fdb:flightDB,text,flightid,displayMode,flighttype,selectedtime):
  419. try:
  420. if displayMode =="A":
  421. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  422. flightid_new=flightid+"-1"+"-A"
  423. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  424. flightid_new = flightid + "-2" + "-A"
  425. elif displayMode =="B":
  426. if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
  427. flightid_new=flightid+"-1"+"-B"
  428. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  429. flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
  430. newdic = {}
  431. if str(flightid_new) not in str(flightids_in_peopleSchedule):
  432. newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
  433. for i in rowlistLabel.keys():
  434. if i == -1:
  435. if text !="清空项目12345678987654321":
  436. newdic[rowlistLabel[i]]=text
  437. else:
  438. newdic[rowlistLabel[i]] = ""
  439. else:
  440. newdic[rowlistLabel[i]] = ""
  441. fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
  442. else:
  443. if text != "清空项目12345678987654321":
  444. newdic[rowlistLabel[int(-1)]]="'%s'"%text
  445. else:
  446. newdic[rowlistLabel[int(-1)]]="''"
  447. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  448. except Exception:
  449. dingding_alert(traceback.format_exc())
  450. def checkPglist(fdb:flightDB,name,selectedtime,bc):
  451. try:
  452. list=["1","2","3","4","5","6","7","8","9","10","11","12"]
  453. if name != "清空项目12345678987654321" and str(name) not in list:
  454. time2=datetime.datetime.strptime(selectedtime,"%Y%m%d")
  455. time1=str((time2 - datetime.timedelta(days=1)).strftime("%Y%m%d"))
  456. check=fdb.queryTabel("pglist{}".format(selectedtime), "工号", "班次='%s' and 姓名='%s'" % (bc,name))
  457. check2 = fdb.queryTabel("pglist{}".format(time1), "工号", "班次='%s' and 姓名='%s'" % (bc, name))
  458. if len(check) == 0 and len(check2) == 0:
  459. res="NO"
  460. else:
  461. res="YES"
  462. elif str(name) in list:
  463. res = "YES"
  464. else:
  465. res = "YES"
  466. return res
  467. except Exception:
  468. dingding_alert(traceback.format_exc())
  469. def mapDispaly(fdb:flightDB,selectedtime):
  470. try:
  471. mapDispalydata = {}
  472. nowDayStr = selectedtime
  473. sorttable = fdb.queryTabel("sortFlight{}".format(nowDayStr),"*","CAST(级别 AS integer)='1' or CAST(级别 AS integer)='3'")
  474. #{机位:[机号,机型,发动机,航班类型,航班号,ta,td,进港机场,出港机场,状态,放行,维修人员,二送人员,保留,工作包,TASKID,flightid,color,备注]}
  475. for row in sorttable:
  476. # print(row)
  477. otheroneSts = []
  478. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  479. if flightinfodata[11] == "短停":
  480. iddd=row[1]+"-1"
  481. iddddd = row[1] + "-2"
  482. jfjSts= fdb.queryTabel("sortFlight{}".format(nowDayStr),"级别","编号='%s'"%iddd)[0][0]
  483. sfjSts = fdb.queryTabel("sortFlight{}".format(nowDayStr), "级别", "编号='%s'" % iddddd)[0][0]
  484. # print(otheroneSts)
  485. if (flightinfodata[11] =="航前" and flightinfodata[21] !="") or (flightinfodata[11] !="航前" and flightinfodata[19] !=""):
  486. TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  487. if flightinfodata[11] == "航前" and flightinfodata[21] != "":
  488. bay=flightinfodata[21]
  489. color="#99CCCC"
  490. elif flightinfodata[11] == "航后" and flightinfodata[19] != "" and row[5]=="3":
  491. bay = flightinfodata[19]
  492. color = "#0095d9"
  493. elif flightinfodata[11] == "停场" and flightinfodata[19] != "" and row[5]=="3":
  494. bay = flightinfodata[19]
  495. color = "#0095d9"
  496. elif flightinfodata[11] == "航后" and flightinfodata[19] != "" and row[5]=="1":
  497. bay = "Y"+flightinfodata[19]
  498. color = "#f6ad49"
  499. elif flightinfodata[11] == "特后前" and flightinfodata[19] != "" and flightinfodata[14] == "":
  500. bay = "Y"+flightinfodata[19]
  501. color = "#f6ad49"
  502. elif flightinfodata[11] == "特后前" and flightinfodata[19] != "" and flightinfodata[14] != "":
  503. bay = flightinfodata[19]
  504. color = "#4c6cb3"
  505. elif flightinfodata[11] == "短停" and flightinfodata[19] != "" and jfjSts=="1":
  506. bay = "Y"+flightinfodata[19]
  507. color = "#f6ad49"
  508. elif flightinfodata[11] == "短停" and flightinfodata[19] != "" and jfjSts=="4" and sfjSts=="1":
  509. bay = flightinfodata[19]
  510. color = "#69b076"
  511. acno=flightinfodata[2]
  512. airpalneType=flightinfodata[4]
  513. EngType=flightinfodata[3]
  514. flightType = flightinfodata[11]
  515. flightNos = flightinfodata[8]
  516. DEP_CH=flightinfodata[6] #进港机场
  517. DEP_CH1=flightinfodata[7] #出港机场
  518. flightsts = flightinfodata[10]
  519. wx=flightinfodata[22]
  520. fx = flightinfodata[23]
  521. es = flightinfodata[30]
  522. flightid=flightinfodata[0]
  523. message=flightinfodata[32]
  524. e = "" #保留
  525. F = ""#工作包
  526. g = "" #taskid
  527. ta = ""
  528. td=""
  529. if len(TaskFlightinfo) != 0:
  530. if TaskFlightinfo[0][16] != "":
  531. e = "有保留"
  532. if TaskFlightinfo[0][18] != "":
  533. F = "有工作包"
  534. if TaskFlightinfo[0][21] != "":
  535. g = TaskFlightinfo[0][21]
  536. if "-" not in TaskFlightinfo[0][9].split('</br>')[0]:
  537. ta = TaskFlightinfo[0][9].split('</br>')[0]
  538. if "-" not in TaskFlightinfo[0][9].split('</br>')[1]:
  539. td = TaskFlightinfo[0][9].split('</br>')[1]
  540. if "CZ" in str(flightNos) or "OQ" in str(flightNos):
  541. nanhang="1"
  542. elif "3U" not in str(flightNos) or "CSC" not in str(flightNos):
  543. nanhang = "0"
  544. else:
  545. nanhang = "3"
  546. mapDispalydata[bay] = {"机号":acno,
  547. "机型":airpalneType,
  548. "发动机":EngType,
  549. "航班类型":flightType,
  550. "航班号":flightNos,
  551. "到达":ta,
  552. "起飞":td,
  553. "进港机场":DEP_CH,
  554. "出港机场":DEP_CH1,
  555. "状态":flightsts,
  556. "放行":fx,
  557. "维修人员":wx,
  558. "二送人员":es,
  559. "保留":e,
  560. "工作包":F,
  561. "TASKID":g,
  562. "flightid":flightid,
  563. "color":color,
  564. "备注":message,
  565. "南航":nanhang
  566. }
  567. return mapDispalydata
  568. except Exception:
  569. dingding_alert(traceback.format_exc())
  570. def postgresql_local(local:flightDB,host_online, port_online, user_online, password_online, database_online):
  571. print(datetime.datetime.now(), "[同步中心]开始同步数据库")
  572. today = datetime.datetime.now().strftime('%Y%m%d')
  573. yesterday=(datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y%m%d')
  574. tomorrow=(datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y%m%d')
  575. online=flightDB(host_online, port_online, user_online, password_online, database_online)
  576. table_colmuns={"flightinfo%s"%today:flightinfoLabel,"flightinfo%s"%yesterday:flightinfoLabel,"flightinfo%s"%tomorrow:flightinfoLabel,
  577. "peopleschedule%s"%today:peopleScheduleLabel,"peopleschedule%s"%yesterday:peopleScheduleLabel,"peopleschedule%s"%tomorrow:peopleScheduleLabel,
  578. "sortflight%s"%today:sortLabel,"sortflight%s"%yesterday:sortLabel,"sortflight%s"%tomorrow:sortLabel,
  579. "display":displayLabel}
  580. dbtables=["flightinfo%s"%today,"flightinfo%s"%yesterday,"flightinfo%s"%tomorrow,
  581. "peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,
  582. "sortflight%s"%today,"sortflight%s"%yesterday,"sortflight%s"%tomorrow,"display"]
  583. try:
  584. tablesok=""
  585. tablenum=0
  586. for dbtable in dbtables:
  587. try:
  588. Dic = {}
  589. primaryKey2 = 'text'
  590. for key in list(table_colmuns[dbtable])[1:]:
  591. Dic[key] = 'text'
  592. online.initTable(dbtable, table_colmuns[dbtable][0], primaryKey2, Dic)
  593. all_source_data=local.getAlldata(dbtable)
  594. if len(all_source_data)!=0:
  595. online.lazydeleteTable(dbtable)
  596. if dbtable=="display":
  597. dispaly_res=online.getSingledata("A", 'display')
  598. if dispaly_res == None or len(dispaly_res) == 0:
  599. online.insertData('display', {'ID': 1, 'A': '{}', 'B': '{}'})
  600. online.insertData('display', {'ID': 2, 'A': '{}', 'B': '{}'})
  601. online.insertData('display', {'ID': 3, 'A': '{}', 'B': '{}'})
  602. for row in all_source_data:
  603. newdic = {"A": '"{}"'.format(row[1]),"B": '"{}"'.format(row[2])}
  604. online.lazyUpdateItem(dbtable, newdic, "ID = '%s'"%row[0])
  605. #online.FunctionCommit()
  606. else:
  607. for row in all_source_data:
  608. online.lazyInsertData2(dbtable,', '.join(table_colmuns[dbtable]),row)
  609. online.FunctionCommit()
  610. tablesok=tablesok+dbtable+"/"
  611. tablenum+=1
  612. except :
  613. print(traceback.format_exc())
  614. continue
  615. print(datetime.datetime.now(), "[同步中心]完成数据库同步(%s[%s])"%(tablesok,tablenum))
  616. return "ok"
  617. except Exception:
  618. print(traceback.format_exc())
  619. return "fail"
  620. def bakupdata(fdb:flightDB):
  621. try:
  622. #print("5分钟间隔自动备份")
  623. nowDay = str(datetime.date.today().strftime("%Y%m%d"))
  624. nowDay_1 = str((datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d"))
  625. aaa={nowDay:"今天",nowDay_1:"昨天"}
  626. tableWidgetDispalydatas={}
  627. wb = Workbook()
  628. for selectedtime in [nowDay,nowDay_1]:
  629. wb.create_sheet(title="%s"%selectedtime, index=0)
  630. ws = wb.active
  631. ws.title = "%s"%selectedtime
  632. ws= wb["%s"%selectedtime]
  633. ws.cell(1, 1).value = "序号"
  634. ws.cell(1, 2).value = "类型"
  635. ws.cell(1, 3).value = "航班号"
  636. ws.cell(1, 4).value = "机型"
  637. ws.cell(1, 5).value = "发动机"
  638. ws.cell(1, 6).value = "机号"
  639. ws.cell(1, 7).value = "计达"
  640. ws.cell(1, 8).value = "预达"
  641. ws.cell(1, 9).value = "计飞"
  642. ws.cell(1, 10).value = "机位"
  643. ws.cell(1, 11).value = "放行"
  644. ws.cell(1, 12).value = "工1"
  645. ws.cell(1, 13).value = "工2"
  646. ws.cell(1, 14).value = "工3"
  647. ws.cell(1, 15).value = "工4"
  648. ws.cell(1, 16).value = "工5"
  649. ws.cell(1, 17).value = "送1"
  650. ws.cell(1, 18).value = "送2"
  651. ws.cell(1, 19).value = "备注"
  652. ws.cell(1, 20).value = "接机到位"
  653. ws.cell(1, 21).value = "二送到位"
  654. ws.cell(1, 22).value = "放行情况"
  655. ws.cell(1, 23).value = "销子夹板"
  656. tableWidgetDispalydata = {}
  657. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight2")
  658. nowDayStr = selectedtime
  659. '''
  660. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  661. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  662. "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "返航备降", "25": "维修人员",
  663. "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
  664. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  665. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  666. "18": "放行","19": "销夹", "17": "二送","20":"附加消息","21": "送机1", "22": "送机2"}
  667. '''
  668. rowNum = 0
  669. for row in sorttable:
  670. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  671. flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "","", "", "","", "", "","", "", "","", "", ""]
  672. jjdw = "√" if flightstsdata[3] != "" else ""
  673. FX = "√" if flightstsdata[4] != "" else ""
  674. XJ = "√" if flightstsdata[5] != "" else ""
  675. ESDW = "√" if flightstsdata[7] != "" else ""
  676. flighttype=flightinfodata[11] if "3U" not in str(flightinfodata[8]) and "CSC" not in str(flightinfodata[8]) else "外"+str(flightinfodata[11])
  677. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  678. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  679. a = flightinfodata[15][-8:-3]
  680. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  681. a = flightinfodata[12][-8:-3]
  682. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  683. a = ""
  684. elif flightinfodata[16] != "":
  685. a = ""
  686. a = str(a).split(":")[0] + str(a).split(":")[1] if a != "" else ""
  687. b = str(flightinfodata[15][-8:-3]).split(":")[0] + str(flightinfodata[15][-8:-3]).split(":")[1] if flightinfodata[15] != "" else ""
  688. c = flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  689. c = str(c).split(":")[0]+ str(c).split(":")[1] if c != "" else ""
  690. fx = ""
  691. g1 = ""
  692. g2 = ""
  693. g3 = ""
  694. g4 = ""
  695. g5 = ""
  696. fj1 = ""
  697. s1 = ""
  698. s2 = ""
  699. fj2 = ""
  700. fj =""
  701. peopleSchedules = fdb.queryTabel('peopleSchedule{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])) if \
  702. len(fdb.queryTabel('peopleSchedule{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else [("000", "", "", "", "", "", "", "", "", "")]
  703. #print(peopleSchedules)
  704. for i in peopleSchedules:
  705. if i[0][-3] =="1":
  706. fx=i[3]
  707. g1=i[4]
  708. g2 = i[5]
  709. g3 = i[6]
  710. g4 = i[7]
  711. g5 = i[8]
  712. fj1= i[9]
  713. elif i[0][-3] =="2":
  714. s1 = i[7]
  715. s2 = i[8]
  716. fj2 = i[9]
  717. fj=fj1+fj2
  718. if flightinfodata[11] == "航后":
  719. ws.cell(rowNum+2, 1).value = rowNum+1
  720. ws.cell(rowNum+2, 2).value = flighttype
  721. ws.cell(rowNum+2, 3).value = flightinfodata[8]
  722. ws.cell(rowNum+2, 4).value = flightinfodata[4]
  723. ws.cell(rowNum+2, 5).value = flightinfodata[3]
  724. ws.cell(rowNum+2, 6).value = flightinfodata[2]
  725. ws.cell(rowNum+2, 7).value = a
  726. ws.cell(rowNum+2, 8).value = b
  727. ws.cell(rowNum+2, 9).value = ""
  728. ws.cell(rowNum+2, 10).value = flightinfodata[19]
  729. ws.cell(rowNum+2, 11).value = fx
  730. ws.cell(rowNum+2, 12).value =g1
  731. ws.cell(rowNum+2, 13).value = g2
  732. ws.cell(rowNum+2, 14).value = g3
  733. ws.cell(rowNum+2, 15).value = g4
  734. ws.cell(rowNum+2, 16).value = g5
  735. ws.cell(rowNum+2, 17).value = s1
  736. ws.cell(rowNum+2, 18).value = s2
  737. ws.cell(rowNum+2, 19).value = fj
  738. ws.cell(rowNum+2, 20).value = jjdw
  739. ws.cell(rowNum+2, 21).value = ""
  740. ws.cell(rowNum+2, 22).value = ""
  741. ws.cell(rowNum+2, 23).value = ""
  742. rowNum += 1
  743. elif flightinfodata[11] == "停场":
  744. ws.cell(rowNum + 2, 1).value = rowNum+1
  745. ws.cell(rowNum + 2, 2).value = flighttype
  746. ws.cell(rowNum + 2, 3).value = ""
  747. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  748. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  749. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  750. ws.cell(rowNum + 2, 7).value = ""
  751. ws.cell(rowNum + 2, 8).value = ""
  752. ws.cell(rowNum + 2, 9).value = ""
  753. ws.cell(rowNum + 2, 10).value = flightinfodata[19]
  754. ws.cell(rowNum + 2, 11).value = fx
  755. ws.cell(rowNum + 2, 12).value = g1
  756. ws.cell(rowNum + 2, 13).value = g2
  757. ws.cell(rowNum + 2, 14).value = g3
  758. ws.cell(rowNum + 2, 15).value = g4
  759. ws.cell(rowNum + 2, 16).value = g5
  760. ws.cell(rowNum + 2, 17).value = s1
  761. ws.cell(rowNum + 2, 18).value = s2
  762. ws.cell(rowNum + 2, 19).value = fj
  763. ws.cell(rowNum + 2, 20).value = ""
  764. ws.cell(rowNum + 2, 21).value = ""
  765. ws.cell(rowNum + 2, 22).value = ""
  766. ws.cell(rowNum + 2, 23).value = ""
  767. rowNum += 1
  768. elif flightinfodata[11] == "航前":
  769. ws.cell(rowNum + 2, 1).value = rowNum+1
  770. ws.cell(rowNum + 2, 2).value = flighttype
  771. ws.cell(rowNum + 2, 3).value = flightinfodata[8]
  772. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  773. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  774. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  775. ws.cell(rowNum + 2, 7).value = ""
  776. ws.cell(rowNum + 2, 8).value = ""
  777. ws.cell(rowNum + 2, 9).value = c
  778. ws.cell(rowNum + 2, 10).value = flightinfodata[21]
  779. ws.cell(rowNum + 2, 11).value = fx
  780. ws.cell(rowNum + 2, 12).value = g1
  781. ws.cell(rowNum + 2, 13).value = g2
  782. ws.cell(rowNum + 2, 14).value = g3
  783. ws.cell(rowNum + 2, 15).value = g4
  784. ws.cell(rowNum + 2, 16).value = g5
  785. ws.cell(rowNum + 2, 17).value = s1
  786. ws.cell(rowNum + 2, 18).value = s2
  787. ws.cell(rowNum + 2, 19).value = fj
  788. ws.cell(rowNum + 2, 20).value = jjdw
  789. ws.cell(rowNum + 2, 21).value = ""
  790. ws.cell(rowNum + 2, 22).value = FX
  791. ws.cell(rowNum + 2, 23).value = XJ
  792. rowNum += 1
  793. elif row[3] == "短停接":
  794. ws.cell(rowNum + 2, 1).value = rowNum+1
  795. ws.cell(rowNum + 2, 2).value = flighttype
  796. ws.cell(rowNum + 2, 3).value = flightinfodata[8]
  797. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  798. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  799. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  800. ws.cell(rowNum + 2, 7).value = a
  801. ws.cell(rowNum + 2, 8).value = b
  802. ws.cell(rowNum + 2, 9).value = c
  803. ws.cell(rowNum + 2, 10).value = flightinfodata[19]
  804. ws.cell(rowNum + 2, 11).value = fx
  805. ws.cell(rowNum + 2, 12).value = g1
  806. ws.cell(rowNum + 2, 13).value = g2
  807. ws.cell(rowNum + 2, 14).value = g3
  808. ws.cell(rowNum + 2, 15).value = g4
  809. ws.cell(rowNum + 2, 16).value = g5
  810. ws.cell(rowNum + 2, 17).value = s1
  811. ws.cell(rowNum + 2, 18).value = s2
  812. ws.cell(rowNum + 2, 19).value = fj
  813. ws.cell(rowNum + 2, 20).value = jjdw
  814. ws.cell(rowNum + 2, 21).value = ESDW
  815. ws.cell(rowNum + 2, 22).value = FX
  816. ws.cell(rowNum + 2, 23).value = ""
  817. rowNum += 1
  818. elif row[3] == "特后前接":
  819. ws.cell(rowNum + 2, 1).value = rowNum+1
  820. ws.cell(rowNum + 2, 2).value = flighttype
  821. ws.cell(rowNum + 2, 3).value = flightinfodata[8]
  822. ws.cell(rowNum + 2, 4).value = flightinfodata[4]
  823. ws.cell(rowNum + 2, 5).value = flightinfodata[3]
  824. ws.cell(rowNum + 2, 6).value = flightinfodata[2]
  825. ws.cell(rowNum + 2, 7).value = a
  826. ws.cell(rowNum + 2, 8).value = b
  827. ws.cell(rowNum + 2, 9).value = c
  828. ws.cell(rowNum + 2, 10).value = flightinfodata[19]
  829. ws.cell(rowNum + 2, 11).value = fx
  830. ws.cell(rowNum + 2, 12).value = g1
  831. ws.cell(rowNum + 2, 13).value = g2
  832. ws.cell(rowNum + 2, 14).value = g3
  833. ws.cell(rowNum + 2, 15).value = g4
  834. ws.cell(rowNum + 2, 16).value = g5
  835. ws.cell(rowNum + 2, 17).value = s1
  836. ws.cell(rowNum + 2, 18).value = s2
  837. ws.cell(rowNum + 2, 19).value = fj
  838. ws.cell(rowNum + 2, 20).value = jjdw
  839. ws.cell(rowNum + 2, 20).value = jjdw
  840. ws.cell(rowNum + 2, 21).value = ESDW
  841. ws.cell(rowNum + 2, 22).value = FX
  842. ws.cell(rowNum + 2, 23).value = ""
  843. rowNum += 1
  844. wb.save('D:/flightinfo/bakup/航班运行备份数据(勿动).xlsx')
  845. #wb.save('航班运行备份数据.xlsx')
  846. res="ok"
  847. return res
  848. except Exception:
  849. dingding_alert(traceback.format_exc())
  850. def tableWidgetDispalyRead(fdb:flightDB,date):
  851. if date == "1":
  852. tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '1'")[0][0] if len(
  853. fdb.queryTabel("display", "A", "ID = '1'")) != 0 else {}
  854. if date == "2":
  855. tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '2'")[0][0] if len(
  856. fdb.queryTabel("display", "A", "ID = '2'")) != 0 else {}
  857. if date == "3":
  858. tableWidgetDispalydata1 = fdb.queryTabel("display", "A", "ID = '3'")[0][0] if len(
  859. fdb.queryTabel("display", "A", "ID = '3'")) != 0 else {}
  860. if "\'" in tableWidgetDispalydata1:
  861. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("\'", '"')
  862. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("'", '"')
  863. tableWidgetDispalydata1 = eval(tableWidgetDispalydata1)
  864. return tableWidgetDispalydata1
  865. def tableWidgetDispalyRead2(fdb:flightDB,date):
  866. if date == "1":
  867. tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '1'")[0][0] if len(
  868. fdb.queryTabel("display", "B", "ID = '1'")) != 0 else {}
  869. if date == "2":
  870. tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '2'")[0][0] if len(
  871. fdb.queryTabel("display", "B", "ID = '2'")) != 0 else {}
  872. if date == "3":
  873. tableWidgetDispalydata1 = fdb.queryTabel("display", "B", "ID = '3'")[0][0] if len(
  874. fdb.queryTabel("display", "B", "ID = '3'")) != 0 else {}
  875. if "\'" in tableWidgetDispalydata1:
  876. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("\'", '"')
  877. tableWidgetDispalydata1 = tableWidgetDispalydata1.replace("'", '"')
  878. tableWidgetDispalydata1 = eval(tableWidgetDispalydata1)
  879. return tableWidgetDispalydata1
  880. def TuplefindInList(lists: list, args):
  881. for l in lists:
  882. if args in l:
  883. return l
  884. return None
  885. def functionDisaplay(row,rowNum,TaskFlightinfoAlldata, workjobDataAll,flightInfoDataAll, flightStsDataAll,
  886. peopleScheduleDataAll, waringMessageID):
  887. #print("kaishi")
  888. TaskFlightinfo = TuplefindInList(TaskFlightinfoAlldata,row[1])
  889. #print(TaskFlightinfo)
  890. # print(row)
  891. e = ""
  892. F = ""
  893. g = ""
  894. if TaskFlightinfo != None and TaskFlightinfo[16] != "":
  895. e = "保留"
  896. if TaskFlightinfo != None :
  897. takinfo = TuplefindInList(workjobDataAll, TaskFlightinfo[21])
  898. JWA = TaskFlightinfo[10]
  899. JWB = TaskFlightinfo[11]
  900. if JWA =="" and JWB !="":
  901. JWA=JWB
  902. elif JWB =="" and JWA !="":
  903. JWB=JWA
  904. if TaskFlightinfo[18] != "":
  905. #takinfo = fdb.queryTabel('workjob', '*', "任务编号= '%s'" % TaskFlightinfo[0][21])
  906. F = "工作包无法正常获取请通过AMRO人工查询"
  907. if takinfo != None and takinfo[4] != "":
  908. F = takinfo[4] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[6] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[7]
  909. elif takinfo != None:
  910. F = "工作包暂未获取请点击右键工作包查询后即可随意查看"
  911. else:
  912. JWA =""
  913. JWB =""
  914. if TaskFlightinfo != None and TaskFlightinfo[21] != "":
  915. g = TaskFlightinfo[21]
  916. #print("tttt:{}".format(g))
  917. wx_people = ""
  918. fx_people = ""
  919. ecsj_people = ""
  920. ta_td = ""
  921. type31 = ""
  922. if TaskFlightinfo != None:
  923. wx_people = TaskFlightinfo[12]
  924. fx_people = TaskFlightinfo[13]
  925. ecsj_people = TaskFlightinfo[19]
  926. ta_td = TaskFlightinfo[9]
  927. type31 = TaskFlightinfo[3]
  928. # print(row[1])
  929. # print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
  930. flightinfodata = TuplefindInList(flightInfoDataAll,row[1])
  931. #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  932. flightstsdata = TuplefindInList(flightStsDataAll, row[1]) if TuplefindInList(flightStsDataAll, row[1]) != None \
  933. else ["", "","", "", "", "","", "", "", "","", "", "", ""]
  934. # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  935. # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  936. # "", "", "", "",
  937. # "", "", "", "",
  938. # "", "", "", ""]
  939. jjdw = "√" if flightstsdata[3] != "" else ""
  940. FX = "√" if flightstsdata[4] != "" else ""
  941. XJ = "√" if flightstsdata[5] != "" else ""
  942. ESDW = "√" if flightstsdata[7] != "" else ""
  943. if flightinfodata[11] == "航后":
  944. postion = str(flightinfodata[6]) + "-天府"
  945. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  946. postion = str(flightinfodata[6]) + "-天府-" + str(flightinfodata[7])
  947. else:
  948. postion = "天府-" + str(flightinfodata[7])
  949. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  950. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  951. a = flightinfodata[15][-8:-3]
  952. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  953. a = flightinfodata[12][-8:-3]
  954. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  955. a = ""
  956. elif flightinfodata[16] != "":
  957. a = ""
  958. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  959. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  960. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  961. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  962. waringMessageIDs = waringMessageID
  963. if str(row[1]) in str(waringMessageIDs["通用警告"]):
  964. color_code = QColorList[6]
  965. color_code1 = QColorList[1]
  966. color_code2 = QColorList[1]
  967. color_code3 = QColorList[1]
  968. elif row[3] == "短停接" and (
  969. str(row[1]) in str(waringMessageIDs["到位警告"]) or str(row[1]) in str(waringMessageIDs["ETA"]) or str(
  970. row[1]) in str(waringMessageIDs["BAY_2"])):
  971. color_code = QColorList[6]
  972. color_code1 = QColorList[1]
  973. color_code2 = QColorList[1]
  974. color_code3 = QColorList[1]
  975. elif row[3] == "短停送" and (
  976. str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
  977. color_code = QColorList[6]
  978. color_code1 = QColorList[1]
  979. color_code2 = QColorList[1]
  980. color_code3 = QColorList[1]
  981. elif row[5] == "4":
  982. color_code = QColorList[5]
  983. color_code1 = QColorList[1]
  984. color_code2 = QColorList[1]
  985. color_code3 = QColorList[1]
  986. elif row[5] == "3":
  987. color_code = QColorList[3]
  988. color_code1 = QColorList[0]
  989. color_code2 = QColorList[0]
  990. color_code3 = QColorList[0]
  991. elif row[5] == "2":
  992. color_code = QColorList[2]
  993. color_code1 = QColorList[0]
  994. color_code2 = QColorList[0]
  995. color_code3 = QColorList[0]
  996. elif row[5] == "1":
  997. if (rowNum + 2) % 2 == 0:
  998. color_code = QColorList[4]
  999. else:
  1000. color_code = QColorList[1]
  1001. color_code1 = QColorList[0]
  1002. color_code2 = QColorList[6]
  1003. color_code3 = QColorList[7]
  1004. findid = row[0] + "-A"
  1005. #print(peopleScheduleDataAll)
  1006. peopleSchedule = TuplefindInList(peopleScheduleDataAll,findid)
  1007. #peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
  1008. #print(peopleSchedule)
  1009. if peopleSchedule != None:
  1010. fx = peopleSchedule[3]
  1011. qw1 = peopleSchedule[4]
  1012. qw2 = peopleSchedule[5]
  1013. g1 = peopleSchedule[6]
  1014. g2 = peopleSchedule[7]
  1015. g3 = peopleSchedule[8]
  1016. if flightinfodata[28] != "" and flightinfodata[28][0] == "R" and "返航航班" not in str(peopleSchedule[9]):
  1017. fj = "返航航班;" + str(peopleSchedule[9])
  1018. elif flightinfodata[28] != "" and flightinfodata[28] == "V" and "备降航班" not in str(peopleSchedule[9]):
  1019. fj = "备降航班;" + str(peopleSchedule[9])
  1020. else:
  1021. fj = str(peopleSchedule[9])
  1022. else:
  1023. fx = ""
  1024. qw1 = ""
  1025. qw2 = ""
  1026. g1 = ""
  1027. g2 = ""
  1028. g3 = ""
  1029. if flightinfodata[28] != "" and flightinfodata[28][0] == "R":
  1030. fj = "返航航班;"
  1031. elif flightinfodata[28] != "" and flightinfodata[28][0] == "V":
  1032. fj = "备降航班;"
  1033. else:
  1034. fj = ""
  1035. if "随机离港" in str(fj):
  1036. SJDW = "√" if flightstsdata[6] != "" else ""
  1037. else:
  1038. SJDW ="--"
  1039. if flightinfodata[11] == "航后":
  1040. item_dic = {"0": rowNum,
  1041. "1": flightinfodata[2],
  1042. "2": flightinfodata[4],
  1043. "3": flightinfodata[3],
  1044. "4": flightinfodata[8],
  1045. "5": a,
  1046. "6": b,
  1047. "7": "--",
  1048. "8": JWA,
  1049. "9": row[3],
  1050. "10": fx,
  1051. "11": qw1,
  1052. "12": qw2,
  1053. "13": g1,
  1054. "14": g2,
  1055. "15": g3,
  1056. "16": jjdw,
  1057. "17": "--",
  1058. "18": "--",
  1059. "19": d,
  1060. "20": "--",
  1061. "21": e,
  1062. "22": F,
  1063. "23": postion,
  1064. "24": wx_people, # flightinfodata[22],
  1065. "25": fx_people, # flightinfodata[23],
  1066. "26": row[1],
  1067. "27": g,
  1068. "28": ta_td,
  1069. "29": type31,
  1070. "30": fj,
  1071. "99": color_code,
  1072. "101": color_code1,
  1073. "102": color_code2,
  1074. "103": color_code3,
  1075. "109": row[5]
  1076. }
  1077. elif flightinfodata[11] == "停场":
  1078. item_dic = {"0": rowNum,
  1079. "1": flightinfodata[2],
  1080. "2": flightinfodata[4],
  1081. "3": flightinfodata[3],
  1082. "4": "--",
  1083. "5": a,
  1084. "6": "--",
  1085. "7": "--",
  1086. "8": flightinfodata[19],
  1087. "9": row[3],
  1088. "10": fx,
  1089. "11": qw1,
  1090. "12": qw2,
  1091. "13": g1,
  1092. "14": g2,
  1093. "15": g3,
  1094. "16": "--",
  1095. "17": "--",
  1096. "18": "--",
  1097. "19": "--",
  1098. "20": "--",
  1099. "21": "--",
  1100. "22": "--",
  1101. "23": "--",
  1102. "24": "--", # flightinfodata[22],
  1103. "25": "--", # flightinfodata[23],
  1104. "26": row[1],
  1105. "27": "TSK",
  1106. "28": "--",
  1107. "29": "--",
  1108. "30": fj,
  1109. "99": color_code,
  1110. "101": color_code1,
  1111. "102": color_code2,
  1112. "103": color_code3,
  1113. "109": row[5]
  1114. }
  1115. elif flightinfodata[11] == "航前":
  1116. item_dic = {"0": rowNum,
  1117. "1": flightinfodata[2],
  1118. "2": flightinfodata[4],
  1119. "3": flightinfodata[3],
  1120. "4": flightinfodata[8],
  1121. "5": "",
  1122. "6": "",
  1123. "7": c,
  1124. "8": JWB,
  1125. "9": row[3],
  1126. "10": fx,
  1127. "11": qw1,
  1128. "12": qw2,
  1129. "13": g1,
  1130. "14": g2,
  1131. "15": g3,
  1132. "16": jjdw,
  1133. "17": FX,
  1134. "18": XJ,
  1135. "19": d,
  1136. "20": SJDW,
  1137. "21": e,
  1138. "22": F,
  1139. "23": postion,
  1140. "24": wx_people, # flightinfodata[22],
  1141. "25": fx_people, # flightinfodata[23],
  1142. "26": row[1],
  1143. "27": g,
  1144. "28": ta_td,
  1145. "29": type31,
  1146. "30": fj,
  1147. "99": color_code,
  1148. "101": color_code1,
  1149. "102": color_code2,
  1150. "103": color_code3,
  1151. "109": row[5]
  1152. }
  1153. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前") and (row[3] == "短停接" or row[3] == "特后前接"):
  1154. item_dic = {"0": rowNum,
  1155. "1": flightinfodata[2],
  1156. "2": flightinfodata[4],
  1157. "3": flightinfodata[3],
  1158. "4": flightinfodata[8],
  1159. "5": a,
  1160. "6": b,
  1161. "7": c,
  1162. "8": JWA,
  1163. "9": row[3],
  1164. "10": fx,
  1165. "11": qw1,
  1166. "12": qw2,
  1167. "13": g1,
  1168. "14": g2,
  1169. "15": g3,
  1170. "16": jjdw,
  1171. "17": FX,
  1172. "18": "--",
  1173. "19": d,
  1174. "20": SJDW,
  1175. "21": e,
  1176. "22": F,
  1177. "23": postion,
  1178. "24": wx_people, # flightinfodata[22],
  1179. "25": fx_people, # flightinfodata[23],
  1180. "26": row[1],
  1181. "27": g,
  1182. "28": ta_td,
  1183. "29": type31,
  1184. "30": fj,
  1185. "99": color_code,
  1186. "101": color_code1,
  1187. "102": color_code2,
  1188. "103": color_code3,
  1189. "109": row[5]
  1190. }
  1191. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前") and (row[3] == "短停送" or row[3] == "特后前送"):
  1192. item_dic = {"0": rowNum,
  1193. "1": flightinfodata[2],
  1194. "2": flightinfodata[4],
  1195. "3": flightinfodata[3],
  1196. "4": flightinfodata[8],
  1197. "5": a,
  1198. "6": b,
  1199. "7": c,
  1200. "8": JWA,
  1201. "9": row[3],
  1202. "10": fx,
  1203. "11": qw1,
  1204. "12": qw2,
  1205. "13": g1,
  1206. "14": g2,
  1207. "15": g3,
  1208. "16": ESDW,
  1209. "17": FX,
  1210. "18": "--",
  1211. "19": d,
  1212. "20": SJDW,
  1213. "21": e,
  1214. "22": F,
  1215. "23": postion,
  1216. "24": ecsj_people, # flightinfodata[22],
  1217. "25": fx_people, # flightinfodata[23],
  1218. "26": row[1],
  1219. "27": g,
  1220. "28": ta_td,
  1221. "29": type31,
  1222. "30": fj,
  1223. "99": color_code,
  1224. "101": color_code1,
  1225. "102": color_code2,
  1226. "103": color_code3,
  1227. "109": row[5]
  1228. }
  1229. else:
  1230. item_dic = {"0": rowNum,
  1231. "1": flightinfodata[2],
  1232. "2": flightinfodata[4],
  1233. "3": flightinfodata[3],
  1234. "4": flightinfodata[8],
  1235. "5": a,
  1236. "6": b,
  1237. "7": c,
  1238. "8": JWA,
  1239. "9": row[3],
  1240. "10": fx,
  1241. "11": qw1,
  1242. "12": qw2,
  1243. "13": g1,
  1244. "14": g2,
  1245. "15": g3,
  1246. "16": jjdw,
  1247. "17": FX,
  1248. "18": "--",
  1249. "19": d,
  1250. "20": SJDW,
  1251. "21": e,
  1252. "22": F,
  1253. "23": postion,
  1254. "24": wx_people, # flightinfodata[22],
  1255. "25": fx_people, # flightinfodata[23],
  1256. "26": row[1],
  1257. "27": g,
  1258. "28": ta_td,
  1259. "29": type31,
  1260. "30": fj,
  1261. "99": color_code,
  1262. "101": color_code1,
  1263. "102": color_code2,
  1264. "103": color_code3,
  1265. "109": row[5]
  1266. }
  1267. #tableWidgetDispalydata[rowNum] = item_dic
  1268. #rowNum += 1
  1269. # print(rowNum)
  1270. # print(item_dic)
  1271. # print({rowNum:item_dic})
  1272. return {rowNum:item_dic}
  1273. #########################################
  1274. # 测试导出
  1275. def tableWidgetDispalyAlllogs(fdb: flightDB):
  1276. index2 = {0: "编号", 1: "航班编号", 2: "警告信息", 3: "信息状态", 4: "提示信息", 5: "产生时间", 6: "处理人", 7: "处理时间", 8: "变更字段",9: "显示对象", 10: "提示内容"}
  1277. data = fdb.getAlldata("logs")
  1278. res = {}
  1279. if data != None and len(data) != 0:
  1280. for i in data:
  1281. aa = {}
  1282. for j in index2.keys():
  1283. aa["%s"%j]=i[j]
  1284. res[i[0]]=aa
  1285. return res
  1286. def tableWidgetDispalyCalllogs(fdb: flightDB):
  1287. index2 = {0: "航班编号", 1: "电话", 2: "航班号", 3: "创建时间", 4: "姓名", 5: "接通时间", 6: "附加信息", 7: "工号", 8: "拨号次数"}
  1288. data = fdb.getAlldata("Calllist")
  1289. res = {}
  1290. if data != None and len(data) != 0:
  1291. ii = 0
  1292. for i in data:
  1293. aa = {}
  1294. for j in index2.keys():
  1295. aa["%s"%j]=i[j]
  1296. res[ii]=aa
  1297. ii+=1
  1298. return res
  1299. ########################################
  1300. def tableWidgetDispaly(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  1301. try:
  1302. #t1 = datetime.datetime.now()
  1303. tableWidgetDispalydata = {}
  1304. nowDayStr = selectedtime
  1305. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
  1306. #t2 = datetime.datetime.now()
  1307. #print(f'【航班刷新】【数据库1】:{t2 - t1}')
  1308. TaskFlightinfoAlldata = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
  1309. #t3 = datetime.datetime.now()
  1310. #print(f'【航班刷新】【数据库2】:{t3 - t2}')
  1311. flightInfoDataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
  1312. #t4 = datetime.datetime.now()
  1313. #print(f'【航班刷新】【数据库3】:{t4 - t3}')
  1314. flightStsDataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
  1315. #t5 = datetime.datetime.now()
  1316. #print(f'【航班刷新】【数据库4】:{t5 - t4}')
  1317. peopleScheduleDataAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
  1318. #t6 = datetime.datetime.now()
  1319. #print(f'【航班刷新】【数据库5】:{t6 - t5}')
  1320. workjobDataAll = fdb.getAlldata('workjob')
  1321. #t7 = datetime.datetime.now()
  1322. #print(f'【航班刷新】【数据库6】:{t7 - t6}')
  1323. #print(f'【航班刷新】【数据库ALL】:{t7 - t1}')
  1324. waringMessageIDs = waringMessageID(fdb)
  1325. executor = concurrent.futures.ThreadPoolExecutor()
  1326. all_task = []
  1327. for i in range(len(sorttable)):
  1328. all_task.append(executor.submit(functionDisaplay, sorttable[i],i, TaskFlightinfoAlldata,workjobDataAll,flightInfoDataAll, flightStsDataAll,peopleScheduleDataAll,waringMessageIDs))
  1329. for future in concurrent.futures.as_completed(all_task):
  1330. data = future.result()
  1331. tableWidgetDispalydata.update(data)
  1332. #t8 = datetime.datetime.now()
  1333. #print(f'【航班刷新】【处理数据】:{t8 - t7}')
  1334. newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
  1335. if date == "1":
  1336. fdb.upDateItem("display", newdic, "ID = '1'")
  1337. elif date == "2":
  1338. fdb.upDateItem("display", newdic, "ID = '2'")
  1339. elif date == "3":
  1340. fdb.upDateItem("display", newdic, "ID = '3'")
  1341. #t9 = datetime.datetime.now()
  1342. #print(f'【航班刷新】【保存数据】:{t9 - t8}')
  1343. #print(f'【航班刷新】【总时间】:{t9 - t1}')
  1344. return tableWidgetDispalydata
  1345. except Exception:
  1346. #dingding_alert(traceback.format_exc())
  1347. print(traceback.format_exc())
  1348. def functionDisplay2(row, rowNum, TaskFlightinfoAll,flightinfodataAll,flightstsdataAll,waringMessageIDs,peopleScheduleAll):
  1349. TaskFlightinfo = TuplefindInList(TaskFlightinfoAll,row[1])
  1350. #TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  1351. e = ""
  1352. F = ""
  1353. g = ""
  1354. if TaskFlightinfo != None:
  1355. JWA = TaskFlightinfo[10]
  1356. JWB = TaskFlightinfo[11]
  1357. if JWB!="" and JWA =="":
  1358. JWA=JWB
  1359. if JWA!="" and JWB =="":
  1360. JWB=JWA
  1361. if TaskFlightinfo[16] != "":
  1362. e = "保留"
  1363. if TaskFlightinfo[18] != "":
  1364. F = "工作包"
  1365. if TaskFlightinfo[21] != "":
  1366. g = TaskFlightinfo[21]
  1367. else:
  1368. JWA = ""
  1369. JWB = ""
  1370. wx_people = ""
  1371. fx_people = ""
  1372. ecsj_people = ""
  1373. ta_td = ""
  1374. type31 = ""
  1375. # print(TaskFlightinfo)
  1376. if TaskFlightinfo != None:
  1377. wx_people = TaskFlightinfo[12]
  1378. fx_people = TaskFlightinfo[13]
  1379. ecsj_people = TaskFlightinfo[19]
  1380. ta_td = TaskFlightinfo[9]
  1381. type31 = TaskFlightinfo[3]
  1382. #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  1383. # print(flightinfodataAll)
  1384. # print(row[0])
  1385. flightinfodata = TuplefindInList(flightinfodataAll, row[1])
  1386. # print(flightinfodata)
  1387. # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  1388. # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  1389. # "", "", "", "",
  1390. # "", "", "", "",
  1391. # "", "", "", ""]
  1392. flightstsdata = TuplefindInList(flightstsdataAll,row[0])if TuplefindInList(flightstsdataAll,row[0])!=None \
  1393. else ["", "","", "", "", "","", "", "", "","", "", "", ""]
  1394. jjdw = "√" if flightstsdata[3] != "" else ""
  1395. FX = "√" if flightstsdata[4] != "" else ""
  1396. XJ = "√" if flightstsdata[5] != "" else ""
  1397. ESDW = "√" if flightstsdata[7] != "" else ""
  1398. SJDW = "√" if flightstsdata[6] != "" else ""
  1399. if flightinfodata[11] == "航后":
  1400. postion = str(flightinfodata[6]) + "-天府"
  1401. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  1402. postion = str(flightinfodata[6]) + "-天府-" + str(flightinfodata[7])
  1403. else:
  1404. postion = "天府-" + str(flightinfodata[7])
  1405. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  1406. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  1407. a = flightinfodata[15][-8:-3]
  1408. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1409. a = flightinfodata[12][-8:-3]
  1410. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1411. a = ""
  1412. elif flightinfodata[16] != "":
  1413. a = ""
  1414. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  1415. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  1416. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  1417. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  1418. # waringMessageIDs = waringMessageID(fdb)
  1419. if str(row[1]) in str(waringMessageIDs["全部警告"]):
  1420. color_code = QColorList[6]
  1421. color_code1 = QColorList[1]
  1422. color_code2 = QColorList[1]
  1423. color_code3 = QColorList[1]
  1424. elif row[5] == "4":
  1425. color_code = QColorList[5]
  1426. color_code1 = QColorList[1]
  1427. color_code2 = QColorList[1]
  1428. color_code3 = QColorList[1]
  1429. elif row[5] == "3":
  1430. color_code = QColorList[3]
  1431. color_code1 = QColorList[0]
  1432. color_code2 = QColorList[0]
  1433. color_code3 = QColorList[0]
  1434. elif row[5] == "2":
  1435. color_code = QColorList[2]
  1436. color_code1 = QColorList[0]
  1437. color_code2 = QColorList[0]
  1438. color_code3 = QColorList[0]
  1439. elif row[5] == "1":
  1440. if (rowNum + 2) % 2 == 0:
  1441. color_code = QColorList[4]
  1442. else:
  1443. color_code = QColorList[1]
  1444. color_code1 = QColorList[0]
  1445. color_code2 = QColorList[6]
  1446. color_code3 = QColorList[7]
  1447. findid = row[0] + "-B"
  1448. #peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
  1449. peopleSchedule = TuplefindInList(peopleScheduleAll, findid)
  1450. if peopleSchedule != None:
  1451. fx = peopleSchedule[3]
  1452. qw1 = peopleSchedule[4]
  1453. qw2 = peopleSchedule[5]
  1454. g1 = peopleSchedule[6]
  1455. g2 = peopleSchedule[7]
  1456. g3 = peopleSchedule[8]
  1457. fj = peopleSchedule[9]
  1458. else:
  1459. fx = ""
  1460. qw1 = ""
  1461. qw2 = ""
  1462. g1 = ""
  1463. g2 = ""
  1464. g3 = ""
  1465. fj = ""
  1466. if flightinfodata[11] == "航后":
  1467. item_dic = {"0": rowNum,
  1468. "1": flightinfodata[2],
  1469. "2": flightinfodata[4],
  1470. "3": flightinfodata[3],
  1471. "4": flightinfodata[8],
  1472. "5": a,
  1473. "6": b,
  1474. "7": "--",
  1475. "8": JWA,
  1476. "9": flightinfodata[11],
  1477. "10": fx,
  1478. "11": qw1,
  1479. "12": qw2,
  1480. "13": g1,
  1481. "14": g2,
  1482. "15": g3,
  1483. "16": jjdw,
  1484. "17": "--",
  1485. "18": "--",
  1486. "19": "--",
  1487. "20": d,
  1488. "21": "--",
  1489. "22": e,
  1490. "23": F,
  1491. "24": postion,
  1492. "25": wx_people, # flightinfodata[22],
  1493. "26": "",
  1494. "27": fx_people, # flightinfodata[23],
  1495. "28": row[1],
  1496. "29": g,
  1497. "30": ta_td,
  1498. "31": type31,
  1499. "32": fj,
  1500. "99": color_code,
  1501. "101": color_code1,
  1502. "102": color_code2,
  1503. "103": color_code3,
  1504. "109": row[5]
  1505. }
  1506. # tableWidgetDispalydata[rowNum] = item_dic
  1507. # rowNum += 1
  1508. return {rowNum: item_dic}
  1509. elif flightinfodata[11] == "停场":
  1510. item_dic = {"0": rowNum,
  1511. "1": flightinfodata[2],
  1512. "2": flightinfodata[4],
  1513. "3": flightinfodata[3],
  1514. "4": "--",
  1515. "5": a,
  1516. "6": "--",
  1517. "7": "--",
  1518. "8": JWA,
  1519. "9": flightinfodata[11],
  1520. "10": fx,
  1521. "11": qw1,
  1522. "12": qw2,
  1523. "13": g1,
  1524. "14": g2,
  1525. "15": g3,
  1526. "16": "--",
  1527. "17": "--",
  1528. "18": "--",
  1529. "19": "--",
  1530. "20": "--",
  1531. "21": "--",
  1532. "22": "--",
  1533. "23": "--",
  1534. "24": "--", # flightinfodata[22],
  1535. "25": "--", # flightinfodata[23],
  1536. "26": "--",
  1537. "27": "--",
  1538. "28": row[1],
  1539. "29": "TSK",
  1540. "30": "--",
  1541. "31": "--",
  1542. "32": fj,
  1543. "99": color_code,
  1544. "101": color_code1,
  1545. "102": color_code2,
  1546. "103": color_code3,
  1547. "109": row[5]
  1548. }
  1549. # tableWidgetDispalydata[rowNum] = item_dic
  1550. # rowNum += 1
  1551. return {rowNum: item_dic}
  1552. elif flightinfodata[11] == "航前":
  1553. item_dic = {"0": rowNum,
  1554. "1": flightinfodata[2],
  1555. "2": flightinfodata[4],
  1556. "3": flightinfodata[3],
  1557. "4": flightinfodata[8],
  1558. "5": "",
  1559. "6": "",
  1560. "7": c,
  1561. "8": JWB,
  1562. "9": flightinfodata[11],
  1563. "10": fx,
  1564. "11": qw1,
  1565. "12": qw2,
  1566. "13": g1,
  1567. "14": g2,
  1568. "15": g3,
  1569. "16": jjdw,
  1570. "18": FX,
  1571. "19": XJ,
  1572. "17": "--",
  1573. "20": d,
  1574. "21": SJDW,
  1575. "22": e,
  1576. "23": F,
  1577. "24": postion,
  1578. "25": wx_people, # flightinfodata[22],
  1579. "26": "",
  1580. "27": fx_people, # flightinfodata[23],
  1581. "28": row[1],
  1582. "29": g,
  1583. "30": ta_td,
  1584. "31": type31,
  1585. "32": fj,
  1586. "99": color_code,
  1587. "101": color_code1,
  1588. "102": color_code2,
  1589. "103": color_code3,
  1590. "109": row[5]
  1591. }
  1592. # tableWidgetDispalydata[rowNum] = item_dic
  1593. # rowNum += 1
  1594. return {rowNum: item_dic}
  1595. elif row[3] == "短停接":
  1596. item_dic = {"0": rowNum,
  1597. "1": flightinfodata[2],
  1598. "2": flightinfodata[4],
  1599. "3": flightinfodata[3],
  1600. "4": flightinfodata[8],
  1601. "5": a,
  1602. "6": b,
  1603. "7": c,
  1604. "8": JWA,
  1605. "9": flightinfodata[11],
  1606. "10": fx,
  1607. "11": qw1,
  1608. "12": qw2,
  1609. "13": g1,
  1610. "14": g2,
  1611. "15": g3,
  1612. "16": jjdw,
  1613. "18": FX,
  1614. "19": "--",
  1615. "17": ESDW,
  1616. "20": d,
  1617. "21": SJDW,
  1618. "22": e,
  1619. "23": F,
  1620. "24": postion,
  1621. "25": wx_people, # flightinfodata[22],
  1622. "26": ecsj_people,
  1623. "27": fx_people, # flightinfodata[23],
  1624. "28": row[1],
  1625. "29": g,
  1626. "30": ta_td,
  1627. "31": type31,
  1628. "32": fj,
  1629. "99": color_code,
  1630. "101": color_code1,
  1631. "102": color_code2,
  1632. "103": color_code3,
  1633. "109": row[5]
  1634. }
  1635. # tableWidgetDispalydata[rowNum] = item_dic
  1636. # rowNum += 1
  1637. return {rowNum: item_dic}
  1638. elif row[3] == "特后前接":
  1639. item_dic = {"0": rowNum,
  1640. "1": flightinfodata[2],
  1641. "2": flightinfodata[4],
  1642. "3": flightinfodata[3],
  1643. "4": flightinfodata[8],
  1644. "5": a,
  1645. "6": b,
  1646. "7": c,
  1647. "8": JWA,
  1648. "9": flightinfodata[11],
  1649. "10": fx,
  1650. "11": qw1,
  1651. "12": qw2,
  1652. "13": g1,
  1653. "14": g2,
  1654. "15": g3,
  1655. "16": jjdw,
  1656. "18": FX,
  1657. "19": "--",
  1658. "17": "--",
  1659. "20": d,
  1660. "21": SJDW,
  1661. "22": e,
  1662. "23": F,
  1663. "24": postion,
  1664. "25": wx_people, # flightinfodata[22],
  1665. "26": "",
  1666. "27": fx_people, # flightinfodata[23],
  1667. "28": row[1],
  1668. "29": g,
  1669. "30": ta_td,
  1670. "31": type31,
  1671. "32": fj,
  1672. "99": color_code,
  1673. "101": color_code1,
  1674. "102": color_code2,
  1675. "103": color_code3,
  1676. "109": row[5]
  1677. }
  1678. #tableWidgetDispalydata[rowNum] = item_dic
  1679. #rowNum += 1
  1680. return {rowNum:item_dic}
  1681. def tableWidgetDispaly2(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  1682. try:
  1683. tableWidgetDispalydata = {}
  1684. sorttable = getSortFlightdata(fdb,selectedtime,"sortFlight2")
  1685. nowDayStr = selectedtime
  1686. TaskFlightinfoAll = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
  1687. flightinfodataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
  1688. flightstsdataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
  1689. waringMessageIDs = waringMessageID(fdb)
  1690. peopleScheduleAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
  1691. '''
  1692. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  1693. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  1694. "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "进出港城市", "25": "维修人员",
  1695. "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
  1696. '''
  1697. rowNum = 0
  1698. # functionDisplay2(sorttable[1], 1, TaskFlightinfoAll,
  1699. # flightinfodataAll, flightstsdataAll, waringMessageIDs,
  1700. # peopleScheduleAll)
  1701. executor = concurrent.futures.ThreadPoolExecutor()
  1702. all_task = []
  1703. for i in range(len(sorttable)):
  1704. all_task.append(executor.submit(functionDisplay2, sorttable[i], i, TaskFlightinfoAll,
  1705. flightinfodataAll, flightstsdataAll, waringMessageIDs,
  1706. peopleScheduleAll))
  1707. for future in concurrent.futures.as_completed(all_task):
  1708. data = future.result()
  1709. tableWidgetDispalydata.update(data)
  1710. newdic = {"B": '"{}"'.format(tableWidgetDispalydata)}
  1711. if date == "1":
  1712. fdb.upDateItem("display", newdic, "ID = '1'")
  1713. elif date == "2":
  1714. fdb.upDateItem("display", newdic, "ID = '2'")
  1715. elif date == "3":
  1716. fdb.upDateItem("display", newdic, "ID = '3'")
  1717. return tableWidgetDispalydata
  1718. except Exception:
  1719. #dingding_alert(traceback.format_exc())
  1720. print(traceback.format_exc())
  1721. def tableWidgetDispalyOld(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  1722. try:
  1723. #print("tableWidgetDispaly")
  1724. #print(selectedtime)
  1725. #ts=datetime.datetime.now()
  1726. tableWidgetDispalydata = {}
  1727. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
  1728. nowDayStr = selectedtime
  1729. rowNum = 0
  1730. for row in sorttable:
  1731. # print(row)
  1732. TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  1733. e = ""
  1734. F = ""
  1735. g = ""
  1736. if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][16] != "":
  1737. e = "保留"
  1738. if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][18] != "":
  1739. takinfo = fdb.queryTabel('workjob','*',"任务编号= '%s'"%TaskFlightinfo[0][21])
  1740. F = "工作包无法正常获取请通过AMRO人工查询"
  1741. if len(takinfo) != 0 and takinfo[0][4] !="":
  1742. F=takinfo[0][4]+"\n<+++++++++++++++++++++++++++++++++++++++++>\n"+takinfo[0][6]+"\n<+++++++++++++++++++++++++++++++++++++++++>\n"+takinfo[0][7]
  1743. elif len(takinfo) != 0:
  1744. F="工作包暂未获取请点击右键工作包查询后即可随意查看"
  1745. if len(TaskFlightinfo) != 0 and TaskFlightinfo[0][21] != "":
  1746. g = TaskFlightinfo[0][21]
  1747. wx_people = ""
  1748. fx_people = ""
  1749. ecsj_people = ""
  1750. ta_td = ""
  1751. type31 = ""
  1752. if len(TaskFlightinfo) != 0:
  1753. wx_people = TaskFlightinfo[0][12]
  1754. fx_people = TaskFlightinfo[0][13]
  1755. ecsj_people = TaskFlightinfo[0][19]
  1756. ta_td = TaskFlightinfo[0][9]
  1757. type31 = TaskFlightinfo[0][3]
  1758. #print(row[1])
  1759. #print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
  1760. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  1761. flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  1762. len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  1763. "", "","", "","", "","", "","", "","", ""]
  1764. jjdw="√" if flightstsdata[3] !="" else ""
  1765. FX = "√" if flightstsdata[4] != "" else ""
  1766. XJ = "√" if flightstsdata[5] != "" else ""
  1767. ESDW = "√" if flightstsdata[7] != "" else ""
  1768. SJDW = "√" if flightstsdata[6] != "" else ""
  1769. if flightinfodata[11] == "航后":
  1770. postion=str(flightinfodata[6])+"-天府"
  1771. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  1772. postion = str(flightinfodata[6]) + "-天府-"+str(flightinfodata[7])
  1773. else:
  1774. postion = "天府-" + str(flightinfodata[7])
  1775. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  1776. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  1777. a = flightinfodata[15][-8:-3]
  1778. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1779. a = flightinfodata[12][-8:-3]
  1780. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  1781. a = ""
  1782. elif flightinfodata[16] != "":
  1783. a = ""
  1784. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  1785. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  1786. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  1787. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  1788. waringMessageIDs=waringMessageID(fdb)
  1789. if str(row[1]) in str(waringMessageIDs["通用警告"]):
  1790. color_code = QColorList[6]
  1791. color_code1 = QColorList[1]
  1792. color_code2 = QColorList[1]
  1793. color_code3 = QColorList[1]
  1794. 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"])):
  1795. color_code = QColorList[6]
  1796. color_code1 = QColorList[1]
  1797. color_code2 = QColorList[1]
  1798. color_code3 = QColorList[1]
  1799. elif row[3]=="短停送" and (str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
  1800. color_code = QColorList[6]
  1801. color_code1 = QColorList[1]
  1802. color_code2 = QColorList[1]
  1803. color_code3 = QColorList[1]
  1804. elif row[5] == "4":
  1805. color_code = QColorList[5]
  1806. color_code1 = QColorList[1]
  1807. color_code2 = QColorList[1]
  1808. color_code3 = QColorList[1]
  1809. elif row[5] == "3":
  1810. color_code = QColorList[3]
  1811. color_code1 = QColorList[0]
  1812. color_code2 = QColorList[0]
  1813. color_code3 = QColorList[0]
  1814. elif row[5] == "2":
  1815. color_code = QColorList[2]
  1816. color_code1 = QColorList[0]
  1817. color_code2 = QColorList[0]
  1818. color_code3 = QColorList[0]
  1819. elif row[5] == "1":
  1820. if (rowNum + 2) % 2 == 0:
  1821. color_code = QColorList[4]
  1822. else:
  1823. color_code = QColorList[1]
  1824. color_code1 = QColorList[0]
  1825. color_code2 = QColorList[6]
  1826. color_code3 = QColorList[7]
  1827. findid=row[0]+"-A"
  1828. peopleSchedule=fdb.queryTabel("peopleSchedule{}".format(nowDayStr),"*","编号='%s'"%findid)
  1829. #print(peopleSchedule)
  1830. if len(peopleSchedule) != 0:
  1831. fx=peopleSchedule[0][3]
  1832. qw1 = peopleSchedule[0][4]
  1833. qw2 = peopleSchedule[0][5]
  1834. g1 = peopleSchedule[0][6]
  1835. g2 = peopleSchedule[0][7]
  1836. g3 = peopleSchedule[0][8]
  1837. if flightinfodata[28] !="" and flightinfodata[28][0] =="R" and "返航航班" not in str(peopleSchedule[0][9]):
  1838. fj = "返航航班;"+str(peopleSchedule[0][9])
  1839. elif flightinfodata[28] !="" and flightinfodata[28][0] == "V" and "备降航班" not in str(peopleSchedule[0][9]):
  1840. fj = "备降航班;" + str(peopleSchedule[0][9])
  1841. else:
  1842. fj = str(peopleSchedule[0][9])
  1843. else:
  1844. fx = ""
  1845. qw1 = ""
  1846. qw2 = ""
  1847. g1 = ""
  1848. g2 = ""
  1849. g3 = ""
  1850. if flightinfodata[28] != "" and flightinfodata[28][0] == "R":
  1851. fj = "返航航班;"
  1852. elif flightinfodata[28] != "" and flightinfodata[28][0] == "V":
  1853. fj = "备降航班;"
  1854. else:
  1855. fj = ""
  1856. if flightinfodata[11] == "航后":
  1857. item_dic = {"0": rowNum,
  1858. "1": flightinfodata[2],
  1859. "2": flightinfodata[4],
  1860. "3": flightinfodata[3],
  1861. "4": flightinfodata[8],
  1862. "5": a,
  1863. "6": b,
  1864. "7": "--",
  1865. "8": flightinfodata[19],
  1866. "9": row[3],
  1867. "10": fx,
  1868. "11": qw1,
  1869. "12": qw2,
  1870. "13": g1,
  1871. "14": g2,
  1872. "15": g3,
  1873. "16":jjdw,
  1874. "17": "--",
  1875. "18": "--",
  1876. "19": d,
  1877. "20": "--",
  1878. "21": e,
  1879. "22": F,
  1880. "23": postion,
  1881. "24": wx_people, # flightinfodata[22],
  1882. "25": fx_people, # flightinfodata[23],
  1883. "26": row[1],
  1884. "27": g,
  1885. "28": ta_td,
  1886. "29": type31,
  1887. "30":fj,
  1888. "99":color_code,
  1889. "101": color_code1,
  1890. "102": color_code2,
  1891. "103": color_code3,
  1892. "109":row[5]
  1893. }
  1894. elif flightinfodata[11] == "停场":
  1895. item_dic = {"0": rowNum,
  1896. "1": flightinfodata[2],
  1897. "2": flightinfodata[4],
  1898. "3": flightinfodata[3],
  1899. "4": "--",
  1900. "5": a,
  1901. "6": "--",
  1902. "7": "--",
  1903. "8": flightinfodata[19],
  1904. "9": row[3],
  1905. "10": fx,
  1906. "11": qw1,
  1907. "12": qw2,
  1908. "13": g1,
  1909. "14": g2,
  1910. "15": g3,
  1911. "16":"--",
  1912. "17": "--",
  1913. "18": "--",
  1914. "19": "--",
  1915. "20": "--",
  1916. "21": "--",
  1917. "22": "--",
  1918. "23": "--",
  1919. "24": "--", # flightinfodata[22],
  1920. "25": "--", # flightinfodata[23],
  1921. "26": row[1],
  1922. "27": "TSK",
  1923. "28": "--",
  1924. "29": "--",
  1925. "30":fj,
  1926. "99":color_code,
  1927. "101": color_code1,
  1928. "102": color_code2,
  1929. "103": color_code3,
  1930. "109":row[5]
  1931. }
  1932. elif flightinfodata[11] == "航前":
  1933. item_dic = {"0": rowNum,
  1934. "1": flightinfodata[2],
  1935. "2": flightinfodata[4],
  1936. "3": flightinfodata[3],
  1937. "4": flightinfodata[8],
  1938. "5": "",
  1939. "6": "",
  1940. "7": c,
  1941. "8": flightinfodata[21],
  1942. "9": row[3],
  1943. "10": fx,
  1944. "11": qw1,
  1945. "12": qw2,
  1946. "13": g1,
  1947. "14": g2,
  1948. "15": g3,
  1949. "16":jjdw,
  1950. "17": FX,
  1951. "18": XJ,
  1952. "19": d,
  1953. "20": SJDW,
  1954. "21": e,
  1955. "22": F,
  1956. "23": postion,
  1957. "24": wx_people, # flightinfodata[22],
  1958. "25": fx_people, # flightinfodata[23],
  1959. "26": row[1],
  1960. "27": g,
  1961. "28": ta_td,
  1962. "29": type31,
  1963. "30":fj,
  1964. "99":color_code,
  1965. "101": color_code1,
  1966. "102": color_code2,
  1967. "103": color_code3,
  1968. "109":row[5]
  1969. }
  1970. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前" ) and (row[3] == "短停接" or row[3] == "特后前接"):
  1971. item_dic = {"0": rowNum,
  1972. "1": flightinfodata[2],
  1973. "2": flightinfodata[4],
  1974. "3": flightinfodata[3],
  1975. "4": flightinfodata[8],
  1976. "5": a,
  1977. "6": b,
  1978. "7": c,
  1979. "8": flightinfodata[19],
  1980. "9": row[3],
  1981. "10": fx,
  1982. "11": qw1,
  1983. "12": qw2,
  1984. "13": g1,
  1985. "14": g2,
  1986. "15": g3,
  1987. "16":jjdw,
  1988. "17": FX,
  1989. "18": "--",
  1990. "19": d,
  1991. "20": SJDW,
  1992. "21": e,
  1993. "22": F,
  1994. "23": postion,
  1995. "24": wx_people, # flightinfodata[22],
  1996. "25": fx_people, # flightinfodata[23],
  1997. "26": row[1],
  1998. "27": g,
  1999. "28": ta_td,
  2000. "29": type31,
  2001. "30":fj,
  2002. "99":color_code,
  2003. "101": color_code1,
  2004. "102": color_code2,
  2005. "103": color_code3,
  2006. "109":row[5]
  2007. }
  2008. elif (flightinfodata[11] == "短停" or flightinfodata[11] == "特后前" ) and (row[3] == "短停送" or row[3] == "特后前送"):
  2009. item_dic = {"0": rowNum,
  2010. "1": flightinfodata[2],
  2011. "2": flightinfodata[4],
  2012. "3": flightinfodata[3],
  2013. "4": flightinfodata[8],
  2014. "5": a,
  2015. "6": b,
  2016. "7": c,
  2017. "8": flightinfodata[19],
  2018. "9": row[3],
  2019. "10": fx,
  2020. "11": qw1,
  2021. "12": qw2,
  2022. "13": g1,
  2023. "14": g2,
  2024. "15": g3,
  2025. "16": ESDW,
  2026. "17": FX,
  2027. "18": "--",
  2028. "19": d,
  2029. "20": SJDW,
  2030. "21": e,
  2031. "22": F,
  2032. "23": postion,
  2033. "24": ecsj_people, # flightinfodata[22],
  2034. "25": fx_people, # flightinfodata[23],
  2035. "26": row[1],
  2036. "27": g,
  2037. "28": ta_td,
  2038. "29": type31,
  2039. "30":fj,
  2040. "99":color_code,
  2041. "101": color_code1,
  2042. "102": color_code2,
  2043. "103": color_code3,
  2044. "109":row[5]
  2045. }
  2046. else:
  2047. item_dic = {"0": rowNum,
  2048. "1": flightinfodata[2],
  2049. "2": flightinfodata[4],
  2050. "3": flightinfodata[3],
  2051. "4": flightinfodata[8],
  2052. "5": a,
  2053. "6": b,
  2054. "7": c,
  2055. "8": flightinfodata[19],
  2056. "9": row[3],
  2057. "10": fx,
  2058. "11": qw1,
  2059. "12": qw2,
  2060. "13": g1,
  2061. "14": g2,
  2062. "15": g3,
  2063. "16":jjdw,
  2064. "17": FX,
  2065. "18": "--",
  2066. "19": d,
  2067. "20": SJDW,
  2068. "21": e,
  2069. "22": F,
  2070. "23": postion,
  2071. "24": wx_people, # flightinfodata[22],
  2072. "25": fx_people, # flightinfodata[23],
  2073. "26": row[1],
  2074. "27": g,
  2075. "28": ta_td,
  2076. "29": type31,
  2077. "30":fj,
  2078. "99":color_code,
  2079. "101": color_code1,
  2080. "102": color_code2,
  2081. "103": color_code3,
  2082. "109":row[5]
  2083. }
  2084. tableWidgetDispalydata[rowNum]=item_dic
  2085. rowNum += 1
  2086. #print(tableWidgetDispalydata)
  2087. #print("耗时%s"%(datetime.datetime.now()-ts)) ###需要传参一个昨天今天明天地结果123
  2088. newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
  2089. if date =="1":
  2090. fdb.upDateItem("display", newdic, "ID = '1'")
  2091. elif date =="2":
  2092. fdb.upDateItem("display", newdic, "ID = '2'")
  2093. elif date =="3":
  2094. fdb.upDateItem("display", newdic, "ID = '3'")
  2095. return tableWidgetDispalydata
  2096. except Exception:
  2097. dingding_alert(traceback.format_exc())
  2098. def tableWidgetDispaly2Old(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  2099. try:
  2100. tableWidgetDispalydata = {}
  2101. sorttable = getSortFlightdata(fdb,selectedtime,"sortFlight2")
  2102. nowDayStr = selectedtime
  2103. '''
  2104. col_dic = {"0": "序号", "1": "机号", "2": "机型", "3": "发动机", "4": "航班号", "5": "计达", "6": "预达", "7": "计飞", "8": "机位",
  2105. "9": "类型", "10": "放行", "11": "勤务1", "12": "勤务2", "13": "工1", "14": "工2", "15": "工3", "16": "到位",
  2106. "18": "放行","19": "销夹", "17": "二送", "20": "随机", "21": "随机到位", "22": "保留", "23": "工作包", "24": "进出港城市", "25": "维修人员",
  2107. "26": "二送人员", "27": "放行", "28": "航班编号", "29": "任务编号", "30": "TATD", "31": "类型","32":"附加消息"}
  2108. '''
  2109. rowNum = 0
  2110. for row in sorttable:
  2111. # print(row)
  2112. TaskFlightinfo = fdb.queryTabel('TaskFlightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))
  2113. e = ""
  2114. F = ""
  2115. g = ""
  2116. if len(TaskFlightinfo) != 0:
  2117. if TaskFlightinfo[0][16] != "":
  2118. e = "保留"
  2119. if TaskFlightinfo[0][18] != "":
  2120. F = "工作包"
  2121. if TaskFlightinfo[0][21] != "":
  2122. g = TaskFlightinfo[0][21]
  2123. wx_people = ""
  2124. fx_people = ""
  2125. ecsj_people = ""
  2126. ta_td = ""
  2127. type31 = ""
  2128. # print(TaskFlightinfo)
  2129. if len(TaskFlightinfo) != 0:
  2130. wx_people = TaskFlightinfo[0][12]
  2131. fx_people = TaskFlightinfo[0][13]
  2132. ecsj_people = TaskFlightinfo[0][19]
  2133. ta_td = TaskFlightinfo[0][9]
  2134. type31 = TaskFlightinfo[0][3]
  2135. flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  2136. flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  2137. len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  2138. "", "","", "","", "","", "","", "","", ""]
  2139. jjdw = "√" if flightstsdata[3] != "" else ""
  2140. FX = "√" if flightstsdata[4] != "" else ""
  2141. XJ = "√" if flightstsdata[5] != "" else ""
  2142. ESDW = "√" if flightstsdata[7] != "" else ""
  2143. SJDW = "√" if flightstsdata[6] != "" else ""
  2144. if flightinfodata[11] == "航后":
  2145. postion=str(flightinfodata[6])+"-天府"
  2146. elif flightinfodata[11] == "短停" or flightinfodata[11] == "特后前":
  2147. postion = str(flightinfodata[6]) + "-天府-"+str(flightinfodata[7])
  2148. else:
  2149. postion = "天府-" + str(flightinfodata[7])
  2150. a = flightinfodata[12][-8:-3] if flightinfodata[12] != "" else ""
  2151. if flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] != "":
  2152. a = flightinfodata[15][-8:-3]
  2153. elif flightinfodata[12] != "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  2154. a = flightinfodata[12][-8:-3]
  2155. elif flightinfodata[12] == "" and flightinfodata[16] == "" and flightinfodata[15] == "":
  2156. a = ""
  2157. elif flightinfodata[16] != "":
  2158. a = ""
  2159. b = flightinfodata[15][-8:-3] if flightinfodata[15] != "" else ""
  2160. c = flightinfodata[17][0:3] + flightinfodata[17][-6:] if flightinfodata[17] != "" else ""
  2161. d = flightinfodata[26].split(">")[1] if ">" in str(flightinfodata[26]) else ""
  2162. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  2163. waringMessageIDs = waringMessageID(fdb)
  2164. if str(row[1]) in str(waringMessageIDs["全部警告"]):
  2165. color_code = QColorList[6]
  2166. color_code1 = QColorList[1]
  2167. color_code2 = QColorList[1]
  2168. color_code3 = QColorList[1]
  2169. elif row[5] == "4":
  2170. color_code = QColorList[5]
  2171. color_code1 = QColorList[1]
  2172. color_code2 = QColorList[1]
  2173. color_code3 = QColorList[1]
  2174. elif row[5] == "3":
  2175. color_code = QColorList[3]
  2176. color_code1 = QColorList[0]
  2177. color_code2 = QColorList[0]
  2178. color_code3 = QColorList[0]
  2179. elif row[5] == "2":
  2180. color_code = QColorList[2]
  2181. color_code1 = QColorList[0]
  2182. color_code2 = QColorList[0]
  2183. color_code3 = QColorList[0]
  2184. elif row[5] == "1":
  2185. if (rowNum + 2) % 2 == 0:
  2186. color_code = QColorList[4]
  2187. else:
  2188. color_code = QColorList[1]
  2189. color_code1 = QColorList[0]
  2190. color_code2 = QColorList[6]
  2191. color_code3 = QColorList[7]
  2192. findid = row[0] + "-B"
  2193. peopleSchedule = fdb.queryTabel("peopleSchedule{}".format(nowDayStr), "*", "编号='%s'" % findid)
  2194. if len(peopleSchedule) != 0:
  2195. fx = peopleSchedule[0][3]
  2196. qw1 = peopleSchedule[0][4]
  2197. qw2 = peopleSchedule[0][5]
  2198. g1 = peopleSchedule[0][6]
  2199. g2 = peopleSchedule[0][7]
  2200. g3 = peopleSchedule[0][8]
  2201. fj = peopleSchedule[0][9]
  2202. else:
  2203. fx = ""
  2204. qw1 = ""
  2205. qw2 = ""
  2206. g1 = ""
  2207. g2 = ""
  2208. g3 = ""
  2209. fj = ""
  2210. if flightinfodata[11] == "航后":
  2211. item_dic = {"0": rowNum,
  2212. "1": flightinfodata[2],
  2213. "2": flightinfodata[4],
  2214. "3": flightinfodata[3],
  2215. "4": flightinfodata[8],
  2216. "5": a,
  2217. "6": b,
  2218. "7": "--",
  2219. "8": flightinfodata[19],
  2220. "9": flightinfodata[11],
  2221. "10": fx,
  2222. "11": qw1,
  2223. "12": qw2,
  2224. "13": g1,
  2225. "14": g2,
  2226. "15": g3,
  2227. "16":jjdw,
  2228. "17": "--",
  2229. "18": "--",
  2230. "19": "--",
  2231. "20": d,
  2232. "21": "--",
  2233. "22": e,
  2234. "23": F,
  2235. "24": postion,
  2236. "25": wx_people, # flightinfodata[22],
  2237. "26": "",
  2238. "27": fx_people, # flightinfodata[23],
  2239. "28": row[1],
  2240. "29": g,
  2241. "30": ta_td,
  2242. "31": type31,
  2243. "32": fj,
  2244. "99":color_code,
  2245. "101": color_code1,
  2246. "102": color_code2,
  2247. "103": color_code3,
  2248. "109":row[5]
  2249. }
  2250. tableWidgetDispalydata[rowNum] = item_dic
  2251. rowNum += 1
  2252. elif flightinfodata[11] == "停场":
  2253. item_dic = {"0": rowNum,
  2254. "1": flightinfodata[2],
  2255. "2": flightinfodata[4],
  2256. "3": flightinfodata[3],
  2257. "4": "--",
  2258. "5": a,
  2259. "6": "--",
  2260. "7": "--",
  2261. "8": flightinfodata[19],
  2262. "9": flightinfodata[11],
  2263. "10": fx,
  2264. "11": qw1,
  2265. "12": qw2,
  2266. "13": g1,
  2267. "14": g2,
  2268. "15": g3,
  2269. "16":"--",
  2270. "17": "--",
  2271. "18": "--",
  2272. "19": "--",
  2273. "20": "--",
  2274. "21": "--",
  2275. "22": "--",
  2276. "23": "--",
  2277. "24": "--", # flightinfodata[22],
  2278. "25": "--", # flightinfodata[23],
  2279. "26": "--",
  2280. "27": "--",
  2281. "28": row[1],
  2282. "29": "TSK",
  2283. "30":"--",
  2284. "31": "--",
  2285. "32": fj,
  2286. "99":color_code,
  2287. "101": color_code1,
  2288. "102": color_code2,
  2289. "103": color_code3,
  2290. "109":row[5]
  2291. }
  2292. tableWidgetDispalydata[rowNum] = item_dic
  2293. rowNum += 1
  2294. elif flightinfodata[11] == "航前":
  2295. item_dic = {"0": rowNum,
  2296. "1": flightinfodata[2],
  2297. "2": flightinfodata[4],
  2298. "3": flightinfodata[3],
  2299. "4": flightinfodata[8],
  2300. "5": "",
  2301. "6": "",
  2302. "7": c,
  2303. "8": flightinfodata[21],
  2304. "9": flightinfodata[11],
  2305. "10": fx,
  2306. "11": qw1,
  2307. "12": qw2,
  2308. "13": g1,
  2309. "14": g2,
  2310. "15": g3,
  2311. "16":jjdw,
  2312. "18": FX,
  2313. "19": XJ,
  2314. "17": "--",
  2315. "20": d,
  2316. "21": SJDW,
  2317. "22": e,
  2318. "23": F,
  2319. "24": postion,
  2320. "25": wx_people, # flightinfodata[22],
  2321. "26": "",
  2322. "27": fx_people, # flightinfodata[23],
  2323. "28": row[1],
  2324. "29": g,
  2325. "30": ta_td,
  2326. "31": type31,
  2327. "32": fj,
  2328. "99":color_code,
  2329. "101": color_code1,
  2330. "102": color_code2,
  2331. "103": color_code3,
  2332. "109":row[5]
  2333. }
  2334. tableWidgetDispalydata[rowNum] = item_dic
  2335. rowNum += 1
  2336. elif row[3] == "短停接":
  2337. item_dic = {"0": rowNum,
  2338. "1": flightinfodata[2],
  2339. "2": flightinfodata[4],
  2340. "3": flightinfodata[3],
  2341. "4": flightinfodata[8],
  2342. "5": a,
  2343. "6": b,
  2344. "7": c,
  2345. "8": flightinfodata[19],
  2346. "9": flightinfodata[11],
  2347. "10": fx,
  2348. "11": qw1,
  2349. "12": qw2,
  2350. "13": g1,
  2351. "14": g2,
  2352. "15": g3,
  2353. "16":jjdw,
  2354. "18": FX,
  2355. "19": "--",
  2356. "17": ESDW,
  2357. "20": d,
  2358. "21": SJDW,
  2359. "22": e,
  2360. "23": F,
  2361. "24": postion,
  2362. "25": wx_people, # flightinfodata[22],
  2363. "26": ecsj_people,
  2364. "27": fx_people, # flightinfodata[23],
  2365. "28": row[1],
  2366. "29": g,
  2367. "30": ta_td,
  2368. "31": type31,
  2369. "32":fj,
  2370. "99":color_code,
  2371. "101": color_code1,
  2372. "102": color_code2,
  2373. "103": color_code3,
  2374. "109":row[5]
  2375. }
  2376. tableWidgetDispalydata[rowNum] = item_dic
  2377. rowNum += 1
  2378. elif row[3] == "特后前接":
  2379. item_dic = {"0": rowNum,
  2380. "1": flightinfodata[2],
  2381. "2": flightinfodata[4],
  2382. "3": flightinfodata[3],
  2383. "4": flightinfodata[8],
  2384. "5": a,
  2385. "6": b,
  2386. "7": c,
  2387. "8": flightinfodata[19],
  2388. "9": flightinfodata[11],
  2389. "10": fx,
  2390. "11": qw1,
  2391. "12": qw2,
  2392. "13": g1,
  2393. "14": g2,
  2394. "15": g3,
  2395. "16":jjdw,
  2396. "18": FX,
  2397. "19": "--",
  2398. "17": "--",
  2399. "20": d,
  2400. "21": SJDW,
  2401. "22": e,
  2402. "23": F,
  2403. "24": postion,
  2404. "25": wx_people, # flightinfodata[22],
  2405. "26": "",
  2406. "27": fx_people, # flightinfodata[23],
  2407. "28": row[1],
  2408. "29": g,
  2409. "30": ta_td,
  2410. "31": type31,
  2411. "32":fj,
  2412. "99":color_code,
  2413. "101": color_code1,
  2414. "102": color_code2,
  2415. "103": color_code3,
  2416. "109":row[5]
  2417. }
  2418. tableWidgetDispalydata[rowNum] = item_dic
  2419. rowNum += 1
  2420. newdic = {"B": '"{}"'.format(tableWidgetDispalydata)}
  2421. if date == "1":
  2422. fdb.upDateItem("display", newdic, "ID = '1'")
  2423. elif date == "2":
  2424. fdb.upDateItem("display", newdic, "ID = '2'")
  2425. elif date == "3":
  2426. fdb.upDateItem("display", newdic, "ID = '3'")
  2427. return tableWidgetDispalydata
  2428. except Exception:
  2429. dingding_alert(traceback.format_exc())
  2430. def tableWidgetDisplayChange(fdb:flightDB,selectedtime):
  2431. try:
  2432. log=fdb.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
  2433. tableWidgetDisplayChangedata={}
  2434. now = datetime.datetime.now()
  2435. rowNum=0
  2436. if len(log) != 0:
  2437. for i in log:
  2438. timedeadline=""
  2439. if i[8] =="人工待办" and i[4] !="" and i[7] =="":
  2440. timedeadline = datetime.datetime.strptime(i[4], "%Y-%m-%d %H:%M")
  2441. #print(timedeadline)
  2442. if timedeadline <= now:
  2443. tableWidgetDisplayChangedata[rowNum]=i
  2444. rowNum +=1
  2445. elif i[8] =="准备组任务" and i[4] !="" and i[7] =="":
  2446. timedeadline = datetime.datetime.strptime(i[4], "%Y-%m-%d %H:%M:%S")
  2447. #print(timedeadline)
  2448. if timedeadline <= now:
  2449. tableWidgetDisplayChangedata[rowNum]=i
  2450. rowNum +=1
  2451. elif i[8] !="人工待办" and i[8] !="人工待办":
  2452. tableWidgetDisplayChangedata[rowNum] = i
  2453. rowNum += 1
  2454. return tableWidgetDisplayChangedata
  2455. except Exception:
  2456. dingding_alert(traceback.format_exc())
  2457. def tableWidgetLOGDispaly(fdb:flightDB,selectedtime):
  2458. try:
  2459. selectdaystr = str(selectedtime)[0:4] + "-" + str(selectedtime)[4:6] + "-" + str(selectedtime)[6:] + " 00:00:00"
  2460. selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
  2461. yesterday = (selectday - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  2462. log_str = fdb.sort_queryTable("编号", 'logs', "提示信息 !='' and 变更字段 !='人工待办' and 产生时间 >'%s'" % yesterday,"产生时间", "desc")
  2463. log_len = 999 if len(log_str) > 1000 else len(log_str)
  2464. tableWidgetLOGDispalydata={}
  2465. for i in range(0,log_len):
  2466. a = fdb.queryTabel('logs', "*", "编号='%s'" % log_str[i][0])[0]
  2467. tableWidgetLOGDispalydata[i]=a[4]
  2468. return tableWidgetLOGDispalydata
  2469. except Exception:
  2470. dingding_alert(traceback.format_exc())
  2471. def deletelogs(fdb:flightDB):
  2472. try:
  2473. now=datetime.datetime.now()
  2474. passtime = (now - datetime.timedelta(days=30)).strftime("%Y-%m-%d %H:%M:%S")
  2475. log_str = fdb.queryTabel('logs',"编号","产生时间 <'%s'" %passtime)
  2476. if len(log_str) != 0:
  2477. for i in log_str:
  2478. fdb.deleteSingledata('logs',"编号='%s'" % i[0])
  2479. except Exception:
  2480. dingding_alert(traceback.format_exc())
  2481. def checkCalllist(fdb:flightDB,time):
  2482. try:
  2483. selectedtime_time = str(time) + " 00:00:00"
  2484. now = datetime.datetime.strptime(selectedtime_time, "%Y%m%d %H:%M:%S")
  2485. tom = (now + datetime.timedelta(days=2)).strftime("%Y-%m-%d %H:%M:%S")
  2486. yesterday = (now - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  2487. calllists=fdb.sort_queryTable2("*","Calllist","创建时间 <'%s' and 创建时间 >'%s'"%(tom,yesterday),"创建时间","desc","接通时间","desc")
  2488. num = 0
  2489. res = {}
  2490. if len(calllists) != 0:
  2491. for i in calllists:
  2492. calllist={}
  2493. calllist["序号"]=num
  2494. calllist["电话"] = i[1]
  2495. calllist["工号"] = i[2]
  2496. calllist["姓名"] = i[3]
  2497. calllist["航班号"] = i[4]
  2498. calllist["拨号次数"] = str(i[6])
  2499. calllist["创建时间"] = i[7]
  2500. calllist["接通时间"] = i[8]
  2501. res[num] = calllist
  2502. num += 1
  2503. return res
  2504. except Exception:
  2505. dingding_alert(traceback.format_exc())
  2506. def getphonelist(fdb:flightDB):
  2507. try:
  2508. phonelists=fdb.getAlldata("workerinfo")
  2509. num = 0
  2510. res={}
  2511. if len(phonelists) != 0:
  2512. for i in phonelists:
  2513. phonelist = {}
  2514. phonelist["序号"]=num
  2515. phonelist["姓名"] = i[1]
  2516. phonelist["部门"] = i[2]
  2517. phonelist["电话"] = i[5]
  2518. phonelist["name"] = i[11]
  2519. res[num]=phonelist
  2520. num+=1
  2521. return res
  2522. except Exception:
  2523. dingding_alert(traceback.format_exc())
  2524. def MM_GJJH_LIST(fdb:flightDB,team,data):
  2525. GJlist1 = {}
  2526. GJlist2 = {}
  2527. if data !=[]:
  2528. now=datetime.datetime.now()
  2529. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  2530. a_str = nowDay_str2 + " 17:00:00"
  2531. time1 = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  2532. if time1 < now :
  2533. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  2534. pglist = fdb.queryTabel("pglist%s"%nowDay,"姓名","班次 = 'A'")
  2535. else:
  2536. nowDay = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  2537. pglist = fdb.queryTabel("pglist%s" % nowDay, "姓名", "班次 = 'B'")
  2538. for row in data:
  2539. phone=fdb.queryTabel("workerinfo","电话","姓名='%s'"%str(row["zlynam"]))
  2540. if len(phone) != 0 and len(phone[0][0]) == 12:
  2541. phonenumber=phone[0][0][1:]
  2542. if str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) in GJlist1.keys():
  2543. maktx=GJlist1[row["zlynam"]]["工具名"]+","+row["maktx"]
  2544. zzbh = GJlist1[row["zlynam"]]["编号"] + "," + row["zzbh"]
  2545. zjcmeng = GJlist1[row["zlynam"]]["数量"] + "," + row["zjcmeng"]
  2546. a={"工具名":maktx,"编号":zzbh,"数量":zjcmeng,"phonenumber":phonenumber}
  2547. GJlist1[row["zlynam"]]=a
  2548. elif str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) not in GJlist1.keys():
  2549. maktx =row["maktx"]
  2550. zzbh = row["zzbh"]
  2551. zjcmeng = row["zjcmeng"]
  2552. a={"工具名":maktx,"编号":zzbh,"数量":zjcmeng,"phonenumber":phonenumber}
  2553. GJlist1[row["zlynam"]] = a
  2554. else:
  2555. if str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) in GJlist2.keys():
  2556. maktx = GJlist2[row["zlynam"]]["工具名"] + "," + row["maktx"]
  2557. zzbh = GJlist2[row["zlynam"]]["编号"] + "," + row["zzbh"]
  2558. zjcmeng = GJlist2[row["zlynam"]]["数量"] + "," + row["zjcmeng"]
  2559. a = {"工具名": maktx, "编号": zzbh, "数量": zjcmeng}
  2560. GJlist2[row["zlynam"]] = a
  2561. elif str(row["zlynam"]) in str(pglist) and str(row["zlynam"]) not in GJlist2.keys():
  2562. maktx = row["maktx"]
  2563. zzbh = row["zzbh"]
  2564. zjcmeng = row["zjcmeng"]
  2565. a = {"工具名": maktx, "编号": zzbh, "数量": zjcmeng}
  2566. GJlist2[row["zlynam"]] = a
  2567. if GJlist1:
  2568. msg = "经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
  2569. times=5
  2570. telphone=list()
  2571. for i in GJlist1:
  2572. msg =msg+"\n"+"【"+str(i)+"】" + "\n[工具名]:" + str(GJlist1[i]["工具名"]) + "\n[数量]:" + str(GJlist1[i]["数量"]) + "\n[编号]:" + str(GJlist1[i]["编号"])
  2573. telphone.append(str(GJlist1[i]["phonenumber"]))
  2574. #telphone.append("17729693827")
  2575. times+=1
  2576. if times % 5 == 0:
  2577. if team == "test":
  2578. dingding_alert1(telphone,msg)
  2579. elif str(team)=="1":
  2580. dingding_alert11(telphone, msg)
  2581. elif str(team)=="2":
  2582. dingding_alert1(telphone, msg)
  2583. elif str(team)=="3":
  2584. dingding_alert1(telphone, msg)
  2585. elif str(team)=="4":
  2586. dingding_alert1(telphone, msg)
  2587. msg = "经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
  2588. telphone = list()
  2589. if msg !="经查询您有以下工具未归还,请注意核实工具归还或交接情况:":
  2590. if team == "test":
  2591. dingding_alert1(telphone, msg)
  2592. elif str(team) == "1":
  2593. #print(telphone, msg)
  2594. #dingding_alert1(telphone, msg)
  2595. dingding_alert11(telphone, msg)
  2596. elif str(team) == "2":
  2597. dingding_alert1(telphone, msg)
  2598. elif str(team) == "3":
  2599. dingding_alert1(telphone, msg)
  2600. elif str(team) == "4":
  2601. dingding_alert1(telphone, msg)
  2602. if GJlist2:
  2603. msg="经查询您有以下工具未归还,请注意核实工具归还或交接情况:"
  2604. a=list()
  2605. for i in GJlist2:
  2606. msg =msg+"\n"+"【"+str(i)+"】" + "\n[工具名]:" + str(GJlist2[i]["工具名"]) + "\n[数量]:" + str(GJlist2[i]["数量"]) + "\n[编号]:" + str(GJlist2[i]["编号"])
  2607. if team == "test":
  2608. dingding_alert1(a, msg)
  2609. elif str(team) == "1":
  2610. #print("联系不上的", msg)
  2611. #dingding_alert1(a, msg)
  2612. dingding_alert11("", msg)
  2613. elif str(team) == "2":
  2614. dingding_alert1(a, msg)
  2615. elif str(team) == "3":
  2616. dingding_alert1(a, msg)
  2617. elif str(team) == "4":
  2618. dingding_alert1(a, msg)
  2619. return
  2620. def taskAtuoCheck(fdb:flightDB,time):
  2621. try:
  2622. now = datetime.datetime.now()
  2623. tomorrow=(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  2624. #print(tomorrow)
  2625. if time =="1":
  2626. print(datetime.datetime.now(),"[数据库操作]准备组任务首次登录检查验证")
  2627. log_str = fdb.queryTabel('logs',"编号","处理时间='' and 变更字段='准备组任务'")
  2628. if len(log_str) == 0:
  2629. getTaskAuto=fdb.getAlldata('taskAuto')
  2630. if len(getTaskAuto) != 0:
  2631. #print(getTaskAuto)
  2632. for i in getTaskAuto:
  2633. #print(i)
  2634. if i[1] !="None":
  2635. time1=str(datetime.date.today())+ " "+i[1]
  2636. time11 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  2637. time2 = str(datetime.date.today()+ datetime.timedelta(days=1)) + " " + i[1]
  2638. time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
  2639. newdic = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2640. "提示信息": "%s" % time11, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务", "显示对象": "",
  2641. "提示内容": i[3]}
  2642. fdb.lazyInsertData("logs", newdic)
  2643. newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2644. "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务", "显示对象": "",
  2645. "提示内容": i[3]}
  2646. fdb.lazyInsertData("logs", newdic2)
  2647. if time =="2":
  2648. print(datetime.datetime.now(),"[数据库操作]准备组任务登录持续验证")
  2649. log_str2 = fdb.queryTabel('logs', "编号", "提示信息 >'%s' and 处理时间='' and 变更字段='准备组任务'" % tomorrow)
  2650. if len(log_str2) == 0:
  2651. getTaskAuto = fdb.getAlldata('taskAuto')
  2652. if len(getTaskAuto) != 0:
  2653. #print(getTaskAuto)
  2654. for i in getTaskAuto:
  2655. #print(i)
  2656. if i[1] != "None":
  2657. time2 = str(datetime.date.today() + datetime.timedelta(days=1)) + " " + i[1]
  2658. time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
  2659. newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2660. "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
  2661. "显示对象": "",
  2662. "提示内容": i[3]}
  2663. fdb.lazyInsertData("logs", newdic2)
  2664. if time =="3":
  2665. print(datetime.datetime.now(),"[数据库操作]更新准备组任务抑制前序任务")
  2666. log_str3 = fdb.queryTabel('logs', "编号", "处理时间='' and 变更字段='准备组任务'")
  2667. #print(log_str3)
  2668. if len(log_str3) != 0:
  2669. for i in log_str3:
  2670. newdic = {"处理人": "'更新准备组任务系统抑制'", "处理时间": "'%s'" % now}
  2671. fdb.lazyUpdateItem('logs', newdic, "编号='%s'" % i[0])
  2672. getTaskAuto = fdb.getAlldata('taskAuto')
  2673. if len(getTaskAuto) != 0:
  2674. #print(getTaskAuto)
  2675. for i in getTaskAuto:
  2676. #print(i)
  2677. if i[1] != "None":
  2678. time1 = str(datetime.date.today()) + " " + i[1]
  2679. time11 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  2680. time2 = str(datetime.date.today() + datetime.timedelta(days=1)) + " " + i[1]
  2681. time22 = datetime.datetime.strptime(time2, "%Y-%m-%d %H:%M:%S")
  2682. newdic = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2683. "提示信息": "%s" % time11, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
  2684. "显示对象": "",
  2685. "提示内容": i[3]}
  2686. fdb.lazyInsertData("logs", newdic)
  2687. newdic2 = {"航班编号": '', "警告信息": i[2], "信息状态": "",
  2688. "提示信息": "%s" % time22, "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "准备组任务",
  2689. "显示对象": "",
  2690. "提示内容": i[3]}
  2691. fdb.lazyInsertData("logs", newdic2)
  2692. fdb.FunctionCommit()
  2693. except Exception:
  2694. fdb.FunctionCommit()
  2695. dingding_alert(traceback.format_exc())
  2696. def selftaxiLogs(database:flightDB,TEXT:str,flightid:str):
  2697. try:
  2698. now = datetime.datetime.now()
  2699. noteid=database.queryTabel("logs","*","航班编号='%s' and 警告信息='%s'"%(flightid,TEXT))
  2700. if len(noteid) == 0:
  2701. newdic = {"航班编号":flightid, "警告信息":TEXT, "信息状态": "",
  2702. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "自滑提示","显示对象":"","提示内容":""}
  2703. database.insertData("logs", newdic)
  2704. except Exception:
  2705. dingding_alert(traceback.format_exc())
  2706. def insertLogs(database:flightDB,TEXT:str,user:str,time):
  2707. try:
  2708. now = datetime.datetime.now()
  2709. newdic = {"航班编号": "人工%s" % user, "警告信息":TEXT, "信息状态": "",
  2710. "提示信息": time,"产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "人工待办","显示对象":"","提示内容":""} #需要确定显示对象,可以考虑传参
  2711. database.insertData("logs", newdic)
  2712. except Exception:
  2713. dingding_alert(traceback.format_exc())
  2714. def insertLogs2(database:flightDB,TEXT:str,user:str,time):
  2715. try:
  2716. now = datetime.datetime.now()
  2717. newdic = {"航班编号": "人工%s" % user, "警告信息":"", "信息状态": "",
  2718. "提示信息": TEXT,"产生时间": "%s" % now, "处理人": user, "处理时间": time, "变更字段": "操作日志","显示对象":"","提示内容":""} #需要确定显示对象,可以考虑传参
  2719. database.insertData("logs", newdic)
  2720. except Exception:
  2721. dingding_alert(traceback.format_exc())
  2722. def manChangests(database:flightDB,flight_id:str,changests_id:str,selectedtime,username):
  2723. try:
  2724. nowDayStr = selectedtime
  2725. now = datetime.datetime.now()
  2726. now11=str(now).split(".")[0]
  2727. code = {"接机到位": "已到位", "放行": "已放行", "随机到位": "已到位", "销子夹板": "已取下", "二送到位": "已到位"}
  2728. code2 = {"接机到位": "接机已到位提示", "放行": "已放行提示", "随机到位": "随机已到位提示", "销子夹板": "销子夹板已提示", "二送到位": "二送已到位提示"}
  2729. flightsts_search=database.queryTabel("flightsts{}".format(nowDayStr),"%s"%changests_id,"航班编号 = '%s'"%flight_id)
  2730. waringsts=database.queryTabel("logs","*","航班编号='%s' and 处理时间 =''"%flight_id)
  2731. if len(flightsts_search) != 0:
  2732. if flightsts_search[0][0] != "":
  2733. newdic={"%s"%changests_id:"''","%s"%code2[changests_id]:"''"}
  2734. database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号='%s'"%flight_id)
  2735. a =database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
  2736. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
  2737. "提示信息": "人工处理:%s取消%s状态!%s" % (a,changests_id,now11),
  2738. "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
  2739. database.insertData('logs', newdic)
  2740. else:
  2741. newdic={"%s"%changests_id:"'%s'"%code[changests_id],"%s"%code2[changests_id]:"'1'"}
  2742. database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号 = '%s'"%flight_id)
  2743. a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(
  2744. database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
  2745. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
  2746. "提示信息": "人工处理:%s确认%s已完成!%s" % (a, changests_id,now11),
  2747. "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
  2748. database.insertData('logs', newdic)
  2749. if len(waringsts) != 0:
  2750. for i in waringsts:
  2751. if changests_id == "接机到位" and i[8]=="到位警告":
  2752. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2753. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2754. elif changests_id == "放行" and i[8]=="放行警告":
  2755. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2756. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2757. elif changests_id == "二送到位" and i[8]=="二送警告":
  2758. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2759. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2760. elif changests_id == "销子夹板" and i[8]=="销夹警告":
  2761. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2762. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2763. elif changests_id == "随机到位" and i[8] == "随机到位警告":
  2764. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  2765. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  2766. except Exception:
  2767. print(traceback.format_exc())
  2768. dingding_alert(traceback.format_exc())
  2769. def checkFlightAlert(database:flightDB):
  2770. try:
  2771. ########需要建立昨日初始化
  2772. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  2773. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  2774. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  2775. 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"]
  2776. now = datetime.datetime.now()
  2777. now_20=(datetime.datetime.now()+ datetime.timedelta(minutes=120)).strftime("%Y%m%d")
  2778. if now_20 == nowDay:
  2779. day=[nowDay,nowDay_1]
  2780. else:
  2781. day = [nowDay, nowDay_1,nowDay_2]
  2782. for nowDayStr in day:
  2783. flightcheck=database.queryTabel("sortFlight{}".format(nowDayStr),"航班编号","CAST(级别 AS integer) = 1" )
  2784. flightcheck2 = database.queryTabel("sortFlight{}".format(nowDayStr), "航班编号", "CAST(级别 AS integer) != 4")
  2785. if database.getSingledata("航班编号", "flightinfo{}".format(nowDayStr)) !=None and len(database.getSingledata("航班编号", "flightinfo{}".format(nowDayStr))) != 0 and len(flightcheck) !=0:
  2786. for i in flightcheck:
  2787. a = database.queryTabel("flightinfo{}".format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
  2788. b = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
  2789. dd = database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % i[0])[0][0]
  2790. if b =="航前":
  2791. c = database.queryTabel("flightinfo{}".format(nowDayStr), "航前离港机位", "航班编号='%s'" % i[0])[0][0]
  2792. else:
  2793. c = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前进港机位", "航班编号='%s'" % i[0])[0][0]
  2794. #if c in selftaxi:
  2795. if "航前" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and database.queryTabel("flightinfo{}".format(nowDayStr),"航前预计起飞","航班编号='%s'"%i[0])[0][0] != "":
  2796. STD=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  2797. STD_str = dd.split("-")[0] + "/" + STD.split("]")[1]
  2798. STD_90 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
  2799. STD_30 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=30)
  2800. if STD_90 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
  2801. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2802. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  2803. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  2804. database.lazyInsertData('logs', newdic)
  2805. if STD_30 < now and "已放行" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"放行","航班编号='%s'"%i[0])) and \
  2806. "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2807. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
  2808. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
  2809. database.lazyInsertData('logs', newdic)
  2810. if STD_30 < now and "已取下" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"销子夹板","航班编号='%s'"%i[0])) and \
  2811. "销夹警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2812. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s销夹取下情况!"%(a,b,c), "信息状态": "",
  2813. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "销夹警告","显示对象":"","提示内容":""}
  2814. database.lazyInsertData('logs', newdic)
  2815. elif "航后" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and\
  2816. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] != "" and\
  2817. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] != "":
  2818. ETA_15_str = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  2819. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  2820. if ETA_15 < now and "已到位" not in database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0]) and \
  2821. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2822. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  2823. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  2824. database.lazyInsertData('logs', newdic)
  2825. elif "短停" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and\
  2826. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!= "" and \
  2827. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0]!= "" :
  2828. ETA_15_str=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  2829. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  2830. ATA = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])
  2831. if ATA[0][0] != "":
  2832. ATA_time_30 = datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  2833. ATA_time_3H=datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S")+datetime.timedelta(minutes=180)
  2834. else:
  2835. ATA_time_30 = ""
  2836. ATA_time_3H=""
  2837. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  2838. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  2839. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  2840. TD_time_25 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")- datetime.timedelta(minutes=25)
  2841. TD_time_120 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  2842. TD_time=datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")
  2843. if ETA_15 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
  2844. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2845. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  2846. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  2847. database.lazyInsertData('logs', newdic)
  2848. 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 \
  2849. "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2850. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
  2851. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
  2852. database.lazyInsertData('logs', newdic)
  2853. 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 \
  2854. "二送警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2855. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s二送到位情况!"%(a,b,c), "信息状态": "",
  2856. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "二送警告","显示对象":"","提示内容":""}
  2857. database.lazyInsertData('logs', newdic)
  2858. if ATA_time_3H !="" and ATA_time_3H < TD_time and TD_time_120 < now and\
  2859. "长短停到位提示" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" % i[0])):
  2860. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认安排%s%s%s长短停上电人员!" % (a, b, c), "信息状态": "",
  2861. "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "长短停到位提示","显示对象":"","提示内容":""}
  2862. database.lazyInsertData('logs', newdic)
  2863. if ATA_time_3H !="" and ATA_time_3H < TD_time and\
  2864. "长短停值守提示" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s'" % i[0])):
  2865. newdic = {"航班编号": "%s" % i[0], "警告信息": "请注意安排%s %s长短停值守,如无需则忽略!" % (a,c), "信息状态": "",
  2866. "提示信息": "", "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "长短停值守提示","显示对象":"","提示内容":""}
  2867. database.lazyInsertData('logs', newdic)
  2868. elif "短停" not in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and \
  2869. "航后" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0]))and \
  2870. "航前" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
  2871. "未显示" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
  2872. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!= "":
  2873. ETA_15_str = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  2874. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  2875. ATA = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])
  2876. if ATA[0][0] != "":
  2877. #print(ATA[0][0])
  2878. ATA_time_30 = datetime.datetime.strptime(ATA[0][0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  2879. else:
  2880. ATA_time_30 = ""
  2881. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  2882. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  2883. #print(TD)
  2884. #print(FlightDate)
  2885. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  2886. TD_time_25 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M")- datetime.timedelta(minutes=25)
  2887. if ETA_15 < now and "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"接机到位","航班编号='%s'"%i[0])) and \
  2888. "到位警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2889. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s到位情况!"%(a,b,c), "信息状态": "",
  2890. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "到位警告","显示对象":"","提示内容":""}
  2891. database.lazyInsertData('logs', newdic)
  2892. 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 \
  2893. "放行警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2894. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s放行情况!"%(a,b,c), "信息状态": "",
  2895. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "放行警告","显示对象":"","提示内容":""}
  2896. database.lazyInsertData('logs', newdic)
  2897. 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 \
  2898. "二送警告" not in str(database.queryTabel('logs', "变更字段", "航班编号='%s' and 处理时间=''" % i[0])):
  2899. newdic = {"航班编号": "%s" % i[0], "警告信息": "请确认%s%s%s二送到位情况!"%(a,b,c), "信息状态": "",
  2900. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "二送警告","显示对象":"","提示内容":""}
  2901. database.lazyInsertData('logs', newdic)
  2902. for i in flightcheck2:
  2903. a = database.queryTabel("flightinfo{}".format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
  2904. b = database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
  2905. dd = database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期","航班编号='%s'" % i[0])[0][0]
  2906. if b =="航前":
  2907. c = database.queryTabel("flightinfo{}".format(nowDayStr), "航前离港机位", "航班编号='%s'" % i[0])[0][0]
  2908. else:
  2909. c = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前进港机位", "航班编号='%s'" % i[0])[0][0]
  2910. if "航前" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and database.queryTabel("flightinfo{}".format(nowDayStr),"航前预计起飞","航班编号='%s'"%i[0])[0][0] != "":
  2911. STD=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  2912. STD_str = dd.split("-")[0] + "/" + STD.split("]")[1]
  2913. STD_120 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  2914. STD_60 = datetime.datetime.strptime(STD_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
  2915. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  2916. "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and STD_120 < now:
  2917. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
  2918. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  2919. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  2920. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
  2921. database.lazyInsertData('logs', newdic)
  2922. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  2923. "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and STD_60 < now and\
  2924. "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
  2925. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  2926. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
  2927. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  2928. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
  2929. database.lazyInsertData('logs', newdic)
  2930. elif "短停" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])):
  2931. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  2932. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  2933. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  2934. TD_time_120 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  2935. TD_time_60 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
  2936. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  2937. "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and TD_time_120 < now:
  2938. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  2939. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
  2940. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  2941. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
  2942. database.lazyInsertData('logs', newdic)
  2943. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  2944. "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and TD_time_60 < now and\
  2945. "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
  2946. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  2947. sjry = database.queryTabel('TaskFlightinfo{}'.format(nowDayStr), "随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
  2948. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  2949. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
  2950. database.lazyInsertData('logs', newdic)
  2951. elif "短停" not in str(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])) and \
  2952. "航后" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0]))and \
  2953. "航前" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and \
  2954. "未显示" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])) and\
  2955. "停场" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])):
  2956. FlightDate=database.queryTabel("flightinfo{}".format(nowDayStr), "航班日期", "航班编号='%s'" % i[0])[0][0]
  2957. TD = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0]
  2958. TD_time_str = FlightDate.split("-")[0] + "/" + TD.split("]")[1]
  2959. TD_time_120= datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=120)
  2960. TD_time_60 = datetime.datetime.strptime(TD_time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=60)
  2961. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  2962. "随机2H提醒" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s'" % i[0])) and TD_time_120 < now:
  2963. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  2964. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split(" ")[1]
  2965. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机2H提醒]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  2966. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机2H提醒","显示对象":"","提示内容":""}
  2967. database.lazyInsertData('logs', newdic)
  2968. if "随机离港" in str(database.queryTabel("peopleSchedule{}".format(nowDayStr), "附加消息", "航班编号='%s'" % i[0])) and\
  2969. "随机到位确认" not in str(database.queryTabel("logs", "警告信息", "航班编号='%s' and 处理时间=''" % i[0])) and TD_time_60 < now and\
  2970. "已到位" not in str(database.queryTabel('flightsts{}'.format(nowDayStr),"随机到位","航班编号='%s'"%i[0])):
  2971. flightno = database.queryTabel("flightinfo{}".format(nowDayStr), "离港机场", "航班编号='%s'" % i[0])[0][0]
  2972. sjry=database.queryTabel('TaskFlightinfo{}'.format(nowDayStr),"随机", "航班编号='%s'" % i[0])[0][0].split("随机离港 ")[1]
  2973. newdic = {"航班编号": "%s" % i[0], "警告信息": "[随机到位确认]%s%s%s%s"%(a,flightno,c,sjry), "信息状态": "",
  2974. "提示信息": "","产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "随机到位警告","显示对象":"","提示内容":""}
  2975. database.lazyInsertData('logs', newdic)
  2976. database.FunctionCommit()
  2977. waringIDs=database.queryTabel('logs',"*","变更字段 like '%警告%' and 处理时间 =''")
  2978. flightstsids=database.getSingledata("航班编号",'flightsts{}'.format(nowDayStr))
  2979. for waringID in waringIDs:
  2980. if str(waringID[1]) in str(flightstsids):
  2981. waringIDstsNow=database.queryTabel('flightsts{}'.format(nowDayStr),"*","航班编号 ='%s'"%waringID[1])
  2982. if waringID[8] == "到位警告" and waringIDstsNow[0][3] == "已到位":
  2983. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  2984. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  2985. if waringID[8] == "放行警告" and waringIDstsNow[0][4] == "已放行":
  2986. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  2987. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  2988. if waringID[8] == "二送警告" and waringIDstsNow[0][7] == "已到位":
  2989. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  2990. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  2991. if waringID[8] == "销夹警告" and waringIDstsNow[0][5] == "已取下":
  2992. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  2993. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  2994. if waringID[8] == "随机到位警告" and waringIDstsNow[0][6] == "已到位":
  2995. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  2996. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  2997. database.FunctionCommit()
  2998. except Exception:
  2999. database.FunctionCommit()
  3000. print(traceback.format_exc())
  3001. dingding_alert(traceback.format_exc())
  3002. def createWorkloadtablesFromPg(fdb: flightDB, workLoad: flightDB,selectedtime):
  3003. try:
  3004. workloadDic = {}
  3005. primaryKey2 = 'text UNIQUE NOT NULL'
  3006. pglist=fdb.getAlldata("pglist{}".format(selectedtime))
  3007. if len(pglist) != 0:
  3008. for workloadkey in list(workloadLabel)[1:]:
  3009. workloadDic[workloadkey] = 'text not null'
  3010. for row in pglist:
  3011. workLoad.initTable('workload%s'%str(row[1]),"编号", primaryKey2, workloadDic)
  3012. except Exception:
  3013. dingding_alert(traceback.format_exc())
  3014. def createWorkloadtables(fdb:flightDB, workLoad:flightDB):
  3015. try:
  3016. workloadDic = {}
  3017. primaryKey = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'
  3018. primaryKey2 = 'TEXT UNIQUE NOT NULL'
  3019. #print(len(fdb.getAlldata("workerinfo")))
  3020. if len(fdb.getAlldata("workerinfo")) != 0:
  3021. for workloadkey in list(workloadLabel)[1:]:
  3022. workloadDic[workloadkey]= 'text not null'
  3023. worknumbs=fdb.getSingledata("工号","workerinfo")
  3024. for worknumbskey in worknumbs:
  3025. if str(worknumbskey[0]) != "*":
  3026. workLoad.initTable('workload%s'%str(worknumbskey[0]),"编号",primaryKey2, workloadDic)
  3027. else:
  3028. print(datetime.datetime.now(),"[数据库操作]人员信息为空,无法创建人员工作量数据库!请先上传人员信息")
  3029. #需要QT输出警告弹框信息
  3030. except Exception:
  3031. dingding_alert(traceback.format_exc())
  3032. def get_full_pinyin1(word, style=Style.NORMAL, separator=''):
  3033. pinyin_list = pinyin(word, style=style)
  3034. #使用列表推导式获取每个汉字的第一个拼音(不带声调),并使用 separator 连接
  3035. full_pinyin = separator.join([''.join(syllable[0]) for syllable in pinyin_list])
  3036. return full_pinyin
  3037. def get_full_pinyin2(word, style=Style.NORMAL, separator=''):
  3038. return ''.join([word[0][0] for word in pinyin(word, style=Style.NORMAL)])
  3039. def get_dic(database:flightDB, fileName):
  3040. try:
  3041. fdb = database
  3042. decrypted_workbook = io.BytesIO()
  3043. try:
  3044. with open(fileName, 'rb') as file:
  3045. office_file = msoffcrypto.OfficeFile(file)
  3046. office_file.load_key(password='Scal_0177')
  3047. office_file.decrypt(decrypted_workbook)
  3048. workbook = openpyxl.load_workbook(filename=decrypted_workbook)
  3049. mysheet = workbook.active
  3050. myrows = list(mysheet.values)[1:]
  3051. mytitle = list(mysheet.values)[0]
  3052. for myrow in myrows:
  3053. mydics0 = {}
  3054. mydics1 = {}
  3055. for i in range(0, (len(mytitle))):
  3056. a = get_full_pinyin1(str(myrow[0])) + ":" + get_full_pinyin2(str(myrow[0]))
  3057. mydics0[mytitle[i]] = "%s"%myrow[i]
  3058. mydics0[mytitle[11]] = "%s" % a
  3059. if i != 3 and i != 11:
  3060. mydics1[mytitle[i]] = "'%s'" % myrow[i]
  3061. elif i == 11:
  3062. mydics1[mytitle[11]] = "'%s'" % a
  3063. #a= fdb.getSingledata("工号",'workerinfo')
  3064. if str(mydics0["工号"]) in str(fdb.getSingledata("工号",'workerinfo')):
  3065. fdb.lazyUpdateItem('workerinfo',mydics1,"工号='%s'"%mydics0["工号"])
  3066. else:
  3067. fdb.lazyInsertData('workerinfo',mydics0)
  3068. #print(1)
  3069. fdb.FunctionCommit()
  3070. return 1
  3071. except Exception:
  3072. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查通讯录文件!人员显示功能失效!!')
  3073. print(traceback.format_exc())
  3074. dingding_alert(traceback.format_exc())
  3075. # 需要QT输出警告弹框信息
  3076. fdb.FunctionCommit()
  3077. return 0
  3078. except Exception:
  3079. dingding_alert(traceback.format_exc())
  3080. def manAddFlight(fdb:flightDB,flighttype,acno,eng,actype,flightno,flightdate,bay,eta,etd,user):
  3081. starttime = flightdate + " 00:00:00"
  3082. flightdate1 = datetime.datetime.strptime(starttime, "%Y-%m-%d %H:%M:%S")
  3083. flightdate2 =flightdate.replace("-", "")
  3084. flightids=fdb.getSingledata("航班编号","flightinfo%s"%flightdate2)
  3085. ETD2=str("[计]"+etd[6:16]).replace("-", "/")
  3086. flightid = "MAN" + str(acno) + str(flightno)+str(flightdate2)
  3087. if flightid not in str(flightids):
  3088. if flighttype =="航前":
  3089. newdic={"航班编号":"%s"%flightid, "航班编号对":"", "机号":acno, "发动机":eng, "机型":actype, "保障航班号":flightno, "进港机场":"", "离港机场":"", "进出港航班号":flightno, "航班日期":flightdate1, "航班状态":"",
  3090. "航班类型":flighttype, "非航前计划到达":"", "航前预计起飞":etd, "非航前实际到达":"", "非航前预计到达":"", "航前实际起飞":"", "非航前预计起飞":ETD2, "非航前预计进港机位":"",
  3091. "非航前进港机位":"", "航前预计离港机位":"", "航前离港机位":bay, "维修人员":"", "放行人员":"", "维修状态":"", "重要航班":"", "随机":"", "保留":"", "备降返航":"", "维修状态时间":"", "二送人员":"", "二送状态":"",
  3092. "附加消息":"人工添加", "取消标志":""}
  3093. elif flighttype =="短停" or flighttype =="特后前":
  3094. newdic = {"航班编号": "%s" % flightid, "航班编号对": "", "机号": acno, "发动机": eng, "机型": actype, "保障航班号": flightno,
  3095. "进港机场": "", "离港机场": "", "进出港航班号": flightno, "航班日期": flightdate1, "航班状态": "","航班类型": flighttype, "非航前计划到达": "", "航前预计起飞": "", "非航前实际到达": eta, "非航前预计到达": eta, "航前实际起飞": eta,
  3096. "非航前预计起飞": ETD2, "非航前预计进港机位": "","非航前进港机位": bay, "航前预计离港机位": "", "航前离港机位": "", "维修人员": "", "放行人员": "", "维修状态": "", "重要航班": "",
  3097. "随机": "", "保留": "", "备降返航": "", "维修状态时间": "", "二送人员": "", "二送状态": "","附加消息": "人工添加", "取消标志": ""}
  3098. else:
  3099. newdic = {"航班编号": "%s" % flightid, "航班编号对": "", "机号": acno, "发动机": eng, "机型": actype, "保障航班号": flightno,
  3100. "进港机场": "", "离港机场": "", "进出港航班号": flightno, "航班日期": flightdate1, "航班状态": "", "航班类型": flighttype,
  3101. "非航前计划到达": "", "航前预计起飞": "", "非航前实际到达": "", "非航前预计到达": eta, "航前实际起飞": eta,
  3102. "非航前预计起飞": "", "非航前预计进港机位": "", "非航前进港机位": bay, "航前预计离港机位": "", "航前离港机位": "", "维修人员": "", "放行人员": "",
  3103. "维修状态": "", "重要航班": "",
  3104. "随机": "", "保留": "", "备降返航": "", "维修状态时间": "", "二送人员": "", "二送状态": "", "附加消息": "人工添加", "取消标志": ""}
  3105. fdb.insertData("flightinfo%s"%flightdate2,newdic)
  3106. else:
  3107. if flighttype =="航前":
  3108. newdic={"航班编号":"'%s'"%flightid,"机号":"'%s'"%acno, "非航前预计起飞":"'%s'"%ETD2,"发动机":"'%s'"%eng, "机型":"'%s'"%actype, "保障航班号":"'%s'"%flightno,"进出港航班号":"'%s'"%flightno, "航班日期":"'%s'"%flightdate1,"航班类型":"'%s'"%flighttype, "航前预计起飞":"'%s'"%etd, "航前离港机位":"'%s'"%bay}
  3109. elif flighttype =="短停" or flighttype =="特后前":
  3110. 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}
  3111. else:
  3112. newdic = {"航班编号": "'%s'" % flightid,"机号":"'%s'"% acno, "发动机":"'%s'"% eng, "机型":"'%s'"% actype, "保障航班号":"'%s'"% flightno,"进出港航班号":"'%s'"% flightno, "航班日期":"'%s'"% flightdate1, "航班类型":"'%s'"% flighttype, "非航前预计到达":"'%s'"% eta,"航前实际起飞": "'%s'"% eta, "非航前进港机位":"'%s'"% bay}
  3113. fdb.upDateItem("flightinfo%s"%flightdate2,newdic,"航班编号='%s'"%flightid)
  3114. sortFlighttime(flightDB(host=host,
  3115. port=port,
  3116. user=user,
  3117. password=password,
  3118. database=databaseflightDB4
  3119. ))
  3120. sortFlighttime2(flightDB(host=host,
  3121. port=port,
  3122. user=user,
  3123. password=password,
  3124. database=databaseflightDB4
  3125. ))
  3126. res={"返回值":"ok"}
  3127. return res
  3128. def deleteFlight(fdb:flightDB,flightid,time):
  3129. fdb.deleteTable("flightinfo%s"%time,"航班编号='%s'"%flightid)
  3130. res={"返回值":"ok"}
  3131. sortFlighttime(flightDB(host=host,
  3132. port=port,
  3133. user=user,
  3134. password=password,
  3135. database=databaseflightDB4
  3136. ))
  3137. sortFlighttime2(flightDB(host=host,
  3138. port=port,
  3139. user=user,
  3140. password=password,
  3141. database=databaseflightDB4
  3142. ))
  3143. return res
  3144. def updateStopFlight(database:flightDB, fileName):
  3145. fdb = database
  3146. textInfo={"机号":2,"非航前进港机位":3,"机型":4,"发动机":5}
  3147. try:
  3148. workbook = openpyxl.load_workbook(filename=fileName)
  3149. mysheet = workbook.active
  3150. myrows = list(mysheet.values)[2:]
  3151. #print(myrows)
  3152. #print(myrows[1])
  3153. if myrows[0][1] != "" and myrows[0][2] != "" and myrows[0][1] != None and myrows[0][2] != None:
  3154. #print(myrows[0])
  3155. day=str(myrows[0][1]).split("/")[0]+str(myrows[0][1]).split("/")[1]+str(myrows[0][1]).split("/")[2]
  3156. day1 = str(myrows[0][1]).split("/")[0] +"-"+ str(myrows[0][1]).split("/")[1] +"-"+ str(myrows[0][1]).split("/")[2]
  3157. daytime = day1 + " 00:00:00"
  3158. starttime = day1 + " 09:00:00"
  3159. a = datetime.datetime.strptime(daytime, "%Y-%m-%d %H:%M:%S")
  3160. b = datetime.datetime.strptime(starttime, "%Y-%m-%d %H:%M:%S")
  3161. flightids=fdb.queryTabel("flightinfo%s"%day,"航班编号","航班类型 ='停场'")
  3162. if len(flightids) != 0:
  3163. for i in flightids:
  3164. fdb.deleteSingledata("flightinfo%s"%day,"航班编号='%s'"%i[0])
  3165. for myrow in myrows:
  3166. mydics0 = {}
  3167. if myrow[2] != None and myrow[1] != None and myrow[2] != "" and myrow[1] != "":
  3168. now = str(time.time() * 1000000).split(".")[0]
  3169. #print(now)
  3170. flightid = "MAN" + str(now)+str(myrow[2])
  3171. #print(flightid)
  3172. for i in flightinfoLabel:
  3173. if i in textInfo.keys():
  3174. text=myrow[textInfo[i]] if myrow[textInfo[i]] !=None else ""
  3175. mydics0[i] = "%s"%text
  3176. elif i =="航班编号":
  3177. mydics0[i]="%s"%flightid
  3178. elif i =="航班日期":
  3179. mydics0[i]="%s"%a
  3180. elif i =="非航前实际到达":
  3181. mydics0[i]="%s"%b
  3182. elif i =="附加消息":
  3183. mydics0[i]="人工添加"
  3184. elif i =="航班类型":
  3185. mydics0[i]="停场"
  3186. else:
  3187. mydics0[i]=''
  3188. #print(mydics0)
  3189. fdb.lazyInsertData("flightinfo%s"%day,mydics0)
  3190. fdb.FunctionCommit()
  3191. sortFlighttime(flightDB(host=host,
  3192. port=port,
  3193. user=user,
  3194. password=password,
  3195. database=databaseflightDB4
  3196. ))
  3197. sortFlighttime2(flightDB(host=host,
  3198. port=port,
  3199. user=user,
  3200. password=password,
  3201. database=databaseflightDB4
  3202. ))
  3203. print(datetime.datetime.now(), '[数据库操作]停场航班导入成功!')
  3204. res = {"返回值": "ok"}
  3205. return res
  3206. except Exception:
  3207. print(datetime.datetime.now(),'[数据库操作]停场航班导入失败!!检查模板文件!')
  3208. print(traceback.format_exc())
  3209. # 需要QT输出警告弹框信息
  3210. res = {"返回值": "fail"}
  3211. fdb.FunctionCommit()
  3212. return res
  3213. #新增内容
  3214. def updateRiskdb(database:flightDB, fileName): #创建准备组提示数据库
  3215. fdb = database
  3216. fdb.deleteTable("RiskTable")
  3217. try:
  3218. workbook = openpyxl.load_workbook(filename=fileName)
  3219. mysheet = workbook.active
  3220. myrows = list(mysheet.values)[1:]
  3221. mytitle = list(mysheet.values)[0]
  3222. for myrow in myrows:
  3223. mydics0 = {}
  3224. for i in range(0, (len(mytitle))):
  3225. mydics0[mytitle[i]] = "%s"%myrow[i]
  3226. #print(mydics0)
  3227. fdb.lazyInsertData('RiskTable',mydics0)
  3228. fdb.FunctionCommit()
  3229. return 1
  3230. except Exception:
  3231. dingding_alert(traceback.format_exc())
  3232. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查模板文件!风险提示功能失效!!')
  3233. fdb.FunctionCommit()
  3234. return 0
  3235. def saveRisktable(database:flightDB):
  3236. fdb = database
  3237. res=fdb.getAlldata("RiskTable")
  3238. if res == None:
  3239. res =[]
  3240. return res
  3241. def getRiskData(fdb:flightDB,bay,time):
  3242. res = fdb.queryTabel("RiskTable","提示内容","状态='生效' and 触发条件1 ='%s' and 触发条件2 ='%s' "%(bay,time))
  3243. tips= res[0][0] if res !=None and res !=[] and len(res) !=0 else ""
  3244. return tips
  3245. def updateTaskAuto(database:flightDB, fileName): #创建准备组提示数据库
  3246. fdb = database
  3247. fdb.deleteTable("taskAuto")
  3248. try:
  3249. workbook = openpyxl.load_workbook(filename=fileName)
  3250. mysheet = workbook.active
  3251. myrows = list(mysheet.values)[1:]
  3252. mytitle = list(mysheet.values)[0]
  3253. for myrow in myrows:
  3254. mydics0 = {}
  3255. for i in range(0, (len(mytitle))):
  3256. mydics0[mytitle[i]] = "%s"%myrow[i]
  3257. #print(mydics0)
  3258. fdb.lazyInsertData('taskAuto',mydics0)
  3259. fdb.FunctionCommit()
  3260. return 1
  3261. except Exception:
  3262. dingding_alert(traceback.format_exc())
  3263. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查模板文件!准备组任务提示功能失效!!')
  3264. fdb.FunctionCommit()
  3265. return 0
  3266. def insertCalllist(fdb,data):
  3267. try:
  3268. #CalllistLabel1 = ["航班编号", "电话", "工号", "姓名", "航班号", "附加消息", "拨号次数", "创建时间", "接通时间"]
  3269. now = datetime.datetime.now()
  3270. data["创建时间"]=now
  3271. data["接通时间"] = ''
  3272. fdb.insertData('Calllist',data)
  3273. #print("test")
  3274. res={"返回值":"ok"}
  3275. return res
  3276. except Exception:
  3277. print(traceback.format_exc())
  3278. dingding_alert(traceback.format_exc())
  3279. def checkTFUairplane(database:flightDB):
  3280. try:
  3281. code = {"接机已到位提示","已放行提示","二送已到位提示"}
  3282. code2 = {"接机已到位提示", "已放行提示"}
  3283. #需要建立昨日初始化
  3284. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3285. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3286. now = datetime.datetime.now()
  3287. now11=str(now).split(".")[0]
  3288. day = [nowDay, nowDay_1]
  3289. for nowDayStr in day:
  3290. AFinsky_arr = []
  3291. AFongroud_arr = []
  3292. TRinsky_arr = []
  3293. TRongroud_arr = []
  3294. THQinsky_arr = []
  3295. THQongroud_arr = []
  3296. APongroud_arr = []
  3297. flightsts_flight_ids_arr=[]
  3298. AFinsky=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='航后' and 非航前预计到达!='' and 非航前实际到达=''and 航前实际起飞!=''")
  3299. AFongroud=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='航后' and 非航前实际到达!=''")
  3300. TRinsky=database.queryTabel('flightinfo{}'.format(nowDayStr),'航班编号',"航班类型='短停' and 非航前预计到达!='' and 非航前实际到达='' and 航前实际起飞!=''")
  3301. TRongroud = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='短停' and 非航前实际到达!='' and (非航前预计起飞 like '%预%' or 非航前预计起飞 like '%计%')")
  3302. THQinsky = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号',"航班类型='特后前' and 非航前预计到达!='' and 非航前实际到达=''and 航前实际起飞!=''")
  3303. THQongroud=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='特后前' and 非航前实际到达!='' and (非航前预计起飞 like '%预%' or 非航前预计起飞 like '%计%')")
  3304. APongroud=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班类型='航前' and 航前实际起飞 =''")
  3305. ##################################
  3306. #缺个未显示的航班筛选
  3307. if len(AFinsky) != 0:
  3308. for i in AFinsky:
  3309. AFinsky_arr.append(i[0])
  3310. if len(AFongroud) != 0:
  3311. for i in AFongroud:
  3312. AFongroud_arr.append(i[0])
  3313. if len(TRinsky) != 0:
  3314. for i in TRinsky:
  3315. TRinsky_arr.append(i[0])
  3316. if len(TRongroud) != 0:
  3317. for i in TRongroud:
  3318. TRongroud_arr.append(i[0])
  3319. if len(THQinsky) != 0:
  3320. for i in THQinsky:
  3321. THQinsky_arr.append(i[0])
  3322. if len(THQongroud) != 0:
  3323. for i in THQongroud:
  3324. THQongroud_arr.append(i[0])
  3325. if len(APongroud) != 0:
  3326. for i in APongroud:
  3327. APongroud_arr.append(i[0])
  3328. flightsts_flight_ids=database.getSingledata('航班编号','flightsts{}'.format(nowDayStr))
  3329. flightinfo_flight_ids=database.getSingledata('航班编号','flightinfo{}'.format(nowDayStr))
  3330. if len(flightsts_flight_ids) != 0:
  3331. for flightstskey in flightsts_flight_ids:
  3332. newdic={"天府飞机":"''"}
  3333. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%flightstskey[0])
  3334. if flightstskey in flightinfo_flight_ids:
  3335. flightsts_flight_ids_arr.append(flightstskey[0])
  3336. else:
  3337. database.deleteSingledata('flightsts{}'.format(nowDayStr),"航班编号='%s'"%flightstskey[0])
  3338. for AFinsky_arr_key in AFinsky_arr:
  3339. if AFinsky_arr_key in flightsts_flight_ids_arr:
  3340. newdic = {"天府飞机":"'空中航后'"}
  3341. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%AFinsky_arr_key)
  3342. else:
  3343. newdic={"航班编号":"%s"%AFinsky_arr_key,"接机到位":"","放行":"","销子夹板":"","随机到位":"","二送到位":"","接机已到位提示":"","已放行提示":"","销子夹板已提示":"","随机已到位提示":"","二送已到位提示":"","天府飞机":'空中航后',"机号":"","机位":""}
  3344. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3345. for AFongroud_arr_key in AFongroud_arr:
  3346. if AFongroud_arr_key in flightsts_flight_ids_arr:
  3347. newdic = {"天府飞机": "'地面航后'"}
  3348. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%AFongroud_arr_key)
  3349. else:
  3350. newdic = {"航班编号": "%s" % AFongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3351. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面航后',"机号":"","机位":""}
  3352. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3353. for TRinsky_arr_key in TRinsky_arr:
  3354. if TRinsky_arr_key in flightsts_flight_ids_arr:
  3355. newdic = {"天府飞机": "'空中短停'"}
  3356. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%TRinsky_arr_key)
  3357. else:
  3358. newdic = {"航班编号": "%s" % TRinsky_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3359. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '空中短停',"机号":"","机位":""}
  3360. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3361. for TRongroud_arr_key in TRongroud_arr:
  3362. if TRongroud_arr_key in flightsts_flight_ids_arr:
  3363. newdic = {"天府飞机": "'地面短停'"}
  3364. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%TRongroud_arr_key)
  3365. else:
  3366. newdic = {"航班编号": "%s" % TRongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3367. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面短停',"机号":"","机位":""}
  3368. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3369. for THQinsky_arr_key in THQinsky_arr:
  3370. if THQinsky_arr_key in flightsts_flight_ids_arr:
  3371. newdic = {"天府飞机": "'空中特后前'"}
  3372. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%THQinsky_arr_key)
  3373. else:
  3374. newdic = {"航班编号": "%s" % THQinsky_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3375. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '空中特后前',"机号":"","机位":""}
  3376. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3377. for THQongroud_arr_key in THQongroud_arr:
  3378. if THQongroud_arr_key in flightsts_flight_ids_arr:
  3379. newdic = {"天府飞机": "'地面特后前'"}
  3380. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%THQongroud_arr_key)
  3381. else:
  3382. newdic = {"航班编号": "%s" % THQongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3383. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面特后前',"机号":"","机位":""}
  3384. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3385. for APongroud_arr_key in APongroud_arr:
  3386. #print(APongroud_arr_key)
  3387. if APongroud_arr_key in flightsts_flight_ids_arr:
  3388. newdic = {"天府飞机":"'地面航前'"}
  3389. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"航班编号='%s'"%APongroud_arr_key)
  3390. else:
  3391. newdic = {"航班编号": "%s" % APongroud_arr_key, "接机到位": "", "放行": "", "销子夹板": "", "随机到位": "", "二送到位": "",
  3392. "接机已到位提示": "", "已放行提示": "", "销子夹板已提示": "", "随机已到位提示": "", "二送已到位提示": "", "天府飞机": '地面航前',"机号":"","机位":""}
  3393. database.lazyInsertData('flightsts{}'.format(nowDayStr),newdic)
  3394. for flightstskey in flightinfo_flight_ids:
  3395. acno_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "机号", "航班编号='{}'".format(flightstskey[0]))
  3396. if "航前" not in database.queryTabel('flightinfo{}'.format(nowDayStr), "航班类型", "航班编号='{}'".format(flightstskey[0])):
  3397. bay_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "航前离港机位", "航班编号='{}'".format(flightstskey[0]))
  3398. else:
  3399. bay_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "非航前进港机位", "航班编号='{}'".format(flightstskey[0]))
  3400. newdic = {"机位":"'%s'"%bay_str[0], "机号":"'%s'"%acno_str[0]}
  3401. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3402. worksts_str=database.queryTabel('flightinfo{}'.format(nowDayStr), "维修状态", "航班编号='{}'".format(flightstskey[0]))
  3403. worksts_STR = worksts_str[0][0] if len(worksts_str) != 0 else 0
  3404. worksts = int(worksts_STR) if worksts_STR != "" else 0
  3405. a=database.queryTabel('flightsts{}'.format(nowDayStr),"机号","航班编号='%s'" % flightstskey[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr),"机号","航班编号='%s'" % flightstskey[0])) != 0 else "未显示机号"
  3406. if worksts >= 7 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
  3407. newdic={"接机到位":"'已到位'", "放行": "'已放行'"}
  3408. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3409. for i in code2:
  3410. if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"%s"%i,"航班编号='%s'" % flightstskey[0]):
  3411. newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s%s!%s"%(a,i,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3412. database.lazyInsertData('logs', newdic)
  3413. newdic = {"%s"%i: 1}
  3414. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3415. elif worksts >= 4 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
  3416. newdic = {"接机到位": "'已到位'"}
  3417. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3418. if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"接机已到位提示","航班编号='%s'" % flightstskey[0]):
  3419. newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s接机已到位提示!%s"%(a,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3420. database.lazyInsertData('logs', newdic)
  3421. newdic = {"接机已到位提示": 1}
  3422. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'"% flightstskey[0])
  3423. ECSJ_worksts_str = database.queryTabel('flightinfo{}'.format(nowDayStr), "二送状态", "航班编号='{}'".format(flightstskey[0]))
  3424. ECSJ_worksts_STR = ECSJ_worksts_str[0][0] if len(ECSJ_worksts_str) != 0 else 0
  3425. ECSJ_worksts = int(ECSJ_worksts_STR) if ECSJ_worksts_STR != "" else 0
  3426. a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flightstskey[0])[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flightstskey[0])) != 0 else "未显示机号"
  3427. if ECSJ_worksts >= 15 and str(flightstskey[0]) in str(flightsts_flight_ids_arr):
  3428. newdic = {"接机到位": "'已到位'", "放行": "'已放行'", "二送到位": "'已到位'"}
  3429. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3430. for i in code:
  3431. if "0" in database.queryTabel('flightsts{}'.format(nowDayStr),"%s"%i,"航班编号='%s'" % flightstskey[0]):
  3432. newdic={"航班编号":"%s"% flightstskey[0],"警告信息":"","信息状态":"","提示信息":"AMRO:%s%s!%s"%(a,i,now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3433. database.lazyInsertData('logs', newdic)
  3434. newdic = {"%s"%i: 1}
  3435. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "航班编号='%s'" % flightstskey[0])
  3436. database.FunctionCommit()
  3437. except Exception:
  3438. dingding_alert(traceback.format_exc())
  3439. database.FunctionCommit()
  3440. def dingdingDelete_flight(database:flightDB):
  3441. try:
  3442. dmac={}
  3443. # 需要建立昨日初始化
  3444. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3445. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3446. day = [nowDay_1,nowDay]
  3447. for nowDayStr in day:
  3448. tfac_ids=database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","CAST(级别 AS integer)=1")
  3449. if len(tfac_ids) != 0:
  3450. for i in tfac_ids:
  3451. acno=database.queryTabel('flightinfo{}'.format(nowDayStr), "机号", "航班编号='%s'" % i[0])[0][0]
  3452. type=database.queryTabel('flightinfo{}'.format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0]
  3453. if acno in dmac.keys() and type !="航前":
  3454. dmac[acno]=i[0]
  3455. elif acno not in dmac.keys():
  3456. dmac[acno] = i[0]
  3457. try:
  3458. res = requests.post(url="http://124.223.185.200:888/delete_flight/", data=json.dumps(dmac),timeout=5) # 自己服务器
  3459. #flightsts = res.json()
  3460. #print(flightsts)
  3461. except Exception:
  3462. dingding_alert(traceback.format_exc())
  3463. pass
  3464. #QT输出弹窗警告,服务器链接失效
  3465. except Exception:
  3466. dingding_alert(traceback.format_exc())
  3467. def dingdinginfoget(database:flightDB):
  3468. try:
  3469. infos={}
  3470. try:
  3471. resfwq = requests.get(url="http://124.223.185.200:4567/get_deal_info/", timeout=10) # 自己服务器
  3472. if resfwq.json() != "":
  3473. infos = resfwq.json()
  3474. except Exception:
  3475. dingding_alert(traceback.format_exc())
  3476. pass
  3477. #print("infos",infos)
  3478. if infos !={}:
  3479. now = datetime.datetime.now()
  3480. for i in infos.keys():
  3481. info=str(infos[i]["info"].split("信息上报")[0])+str(now.strftime("%Y-%m-%d %H:%M:%S"))+"上报信息,鼠标停留查看详情"
  3482. newdic = {"航班编号": "%s" % i, "警告信息": "%s"%info, "信息状态": "", "提示信息": "",
  3483. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "", "显示对象": "", "提示内容": "%s"%infos[i]["info"]}
  3484. database.lazyInsertData('logs', newdic)
  3485. database.FunctionCommit()
  3486. except Exception:
  3487. dingding_alert(traceback.format_exc())
  3488. database.FunctionCommit()
  3489. def dingdingFlightsts(database:flightDB):
  3490. try:
  3491. flightsts = {}
  3492. sever_code={"JJDW":"接机到位","FX":"放行","SJDW":"随机到位","XJ":"销子夹板","ESDW":"二送到位"}
  3493. sever_code1 = {"JJDW": "已到位", "FX": "已放行", "SJDW": "已到位", "XJ": "已取下", "ESDW": "已到位"}
  3494. code2 = {"JJDW": "接机已到位", "FX": "已放行", "SJDW": "随机已到位", "XJ": "销子夹板已取下", "ESDW": "二送已到位"}
  3495. code3 = {"JJDW": "接机已到位提示", "FX": "已放行提示", "SJDW": "随机已到位提示", "XJ": "销子夹板已提示", "ESDW": "二送已到位提示"}
  3496. try:
  3497. resfwq = requests.get(url="http://124.223.185.200:888/search_status/", timeout=10) # 自己服务器
  3498. if resfwq.json() != "":
  3499. flightsts = resfwq.json()
  3500. #print(flightsts)
  3501. #测试数据
  3502. #flightsts={'30CA':{"JJDW": 1, "FX": 1, "SJDW": 1, "XJ": 1, "ESDW": 1},'300D':{"JJDW": 1, "FX": 1, "SJDW": 1, "XJ": 1, "ESDW": 0}}
  3503. except Exception:
  3504. dingding_alert(traceback.format_exc())
  3505. pass
  3506. # QT输出弹窗警告,服务器链接失效
  3507. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3508. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3509. now = datetime.datetime.now()
  3510. now11=str(now).split(".")[0]
  3511. day = [nowDay_1, nowDay]
  3512. tfac_acs=[]
  3513. for nowDayStr in day:
  3514. dmacs = database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","CAST(级别 AS integer)=1")
  3515. for i in dmacs:
  3516. dmac=database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'"%i[0])
  3517. if str(dmac[0]) not in str(tfac_acs):
  3518. tfac_acs.append(dmac[0])
  3519. if len(tfac_acs) != 0:
  3520. for i in tfac_acs:
  3521. #print(i[0])
  3522. if i[0] in flightsts.keys():
  3523. for j,k in sever_code.items():
  3524. if flightsts[i[0]][j] == 1:
  3525. newdic={"%s"%k:"'%s'"%sever_code1[j]}
  3526. #print(newdic)
  3527. database.lazyUpdateItem('flightsts{}'.format(nowDayStr),newdic,"机号='%s' and 天府飞机!=''"%i[0])
  3528. newdic={}
  3529. 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"
  3530. 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 "未显示机号"
  3531. if a !="1":
  3532. newdic={"%s"%code3[j]:1}
  3533. database.lazyUpdateItem('flightsts{}'.format(nowDayStr), newdic, "机号='%s' and 天府飞机!=''" % i[0])
  3534. newdic={"航班编号":"%s"%b,"警告信息":"","信息状态":"","提示信息":"钉钉:%s%s!%s"%(i[0],code2[j],now11),"产生时间":"%s"%now,"处理人":"","处理时间":"","变更字段":"","显示对象":"","提示内容":""}
  3535. database.lazyInsertData('logs',newdic)
  3536. database.FunctionCommit()
  3537. #########################################
  3538. #引入钉钉显示
  3539. ########################################
  3540. except Exception:
  3541. dingding_alert(traceback.format_exc())
  3542. database.FunctionCommit()
  3543. def waringMessageID(database:flightDB):
  3544. try:
  3545. waringMessageID1_arr=[]
  3546. waringMessageID2_arr = []
  3547. waringMessageID3_arr = []
  3548. waringMessageID4_arr = []
  3549. waringMessageID5_arr = []
  3550. waringMessageID6_arr = []
  3551. waringMessageID0_arr = []
  3552. waringMessageID_arrs={}
  3553. waringMessageIDs=database.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
  3554. if len(waringMessageIDs) != 0:
  3555. for i in waringMessageIDs:
  3556. waringMessageID0_arr.append(i[1])
  3557. if i[8] == "到位警告":
  3558. waringMessageID1_arr.append(i[1])
  3559. elif i[8] == "二送警告":
  3560. waringMessageID2_arr.append(i[1])
  3561. elif i[8] == "非航前预计到达":
  3562. waringMessageID3_arr.append(i[1])
  3563. elif i[8] == "非航前进港机位":
  3564. waringMessageID4_arr.append(i[1])
  3565. elif i[8] == "非航前预计起飞":
  3566. waringMessageID5_arr.append(i[1])
  3567. else:
  3568. waringMessageID6_arr.append(i[1])
  3569. waringMessageID_arrs["到位警告"]=waringMessageID1_arr
  3570. waringMessageID_arrs["二送警告"] = waringMessageID2_arr
  3571. waringMessageID_arrs["ETA"] = waringMessageID3_arr
  3572. waringMessageID_arrs["BAY_2"] = waringMessageID4_arr
  3573. waringMessageID_arrs["TD"] = waringMessageID5_arr
  3574. waringMessageID_arrs["通用警告"] = waringMessageID6_arr
  3575. waringMessageID_arrs["全部警告"] = waringMessageID0_arr
  3576. return waringMessageID_arrs
  3577. except Exception:
  3578. dingding_alert(traceback.format_exc())
  3579. def sortFlighttime2(database:flightDB):
  3580. try:
  3581. sortLabel = ["编号", "航班编号", "保障时间", "航班类型", "航班日期", "级别"]
  3582. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3583. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3584. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  3585. now = datetime.datetime.now()
  3586. now_20 = (datetime.datetime.now() + datetime.timedelta(minutes=200)).strftime("%Y%m%d")
  3587. initFlightDatabase(database, now_20)
  3588. initFlightDatabase(database, nowDay_1)
  3589. initFlightDatabase(database, nowDay_2)
  3590. initFlightDatabase(database, nowDay)
  3591. if now_20 == nowDay:
  3592. day = [nowDay, nowDay_1]
  3593. else:
  3594. day = [nowDay, nowDay_1, nowDay_2]
  3595. for selectedtime in day:
  3596. sort2NOs_arr=[]
  3597. sort2NOs = database.getSingledata("编号","sortFlight2{}".format(selectedtime))
  3598. sortNOs = database.getSingledata("编号", "sortFlight{}".format(selectedtime))
  3599. if sort2NOs !=None and len(sort2NOs)!=0:
  3600. for i in sort2NOs:
  3601. if str(i) in str(sortNOs):
  3602. sort2NOs_arr.append(i[0])
  3603. else:
  3604. database.deleteSingledata("sortFlight2{}".format(selectedtime),"编号 = '%s'"%i[0])
  3605. sorttable = getSortFlightdata(database, selectedtime,"sortFlight")
  3606. for row in sorttable:
  3607. if row[3] == "短停接" or row[3] == "特后前接":
  3608. if str(row[5]) == "4":
  3609. find_id = row[1] + "-2"
  3610. for row2 in sorttable:
  3611. if row2[0] == find_id and row2[5] == "4":
  3612. jb = row[5]
  3613. elif row2[0] == find_id:
  3614. jb = "1"
  3615. else:
  3616. jb = row[5]
  3617. newdic = {}
  3618. newdic2={}
  3619. for col in range(0,6):
  3620. if col == 0:
  3621. newdic[sortLabel[col]]=row[col]
  3622. elif col != 5:
  3623. newdic[sortLabel[col]]=row[col]
  3624. newdic2[sortLabel[col]]="'%s'"%row[col]
  3625. else:
  3626. newdic[sortLabel[5]]=jb
  3627. newdic2[sortLabel[5]] = "'%s'"%jb
  3628. if str(row[0]) not in str(sort2NOs_arr):
  3629. database.lazyInsertData('sortFlight2{}'.format(selectedtime),newdic)
  3630. else:
  3631. database.lazyUpdateItem('sortFlight2{}'.format(selectedtime),newdic2,"编号 = '%s'"%row[0])
  3632. elif row[3] != "短停送" and row[3] != "特后前送":
  3633. newdic = {}
  3634. newdic2 = {}
  3635. for col in range(0,6):
  3636. if col == 0:
  3637. newdic[sortLabel[col]]=row[col]
  3638. else:
  3639. newdic[sortLabel[col]]=row[col]
  3640. newdic2[sortLabel[col]] = "'%s'"%row[col]
  3641. if str(row[0]) not in str(sort2NOs_arr):
  3642. database.lazyInsertData('sortFlight2{}'.format(selectedtime), newdic)
  3643. else:
  3644. database.lazyUpdateItem('sortFlight2{}'.format(selectedtime), newdic2, "编号 = '%s'" % row[0])
  3645. database.FunctionCommit()
  3646. except Exception:
  3647. dingding_alert(traceback.format_exc())
  3648. def sortFlighttime(database:flightDB):
  3649. try:
  3650. print(datetime.datetime.now(),'[数据库操作]开始排序')
  3651. #yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  3652. #today_search=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  3653. #tomorrow_search=(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  3654. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  3655. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  3656. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  3657. now = datetime.datetime.now()
  3658. now_20 = (datetime.datetime.now() + datetime.timedelta(minutes=200)).strftime("%Y%m%d")
  3659. initFlightDatabase(database, now_20)
  3660. initFlightDatabase(database, nowDay_1)
  3661. initFlightDatabase(database, nowDay_2)
  3662. initFlightDatabase(database, nowDay)
  3663. if now_20 == nowDay:
  3664. day = [nowDay, nowDay_1]
  3665. else:
  3666. day = [nowDay, nowDay_1, nowDay_2]
  3667. for nowDayStr in day:
  3668. #nowDayStr = datatime
  3669. sort_flight_ids_arr=[]
  3670. sort_flight_ids = database.getSingledata('编号','sortFlight{}'.format(nowDayStr))
  3671. flightinfo_flight_ids = database.getSingledata('航班编号', 'flightinfo{}'.format(nowDayStr))
  3672. if len(sort_flight_ids) != 0:
  3673. for sortkey in sort_flight_ids:
  3674. sort_flight_id=database.queryTabel('sortFlight{}'.format(nowDayStr),"航班编号","编号='%s'"%sortkey[0])[0]
  3675. if str(sort_flight_id) in str(flightinfo_flight_ids):
  3676. sort_flight_ids_arr.append(sortkey[0])
  3677. else:
  3678. database.deleteSingledata('sortFlight{}'.format(nowDayStr),"编号='%s'"%sortkey[0])
  3679. for i in flightinfo_flight_ids:
  3680. #print(database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0]))
  3681. flight_date_str=database.queryTabel("flightinfo{}".format(nowDayStr),"航班日期","航班编号='%s'"%i[0])[0][0]
  3682. if database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] == "航前" and "MAN" not in str(i[0]):
  3683. if database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]!= "":
  3684. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  3685. time_str = flight_date_str.split("-")[0] + "/" + time.split("]")[1]
  3686. sendtime = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
  3687. ii=str(i[0])+str(-2)
  3688. iii = str(i[0]) + str(-1)
  3689. if ii in str(sort_flight_ids_arr):
  3690. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3691. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3692. else:
  3693. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0],"保障时间": "%s" % sendtime, "航班类型": "航前",
  3694. "航班日期": "%s" % flight_date_str, "级别": 1}
  3695. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3696. #print('插入{}'.format(newdic))
  3697. if iii in str(sort_flight_ids_arr):
  3698. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3699. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] !="":
  3700. time=database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0]
  3701. sendtime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3702. ii=str(i[0])+str(-2)
  3703. iii = str(i[0]) + str(-1)
  3704. if ii in str(sort_flight_ids_arr):
  3705. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  3706. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3707. else:
  3708. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % sendtime, "航班类型": "航前",
  3709. "航班日期": "%s" % flight_date_str, "级别": 4}
  3710. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3711. if iii in str(sort_flight_ids_arr):
  3712. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3713. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] == "航前" and "MAN" in str(i[0]):
  3714. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0][0]
  3715. time_str = flight_date_str.split("-")[0] + "/" + time.split("]")[1]
  3716. sendtime = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=90)
  3717. sendtime2 = datetime.datetime.strptime(time_str, "%Y/%m/%d %H:%M")
  3718. if now < sendtime2:
  3719. ii=str(i[0])+str(-2)
  3720. iii = str(i[0]) + str(-1)
  3721. if ii in str(sort_flight_ids_arr):
  3722. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3723. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3724. else:
  3725. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0],"保障时间": "%s" % sendtime, "航班类型": "航前",
  3726. "航班日期": "%s" % flight_date_str, "级别": 1}
  3727. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3728. #print('插入{}'.format(newdic))
  3729. if iii in str(sort_flight_ids_arr):
  3730. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3731. else:
  3732. ii=str(i[0])+str(-2)
  3733. iii = str(i[0]) + str(-1)
  3734. if ii in str(sort_flight_ids_arr):
  3735. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%sendtime2,"航班类型":"'航前'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  3736. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3737. else:
  3738. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % sendtime2, "航班类型": "航前",
  3739. "航班日期": "%s" % flight_date_str, "级别": 4}
  3740. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3741. if iii in str(sort_flight_ids_arr):
  3742. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3743. elif database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "停场":
  3744. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0]
  3745. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3746. ii = str(i[0]) + str(-1)
  3747. iii = str(i[0]) + str(-2)
  3748. if ii in str(sort_flight_ids_arr):
  3749. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'停场'",
  3750. "航班日期": "'%s'" % flight_date_str, "级别": "3"}
  3751. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  3752. else:
  3753. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "停场",
  3754. "航班日期": "%s" % flight_date_str, "级别": 3}
  3755. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3756. if iii in str(sort_flight_ids_arr):
  3757. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3758. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="航后" and "MAN" not in str(i[0]):
  3759. if database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  3760. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] !="" and \
  3761. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  3762. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3763. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3764. ii=str(i[0])+str(-1)
  3765. iii = str(i[0]) + str(-2)
  3766. if ii in str(sort_flight_ids_arr):
  3767. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3768. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3769. else:
  3770. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  3771. "航班日期": "%s" % flight_date_str, "级别": 1}
  3772. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3773. if iii in str(sort_flight_ids_arr):
  3774. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3775. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  3776. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] =="" and \
  3777. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  3778. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  3779. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3780. ii=str(i[0])+str(-1)
  3781. iii = str(i[0]) + str(-2)
  3782. if ii in str(sort_flight_ids_arr):
  3783. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3784. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3785. else:
  3786. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  3787. "航班日期": "%s" % flight_date_str, "级别": 1}
  3788. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3789. if iii in str(sort_flight_ids_arr):
  3790. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3791. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  3792. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and \
  3793. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0] == "" and \
  3794. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]!="" :
  3795. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  3796. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3797. ii=str(i[0])+str(-1)
  3798. iii = str(i[0]) + str(-2)
  3799. if ii in str(sort_flight_ids_arr):
  3800. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  3801. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3802. else:
  3803. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  3804. "航班日期": "%s" % flight_date_str, "级别": 2}
  3805. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3806. if iii in str(sort_flight_ids_arr):
  3807. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3808. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] !="":
  3809. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]
  3810. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3811. ii=str(i[0])+str(-1)
  3812. iii = str(i[0]) + str(-2)
  3813. if ii in str(sort_flight_ids_arr):
  3814. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"3"}
  3815. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3816. else:
  3817. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  3818. "航班日期": "%s" % flight_date_str, "级别": 3}
  3819. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3820. if iii in str(sort_flight_ids_arr):
  3821. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3822. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  3823. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] == "" and \
  3824. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]!="" :
  3825. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3826. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3827. ii=str(i[0])+str(-1)
  3828. iii = str(i[0]) + str(-2)
  3829. if ii in str(sort_flight_ids_arr):
  3830. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  3831. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3832. else:
  3833. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  3834. "航班日期": "%s" % flight_date_str, "级别": 2}
  3835. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3836. if iii in str(sort_flight_ids_arr):
  3837. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3838. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="航后" and "MAN" in str(i[0]):
  3839. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3840. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3841. receivetime2= datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3842. if now < receivetime2:
  3843. ii=str(i[0])+str(-1)
  3844. iii = str(i[0]) + str(-2)
  3845. if ii in str(sort_flight_ids_arr):
  3846. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3847. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3848. else:
  3849. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "航后",
  3850. "航班日期": "%s" % flight_date_str, "级别": 1}
  3851. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3852. if iii in str(sort_flight_ids_arr):
  3853. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3854. else:
  3855. ii=str(i[0])+str(-1)
  3856. iii = str(i[0]) + str(-2)
  3857. if ii in str(sort_flight_ids_arr):
  3858. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'航后'","航班日期":"'%s'"%flight_date_str,"级别":"3"}
  3859. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3860. else:
  3861. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "航后",
  3862. "航班日期": "%s" % flight_date_str, "级别": 3}
  3863. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3864. if iii in str(sort_flight_ids_arr):
  3865. database.deleteSingledata('sortFlight{}'.format(nowDayStr), "编号='%s'" % iii)
  3866. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="短停" and "MAN" not in str(i[0]):
  3867. if database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  3868. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] != "" and \
  3869. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  3870. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3871. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3872. ii=str(i[0])+str(-1)
  3873. if ii in str(sort_flight_ids_arr):
  3874. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3875. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3876. else:
  3877. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  3878. "航班日期": "%s" % flight_date_str, "级别": 1}
  3879. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3880. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]=="" and \
  3881. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] == "" and \
  3882. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  3883. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  3884. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3885. ii=str(i[0])+str(-1)
  3886. if ii in str(sort_flight_ids_arr):
  3887. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3888. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3889. else:
  3890. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  3891. "航班日期": "%s" % flight_date_str, "级别": 1}
  3892. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3893. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  3894. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] =="" and \
  3895. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0] == "" and \
  3896. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0] !="":
  3897. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前计划到达","航班编号='%s'"%i[0])[0][0]
  3898. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3899. ii=str(i[0])+str(-1)
  3900. if ii in str(sort_flight_ids_arr):
  3901. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  3902. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3903. else:
  3904. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  3905. "航班日期": "%s" % flight_date_str, "级别": 2}
  3906. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3907. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] =="" and \
  3908. database.queryTabel("flightinfo{}".format(nowDayStr),"航前实际起飞","航班编号='%s'"%i[0])[0][0] =="" and\
  3909. database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0] !="":
  3910. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3911. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3912. ii=str(i[0])+str(-1)
  3913. if ii in str(sort_flight_ids_arr):
  3914. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"2"}
  3915. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3916. else:
  3917. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  3918. "航班日期": "%s" % flight_date_str, "级别": 2}
  3919. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3920. elif database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0] !="":
  3921. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前实际到达","航班编号='%s'"%i[0])[0][0]
  3922. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3923. ii=str(i[0])+str(-1)
  3924. if ii in str(sort_flight_ids_arr):
  3925. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  3926. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3927. else:
  3928. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  3929. "航班日期": "%s" % flight_date_str, "级别": 4}
  3930. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3931. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="短停" and "MAN" in str(i[0]):
  3932. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计到达","航班编号='%s'"%i[0])[0][0]
  3933. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3934. receivetime2 = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  3935. if now < receivetime2:
  3936. ii=str(i[0])+str(-1)
  3937. if ii in str(sort_flight_ids_arr):
  3938. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"1"}
  3939. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3940. else:
  3941. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停接",
  3942. "航班日期": "%s" % flight_date_str, "级别": 1}
  3943. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  3944. else:
  3945. ii=str(i[0])+str(-1)
  3946. if ii in str(sort_flight_ids_arr):
  3947. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'短停接'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  3948. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  3949. else:
  3950. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "短停接",
  3951. "航班日期": "%s" % flight_date_str, "级别": 4}
  3952. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3953. elif database.queryTabel("flightinfo{}".format(nowDayStr),"航班类型","航班编号='%s'"%i[0])[0][0] =="特后前" and "MAN" not in str(i[0]):
  3954. if database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] == "" and \
  3955. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  3956. 0] != "" and \
  3957. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  3958. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  3959. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3960. ii = str(i[0]) + str(-1)
  3961. if ii in str(sort_flight_ids_arr):
  3962. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  3963. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  3964. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  3965. else:
  3966. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  3967. "航班日期": "%s" % flight_date_str, "级别": 1}
  3968. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3969. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
  3970. 0] == "" and \
  3971. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  3972. 0] == "" and \
  3973. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][0] != "":
  3974. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][0]
  3975. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3976. ii = str(i[0]) + str(-1)
  3977. if ii in str(sort_flight_ids_arr):
  3978. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  3979. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  3980. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  3981. else:
  3982. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  3983. "航班日期": "%s" % flight_date_str, "级别": 1}
  3984. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  3985. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
  3986. 0] == "" and \
  3987. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][
  3988. 0] == "" and \
  3989. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  3990. 0] == "" and \
  3991. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][
  3992. 0] != "":
  3993. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前计划到达", "航班编号='%s'" % i[0])[0][0]
  3994. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  3995. ii = str(i[0]) + str(-1)
  3996. if ii in str(sort_flight_ids_arr):
  3997. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  3998. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  3999. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4000. else:
  4001. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4002. "航班日期": "%s" % flight_date_str, "级别": 2}
  4003. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4004. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][
  4005. 0] == "" and \
  4006. database.queryTabel("flightinfo{}".format(nowDayStr), "航前实际起飞", "航班编号='%s'" % i[0])[0][
  4007. 0] == "" and \
  4008. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][
  4009. 0] != "":
  4010. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4011. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4012. ii = str(i[0]) + str(-1)
  4013. if ii in str(sort_flight_ids_arr):
  4014. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4015. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4016. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4017. else:
  4018. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4019. "航班日期": "%s" % flight_date_str, "级别": 2}
  4020. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4021. elif database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] != "":
  4022. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0]
  4023. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4024. ii = str(i[0]) + str(-1)
  4025. if ii in str(sort_flight_ids_arr):
  4026. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4027. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
  4028. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4029. else:
  4030. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4031. "航班日期": "%s" % flight_date_str, "级别": 4}
  4032. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4033. elif database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][
  4034. 0] == "特后前" and "MAN" in str(i[0]):
  4035. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4036. receivetime = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4037. receivetime2 = datetime.datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
  4038. if now < receivetime2:
  4039. ii = str(i[0]) + str(-1)
  4040. if ii in str(sort_flight_ids_arr):
  4041. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4042. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4043. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4044. else:
  4045. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前接",
  4046. "航班日期": "%s" % flight_date_str, "级别": 1}
  4047. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4048. else:
  4049. ii = str(i[0]) + str(-1)
  4050. if ii in str(sort_flight_ids_arr):
  4051. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime2,
  4052. "航班类型": "'特后前接'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
  4053. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4054. else:
  4055. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "特后前接",
  4056. "航班日期": "%s" % flight_date_str, "级别": 4}
  4057. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4058. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "短停" and "MAN" not in str(i[0]):
  4059. if "[实]" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])):
  4060. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
  4061. receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4062. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4063. ii=str(i[0])+str(-2)
  4064. if ii in str(sort_flight_ids_arr):
  4065. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型":"'短停送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4066. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4067. else:
  4068. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
  4069. "航班日期": "%s" % flight_date_str, "级别": 4}
  4070. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4071. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4072. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] !="" and \
  4073. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4074. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4075. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4076. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4077. ii = str(i[0]) + str(-2)
  4078. if ii in str(sort_flight_ids_arr):
  4079. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'短停送'",
  4080. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4081. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4082. else:
  4083. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
  4084. "航班日期": "%s" % flight_date_str, "级别": 1}
  4085. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4086. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4087. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] =="" and \
  4088. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4089. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4090. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4091. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4092. ii = str(i[0]) + str(-2)
  4093. if ii in str(sort_flight_ids_arr):
  4094. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'短停送'",
  4095. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4096. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4097. else:
  4098. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "短停送",
  4099. "航班日期": "%s" % flight_date_str, "级别": 2}
  4100. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4101. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "短停" and "MAN" in str(i[0]):
  4102. time1 = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4103. receivetime1 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  4104. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
  4105. receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4106. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4107. receivetime2 = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M")
  4108. if now<receivetime1:
  4109. ii = str(i[0]) + str(-2)
  4110. if ii in str(sort_flight_ids_arr):
  4111. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4112. "航班类型": "'短停送'",
  4113. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4114. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4115. else:
  4116. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4117. "航班类型": "短停送",
  4118. "航班日期": "%s" % flight_date_str, "级别": 2}
  4119. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4120. elif receivetime1<now<receivetime2:
  4121. ii = str(i[0]) + str(-2)
  4122. if ii in str(sort_flight_ids_arr):
  4123. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4124. "航班类型": "'短停送'",
  4125. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4126. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4127. else:
  4128. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4129. "航班类型": "短停送",
  4130. "航班日期": "%s" % flight_date_str, "级别": 1}
  4131. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4132. else:
  4133. ii=str(i[0])+str(-2)
  4134. if ii in str(sort_flight_ids_arr):
  4135. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime2,"航班类型":"'短停送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4136. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4137. else:
  4138. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "短停送",
  4139. "航班日期": "%s" % flight_date_str, "级别": 4}
  4140. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4141. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][0] == "特后前" and "MAN" not in str(i[0]):
  4142. if "[实]" in str(database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])):
  4143. time=database.queryTabel("flightinfo{}".format(nowDayStr),"非航前预计起飞","航班编号='%s'"%i[0])[0]
  4144. receivetime_str =flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4145. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4146. ii=str(i[0])+str(-2)
  4147. if ii in str(sort_flight_ids_arr):
  4148. newdic={"编号":"'%s'"%ii,"航班编号":"'%s'"%i[0],"保障时间":"'%s'"%receivetime,"航班类型": "'特后前送'","航班日期":"'%s'"%flight_date_str,"级别":"4"}
  4149. database.lazyUpdateItem("sortFlight{}".format(nowDayStr),newdic,"编号='%s'"%ii)
  4150. else:
  4151. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
  4152. "航班日期": "%s" % flight_date_str, "级别": 4}
  4153. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4154. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4155. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] !="" and \
  4156. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4157. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4158. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4159. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4160. ii = str(i[0]) + str(-2)
  4161. if ii in str(sort_flight_ids_arr):
  4162. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'特后前送'",
  4163. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4164. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4165. else:
  4166. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
  4167. "航班日期": "%s" % flight_date_str, "级别": 1}
  4168. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4169. elif "[实]" not in str(database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])) and \
  4170. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前实际到达", "航班编号='%s'" % i[0])[0][0] =="" and \
  4171. database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0][0] !="":
  4172. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4173. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4174. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4175. ii = str(i[0]) + str(-2)
  4176. if ii in str(sort_flight_ids_arr):
  4177. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime, "航班类型": "'特后前送'",
  4178. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4179. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4180. else:
  4181. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime, "航班类型": "特后前送",
  4182. "航班日期": "%s" % flight_date_str, "级别": 2}
  4183. database.lazyInsertData("sortFlight{}".format(nowDayStr),newdic)
  4184. if database.queryTabel("flightinfo{}".format(nowDayStr), "航班类型", "航班编号='%s'" % i[0])[0][
  4185. 0] == "特后前" and "MAN" in str(i[0]):
  4186. time1 = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计到达", "航班编号='%s'" % i[0])[0][0]
  4187. receivetime1 = datetime.datetime.strptime(time1, "%Y-%m-%d %H:%M:%S")
  4188. time = database.queryTabel("flightinfo{}".format(nowDayStr), "非航前预计起飞", "航班编号='%s'" % i[0])[0]
  4189. receivetime_str = flight_date_str.split("-")[0] + "/" + time[0].split("]")[1]
  4190. receivetime = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M") - datetime.timedelta(
  4191. minutes=25)
  4192. receivetime2 = datetime.datetime.strptime(receivetime_str, "%Y/%m/%d %H:%M")
  4193. if now < receivetime1:
  4194. ii = str(i[0]) + str(-2)
  4195. if ii in str(sort_flight_ids_arr):
  4196. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4197. "航班类型": "'特后前送'",
  4198. "航班日期": "'%s'" % flight_date_str, "级别": "2"}
  4199. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4200. else:
  4201. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4202. "航班类型": "特后前送",
  4203. "航班日期": "%s" % flight_date_str, "级别": 2}
  4204. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4205. elif receivetime1 < now < receivetime2:
  4206. ii = str(i[0]) + str(-2)
  4207. if ii in str(sort_flight_ids_arr):
  4208. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime,
  4209. "航班类型": "'特后前送'",
  4210. "航班日期": "'%s'" % flight_date_str, "级别": "1"}
  4211. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4212. else:
  4213. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime,
  4214. "航班类型": "特后前送",
  4215. "航班日期": "%s" % flight_date_str, "级别": 1}
  4216. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4217. else:
  4218. ii = str(i[0]) + str(-2)
  4219. if ii in str(sort_flight_ids_arr):
  4220. newdic = {"编号": "'%s'" % ii, "航班编号": "'%s'" % i[0], "保障时间": "'%s'" % receivetime2,
  4221. "航班类型": "'特后前送'", "航班日期": "'%s'" % flight_date_str, "级别": "4"}
  4222. database.lazyUpdateItem("sortFlight{}".format(nowDayStr), newdic, "编号='%s'" % ii)
  4223. else:
  4224. newdic = {"编号": "%s" % ii, "航班编号": "%s" % i[0], "保障时间": "%s" % receivetime2, "航班类型": "特后前送",
  4225. "航班日期": "%s" % flight_date_str, "级别": 4}
  4226. database.lazyInsertData("sortFlight{}".format(nowDayStr), newdic)
  4227. database.FunctionCommit()
  4228. except Exception:
  4229. dingding_alert(traceback.format_exc())
  4230. database.FunctionCommit()
  4231. print(datetime.datetime.now(),'[数据库操作]结束排序')
  4232. def checkWorkerlaod(database:flightDB, workload:flightDB,nowDayStr1,nowDay_11):
  4233. try:
  4234. #需要初始化表格
  4235. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  4236. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  4237. day=[nowDay_1,nowDay]
  4238. nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  4239. #nowDayStr_search=datetime.datetime.strptime(str("2023-06-11 00:00:00"),"%Y-%m-%d %H:%M:%S")
  4240. yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  4241. workernames_arr=[]
  4242. workernames1=database.getSingledata('姓名','pglist%s'%nowDayStr1)
  4243. if len(workernames1) != 0:
  4244. for i in workernames1:
  4245. workernames_arr.append(i[0])
  4246. workernames2 = database.getSingledata('姓名', 'pglist%s' % nowDay_11)
  4247. if len(workernames2) != 0:
  4248. for i in workernames2:
  4249. workernames_arr.append(i[0])
  4250. for worker in workernames_arr:
  4251. if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker))!= 0:
  4252. worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
  4253. else:
  4254. worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
  4255. # worker_number = a if len(a) !=0 else ""
  4256. single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
  4257. single_worker_load_ids_arr = []
  4258. if len(single_worker_load_ids) != 0:
  4259. for l in single_worker_load_ids:
  4260. single_worker_load_ids_arr.append(l[0])
  4261. for nowDayStr in day:
  4262. worker_laod_ids=database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "维修人员 like '%{}%'".format(worker))
  4263. worker_laod_ids_arr = []
  4264. if len(worker_laod_ids)!= 0:
  4265. for j in worker_laod_ids:
  4266. worker_laod_ids_arr.append(j[0])
  4267. if len(worker_laod_ids_arr) != 0:
  4268. for k in worker_laod_ids_arr:
  4269. TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'"%k)[0][0]
  4270. #TYPE = a[0] if len(a) !=0 else ""
  4271. acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
  4272. #acno = a[0] if len(a) !=0 else ""
  4273. bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
  4274. bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
  4275. #bay = a[0] if len(a) !=0 else ""
  4276. flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
  4277. flight_id_1=str(str(flight_id))+str("-1") #接机保障标志
  4278. flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
  4279. #print(flight_id_1)
  4280. #flight_id = a[0] if len(a) !=0 else ""
  4281. flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
  4282. #flight_date = a[0] if len(a) !=0 else ""
  4283. if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4284. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4285. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4286. endtime=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前实际到达', "航班编号='%s'"%k)[0][0]
  4287. if flight_id_1 in single_worker_load_ids_arr:
  4288. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4289. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4290. else:
  4291. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4292. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4293. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4294. elif TYPE == '航前' and database.queryTabel('flightinfo{}'.format(nowDayStr), '航前预计起飞', "航班编号 ='%s'"%k)[0][0] != "":
  4295. endtime_ap = database.queryTabel('flightinfo{}'.format(nowDayStr),'航前实际起飞', "航班编号='{}'".format(k))[0][0]
  4296. STD_ap=database.queryTabel('flightinfo{}'.format(nowDayStr),'航前预计起飞', "航班编号='{}'".format(k))[0]
  4297. #STD_time_str =flight_date[0].split("-")[0] + "/" + STD_ap[0].split("]")[1]
  4298. #print(STD_ap)
  4299. starttime_ap = datetime.datetime.strptime(STD_ap[0], "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=90)
  4300. if flight_id_1 in single_worker_load_ids_arr:
  4301. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay1, "开始时间": "'%s'"%starttime_ap, "结束时间": "'%s'"%endtime_ap, "航班类型": "'%s'"%TYPE}
  4302. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='%s'"%flight_id_1)
  4303. else:
  4304. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s"%bay1, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime_ap,
  4305. "结束时间": "%s" % endtime_ap, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4306. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4307. elif TYPE == '航后' and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4308. eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
  4309. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4310. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) == "8":
  4311. endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4312. else:
  4313. endtime=""
  4314. if flight_id_1 in single_worker_load_ids_arr:
  4315. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime,
  4316. "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4317. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_1))
  4318. else:
  4319. newdic = {"编号": "%s" % flight_id_1, "机号": "%s" % acno, "机位": "%s" % bay,
  4320. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4321. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE, "人员状态": ""}
  4322. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4323. elif TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4324. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4325. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4326. if "[实]" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]):
  4327. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4328. endtime_str1 =flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4329. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4330. else:
  4331. endtime = ""
  4332. if flight_id_1 in single_worker_load_ids_arr:
  4333. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4334. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4335. else:
  4336. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4337. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4338. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4339. if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)) != 0:
  4340. worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
  4341. else:
  4342. worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
  4343. single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
  4344. single_worker_load_ids_arr = []
  4345. if len(single_worker_load_ids) != 0:
  4346. for l in single_worker_load_ids:
  4347. single_worker_load_ids_arr.append(l[0])
  4348. FX_laod_ids = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "放行人员 like '%{}%'".format(worker))
  4349. FX_laod_ids_arr = []
  4350. if len(FX_laod_ids) != 0:
  4351. for j in FX_laod_ids:
  4352. FX_laod_ids_arr.append(j[0])
  4353. if len(FX_laod_ids_arr) != 0:
  4354. for k in FX_laod_ids_arr:
  4355. TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'"%k)[0][0]
  4356. #TYPE = a[0] if len(a) !=0 else ""
  4357. acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
  4358. #acno = a[0] if len(a) !=0 else ""
  4359. bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
  4360. bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
  4361. #bay = a[0] if len(a) !=0 else ""
  4362. flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
  4363. flight_id_1=str(str(flight_id))+str("-1") #接机保障标志
  4364. flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
  4365. #print(flight_id_1)
  4366. #flight_id = a[0] if len(a) !=0 else ""
  4367. flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
  4368. #flight_date = a[0] if len(a) !=0 else ""
  4369. if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4370. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4371. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4372. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "7":
  4373. endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4374. else:
  4375. endtime = ""
  4376. if flight_id_1 in single_worker_load_ids_arr:
  4377. if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'"%flight_id_1)[0][0] =="":
  4378. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4379. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4380. else:
  4381. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4382. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4383. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4384. elif TYPE == '航前' and database.queryTabel('flightinfo{}'.format(nowDayStr), '航前预计起飞', "航班编号 ='%s'"%k)[0][0] != "":
  4385. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "7":
  4386. endtime_ap = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4387. else:
  4388. endtime_ap = ""
  4389. STD_ap=database.queryTabel('flightinfo{}'.format(nowDayStr),'航前预计起飞', "航班编号='{}'".format(k))[0]
  4390. #STD_time_str =flight_date[0].split("-")[0] + "/" + STD_ap[0].split("]")[1]
  4391. #print(STD_ap)
  4392. starttime_ap = datetime.datetime.strptime(STD_ap[0], "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=90)
  4393. if flight_id_1 in single_worker_load_ids_arr:
  4394. if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'" % flight_id_1)[0][0] == "":
  4395. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay1, "开始时间": "'%s'"%starttime_ap, "结束时间": "'%s'"%endtime_ap, "航班类型": "'%s'"%TYPE}
  4396. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='%s'"%flight_id_1)
  4397. else:
  4398. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s"%bay1, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime_ap,
  4399. "结束时间": "%s" % endtime_ap, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4400. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4401. elif TYPE == '航后' and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4402. eta_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'" % k)[0][0]
  4403. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4404. if str(database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态', "航班编号='%s'" % k)[0][0]) >= "8":
  4405. endtime = database.queryTabel('flightinfo{}'.format(nowDayStr), '维修状态时间', "航班编号='%s'" % k)[0][0]
  4406. else:
  4407. endtime=""
  4408. if flight_id_1 in single_worker_load_ids_arr:
  4409. if workload.queryTabel('workload%s' % worker_number, '结束时间', "编号 ='%s'" % flight_id_1)[0][0] == "":
  4410. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime,
  4411. "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4412. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_1))
  4413. else:
  4414. newdic = {"编号": "%s" % flight_id_1, "机号": "%s" % acno, "机位": "%s" % bay,
  4415. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4416. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE, "人员状态": ""}
  4417. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4418. elif TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0] != "":
  4419. eta_str=database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计到达', "航班编号 ='%s'"%k)[0][0]
  4420. starttime = datetime.datetime.strptime(eta_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  4421. if "[实]" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]):
  4422. #print(flight_date)
  4423. #print(endtime_str)
  4424. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4425. #print(flight_date.split("-")[0])
  4426. #print(endtime_str.split("]")[1])
  4427. endtime_str1 =flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4428. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4429. else:
  4430. endtime = ""
  4431. if flight_id_1 in single_worker_load_ids_arr:
  4432. newdic = {"机号": "'%s'"%acno, "机位": "'%s'"%bay, "开始时间": "'%s'"%starttime, "结束时间": "'%s'"%endtime,"航班类型": "'%s'"%TYPE}
  4433. workload.lazyUpdateItem('workload%s'%worker_number,newdic,"编号='{}'".format(flight_id_1))
  4434. else:
  4435. newdic = {"编号":"%s"%flight_id_1,"机号": "%s" % acno, "机位": "%s" % bay, "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4436. "结束时间": "%s" % endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,"人员状态":""}
  4437. workload.lazyInsertData('workload%s'%worker_number, newdic)
  4438. if len(database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)) != 0:
  4439. worker_number = database.queryTabel('pglist%s' % nowDayStr1, '工号', "姓名 ='%s'" % worker)[0]
  4440. else:
  4441. worker_number = database.queryTabel('pglist%s' % nowDay_11, '工号', "姓名 ='%s'" % worker)[0]
  4442. single_worker_load_ids = workload.getSingledata('编号', 'workload%s' % worker_number)
  4443. single_worker_load_ids_arr = []
  4444. if len(single_worker_load_ids) != 0:
  4445. for l in single_worker_load_ids:
  4446. single_worker_load_ids_arr.append(l[0])
  4447. ECCJ_laod_ids = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "二送人员 like '%{}%'".format(worker))
  4448. ECSJ_laod_ids_arr = []
  4449. if len(ECCJ_laod_ids) != 0:
  4450. for j in ECCJ_laod_ids:
  4451. ECSJ_laod_ids_arr.append(j[0])
  4452. if len(ECSJ_laod_ids_arr) != 0:
  4453. for k in ECSJ_laod_ids_arr:
  4454. TYPE = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班类型', "航班编号 ='%s'" % k)[0][0]
  4455. # TYPE = a[0] if len(a) !=0 else ""
  4456. acno = database.queryTabel('flightinfo{}'.format(nowDayStr), '机号', "航班编号 ='%s'" % k)[0][0]
  4457. # acno = a[0] if len(a) !=0 else ""
  4458. bay = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前进港机位', "航班编号 ='%s'" % k)[0][0]
  4459. bay1 = database.queryTabel('flightinfo{}'.format(nowDayStr), '航前离港机位', "航班编号 ='%s'" % k)[0][0]
  4460. # bay = a[0] if len(a) !=0 else ""
  4461. flight_id = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班编号', "航班编号 ='%s'" % k)[0][0]
  4462. flight_id_1 = str(str(flight_id)) + str("-1") # 接机保障标志
  4463. flight_id_2 = str(str(flight_id)) + str("-2") # 接机保障标志
  4464. # print(flight_id_1)
  4465. # flight_id = a[0] if len(a) !=0 else ""
  4466. flight_date = database.queryTabel('flightinfo{}'.format(nowDayStr), '航班日期', "航班编号 ='%s'" % k)[0][0]
  4467. # flight_date = a[0] if len(a) !=0 else ""
  4468. if TYPE == "短停" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0] != "":
  4469. if "实" not in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4470. starttime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4471. starttime_str1 = flight_date.split("-")[0] + "/" + starttime_str.split("]")[1]
  4472. starttime = datetime.datetime.strptime(starttime_str1, "%Y/%m/%d %H:%M")-datetime.timedelta(minutes=25)
  4473. if flight_id_2 in single_worker_load_ids_arr:
  4474. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime, "航班类型": "'%s'" % TYPE}
  4475. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4476. else:
  4477. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4478. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4479. "结束时间": "" , "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4480. "人员状态": ""}
  4481. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4482. if "实" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4483. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4484. endtime_str1 = flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4485. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4486. starttime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4487. if flight_id_2 in single_worker_load_ids_arr:
  4488. if workload.queryTabel('workload%s' % worker_number, "开始时间", "编号='{}'".format(flight_id_2))[0][0] != "":
  4489. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4490. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4491. else:
  4492. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay,"开始时间": "'%s'" % starttime, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4493. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4494. else:
  4495. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4496. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4497. "结束时间": "%s"%endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4498. "人员状态": ""}
  4499. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4500. if TYPE == "特后前" and database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0] != "":
  4501. if "实" not in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4502. starttime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4503. starttime_str1 = flight_date.split("-")[0] + "/" + starttime_str.split("]")[1]
  4504. starttime = datetime.datetime.strptime(starttime_str1, "%Y/%m/%d %H:%M")-datetime.timedelta(minutes=25)
  4505. if flight_id_2 in single_worker_load_ids_arr:
  4506. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "开始时间": "'%s'" % starttime, "航班类型": "'%s'" % TYPE}
  4507. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4508. else:
  4509. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4510. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4511. "结束时间": "" , "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4512. "人员状态": ""}
  4513. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4514. if "实" in str(database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号 ='%s'" % k)[0][0]):
  4515. endtime_str = database.queryTabel('flightinfo{}'.format(nowDayStr), '非航前预计起飞', "航班编号='%s'" % k)[0][0]
  4516. endtime_str1 = flight_date.split("-")[0] + "/" + endtime_str.split("]")[1]
  4517. endtime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M")
  4518. starttime = datetime.datetime.strptime(endtime_str1, "%Y/%m/%d %H:%M") - datetime.timedelta(minutes=25)
  4519. if flight_id_2 in single_worker_load_ids_arr:
  4520. if workload.queryTabel('workload%s' % worker_number, "开始时间", "编号='{}'".format(flight_id_2))[0][0] != "":
  4521. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4522. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4523. else:
  4524. newdic = {"机号": "'%s'" % acno, "机位": "'%s'" % bay,"开始时间": "'%s'" % starttime, "结束时间": "'%s'" % endtime, "航班类型": "'%s'" % TYPE}
  4525. workload.lazyUpdateItem('workload%s' % worker_number, newdic, "编号='{}'".format(flight_id_2))
  4526. else:
  4527. newdic = {"编号": "%s" % flight_id_2, "机号": "%s" % acno, "机位": "%s" % bay,
  4528. "航班编号": "%s" % flight_id, "开始时间": "%s" % starttime,
  4529. "结束时间": "%s"%endtime, "保障日期": "%s" % flight_date, "航班类型": "%s" % TYPE,
  4530. "人员状态": ""}
  4531. workload.lazyInsertData('workload%s' % worker_number, newdic)
  4532. single_worker_load_twoday_ids = workload.queryTabel('workload%s' % worker_number, '编号',"保障日期='{}'or 保障日期='{}'".format(nowDayStr_search,yesterday_search))
  4533. single_worker_load_twoday_ids_arr = []
  4534. if len(single_worker_load_twoday_ids) != 0:
  4535. for ll in single_worker_load_twoday_ids:
  4536. single_worker_load_twoday_ids_arr.append(ll[0])
  4537. worker_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号',"维修人员 like '%{}%'".format(worker))
  4538. worker_laod_ids_twoday_arr = [] # 两天的量
  4539. if len(worker_laod_ids) != 0:
  4540. for j in worker_laod_ids:
  4541. worker_laod_ids_twoday_arr.append(j[0])
  4542. worker_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"维修人员 like '%{}%'".format(worker))
  4543. if len(worker_laod_ids_yesterday) != 0:
  4544. for m in worker_laod_ids_yesterday:
  4545. worker_laod_ids_twoday_arr.append(m[0])
  4546. FX_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号', "放行人员 like '%{}%'".format(worker))
  4547. if len(FX_laod_ids) != 0:
  4548. for j in FX_laod_ids:
  4549. worker_laod_ids_twoday_arr.append(j[0])
  4550. FX_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"放行人员 like '%{}%'".format(worker))
  4551. if len(FX_laod_ids_yesterday) != 0:
  4552. for m in FX_laod_ids_yesterday:
  4553. worker_laod_ids_twoday_arr.append(m[0])
  4554. ECSJ_laod_ids = database.queryTabel('flightinfo{}'.format(nowDay), '航班编号', "二送人员 like '%{}%'".format(worker))
  4555. if len(ECSJ_laod_ids) != 0:
  4556. for j in ECSJ_laod_ids:
  4557. worker_laod_ids_twoday_arr.append(j[0])
  4558. #暂无昨日table,待完善后启用两日查询
  4559. ECCJ_laod_ids_yesterday = database.queryTabel('flightinfo{}'.format(nowDay_1), '航班编号',"二送人员 like '%{}%'".format(worker))
  4560. if len(ECCJ_laod_ids_yesterday) != 0:
  4561. for m in ECCJ_laod_ids_yesterday:
  4562. worker_laod_ids_twoday_arr.append(m[0])
  4563. for kk in single_worker_load_twoday_ids_arr:
  4564. if str(str(kk)[:-2]) not in str(worker_laod_ids_twoday_arr):
  4565. workload.deleteSingledata('workload%s' % worker_number, "编号='{}'".format(kk))
  4566. workload.FunctionCommit()
  4567. except Exception:
  4568. dingding_alert(traceback.format_exc())
  4569. def initAuthority(database:flightDB):
  4570. try:
  4571. fdb = database
  4572. primaryKey = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'
  4573. labelKey = ['登录名', '密码', '权限', '使用人']
  4574. dic = {}
  4575. for key in labelKey:
  4576. dic[key] = 'text not null'
  4577. fdb.initTable('loginTable', 'ID', primaryKey, dic)
  4578. except Exception:
  4579. dingding_alert(traceback.format_exc())
  4580. def insertDataToAuthority(database:flightDB):
  4581. try:
  4582. dataDic = {}
  4583. dataDic['登录名'] = 'admin'
  4584. dataDic['密码'] = 'admin123'
  4585. dataDic['权限'] = '0'
  4586. dataDic['使用人'] = '开发'
  4587. rest = database.queryTabel('loginTable', '*', "登录名='admin'")
  4588. #print(rest)
  4589. if len(rest) == 0:
  4590. database.insertData('loginTable', dataDic)
  4591. except Exception:
  4592. dingding_alert(traceback.format_exc())
  4593. def insertWorkjob(database:flightDB,workjobdata,taskid):
  4594. try:
  4595. A=["MDTITLE_C","WORKSTEP","BASE_CODE","PLANSTD"]
  4596. num=1
  4597. MDTITLE_C=""
  4598. WORKSTEP=""
  4599. PLANSTD=""
  4600. BASE_CODE_now=""
  4601. if len(workjobdata) != 0:
  4602. for row in workjobdata:
  4603. MDTITLE_C_now=row["MDTITLE_C"] if "MDTITLE_C" in row.keys() else ""
  4604. WORKSTEP_now = row["WORKSTEP"] if "WORKSTEP" in row.keys() else ""
  4605. BASE_CODE_now = row["BASE_CODE"] if "BASE_CODE" in row.keys() else ""
  4606. PLANSTD_now = row["PLANSTD"] if "PLANSTD" in row.keys() else ""
  4607. if MDTITLE_C !="":
  4608. MDTITLE_C=MDTITLE_C+"\n------------------------------------------------\n"+"工作包%s内容:"%num+"\n"+MDTITLE_C_now
  4609. WORKSTEP=WORKSTEP+"\n------------------------------------------------\n"+"工作包%s步骤:"%num+"\n"+WORKSTEP_now
  4610. PLANSTD=PLANSTD+"\n------------------------------------------------\n"+"工作包%s计划开始时间:"%num+"\n"+PLANSTD_now
  4611. else:
  4612. MDTITLE_C ="工作包%s内容:" % num + "\n" + MDTITLE_C_now
  4613. WORKSTEP ="工作包%s步骤:" % num + "\n" + WORKSTEP_now
  4614. PLANSTD ="工作包%s计划开始时间:" % num + "\n" + PLANSTD_now
  4615. num+=1
  4616. newdic={"基地":"'%s'"%BASE_CODE_now,"开始时间":"'%s'"%PLANSTD,"项目描述":"'%s'"%MDTITLE_C.replace("\"","*").replace("#","*").replace("\\",";").replace("\'","*").replace("/","、"),"工作步骤":"'%s'"%WORKSTEP.replace("\'","*").replace("\\",";").replace("/","、").replace("\"","*").replace("#","*")}
  4617. database.lazyUpdateItem('workjob', newdic, "任务编号='%s'" %taskid)
  4618. res={"返回值":"ok"}
  4619. database.FunctionCommit()
  4620. return res
  4621. except Exception:
  4622. dingding_alert(traceback.format_exc())
  4623. res = {"返回值": "fail"}
  4624. database.FunctionCommit()
  4625. return res
  4626. def getWorkjobInfo(database:flightDB,taskid):
  4627. try:
  4628. res={}
  4629. infos=database.queryTabel('workjob','*',"任务编号 ='%s'"%taskid)
  4630. if len(infos) != 0:
  4631. res["taskids"]=infos[0][1]
  4632. res["acno"] = infos[0][8]
  4633. res["taskType"] = infos[0][10]
  4634. res["actype"] = infos[0][9]
  4635. res["startDate"] = infos[0][2]
  4636. res["endDate"] = infos[0][3]
  4637. return res
  4638. except Exception:
  4639. dingding_alert(traceback.format_exc())
  4640. def update_Pglist(database:flightDB,datatime: str,bc:str,jsonData):
  4641. try:
  4642. nowDayStr = datatime
  4643. newdic={}
  4644. database.deleteSingledata("pglist{}".format(nowDayStr), "班次='%s'" % bc)
  4645. names=[]
  4646. for row in jsonData:
  4647. if "SHIFT" in row.keys() and row["SHIFT"]==bc and row["NAME"] not in names:
  4648. for col in row:
  4649. if col in pglistLabel2en.keys():
  4650. newdic[pglistLabel2en[col]]=row[col]
  4651. database.lazyInsertData("pglist{}".format(nowDayStr),newdic)
  4652. names = row["NAME"]
  4653. database.FunctionCommit()
  4654. except Exception:
  4655. database.FunctionCommit()
  4656. dingding_alert(traceback.format_exc())
  4657. def get_empNos_phoone(database:flightDB,name):
  4658. try:
  4659. infos={}
  4660. info=database.queryTabel('workerinfo',"*","姓名='%s'"%name)
  4661. if len(info) != 0:
  4662. infos={"工号":'%s'%info[0][0],"电话":"%s"%info[0][5]}
  4663. return infos
  4664. except Exception:
  4665. dingding_alert(traceback.format_exc())
  4666. def callon(fdb:flightDB,phonenum):
  4667. try:
  4668. now = datetime.datetime.now()
  4669. now1=datetime.datetime.now()- datetime.timedelta(seconds=5)
  4670. if phonenum !="" and phonenum !=None:
  4671. calllist = fdb.sort_queryTable2("航班编号", "Calllist", "电话 ='%s' and 接通时间 =''"%phonenum, "拨号次数", "ASC", "创建时间", "ASC")
  4672. if len(calllist) != 0:
  4673. lasttime = fdb.sort_queryTable("接通时间", "Calllist", "接通时间 !='' and 接通时间 not like '%人工%'", "接通时间", "desc")
  4674. #print("lasttime", lasttime[0][0])
  4675. if len(lasttime) == 0 or(len(lasttime) != 0 and now1 > datetime.datetime.strptime(lasttime[0][0][:19],"%Y-%m-%d %H:%M:%S")):
  4676. newdic = {"接通时间": "'%s'" % now}
  4677. fdb.upDateItem("Calllist", newdic, "航班编号='%s'" % calllist[0][0])
  4678. except Exception:
  4679. dingding_alert(traceback.format_exc())
  4680. def calltry(fdb:flightDB,ip,token):
  4681. try:
  4682. #print("calltry")
  4683. #print(ip,token)
  4684. calllist=fdb.sort_queryTable2("*","Calllist","接通时间 ='' and 拨号次数<4","拨号次数","ASC","创建时间","ASC")
  4685. if len(calllist) != 0:
  4686. phone_num=calllist[0][1]
  4687. calltime=int((fdb.queryTabel("Calllist","拨号次数","航班编号='%s'"%calllist[0][0]))[0][0])+1
  4688. newdic={"拨号次数":"%s"%calltime}
  4689. fdb.upDateItem("Calllist",newdic,"航班编号='%s'"%calllist[0][0])
  4690. try:
  4691. data = {"PHB_AutoDialNumber": phone_num,
  4692. "ReturnPage": "/contacts.htm",
  4693. "AutoDialSubmit": "submit",
  4694. "PHB_AutoDialLine": "1"
  4695. }
  4696. header = {
  4697. "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",
  4698. "Connection": "keep-alive",
  4699. "Cookie": token
  4700. }
  4701. requests.post(url="http://%s/contacts.htm" % ip, data=data, headers=header)
  4702. except Exception:
  4703. dingding_alert(traceback.format_exc())
  4704. print(datetime.datetime.now(),"[数据中心]拨号失败")
  4705. except Exception:
  4706. print(traceback.format_exc())
  4707. dingding_alert(traceback.format_exc())
  4708. def calledChecked(fdb: flightDB):
  4709. try:
  4710. now=datetime.datetime.now()
  4711. now_5 = now - datetime.timedelta(minutes=8)
  4712. callist = fdb.queryTabel("Calllist", "*", "接通时间 ='' and (创建时间<'%s' or CAST(拨号次数 AS integer)>3)"%now_5)
  4713. if len(callist) != 0:
  4714. for i in callist:
  4715. if len(fdb.queryTabel("logs", "航班编号", "航班编号 ='%s' and 处理时间=''"%i[0])) == 0:
  4716. newdic = {"航班编号": "%s" %i[0], "警告信息": "%s %s超过自动联系超过8min或连续拨号超过3次无响应,请人工处理!!"%(i[4],i[3]), "信息状态": "", "提示信息": "",
  4717. "产生时间": "%s" % now, "处理人": "", "处理时间": "", "变更字段": "无法联系", "显示对象": "", "提示内容": ""}
  4718. fdb.lazyInsertData('logs', newdic)
  4719. newdic1={"接通时间":"'%s推送人工处理'"%now}
  4720. fdb.lazyUpdateItem("Calllist",newdic1,"航班编号='%s'"%i[0])
  4721. fdb.FunctionCommit()
  4722. except Exception:
  4723. fdb.FunctionCommit()
  4724. dingding_alert(traceback.format_exc())
  4725. def get_empNos(database:flightDB,dict:dict):
  4726. try:
  4727. date=judge_bc()["date"]
  4728. date_str=judge_bc()["date"][0:4]+"-"+judge_bc()["date"][4:6]+"-"+judge_bc()["date"][6:]
  4729. bc = judge_bc()["bc"]
  4730. faillist=[]
  4731. WXempNos = ""
  4732. ESempNos = ""
  4733. FXempNos = ""
  4734. WX = ""
  4735. ES = ""
  4736. FX = ""
  4737. wxkey = ["工1", "工2", "工3/送1", "工4/送2"]
  4738. eskey = [ "工3/送1", "工4/送2"]
  4739. for i in wxkey:
  4740. if dict[i] != "":
  4741. aa = []
  4742. if bc == "A":
  4743. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
  4744. elif bc == "B":
  4745. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
  4746. if len(aa) != 0 and WXempNos == "":
  4747. if aa[0][0] !="":
  4748. WXempNos = str(aa[0][0])
  4749. else:
  4750. faillist.append(dict[i])
  4751. elif len(aa) != 0 and WXempNos != "":
  4752. if aa[0][0] != "":
  4753. WXempNos =WXempNos+","+str(aa[0][0])
  4754. else:
  4755. faillist.append(dict[i])
  4756. elif len(aa) == 0:
  4757. faillist.append(dict[i])
  4758. if dict[i] != "" and WX == "":
  4759. WX=dict[i]
  4760. elif dict[i] != "" and WX != "":
  4761. WX=WX+","+dict[i]
  4762. for i in eskey:
  4763. if dict[i] != "":
  4764. aa = []
  4765. if bc == "A":
  4766. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
  4767. elif bc == "B":
  4768. aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
  4769. if len(aa) != 0 and ESempNos == "":
  4770. if aa[0][0] !="":
  4771. ESempNos = str(aa[0][0])
  4772. else:
  4773. faillist.append(dict[i])
  4774. elif len(aa) != 0 and ESempNos != "":
  4775. if aa[0][0] != "":
  4776. ESempNos =ESempNos+","+str(aa[0][0])
  4777. else:
  4778. faillist.append(dict[i])
  4779. elif len(aa) == 0:
  4780. faillist.append(dict[i])
  4781. if dict[i] != "" and ES == "":
  4782. ES=dict[i]
  4783. elif dict[i] != "" and ES != "":
  4784. ES=ES+","+dict[i]
  4785. if dict["放行"] != "":
  4786. aa = []
  4787. if bc == "A":
  4788. aa=database.queryTabel("pglist{}".format(date),"工号","班次='A' and 姓名='%s'"%dict["放行"])
  4789. elif bc == "B":
  4790. aa=database.queryTabel("pglist{}".format(date),"工号","班次='B' and 姓名='%s'"%dict["放行"])
  4791. if len(aa) != 0 and FXempNos == "":
  4792. if aa[0][0] != "":
  4793. FXempNos = str(aa[0][0])
  4794. else:
  4795. faillist.append(dict["放行"])
  4796. elif len(aa) != 0 and FXempNos != "":
  4797. if aa[0][0] != "":
  4798. FXempNos = FXempNos + "," + str(aa[0][0])
  4799. else:
  4800. faillist.append(dict["放行"])
  4801. elif len(aa) == 0:
  4802. faillist.append(dict["放行"])
  4803. FX=dict["放行"]
  4804. if WXempNos =="" and FXempNos=="" and ESempNos=="":
  4805. dict1={"code":"fail","WXempNos":"","FXempNos":"","ESempNos":"","faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
  4806. elif faillist=="":
  4807. dict1 = {"code": "ok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
  4808. elif faillist !="":
  4809. dict1 = {"code": "justok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
  4810. return dict1
  4811. except Exception:
  4812. dingding_alert(traceback.format_exc())
  4813. def dealLogs(database:flightDB,name:str,number:str):
  4814. try:
  4815. now=datetime.datetime.now()
  4816. nowDay = datetime.datetime.now()
  4817. nowDayStr = nowDay.strftime("%Y%m%d")
  4818. id=number
  4819. newdic={"处理人":"'%s'"%name,"处理时间":"'%s'"%now}
  4820. database.upDateItem('logs',newdic,"编号='%s'"%id)
  4821. except Exception:
  4822. dingding_alert(traceback.format_exc())
  4823. def mandealAllLogs(database:flightDB,name:str,mode):
  4824. try:
  4825. if mode =="norm":
  4826. now=datetime.datetime.now()
  4827. clear=database.queryTabel('logs',"编号","警告信息 !='' and 处理时间 ='' and 变更字段 !='人工待办' and 变更字段 !='准备组任务' ")
  4828. newdic = {"处理人": "'%s'" % name, "处理时间": "'%s'" % now,"信息状态":"'人工一键处理'"}
  4829. if len(clear) != 0:
  4830. for i in clear:
  4831. database.lazyUpdateItem('logs',newdic,"编号='%s'"%i[0])
  4832. elif mode == "super":
  4833. now = datetime.datetime.now()
  4834. clear = database.queryTabel('logs', "编号", "警告信息 !='' and 处理时间 ='' and 变更字段 !='人工待办'")
  4835. newdic = {"处理人": "'%s'" % name, "处理时间": "'%s'" % now, "信息状态": "'人工一键处理'"}
  4836. if len(clear) != 0:
  4837. for i in clear:
  4838. database.lazyUpdateItem('logs', newdic, "编号='%s'" % i[0])
  4839. database.FunctionCommit()
  4840. except Exception:
  4841. dingding_alert(traceback.format_exc())
  4842. database.FunctionCommit()
  4843. def getFlightData(database:flightDB,*args):
  4844. try:
  4845. nowDay = datetime.datetime.now()
  4846. nowDayStr = nowDay.strftime("%Y%m%d")
  4847. if args!=():
  4848. flightData = database.getAlldata('flightinfo{}'.format(args[0]))
  4849. else:
  4850. flightData = database.getAlldata('flightinfo{}'.format(nowDayStr))
  4851. return flightData
  4852. except Exception:
  4853. dingding_alert(traceback.format_exc())
  4854. def getSortFlightdata(fdb:flightDB, datatime:str,tablename:str):
  4855. try:
  4856. nowDayStr = datatime
  4857. sortData = fdb.sortTable('{}{}'.format(tablename,nowDayStr), '级别,保障时间','asc')
  4858. return sortData
  4859. except Exception:
  4860. dingding_alert(traceback.format_exc())
  4861. if __name__ == '__main__':
  4862. fdb = flightDB(host=host,
  4863. port=port,
  4864. user=user,
  4865. password=password,
  4866. database=databaseflightDB4
  4867. )
  4868. loginDB = flightDB(host=host,
  4869. port=port,
  4870. user=user,
  4871. password=password,
  4872. database=databaseflightDB4
  4873. )