GeneralMethod.cs 303 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522
  1. 
  2. using Aspose.Cells;
  3. using Aspose.Words;
  4. using Aspose.Words.Layout;
  5. using Aspose.Words.Saving;
  6. using Aspose.Words.Tables;
  7. using Dm.util;
  8. using Microsoft.AspNetCore.SignalR;
  9. using Microsoft.International.Converters.PinYinConverter;
  10. using NodaTime;
  11. using NPOI.OpenXmlFormats.Vml;
  12. using OASystem.API.OAMethodLib.File;
  13. using OASystem.API.OAMethodLib.Hub.HubClients;
  14. using OASystem.API.OAMethodLib.Hub.Hubs;
  15. using OASystem.API.OAMethodLib.JuHeAPI;
  16. using OASystem.API.OAMethodLib.KiMiApi;
  17. using OASystem.API.OAMethodLib.SignalR.Hubs;
  18. using OASystem.Domain.AesEncryption;
  19. using OASystem.Domain.Dtos.Groups;
  20. using OASystem.Domain.Entities.Customer;
  21. using OASystem.Domain.Entities.Financial;
  22. using OASystem.Domain.Entities.Groups;
  23. using OASystem.Domain.ViewModels.Financial;
  24. using OASystem.Domain.ViewModels.Groups;
  25. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  26. using OASystem.Domain.ViewModels.Statistics;
  27. using OASystem.Infrastructure.Repositories.CRM;
  28. using OASystem.Infrastructure.Repositories.Groups;
  29. using System.Data;
  30. using System.IdentityModel.Tokens.Jwt;
  31. using System.Security.Claims;
  32. namespace OASystem.API.OAMethodLib
  33. {
  34. public static class GeneralMethod
  35. {
  36. //团组信息
  37. private static readonly SqlSugarClient _sqlSugar = AutofacIocManager.Instance.GetService<SqlSugarClient>();
  38. private static readonly DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  39. private static readonly TeamRateRepository _teamRateRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
  40. private static readonly IJuHeApiService _juHeApi = AutofacIocManager.Instance.GetService<IJuHeApiService>();
  41. private static readonly SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
  42. private static readonly TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
  43. private static readonly MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
  44. private static readonly IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
  45. private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  46. #region 团组操作-->团组归属部门
  47. /// <summary>
  48. /// 团组操作-->团组归属部门
  49. /// </summary>
  50. /// <returns></returns>
  51. public static async Task<List<GroupOpAffiliationBranchView>> GroupOpAffiliationBranchInit()
  52. {
  53. /*
  54. * 1.sq 和 gyy 等显示 市场部
  55. * 2.王鸽和主管及张总还有管理员号统一国交部
  56. * 2-1. 4 管理员 ,21 张海麟
  57. */
  58. //List<int> userIds = new List<int>() { 4, 21 };
  59. var userDepDatas = new List<GroupOpAffiliationBranchView>();
  60. //userDepDatas = _sqlSugar.Queryable<Sys_Users>()
  61. // .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  62. // .Where(u => u.IsDel == 0)
  63. // .Select((u, d) => new GroupOpAffiliationBranchView { value = userIds.Contains(u.Id) ? "国交部" : d.DepName, text = userIds.Contains(u.Id) ? "国交部" : d.DepName })
  64. // .ToList();
  65. //userDepDatas.Insert(0, new GroupOpAffiliationBranchView() { text = "公司", value = "公司" });
  66. userDepDatas.Insert(0, new GroupOpAffiliationBranchView() { text = "全部", value = "全部" });
  67. userDepDatas.Insert(1, new GroupOpAffiliationBranchView() { text = "国交部", value = "国交部" });
  68. userDepDatas.Insert(2, new GroupOpAffiliationBranchView() { text = "市场部", value = "市场部" });
  69. userDepDatas.Insert(3, new GroupOpAffiliationBranchView() { text = "策划部", value = "策划部" });
  70. return userDepDatas;
  71. }
  72. public class GroupOpAffiliationBranchView
  73. {
  74. public string value { get; set; }
  75. public string text { get; set; }
  76. }
  77. #endregion
  78. #region 员工注册默认添加基础页面
  79. /// <summary>
  80. /// 默认职位权限
  81. /// </summary>
  82. public static bool DefaultPostAuth(int depId, int postId, int userId, int createUserId)
  83. {
  84. if (depId < 1) return false;
  85. if (postId < 1) return false;
  86. if (userId < 1) return false;
  87. if (createUserId < 1) return false;
  88. List<DefaultPostPageAuthView> _defaultData = AppSettingsHelper.Get<DefaultPostPageAuthView>("DefaultPostPageData");
  89. if (_defaultData.Count < 1) return false;
  90. var postJobDatas = _dirRep._sqlSugar.Queryable<Sys_JobPost>().Where(it => it.IsDel == 0).ToList();
  91. List<int> pageData = new List<int>();
  92. //添加公司公共页面
  93. pageData.AddRange(_defaultData.Find(it => it.DepId == -1)?.PostPageAuths[0].PageIds ?? new List<int>());
  94. //添加部门页面
  95. var depPublicPageData = _defaultData.Find(it => it.DepId == depId);
  96. var jobPublicPageData = postJobDatas.Find(it => it.DepId == depId && it.Id == postId);
  97. if (depPublicPageData != null) //特殊部门
  98. {
  99. //公共页面
  100. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == -1)?.PageIds ?? new List<int>());
  101. if (depId == 7) //国交部特殊处理
  102. {
  103. List<string> postNames = new List<string>() { "主管", "经理" };
  104. //岗位页面
  105. if (jobPublicPageData != null)
  106. {
  107. if (postNames.Contains(jobPublicPageData.JobName))
  108. {
  109. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == 0)?.PageIds ?? new List<int>());
  110. }
  111. else
  112. {
  113. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == postId)?.PageIds ?? new List<int>());
  114. }
  115. }
  116. }
  117. #region 按照岗位默认分配页面 特殊处理 市场部-销售顾问
  118. var salesDefaultPages = new List<int>() {
  119. 27 , //团组操作
  120. 104, //接团客户名单
  121. 106, //倒推表
  122. 118, //出入境费用明细
  123. 168, //出入境国家三公费用标准
  124. 194, //出入境费用明细-草稿
  125. 196, //前期需求表单收集
  126. };
  127. var jobName = jobPublicPageData.JobName;
  128. if (!string.IsNullOrEmpty(jobName))
  129. {
  130. if (jobPublicPageData.JobName.Equals("销售顾问"))
  131. {
  132. pageData.AddRange(salesDefaultPages);
  133. pageData = pageData.Distinct().OrderBy(x => x).ToList();
  134. }
  135. }
  136. #endregion
  137. }
  138. else //通用部门
  139. {
  140. pageData.AddRange(_defaultData.Find(it => it.DepId == 0)?.PostPageAuths[0].PageIds ?? new List<int>());
  141. }
  142. if (pageData.Count > 0)
  143. {
  144. //页面操作权限数据(添加修改等...)
  145. var pageFunctionData = _dirRep._sqlSugar.Queryable<Sys_SystemMenuAndFunction>().Where(it => pageData.Contains(it.SmId) && it.IsDel == 0).ToList();
  146. var defaultPageData = pageFunctionData.Select(it => new Sys_UserAuthority()
  147. {
  148. UId = userId,
  149. SmId = it.SmId,
  150. FId = it.FId,
  151. CreateUserId = createUserId, //管理员
  152. CreateTime = DateTime.Now,
  153. IsDel = 0,
  154. IsTemp = 1
  155. }).ToList();
  156. if (defaultPageData.Count > 0)
  157. {
  158. //移除每个页面的审核权限,审核权限需要单独开启
  159. defaultPageData = defaultPageData.Where(it => it.FId != 12).ToList();
  160. //添加页面操作权限
  161. var s = _dirRep._sqlSugar.Fastest<Sys_UserAuthority>().PageSize(100000).BulkCopy(defaultPageData);
  162. if (s > 0)
  163. {
  164. return true;
  165. }
  166. }
  167. }
  168. return false;
  169. }
  170. #endregion
  171. #region 消息
  172. /// <summary>
  173. /// 消息 发布And 通知
  174. /// </summary>
  175. /// <param name="msgTypeEnum">
  176. /// 消息类型
  177. /// 1 公告通知
  178. /// 2 团组流程管控通知
  179. /// 3 团组业务操作通知
  180. /// 4 团组费用审核消息
  181. /// 5 团组签证进度通知
  182. /// 6 团组任务进度通知
  183. /// 7 日付申请通知
  184. /// </param>
  185. /// <param name="title">消息标题</param>
  186. /// <param name="content">消息内容</param>
  187. /// <param name="userIds"></param>
  188. /// <param name="diId">团组id</param>
  189. /// <param name="param">团组id</param>
  190. /// <returns></returns>
  191. public static async Task<bool> MessageIssueAndNotification(MessageTypeEnum msgTypeEnum, string title, string content, List<int> userIds, int diId = 0, string param = "")
  192. {
  193. MessageDto messageDto = new()
  194. {
  195. Type = msgTypeEnum,
  196. IssuerId = 4,//管理员
  197. DiId = diId,
  198. Title = title,
  199. Content = content,
  200. ReleaseTime = DateTime.Now,
  201. UIdList = userIds,
  202. Param = param
  203. };
  204. var status = await _messageRep.AddMsg(messageDto);//添加消息
  205. if (status)
  206. {
  207. //给在线在用户发送消息
  208. var connIds = UserStore.OnlineUser.Where(it => userIds.Contains(it.UserId)).Select(it => it.ConnectionId).ToList();
  209. var notificationTypeStr1 = GetMsgNotificationType(msgTypeEnum);
  210. var notificationTypeStr = JsonConvert.SerializeObject(
  211. new
  212. {
  213. UserIds = userIds,
  214. Msg = $"您有一条{notificationTypeStr1}相关的消息!"
  215. }
  216. );
  217. await _hubContext.Clients.Clients(connIds).ReceiveMessage($"您有一条{notificationTypeStr1}相关的消息!");
  218. return true;
  219. }
  220. return false;
  221. }
  222. /// <summary>
  223. /// 根据消息类型 获取 消息通知类型
  224. /// </summary>
  225. /// <returns></returns>
  226. public static string GetMsgNotificationType(MessageTypeEnum msgTypeEnum)
  227. {
  228. int notificationType = 0;
  229. string notificationStr = "";
  230. List<NotificationTypeView> notificationTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
  231. notificationType = notificationTypeViews.Where(it => it.MsgTypeIds.Contains((int)msgTypeEnum)).Select(it => it.TypeId).FirstOrDefault();
  232. if (notificationType == 1021) notificationStr = "操作";
  233. else if (notificationType == 1020) notificationStr = "任务";
  234. return notificationStr;
  235. }
  236. #endregion
  237. #region md5 加密
  238. /// <summary>
  239. /// MD5加密,和动网上的16/32位MD5加密结果相同,
  240. /// 使用的UTF8编码
  241. /// </summary>
  242. /// <param name="source">待加密字串</param>
  243. /// <param name="length">16或32值之一,其它则采用.net默认MD5加密算法</param>
  244. /// <returns>加密后的字串</returns>
  245. public static string Encrypt(string source, int length = 32)
  246. {
  247. if (string.IsNullOrWhiteSpace(source))
  248. return string.Empty;
  249. HashAlgorithm hashAlgorithm = CryptoConfig.CreateFromName("MD5") as HashAlgorithm;
  250. byte[] bytes = Encoding.UTF8.GetBytes(source);
  251. byte[] hashValue = hashAlgorithm.ComputeHash(bytes);
  252. StringBuilder sb = new StringBuilder();
  253. switch (length)
  254. {
  255. case 16://16位密文是32位密文的9到24位字符
  256. for (int i = 4; i < 12; i++)
  257. {
  258. sb.Append(hashValue[i].ToString("x2"));
  259. }
  260. break;
  261. case 32:
  262. for (int i = 0; i < 16; i++)
  263. {
  264. sb.Append(hashValue[i].ToString("x2"));
  265. }
  266. break;
  267. default:
  268. for (int i = 0; i < hashValue.Length; i++)
  269. {
  270. sb.Append(hashValue[i].ToString("x2"));
  271. }
  272. break;
  273. }
  274. return sb.ToString();
  275. }
  276. #endregion
  277. #region jwt
  278. /// <summary>
  279. /// 获取token
  280. /// </summary>
  281. /// <param name="_config"></param>
  282. /// <param name="Number"></param>
  283. /// <param name="uId"></param>
  284. /// <param name="uName"></param>
  285. /// <param name="exp"></param>
  286. /// <returns></returns>
  287. public static async Task<string> GetToken(IConfiguration _config, string Number, int uId, string uName, DateTime exp)
  288. {
  289. string userId = Guid.NewGuid().ToString().Replace("-", "");
  290. var claims = new[] {
  291. new Claim(ClaimTypes.NameIdentifier, uName),
  292. new Claim(ClaimTypes.NameIdentifier, uId.ToString()),
  293. new Claim(ClaimTypes.NameIdentifier, userId),
  294. new Claim("Number",Number)
  295. };
  296. var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"]));
  297. var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
  298. var token = new JwtSecurityToken(
  299. issuer: "OASystem.com",
  300. audience: "OASystem.com",
  301. claims: claims,
  302. expires: exp,
  303. signingCredentials: creds);
  304. var identity = new ClaimsIdentity(claims, "login");
  305. var principal = new ClaimsPrincipal(identity);
  306. // await _httpContext.SignInAsync (CookieAuthenticationDefaults.AuthenticationScheme, principal);
  307. return new JwtSecurityTokenHandler().WriteToken(token);
  308. }
  309. #endregion
  310. #region 数据类型转换
  311. /// <summary>
  312. /// object 转 Int
  313. /// </summary>
  314. /// <param name="obj"></param>
  315. /// <returns></returns>
  316. public static int GetInt(this object obj)
  317. {
  318. if (obj == null)
  319. return 0;
  320. var number = 0;
  321. var reslut = Int32.TryParse(obj.ToString(), out number);
  322. return number;
  323. }
  324. private static DateTime _dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
  325. private static long _longTime = 621355968000000000;
  326. private static int _samllTime = 10000000;
  327. /// <summary>
  328. /// 时间戳 转 datetime
  329. /// </summary>
  330. /// <param name="timeStamp"></param>
  331. /// <returns></returns>
  332. public static DateTime GetTimeSpmpToDate(this object timeStamp)
  333. {
  334. if (timeStamp == null) return _dateStart;
  335. DateTime dateTime = new DateTime(_longTime + Convert.ToInt64(timeStamp) * _samllTime, DateTimeKind.Utc).ToLocalTime();
  336. return dateTime;
  337. }
  338. #endregion
  339. #region 用户页面操作功能 权限
  340. /// <summary>
  341. /// 用户页面操作功能(可使用)
  342. /// </summary>
  343. /// <param name="userId">用户Id</param>
  344. /// <param name="PageId">页面Id</param>
  345. /// <returns></returns>
  346. public static async Task<PageFunAuthViewBase> PostUserPageFuncDatas(int userId, int PageId)
  347. {
  348. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  349. List<UserPageFuncView> userPageFuncDatas = new List<UserPageFuncView>();
  350. string sql = string.Format(@"Select ua.UId As UserId, u.CnName As UserName, pa.ModuleId,pa.ModuleName,pa.PageId,pa.PageName,pa.PageIsEnable,
  351. pa.PagePhoneIsEnable,pa.FuncId,pa.FuncName,pa.FuncIsEnable
  352. From Sys_UserAuthority ua
  353. Left Join Sys_Users u On ua.UId = u.Id
  354. Left Join (
  355. Select sd.Id As ModuleId,sd.Name As ModuleName, smp.Id As PageId,smp.Name As PageName,smp.IsEnable As PageIsEnable,
  356. smp.phoneIsEnable As PagePhoneIsEnable,pfp.Id As FuncId,pfp.FunctionName As FuncName,pfp.IsEnable As FuncIsEnable
  357. From Sys_SystemMenuAndFunction smaf
  358. Left Join Sys_SystemMenuPermission smp On smaf.SmId = smp.Id
  359. Left Join Sys_SetData sd On sd.STid = 5 And smp.Mid = sd.Id
  360. Left Join Sys_PageFunctionPermission pfp On smaf.FId = pfp.Id
  361. Where smaf.IsDel = 0 And smp.IsDel = 0 And pfp.IsDel = 0 And sd.IsDel = 0 And smp.IsEnable = 1
  362. ) As pa On ua.SmId = pa.PageId And ua.FId = pa.FuncId
  363. Where ua.IsDel = 0 And ua.UId = {0} And pa.PageId = {1}
  364. Order By ModuleId,PageId,FuncId Asc", userId, PageId);
  365. userPageFuncDatas = await _dirRep._sqlSugar.SqlQueryable<UserPageFuncView>(sql).ToListAsync();
  366. if (userPageFuncDatas.Count <= 0)
  367. {
  368. return pageFunAuth;
  369. }
  370. UserPageFuncView userPageFunc = new UserPageFuncView();
  371. //查询 1
  372. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 1).FirstOrDefault();
  373. if (userPageFunc != null) pageFunAuth.CheckAuth = 1;
  374. //删除 2
  375. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 2).FirstOrDefault();
  376. if (userPageFunc != null) pageFunAuth.DeleteAuth = 1;
  377. //编辑 3
  378. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 3).FirstOrDefault();
  379. if (userPageFunc != null) pageFunAuth.EditAuth = 1;
  380. //下载 4
  381. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 4).FirstOrDefault();
  382. if (userPageFunc != null) pageFunAuth.FilesDownloadAuth = 1;
  383. //上传 5
  384. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 5).FirstOrDefault();
  385. if (userPageFunc != null) pageFunAuth.FilesUploadAuth = 1;
  386. //添加 11
  387. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 11).FirstOrDefault();
  388. if (userPageFunc != null) pageFunAuth.AddAuth = 1;
  389. //审核 12
  390. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 12).FirstOrDefault();
  391. if (userPageFunc != null) pageFunAuth.AuditAuth = 1;
  392. return pageFunAuth;
  393. }
  394. #endregion
  395. #region 业务模块 团组权限
  396. /// <summary>
  397. /// 业务模块 团组操作权限
  398. /// 验证 并返回可操作的团
  399. /// </summary>
  400. /// <param name="diId">团组Id</param>
  401. /// <param name="userId">用户Id</param>
  402. /// <param name="CTable">业务模块Id</param>
  403. /// <returns></returns>
  404. public static async Task<Result> PostGroupOperationAuth(int diId, int userId, int CTable)
  405. {
  406. Result _result = new Result { Code = -1, Msg = "No Operation Authorty!" };
  407. if (CTable < 1)
  408. {
  409. _result.Msg = "请填写正确的用户Id!";
  410. return _result;
  411. }
  412. var data = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.DIId == diId && it.UId == userId && it.CTId == CTable && it.IsDel == 0).First();
  413. if (data == null)
  414. {
  415. _result.Msg = "你没有本团下的该业务模块操作,请联系主管分配操作权限!";
  416. }
  417. else
  418. {
  419. _result.Code = 0;
  420. }
  421. return _result;
  422. }
  423. /// <summary>
  424. /// 业务模块 团组操作权限
  425. /// 返回可操作的团
  426. /// </summary>
  427. /// <param name="userId">用户Id</param>
  428. /// <param name="CTable">业务模块Id</param>
  429. /// <returns></returns>
  430. public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
  431. {
  432. var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
  433. var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
  434. if (taskData.Count < 1) return shareGroupInfoViews;
  435. var diIds = string.Join(",", taskData.Select(it => it.DIId).ToList());
  436. var sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  437. From Grp_DelegationInfo Where Id In({0}) And IsDel = 0 Order By Id Desc", diIds);
  438. shareGroupInfoViews = await _dirRep._sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
  439. return shareGroupInfoViews;
  440. }
  441. #endregion
  442. #region 团组相关
  443. #region 建团按国家默认添加汇率 / 默认权限分配
  444. /// <summary>
  445. /// 团组汇率
  446. /// 建团时 添加基础汇率 CNY
  447. /// 按国家 添加 默认币种
  448. /// </summary>
  449. /// <param name="userId"></param>
  450. /// <param name="diId"></param>
  451. /// <returns></returns>
  452. public static async Task<Result> PostGroupRateAddInit(int userId, int diId)
  453. {
  454. Result result = new() { Code = -2 };
  455. if (userId < 1)
  456. {
  457. result.Msg = string.Format(@"请传入正确的userId");
  458. return result;
  459. }
  460. if (diId < 1)
  461. {
  462. result.Msg = string.Format(@"请传入正确的DiId");
  463. return result;
  464. }
  465. //美元(USD):1.0000|欧元(EUR):1.0000|墨西哥比索(MXN):1.0000
  466. string rateInit = string.Format(@"人民币(CNY):1.0000");
  467. //var gropInfo = _dirRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == diId).First();
  468. //if (gropInfo == null)
  469. //{
  470. // result.Msg = $@"未查询到团组信息!";
  471. // return result;
  472. //}
  473. var juheRateData = await _juHeApi.GetExchangeRateAsync();
  474. if (juheRateData.Error_code != 0)
  475. {
  476. result.Msg = juheRateData.Reason;
  477. return result;
  478. }
  479. List<ExchangeRateModel> exchangeRateModels = (List<ExchangeRateModel>)juheRateData.Result;
  480. if (exchangeRateModels.Count <= 0)
  481. {
  482. result.Msg = $@"未查询到聚合接口汇率信息!";
  483. return result;
  484. }
  485. if (exchangeRateModels.Count > 0)
  486. {
  487. var codes = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  488. for (int i = 0; i < exchangeRateModels.Count; i++)
  489. {
  490. string currencyName = exchangeRateModels[i].Name;
  491. string code = "";
  492. var currencyData = codes.Where(it => it.Remark == currencyName).FirstOrDefault();
  493. if (currencyData != null)
  494. {
  495. code = currencyData.Name;
  496. decimal currRate = 0.00M;
  497. string MSellPri = exchangeRateModels[i].MSellPri;
  498. if (!string.IsNullOrEmpty(MSellPri))
  499. {
  500. currRate = Convert.ToDecimal(MSellPri) / 100M;
  501. }
  502. rateInit += $@"|{currencyName}({code}):{currRate.ToString("#0.0000")}";
  503. }
  504. }
  505. }
  506. var cTableIds = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  507. if (cTableIds.Count < 1)
  508. {
  509. result.Msg = $@"未查询到操作模块信息!";
  510. return result;
  511. }
  512. List<Grp_TeamRate> grp_TeamRates = new List<Grp_TeamRate>();
  513. foreach (var item in cTableIds)
  514. {
  515. grp_TeamRates.Add(
  516. new Grp_TeamRate() { DiId = diId, CTable = item.Id, Remark = rateInit, CreateUserId = userId }
  517. );
  518. }
  519. if (grp_TeamRates.Count > 0)
  520. {
  521. var addId = _teamRateRep._sqlSugar.Insertable(grp_TeamRates).ExecuteCommand();
  522. if (addId < 1)
  523. {
  524. result.Msg = string.Format(@"添加失败!");
  525. return result;
  526. }
  527. }
  528. result.Code = 0;
  529. result.Msg = string.Format(@"操作成功!");
  530. return result;
  531. }
  532. /// <summary>
  533. /// 团组任务分配
  534. /// 建团时 默认按照岗位分配权限
  535. /// </summary>
  536. /// <param name="userId"></param>
  537. /// <param name="diId"></param>
  538. /// <param name="companyId"></param>
  539. /// <returns></returns>
  540. public static async Task<Result> PostGroupAuthAddInit(int userId, int diId, int companyId = 2)
  541. {
  542. Result result = new() { Code = -2 };
  543. if (userId < 0)
  544. {
  545. result.Msg = string.Format(@"请传入正确的userId");
  546. return result;
  547. }
  548. if (companyId < 0)
  549. {
  550. result.Msg = string.Format(@"请传入正确的companyId");
  551. return result;
  552. }
  553. if (diId < 0)
  554. {
  555. result.Msg = string.Format(@"请传入正确的DiId");
  556. return result;
  557. }
  558. var usersData = await _teamRateRep._sqlSugar.Queryable<Sys_Users>()
  559. .LeftJoin<Sys_Department>((su, sd) => su.DepId == sd.Id && sd.IsDel == 0)
  560. .LeftJoin<Sys_JobPost>((su, sd, sjp) => su.JobPostId == sjp.Id && sjp.IsDel == 0)
  561. .Where(su => su.IsDel == 0)
  562. .Select((su, sd, sjp) => new
  563. {
  564. su.DepId,
  565. sd.DepName,
  566. su.JobPostId,
  567. sjp.JobName,
  568. su.Id,
  569. su.CnName
  570. })
  571. .ToListAsync();
  572. /*
  573. * 76 酒店预订 --> 国交部门 酒店,主管 岗位
  574. * 77 行程 --> 国交部门 经理,主管 岗位
  575. * 79 车/导游地接 --> 国交部门 OP,主管 岗位
  576. * 80 签证 --> 国交部门 签证 岗位
  577. * 81 邀请/公务活动 --> 国交部门 商邀 岗位
  578. * 82 团组客户保险 --> 国交部 经理,主管 岗位
  579. * 85 机票预订 --> 国交部门 机票 岗位
  580. * 98 其他款项 --> 总经办部门 总经理 岗位/国交部门(ALL) 岗位/财务部门(ALL) 岗位/策划部门(ALL) 岗位/人事部门 采购 岗位
  581. * 1015 超支费用,69 收款退还 --> 财务部门(ALL)岗位
  582. * 1015 超支费用 --> 国交部(ALL)岗位
  583. * 1081 文档下载 --> 国交部门 酒店,主管 岗位
  584. */
  585. var groupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
  586. // 76 酒店预订 --> 国交部门(7) 酒店(25)、主管(22) 岗位
  587. groupsTaskAssignments.AddRange(
  588. usersData
  589. .Where(it => it.DepId == 7 && (it.JobPostId == 25 || it.JobPostId == 22))
  590. .Select(it => new Grp_GroupsTaskAssignment()
  591. {
  592. DIId = diId,
  593. CTId = 76,
  594. UId = it.Id,
  595. CreateUserId = userId
  596. }).ToList()
  597. );
  598. // 77 行程 --> 国交部门(7) 经理(32),主管(22) 岗位
  599. groupsTaskAssignments.AddRange(
  600. usersData
  601. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 32))
  602. .Select(it => new Grp_GroupsTaskAssignment()
  603. {
  604. DIId = diId,
  605. CTId = 77,
  606. UId = it.Id,
  607. CreateUserId = userId
  608. }).ToList()
  609. );
  610. //79 车/导游地接 --> 国交部门(7) OP(28)、主管(22) 岗位
  611. //groupsTaskAssignments.AddRange(
  612. // usersData.Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 28))
  613. // .Select(it => new Grp_GroupsTaskAssignment()
  614. // {
  615. // DIId = diId,
  616. // CTId = 79,
  617. // UId = it.Id,
  618. // CreateUserId = userId
  619. // }).ToList()
  620. //);
  621. //81 邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
  622. //groupsTaskAssignments.AddRange(
  623. // usersData.Where(it => it.DepId == 7 && it.JobPostId == 27)
  624. // .Select(it => new Grp_GroupsTaskAssignment()
  625. // {
  626. // DIId = diId,
  627. // CTId = 81,
  628. // UId = it.Id,
  629. // CreateUserId = userId
  630. // }).ToList()
  631. //);
  632. //2024年8月26日16点27分 “邀请公务活动分配给王鸽(UserID:149)”
  633. //groupsTaskAssignments.Add(
  634. // new Grp_GroupsTaskAssignment()
  635. // {
  636. // DIId = diId,
  637. // CTId = 81,
  638. // UId = 149,
  639. // CreateUserId = userId
  640. // }
  641. //);
  642. //80 签证 --> 国交部门(7) 签证(26) 岗位
  643. //groupsTaskAssignments.AddRange(
  644. // usersData
  645. // .Where(it => it.DepId == 7 && it.JobPostId == 26)
  646. // .Select(it => new Grp_GroupsTaskAssignment()
  647. // {
  648. // DIId = diId,
  649. // CTId = 80,
  650. // UId = it.Id,
  651. // CreateUserId = userId
  652. // }).ToList()
  653. //);
  654. //82 团组客户保险 --> 国交部(7) 经理(32),主管(22) 岗位
  655. //2024-06-25 默认将保险权限分配给签证岗。 签证(26) 岗位
  656. List<int> insurancePositions = new List<int>() { 32, 22, 26 };
  657. groupsTaskAssignments.AddRange(
  658. usersData
  659. .Where(it => it.DepId == 7 && insurancePositions.Contains(it.JobPostId))
  660. .Select(it => new Grp_GroupsTaskAssignment()
  661. {
  662. DIId = diId,
  663. CTId = 82,
  664. UId = it.Id,
  665. CreateUserId = userId
  666. }).ToList()
  667. );
  668. //85 机票预订 --> 国交部门(7) 机票(24),主管(22) 岗位
  669. groupsTaskAssignments.AddRange(
  670. usersData
  671. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 24))
  672. .Select(it => new Grp_GroupsTaskAssignment()
  673. {
  674. DIId = diId,
  675. CTId = 85,
  676. UId = it.Id,
  677. CreateUserId = userId
  678. }).ToList()
  679. );
  680. //98 其他款项 --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
  681. var depIds = new List<int>() { 7, 3, 5 };
  682. var jobIds = new List<int>() { 1, 74 };
  683. groupsTaskAssignments.AddRange(
  684. usersData
  685. .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
  686. .Select(it => new Grp_GroupsTaskAssignment()
  687. {
  688. DIId = diId,
  689. CTId = 98,
  690. UId = it.Id,
  691. CreateUserId = userId
  692. }).ToList()
  693. );
  694. //2024年8月26日16点27分 “其他款项分配给王鸽(UserID:149)”
  695. groupsTaskAssignments.Add(new Grp_GroupsTaskAssignment()
  696. {
  697. DIId = diId,
  698. CTId = 98,
  699. UId = 149,
  700. CreateUserId = userId
  701. }
  702. );
  703. //1015 超支费用,285 收款退还 --> 财务部门(ALL)岗位
  704. groupsTaskAssignments.AddRange(
  705. usersData
  706. .Where(it => it.DepId == 3)
  707. .Select(it => new Grp_GroupsTaskAssignment()
  708. {
  709. DIId = diId,
  710. CTId = 1015,
  711. UId = it.Id,
  712. CreateUserId = userId
  713. }).ToList()
  714. );
  715. groupsTaskAssignments.AddRange(
  716. usersData
  717. .Where(it => it.DepId == 3)
  718. .Select(it => new Grp_GroupsTaskAssignment()
  719. {
  720. DIId = diId,
  721. CTId = 285,
  722. UId = it.Id,
  723. CreateUserId = userId
  724. }).ToList()
  725. );
  726. //1015 超支费用 --> 国交部(ALL)岗位
  727. groupsTaskAssignments.AddRange(
  728. usersData
  729. .Where(it => it.DepId == 7)
  730. .Select(it => new Grp_GroupsTaskAssignment()
  731. {
  732. DIId = diId,
  733. CTId = 1015,
  734. UId = it.Id,
  735. CreateUserId = userId
  736. }).ToList()
  737. );
  738. if (groupsTaskAssignments.Count > 0)
  739. {
  740. var addId = await _teamRateRep._sqlSugar.Insertable(groupsTaskAssignments).ExecuteCommandAsync();
  741. }
  742. result.Code = 0;
  743. result.Msg = string.Format(@"操作成功!");
  744. return result;
  745. }
  746. #endregion
  747. #region 员工是否是市场部人员
  748. /// <summary>
  749. /// 验证市场部客户人员
  750. /// </summary>
  751. /// <param name="userId"></param>
  752. /// <returns></returns>
  753. public static async Task<bool> IsMarketingStaff(int userId)
  754. {
  755. var userInfos = await _dirRep._sqlSugar
  756. .Queryable<Sys_Users>()
  757. .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  758. .Where((u, d) => u.IsDel == 0 && u.Id == userId && d.DepName.Contains("市场部"))
  759. .ToListAsync();
  760. if (userInfos.Count > 0) return true;
  761. return false;
  762. }
  763. #endregion
  764. #region 三公费用相关
  765. /// <summary>
  766. /// 保存操作前汇率
  767. /// </summary>
  768. /// <param name="currUserId"></param>
  769. /// <param name="diId"></param>
  770. /// <param name="linkModule"></param>
  771. /// <returns></returns>
  772. public static async Task<bool> RateRecordSave(int currUserId, int diId, string linkModule)
  773. {
  774. //var selectData = await _enterExitCostRep._sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  775. // .Where(x => Convert.ToDateTime(x.RateDateTime).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
  776. // .FirstAsync();
  777. //if (selectData != null) return false;
  778. var _currencyRate = await _juHeApi.PostItemRateAsync(Array.Empty<string>());
  779. string rateInfoStr = string.Empty;
  780. var oaCurrencyData = await _sqlSugar.Queryable<Sys_SetData>()
  781. .Where(x => x.IsDel == 0 && x.STid == 66)
  782. .ToListAsync();
  783. foreach (var rate in _currencyRate)
  784. {
  785. var oaCurrncy = oaCurrencyData.Find(x => x.Remark.Equals(rate.Name));
  786. if (oaCurrncy == null) continue;
  787. //美元(USD):7.5|
  788. string rateStr = rate.FSellPri ?? "0.00";
  789. rateInfoStr += $"{rate.Name}({oaCurrncy.Name}):{rateStr}|";
  790. }
  791. if (string.IsNullOrEmpty(rateInfoStr)) return false;
  792. var add = await _sqlSugar
  793. .Insertable<Sys_ExchangeRateRecord>(new Sys_ExchangeRateRecord()
  794. {
  795. DiId = diId,
  796. LinkModule = linkModule,
  797. RateDateTime = DateTime.Now,
  798. RateInfo = rateInfoStr,
  799. CreateUserId = currUserId,
  800. IsDel = 0
  801. })
  802. .ExecuteCommandAsync();
  803. return add > 0;
  804. }
  805. /// <summary>
  806. /// 三公费用导入收款账单数据
  807. /// </summary>
  808. /// <param name="groupId"></param>
  809. /// <returns></returns>
  810. public static async Task<List<Fin_ForeignReceivables>> ReceivablesImportFeeAsync(int groupId)
  811. {
  812. var data = new List<Fin_ForeignReceivables>();
  813. var enterExitCosts = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).FirstAsync();
  814. var dayAndCosts = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).ToListAsync();
  815. var dayOtherCosts = await _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == groupId).ToListAsync(); //其他款项
  816. if (enterExitCosts == null) return data;
  817. //数据源
  818. var stayData = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  819. var mealData = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  820. var miscellaneousData = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  821. var trainData = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  822. //筛选 陪同人员 = 1
  823. var groupClientList = await _sqlSugar.Queryable<Grp_TourClientList>()
  824. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id)
  825. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id)
  826. .LeftJoin<Sys_SetData>((tcl, dc, cc, sd) => tcl.ShippingSpaceTypeId == sd.Id)
  827. .Where(tcl => tcl.IsDel == 0 &&
  828. tcl.DiId == groupId &&
  829. tcl.IsAccompany == 1
  830. )
  831. .Select((tcl, dc, cc, sd) => new
  832. {
  833. DiId = tcl.DiId,
  834. CompanyId = cc.Id,
  835. CompanyName = cc.CompanyFullName,
  836. ClienId = dc.Id,
  837. ClientName = dc.FirstName + dc.LastName,
  838. SpaceId = tcl.ShippingSpaceTypeId,
  839. SpaceName = sd.Name
  840. })
  841. .ToListAsync();
  842. if (!groupClientList.Any()) return data;
  843. decimal domesticFeeTotal = 0.00M, //境内费用
  844. economyClassFeeTotal = 0.00M, //经济舱费用
  845. businessClassFeeTotal = 0.00M, //公务舱费用
  846. firstClassFeeTotal = 0.00M, //头等舱费用
  847. stayFeeTotal = 0.00M, //住宿费
  848. mealsFeeTotal = 0.00M, //餐食费
  849. miscellaneousFeeTotal = 0.00M, //公杂费
  850. trainFeeTotal = 0.00M, //培训费
  851. otherPriceTotal = 0.00M; //其他款项
  852. //境内费用(其他费用)
  853. if (enterExitCosts.ChoiceOne == 1) domesticFeeTotal = enterExitCosts.InsidePay;
  854. //住宿费
  855. if (enterExitCosts.ChoiceThree == 1) stayFeeTotal = stayData.Sum(x => x.SubTotal);
  856. //伙食费
  857. if (enterExitCosts.ChoiceFour == 1) mealsFeeTotal = mealData.Sum(x => x.SubTotal);
  858. //公杂费
  859. if (enterExitCosts.ChoiceFive == 1) miscellaneousFeeTotal = miscellaneousData.Sum(x => x.SubTotal);
  860. //培训费
  861. if (enterExitCosts.ChoiceSix == 1) trainFeeTotal = trainData.Sum(x => x.SubTotal);
  862. //其他款项
  863. if (enterExitCosts.OtherExpenses_Checked == 1) otherPriceTotal = dayOtherCosts.Sum(x => x.SubTotal);
  864. decimal otherFeeTotal = domesticFeeTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainFeeTotal + otherPriceTotal;
  865. //国际旅费合计
  866. //经济舱
  867. if (enterExitCosts.SumJJC == 1) economyClassFeeTotal = enterExitCosts.OutsideJJPay + otherFeeTotal;
  868. //公务舱
  869. if (enterExitCosts.SumGWC == 1) businessClassFeeTotal = enterExitCosts.OutsideGWPay + otherFeeTotal;
  870. //头等舱
  871. if (enterExitCosts.SumTDC == 1) firstClassFeeTotal = enterExitCosts.OutsideTDPay + otherFeeTotal;
  872. var groupClientListGroup = groupClientList.GroupBy(x => x.CompanyId);
  873. foreach (var item in groupClientListGroup)
  874. {
  875. var companyName = AesEncryptionHelper.Decrypt(item.FirstOrDefault().CompanyName);
  876. var airTicketGroup = item.GroupBy(x => x.SpaceId);
  877. foreach (var airTicket in airTicketGroup)
  878. {
  879. int quantity = airTicket.Count();
  880. if (quantity > 0)
  881. {
  882. var price = 0.00M;
  883. var spaceName = airTicket.FirstOrDefault()?.SpaceName ?? string.Empty;
  884. if (spaceName.Equals("经济舱")) price = economyClassFeeTotal;
  885. else if (spaceName.Equals("公务舱")) price = businessClassFeeTotal;
  886. else if (spaceName.Equals("头等舱")) price = firstClassFeeTotal;
  887. if (price > 0)
  888. {
  889. decimal itemTotal = price * quantity;
  890. data.Add(new Fin_ForeignReceivables()
  891. {
  892. Id = 0,
  893. CreateTime = DateTime.Now,
  894. Diid = groupId,
  895. PriceName = $"{companyName}-{spaceName}",
  896. Price = price,
  897. Count = quantity,
  898. Unit = "人",
  899. ItemSumPrice = itemTotal,
  900. Currency = 836,
  901. Rate = 1.0000M,
  902. AddingWay = 2,
  903. Remark = "由出入境费用导入费用",
  904. });
  905. }
  906. }
  907. }
  908. }
  909. return data;
  910. }
  911. #endregion
  912. #region 根据团ID获取各板块实际操作人
  913. /// <summary>
  914. /// 获取 团组模块操作人
  915. /// </summary>
  916. /// <param name="groupId"></param>
  917. /// <returns></returns>
  918. public static List<GroupOperationUserView> GetGroupModuleOperators(int groupId)
  919. {
  920. var modoule = new GroupOperationUserView();
  921. var view = modoule.GetOperationUsersInit();
  922. if (groupId < 1) return view;
  923. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>()
  924. .Where(it => it.IsDel == 0 && it.Id == groupId)
  925. .First();
  926. if (groupInfo == null) return view;
  927. //获取团组下的操作人
  928. //车/导游地接
  929. var opUers = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  930. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 79)
  931. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  932. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  933. .Select((x, y, u) => new GroupOperationUserInfo
  934. {
  935. UserId = u.Id,
  936. UserName = u.CnName
  937. }).Distinct().ToList();
  938. view.Where(it => it.CTableId == 79).FirstOrDefault().OperationUsers = opUers;
  939. //签证
  940. var visaUsers = _sqlSugar.Queryable<Grp_VisaInfo>()
  941. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 80)
  942. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  943. .Where((x, y, u) => x.DIId == groupId && x.IsDel == 0)
  944. .Select((x, y, u) => new GroupOperationUserInfo
  945. {
  946. UserId = u.Id,
  947. UserName = u.CnName
  948. }).Distinct().ToList();
  949. view.Where(it => it.CTableId == 80).FirstOrDefault().OperationUsers = visaUsers;
  950. //保险
  951. var insUsers = _sqlSugar.Queryable<Grp_Customers>()
  952. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 82)
  953. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  954. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  955. .Select((x, y, u) => new GroupOperationUserInfo
  956. {
  957. UserId = u.Id,
  958. UserName = u.CnName
  959. }).Distinct().ToList();
  960. view.Where(it => it.CTableId == 82).FirstOrDefault().OperationUsers = insUsers;
  961. //邀请/公务活动
  962. var ioaUsers = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>()
  963. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 81)
  964. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  965. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  966. .Select((x, y, u) => new GroupOperationUserInfo
  967. {
  968. UserId = u.Id,
  969. UserName = u.CnName
  970. }).Distinct().ToList();
  971. if (!ioaUsers.Any())
  972. {
  973. ioaUsers = _sqlSugar.Queryable<Res_OfficialActivities>()
  974. .LeftJoin<Sys_Users>((x, y) => x.CreateUserId == y.Id)
  975. .Where((x, y) => x.DiId == groupId && x.IsDel == 0)
  976. .Select((x, y) => new GroupOperationUserInfo
  977. {
  978. UserId = y.Id,
  979. UserName = y.CnName
  980. }).Distinct().ToList();
  981. }
  982. view.Where(it => it.CTableId == 81).FirstOrDefault().OperationUsers = ioaUsers;
  983. //其他款项 98
  984. var otherUsers = _sqlSugar.Queryable<Grp_DecreasePayments>()
  985. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 98)
  986. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  987. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  988. .Select((x, y, u) => new GroupOperationUserInfo
  989. {
  990. UserId = u.Id,
  991. UserName = u.CnName
  992. }).Distinct().ToList();
  993. view.Where(it => it.CTableId == 98).FirstOrDefault().OperationUsers = otherUsers;
  994. //添加分配人员
  995. // 79 车/导游地接
  996. // 80 签证
  997. // 81 邀请/公务活动
  998. var setdataids = new List<int>() { 79, 81 };
  999. // 27 商邀
  1000. // 28 OP
  1001. var jobSetdataids = new List<int>() { 27, 28 };
  1002. var q = _sqlSugar.Queryable<Grp_GroupsTaskAssignment, Sys_Users>(
  1003. (ccta, su) => new JoinQueryInfos(
  1004. JoinType.Left, ccta.UId == su.Id && su.IsDel == 0))
  1005. .Where((ccta, su) =>
  1006. ccta.IsDel == 0 &&
  1007. ccta.DIId == groupId &&
  1008. jobSetdataids.Contains(su.JobPostId) &&
  1009. setdataids.Contains(ccta.CTId))
  1010. .Select((ccta, su) => new
  1011. {
  1012. userid = su.Id,
  1013. su.JobPostId,
  1014. ccta.CTId,
  1015. ccta.DIId,
  1016. su.CnName,
  1017. });
  1018. var qtb = q.ToDataTable();
  1019. foreach (var groupModule in view)
  1020. {
  1021. if (setdataids.Contains(groupModule.CTableId) && !groupModule.OperationUsers.Any())
  1022. {
  1023. var qtbUsers = qtb.AsEnumerable().
  1024. Where(x => x.Field<int>("CTId") == groupModule.CTableId).
  1025. Select(x => x.Field<int>("userid")).ToList();
  1026. groupModule.OperationUsers = qtbUsers.Select(x => new GeneralMethod.GroupOperationUserInfo()
  1027. {
  1028. UserId = x,
  1029. UserName = qtb.AsEnumerable().FirstOrDefault(y => y.Field<int>("userid") == x)?.Field<string>("CnName") ?? ""
  1030. }).ToList();
  1031. }
  1032. }
  1033. return view;
  1034. }
  1035. public class GroupOperationUserView
  1036. {
  1037. public int CTableId { get; set; }
  1038. public string CTableName { get; set; }
  1039. public List<GroupOperationUserInfo> OperationUsers { get; set; }
  1040. public GroupOperationUserView() { }
  1041. /// <summary>
  1042. /// 默认模块List
  1043. /// </summary>
  1044. /// <returns></returns>
  1045. public List<GroupOperationUserView> GetOperationUsersInit()
  1046. {
  1047. var modules = new List<GroupOperationUserView>() {
  1048. new(){ CTableId = 76,CTableName = "酒店预订",
  1049. OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 226,UserName = "宋夏雨" } } },
  1050. new(){ CTableId = 79,CTableName = "车/导游地接" },
  1051. new(){ CTableId = 80,CTableName = "签证" },
  1052. new(){ CTableId = 82,CTableName = "团组客户保险" },
  1053. new(){ CTableId = 81,CTableName = "邀请/公务活动" },
  1054. new(){ CTableId = 85,CTableName = "机票预订",
  1055. OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 385, UserName = "雍婷玉" } } },
  1056. new(){ CTableId = 98,CTableName = "其他款项" },
  1057. };
  1058. return modules;
  1059. }
  1060. }
  1061. public class GroupOperationUserInfo
  1062. {
  1063. public int UserId { get; set; }
  1064. public string UserName { get; set; }
  1065. }
  1066. #endregion
  1067. #endregion
  1068. #region 团组汇率
  1069. /// <summary>
  1070. /// 团组汇率
  1071. /// 获取板块 币种 及 汇率
  1072. /// 76 酒店预订 77 行程 79 车/导游地接
  1073. /// 80 签证 82 团组客户保险 85 机票预订
  1074. /// 98 其他款项 285 收款退还
  1075. /// </summary>
  1076. /// <param name="teamRateModels"></param>
  1077. /// <param name="cTable"></param>
  1078. /// <param name="currencyCodes"></param>
  1079. /// <returns>
  1080. /// string
  1081. /// eg: CNY 1.0000
  1082. /// </returns>
  1083. public static async Task<string> PostGroupRateByCTableAndCurrency(List<TeamRateModelView> teamRateModels, int cTable, List<string> currencyCodes)
  1084. {
  1085. string str = "";
  1086. List<string> currencyRates = new List<string>();
  1087. TeamRateModelView hotelRateData = teamRateModels.Where(it => it.CTableId == cTable).FirstOrDefault();
  1088. if (hotelRateData != null)
  1089. {
  1090. var hotelRates = hotelRateData.TeamRates;
  1091. foreach (var item in currencyCodes)
  1092. {
  1093. if (!string.IsNullOrEmpty(item))
  1094. {
  1095. var hotelRateInfo = hotelRates.Where(it => it.CurrencyCode.Equals(item)).FirstOrDefault();
  1096. if (hotelRateInfo != null)
  1097. {
  1098. string str1 = string.Format("{0} {1}\r\n", hotelRateInfo.CurrencyCode, hotelRateInfo.Rate.ToString("#0.0000"));
  1099. currencyRates.Add(str1);
  1100. }
  1101. }
  1102. }
  1103. if (currencyRates != null || currencyRates.Count > 0)
  1104. {
  1105. currencyRates = currencyRates.Distinct().ToList();
  1106. foreach (var item in currencyRates)
  1107. {
  1108. str += item;
  1109. }
  1110. }
  1111. }
  1112. return str;
  1113. }
  1114. /// <summary>
  1115. /// 团组汇率 币种 Item (来源:团组汇率)
  1116. /// 根据 团组Id And 业务类型(CTable)Id
  1117. /// api处理CTable = 285,默认返回CNY
  1118. /// </summary>
  1119. /// <param name="portType"></param>
  1120. /// <param name="diId"></param>
  1121. /// <param name="cTable"></param>
  1122. /// <returns></returns>
  1123. public static async Task<TeamRateModelGeneralView> PostGroupTeamRateByDiIdAndCTableId(int portType, int diId, int cTable)
  1124. {
  1125. TeamRateModelGeneralView _view = new TeamRateModelGeneralView();
  1126. _view = await _teamRateRep.PostGroupTeamRateByDiIdAndCTableId(portType, diId, cTable);
  1127. return _view;
  1128. }
  1129. /// <summary>
  1130. /// 汇率备注拆分
  1131. /// (美元(USD):7.2370|日元(JPY):0.0499|欧元(EUR):8.3000|英镑(GBP):9.1996|港币(HKD):0.9291)
  1132. /// </summary>
  1133. /// <param name="rateRemark"></param>
  1134. /// <returns></returns>
  1135. public static async Task<List<TeamRateDescAddCurrencyIdView>> SplitExchangeRate(this string rateRemark)
  1136. {
  1137. List<TeamRateDescAddCurrencyIdView> _view = new List<TeamRateDescAddCurrencyIdView>();
  1138. List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
  1139. #region 获取所有币种
  1140. string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
  1141. var DBdata = _setDataRep.GetListBySqlWithNolock(sql);
  1142. if (DBdata == null || DBdata.Count == 0)
  1143. {
  1144. return _view;
  1145. }
  1146. currencyDatas = DBdata.Select(x => new SetDataInfoView
  1147. {
  1148. Name = x.Name,
  1149. Id = x.Id,
  1150. Remark = x.Remark,
  1151. }).ToList();
  1152. #endregion
  1153. #region 拆分remark里的汇率
  1154. if (string.IsNullOrEmpty(rateRemark))
  1155. {
  1156. return _view;
  1157. }
  1158. if (rateRemark.Contains("|"))
  1159. {
  1160. string[] currencyArr = rateRemark.Split("|");
  1161. foreach (string currency in currencyArr)
  1162. {
  1163. string[] currency1 = currency.Split(":");
  1164. string[] currency2 = currency1[0].Split("(");
  1165. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  1166. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  1167. {
  1168. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  1169. CurrencyCode = currencyCode,
  1170. CurrencyName = currency2[0],
  1171. Rate = decimal.Parse(currency1[1]),
  1172. };
  1173. _view.Add(rateDescView);
  1174. }
  1175. }
  1176. else
  1177. {
  1178. try
  1179. {
  1180. string[] currency1 = rateRemark.Split(":");
  1181. string[] currency2 = currency1[0].Split("(");
  1182. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  1183. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  1184. {
  1185. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  1186. CurrencyCode = currencyCode,
  1187. CurrencyName = currency2[0],
  1188. Rate = decimal.Parse(currency1[1]),
  1189. };
  1190. _view.Add(rateDescView);
  1191. }
  1192. catch (Exception)
  1193. {
  1194. return _view;
  1195. }
  1196. }
  1197. #endregion
  1198. return _view;
  1199. }
  1200. #endregion
  1201. #region 汉字转换拼音
  1202. private static Dictionary<int, List<string>> GetTotalPingYinDictionary(string text)
  1203. {
  1204. var chs = text.ToCharArray();
  1205. //记录每个汉字的全拼
  1206. Dictionary<int, List<string>> totalPingYinList = new Dictionary<int, List<string>>();
  1207. for (int i = 0; i < chs.Length; i++)
  1208. {
  1209. var pinyinList = new List<string>();
  1210. //是否是有效的汉字
  1211. if (ChineseChar.IsValidChar(chs[i]))
  1212. {
  1213. ChineseChar cc = new ChineseChar(chs[i]);
  1214. pinyinList = cc.Pinyins.Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
  1215. }
  1216. else
  1217. {
  1218. pinyinList.Add(chs[i].ToString());
  1219. }
  1220. //去除声调,转小写
  1221. pinyinList = pinyinList.ConvertAll(p => Regex.Replace(p, @"\d", "").ToLower());
  1222. //去重
  1223. pinyinList = pinyinList.Where(p => !string.IsNullOrWhiteSpace(p)).Distinct().ToList();
  1224. if (pinyinList.Any())
  1225. {
  1226. totalPingYinList[i] = pinyinList;
  1227. }
  1228. }
  1229. return totalPingYinList;
  1230. }
  1231. /// <summary>
  1232. /// 获取汉语拼音全拼
  1233. /// </summary>
  1234. /// <param name="text">The string.</param>
  1235. /// <returns></returns>
  1236. public static List<string> GetTotalPingYin(this string text)
  1237. {
  1238. var result = new List<string>();
  1239. foreach (var pys in GetTotalPingYinDictionary(text))
  1240. {
  1241. var items = pys.Value;
  1242. if (result.Count <= 0)
  1243. {
  1244. result = items;
  1245. }
  1246. else
  1247. {
  1248. //全拼循环匹配
  1249. var newTotalPingYinList = new List<string>();
  1250. foreach (var totalPingYin in result)
  1251. {
  1252. newTotalPingYinList.AddRange(items.Select(item => totalPingYin + item));
  1253. }
  1254. newTotalPingYinList = newTotalPingYinList.Distinct().ToList();
  1255. result = newTotalPingYinList;
  1256. }
  1257. }
  1258. return result;
  1259. }
  1260. /// <summary>
  1261. /// 获取中文第一个拼音
  1262. /// </summary>
  1263. /// <param name="text"></param>
  1264. /// <param name="isUp"></param>
  1265. /// <returns></returns>
  1266. public static string GetTotalPingYinFirst(this string text, bool isUp = true)
  1267. {
  1268. var returnstr = string.Empty;
  1269. var enResult = text.GetTotalPingYin();
  1270. if (enResult.Count == 0)
  1271. {
  1272. returnstr = text;
  1273. }
  1274. else if (isUp)
  1275. {
  1276. returnstr = enResult[0].ToUpper();
  1277. }
  1278. else
  1279. {
  1280. returnstr = enResult[0].ToLower();
  1281. }
  1282. return returnstr;
  1283. }
  1284. /// <summary>
  1285. /// 获取汉语拼音首字母
  1286. /// </summary>
  1287. /// <param name="text"></param>
  1288. /// <returns></returns>
  1289. public static List<string> GetFirstPingYin(this string text)
  1290. {
  1291. var result = new List<string>();
  1292. foreach (var pys in GetTotalPingYinDictionary(text))
  1293. {
  1294. var items = pys.Value;
  1295. if (result.Count <= 0)
  1296. {
  1297. result = items.ConvertAll(p => p.Substring(0, 1)).Distinct().ToList();
  1298. }
  1299. else
  1300. {
  1301. //首字母循环匹配
  1302. var newFirstPingYinList = new List<string>();
  1303. foreach (var firstPingYin in result)
  1304. {
  1305. newFirstPingYinList.AddRange(items.Select(item => firstPingYin + item.Substring(0, 1)));
  1306. }
  1307. newFirstPingYinList = newFirstPingYinList.Distinct().ToList();
  1308. result = newFirstPingYinList;
  1309. }
  1310. }
  1311. return result;
  1312. }
  1313. #endregion
  1314. #region 新客户资料表 操作记录
  1315. /// <summary>
  1316. /// 新客户资料表
  1317. /// 操作记录添加
  1318. /// </summary>
  1319. /// <param name="portType"></param>
  1320. /// <param name="operationEnum"></param>
  1321. /// <param name="userId"></param>
  1322. /// <param name="dataId"></param>
  1323. /// <param name="remark"></param>
  1324. /// <returns></returns>
  1325. public static async Task<bool> NewClientOperationRecord(int portType, OperationEnum operationEnum, int userId, int dataId, string remark)
  1326. {
  1327. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  1328. {
  1329. TableName = "Crm_NewClientData",
  1330. PortType = portType,
  1331. OperationItem = operationEnum,
  1332. DataId = dataId,
  1333. CreateUserId = userId,
  1334. CreateTime = DateTime.Now,
  1335. Remark = remark
  1336. };
  1337. bool add = await _tableOperationRecordRep._Add(_TableOperationRecord);
  1338. if (add) return false;
  1339. return false;
  1340. }
  1341. #endregion
  1342. #region 金额转大写
  1343. /// <summary>
  1344. /// 金额转换为大写数字
  1345. /// <para>1、支持的最大数字:999999999999.99(玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖元玖角玖分)</para>
  1346. /// <para>2、小数点后最多支持两位</para>
  1347. /// </summary>
  1348. /// <param name="num">数值</param>
  1349. /// <returns></returns>
  1350. public static string ConvertCNYUpper(this decimal num)
  1351. {
  1352. if (num == 0)
  1353. {
  1354. return "零元";
  1355. }
  1356. // 解决327000000转换后缺少单位万的问题
  1357. return ConvertToChinese(num);
  1358. }
  1359. #region 实例
  1360. /// <summary>
  1361. /// 要转换的数字
  1362. /// </summary>
  1363. private static decimal j;
  1364. /// <summary>
  1365. ///
  1366. /// </summary>
  1367. private static string[] NumChineseCharacter = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
  1368. /// <summary>
  1369. /// 判断输入的数字是否大于double类型
  1370. /// </summary>
  1371. private static bool IsNumber
  1372. {
  1373. get
  1374. {
  1375. if (j > decimal.MaxValue || j <= 0)
  1376. return false;
  1377. else
  1378. return true;
  1379. }
  1380. }
  1381. /// <summary>
  1382. /// 数字转换成大写汉字主函数
  1383. /// </summary>
  1384. /// <returns>返回转换后的大写汉字</returns>
  1385. public static string ConvertToChinese(decimal m)
  1386. {
  1387. j = m;
  1388. string bb = "";
  1389. if (IsNumber)
  1390. {
  1391. string str = j.ToString();
  1392. string[] Num = str.Split('.');
  1393. if (Num.Length == 1)
  1394. {
  1395. bb = NumberString(Num[0]) + "元整";
  1396. bb = bb.Replace("零零", "零");
  1397. }
  1398. else
  1399. {
  1400. bb = NumberString(Num[0]) + "元";
  1401. bb += FloatString(Num[1]);
  1402. bb = bb.Replace("零零", "零");
  1403. }
  1404. }
  1405. else
  1406. {
  1407. throw new FormatException("你输入的数字格式不正确或不是数字!");
  1408. }
  1409. return bb;
  1410. }
  1411. /// <summary>
  1412. /// 小数位转换只支持两位的小数
  1413. /// </summary>
  1414. /// <param name="Num">转换的小数</param>
  1415. /// <returns>小数转换成汉字</returns>
  1416. private static string FloatString(string Num)
  1417. {
  1418. string cc = "";
  1419. if (Num.Length > 2)
  1420. {
  1421. throw new FormatException("小数位数过多.");
  1422. }
  1423. else
  1424. {
  1425. string bb = ConvertString(Num);
  1426. int len = bb.IndexOf("零");
  1427. if (len != 0)
  1428. {
  1429. bb = bb.Replace("零", "");
  1430. if (bb.Length == 1)
  1431. {
  1432. cc = bb.Substring(0, 1) + "角";
  1433. }
  1434. else
  1435. {
  1436. cc = bb.Substring(0, 1) + "角";
  1437. cc += bb.Substring(1, 1) + "分";
  1438. }
  1439. }
  1440. else
  1441. cc = bb + "分";
  1442. }
  1443. return cc;
  1444. }
  1445. /// <summary>
  1446. /// 判断数字位数以进行拆分转换
  1447. /// </summary>
  1448. /// <param name="Num">要进行拆分的数字</param>
  1449. /// <returns>转换成的汉字</returns>
  1450. private static string NumberString(string Num)
  1451. {
  1452. string bb = "";
  1453. if (Num.Length <= 4)
  1454. {
  1455. bb = Convert4(Num);
  1456. }
  1457. else if (Num.Length > 4 && Num.Length <= 8)
  1458. {
  1459. bb = Convert4(Num.Substring(0, Num.Length - 4)) + "万";
  1460. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1461. }
  1462. else if (Num.Length > 8 && Num.Length <= 12)
  1463. {
  1464. bb = Convert4(Num.Substring(0, Num.Length - 8)) + "亿";
  1465. if (Convert4(Num.Substring(Num.Length - 8, 4)) == "")
  1466. if (Convert4(Num.Substring(Num.Length - 4, 4)) != "")
  1467. bb += "零";
  1468. else
  1469. bb += "";
  1470. else
  1471. bb += Convert4(Num.Substring(Num.Length - 8, 4)) + "万";
  1472. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1473. }
  1474. else
  1475. {
  1476. throw new Exception("整数部分最多支持12位");
  1477. }
  1478. return bb;
  1479. }
  1480. /// <summary>
  1481. /// 四位数字的转换
  1482. /// </summary>
  1483. /// <param name="Num">准备转换的四位数字</param>
  1484. /// <returns>转换以后的汉字</returns>
  1485. private static string Convert4(string Num)
  1486. {
  1487. string bb = "";
  1488. if (Num.Length == 1)
  1489. {
  1490. bb = ConvertString(Num);
  1491. }
  1492. else if (Num.Length == 2)
  1493. {
  1494. bb = ConvertString(Num);
  1495. bb = Convert2(bb);
  1496. }
  1497. else if (Num.Length == 3)
  1498. {
  1499. bb = ConvertString(Num);
  1500. bb = Convert3(bb);
  1501. }
  1502. else
  1503. {
  1504. bb = ConvertString(Num);
  1505. string cc = "";
  1506. string len = bb.Substring(0, 4);
  1507. if (len != "零零零零")
  1508. {
  1509. len = bb.Substring(0, 3);
  1510. if (len != "零零零")
  1511. {
  1512. bb = bb.Replace("零零零", "");
  1513. if (bb.Length == 1)
  1514. {
  1515. bb = bb.Substring(0, 1) + "仟";
  1516. }
  1517. else
  1518. {
  1519. if (bb.Substring(0, 1) != "零" && bb.Substring(0, 2) != "零")
  1520. cc = bb.Substring(0, 1) + "仟";
  1521. else
  1522. cc = bb.Substring(0, 1);
  1523. bb = cc + Convert3(bb.Substring(1, 3));
  1524. }
  1525. }
  1526. else
  1527. {
  1528. bb = bb.Replace("零零零", "零");
  1529. }
  1530. }
  1531. else
  1532. {
  1533. bb = bb.Replace("零零零零", "");
  1534. }
  1535. }
  1536. return bb;
  1537. }
  1538. /// <summary>
  1539. /// 将数字转换成汉字
  1540. /// </summary>
  1541. /// <param name="Num">需要转换的数字</param>
  1542. /// <returns>转换后的汉字</returns>
  1543. private static string ConvertString(string Num)
  1544. {
  1545. string bb = "";
  1546. for (int i = 0; i < Num.Length; i++)
  1547. {
  1548. bb += NumChineseCharacter[int.Parse(Num.Substring(i, 1))];
  1549. }
  1550. return bb;
  1551. }
  1552. /// <summary>
  1553. /// 两位数字的转换
  1554. /// </summary>
  1555. /// <param name="Num">两位数字</param>
  1556. /// <returns>转换后的汉字</returns>
  1557. private static string Convert2(string Num)
  1558. {
  1559. string bb = ""; string cc = "";
  1560. string len = Num.Substring(0, 1);
  1561. if (len != "零")
  1562. {
  1563. bb = Num.Replace("零", "");
  1564. if (bb.Length == 1)
  1565. {
  1566. cc = bb.Substring(0, 1) + "拾";
  1567. }
  1568. else
  1569. {
  1570. cc = bb.Substring(0, 1) + "拾";
  1571. cc += bb.Substring(1, 1);
  1572. }
  1573. }
  1574. else
  1575. cc = Num;
  1576. return cc;
  1577. }
  1578. /// <summary>
  1579. /// 三位数字的转换
  1580. /// </summary>
  1581. /// <param name="Num">三位数字</param>
  1582. /// <returns>转换后的汉字</returns>
  1583. private static string Convert3(string Num)
  1584. {
  1585. string bb = ""; string cc = "";
  1586. string len = Num.Substring(0, 2);
  1587. if (len != "零零")
  1588. {
  1589. bb = Num.Replace("零零", "");
  1590. if (bb.Length == 1)
  1591. {
  1592. bb = bb.Substring(0, 1) + "佰";
  1593. }
  1594. else
  1595. {
  1596. if (bb.Substring(0, 1) != "零")
  1597. cc = bb.Substring(0, 1) + "佰";
  1598. else
  1599. cc = bb.Substring(0, 1);
  1600. bb = cc + Convert2(bb.Substring(1, 2));
  1601. }
  1602. }
  1603. else
  1604. {
  1605. bb = Num.Replace("零零", "零");
  1606. }
  1607. return bb;
  1608. }
  1609. #endregion
  1610. #endregion
  1611. #region 数字验证
  1612. /// <summary>
  1613. /// 验证数字字符串
  1614. /// </summary>
  1615. /// <param name="numStr"></param>
  1616. /// <returns></returns>
  1617. public static bool IsNumeric(this string numStr)
  1618. {
  1619. bool isNumeric = Regex.IsMatch(numStr, @"^\d+$");
  1620. if (isNumeric)
  1621. {
  1622. return true;
  1623. }
  1624. return false;
  1625. }
  1626. #endregion
  1627. #region 日期 格式转换
  1628. /// <summary>
  1629. /// 验证日期字符串
  1630. /// </summary>
  1631. /// <param name="str"></param>
  1632. /// <returns></returns>
  1633. public static string ConvertToDatetime(this string str)
  1634. {
  1635. if (!string.IsNullOrEmpty(str))
  1636. {
  1637. DateTime currentDate = Convert.ToDateTime(str);
  1638. return $"{currentDate.Year}年{currentDate.Month}月{currentDate.Day}日";
  1639. }
  1640. return "";
  1641. }
  1642. #endregion
  1643. #region 月份/季度
  1644. /// <summary>
  1645. /// 获取月份对应的起始天数
  1646. /// </summary>
  1647. /// <param name="year"></param>
  1648. /// <returns></returns>
  1649. public static List<MonthInfo> GetMonthInfos(int year)
  1650. {
  1651. List<MonthInfo> months = new List<MonthInfo>();
  1652. if (year > 1)
  1653. {
  1654. for (int i = 1; i < 13; i++)
  1655. {
  1656. months.Add(new MonthInfo()
  1657. {
  1658. Month = i,
  1659. Days = new DaysInfo() { BeginDays = 1, EndDays = DateTime.DaysInMonth(year, i) }
  1660. });
  1661. }
  1662. }
  1663. return months;
  1664. }
  1665. /// <summary>
  1666. /// 获取季度对应的起始天数
  1667. /// </summary>
  1668. /// <param name="year"></param>
  1669. /// <returns></returns>
  1670. public static List<MonthInfo> GetQuarter(int year)
  1671. {
  1672. List<MonthInfo> months = new List<MonthInfo>();
  1673. months.Add(new MonthInfo() { Month = 1, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //1.1 - 3.31
  1674. months.Add(new MonthInfo() { Month = 2, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //4.1 - 6.30
  1675. months.Add(new MonthInfo() { Month = 3, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //7.1 - 9.31
  1676. months.Add(new MonthInfo() { Month = 4, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //10.1 - 12.31
  1677. return months;
  1678. }
  1679. public class MonthInfo
  1680. {
  1681. public int Month { get; set; }
  1682. public DaysInfo Days { get; set; }
  1683. }
  1684. public class DaysInfo
  1685. {
  1686. public int BeginDays { get; set; }
  1687. public int EndDays { get; set; }
  1688. }
  1689. #endregion
  1690. #region op行程单,黑屏幕代码
  1691. public static string GetCountryStandingTime(int diId)
  1692. {
  1693. DataTable datas = GetTableByBlackCode(diId);
  1694. string countryStr = "[黑屏代码未录入].";
  1695. if (datas.Rows.Count > 0)
  1696. {
  1697. var airDatas = from row in datas.AsEnumerable()
  1698. select new
  1699. {
  1700. Three = row.Field<string>("Three"),
  1701. Day = row.Field<string>("Day"),
  1702. ArrivedDate = row.Field<string>("ArrivedDate"),
  1703. };
  1704. //三字码信息
  1705. List<Res_ThreeCode> listcode = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToList();
  1706. //string countryStr = "";
  1707. int index = 0;
  1708. List<string> cityCodes = new List<string>();
  1709. //去掉开始和结束城市
  1710. foreach (var row in airDatas)
  1711. {
  1712. if (!string.IsNullOrEmpty(row.Three))
  1713. {
  1714. if (index == 0) cityCodes.Add(row.Three.Substring(3, 3)); //到达国家
  1715. else if (airDatas.Count() - 1 == index) cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1716. else cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1717. }
  1718. index++;
  1719. }
  1720. cityCodes = cityCodes.Distinct().ToList();
  1721. if (cityCodes.Count > 0) countryStr = "";
  1722. foreach (var item in cityCodes)
  1723. {
  1724. var airData = airDatas.Where(it => it.Three.Contains(item)).ToList();
  1725. string country = listcode.Find(it => it.Three.Equals(item))?.Country ?? "Unknown";
  1726. if (country.Equals("中国"))
  1727. {
  1728. country = listcode.Find(it => it.Three.Equals(item))?.City ?? "Unknown";
  1729. }
  1730. //int days = 0;
  1731. if (airData.Count == 2)
  1732. {
  1733. DateTime arr_dt = Convert.ToDateTime(airData[0].ArrivedDate); //抵达时间
  1734. DateTime dep_dt = Convert.ToDateTime(airData[1].Day); //离开时间
  1735. //days = (dep_dt - arr_dt).Days;
  1736. //countryStr += $@"{country}停留{days}日、";
  1737. countryStr += $@"{country}停留 日、";
  1738. }
  1739. }
  1740. if (countryStr.Length > 0) countryStr = countryStr.Substring(0, countryStr.Length - 1);
  1741. }
  1742. return countryStr;
  1743. }
  1744. /// <summary>
  1745. ///根据机票黑屏代码整理DataTable
  1746. /// </summary>
  1747. /// <param name="diid"></param>
  1748. /// <returns></returns>
  1749. public static DataTable GetTableByBlackCode1(int diid)
  1750. {
  1751. //黑屏代码信息
  1752. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1753. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1754. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1755. DataTable dt = new DataTable();
  1756. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1757. dt.Columns.Add("Date", typeof(string));//起飞日期
  1758. dt.Columns.Add("Three", typeof(string));//三字码
  1759. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1760. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1761. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1762. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1763. dt.Columns.Add("AirModel", typeof(string)); //机型
  1764. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1765. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1766. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1767. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1768. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1769. //判断是否录入黑屏代码
  1770. if (listcode.Count == 0 || listcode == null)
  1771. {
  1772. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  1773. }
  1774. else
  1775. {
  1776. //读取单段黑屏代码
  1777. for (int i = 0; i < listcode.Count; i++)
  1778. {
  1779. //去除序号
  1780. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1781. //去除多余空格,方法一Linq扩展方法
  1782. CodeList = CodeList.Where(str => str != "").ToArray();
  1783. CodeList = CodeList.Where(str => str != " ").ToArray();
  1784. //年
  1785. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  1786. //读取单条黑屏代码
  1787. for (int j = 0; j < CodeList.Length; j++)
  1788. {
  1789. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1790. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1791. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1792. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1793. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1794. //去除多余空格
  1795. Info = Info.Where(str => str != "").ToArray();
  1796. Info = Info.Where(str => str != " ").ToArray();
  1797. //判断黑屏代码是否正确拆分; 理应拆成9段
  1798. if (Info.Length < 9)
  1799. {
  1800. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  1801. }
  1802. else
  1803. {
  1804. try
  1805. {
  1806. //月
  1807. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  1808. //日
  1809. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  1810. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  1811. if (j > 0)
  1812. {
  1813. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1814. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1815. Temp = Temp.Where(str => str != "").ToArray();
  1816. Temp = Temp.Where(str => str != " ").ToArray();
  1817. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  1818. // 如果相邻月份之差小于0,则证明次一条年份需+1
  1819. if (month - monthTemp < 0)
  1820. {
  1821. year = year + 1;
  1822. }
  1823. //如果相邻代码三字码不顶真,提醒
  1824. string FootThree = Temp[2].Substring(3, 3);
  1825. string HeadThree = Info[2].Substring(0, 3);
  1826. if (FootThree != HeadThree)
  1827. {
  1828. //DelegationInfoService s = new DelegationInfoService();
  1829. //UsersService us = new UsersService();
  1830. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  1831. //77 行程
  1832. List<Grp_GroupsTaskAssignment> list2 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  1833. foreach (var temp in list2)
  1834. {
  1835. //if (temp.UId != 21)
  1836. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1837. // "黑屏代码提醒",
  1838. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1839. }
  1840. //85 机票预订
  1841. List<Grp_GroupsTaskAssignment> list6 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  1842. foreach (var temp in list6)
  1843. {
  1844. //if (temp.UId != 21)
  1845. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1846. // "黑屏代码提醒",
  1847. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1848. }
  1849. }
  1850. }
  1851. #endregion
  1852. #region 判断到达日期是否需要加1
  1853. if (Info[4].Contains("+"))
  1854. {
  1855. //日期+1
  1856. day = day + 1;
  1857. //判断是否进入下一月
  1858. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  1859. {
  1860. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  1861. month = month + 1;
  1862. //判断是否进入下一年
  1863. if (month > 12)
  1864. {
  1865. month = month - 12;
  1866. year = year + 1;
  1867. }
  1868. }
  1869. //月份整理格式
  1870. string monthTemp = month.ToString();
  1871. if (month < 10)
  1872. {
  1873. monthTemp = "0" + monthTemp;
  1874. }
  1875. //日期整理格式
  1876. string daytemp = day.ToString();
  1877. if (day < 10)
  1878. {
  1879. daytemp = "0" + daytemp;
  1880. }
  1881. string temp = Info[4].Split('+')[0];
  1882. //添加起飞数据
  1883. dt.Rows.Add(Info[0],
  1884. Info[1],
  1885. Info[2],
  1886. Info[3],
  1887. temp,
  1888. Info[5],
  1889. Info[6],
  1890. Info[7],
  1891. Info[8],
  1892. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  1893. year + "-" + monthTemp + "-" + daytemp,
  1894. "",
  1895. "0");
  1896. //加1天,添加到达数据
  1897. dt.Rows.Add(Info[0],
  1898. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  1899. Info[2],
  1900. Info[3],
  1901. temp,
  1902. Info[5],
  1903. Info[6],
  1904. Info[7],
  1905. Info[8],
  1906. year + "-" + monthTemp + "-" + daytemp,
  1907. year + "-" + monthTemp + "-" + daytemp,
  1908. "",
  1909. "1");
  1910. }
  1911. else
  1912. {
  1913. //月份整理格式
  1914. string monthTemp = month.ToString();
  1915. if (month < 10)
  1916. {
  1917. monthTemp = "0" + monthTemp;
  1918. }
  1919. //日期整理格式
  1920. string daytemp = day.ToString();
  1921. if (day < 10)
  1922. {
  1923. daytemp = "0" + daytemp;
  1924. }
  1925. dt.Rows.Add(Info[0],
  1926. Info[1],
  1927. Info[2],
  1928. Info[3],
  1929. Info[4],
  1930. Info[5],
  1931. Info[6],
  1932. Info[7],
  1933. Info[8],
  1934. year + "-" + monthTemp + "-" + daytemp,
  1935. year + "-" + monthTemp + "-" + daytemp,
  1936. "",
  1937. "0");
  1938. }
  1939. #endregion
  1940. }
  1941. catch (Exception ex)
  1942. {
  1943. string exstr = ex.Message.ToString();
  1944. }
  1945. }
  1946. }
  1947. //排序
  1948. dt.DefaultView.Sort = "Day asc";
  1949. dt = dt.DefaultView.ToTable();
  1950. }
  1951. }
  1952. return dt;
  1953. }
  1954. private readonly static string[] excludeArr = new string[] { "[中转]", "[转机]", "[国内]" };
  1955. /// <summary>
  1956. ///根据机票黑屏代码整理DataTable
  1957. /// </summary>
  1958. /// <param name="diid"></param>
  1959. /// <returns></returns>
  1960. public static DataTable GetTableByBlackCode(int diid)
  1961. {
  1962. //黑屏代码信息
  1963. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1964. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1965. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1966. DataTable dt = new DataTable();
  1967. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1968. dt.Columns.Add("Date", typeof(string));//起飞日期
  1969. dt.Columns.Add("Three", typeof(string));//三字码
  1970. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1971. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1972. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1973. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1974. dt.Columns.Add("AirModel", typeof(string)); //机型
  1975. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1976. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1977. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1978. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1979. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1980. //添加转机标识
  1981. dt.Columns.Add("isTransitShipment", typeof(bool));
  1982. //判断是否录入黑屏代码
  1983. if (listcode.Count == 0 || listcode == null)
  1984. {
  1985. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false);
  1986. }
  1987. else
  1988. {
  1989. //读取单段黑屏代码
  1990. for (int i = 0; i < listcode.Count; i++)
  1991. {
  1992. //去除序号
  1993. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1994. //去除多余空格,方法一Linq扩展方法
  1995. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  1996. //读取单条黑屏代码
  1997. for (int j = 0; j < CodeList.Length; j++)
  1998. {
  1999. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  2000. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  2001. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2002. //去除多余空格
  2003. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2004. //判断黑屏代码是否正确拆分; 理应拆成9段
  2005. if (Info.TakeWhile((x) =>
  2006. {
  2007. return !excludeArr.Contains(x);
  2008. }).Count() != 9)
  2009. {
  2010. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false);
  2011. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  2012. return dt;
  2013. }
  2014. else
  2015. {
  2016. try
  2017. {
  2018. var monthEn = Info[1].Substring(4, 3);
  2019. //月
  2020. int month = Convert.ToInt32(GetLonger(monthEn));
  2021. //日
  2022. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  2023. var time = new DateTime(DateTime.Now.Year, month, day); //
  2024. var isExist = Info.Contains("[中转]");
  2025. //dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2026. //dt.Columns.Add("Date", typeof(string));//起飞日期
  2027. //dt.Columns.Add("Three", typeof(string));//三字码
  2028. //dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2029. //dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2030. //dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2031. //dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2032. //dt.Columns.Add("AirModel", typeof(string)); //机型
  2033. //dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2034. //dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2035. //dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2036. //dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2037. //dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2038. dt.Rows.Add(Info[0],
  2039. Info[1],
  2040. Info[2],
  2041. Info[3],
  2042. Info[4],
  2043. Info[5],
  2044. Info[6],
  2045. Info[7],
  2046. Info[8],
  2047. time.ToString("yyyy-MM-dd"),
  2048. time.ToString("yyyy-MM-dd"),
  2049. "",
  2050. "0",
  2051. isExist
  2052. );
  2053. }
  2054. catch (Exception ex)
  2055. {
  2056. string exstr = ex.Message.ToString();
  2057. }
  2058. }
  2059. }
  2060. //排序
  2061. dt.DefaultView.Sort = "Day asc";
  2062. dt = dt.DefaultView.ToTable();
  2063. }
  2064. }
  2065. return dt;
  2066. }
  2067. /// <summary>
  2068. ///根据黑屏代码整理DataTable
  2069. /// </summary>
  2070. /// <param name="blackCode"></param>
  2071. /// <returns></returns>
  2072. public static DataTable GetTableByBlackCodeBySingle(Air_TicketBlackCode blackCode)
  2073. {
  2074. DataTable dt = new DataTable();
  2075. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2076. dt.Columns.Add("Date", typeof(string));//起飞日期
  2077. dt.Columns.Add("Three", typeof(string));//三字码
  2078. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2079. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2080. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2081. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2082. dt.Columns.Add("AirModel", typeof(string)); //机型
  2083. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2084. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2085. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2086. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2087. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2088. //添加转机标识
  2089. dt.Columns.Add("isTransitShipment", typeof(bool));
  2090. //添加国内段标识
  2091. dt.Columns.Add("isDomesticSection", typeof(bool));
  2092. //判断是否录入黑屏代码
  2093. if (blackCode == null)
  2094. {
  2095. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false, false);
  2096. }
  2097. else
  2098. {
  2099. var listcode = new List<Air_TicketBlackCode> { blackCode };
  2100. //读取单段黑屏代码
  2101. for (int i = 0; i < listcode.Count; i++)
  2102. {
  2103. //去除序号
  2104. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  2105. //去除多余空格,方法一Linq扩展方法
  2106. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2107. //读取单条黑屏代码
  2108. for (int j = 0; j < CodeList.Length; j++)
  2109. {
  2110. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  2111. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  2112. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2113. //去除多余空格
  2114. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2115. //判断黑屏代码是否正确拆分; 理应拆成9段
  2116. if (Info.TakeWhile((x) =>
  2117. {
  2118. return !excludeArr.Contains(x);
  2119. }).Count() != 9)
  2120. {
  2121. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false, false);
  2122. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  2123. return dt;
  2124. }
  2125. else
  2126. {
  2127. try
  2128. {
  2129. var monthEn = Info[1].Substring(4, 3);
  2130. //月
  2131. int month = Convert.ToInt32(GetLonger(monthEn));
  2132. //日
  2133. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  2134. var time = new DateTime(DateTime.Now.Year, month, day); //
  2135. var isExist = Info.Contains("[中转]");
  2136. if (!isExist)
  2137. {
  2138. isExist = Info.Contains("[转机]");
  2139. }
  2140. var isDomesticSection = Info.Contains("[国内]");
  2141. if (isDomesticSection)
  2142. {
  2143. continue;
  2144. }
  2145. dt.Rows.Add(Info[0],
  2146. Info[1],
  2147. Info[2],
  2148. Info[3],
  2149. Info[4],
  2150. Info[5],
  2151. Info[6],
  2152. Info[7],
  2153. Info[8],
  2154. time.ToString("yyyy-MM-dd"),
  2155. time.ToString("yyyy-MM-dd"),
  2156. "",
  2157. ExtractNumberAfterPlus(Info[4]),
  2158. isExist,
  2159. isDomesticSection
  2160. );
  2161. }
  2162. catch (Exception ex)
  2163. {
  2164. string exstr = ex.Message.ToString();
  2165. }
  2166. }
  2167. }
  2168. //排序
  2169. dt.DefaultView.Sort = "Day asc";
  2170. dt = dt.DefaultView.ToTable();
  2171. }
  2172. }
  2173. return dt;
  2174. }
  2175. private static int ExtractNumberAfterPlus(string input)
  2176. {
  2177. int value = 0;
  2178. if (string.IsNullOrEmpty(input))
  2179. {
  2180. return value;
  2181. }
  2182. string pattern = @"\+\d+"; // 匹配“+”及其后的数字
  2183. Match match = Regex.Match(input, pattern);
  2184. if (match.Success)
  2185. {
  2186. int.TryParse(match.Value.Substring(1), out value); // 去掉“+”符号,只保留数字部分
  2187. }
  2188. return value;
  2189. }
  2190. /// <summary>
  2191. /// 根据星期,月份的缩写,转换成数字或者全称
  2192. /// 根据币种中文名称返回币种代码
  2193. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  2194. /// 20210903贾文滔
  2195. /// </summary>
  2196. /// <param name="temp"></param>
  2197. /// <returns></returns>
  2198. public static string GetLonger(string temp)
  2199. {
  2200. string str = "";
  2201. switch (temp.ToUpper())
  2202. {
  2203. case "美元":
  2204. str = "USD";
  2205. break;
  2206. case "日元":
  2207. str = "JPY";
  2208. break;
  2209. case "英镑":
  2210. str = "GBP";
  2211. break;
  2212. case "欧元":
  2213. str = "EUR";
  2214. break;
  2215. case "港币":
  2216. str = "HKD";
  2217. break;
  2218. case "MO":
  2219. str = "星期一";
  2220. break;
  2221. case "TU":
  2222. str = "星期二";
  2223. break;
  2224. case "WE":
  2225. str = "星期三";
  2226. break;
  2227. case "TH":
  2228. str = "星期四";
  2229. break;
  2230. case "FR":
  2231. str = "星期五";
  2232. break;
  2233. case "SA":
  2234. str = "星期六";
  2235. break;
  2236. case "SU":
  2237. str = "星期天";
  2238. break;
  2239. case "JAN":
  2240. str = "01";
  2241. break;
  2242. case "FEB":
  2243. str = "02";
  2244. break;
  2245. case "MAR":
  2246. str = "03";
  2247. break;
  2248. case "APR":
  2249. str = "04";
  2250. break;
  2251. case "MAY":
  2252. str = "05";
  2253. break;
  2254. case "JUN":
  2255. str = "06";
  2256. break;
  2257. case "JUL":
  2258. str = "07";
  2259. break;
  2260. case "AUG":
  2261. str = "08";
  2262. break;
  2263. case "SEP":
  2264. str = "09";
  2265. break;
  2266. case "OCT":
  2267. str = "10";
  2268. break;
  2269. case "NOV":
  2270. str = "11";
  2271. break;
  2272. case "DEC":
  2273. str = "12";
  2274. break;
  2275. case "MONDAY":
  2276. str = "星期一";
  2277. break;
  2278. case "TUESDAY":
  2279. str = "星期二";
  2280. break;
  2281. case "WEDNESDAY":
  2282. str = "星期三";
  2283. break;
  2284. case "THURSDAY":
  2285. str = "星期四";
  2286. break;
  2287. case "FRIDAY":
  2288. str = "星期五";
  2289. break;
  2290. case "SATURDAY":
  2291. str = "星期六";
  2292. break;
  2293. case "SUNDAY":
  2294. str = "星期日";
  2295. break;
  2296. case "01":
  2297. str = "JAN";
  2298. break;
  2299. case "02":
  2300. str = "FEB";
  2301. break;
  2302. case "03":
  2303. str = "MAR";
  2304. break;
  2305. case "04":
  2306. str = "APR";
  2307. break;
  2308. case "05":
  2309. str = "MAY";
  2310. break;
  2311. case "06":
  2312. str = "JUN";
  2313. break;
  2314. case "07":
  2315. str = "JUL";
  2316. break;
  2317. case "08":
  2318. str = "AUG";
  2319. break;
  2320. case "09":
  2321. str = "SEP";
  2322. break;
  2323. case "10":
  2324. str = "OCT";
  2325. break;
  2326. case "11":
  2327. str = "NOV";
  2328. break;
  2329. case "12":
  2330. str = "DEC";
  2331. break;
  2332. case "2":
  2333. str = "空客A";
  2334. break;
  2335. case "3":
  2336. str = "空客A";
  2337. break;
  2338. case "7":
  2339. str = "波音";
  2340. break;
  2341. }
  2342. return str;
  2343. }
  2344. /// <summary>
  2345. /// 根据月份返回天数
  2346. /// </summary>
  2347. /// <param name="Month"></param>
  2348. /// <param name="year"></param>
  2349. /// <returns></returns>
  2350. public static string GetDaysByMonth(string Month, int year)
  2351. {
  2352. string str = "";
  2353. //判断是否是闰年
  2354. if (DateTime.IsLeapYear(year) == false)
  2355. {
  2356. switch (Month.ToUpper())
  2357. {
  2358. case "JAN":
  2359. str = "31";
  2360. break;
  2361. case "FEB":
  2362. str = "28";
  2363. break;
  2364. case "MAR":
  2365. str = "31";
  2366. break;
  2367. case "APR":
  2368. str = "30";
  2369. break;
  2370. case "MAY":
  2371. str = "31";
  2372. break;
  2373. case "JUN":
  2374. str = "30";
  2375. break;
  2376. case "JUL":
  2377. str = "31";
  2378. break;
  2379. case "AUG":
  2380. str = "31";
  2381. break;
  2382. case "SEP":
  2383. str = "30";
  2384. break;
  2385. case "OCT":
  2386. str = "31";
  2387. break;
  2388. case "NOV":
  2389. str = "30";
  2390. break;
  2391. case "DEC":
  2392. str = "31";
  2393. break;
  2394. case "01":
  2395. str = "31";
  2396. break;
  2397. case "02":
  2398. str = "28";
  2399. break;
  2400. case "03":
  2401. str = "31";
  2402. break;
  2403. case "04":
  2404. str = "30";
  2405. break;
  2406. case "05":
  2407. str = "31";
  2408. break;
  2409. case "06":
  2410. str = "30";
  2411. break;
  2412. case "07":
  2413. str = "31";
  2414. break;
  2415. case "08":
  2416. str = "31";
  2417. break;
  2418. case "09":
  2419. str = "30";
  2420. break;
  2421. case "10":
  2422. str = "31";
  2423. break;
  2424. case "11":
  2425. str = "30";
  2426. break;
  2427. case "12":
  2428. str = "31";
  2429. break;
  2430. }
  2431. }
  2432. else
  2433. {
  2434. switch (Month.ToUpper())
  2435. {
  2436. case "JAN":
  2437. str = "31";
  2438. break;
  2439. case "FEB":
  2440. str = "29";
  2441. break;
  2442. case "MAR":
  2443. str = "31";
  2444. break;
  2445. case "APR":
  2446. str = "30";
  2447. break;
  2448. case "MAY":
  2449. str = "31";
  2450. break;
  2451. case "JUN":
  2452. str = "30";
  2453. break;
  2454. case "JUL":
  2455. str = "31";
  2456. break;
  2457. case "AUG":
  2458. str = "31";
  2459. break;
  2460. case "SEP":
  2461. str = "30";
  2462. break;
  2463. case "OCT":
  2464. str = "31";
  2465. break;
  2466. case "NOV":
  2467. str = "30";
  2468. break;
  2469. case "DEC":
  2470. str = "31";
  2471. break;
  2472. case "01":
  2473. str = "31";
  2474. break;
  2475. case "02":
  2476. str = "29";
  2477. break;
  2478. case "03":
  2479. str = "31";
  2480. break;
  2481. case "04":
  2482. str = "30";
  2483. break;
  2484. case "05":
  2485. str = "31";
  2486. break;
  2487. case "06":
  2488. str = "30";
  2489. break;
  2490. case "07":
  2491. str = "31";
  2492. break;
  2493. case "08":
  2494. str = "31";
  2495. break;
  2496. case "09":
  2497. str = "30";
  2498. break;
  2499. case "10":
  2500. str = "31";
  2501. break;
  2502. case "11":
  2503. str = "30";
  2504. break;
  2505. case "12":
  2506. str = "31";
  2507. break;
  2508. }
  2509. }
  2510. return str;
  2511. }
  2512. /// <summary>
  2513. /// op行程单 团组 城市路径
  2514. /// </summary>
  2515. /// <param name="diid">团组Id</param>
  2516. /// <param name="separator">分隔符</param>
  2517. /// <returns></returns>
  2518. public static string GetGroupCityLine(int diid, string separator)
  2519. {
  2520. string city = string.Empty;
  2521. var blackCode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  2522. if (blackCode.Count > 0)
  2523. {
  2524. var black = blackCode.First();
  2525. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2526. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2527. if (blackSp.Length > 0)
  2528. {
  2529. try
  2530. {
  2531. var cityArrCode = new List<string>(20);
  2532. foreach (var item in blackSp)
  2533. {
  2534. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2535. var IndexSelect = itemSp[2];
  2536. var cityArrCodeLength = cityArrCode.Count - 1;
  2537. var startCity = IndexSelect.Substring(0, 3);
  2538. if (cityArrCodeLength > 0)
  2539. {
  2540. var arrEndCity = cityArrCode[cityArrCodeLength];
  2541. if (arrEndCity != startCity)
  2542. {
  2543. cityArrCode.Add(startCity.ToUpper());
  2544. }
  2545. }
  2546. else
  2547. {
  2548. cityArrCode.Add(startCity.ToUpper());
  2549. }
  2550. var endCity = IndexSelect.Substring(3, 3);
  2551. cityArrCode.Add(endCity.ToUpper());
  2552. }
  2553. var cityThree = string.Empty;
  2554. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2555. cityThree = cityThree.TrimEnd(',');
  2556. if (string.IsNullOrWhiteSpace(cityThree))
  2557. {
  2558. throw new Exception("error");
  2559. }
  2560. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2561. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2562. foreach (var item in cityArrCode)
  2563. {
  2564. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2565. if (find != null)
  2566. {
  2567. city += find.City + separator;
  2568. }
  2569. else
  2570. {
  2571. city += item + "[三字码未收录]" + separator;
  2572. }
  2573. }
  2574. city = city.TrimEnd(char.Parse(separator));
  2575. }
  2576. catch (Exception e)
  2577. {
  2578. city = "[黑屏代码格式不正确!]";
  2579. }
  2580. }
  2581. }
  2582. else city = "[未录入黑屏代码]";
  2583. return city;
  2584. }
  2585. /// <summary>
  2586. /// op行程单 团组 城市路径
  2587. /// </summary>
  2588. /// <param name="black">黑屏代码实例</param>
  2589. /// <param name="separator">分隔符</param>
  2590. /// <returns></returns>
  2591. public static string GetGroupCityLine(Air_TicketBlackCode black, string separator)
  2592. {
  2593. string city = string.Empty;
  2594. if (black != null)
  2595. {
  2596. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2597. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2598. if (blackSp.Length > 0)
  2599. {
  2600. try
  2601. {
  2602. var cityArrCode = new List<string>(20);
  2603. foreach (var item in blackSp)
  2604. {
  2605. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2606. var IndexSelect = itemSp[2];
  2607. var cityArrCodeLength = cityArrCode.Count - 1;
  2608. var startCity = IndexSelect.Substring(0, 3);
  2609. if (cityArrCodeLength > 0)
  2610. {
  2611. var arrEndCity = cityArrCode[cityArrCodeLength];
  2612. if (arrEndCity != startCity)
  2613. {
  2614. cityArrCode.Add(startCity.ToUpper());
  2615. }
  2616. }
  2617. else
  2618. {
  2619. cityArrCode.Add(startCity.ToUpper());
  2620. }
  2621. var endCity = IndexSelect.Substring(3, 3);
  2622. cityArrCode.Add(endCity.ToUpper());
  2623. }
  2624. var cityThree = string.Empty;
  2625. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2626. cityThree = cityThree.TrimEnd(',');
  2627. if (string.IsNullOrWhiteSpace(cityThree))
  2628. {
  2629. throw new Exception("error");
  2630. }
  2631. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2632. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2633. foreach (var item in cityArrCode)
  2634. {
  2635. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2636. if (find != null)
  2637. {
  2638. city += find.City + separator;
  2639. }
  2640. else
  2641. {
  2642. city += item + "[三字码未收录]" + separator;
  2643. }
  2644. }
  2645. city = city.TrimEnd(char.Parse(separator));
  2646. }
  2647. catch (Exception e)
  2648. {
  2649. city = "[黑屏代码格式不正确!]";
  2650. }
  2651. }
  2652. }
  2653. else city = "[黑屏代码有误!]";
  2654. return city;
  2655. }
  2656. /// <summary>
  2657. /// op行程单 团组 城市路径
  2658. /// </summary>
  2659. /// <param name="diids">团组Id</param>
  2660. /// <param name="separator">分隔符</param>
  2661. /// <returns></returns>
  2662. public static Dictionary<int, string> GetGroupCityLineItem(List<int> diids, string separator)
  2663. {
  2664. Dictionary<int, string> dicCitys = new Dictionary<int, string>();
  2665. var cityCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  2666. var blackCodes = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && diids.Contains(x.DiId)).ToList();
  2667. foreach (var diid in diids)
  2668. {
  2669. string city = string.Empty;
  2670. var blackCode = blackCodes.Where(it => it.DiId == diid).ToList();
  2671. if (blackCode.Count > 0)
  2672. {
  2673. var black = blackCode.First();
  2674. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2675. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2676. if (blackSp.Length > 0)
  2677. {
  2678. try
  2679. {
  2680. var cityArrCode = new List<string>(20);
  2681. foreach (var item in blackSp)
  2682. {
  2683. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2684. var IndexSelect = itemSp[2];
  2685. var cityArrCodeLength = cityArrCode.Count - 1;
  2686. var startCity = IndexSelect.Substring(0, 3);
  2687. if (cityArrCodeLength > 0)
  2688. {
  2689. var arrEndCity = cityArrCode[cityArrCodeLength];
  2690. if (arrEndCity != startCity)
  2691. {
  2692. cityArrCode.Add(startCity.ToUpper());
  2693. }
  2694. }
  2695. else
  2696. {
  2697. cityArrCode.Add(startCity.ToUpper());
  2698. }
  2699. var endCity = IndexSelect.Substring(3, 3);
  2700. cityArrCode.Add(endCity.ToUpper());
  2701. }
  2702. var cityThree = string.Empty;
  2703. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2704. cityThree = cityThree.TrimEnd(',');
  2705. if (string.IsNullOrWhiteSpace(cityThree))
  2706. {
  2707. throw new Exception("error");
  2708. }
  2709. var cityArr = cityCodes.Where(it => cityThree.Contains(it.Three.ToUpper())).ToList();
  2710. foreach (var item in cityArrCode)
  2711. {
  2712. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2713. if (find != null)
  2714. {
  2715. city += find.City + separator;
  2716. }
  2717. else
  2718. {
  2719. city += item + "[三字码未收录]" + separator;
  2720. }
  2721. }
  2722. city = city.TrimEnd(char.Parse(separator));
  2723. }
  2724. catch (Exception e)
  2725. {
  2726. city = "[黑屏代码格式不正确!]";
  2727. }
  2728. }
  2729. }
  2730. else city = "[未录入黑屏代码]";
  2731. dicCitys.Add(diid, city);
  2732. }
  2733. return dicCitys;
  2734. }
  2735. /// <summary>
  2736. /// op行程单相关团组信息 含途径城市
  2737. /// </summary>
  2738. /// <returns></returns>
  2739. public static async Task<List<MateOpGroupPageListView>> MateOpGroupPageListRedis()
  2740. {
  2741. List<MateOpGroupPageListView> _views = new List<MateOpGroupPageListView>();
  2742. string viewStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("MateOpGroupPageList");//string 取
  2743. if (!string.IsNullOrEmpty(viewStr))
  2744. {
  2745. _views = JsonConvert.DeserializeObject<List<MateOpGroupPageListView>>(viewStr);
  2746. }
  2747. else
  2748. {
  2749. string sql = string.Format($@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2750. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  2751. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  2752. JietuanOperator,IsSure,CreateTime,VisitCountry
  2753. From (
  2754. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  2755. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  2756. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  2757. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  2758. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.VisitCountry
  2759. From Grp_DelegationInfo gdi
  2760. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2761. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2762. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2763. Where gdi.IsDel = 0
  2764. ) temp");
  2765. _views = _dirRep._sqlSugar.SqlQueryable<MateOpGroupPageListView>(sql).ToList();
  2766. #region 处理所属部门
  2767. /*
  2768. * 1.sq 和 gyy 等显示 市场部
  2769. * 2.王鸽和主管及张总还有管理员号统一国交部
  2770. * 2-1. 4 管理员 ,21 张海麟
  2771. */
  2772. List<int> userIds = _views.Select(it => it.JietuanOperatorId).ToList();
  2773. List<int> userIds1 = new List<int>() { 4, 21 };
  2774. var UserDepDatas = _dirRep._sqlSugar.Queryable<Sys_Users>()
  2775. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2776. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2777. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2778. .ToList();
  2779. #endregion
  2780. _views.ForEach(it =>
  2781. {
  2782. it.RouteCity = GetGroupCityLine(it.Id, @"/");
  2783. it.Department = UserDepDatas.Find(it1 => it.JietuanOperatorId == it1.UserId)?.DepName ?? "Unknown";
  2784. });
  2785. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay;
  2786. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("MateOpGroupPageList", JsonConvert.SerializeObject(_views), ts);//string 存
  2787. }
  2788. return _views;
  2789. }
  2790. /// <summary>
  2791. /// 获取黑屏代码日期列表
  2792. /// </summary>
  2793. /// <param name="dt"></param>
  2794. /// <returns></returns>
  2795. public static List<string> GetTimeListByDataTable(DataTable dt)
  2796. {
  2797. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  2798. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  2799. List<string> timeList = new List<string>();
  2800. while (datestart <= dateend)
  2801. {
  2802. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  2803. datestart = datestart.AddDays(1);
  2804. }
  2805. return timeList;
  2806. }
  2807. const decimal conversion = 1.61M;
  2808. /// <summary>
  2809. /// 简要行程
  2810. /// </summary>
  2811. /// <param name="diid"></param>
  2812. /// <returns></returns>
  2813. public static Result GetBriefStroke(int diid)
  2814. {
  2815. DataTable resultTable = GetTableByBlackCode(diid);
  2816. if (resultTable == null)
  2817. {
  2818. return new Result { Code = -1, Msg = "黑屏代码有误或黑屏代码未录入" };
  2819. }
  2820. if (resultTable.Rows.Count == 0 || string.IsNullOrWhiteSpace(resultTable.Rows[0][1].ToString()))
  2821. {
  2822. string msg = string.Empty;
  2823. if (resultTable.Rows.Count > 0)
  2824. {
  2825. msg = resultTable.Rows[0]["Error"].ToString();
  2826. }
  2827. return new Result { Code = -1, Msg = $"黑屏代码有误;{msg}" };
  2828. }
  2829. var timeArr = GetTimeListByDataTable(resultTable);
  2830. var threeCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList(); //三字码
  2831. var airCompanys = _dirRep._sqlSugar.Queryable<Res_AirCompany>().Where(it => it.IsDel == 0).ToList(); //航司公司
  2832. var obDatas = _dirRep._sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == diid).ToList(); //公务信息
  2833. var NewListTravel = new List<Grp_TravelList>();
  2834. var index = 0;
  2835. var stopCity = string.Empty;
  2836. foreach (var item in timeArr)
  2837. {
  2838. string trip = string.Empty;
  2839. string weekDay = string.Empty;
  2840. DateTime time = DateTime.Now;
  2841. if (DateTime.TryParse(item, out time))
  2842. {
  2843. weekDay = weekdays[(int)time.DayOfWeek];
  2844. }
  2845. else
  2846. {
  2847. weekDay = "日期格式不正确!";
  2848. }
  2849. var empty = "【未收入该三字码!请机票同事录入】";
  2850. var tabSelect = resultTable.Select(string.Format("Day = '{0}'", item));
  2851. var isMoreTraffic = false;
  2852. if (tabSelect.Length > 0)
  2853. {
  2854. isMoreTraffic = true;
  2855. var takeOffTime = DateTime.Parse(item);
  2856. var fallToTime = DateTime.Parse(item);
  2857. Res_ThreeCode start_Object = null;
  2858. Res_ThreeCode end_Object = null;
  2859. //bool isTrade = false;
  2860. //air 处理
  2861. foreach (var tabRow in tabSelect)
  2862. {
  2863. takeOffTime = DateTime.Parse(item);
  2864. fallToTime = DateTime.Parse(item);
  2865. var takeOff = tabRow["StartTime"].ToString();
  2866. var fallTo = tabRow["EndTime"].ToString();
  2867. takeOffTime = takeOffTime.AddHours(int.Parse(takeOff.Substring(0, 2)));
  2868. takeOffTime = takeOffTime.AddMinutes(int.Parse(takeOff.Substring(2, 2)));
  2869. fallToTime = fallToTime.AddHours(int.Parse(fallTo.Substring(0, 2)));
  2870. fallToTime = fallToTime.AddMinutes(int.Parse(fallTo.Substring(2, 2)));
  2871. var threeCode = tabRow["Three"].ToString();
  2872. var start = threeCode.Substring(0, 3);
  2873. var end = threeCode.Substring(3, 3);
  2874. stopCity = end;
  2875. start_Object = threeCodes.Find(x => x.Three.ToUpper() == start.ToUpper());
  2876. end_Object = threeCodes.Find(x => x.Three.ToUpper() == end.ToUpper());
  2877. if (start_Object == null)
  2878. {
  2879. start_Object = new Res_ThreeCode()
  2880. {
  2881. AirPort = empty,
  2882. AirPort_En = empty,
  2883. City = empty,
  2884. Country = empty,
  2885. Four = empty,
  2886. Three = empty,
  2887. };
  2888. }
  2889. if (end_Object == null)
  2890. {
  2891. end_Object = new Res_ThreeCode()
  2892. {
  2893. AirPort = empty,
  2894. AirPort_En = empty,
  2895. City = empty,
  2896. Country = empty,
  2897. Four = empty,
  2898. Three = empty,
  2899. };
  2900. }
  2901. //航班号
  2902. string flightcode = tabRow["Fliagtcode"].ToString();
  2903. trip += $"{takeOffTime.ToString("HH:mm")}—{fallToTime.ToString("HH:mm")} {start_Object.City}—{end_Object.City} 航班号:{flightcode}\r\n";
  2904. }
  2905. //var airArrive = fallToTime; //航班落地时间
  2906. time = fallToTime.AddHours(1.5); //出机场一个半小时
  2907. string Time = string.Empty;
  2908. string Distance = string.Empty;
  2909. int GetGoogleResult = 0;
  2910. int GetDistResult = 0;
  2911. JObject Result = null;
  2912. try
  2913. {
  2914. Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace(" ", "").Trim();
  2915. Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString().Replace(" ", "").Trim();
  2916. if (Time.Contains("hours"))
  2917. {
  2918. Time = Time.Replace("hours", "小时");
  2919. }
  2920. if (Time.Contains("hour"))
  2921. {
  2922. Time = Time.Replace("hour", "小时");
  2923. }
  2924. Time = Time.Replace("mins", "分钟");
  2925. if (Distance.Contains("mi"))
  2926. {
  2927. var distSp = Regex.Split(Distance, "mi");
  2928. if (distSp.Length > 0)
  2929. {
  2930. Distance = (decimal.Parse(distSp[0]) * conversion).ToString("#0.00") + " 公里";
  2931. }
  2932. }
  2933. if (Distance.Contains("km"))
  2934. {
  2935. Distance = Distance.Replace("km", "公里");
  2936. }
  2937. if (Time.Contains("小时"))
  2938. {
  2939. var xs = Regex.Split(Time, "小时");
  2940. var xsValue = int.Parse(xs[0]);
  2941. var fz = Regex.Split(xs[1], "分钟");
  2942. var fzValue = int.Parse(fz[0]);
  2943. GetGoogleResult = xsValue * 60;
  2944. GetGoogleResult += fzValue;
  2945. }
  2946. else if (Time.Contains("分钟"))
  2947. {
  2948. GetGoogleResult = int.Parse(Regex.Split(Time, "分钟")[0]);
  2949. }
  2950. if (Distance.Contains("公里"))
  2951. {
  2952. GetDistResult = (int)decimal.Parse(Regex.Split(Distance, "公里")[0]);
  2953. }
  2954. if (GetGoogleResult > 0 && GetGoogleResult % 5 != 0)
  2955. {
  2956. while (GetGoogleResult % 5 != 0)
  2957. {
  2958. GetGoogleResult++;
  2959. }
  2960. }
  2961. if (GetDistResult % 5 != 0 && GetDistResult > 0)
  2962. {
  2963. while (GetDistResult % 5 != 0)
  2964. {
  2965. GetDistResult++;
  2966. }
  2967. }
  2968. int H = (GetGoogleResult / 60);
  2969. int m = (GetGoogleResult % 60);
  2970. string TimeStr = string.Empty;
  2971. if (H != 0)
  2972. {
  2973. if (H < 10)
  2974. {
  2975. TimeStr += "0" + H + "小时";
  2976. }
  2977. else
  2978. {
  2979. TimeStr += H + "小时";
  2980. }
  2981. }
  2982. if (m < 10)
  2983. {
  2984. TimeStr += "0" + m + "分钟";
  2985. }
  2986. else
  2987. {
  2988. TimeStr += m + "分钟";
  2989. }
  2990. Time = TimeStr;
  2991. Distance = GetDistResult.ToString() + "公里";
  2992. }
  2993. catch (Exception ex)
  2994. {
  2995. Time = "未知!";
  2996. Distance = "未知!";
  2997. }
  2998. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区 路程{Distance},耗时{Time})";
  2999. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区)";
  3000. time = time.AddMinutes(GetGoogleResult); //到达市区时间
  3001. string tripDate = Convert.ToDateTime(item).ToString("M月d日");
  3002. if (index == timeArr.Count - 1)
  3003. {
  3004. NewListTravel.Add(new Grp_TravelList
  3005. {
  3006. CreateTime = DateTime.Now,
  3007. CreateUserId = 0,
  3008. Diid = diid,
  3009. Date = tripDate,
  3010. Trip = trip,
  3011. WeekDay = weekDay,
  3012. Days = index + 1,
  3013. Traffic_First = "飞机",
  3014. Traffic_Second = "汽车",
  3015. Diffgroup = 1,
  3016. Issel = 1,
  3017. IsDel = 0,
  3018. });
  3019. continue;
  3020. }
  3021. if (time.Day != fallToTime.Day) //超出一天
  3022. {
  3023. NewListTravel.Add(new Grp_TravelList
  3024. {
  3025. CreateTime = DateTime.Now,
  3026. CreateUserId = 0,
  3027. Diid = diid,
  3028. Date = tripDate,
  3029. Trip = trip,
  3030. WeekDay = weekDay,
  3031. Days = index + 1,
  3032. Traffic_First = "飞机",
  3033. Traffic_Second = "汽车",
  3034. Diffgroup = 1,
  3035. Issel = 1,
  3036. IsDel = 0,
  3037. });
  3038. continue;
  3039. }
  3040. var obInfo = obDatas.Find(it => Convert.ToDateTime(it.Date).ToString("M月d日").Equals(tripDate));
  3041. string obtime = "";
  3042. string obcontent = "";
  3043. if (obInfo != null)
  3044. {
  3045. obtime = obInfo.Time;
  3046. obcontent = $"拜访{obInfo.Client ?? "公务出访单位未录入"}{obInfo.Job ?? "公务出访联系人职务未录入"}{obInfo.Contact ?? "公务出访联系人职务未录入"}";
  3047. }
  3048. bool obTime_bool = DateTime.TryParse(obtime, out DateTime obTimeDt);
  3049. if (time.Hour < 9) // && (airArrive < new DateTime(airArrive.Year,airArrive.Month,airArrive.Day,6, 30, 0))
  3050. {
  3051. if (obTime_bool)
  3052. {
  3053. if (obTimeDt.Hour < 9)
  3054. {
  3055. trip += $"{obTimeDt.ToString("HH:mm")}—10:30 {obcontent};\r\n";
  3056. }
  3057. }
  3058. else
  3059. {
  3060. trip += "09:00—10:30 公务活动;\r\n";
  3061. }
  3062. }
  3063. else if (time.Hour < 10)
  3064. {
  3065. if (obTime_bool)
  3066. {
  3067. if (obTimeDt.Hour < 10)
  3068. {
  3069. trip += $"{obTimeDt.ToString("HH:mm")}—12:00 {obcontent};\r\n";
  3070. }
  3071. }
  3072. else
  3073. {
  3074. trip += "10:30—12:00 公务活动;\r\n";
  3075. }
  3076. }
  3077. if (time.Hour < 13)
  3078. {
  3079. //trip += $"\r\n{time.ToString("HH:mm")} 午餐于当地餐厅;";
  3080. }
  3081. if (time < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  3082. {
  3083. if (obTime_bool)
  3084. {
  3085. if (obTimeDt < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  3086. {
  3087. trip += $"{obTimeDt.ToString("HH:mm")}—16:00 {obcontent};\r\n";
  3088. }
  3089. }
  3090. else
  3091. {
  3092. trip += "14:00—16:00 公务活动;\r\n";
  3093. }
  3094. }
  3095. else if (time.Hour < 16)
  3096. {
  3097. if (obTime_bool)
  3098. {
  3099. if (obTimeDt.Hour < 16)
  3100. {
  3101. trip += $"{obTimeDt.ToString("HH:mm")}—17:30 {obcontent};\r\n";
  3102. }
  3103. }
  3104. else
  3105. {
  3106. trip += "16:00—17:30 公务活动;\r\n";
  3107. }
  3108. }
  3109. //if (time.Hour < 18)
  3110. //{
  3111. // trip += $"\r\n18:00 晚餐于当地餐厅;";
  3112. //}
  3113. //time = time.AddHours(1);
  3114. //trip += $"\r\n{time.ToString("HH:mm")} 搭乘专车前往酒店,抵达后办理入住;";
  3115. }
  3116. else
  3117. {
  3118. var end_Object = threeCodes.Find(x => x.Three.ToUpper() == stopCity.ToUpper());
  3119. if (end_Object == null)
  3120. {
  3121. end_Object = new Res_ThreeCode()
  3122. {
  3123. AirPort = empty,
  3124. AirPort_En = empty,
  3125. City = empty,
  3126. Country = empty,
  3127. Four = empty,
  3128. Three = empty,
  3129. };
  3130. }
  3131. //trip += $"{end_Object.City}\r\n";
  3132. // trip += @"08:00 早餐于酒店;
  3133. //09:00—10:30 公务活动;
  3134. //12:00 午餐于当地餐厅;
  3135. //14:00—16:00 公务活动;
  3136. //18:00 晚餐于当地餐厅;
  3137. //19:00 入住酒店休息;";
  3138. trip += "09:00—10:30 公务活动;\r\n14:00—16:00 公务活动;\r\n";
  3139. }
  3140. string[] traffic = new string[] { "飞机", "汽车" };
  3141. if (!isMoreTraffic)
  3142. {
  3143. traffic = new string[] { "汽车", "" };
  3144. }
  3145. NewListTravel.Add(new Grp_TravelList
  3146. {
  3147. CreateTime = DateTime.Now,
  3148. CreateUserId = 0,
  3149. Diid = diid,
  3150. Date = Convert.ToDateTime(item).ToString("M月d日"),
  3151. Trip = trip,
  3152. WeekDay = weekDay,
  3153. Days = index + 1,
  3154. Traffic_First = traffic[0],
  3155. Traffic_Second = traffic[1],
  3156. Diffgroup = 1,
  3157. Issel = 1,
  3158. IsDel = 0,
  3159. });
  3160. index++;
  3161. }
  3162. return new Result() { Code = 0, Msg = "获取成功!", Data = NewListTravel };
  3163. }
  3164. /// <summary>
  3165. /// 根据日期获取星期
  3166. /// </summary>
  3167. /// <param name="dtStr"></param>
  3168. /// <returns></returns>
  3169. public static string GetWeek(this string dtStr)
  3170. {
  3171. string week = "";
  3172. bool isDt = DateTime.TryParse(dtStr, out DateTime dt);
  3173. if (isDt)
  3174. {
  3175. week = weekdays[(int)dt.DayOfWeek];
  3176. }
  3177. return week;
  3178. }
  3179. #endregion
  3180. #region 计算国家城市当时时间
  3181. /// <summary>
  3182. /// 中文城市名称映射
  3183. /// </summary>
  3184. private static readonly Dictionary<string, string> _timeZoneCityMappings = new Dictionary<string, string>
  3185. {
  3186. {"Africa/Abidjan","非洲/阿比让"} ,
  3187. {"Africa/Accra","非洲/阿克拉"} ,
  3188. {"Africa/Addis_Ababa","非洲/亚的斯亚贝巴"} ,
  3189. {"Africa/Algiers","非洲/阿尔及尔"} ,
  3190. {"Africa/Asmara","非洲/阿斯马拉"} ,
  3191. {"Africa/Asmera","非洲/阿斯梅拉"} ,
  3192. {"Africa/Bamako","非洲/巴马科"} ,
  3193. {"Africa/Bangui","非洲/班吉"} ,
  3194. {"Africa/Banjul","非洲/班珠尔"} ,
  3195. {"Africa/Bissau","非洲/比绍"} ,
  3196. {"Africa/Blantyre","非洲/布兰太尔"} ,
  3197. {"Africa/Brazzaville","非洲/布拉柴维尔"} ,
  3198. {"Africa/Bujumbura","非洲/布琼布拉"} ,
  3199. {"Africa/Cairo","非洲/开罗"} ,
  3200. {"Africa/Casablanca","非洲/卡萨布兰卡"} ,
  3201. {"Africa/Ceuta","非洲/休达"} ,
  3202. {"Africa/Conakry","非洲/科纳克里"} ,
  3203. {"Africa/Dakar","非洲/达喀尔"} ,
  3204. {"Africa/Dar_es_Salaam","非洲/达累斯萨拉姆"} ,
  3205. {"Africa/Djibouti","非洲/吉布提"} ,
  3206. {"Africa/Douala","非洲/杜阿拉"} ,
  3207. {"Africa/El_Aaiun","非洲/阿尤恩"} ,
  3208. {"Africa/Freetown","非洲/弗里敦"} ,
  3209. {"Africa/Gaborone","非洲/哈博罗内"} ,
  3210. {"Africa/Harare","非洲/哈拉雷"} ,
  3211. {"Africa/Johannesburg","非洲/约翰内斯堡"} ,
  3212. {"Africa/Juba","非洲/朱巴"} ,
  3213. {"Africa/Kampala","非洲/坎帕拉"} ,
  3214. {"Africa/Khartoum","非洲/喀土穆"} ,
  3215. {"Africa/Kigali","非洲/基加利"} ,
  3216. {"Africa/Kinshasa","非洲/金沙萨"} ,
  3217. {"Africa/Lagos","非洲/拉各斯"} ,
  3218. {"Africa/Libreville","非洲/利伯维尔"} ,
  3219. {"Africa/Lome","非洲/洛美"} ,
  3220. {"Africa/Luanda","非洲/罗安达"} ,
  3221. {"Africa/Lubumbashi","非洲/卢本巴希"} ,
  3222. {"Africa/Lusaka","非洲/卢萨卡"} ,
  3223. {"Africa/Malabo","非洲/马拉博"} ,
  3224. {"Africa/Maputo","非洲/马普托"} ,
  3225. {"Africa/Maseru","非洲/马塞卢"} ,
  3226. {"Africa/Mbabane","非洲/姆巴巴内"} ,
  3227. {"Africa/Mogadishu","非洲/摩加迪沙"} ,
  3228. {"Africa/Monrovia","非洲/蒙罗维亚"} ,
  3229. {"Africa/Nairobi","非洲/内罗毕"} ,
  3230. {"Africa/Ndjamena","非洲/恩贾梅纳"} ,
  3231. {"Africa/Niamey","非洲/尼亚美"} ,
  3232. {"Africa/Nouakchott","非洲/努瓦克肖特"} ,
  3233. {"Africa/Ouagadougou","非洲/瓦加杜古"} ,
  3234. {"Africa/Porto-Novo","非洲/波多诺伏"} ,
  3235. {"Africa/Sao_Tome","非洲/圣多美"} ,
  3236. {"Africa/Timbuktu","非洲/廷巴克图"} ,
  3237. {"Africa/Tripoli","非洲/的黎波里"} ,
  3238. {"Africa/Tunis","非洲/突尼斯"} ,
  3239. {"Africa/Windhoek","非洲/温得和克"} ,
  3240. {"America/Adak","美洲/埃达克"} ,
  3241. {"America/Anchorage","美洲/安克雷奇"} ,
  3242. {"America/Anguilla","美洲/安圭拉"} ,
  3243. {"America/Antigua","美洲/安提瓜岛"} ,
  3244. {"America/Araguaina","美洲/阿拉瓜纳"} ,
  3245. {"America/Argentina/Buenos_Aires","美洲/阿根廷/布宜诺斯艾利斯"} ,
  3246. {"America/Argentina/Catamarca","美洲/阿根廷/卡塔马卡"} ,
  3247. {"America/Argentina/ComodRivadavia","美洲/阿根廷/科莫德里瓦达维亚"} ,
  3248. {"America/Argentina/Cordoba","美洲/阿根廷/科尔多瓦"} ,
  3249. {"America/Argentina/Jujuy","美洲/阿根廷/胡胡伊省"} ,
  3250. {"America/Argentina/La_Rioja","美洲/阿根廷/拉里奥哈"} ,
  3251. {"America/Argentina/Mendoza","美洲/阿根廷/门多萨"} ,
  3252. {"America/Argentina/Rio_Gallegos","美洲/阿根廷/里奥加耶戈斯"} ,
  3253. {"America/Argentina/Salta","美洲/阿根廷/萨尔塔"} ,
  3254. {"America/Argentina/San_Juan","美洲/阿根廷/San_Juan"} ,
  3255. {"America/Argentina/San_Luis","美洲/阿根廷/圣路易斯"} ,
  3256. {"America/Argentina/Tucuman","美洲/阿根廷/图库曼"} ,
  3257. {"America/Argentina/Ushuaia","美洲/阿根廷/乌斯怀亚"} ,
  3258. {"America/Aruba","美洲/阿鲁巴岛"} ,
  3259. {"America/Asuncion","美洲/亚松森"} ,
  3260. {"America/Atikokan","美洲/阿蒂科坎"} ,
  3261. {"America/Atka","美洲/阿特卡"} ,
  3262. {"America/Bahia","美洲/巴伊亚"} ,
  3263. {"America/Bahia_Banderas","美洲/巴伊亚_班德拉斯"} ,
  3264. {"America/Barbados","美洲/巴巴多斯"} ,
  3265. {"America/Belem","美洲/贝伦"} ,
  3266. {"America/Belize","美洲/伯利兹"} ,
  3267. {"America/Blanc-Sablon","America/Blanc-Sablon"} ,
  3268. {"America/Boa_Vista","美洲/博阿维斯塔"} ,
  3269. {"America/Bogota","美洲/波哥大"} ,
  3270. {"America/Boise","美洲/博伊西"} ,
  3271. {"America/Buenos_Aires","美洲/布宜诺斯艾利斯"} ,
  3272. {"America/Cambridge_Bay","美洲/剑桥湾"} ,
  3273. {"America/Campo_Grande","美洲/大坎普"} ,
  3274. {"America/Cancun","美洲/坎昆"} ,
  3275. {"America/Caracas","美洲/加拉加斯"} ,
  3276. {"America/Catamarca","美洲/卡塔马卡"} ,
  3277. {"America/Cayenne","美洲/卡宴"} ,
  3278. {"America/Cayman","美洲/开曼"} ,
  3279. {"America/Chicago","美洲/芝加哥"} ,
  3280. {"America/Chihuahua","美洲/奇瓦瓦州"} ,
  3281. {"America/Ciudad_Juarez","美洲/华雷斯城"} ,
  3282. {"America/Coral_Harbour","美洲/珊瑚港"} ,
  3283. {"America/Cordoba","美洲/科尔多瓦"} ,
  3284. {"America/Costa_Rica","美洲/哥斯达黎加"} ,
  3285. {"America/Creston","美洲/克雷斯顿"} ,
  3286. {"America/Cuiaba","美洲/库艾巴"} ,
  3287. {"America/Curacao","美洲/库拉索岛"} ,
  3288. {"America/Danmarkshavn","美洲/丹麦港"} ,
  3289. {"America/Dawson","美洲/道森"} ,
  3290. {"America/Dawson_Creek","美洲/道森克里克"} ,
  3291. {"America/Denver","美洲/丹佛"} ,
  3292. {"America/Detroit","美洲/底特律"} ,
  3293. {"America/Dominica","美洲/多米尼克"} ,
  3294. {"America/Edmonton","美洲/埃德蒙顿"} ,
  3295. {"America/Eirunepe","美洲/埃鲁内佩"} ,
  3296. {"America/El_Salvador","美洲/萨尔瓦多"} ,
  3297. {"America/Ensenada","美洲/恩塞纳达"} ,
  3298. {"America/Fort_Nelson","美洲/纳尔逊堡"} ,
  3299. {"America/Fort_Wayne","美洲/韦恩堡"} ,
  3300. {"America/Fortaleza","美洲/福塔莱萨"} ,
  3301. {"America/Glace_Bay","America/Glace_Bay"} ,
  3302. {"America/Godthab","美洲/戈德哈布"} ,
  3303. {"America/Goose_Bay","America/Goose_Bay"} ,
  3304. {"America/Grand_Turk","美洲/大特克岛"} ,
  3305. {"America/Grenada","美洲/格林纳达"} ,
  3306. {"America/Guadeloupe","美洲/瓜德罗普岛"} ,
  3307. {"America/Guatemala","美洲/危地马拉"} ,
  3308. {"America/Guayaquil","美洲/瓜亚基尔"} ,
  3309. {"America/Guyana","美洲/圭亚那"} ,
  3310. {"America/Halifax","美洲/哈利法克斯"} ,
  3311. {"America/Havana","美洲/哈瓦那"} ,
  3312. {"America/Hermosillo","美洲/埃莫西约"} ,
  3313. {"America/Indiana/Indianapolis","美洲/印第安纳州/印第安纳波利斯"} ,
  3314. {"America/Indiana/Knox","美洲/印第安纳州/诺克斯"} ,
  3315. {"America/Indiana/Marengo","美洲/印第安纳州/马伦戈"} ,
  3316. {"America/Indiana/Petersburg","美洲/印第安纳州/彼得斯堡"} ,
  3317. {"America/Indiana/Tell_City","美洲/印第安纳州/Tell_City"} ,
  3318. {"America/Indiana/Vevay","美洲/印第安纳州/沃韦"} ,
  3319. {"America/Indiana/Vincennes","美洲/印第安纳州/文森斯"} ,
  3320. {"America/Indiana/Winamac","美洲/印第安纳州/威纳马克"} ,
  3321. {"America/Indianapolis","美洲/印第安纳波利斯"} ,
  3322. {"America/Inuvik","美洲/伊努维克人"} ,
  3323. {"America/Iqaluit","美洲/伊魁特"} ,
  3324. {"America/Jamaica","美洲/牙买加"} ,
  3325. {"America/Jujuy","美洲/胡胡伊省"} ,
  3326. {"America/Juneau","美洲/朱诺"} ,
  3327. {"America/Kentucky/Louisville","美洲/肯塔基州/路易斯维尔"} ,
  3328. {"America/Kentucky/Monticello","美洲/肯塔基州/蒙蒂塞洛"} ,
  3329. {"America/Knox_IN","美洲/Knox_IN"} ,
  3330. {"America/Kralendijk","美洲/克拉伦代克"} ,
  3331. {"America/La_Paz","美洲/拉巴斯"} ,
  3332. {"America/Lima","美洲/利马"} ,
  3333. {"America/Los_Angeles","美洲/洛杉矶"} ,
  3334. {"America/Louisville","美洲/路易斯维尔"} ,
  3335. {"America/Lower_Princes","美洲/下王子郡"} ,
  3336. {"America/Maceio","美洲/马塞约"} ,
  3337. {"America/Managua","美洲/马那瓜"} ,
  3338. {"America/Manaus","美洲/马瑙斯"} ,
  3339. {"America/Marigot","美洲/马里戈特"} ,
  3340. {"America/Martinique","美洲/马提尼克岛"} ,
  3341. {"America/Matamoros","美洲/马塔莫罗斯"} ,
  3342. {"America/Mazatlan","美洲/马萨特兰"} ,
  3343. {"America/Mendoza","美洲/门多萨"} ,
  3344. {"America/Menominee","美国/梅诺米尼"} ,
  3345. {"America/Merida","美洲/梅里达"} ,
  3346. {"America/Metlakatla","美洲/梅特拉卡特拉"} ,
  3347. {"America/Mexico_City","美洲/墨西哥_城市"} ,
  3348. {"America/Miquelon","美洲/密克隆群岛"} ,
  3349. {"America/Moncton","美洲/蒙克顿"} ,
  3350. {"America/Monterrey","美洲/蒙特雷"} ,
  3351. {"America/Montevideo","美洲/蒙得维的亚"} ,
  3352. {"America/Montreal","美洲/蒙特利尔"} ,
  3353. {"America/Montserrat","美洲/蒙特塞拉特"} ,
  3354. {"America/Nassau","美洲/拿骚"} ,
  3355. {"America/New_York","美洲/纽约"} ,
  3356. {"America/Nipigon","美洲/尼皮贡"} ,
  3357. {"America/Nome","美国/名称"} ,
  3358. {"America/Noronha","美国/某地"} ,
  3359. {"America/North_Dakota/Beulah","美洲/北达科他州/比尤拉"} ,
  3360. {"America/North_Dakota/Center","美洲/北达科他州/中部"} ,
  3361. {"America/North_Dakota/New_Salem","美洲/北达科他州/新塞勒姆"} ,
  3362. {"America/Nuuk","美洲/努克"} ,
  3363. {"America/Ojinaga","美洲/奥吉纳加"} ,
  3364. {"America/Panama","美洲/巴拿马"} ,
  3365. {"America/Pangnirtung","美洲/庞纳通"} ,
  3366. {"America/Paramaribo","美洲/帕拉马里博"} ,
  3367. {"America/Phoenix","美洲/菲尼克斯"} ,
  3368. {"America/Port-au-Prince","美洲/太子港"} ,
  3369. {"America/Port_of_Spain","美洲/西班牙港"} ,
  3370. {"America/Porto_Acre","美洲/阿卡港"} ,
  3371. {"America/Porto_Velho","美洲/旧波尔图"} ,
  3372. {"America/Puerto_Rico","美洲/波多黎各"} ,
  3373. {"America/Punta_Arenas","美洲/蓬塔阿雷纳斯"} ,
  3374. {"America/Rainy_River","美洲/雷尼河"} ,
  3375. {"America/Rankin_Inlet","兰金因莱特"} ,
  3376. {"America/Recife","美洲/累西腓"} ,
  3377. {"America/Regina","美洲/里贾纳"} ,
  3378. {"America/Resolute","美国/坚决"} ,
  3379. {"America/Rio_Branco","美洲/里奥布兰科"} ,
  3380. {"America/Rosario","美洲/罗萨里奥"} ,
  3381. {"America/Santa_Isabel","美洲/圣伊莎贝尔"} ,
  3382. {"America/Santarem","美洲/圣塔伦"} ,
  3383. {"America/Santiago","美洲/圣地亚哥"} ,
  3384. {"America/Santo_Domingo","美洲/圣多明各"} ,
  3385. {"America/Sao_Paulo","美洲/圣保罗"} ,
  3386. {"America/Scoresbysund","美洲/斯科斯比松"} ,
  3387. {"America/Shiprock","美洲/希普洛克"} ,
  3388. {"America/Sitka","美洲/锡特卡"} ,
  3389. {"America/St_Barthelemy","美洲/圣巴泰勒米"} ,
  3390. {"America/St_Johns","美洲/圣约翰斯"} ,
  3391. {"America/St_Kitts","美洲/圣基茨"} ,
  3392. {"America/St_Lucia","美洲/圣卢西亚"} ,
  3393. {"America/St_Thomas","美洲/圣托马斯"} ,
  3394. {"America/St_Vincent","美洲/圣文森特"} ,
  3395. {"America/Swift_Current","America/Swift_Current"} ,
  3396. {"America/Tegucigalpa","美洲/特古西加尔巴"} ,
  3397. {"America/Thule","美洲/图勒"} ,
  3398. {"America/Thunder_Bay","美洲/雷湾"} ,
  3399. {"America/Tijuana","美洲/蒂华纳"} ,
  3400. {"America/Toronto","美洲/多伦多"} ,
  3401. {"America/Tortola","美洲/托尔托拉岛"} ,
  3402. {"America/Vancouver","美洲/温哥华"} ,
  3403. {"America/Virgin","美国/维珍"} ,
  3404. {"America/Whitehorse","美洲/怀特霍斯"} ,
  3405. {"America/Winnipeg","美洲/温尼伯"} ,
  3406. {"America/Yakutat","美洲/雅库塔特"} ,
  3407. {"America/Yellowknife","美洲/黄刀镇"} ,
  3408. {"Antarctica/Casey","南极洲/凯西"} ,
  3409. {"Antarctica/Davis","南极洲/戴维斯"} ,
  3410. {"Antarctica/DumontDUrville","南极洲/杜蒙杜维尔"} ,
  3411. {"Antarctica/Macquarie","南极洲/麦格理"} ,
  3412. {"Antarctica/Mawson","南极洲/莫森"} ,
  3413. {"Antarctica/McMurdo","南极洲/麦克默多"} ,
  3414. {"Antarctica/Palmer","南极洲/帕尔默"} ,
  3415. {"Antarctica/Rothera","南极洲/罗塞拉岛"} ,
  3416. {"Antarctica/South_Pole","南极洲/南极点"} ,
  3417. {"Antarctica/Syowa","南极洲/昭和"} ,
  3418. {"Antarctica/Troll","南极洲/巨魔"} ,
  3419. {"Antarctica/Vostok","南极洲/东方"} ,
  3420. {"Arctic/Longyearbyen","北极/朗伊尔城"} ,
  3421. {"Asia/Aden","亚洲/亚丁"} ,
  3422. {"Asia/Almaty","亚洲/阿拉木图"} ,
  3423. {"Asia/Amman","亚洲/安曼"} ,
  3424. {"Asia/Anadyr","亚洲/阿纳德尔"} ,
  3425. {"Asia/Aqtau","亚洲/阿克套"} ,
  3426. {"Asia/Aqtobe","亚洲/阿克托比"} ,
  3427. {"Asia/Ashgabat","亚洲/阿什哈巴德"} ,
  3428. {"Asia/Ashkhabad","亚洲/阿什哈巴德"} ,
  3429. {"Asia/Atyrau","亚洲/阿特劳"} ,
  3430. {"Asia/Baghdad","亚洲/巴格达"} ,
  3431. {"Asia/Bahrain","亚洲/巴林"} ,
  3432. {"Asia/Baku","亚洲/巴库"} ,
  3433. {"Asia/Bangkok","亚洲/曼谷"} ,
  3434. {"Asia/Barnaul","亚洲/巴尔瑙尔"} ,
  3435. {"Asia/Beirut","亚洲/贝鲁特"} ,
  3436. {"Asia/Bishkek","亚洲/比什凯克"} ,
  3437. {"Asia/Brunei","亚洲/文莱"} ,
  3438. {"Asia/Calcutta","亚洲/加尔各答"} ,
  3439. {"Asia/Chita","亚洲/赤塔"} ,
  3440. {"Asia/Choibalsan","亚洲/乔巴山"} ,
  3441. {"Asia/Chongqing","亚洲/重庆"} ,
  3442. {"Asia/Chungking","亚洲/重庆"} ,
  3443. {"Asia/Colombo","亚洲/科伦坡"} ,
  3444. {"Asia/Dacca","亚洲/达卡"} ,
  3445. {"Asia/Damascus","亚洲/大马士革"} ,
  3446. {"Asia/Dhaka","亚洲/达卡"} ,
  3447. {"Asia/Dili","亚洲/帝力"} ,
  3448. {"Asia/Dubai","亚洲/迪拜"} ,
  3449. {"Asia/Dushanbe","亚洲/杜尚别"} ,
  3450. {"Asia/Famagusta","亚洲/法马古斯塔"} ,
  3451. {"Asia/Gaza","亚洲/加沙"} ,
  3452. {"Asia/Harbin","亚洲/哈尔滨"} ,
  3453. {"Asia/Hebron","亚洲/希伯伦"} ,
  3454. {"Asia/Ho_Chi_Minh","亚洲/胡志明市"} ,
  3455. {"Asia/Hong_Kong","亚洲/香港"} ,
  3456. {"Asia/Hovd","亚洲/霍布德"} ,
  3457. {"Asia/Irkutsk","亚洲/伊尔库茨克"} ,
  3458. {"Asia/Istanbul","亚洲/伊斯坦布尔"} ,
  3459. {"Asia/Jakarta","亚洲/雅加达"} ,
  3460. {"Asia/Jayapura","亚洲/查亚普拉"} ,
  3461. {"Asia/Jerusalem","亚洲/耶路撒冷"} ,
  3462. {"Asia/Kabul","亚洲/喀布尔"} ,
  3463. {"Asia/Kamchatka","亚洲/堪察加半岛"} ,
  3464. {"Asia/Karachi","亚洲/卡拉奇"} ,
  3465. {"Asia/Kashgar","亚洲/喀什"} ,
  3466. {"Asia/Kathmandu","亚洲/加德满都"} ,
  3467. {"Asia/Katmandu","亚洲/加德满都"} ,
  3468. {"Asia/Khandyga","亚洲/坎迪加"} ,
  3469. {"Asia/Kolkata","亚洲/加尔各答"} ,
  3470. {"Asia/Krasnoyarsk","亚洲/克拉斯诺亚尔斯克"} ,
  3471. {"Asia/Kuala_Lumpur","亚洲/吉隆坡_吉隆坡"} ,
  3472. {"Asia/Kuching","亚洲/古晋"} ,
  3473. {"Asia/Kuwait","亚洲/科威特"} ,
  3474. {"Asia/Macao","亚洲/澳门"} ,
  3475. {"Asia/Macau","亚洲/澳门"} ,
  3476. {"Asia/Magadan","亚洲/马加丹"} ,
  3477. {"Asia/Makassar","亚洲/望加锡"} ,
  3478. {"Asia/Manila","亚洲/马尼拉"} ,
  3479. {"Asia/Muscat","亚洲/马斯喀特"} ,
  3480. {"Asia/Nicosia","亚洲/尼科西亚"} ,
  3481. {"Asia/Novokuznetsk","亚洲/新库兹涅茨克"} ,
  3482. {"Asia/Novosibirsk","亚洲/新西伯利亚"} ,
  3483. {"Asia/Omsk","亚洲/鄂木斯克"} ,
  3484. {"Asia/Oral","亚洲/口头"} ,
  3485. {"Asia/Phnom_Penh","亚洲/金边"} ,
  3486. {"Asia/Pontianak","亚洲/笨珍"} ,
  3487. {"Asia/Pyongyang","亚洲/平壤"} ,
  3488. {"Asia/Qatar","亚洲/卡塔尔"} ,
  3489. {"Asia/Qostanay","亚洲/库斯塔奈"} ,
  3490. {"Asia/Qyzylorda","亚洲/克孜勒奥尔达"} ,
  3491. {"Asia/Rangoon","亚洲/仰光"} ,
  3492. {"Asia/Riyadh","亚洲/利雅得"} ,
  3493. {"Asia/Saigon","亚洲/西贡"} ,
  3494. {"Asia/Sakhalin","亚洲/萨哈林岛"} ,
  3495. {"Asia/Samarkand","亚洲/撒马尔罕"} ,
  3496. {"Asia/Seoul","亚洲/首尔"} ,
  3497. {"Asia/Shanghai","亚洲/上海"} ,
  3498. {"Asia/Singapore","亚洲/新加坡"} ,
  3499. {"Asia/Srednekolymsk","亚洲/中科雷姆斯克"} ,
  3500. {"Asia/Taipei","亚洲/台北"} ,
  3501. {"Asia/Tashkent","亚洲/塔什干"} ,
  3502. {"Asia/Tbilisi","亚洲/第比利斯"} ,
  3503. {"Asia/Tehran","亚洲/德黑兰"} ,
  3504. {"Asia/Tel_Aviv","亚洲/特拉维夫"} ,
  3505. {"Asia/Thimbu","亚洲/廷布"} ,
  3506. {"Asia/Thimphu","亚洲/廷布"} ,
  3507. {"Asia/Tokyo","亚洲/东京"} ,
  3508. {"Asia/Tomsk","亚洲/托木斯克"} ,
  3509. {"Asia/Ujung_Pandang","亚洲/乌戎_潘当"} ,
  3510. {"Asia/Ulaanbaatar","亚洲/乌兰巴托"} ,
  3511. {"Asia/Ulan_Bator","亚洲/乌兰巴托"} ,
  3512. {"Asia/Urumqi","亚洲/乌鲁木齐"} ,
  3513. {"Asia/Ust-Nera","亚洲/乌斯季-内拉"} ,
  3514. {"Asia/Vientiane","亚洲/万象"} ,
  3515. {"Asia/Vladivostok","亚洲/符拉迪沃斯托克"} ,
  3516. {"Asia/Yakutsk","亚洲/雅库茨克"} ,
  3517. {"Asia/Yangon","亚洲/仰光"} ,
  3518. {"Asia/Yekaterinburg","亚洲/叶卡捷琳堡"} ,
  3519. {"Asia/Yerevan","亚洲/埃里温"} ,
  3520. {"Atlantic/Azores","大西洋/亚速尔群岛"} ,
  3521. {"Atlantic/Bermuda","大西洋/百慕大"} ,
  3522. {"Atlantic/Canary","大西洋/加那利"} ,
  3523. {"Atlantic/Cape_Verde","大西洋/佛得角"} ,
  3524. {"Atlantic/Faeroe","大西洋/法罗"} ,
  3525. {"Atlantic/Faroe","大西洋/法罗"} ,
  3526. {"Atlantic/Jan_Mayen","大西洋/扬马延"} ,
  3527. {"Atlantic/Madeira","大西洋/马德拉"} ,
  3528. {"Atlantic/Reykjavik","大西洋/雷克雅未克"} ,
  3529. {"Atlantic/South_Georgia","大西洋/南乔治亚州"} ,
  3530. {"Atlantic/St_Helena","大西洋/圣赫勒拿岛"} ,
  3531. {"Atlantic/Stanley","大西洋/斯坦利"} ,
  3532. {"Australia/ACT","澳大利亚/澳大利亚首都地区"} ,
  3533. {"Australia/Adelaide","澳大利亚/阿德莱德"} ,
  3534. {"Australia/Brisbane","澳大利亚/布里斯班"} ,
  3535. {"Australia/Broken_Hill","澳大利亚/布罗肯希尔"} ,
  3536. {"Australia/Canberra","澳大利亚/堪培拉"} ,
  3537. {"Australia/Currie","澳大利亚/柯里"} ,
  3538. {"Australia/Darwin","澳大利亚/达尔文"} ,
  3539. {"Australia/Eucla","澳大利亚/尤克拉拉"} ,
  3540. {"Australia/Hobart","澳大利亚/霍巴特"} ,
  3541. {"Australia/LHI","澳大利亚/LHI"} ,
  3542. {"Australia/Lindeman","澳大利亚/林德曼"} ,
  3543. {"Australia/Lord_Howe","澳大利亚/豪勋爵"} ,
  3544. {"Australia/Melbourne","澳大利亚/墨尔本"} ,
  3545. {"Australia/NSW","澳大利亚/新南威尔士州"} ,
  3546. {"Australia/North","澳大利亚/北部"} ,
  3547. {"Australia/Perth","澳大利亚/珀斯"} ,
  3548. {"Australia/Queensland","澳大利亚/昆士兰"} ,
  3549. {"Australia/South","澳大利亚/南部"} ,
  3550. {"Australia/Sydney","澳大利亚/悉尼"} ,
  3551. {"Australia/Tasmania","澳大利亚/塔斯马尼亚"} ,
  3552. {"Australia/Victoria","澳大利亚/维多利亚"} ,
  3553. {"Australia/West","澳大利亚/西部"} ,
  3554. {"Australia/Yancowinna","澳大利亚/扬科温纳"} ,
  3555. {"Brazil/Acre","巴西/阿卡"} ,
  3556. {"Brazil/DeNoronha","巴西/迪诺罗尼亚群岛"} ,
  3557. {"Brazil/East","巴西/东部"} ,
  3558. {"Brazil/West","巴西/西部"} ,
  3559. {"CET","CET"} ,
  3560. {"CST6CDT","CST6CDT"} ,
  3561. {"Canada/Atlantic","加拿大/大西洋"} ,
  3562. {"Canada/Central","加拿大/中部"} ,
  3563. {"Canada/Eastern","加拿大/东部"} ,
  3564. {"Canada/Mountain","加拿大/山区"} ,
  3565. {"Canada/Newfoundland","加拿大/纽芬兰"} ,
  3566. {"Canada/Pacific","加拿大/太平洋地区"} ,
  3567. {"Canada/Saskatchewan","加拿大/萨斯喀彻温省"} ,
  3568. {"Canada/Yukon","加拿大/育空地区"} ,
  3569. {"Chile/Continental","智利/大陆航空"} ,
  3570. {"Chile/EasterIsland","智利/复活节岛"} ,
  3571. {"Cuba","古巴"} ,
  3572. {"EET","欧洲东部时间"} ,
  3573. {"EST","东部时间"} ,
  3574. {"EST5EDT","EST5EDT"} ,
  3575. {"Egypt","埃及"} ,
  3576. {"Eire","爱尔兰"} ,
  3577. {"Etc/GMT","Etc/GMT"} ,
  3578. {"Etc/GMT+0","Etc/GMT+0"} ,
  3579. {"Etc/GMT+1","Etc/GMT+1"} ,
  3580. {"Etc/GMT+10","Etc/GMT+10"} ,
  3581. {"Etc/GMT+11","Etc/GMT+11"} ,
  3582. {"Etc/GMT+12","Etc/GMT+12"} ,
  3583. {"Etc/GMT+2","Etc/GMT+2"} ,
  3584. {"Etc/GMT+3","Etc/GMT+3"} ,
  3585. {"Etc/GMT+4","Etc/GMT+4"} ,
  3586. {"Etc/GMT+5","Etc/GMT+5"} ,
  3587. {"Etc/GMT+6","Etc/GMT+6"} ,
  3588. {"Etc/GMT+7","Etc/GMT+7"} ,
  3589. {"Etc/GMT+8","Etc/GMT+8"} ,
  3590. {"Etc/GMT+9","Etc/GMT+9"} ,
  3591. {"Etc/GMT-0","Etc/GMT-0"} ,
  3592. {"Etc/GMT-1","Etc/GMT-1"} ,
  3593. {"Etc/GMT-10","Etc/GMT-10"} ,
  3594. {"Etc/GMT-11","Etc/GMT-11"} ,
  3595. {"Etc/GMT-12","Etc/GMT-12"} ,
  3596. {"Etc/GMT-13","Etc/GMT-13"} ,
  3597. {"Etc/GMT-14","Etc/GMT-14"} ,
  3598. {"Etc/GMT-2","Etc/GMT-2"} ,
  3599. {"Etc/GMT-3","Etc/GMT-3"} ,
  3600. {"Etc/GMT-4","Etc/GMT-4"} ,
  3601. {"Etc/GMT-5","Etc/GMT-5"} ,
  3602. {"Etc/GMT-6","Etc/GMT-6"} ,
  3603. {"Etc/GMT-7","Etc/GMT-7"} ,
  3604. {"Etc/GMT-8","Etc/GMT-8"} ,
  3605. {"Etc/GMT-9","Etc/GMT-9"} ,
  3606. {"Etc/GMT0","Etc/GMT0"} ,
  3607. {"Etc/Greenwich","Etc/格林威治"} ,
  3608. {"Etc/UCT","Etc/UCT"} ,
  3609. {"Etc/UTC","Etc/UTC"} ,
  3610. {"Etc/Universal","Etc/通用"} ,
  3611. {"Etc/Zulu","Etc/祖鲁语"} ,
  3612. {"Europe/Amsterdam","欧洲/阿姆斯特丹"} ,
  3613. {"Europe/Andorra","欧洲/安道尔"} ,
  3614. {"Europe/Astrakhan","欧洲/阿斯特拉罕"} ,
  3615. {"Europe/Athens","欧洲/雅典"} ,
  3616. {"Europe/Belfast","欧洲/贝尔法斯特"} ,
  3617. {"Europe/Belgrade","欧洲/贝尔格莱德"} ,
  3618. {"Europe/Berlin","欧洲/柏林"} ,
  3619. {"Europe/Bratislava","欧洲/布拉迪斯拉发"} ,
  3620. {"Europe/Brussels","欧洲/布鲁塞尔"} ,
  3621. {"Europe/Bucharest","欧洲/布加勒斯特"} ,
  3622. {"Europe/Budapest","欧洲/布达佩斯"} ,
  3623. {"Europe/Busingen","欧洲/布辛根"} ,
  3624. {"Europe/Chisinau","欧洲/基希讷乌"} ,
  3625. {"Europe/Copenhagen","欧洲/哥本哈根"} ,
  3626. {"Europe/Dublin","欧洲/都柏林"} ,
  3627. {"Europe/Gibraltar","欧洲/直布罗陀"} ,
  3628. {"Europe/Guernsey","欧洲/根西岛"} ,
  3629. {"Europe/Helsinki","欧洲/赫尔辛基"} ,
  3630. {"Europe/Isle_of_Man","欧洲/马恩岛"} ,
  3631. {"Europe/Istanbul","欧洲/伊斯坦布尔"} ,
  3632. {"Europe/Jersey","欧洲/泽西岛"} ,
  3633. {"Europe/Kaliningrad","欧洲/加里宁格勒"} ,
  3634. {"Europe/Kiev","欧洲/基辅"} ,
  3635. {"Europe/Kirov","欧洲/基洛夫"} ,
  3636. {"Europe/Kyiv","欧洲/基辅"} ,
  3637. {"Europe/Lisbon","欧洲/里斯本"} ,
  3638. {"Europe/Ljubljana","欧洲/卢布尔雅那"} ,
  3639. {"Europe/London","欧洲/伦敦"} ,
  3640. {"Europe/Luxembourg","欧洲/卢森堡"} ,
  3641. {"Europe/Madrid","欧洲/马德里"} ,
  3642. {"Europe/Malta","欧洲/马耳他"} ,
  3643. {"Europe/Mariehamn","欧洲/玛丽港"} ,
  3644. {"Europe/Minsk","欧洲/明斯克"} ,
  3645. {"Europe/Monaco","欧洲/摩纳哥"} ,
  3646. {"Europe/Moscow","欧洲/莫斯科"} ,
  3647. {"Europe/Nicosia","欧洲/尼科西亚"} ,
  3648. {"Europe/Oslo","欧洲/奥斯陆"} ,
  3649. {"Europe/Paris","欧洲/巴黎"} ,
  3650. {"Europe/Podgorica","欧洲/波德戈里察"} ,
  3651. {"Europe/Prague","欧洲/布拉格"} ,
  3652. {"Europe/Riga","欧洲/里加"} ,
  3653. {"Europe/Rome","欧洲/罗马"} ,
  3654. {"Europe/Samara","欧洲/萨马拉"} ,
  3655. {"Europe/San_Marino","欧洲/圣马力诺"} ,
  3656. {"Europe/Sarajevo","欧洲/萨拉热窝"} ,
  3657. {"Europe/Saratov","欧洲/萨拉托夫"} ,
  3658. {"Europe/Simferopol","欧洲/辛菲罗波尔"} ,
  3659. {"Europe/Skopje","欧洲/斯科普里"} ,
  3660. {"Europe/Sofia","欧洲/索非亚"} ,
  3661. {"Europe/Stockholm","欧洲/斯德哥尔摩"} ,
  3662. {"Europe/Tallinn","欧洲/塔林"} ,
  3663. {"Europe/Tirane","欧洲/地拉那"} ,
  3664. {"Europe/Tiraspol","欧洲/蒂拉斯波尔"} ,
  3665. {"Europe/Ulyanovsk","欧洲/乌里扬诺夫斯克"} ,
  3666. {"Europe/Uzhgorod","欧洲/乌日哥罗德"} ,
  3667. {"Europe/Vaduz","欧洲/瓦杜兹"} ,
  3668. {"Europe/Vatican","欧洲/梵蒂冈"} ,
  3669. {"Europe/Vienna","欧洲/维也纳"} ,
  3670. {"Europe/Vilnius","欧洲/维尔纽斯"} ,
  3671. {"Europe/Volgograd","欧洲/伏尔加格勒"} ,
  3672. {"Europe/Warsaw","欧洲/华沙"} ,
  3673. {"Europe/Zagreb","欧洲/萨格勒布"} ,
  3674. {"Europe/Zaporozhye","欧洲/扎波罗热"} ,
  3675. {"Europe/Zurich","欧洲/苏黎世"} ,
  3676. {"GB","国标"} ,
  3677. {"GB-Eire","英国-爱尔兰"} ,
  3678. {"GMT","格林威治标准时间"} ,
  3679. {"GMT+0","格林威治标准时间+0"} ,
  3680. {"GMT-0","GMT-0"} ,
  3681. {"GMT0","格林威治标准时间0"} ,
  3682. {"Greenwich","格林威治"} ,
  3683. {"HST","高温试验"} ,
  3684. {"Hongkong","香港"} ,
  3685. {"Iceland","冰岛"} ,
  3686. {"Indian/Antananarivo","印度/塔那那利佛"} ,
  3687. {"Indian/Chagos","印第安人/查戈斯人"} ,
  3688. {"Indian/Christmas","印度/圣诞节"} ,
  3689. {"Indian/Cocos","印度/科科斯"} ,
  3690. {"Indian/Comoro","印度/科摩罗"} ,
  3691. {"Indian/Kerguelen","印度/凯尔盖朗"} ,
  3692. {"Indian/Mahe","印度/马埃岛"} ,
  3693. {"Indian/Maldives","印度/马尔代夫"} ,
  3694. {"Indian/Mauritius","印度/毛里求斯"} ,
  3695. {"Indian/Mayotte","印度/马约特岛"} ,
  3696. {"Indian/Reunion","印度/留尼汪岛"} ,
  3697. {"Iran","伊朗"} ,
  3698. {"Israel","以色列"} ,
  3699. {"Jamaica","牙买加"} ,
  3700. {"Japan","日本"} ,
  3701. {"Kwajalein","夸贾林环礁"} ,
  3702. {"Libya","利比亚"} ,
  3703. {"MET","梅特"} ,
  3704. {"MST","MST"} ,
  3705. {"MST7MDT","MST7MDT"} ,
  3706. {"Mexico/BajaNorte","墨西哥/北下巴"} ,
  3707. {"Mexico/BajaSur","墨西哥/巴哈苏尔"} ,
  3708. {"Mexico/General","墨西哥/一般"} ,
  3709. {"NZ","新西兰"} ,
  3710. {"NZ-CHAT","新西兰聊天室"} ,
  3711. {"Navajo","纳瓦霍语"} ,
  3712. {"PRC","中国"} ,
  3713. {"PST8PDT","PST8PDT"} ,
  3714. {"Pacific/Apia","太平洋/阿皮亚"} ,
  3715. {"Pacific/Auckland","太平洋/奥克兰"} ,
  3716. {"Pacific/Bougainville","太平洋/布干维尔岛"} ,
  3717. {"Pacific/Chatham","太平洋/查塔姆"} ,
  3718. {"Pacific/Chuuk","太平洋/楚克"} ,
  3719. {"Pacific/Easter","太平洋/复活节"} ,
  3720. {"Pacific/Efate","太平洋/埃法特"} ,
  3721. {"Pacific/Enderbury","太平洋/恩德伯里"} ,
  3722. {"Pacific/Fakaofo","太平洋/法考福"} ,
  3723. {"Pacific/Fiji","太平洋/斐济"} ,
  3724. {"Pacific/Funafuti","太平洋/富纳富提"} ,
  3725. {"Pacific/Galapagos","太平洋/加拉帕戈斯群岛"} ,
  3726. {"Pacific/Gambier","太平洋/甘比尔"} ,
  3727. {"Pacific/Guadalcanal","太平洋/瓜达尔卡纳尔岛"} ,
  3728. {"Pacific/Guam","太平洋/关岛"} ,
  3729. {"Pacific/Honolulu","太平洋/檀香山"} ,
  3730. {"Pacific/Johnston","太平洋/约翰斯顿"} ,
  3731. {"Pacific/Kanton","太平洋/关东"} ,
  3732. {"Pacific/Kiritimati","太平洋/基里蒂马蒂"} ,
  3733. {"Pacific/Kosrae","太平洋/科斯雷"} ,
  3734. {"Pacific/Kwajalein","太平洋/夸贾林环礁"} ,
  3735. {"Pacific/Majuro","太平洋/马朱罗"} ,
  3736. {"Pacific/Marquesas","太平洋/马克萨斯"} ,
  3737. {"Pacific/Midway","太平洋/中途岛"} ,
  3738. {"Pacific/Nauru","太平洋/瑙鲁"} ,
  3739. {"Pacific/Niue","太平洋/纽埃"} ,
  3740. {"Pacific/Norfolk","太平洋/诺福克"} ,
  3741. {"Pacific/Noumea","太平洋/努美阿"} ,
  3742. {"Pacific/Pago_Pago","太平洋/帕果"} ,
  3743. {"Pacific/Palau","太平洋/帕劳"} ,
  3744. {"Pacific/Pitcairn","太平洋/皮特凯恩"} ,
  3745. {"Pacific/Pohnpei","太平洋/波纳佩"} ,
  3746. {"Pacific/Ponape","太平洋/波纳佩"} ,
  3747. {"Pacific/Port_Moresby","太平洋/莫尔兹比港"} ,
  3748. {"Pacific/Rarotonga","太平洋/拉罗汤加"} ,
  3749. {"Pacific/Saipan","太平洋/塞班岛"} ,
  3750. {"Pacific/Samoa","太平洋/萨摩亚"} ,
  3751. {"Pacific/Tahiti","太平洋/大溪地"} ,
  3752. {"Pacific/Tarawa","太平洋/塔拉瓦"} ,
  3753. {"Pacific/Tongatapu","太平洋/汤加塔布岛"} ,
  3754. {"Pacific/Truk","太平洋/特鲁克"} ,
  3755. {"Pacific/Wake","太平洋/威克"} ,
  3756. {"Pacific/Wallis","太平洋/沃利斯"} ,
  3757. {"Pacific/Yap","太平洋/雅浦岛"} ,
  3758. {"Poland","波兰"} ,
  3759. {"Portugal","葡萄牙"} ,
  3760. {"ROC","ROC"} ,
  3761. {"ROK","韩国"} ,
  3762. {"Singapore","新加坡"} ,
  3763. {"Turkey","Turkey"} ,
  3764. {"UCT","世界标准时间"} ,
  3765. {"US/Alaska","美国/阿拉斯加"} ,
  3766. {"US/Aleutian","美国/阿留申群岛"} ,
  3767. {"US/Arizona","美国/亚利桑那州"} ,
  3768. {"US/Central","美国/中部"} ,
  3769. {"US/East-Indiana","美国/东印第安纳州"} ,
  3770. {"US/Eastern","美国/东部"} ,
  3771. {"US/Hawaii","美国/夏威夷"} ,
  3772. {"US/Indiana-Starke","美国/印第安纳州斯塔克"} ,
  3773. {"US/Michigan","美国/密歇根州"} ,
  3774. {"US/Mountain","美国/山地"} ,
  3775. {"US/Pacific","美国/太平洋地区"} ,
  3776. {"US/Samoa","美国/萨摩亚"} ,
  3777. {"UTC","世界标准时间"} ,
  3778. {"Universal","Universal"} ,
  3779. {"W-SU","W-SU"} ,
  3780. {"WET","WET"} ,
  3781. {"Zulu","Zulu"}
  3782. };
  3783. /// <summary>
  3784. /// 获取国家或城市当地时间
  3785. /// </summary>
  3786. /// <param name="country"></param>
  3787. /// <param name="city"></param>
  3788. /// <returns></returns>
  3789. public static DateTime? GetCountryOrCityCurrentDateTime(string country, string city)
  3790. {
  3791. DateTime? currDt = null;
  3792. var currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(city)).ToList();
  3793. if (!currTimezones.Any())
  3794. {
  3795. currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(country)).ToList();
  3796. }
  3797. ;
  3798. string timeZoneId = string.Empty;
  3799. if (currTimezones.Count > 1)
  3800. {
  3801. currTimezones = currTimezones.Where(x => x.Value.Contains(country)).ToList();
  3802. timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3803. }
  3804. else timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3805. if (string.IsNullOrEmpty(timeZoneId)) return currDt;
  3806. // Step 1: 获取当前 UTC 时间
  3807. Instant now = SystemClock.Instance.GetCurrentInstant();
  3808. // Step 2: 加载目标时区(以 "Asia/Shanghai" 为例)
  3809. var timeZone = DateTimeZoneProviders.Tzdb[timeZoneId];
  3810. if (timeZone == null) return currDt;
  3811. // Step 3: 将 UTC 时间转换为目标时区的本地时间
  3812. currDt = now.InZone(timeZone).ToDateTimeUnspecified();
  3813. return currDt;
  3814. }
  3815. #endregion
  3816. #region aspose
  3817. /// <summary>
  3818. /// aspose word 设置页脚
  3819. /// </summary>
  3820. /// <param name="builder"></param>
  3821. /// <param name="footerLabel">页脚内容</param>
  3822. /// <param name="font">字体名称</param>
  3823. /// <param name="fontSize"><字体大小/param>
  3824. public static void AsposeWordSetFooter(DocumentBuilder builder, string footerLabel, string font, int fontSize)
  3825. {
  3826. Section currentSection = builder.CurrentSection;
  3827. var pageSetup = currentSection.PageSetup;
  3828. pageSetup.DifferentFirstPageHeaderFooter = true;
  3829. //第一页页脚
  3830. builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
  3831. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3832. builder.Font.Name = font;
  3833. builder.Font.Bold = true;
  3834. builder.Font.Size = fontSize;
  3835. builder.Write(footerLabel);
  3836. //非第一页页脚
  3837. builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
  3838. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3839. builder.Font.Name = font;
  3840. builder.Font.Bold = true;
  3841. builder.Font.Size = fontSize;
  3842. builder.Write(footerLabel);
  3843. }
  3844. #endregion
  3845. #region 出入境费用
  3846. #region 汇率
  3847. /// <summary>
  3848. /// 出入境费用 初始化汇率
  3849. /// </summary>
  3850. /// <returns></returns>
  3851. public static async Task<List<CurrencyInfo>> EnterExitCostInitRate()
  3852. {
  3853. //默认币种显示
  3854. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  3855. {
  3856. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3857. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3858. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3859. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3860. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3861. };
  3862. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  3863. if (currencyRate.Count > 0)
  3864. {
  3865. foreach (var item in currencyInfos)
  3866. {
  3867. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3868. if (rateInfo != null)
  3869. {
  3870. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3871. //if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M; //rate1 = rate1 * 1;
  3872. //else rate1 *= 1.035M;
  3873. rate1 *= 1.035M;
  3874. item.Rate = rate1.TruncDecimals(4) + 0.01M;
  3875. }
  3876. }
  3877. }
  3878. return currencyInfos;
  3879. }
  3880. /// <summary>
  3881. /// 出入境费用 实时汇率
  3882. /// </summary>
  3883. /// <returns></returns>
  3884. public static async Task<List<dynamic>> EnterExitCostLiveRate()
  3885. {
  3886. List<dynamic> reteInfos = new List<dynamic>();
  3887. //默认币种显示
  3888. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  3889. {
  3890. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3891. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3892. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3893. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3894. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3895. };
  3896. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  3897. if (currencyRate.Count > 0)
  3898. {
  3899. foreach (var item in currencyInfos)
  3900. {
  3901. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3902. if (rateInfo != null)
  3903. {
  3904. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3905. decimal rate1 = item.Rate * 1.0350M;
  3906. //rate1 += 0.01M;
  3907. reteInfos.Add(new
  3908. {
  3909. currCode = item.CurrencyCode,
  3910. currName = item.CurrencyName,
  3911. rate = rate1.TruncDecimals(4),
  3912. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3913. });
  3914. }
  3915. }
  3916. }
  3917. return reteInfos;
  3918. }
  3919. /// <summary>
  3920. /// 出入境费用 汇率验证
  3921. /// </summary>
  3922. /// <param name="groupId"></param>
  3923. /// <param name="checkCurrencys">已使用币种</param>
  3924. /// <returns></returns>
  3925. public static async Task<(bool, string, List<CurrencyInfo>)> EnterExitCostCheckRate(int groupId, List<CurrencyInfo> checkCurrencys)
  3926. {
  3927. if (checkCurrencys == null || checkCurrencys.Count < 1) return (false, string.Empty, new List<CurrencyInfo>());
  3928. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == groupId);
  3929. if (info == null) return (false, string.Empty, new List<CurrencyInfo>());
  3930. List<CurrencyInfo> liveRates;
  3931. var cacheRateInfo = await _sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  3932. .OrderByDescending(x => x.CreateTime)
  3933. .FirstAsync(x => x.IsDel == 0 && x.DiId == info.Id);
  3934. if (cacheRateInfo == null)
  3935. {
  3936. var _currencyRate = await _juHeApi.PostItemRateAsync(Array.Empty<string>());
  3937. if (_currencyRate.Count < 1) return (false, "获取汇率失败,请稍后再试!", new List<CurrencyInfo>());
  3938. liveRates = _currencyRate.Select(it => new CurrencyInfo
  3939. {
  3940. CurrencyCode = it.Name,
  3941. CurrencyName = it.Name,
  3942. Rate = Convert.ToDecimal((Convert.ToDecimal(it.FSellPri == null ? 0.00M : it.FSellPri) / 100.00M).ToString("#0.0000"))
  3943. }).ToList();
  3944. }
  3945. else
  3946. {
  3947. liveRates = CommonFun.GetCurrencyChinaToList(cacheRateInfo.RateInfo);
  3948. foreach (var x in liveRates)
  3949. x.Rate = (x.Rate / 100.00M).TruncDecimals(4);
  3950. }
  3951. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  3952. var isSendMsg = false;
  3953. var msgContent = new StringBuilder();
  3954. //去掉费用未使用得币种
  3955. if (checkCurrencys != null && checkCurrencys.Count > 0)
  3956. {
  3957. cacheRateInfos = cacheRateInfos.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  3958. }
  3959. if (cacheRateInfos.Any())
  3960. {
  3961. decimal rowthRate = 1.0350M;
  3962. foreach (var cacheRate in cacheRateInfos)
  3963. {
  3964. var liveRate = liveRates.Find(x => x.CurrencyName.Equals(cacheRate.CurrencyName));
  3965. if (liveRate == null) continue;
  3966. var currRate = (rowthRate * liveRate.Rate).TruncDecimals(4);
  3967. if (cacheRate.Rate != currRate)
  3968. {
  3969. isSendMsg = true;
  3970. //>团组归属:<font color='info'>{groupName}</font>
  3971. msgContent.AppendLine($">- {cacheRate.CurrencyName}汇率(页面保存):{cacheRate.Rate:#0.0000} / 实时汇率(接口保存,已上浮1.0350):{currRate:#0.0000}【原接口输出汇率为:{liveRate.Rate:#0.0000}】");
  3972. }
  3973. }
  3974. return (isSendMsg, msgContent.ToString(), liveRates);
  3975. }
  3976. return (false, string.Empty, new List<CurrencyInfo>());
  3977. }
  3978. #endregion
  3979. #region 三公费用明细 文件下载
  3980. /// <summary>
  3981. /// 获取三公费用标准city
  3982. /// </summary>
  3983. /// <param name="placeData"></param>
  3984. /// <param name="nationalTravelFeeId"></param>
  3985. /// <returns></returns>
  3986. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  3987. {
  3988. string _city = string.Empty;
  3989. if (placeData.Count < 1) return _city;
  3990. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  3991. if (data == null) return _city;
  3992. string country = data.Country;
  3993. string city = data.City;
  3994. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  3995. else _city = city;
  3996. return _city;
  3997. }
  3998. /// <summary>
  3999. /// 三公费用明细 文件下载
  4000. /// </summary>
  4001. /// <param name="dto"></param>
  4002. /// <param name="fileFormat"></param>
  4003. /// <returns></returns>
  4004. public static async Task<JsonView> EnterExitCostDownload(EnterExitCostDownloadDto dto, string fileFormat = "pdf")
  4005. {
  4006. var _view = new JsonView() { Code = StatusCodes.Status204NoContent };
  4007. if (dto.DiId < 1)
  4008. {
  4009. _view.Msg = "请传入有效的DiId参数;";
  4010. return _view;
  4011. }
  4012. if (dto.ExportType < 1)
  4013. {
  4014. _view.Msg = MsgTips.Port;
  4015. return _view;
  4016. }
  4017. if (dto.SubTypeId < 1)
  4018. {
  4019. _view.Msg = @"请传入有效的SubTypeId参数;
  4020. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4021. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4022. 3 团组成员名单 1 团组成员名单";
  4023. return _view;
  4024. }
  4025. try
  4026. {
  4027. var enterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4028. var dayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4029. if (enterExitCosts == null)
  4030. {
  4031. _view.Msg = @"该团组未填写出入境费用;";
  4032. return _view;
  4033. }
  4034. //数据源
  4035. List<Grp_DayAndCost> dac1 = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4036. List<Grp_DayAndCost> dac2 = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4037. List<Grp_DayAndCost> dac3 = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4038. List<Grp_DayAndCost> dac4 = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4039. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4040. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4041. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4042. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4043. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4044. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4045. .Select((tcl, dc, cc) => new
  4046. {
  4047. Name = dc.LastName + dc.FirstName,
  4048. Sex = dc.Sex,
  4049. Birthday = dc.BirthDay,
  4050. Company = cc.CompanyFullName,
  4051. Job = dc.Job
  4052. })
  4053. .ToList();
  4054. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4055. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4056. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4057. var rateDatas = await enterExitCosts.CurrencyRemark.SplitExchangeRate();
  4058. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4059. if (dto.ExportType == 1) //明细表
  4060. {
  4061. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4062. {
  4063. if (!fileFormat.Equals("pdf")) fileFormat = "docx";
  4064. //获取模板
  4065. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4066. //载入模板
  4067. Document doc = new Document(tempPath);
  4068. DocumentBuilder builder = new DocumentBuilder(doc);
  4069. //利用键值对存放数据
  4070. Dictionary<string, string> dic = new Dictionary<string, string>();
  4071. decimal stayFeeTotal = dayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4072. decimal mealsFeeTotal = dayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4073. decimal miscellaneousFeeTotal = dayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4074. decimal tainFeeTotal = dayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4075. decimal insidePayTotal = enterExitCosts.InsidePay;
  4076. string row1_1 = "";
  4077. if (enterExitCosts.Visa > 0)
  4078. {
  4079. //insidePayTotal += enterExitCosts.Visa;
  4080. row1_1 = $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4081. //if (!string.IsNullOrEmpty(enterExitCosts.VisaRemark))
  4082. //{
  4083. // row1_1 += $"\t签证费用描述: {enterExitCosts.VisaRemark}";
  4084. //}
  4085. }
  4086. string row1_2 = "";
  4087. if (enterExitCosts.YiMiao > 0)
  4088. {
  4089. //insidePayTotal += enterExitCosts.YiMiao;
  4090. row1_2 += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4091. }
  4092. if (enterExitCosts.HeSuan > 0)
  4093. {
  4094. //insidePayTotal += enterExitCosts.HeSuan;
  4095. row1_2 += $"核酸检测费:{enterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4096. }
  4097. if (enterExitCosts.Service > 0)
  4098. {
  4099. //insidePayTotal += enterExitCosts.Service;
  4100. row1_2 += $"服务费:{enterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4101. }
  4102. string row1_3 = "";
  4103. if (enterExitCosts.Safe > 0)
  4104. {
  4105. //insidePayTotal += enterExitCosts.Safe;
  4106. row1_3 += $"保险费:{enterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4107. }
  4108. if (enterExitCosts.Ticket > 0)
  4109. {
  4110. //insidePayTotal += enterExitCosts.Ticket;
  4111. row1_3 += $"参展门票:{enterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4112. }
  4113. string row1 = "";
  4114. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4115. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4116. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4117. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4118. dic.Add("Row1Str", row1);
  4119. dic.Add("OutsideJJ", enterExitCosts.OutsideJJPay.ToString("#0.00"));
  4120. dic.Add("OutsaideGW", enterExitCosts.OutsideGWPay.ToString("#0.00"));
  4121. dic.Add("AirJJ", enterExitCosts.AirJJ.ToString("#0.00"));
  4122. dic.Add("AirGW", enterExitCosts.AirGW.ToString("#0.00"));
  4123. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4124. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4125. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4126. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  4127. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  4128. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  4129. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideJJPay;
  4130. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideGWPay;
  4131. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4132. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4133. #region 填充word模板书签内容
  4134. foreach (var key in dic.Keys)
  4135. {
  4136. builder.MoveToBookmark(key);
  4137. builder.Write(dic[key]);
  4138. }
  4139. #endregion
  4140. #region 填充word表格内容
  4141. ////获读取指定表格方法二
  4142. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4143. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4144. for (int i = 0; i < dac1.Count; i++)
  4145. {
  4146. Grp_DayAndCost dac = dac1[i];
  4147. if (dac == null) continue;
  4148. builder.MoveToCell(0, i, 0, 0);
  4149. builder.Write("第" + dac.Days.ToString() + "晚:");
  4150. builder.MoveToCell(0, i, 1, 0);
  4151. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4152. //builder.Write(dac.Place == null ? "" : dac.Place);
  4153. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4154. builder.MoveToCell(0, i, 2, 0);
  4155. builder.Write("费用标准:");
  4156. string curr = "";
  4157. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4158. if (currData != null)
  4159. {
  4160. curr = currData.Name;
  4161. }
  4162. builder.MoveToCell(0, i, 3, 0);
  4163. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4164. builder.MoveToCell(0, i, 4, 0);
  4165. builder.Write("费用小计:");
  4166. builder.MoveToCell(0, i, 5, 0);
  4167. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4168. }
  4169. //删除多余行
  4170. while (table1.Rows.Count > dac1.Count)
  4171. {
  4172. table1.Rows.RemoveAt(dac1.Count);
  4173. }
  4174. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4175. for (int i = 0; i < dac2.Count; i++)
  4176. {
  4177. Grp_DayAndCost dac = dac2[i];
  4178. if (dac == null) continue;
  4179. builder.MoveToCell(1, i, 0, 0);
  4180. builder.Write("第" + dac.Days.ToString() + "天:");
  4181. builder.MoveToCell(1, i, 1, 0);
  4182. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4183. builder.MoveToCell(1, i, 2, 0);
  4184. builder.Write("费用标准:");
  4185. string curr = "";
  4186. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4187. if (currData != null)
  4188. {
  4189. curr = currData.Name;
  4190. }
  4191. builder.MoveToCell(1, i, 3, 0);
  4192. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4193. builder.MoveToCell(1, i, 4, 0);
  4194. builder.Write("费用小计:");
  4195. builder.MoveToCell(1, i, 5, 0);
  4196. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4197. }
  4198. //删除多余行
  4199. while (table2.Rows.Count > dac2.Count)
  4200. {
  4201. table2.Rows.RemoveAt(dac2.Count);
  4202. }
  4203. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4204. for (int i = 0; i < dac3.Count; i++)
  4205. {
  4206. Grp_DayAndCost dac = dac3[i];
  4207. if (dac == null) continue;
  4208. builder.MoveToCell(2, i, 0, 0);
  4209. builder.Write("第" + dac.Days.ToString() + "天:");
  4210. builder.MoveToCell(2, i, 1, 0);
  4211. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4212. builder.MoveToCell(2, i, 2, 0);
  4213. builder.Write("费用标准:");
  4214. string curr = "";
  4215. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4216. if (currData != null)
  4217. {
  4218. curr = currData.Name;
  4219. }
  4220. builder.MoveToCell(2, i, 3, 0);
  4221. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4222. builder.MoveToCell(2, i, 4, 0);
  4223. builder.Write("费用小计:");
  4224. builder.MoveToCell(2, i, 5, 0);
  4225. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4226. }
  4227. //删除多余行
  4228. while (table3.Rows.Count > dac3.Count)
  4229. {
  4230. table3.Rows.RemoveAt(dac3.Count);
  4231. }
  4232. #endregion
  4233. //文件名
  4234. //string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  4235. //string strFileName = $"{_DelegationInfo.TeamName}-出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  4236. string strFileName = $"{_DelegationInfo.TeamName}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileFormat}";
  4237. AsposeHelper.removewatermark_v2180();
  4238. //doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4239. var saveFormat = Aspose.Words.SaveFormat.Docx;
  4240. if (fileFormat.Equals("pdf"))
  4241. {
  4242. //doc.LayoutOptions.IsShowComments = false;
  4243. doc.LayoutOptions.IsShowHiddenText = false;
  4244. doc.LayoutOptions.IsShowParagraphMarks = false;
  4245. doc.LayoutOptions.RevisionOptions.DeletedTextEffect = RevisionTextEffect.None;
  4246. doc.AcceptAllRevisions();
  4247. Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
  4248. options.Compliance = PdfCompliance.PdfA1a;
  4249. options.CreateNoteHyperlinks = true;
  4250. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, options);
  4251. //_view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  4252. _view.Data = new { Url = strFileName };
  4253. _view.Msg = "成功";
  4254. return _view;
  4255. }
  4256. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, saveFormat);
  4257. _view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  4258. _view.Msg = "成功";
  4259. return _view;
  4260. }
  4261. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4262. {
  4263. //获取模板
  4264. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4265. //载入模板
  4266. Document doc = new Document(tempPath);
  4267. DocumentBuilder builder = new DocumentBuilder(doc);
  4268. Dictionary<string, string> dic = new Dictionary<string, string>();
  4269. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4270. {
  4271. List<string> list = new List<string>();
  4272. try
  4273. {
  4274. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4275. foreach (var item in spilitArr)
  4276. {
  4277. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4278. var depCode = spDotandEmpty[2].Substring(0, 3);
  4279. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4280. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4281. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4282. list.Add(depName);
  4283. list.Add(arrName);
  4284. }
  4285. list = list.Distinct().ToList();
  4286. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4287. }
  4288. catch (Exception)
  4289. {
  4290. dic.Add("ReturnCode", "行程录入不正确!");
  4291. }
  4292. }
  4293. else
  4294. {
  4295. dic.Add("ReturnCode", "未录入行程!");
  4296. }
  4297. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4298. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4299. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4300. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4301. {
  4302. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4303. dic.Add("Day", sp.Days.ToString());
  4304. }
  4305. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4306. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4307. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4308. //dic.Add("Names", Names);
  4309. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4310. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4311. decimal dac1totalPrice = 0.00M;
  4312. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4313. foreach (var dac in dac1)
  4314. {
  4315. if (dac.SubTotal == 0.00M)
  4316. {
  4317. continue;
  4318. }
  4319. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4320. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4321. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4322. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4323. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4324. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4325. builder.Write(currency);//币种
  4326. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4327. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4328. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4329. builder.Write("");//人数
  4330. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4331. builder.Write("");//天数
  4332. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4333. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4334. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4335. decimal rate = 0.00M;
  4336. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4337. builder.Write(rate.ToString("#0.0000"));//汇率
  4338. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4339. decimal rbmPrice = dac.SubTotal;
  4340. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4341. accommodationStartIndex++;
  4342. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4343. }
  4344. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4345. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4346. {
  4347. table1.Rows.RemoveAt(i - 1);
  4348. foodandotherStartIndex--;
  4349. }
  4350. if (dac2.Count == dac3.Count)//国家 币种 金额
  4351. {
  4352. for (int i = 0; i < dac2.Count; i++)
  4353. {
  4354. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4355. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4356. }
  4357. }
  4358. decimal dac2totalPrice = 0.00M;
  4359. foreach (var dac in dac2)
  4360. {
  4361. if (dac.SubTotal == 0)
  4362. {
  4363. continue;
  4364. }
  4365. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4366. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4367. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4368. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4369. builder.Write(currency);//币种
  4370. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4371. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4372. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4373. builder.Write("");//人数
  4374. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4375. builder.Write("");//天数
  4376. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4377. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4378. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4379. decimal rate = 0.00M;
  4380. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4381. builder.Write(rate.ToString("#0.0000"));//汇率
  4382. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4383. decimal rbmPrice = dac.SubTotal;
  4384. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4385. foodandotherStartIndex++;
  4386. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4387. }
  4388. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4389. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4390. {
  4391. table1.Rows.RemoveAt(i - 1);
  4392. }
  4393. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4394. string otherFeeStr = "";
  4395. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4396. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4397. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4398. if (otherFeeStr.Length > 0)
  4399. {
  4400. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4401. otherFeeStr = $"({otherFeeStr})";
  4402. dic.Add("OtherFeeStr", otherFeeStr);
  4403. }
  4404. //总计
  4405. decimal allPrice = dac1totalPrice + dac2totalPrice + enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket;
  4406. //国际旅费
  4407. string outsideJJ = "";
  4408. string allPriceJJ = "";
  4409. if (enterExitCosts.SumJJC == 1)
  4410. {
  4411. outsideJJ = string.Format(@"经济舱:{0} 元/人", enterExitCosts.AirJJ.ToString("#0.00"));
  4412. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + enterExitCosts.OutsideJJPay).ToString("#0.00"));
  4413. }
  4414. string outsideGW = "";
  4415. string allPriceGW = "";
  4416. if (enterExitCosts.SumGWC == 1)
  4417. {
  4418. outsideGW = string.Format(@"公务舱:{0} 元/人", enterExitCosts.AirGW.ToString("#0.00"));
  4419. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4420. }
  4421. if (enterExitCosts.SumJJC == 1 || enterExitCosts.SumGWC == 1)
  4422. {
  4423. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4424. dic.Add("InTravelPrice", InTravelPriceStr);
  4425. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4426. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4427. }
  4428. //dic.Add("VisaPay", enterExitCosts.Visa.ToString("#0.00"));
  4429. //dic.Add("SafePay", enterExitCosts.Safe.ToString("#0.00"));
  4430. //dic.Add("YiMiao", enterExitCosts.YiMiao.ToString("#0.00"));
  4431. foreach (var key in dic.Keys)
  4432. {
  4433. builder.MoveToBookmark(key);
  4434. builder.Write(dic[key]);
  4435. }
  4436. //模板文件名
  4437. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4438. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4439. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4440. _view.Data = new { Url = url };
  4441. _view.Msg = "成功";
  4442. return _view;
  4443. }
  4444. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4445. {
  4446. //获取模板
  4447. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4448. //载入模板
  4449. WorkbookDesigner designer = new WorkbookDesigner();
  4450. designer.Workbook = new Workbook(tempPath);
  4451. Dictionary<string, string> dic = new Dictionary<string, string>();
  4452. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4453. {
  4454. List<string> list = new List<string>();
  4455. try
  4456. {
  4457. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4458. foreach (var item in spilitArr)
  4459. {
  4460. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4461. var depCode = spDotandEmpty[2].Substring(0, 3);
  4462. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4463. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4464. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4465. list.Add(depName);
  4466. list.Add(arrName);
  4467. }
  4468. list = list.Distinct().ToList();
  4469. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4470. }
  4471. catch (Exception)
  4472. {
  4473. dic.Add("ReturnCode", "行程录入不正确!");
  4474. }
  4475. }
  4476. else
  4477. {
  4478. dic.Add("ReturnCode", "未录入行程!");
  4479. }
  4480. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4481. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4482. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4483. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4484. {
  4485. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4486. dic.Add("Day", sp.Days.ToString());
  4487. }
  4488. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4489. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4490. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4491. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4492. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4493. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4494. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4495. designer.SetDataSource("Name", Names);
  4496. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4497. designer.SetDataSource("Day", dic["Day"] + "天");
  4498. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4499. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4500. int startIndex = 10;
  4501. const int startIndexcopy = 10;
  4502. if (dac2.Count == dac3.Count)//国家 币种 金额
  4503. {
  4504. for (int i = 0; i < dac2.Count; i++)
  4505. {
  4506. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4507. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4508. }
  4509. }
  4510. DataTable dtdac1 = new DataTable();
  4511. List<string> place = new List<string>();
  4512. dtdac1.Columns.AddRange(new DataColumn[] {
  4513. new DataColumn(){ ColumnName = "city"},
  4514. new DataColumn(){ ColumnName = "curr"},
  4515. new DataColumn(){ ColumnName = "criterion"},
  4516. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4517. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4518. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4519. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4520. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4521. });
  4522. DataTable dtdac2 = new DataTable();
  4523. dtdac2.Columns.AddRange(new DataColumn[] {
  4524. new DataColumn(){ ColumnName = "city"},
  4525. new DataColumn(){ ColumnName = "curr"},
  4526. new DataColumn(){ ColumnName = "criterion"},
  4527. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4528. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4529. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4530. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4531. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4532. });
  4533. dtdac1.TableName = "tb1";
  4534. dtdac2.TableName = "tb2";
  4535. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4536. foreach (var item in dac1)
  4537. {
  4538. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4539. if (place.Contains(item.Place))
  4540. {
  4541. continue;
  4542. }
  4543. DataRow row = dtdac1.NewRow();
  4544. row["city"] = item.Place;
  4545. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4546. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4547. row["curr"] = currency;
  4548. row["rate"] = rate.ToString("#0.0000");
  4549. row["criterion"] = item.Cost.ToString("#0.00");
  4550. row["number"] = 1;
  4551. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4552. //row["costRMB"] = rbmPrice;
  4553. dtdac1.Rows.Add(row);
  4554. place.Add(item.Place);
  4555. }
  4556. place = new List<string>();
  4557. foreach (var item in dac2)
  4558. {
  4559. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4560. if (place.Contains(item.Place))
  4561. {
  4562. continue;
  4563. }
  4564. DataRow row = dtdac2.NewRow();
  4565. row["city"] = item.Place;
  4566. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4567. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4568. row["curr"] = currency;
  4569. row["rate"] = rate.ToString("#0.0000");
  4570. row["criterion"] = item.Cost.ToString("#0.00");
  4571. row["number"] = 1;
  4572. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4573. //row["cost"] = item.SubTotal;
  4574. //row["costRMB"] = rbmPrice;
  4575. dtdac2.Rows.Add(row);
  4576. place.Add(item.Place);
  4577. //dac2totalPrice += rbmPrice;
  4578. }
  4579. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4580. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4581. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4582. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4583. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {enterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4584. designer.SetDataSource("sumCityTranffic", @$"{enterExitCosts.CityTranffic.ToString("#0.00")} ");
  4585. string cell4Str = $" 4.国际旅费:经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{enterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4586. string cellStr = $" 5.其他费用(";
  4587. if (enterExitCosts.Visa > 0) cellStr += $"签证费:{enterExitCosts.Visa.ToString("#0.00")}元,";
  4588. if (enterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")}元,";
  4589. if (enterExitCosts.HeSuan > 0) cellStr += $"核酸费:{enterExitCosts.HeSuan.ToString("#0.00")}元,";
  4590. if (enterExitCosts.Safe > 0) cellStr += $"保险费:{enterExitCosts.Safe.ToString("#0.00")}元,";
  4591. if (enterExitCosts.Ticket > 0) cellStr += $"参展门票费:{enterExitCosts.Ticket.ToString("#0.00")}元,";
  4592. if (enterExitCosts.Service > 0) cellStr += $"服务费:{enterExitCosts.Service.ToString("#0.00")}元,";
  4593. if (cellStr.Length > 8)
  4594. {
  4595. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4596. }
  4597. cellStr += ")";
  4598. decimal otherFee = enterExitCosts.Visa + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.Service;
  4599. decimal s = dac1totalPrice + dac2totalPrice + enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay + otherFee;
  4600. decimal pxFee = dac4.Sum(it => it.Cost);
  4601. decimal glvFee = enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay;
  4602. string celllastStr1 = "";
  4603. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4604. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4605. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4606. celllastStr1 += $",国际旅费 元";
  4607. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4608. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4609. designer.SetDataSource("cell4Str", cell4Str);
  4610. designer.SetDataSource("cellStr", cellStr);
  4611. designer.SetDataSource("cellSum", (enterExitCosts.Visa + enterExitCosts.Safe).ToString("#0.00"));
  4612. designer.SetDataSource("cellSum4", (enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4613. designer.SetDataSource("celllastStr", celllastStr);
  4614. Workbook wb = designer.Workbook;
  4615. var sheet = wb.Worksheets[0];
  4616. //绑定datatable数据集
  4617. designer.SetDataSource(dtdac1);
  4618. designer.SetDataSource(dtdac2);
  4619. designer.Process();
  4620. var rowStart = dtdac1.Rows.Count;
  4621. while (rowStart > 0)
  4622. {
  4623. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4624. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4625. startIndex++;
  4626. rowStart--;
  4627. }
  4628. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4629. startIndex += 1; //总计行
  4630. rowStart = dtdac2.Rows.Count;
  4631. while (rowStart > 0)
  4632. {
  4633. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4634. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4635. startIndex++;
  4636. rowStart--;
  4637. }
  4638. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4639. wb.CalculateFormula(true);
  4640. //模板文件名
  4641. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4642. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4643. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4644. _view.Data = new { Url = url };
  4645. _view.Msg = "成功";
  4646. return _view;
  4647. }
  4648. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4649. {
  4650. //获取模板
  4651. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4652. //载入模板
  4653. Document doc = new Document(tempPath);
  4654. DocumentBuilder builder = new DocumentBuilder(doc);
  4655. Dictionary<string, string> dic = new Dictionary<string, string>();
  4656. dic.Add("GroupName", _DelegationInfo.TeamName);
  4657. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4658. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4659. string missionLeaderJob = "";//负责人job
  4660. //int groupNumber = 0; //团人数
  4661. if (DeleClientList.Count > 0)
  4662. {
  4663. missionLeader = DeleClientList[0]?.Name ?? "";
  4664. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4665. }
  4666. dic.Add("MissionLeader", missionLeader); //团负责人
  4667. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4668. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4669. #region MyRegion
  4670. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4671. //{
  4672. // List<string> list = new List<string>();
  4673. // try
  4674. // {
  4675. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4676. // foreach (var item in spilitArr)
  4677. // {
  4678. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4679. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4680. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4681. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4682. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4683. // list.Add(depName);
  4684. // list.Add(arrName);
  4685. // }
  4686. // list = list.Distinct().ToList();
  4687. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4688. // }
  4689. // catch (Exception)
  4690. // {
  4691. // dic.Add("ReturnCode", "行程录入不正确!");
  4692. // }
  4693. //}
  4694. //else
  4695. //{
  4696. // dic.Add("ReturnCode", "未录入行程!");
  4697. //}
  4698. List<string> countrys = _dirRep.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4699. dic.Add("ReturnCode", string.Join("、", countrys));
  4700. #endregion
  4701. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4702. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4703. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4704. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4705. //{
  4706. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4707. // dic.Add("Day", sp.Days.ToString());
  4708. //}
  4709. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4710. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4711. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4712. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4713. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4714. //培训人员名单
  4715. int cultivateRowIndex = 7;
  4716. foreach (var item in DeleClientList)
  4717. {
  4718. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4719. builder.Write(item.Name);
  4720. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4721. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4722. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4723. string birthDay = "";
  4724. if (item.Birthday != null)
  4725. {
  4726. DateTime dt = Convert.ToDateTime(item.Birthday);
  4727. birthDay = $"{dt.Year}.{dt.Month}";
  4728. }
  4729. builder.Write(birthDay);
  4730. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4731. builder.Write(item.Company);
  4732. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4733. builder.Write(item.Job);
  4734. cultivateRowIndex++;
  4735. }
  4736. //删除多余行
  4737. //cultivateRowIndex -= 2;
  4738. int delRows = 10 + 7 - cultivateRowIndex;
  4739. if (delRows > 0)
  4740. {
  4741. for (int i = 0; i < delRows; i++)
  4742. {
  4743. table1.Rows.RemoveAt(cultivateRowIndex);
  4744. //cultivateRowIndex++;
  4745. }
  4746. }
  4747. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4748. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4749. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4750. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4751. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4752. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4753. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4754. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4755. decimal cityTranfficFeeToatal = enterExitCosts.CityTranffic; //城市区间交通费
  4756. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4757. //其他费用
  4758. decimal otherFeeTotal = enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Service;
  4759. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4760. //其他费用合计
  4761. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4762. decimal _jjcFeeToatal = enterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4763. decimal _gwcFeeToatal = enterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4764. //公务舱合计
  4765. //国际旅费
  4766. //string outsideJJ = "";
  4767. //string allPriceJJ = "";
  4768. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 0)
  4769. {
  4770. dic.Add("AirFeeTotal", enterExitCosts.AirJJ.ToString("#0.00"));
  4771. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4772. }
  4773. if (enterExitCosts.SumGWC == 1 && enterExitCosts.SumJJC == 0)
  4774. {
  4775. dic.Add("AirFeeTotal", enterExitCosts.AirGW.ToString("#0.00"));
  4776. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4777. }
  4778. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 1)
  4779. {
  4780. string airFeeTotalStr = string.Format(@$"经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{enterExitCosts.AirGW.ToString("#0.00")}");
  4781. dic.Add("AirFeeTotal", airFeeTotalStr);
  4782. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4783. dic.Add("FeeTotal", feeTotalStr);
  4784. }
  4785. foreach (var key in dic.Keys)
  4786. {
  4787. builder.MoveToBookmark(key);
  4788. builder.Write(dic[key]);
  4789. }
  4790. //模板文件名
  4791. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4792. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4793. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4794. _view.Data = new { Url = url };
  4795. _view.Msg = "成功";
  4796. return _view;
  4797. }
  4798. }
  4799. else if (dto.ExportType == 2) //表格
  4800. {
  4801. //利用键值对存放数据
  4802. Dictionary<string, string> dic = new Dictionary<string, string>();
  4803. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4804. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4805. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4806. dic.Add("Day", sp.Days.ToString());
  4807. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4808. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4809. {
  4810. //获取模板
  4811. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4812. //载入模板
  4813. Document doc = new Document(tempPath);
  4814. DocumentBuilder builder = new DocumentBuilder(doc);
  4815. dic.Add("TeamName", _DelegationInfo.TeamName);
  4816. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4817. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4818. string missionLeaderName = "",
  4819. missionLeaderJob = "";
  4820. if (DeleClientList.Count > 0)
  4821. {
  4822. missionLeaderName = DeleClientList[0].Name;
  4823. missionLeaderJob = DeleClientList[0].Job;
  4824. }
  4825. dic.Add("MissionLeaderName", missionLeaderName);
  4826. dic.Add("MissionLeaderJob", missionLeaderJob);
  4827. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4828. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4829. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4830. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4831. int rowCount = 10;//总人数行
  4832. int startRowIndex = 7; //起始行
  4833. for (int i = 0; i < DeleClientList.Count; i++)
  4834. {
  4835. builder.MoveToCell(0, startRowIndex, 0, 0);
  4836. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4837. builder.MoveToCell(0, startRowIndex, 1, 0);
  4838. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4839. builder.Write(sex);//性别
  4840. builder.MoveToCell(0, startRowIndex, 2, 0);
  4841. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4842. builder.MoveToCell(0, startRowIndex, 3, 0);
  4843. builder.Write(DeleClientList[i].Company);//工作单位
  4844. builder.MoveToCell(0, startRowIndex, 4, 0);
  4845. builder.Write(DeleClientList[i].Job);//职务及级别
  4846. builder.MoveToCell(0, startRowIndex, 5, 0);
  4847. builder.Write("");//人员属性
  4848. builder.MoveToCell(0, startRowIndex, 6, 0);
  4849. builder.Write("");//上次出国时间
  4850. startRowIndex++;
  4851. }
  4852. int nullRow = rowCount - DeleClientList.Count;//空行
  4853. for (int i = 0; i < nullRow; i++)
  4854. {
  4855. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4856. }
  4857. foreach (var key in dic.Keys)
  4858. {
  4859. builder.MoveToBookmark(key);
  4860. builder.Write(dic[key]);
  4861. }
  4862. //模板文件名
  4863. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4864. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4865. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4866. _view.Data = new { Url = url };
  4867. _view.Msg = "成功";
  4868. return _view;
  4869. }
  4870. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4871. {
  4872. //获取模板
  4873. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4874. //载入模板
  4875. Document doc = new Document(tempPath);
  4876. DocumentBuilder builder = new DocumentBuilder(doc);
  4877. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4878. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4879. dic.Add("Names", Names);
  4880. int accommodationRows = 12, foodandotherRows = 12;
  4881. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4882. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4883. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4884. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4885. int accommodationStartIndex = 6;
  4886. decimal dac1totalPrice = 0.00M;
  4887. foreach (var dac in dac1)
  4888. {
  4889. if (dac.SubTotal == 0)
  4890. {
  4891. continue;
  4892. }
  4893. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4894. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4895. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4896. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4897. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4898. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4899. builder.Write(currency);//币种
  4900. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4901. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4902. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4903. builder.Write("");//人数
  4904. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4905. builder.Write("");//天数
  4906. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4907. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4908. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4909. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4910. builder.Write(rate.ToString("#0.0000"));//汇率
  4911. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4912. decimal rbmPrice = rate * dac.SubTotal;
  4913. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4914. accommodationStartIndex++;
  4915. dac1totalPrice += rbmPrice;
  4916. }
  4917. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4918. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4919. builder.Write("小计");
  4920. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4921. builder.Write(dac1totalPrice.ToString("#0.00"));
  4922. accommodationStartIndex++;
  4923. int nullRow = accommodationRows - dac1.Count;
  4924. //删除空行
  4925. //if (nullRow > 0)
  4926. //{
  4927. // int rowIndex = accommodationStartIndex;
  4928. // for (int i = 0; i < nullRow; i++)
  4929. // {
  4930. // Row row = table1.Rows[rowIndex];
  4931. // row.Remove();
  4932. // rowIndex++;
  4933. // }
  4934. //}
  4935. if (dac2.Count == dac3.Count)//国家 币种 金额
  4936. {
  4937. for (int i = 0; i < dac2.Count; i++)
  4938. {
  4939. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4940. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4941. }
  4942. }
  4943. int foodandotherStartIndex = 19;//
  4944. decimal dac2totalPrice = 0.00M;
  4945. foreach (var dac in dac2)
  4946. {
  4947. if (dac.SubTotal == 0)
  4948. {
  4949. continue;
  4950. }
  4951. //foodandotherStartIndex = 12;
  4952. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4953. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4954. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4955. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4956. builder.Write(currency);//币种
  4957. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4958. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4959. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4960. builder.Write("");//人数
  4961. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4962. builder.Write("");//天数
  4963. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4964. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4965. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4966. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4967. builder.Write(rate.ToString("#0.0000"));//汇率
  4968. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4969. decimal rbmPrice = rate * dac.SubTotal;
  4970. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4971. foodandotherStartIndex++;
  4972. dac2totalPrice += rbmPrice;
  4973. }
  4974. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4975. //删除空行
  4976. if (dac2.Count < foodandotherRows)
  4977. {
  4978. //int nullRow = accommodationRows - dac2.Count;
  4979. //while (table2.Rows.Count > dac2.Count)
  4980. //{
  4981. // table2.Rows.RemoveAt(dac2.Count);
  4982. //}
  4983. }
  4984. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4985. string otherFeeStr = "";
  4986. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4987. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4988. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4989. if (otherFeeStr.Length > 0)
  4990. {
  4991. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4992. otherFeeStr = $"({otherFeeStr})";
  4993. dic.Add("OtherFeeStr", otherFeeStr);
  4994. }
  4995. foreach (var key in dic.Keys)
  4996. {
  4997. builder.MoveToBookmark(key);
  4998. builder.Write(dic[key]);
  4999. }
  5000. //模板文件名
  5001. string strFileName = $"省级单位出(境)经费报销单.docx";
  5002. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5003. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5004. _view.Data = new { Url = url };
  5005. _view.Msg = "成功";
  5006. return _view;
  5007. }
  5008. }
  5009. else if (dto.ExportType == 3)
  5010. {
  5011. if (dto.SubTypeId == 1) //团组成员名单
  5012. {
  5013. if (DeleClientList.Count < 1)
  5014. {
  5015. _view.Msg = "团组成员暂未录入!!!";
  5016. return _view;
  5017. }
  5018. //获取模板
  5019. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5020. //载入模板
  5021. Document doc = new Document(tempPath);
  5022. DocumentBuilder builder = new DocumentBuilder(doc);
  5023. //获取word里所有表格
  5024. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5025. //获取所填表格的序数
  5026. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5027. var rowStart = tableOne.Rows[0]; //获取第1行
  5028. //循环赋值
  5029. for (int i = 0; i < DeleClientList.Count; i++)
  5030. {
  5031. builder.MoveToCell(0, i + 1, 0, 0);
  5032. builder.Write(DeleClientList[i].Name);
  5033. builder.MoveToCell(0, i + 1, 1, 0);
  5034. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5035. builder.Write(sex);
  5036. builder.MoveToCell(0, i + 1, 2, 0);
  5037. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5038. builder.MoveToCell(0, i + 1, 3, 0);
  5039. builder.Write(DeleClientList[i].Company);
  5040. builder.MoveToCell(0, i + 1, 4, 0);
  5041. builder.Write(DeleClientList[i].Job);
  5042. }
  5043. //删除多余行
  5044. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5045. {
  5046. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5047. }
  5048. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5049. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5050. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5051. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5052. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5053. _view.Data = new { Url = url };
  5054. _view.Msg = "成功";
  5055. return _view;
  5056. }
  5057. }
  5058. }
  5059. catch (Exception ex)
  5060. {
  5061. _view.Code = StatusCodes.Status500InternalServerError;
  5062. _view.Msg = ex.Message;
  5063. return _view;
  5064. }
  5065. return _view;
  5066. }
  5067. #endregion
  5068. #region 机票费用提示
  5069. /// <summary>
  5070. /// 三公机票费用提示
  5071. /// </summary>
  5072. /// <param name="diId"></param>
  5073. /// <returns></returns>
  5074. public static async Task<EntryAndExitTipsView[]> EntryAndExitTips(int diId)
  5075. {
  5076. if (diId < 1) return Array.Empty<EntryAndExitTipsView>();
  5077. var airFees = await _sqlSugar.Queryable<Air_TicketBlackCode>().Where(a => a.IsDel == 0 && a.DiId == diId).ToListAsync();
  5078. if (airFees.Any())
  5079. {
  5080. var result = new List<EntryAndExitTipsView>();
  5081. foreach (var x in airFees)
  5082. {
  5083. string tripDesc = "";
  5084. if (!string.IsNullOrEmpty(x.BlackCode))
  5085. {
  5086. var redisKeyName = string.Format("AirTripDesc_{0}_{1}", x.DiId, x.Id);
  5087. tripDesc = await KIMIAirTripCodeRec(redisKeyName, x.BlackCode);
  5088. }
  5089. result.Add(new EntryAndExitTipsView
  5090. {
  5091. jjcCurrentRate = x.ECPrice,
  5092. gwcCurrentRate = x.BCPrice,
  5093. tdcCurrentRate = x.FCPrice,
  5094. remark = $"经济舱全价:{x.ECPrice.ToString("#0.00")} 元/人 公务舱全价:{x.BCPrice.ToString("#0.00")} 元/人 头等舱全价:{x.FCPrice.ToString("#0.00")} 元/人",
  5095. TripDesc = tripDesc
  5096. });
  5097. }
  5098. return result.OrderByDescending(x => x.jjcCurrentRate + x.gwcCurrentRate + x.tdcCurrentRate).ToArray();
  5099. }
  5100. return Array.Empty<EntryAndExitTipsView>();
  5101. }
  5102. /// <summary>
  5103. /// 机票行程代码识别
  5104. /// </summary>
  5105. /// <param name="redisKeyName">redis缓存名称(名称定义格式:AirTripDesc_Diid_Id)</param>
  5106. /// <param name="msg"></param>
  5107. /// <returns></returns>
  5108. public static async Task<string> KIMIAirTripCodeRec(string redisKeyName, string msg)
  5109. {
  5110. string result = string.Empty;
  5111. if (!string.IsNullOrEmpty(redisKeyName))
  5112. {
  5113. result = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>(redisKeyName);//string 取
  5114. if (!string.IsNullOrEmpty(result)) return result;
  5115. }
  5116. if (string.IsNullOrEmpty(msg)) return result;
  5117. KiMiApiClient KiMiApi = new KiMiApiClient();
  5118. var kimiMsgs = new List<SeedMessages>() {
  5119. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  5120. new SeedMessages { Role = KimiRole.user, Content = "请将提供的三字码行程信息翻译成中文,每条信息独立一行,并在次日到达的时间后加上“+1”以表示次日。日期(星期)格式请按照“04月14日(星期一)”标注。航站楼信息请按照“T1”、“T2”、“ ”等格式标注。只输出正文数据,不要除正文数据外的任何文字以及符号。格式示例如下:\r\n1. CA445 05月17日(星期六) 成都天府 T1 - 米兰马尔彭萨 T1 01:50 06:55" },
  5121. new SeedMessages { Role = KimiRole.user, Content = msg }
  5122. };
  5123. var kimiApiResult = await KiMiApi.SeedMessage(kimiMsgs);
  5124. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  5125. result = kimiApiResult_JObject["content"].ToString();
  5126. if (!string.IsNullOrEmpty(result))
  5127. {
  5128. TimeSpan ts = TimeSpan.FromHours(2); //过期时间 2 小时
  5129. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>(redisKeyName, result, ts);//string 存
  5130. }
  5131. return result;
  5132. }
  5133. #endregion
  5134. #endregion
  5135. #region Excel导出服务
  5136. #region 类
  5137. public class FileExportSettings
  5138. {
  5139. public string ExportBasePath { get; set; } = "wwwroot/exports";
  5140. public string DownloadBaseUrl { get; set; } = "/exports";
  5141. public int RetentionDays { get; set; } = 7;
  5142. public int MaxFileSizeMB { get; set; } = 50;
  5143. public string ExcelTemplatesPath { get; set; } = "Templates/Excel";
  5144. }
  5145. public class ExportResult
  5146. {
  5147. public bool Success { get; set; }
  5148. public string FilePath { get; set; }
  5149. public string DownloadUrl { get; set; }
  5150. public string FileName { get; set; }
  5151. public long FileSize { get; set; }
  5152. public string MimeType { get; set; } = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  5153. public string ErrorMessage { get; set; }
  5154. public DateTime GeneratedAt { get; set; } = DateTime.Now;
  5155. }
  5156. public class ExportRequest
  5157. {
  5158. public IEnumerable<object> Data { get; set; }
  5159. public string FileName { get; set; }
  5160. public string SheetName { get; set; } = "Sheet1";
  5161. public string TemplateType { get; set; } = "default";
  5162. public Dictionary<string, string> CustomHeaders { get; set; }
  5163. }
  5164. public class ExportResponse
  5165. {
  5166. public string FilePath { get; set; }
  5167. public string DownloadUrl { get; set; }
  5168. public string FileName { get; set; }
  5169. public long FileSize { get; set; }
  5170. public DateTime GeneratedAt { get; set; }
  5171. public string Message { get; set; }
  5172. }
  5173. #endregion
  5174. public static async Task<ExportResult> ExportToExcel<T>(IEnumerable<T> data, string fileName, string sheetName = "Sheet1", string templateType = "default")
  5175. {
  5176. try
  5177. {
  5178. byte[] excelBytes = templateType.ToLower() switch
  5179. {
  5180. "styled" => GenerateStyledExcel(data, sheetName),
  5181. "with_formulas" => GenerateExcelWithFormulas(data, sheetName),
  5182. //"with_charts" => GenerateExcelWithCharts(data, sheetName),
  5183. _ => GenerateDefaultExcel(data, sheetName)
  5184. };
  5185. var filePath = await SaveFileAsync(excelBytes, fileName, "excel");
  5186. var downloadUrl = $"wwwroot/exports/{filePath}";
  5187. return new ExportResult
  5188. {
  5189. Success = true,
  5190. FilePath = filePath,
  5191. DownloadUrl = downloadUrl,
  5192. FileName = Path.GetFileName(filePath),
  5193. FileSize = excelBytes.Length,
  5194. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5195. };
  5196. }
  5197. catch (Exception ex)
  5198. {
  5199. return new ExportResult
  5200. {
  5201. Success = false,
  5202. ErrorMessage = ex.Message
  5203. };
  5204. }
  5205. }
  5206. public static async Task<ExportResult> ExportWithTemplate<T>(IEnumerable<T> data, byte[] templateBytes, string fileName, string sheetName = "Sheet1")
  5207. {
  5208. try
  5209. {
  5210. using var templateStream = new MemoryStream(templateBytes);
  5211. using var workbook = new Workbook(templateStream);
  5212. var worksheet = workbook.Worksheets[sheetName] ?? workbook.Worksheets[0];
  5213. // 查找数据起始行(可以根据模板中的标记来定位)
  5214. int startRow = FindDataStartRow(worksheet);
  5215. // 填充数据
  5216. FillWorksheetWithData(worksheet, data, startRow);
  5217. using var outputStream = new MemoryStream();
  5218. workbook.Save(outputStream, Aspose.Cells.SaveFormat.Xlsx);
  5219. var excelBytes = outputStream.ToArray();
  5220. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/templates");
  5221. var downloadUrl = $"wwwroot/exports/exports/{filePath}";
  5222. return new ExportResult
  5223. {
  5224. Success = true,
  5225. FilePath = filePath,
  5226. DownloadUrl = downloadUrl,
  5227. FileName = Path.GetFileName(filePath),
  5228. FileSize = excelBytes.Length,
  5229. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5230. };
  5231. }
  5232. catch (Exception ex)
  5233. {
  5234. return new ExportResult
  5235. {
  5236. Success = false,
  5237. ErrorMessage = ex.Message
  5238. };
  5239. }
  5240. }
  5241. public static async Task<ExportResult> ExportMultipleSheets<T>(Dictionary<string, IEnumerable<T>> sheetsData, string fileName)
  5242. {
  5243. try
  5244. {
  5245. using var workbook = new Workbook();
  5246. workbook.Worksheets.Clear(); // 清除默认工作表
  5247. foreach (var sheet in sheetsData)
  5248. {
  5249. var worksheet = workbook.Worksheets.Add(sheet.Key);
  5250. var data = sheet.Value;
  5251. if (data != null && data.Any())
  5252. {
  5253. FillWorksheetWithData(worksheet, data, 0);
  5254. worksheet.AutoFitColumns();
  5255. }
  5256. }
  5257. using var stream = new MemoryStream();
  5258. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5259. var excelBytes = stream.ToArray();
  5260. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/multi-sheets");
  5261. var downloadUrl = $"wwwroot/exports/exports/{filePath}";
  5262. return new ExportResult
  5263. {
  5264. Success = true,
  5265. FilePath = filePath,
  5266. DownloadUrl = downloadUrl,
  5267. FileName = Path.GetFileName(filePath),
  5268. FileSize = excelBytes.Length,
  5269. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5270. };
  5271. }
  5272. catch (Exception ex)
  5273. {
  5274. return new ExportResult
  5275. {
  5276. Success = false,
  5277. ErrorMessage = ex.Message
  5278. };
  5279. }
  5280. }
  5281. public static async Task<ExportResult> ExportWithCustomHeaders<T>(IEnumerable<T> data, Dictionary<string, string> headers, string fileName, string sheetName = "Sheet1")
  5282. {
  5283. try
  5284. {
  5285. using var workbook = new Workbook();
  5286. var worksheet = workbook.Worksheets[0];
  5287. worksheet.Name = sheetName;
  5288. // 设置自定义表头
  5289. int colIndex = 0;
  5290. foreach (var header in headers)
  5291. {
  5292. worksheet.Cells[0, colIndex].PutValue(header.Value);
  5293. colIndex++;
  5294. }
  5295. // 填充数据
  5296. if (data != null && data.Any())
  5297. {
  5298. int rowIndex = 1;
  5299. var properties = typeof(T).GetProperties();
  5300. foreach (var item in data)
  5301. {
  5302. colIndex = 0;
  5303. foreach (var header in headers)
  5304. {
  5305. var property = properties.FirstOrDefault(p => p.Name == header.Key);
  5306. if (property != null)
  5307. {
  5308. var value = property.GetValue(item);
  5309. worksheet.Cells[rowIndex, colIndex].PutValue(value);
  5310. }
  5311. colIndex++;
  5312. }
  5313. rowIndex++;
  5314. }
  5315. }
  5316. worksheet.AutoFitColumns();
  5317. using var stream = new MemoryStream();
  5318. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5319. var excelBytes = stream.ToArray();
  5320. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/custom-headers");
  5321. var downloadUrl = $"filePath";
  5322. return new ExportResult
  5323. {
  5324. Success = true,
  5325. FilePath = filePath,
  5326. DownloadUrl = downloadUrl,
  5327. FileName = Path.GetFileName(filePath),
  5328. FileSize = excelBytes.Length,
  5329. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5330. };
  5331. }
  5332. catch (Exception ex)
  5333. {
  5334. return new ExportResult
  5335. {
  5336. Success = false,
  5337. ErrorMessage = ex.Message
  5338. };
  5339. }
  5340. }
  5341. private static byte[] GenerateDefaultExcel<T>(IEnumerable<T> data, string sheetName)
  5342. {
  5343. using var workbook = new Workbook();
  5344. var worksheet = workbook.Worksheets[0];
  5345. worksheet.Name = sheetName;
  5346. if (data != null && data.Any())
  5347. {
  5348. FillWorksheetWithData(worksheet, data, 0);
  5349. worksheet.AutoFitColumns();
  5350. }
  5351. return SaveWorkbookToBytes(workbook);
  5352. }
  5353. private static byte[] GenerateStyledExcel<T>(IEnumerable<T> data, string sheetName)
  5354. {
  5355. using var workbook = new Workbook();
  5356. var worksheet = workbook.Worksheets[0];
  5357. worksheet.Name = sheetName;
  5358. if (data != null && data.Any())
  5359. {
  5360. FillWorksheetWithData(worksheet, data, 0);
  5361. // 设置样式
  5362. var headerStyle = workbook.CreateStyle();
  5363. headerStyle.Pattern = BackgroundType.Solid;
  5364. headerStyle.ForegroundColor = System.Drawing.Color.LightGray;
  5365. headerStyle.Font.IsBold = true;
  5366. headerStyle.HorizontalAlignment = TextAlignmentType.Center;
  5367. var properties = typeof(T).GetProperties();
  5368. Aspose.Cells.Range headerRange = worksheet.Cells.CreateRange(0, 0, 1, properties.Length);
  5369. headerRange.ApplyStyle(headerStyle, new StyleFlag { All = true });
  5370. worksheet.AutoFitColumns();
  5371. }
  5372. return SaveWorkbookToBytes(workbook);
  5373. }
  5374. private static byte[] GenerateExcelWithFormulas<T>(IEnumerable<T> data, string sheetName)
  5375. {
  5376. using var workbook = new Workbook();
  5377. var worksheet = workbook.Worksheets[0];
  5378. worksheet.Name = sheetName;
  5379. if (data != null && data.Any())
  5380. {
  5381. FillWorksheetWithData(worksheet, data, 0);
  5382. // 添加公式(例如:求和公式)
  5383. var properties = typeof(T).GetProperties();
  5384. int lastRow = data.Count() + 1;
  5385. for (int i = 0; i < properties.Length; i++)
  5386. {
  5387. if (IsNumericType(properties[i].PropertyType))
  5388. {
  5389. worksheet.Cells[lastRow, i].Formula = $"=SUM({worksheet.Cells[1, i].Name}:{worksheet.Cells[lastRow - 1, i].Name})";
  5390. }
  5391. }
  5392. worksheet.AutoFitColumns();
  5393. }
  5394. return SaveWorkbookToBytes(workbook);
  5395. }
  5396. private static void FillWorksheetWithData<T>(Worksheet worksheet, IEnumerable<T> data, int startRow)
  5397. {
  5398. var properties = typeof(T).GetProperties();
  5399. // 设置表头
  5400. for (int i = 0; i < properties.Length; i++)
  5401. {
  5402. worksheet.Cells[startRow, i].PutValue(properties[i].Name);
  5403. }
  5404. // 填充数据
  5405. int rowIndex = startRow + 1;
  5406. foreach (var item in data)
  5407. {
  5408. for (int colIndex = 0; colIndex < properties.Length; colIndex++)
  5409. {
  5410. var value = properties[colIndex].GetValue(item);
  5411. worksheet.Cells[rowIndex, colIndex].PutValue(value);
  5412. }
  5413. rowIndex++;
  5414. }
  5415. }
  5416. private static int FindDataStartRow(Worksheet worksheet)
  5417. {
  5418. // 在实际项目中,可以根据模板中的特定标记来定位数据起始行
  5419. // 例如查找 "{{DATA_START}}" 这样的标记
  5420. for (int row = 0; row < 50; row++)
  5421. {
  5422. for (int col = 0; col < 10; col++)
  5423. {
  5424. var value = worksheet.Cells[row, col].StringValue;
  5425. if (value == "{{DATA_START}}")
  5426. {
  5427. worksheet.Cells[row, col].PutValue(""); // 清空标记
  5428. return row + 1;
  5429. }
  5430. }
  5431. }
  5432. return 1; // 默认从第2行开始
  5433. }
  5434. private static byte[] SaveWorkbookToBytes(Workbook workbook)
  5435. {
  5436. using var stream = new MemoryStream();
  5437. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5438. return stream.ToArray();
  5439. }
  5440. private static bool IsNumericType(Type type)
  5441. {
  5442. return Type.GetTypeCode(type) switch
  5443. {
  5444. TypeCode.Byte or TypeCode.SByte or TypeCode.UInt16 or TypeCode.UInt32 or
  5445. TypeCode.UInt64 or TypeCode.Int16 or TypeCode.Int32 or TypeCode.Int64 or
  5446. TypeCode.Decimal or TypeCode.Double or TypeCode.Single => true,
  5447. _ => false
  5448. };
  5449. }
  5450. public static async Task<string> SaveFileAsync(byte[] fileData, string fileName, string subFolder = "")
  5451. {
  5452. try
  5453. {
  5454. var basePath = "wwwroot/exports/exports";
  5455. var folderPath = Path.Combine(basePath, subFolder);
  5456. Directory.CreateDirectory(folderPath);
  5457. var uniqueFileName = $"{Path.GetFileNameWithoutExtension(fileName)}_{Guid.NewGuid():N}{Path.GetExtension(fileName)}.xlsx";
  5458. var filePath = Path.Combine(folderPath, uniqueFileName);
  5459. await System.IO.File.WriteAllBytesAsync(filePath, fileData);
  5460. var relativePath = Path.Combine(basePath, subFolder, uniqueFileName).Replace("\\", "/");
  5461. return relativePath;
  5462. }
  5463. catch (Exception ex)
  5464. {
  5465. throw;
  5466. }
  5467. }
  5468. #endregion
  5469. #region 动态构架word表格
  5470. /// <summary>
  5471. /// 设置表格样式
  5472. /// </summary>
  5473. /// <param name="builder"></param>
  5474. public static void SetupDocumentStyles(DocumentBuilder builder)
  5475. {
  5476. builder.Font.Name = "微软雅黑";
  5477. builder.Font.Size = 10;
  5478. builder.ParagraphFormat.SpaceAfter = 0;
  5479. }
  5480. /// <summary>
  5481. /// 添加标题
  5482. /// </summary>
  5483. /// <param name="builder"></param>
  5484. /// <param name="title"></param>
  5485. public static void AddTitle(DocumentBuilder builder, string title)
  5486. {
  5487. // 主标题
  5488. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  5489. builder.Font.Size = 16;
  5490. builder.Font.Bold = true;
  5491. builder.Font.Color = System.Drawing.Color.DarkBlue;
  5492. builder.Writeln(title);
  5493. // 空行
  5494. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5495. builder.Font.Size = 10;
  5496. builder.Font.Bold = false;
  5497. builder.Font.Color = System.Drawing.Color.Black;
  5498. builder.Writeln();
  5499. }
  5500. /// <summary>
  5501. /// 生成酒机票表格信息
  5502. /// </summary>
  5503. /// <param name="builder"></param>
  5504. /// <param name="airInfos"></param>
  5505. /// <param name="footerText"></param>
  5506. public static void AddAirInfoSections(DocumentBuilder builder, List<Grp_AirTicketReservations> airInfos, string? footerText)
  5507. {
  5508. if (airInfos == null || !airInfos.Any())
  5509. {
  5510. builder.Writeln("暂无机票航班信息。");
  5511. return;
  5512. }
  5513. int airCount = 0;
  5514. const int maxAirPerPage = 3; // 每页最多显示3个酒店,确保有足够空间
  5515. for (int i = 0; i < airInfos.Count; i++)
  5516. {
  5517. var info = airInfos[i];
  5518. // 检查是否需要分页
  5519. if (airCount > 0 && airCount > maxAirPerPage)
  5520. {
  5521. builder.InsertBreak(BreakType.PageBreak);
  5522. airCount = 0;
  5523. }
  5524. airCount++;
  5525. // 为每个酒店创建详细信息表格
  5526. CreateAirDetailTable(builder, info);
  5527. // 酒店之间添加间距,但不是最后一个
  5528. if (i < airInfos.Count() - 1)
  5529. {
  5530. AddSpacingBetweenHotels(builder);
  5531. }
  5532. // 检查是否达到每页最大酒店数量
  5533. if (airCount >= maxAirPerPage && (i < airInfos.Count - 1 || i < airInfos.Count() - 1))
  5534. {
  5535. builder.InsertBreak(BreakType.PageBreak);
  5536. airCount = 0;
  5537. }
  5538. }
  5539. if (!string.IsNullOrEmpty(footerText))
  5540. {
  5541. AddFooter(builder, footerText);
  5542. }
  5543. }
  5544. /// <summary>
  5545. /// 生成酒店表格信息
  5546. /// </summary>
  5547. /// <param name="builder"></param>
  5548. /// <param name="hotelInfos"></param>
  5549. /// <param name="footerText"></param>
  5550. public static void AddHotelInfoSections(DocumentBuilder builder, List<Grp_HotelReservations> hotelInfos, string? footerText)
  5551. {
  5552. if (hotelInfos == null || !hotelInfos.Any())
  5553. {
  5554. builder.Writeln("暂无酒店信息");
  5555. return;
  5556. }
  5557. int hotelCount = 0;
  5558. const int maxHotelsPerPage = 3; // 每页最多显示3个酒店,确保有足够空间
  5559. for (int i = 0; i < hotelInfos.Count; i++)
  5560. {
  5561. var info = hotelInfos[i];
  5562. // 检查是否需要分页
  5563. if (hotelCount > 0 && hotelCount > maxHotelsPerPage)
  5564. {
  5565. builder.InsertBreak(BreakType.PageBreak);
  5566. hotelCount = 0;
  5567. }
  5568. hotelCount++;
  5569. AddCityHeader(builder, info.City);
  5570. // 为每个酒店创建详细信息表格
  5571. CreateHotelDetailTable(builder, info);
  5572. // 酒店之间添加间距,但不是最后一个
  5573. if (i < hotelInfos.Count() - 1)
  5574. {
  5575. AddSpacingBetweenHotels(builder);
  5576. }
  5577. // 检查是否达到每页最大酒店数量
  5578. if (hotelCount >= maxHotelsPerPage && (i < hotelInfos.Count - 1 || i < hotelInfos.Count() - 1))
  5579. {
  5580. builder.InsertBreak(BreakType.PageBreak);
  5581. hotelCount = 0;
  5582. }
  5583. }
  5584. if (!string.IsNullOrEmpty(footerText))
  5585. {
  5586. AddFooter(builder, footerText);
  5587. }
  5588. }
  5589. private static void AddSpacingBetweenHotels(DocumentBuilder builder)
  5590. {
  5591. builder.Writeln();
  5592. builder.InsertBreak(BreakType.LineBreak);
  5593. }
  5594. private static void AddCityHeader(DocumentBuilder builder, string cityName)
  5595. {
  5596. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5597. builder.Font.Size = 14;
  5598. builder.Font.Bold = true;
  5599. builder.Font.Color = System.Drawing.Color.DarkGreen;
  5600. builder.Writeln($"城市:{cityName}");
  5601. builder.Font.Size = 10;
  5602. builder.Font.Bold = false;
  5603. builder.Font.Color = System.Drawing.Color.Black;
  5604. }
  5605. private static void CreateHotelDetailTable(DocumentBuilder builder, Grp_HotelReservations hotel)
  5606. {
  5607. // 设置表格不允许跨页断行,确保整个表格在一页上
  5608. Table table = builder.StartTable();
  5609. //table.AllowBreakAcrossPages = false; // 关键设置:不允许表格跨页
  5610. // 设置表格样式
  5611. ApplyTableStyle(table);
  5612. // 添加酒店基本信息行
  5613. AddTableRow(builder, "酒店名称", hotel.HotelName ?? "-", true);
  5614. AddTableRow(builder, "联系电话", hotel.HotelTel ?? "-");
  5615. AddTableRow(builder, "酒店地址", hotel.HotelAddress ?? "-");
  5616. AddTableRow(builder, "确认号码", hotel.DetermineNo ?? "-");
  5617. AddTableRow(builder, "入住日期", hotel.CheckInDate);
  5618. AddTableRow(builder, "离店日期", hotel.CheckOutDate);
  5619. AddTableRow(builder, "房间信息", hotel.RoomExplanation ?? "-");
  5620. builder.EndTable();
  5621. }
  5622. private static void CreateAirDetailTable(DocumentBuilder builder, Grp_AirTicketReservations air)
  5623. {
  5624. // 设置表格不允许跨页断行,确保整个表格在一页上
  5625. Table table = builder.StartTable();
  5626. //table.AllowBreakAcrossPages = false; // 关键设置:不允许表格跨页
  5627. // 设置表格样式
  5628. ApplyTableStyle(table);
  5629. // 添加酒店基本信息行
  5630. AddTableRow(builder, "城市(A-B)", air.FlightsCity ?? "-", true);
  5631. AddTableRow(builder, "航班日期", air.FlightsDate + " " + air.FlightsTime ?? "-");
  5632. AddTableRow(builder, "机票票号", air.TicketNumber ?? "-");
  5633. AddTableRow(builder, "航班简述", air.FlightsCode ?? "-");
  5634. AddTableRow(builder, "航班描述", air.FlightsDescription);
  5635. builder.EndTable();
  5636. }
  5637. private static void AddTableRow(DocumentBuilder builder, string title, string value, bool isHeaderRow = false)
  5638. {
  5639. // 左边单元格 - 标题
  5640. builder.InsertCell();
  5641. //builder.CellFormat.BackColor = isHeaderRow ? System.Drawing.Color.LightBlue : System.Drawing.Color.LightGray;
  5642. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  5643. builder.CellFormat.Width = 60;
  5644. builder.Font.Bold = true;
  5645. builder.Font.Size = isHeaderRow ? 12 : 10;
  5646. builder.Font.Color = isHeaderRow ? System.Drawing.Color.DarkBlue : System.Drawing.Color.Black;
  5647. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  5648. builder.Write(title);
  5649. // 右边单元格 - 值
  5650. builder.InsertCell();
  5651. //builder.CellFormat.BackColor = System.Drawing.Color.White;
  5652. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  5653. builder.CellFormat.Width = 200;
  5654. builder.Font.Bold = isHeaderRow;
  5655. builder.Font.Size = isHeaderRow ? 12 : 10;
  5656. builder.Font.Color = System.Drawing.Color.Black;
  5657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5658. builder.Write(value);
  5659. builder.EndRow();
  5660. // 重置单元格格式(除了宽度)
  5661. //builder.CellFormat.BackColor = System.Drawing.Color.White;
  5662. builder.Font.Bold = false;
  5663. builder.Font.Size = 10;
  5664. builder.Font.Color = System.Drawing.Color.Black;
  5665. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5666. }
  5667. private static void ApplyTableStyle(Table table)
  5668. {
  5669. try
  5670. {
  5671. // 设置表格边框
  5672. table.SetBorders(LineStyle.Single, 1.0, System.Drawing.Color.Gray);
  5673. // 设置表格属性
  5674. table.LeftPadding = 5;
  5675. table.RightPadding = 5;
  5676. table.TopPadding = 3;
  5677. table.BottomPadding = 3;
  5678. table.Alignment = TableAlignment.Left;
  5679. table.AllowAutoFit = false;
  5680. //table.AllowBreakAcrossPages = true;
  5681. // 设置表格宽度
  5682. table.PreferredWidth = PreferredWidth.FromPoints(400);
  5683. // 设置列宽
  5684. if (table.FirstRow != null && table.FirstRow.Cells.Count == 2)
  5685. {
  5686. table.FirstRow.Cells[0].CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
  5687. table.FirstRow.Cells[1].CellFormat.PreferredWidth = PreferredWidth.FromPercent(80);
  5688. }
  5689. }
  5690. catch (Exception ex)
  5691. {
  5692. //_logger.LogWarning(ex, "设置表格样式时发生错误");
  5693. }
  5694. }
  5695. private static void AddFooter(DocumentBuilder builder, string footerText)
  5696. {
  5697. builder.InsertBreak(BreakType.ParagraphBreak);
  5698. builder.Writeln();
  5699. builder.Writeln();
  5700. // 添加分隔线
  5701. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  5702. builder.Font.Size = 8;
  5703. builder.Font.Color = System.Drawing.Color.LightGray;
  5704. //builder.Writeln("────────────────────────────────────");
  5705. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  5706. builder.Font.Size = 9;
  5707. builder.Font.Italic = true;
  5708. builder.Font.Color = System.Drawing.Color.Gray;
  5709. builder.Writeln(footerText);
  5710. builder.Writeln($"文档生成时间:{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
  5711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5712. builder.Font.Size = 10;
  5713. builder.Font.Italic = false;
  5714. builder.Font.Color = System.Drawing.Color.Black;
  5715. }
  5716. }
  5717. #endregion
  5718. }