GeneralMethod.cs 312 KB

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