GeneralMethod.cs 290 KB

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